Use deliverablesRef + limited poll for post-task server docs; pass reconnectRunId across auto-retry; GetRun reads idempotency_key; StartClaimedRun fails closed on UpdateRun; MessageBubble/E2E scope this-turn assistant; correct audit retry/schema19 wording. Co-authored-by: Cursor <cursoragent@cursor.com>
43 lines
1.7 KiB
TypeScript
43 lines
1.7 KiB
TypeScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import {
|
|
resolveReconnectRunId,
|
|
shouldSubscribeExistingRun,
|
|
isRemoteTaskTerminal,
|
|
nextAttemptOpts,
|
|
} from './taskRunReconnect';
|
|
|
|
test('resolveReconnectRunId prefers explicit opts and ignores attempt without opts', () => {
|
|
assert.equal(
|
|
resolveReconnectRunId({ attemptIndex: 1, optsReconnectRunId: 'run_abc' }),
|
|
'run_abc',
|
|
);
|
|
assert.equal(resolveReconnectRunId({ attemptIndex: 0, optsReconnectRunId: null }), undefined);
|
|
assert.equal(resolveReconnectRunId({ attemptIndex: 2, optsReconnectRunId: ' ' }), undefined);
|
|
assert.equal(resolveReconnectRunId({ attemptIndex: 3 }), undefined);
|
|
});
|
|
|
|
test('shouldSubscribeExistingRun only for in-flight statuses', () => {
|
|
assert.equal(shouldSubscribeExistingRun('running'), true);
|
|
assert.equal(shouldSubscribeExistingRun('pending'), true);
|
|
assert.equal(shouldSubscribeExistingRun('completed'), false);
|
|
assert.equal(shouldSubscribeExistingRun('failed'), false);
|
|
});
|
|
|
|
test('isRemoteTaskTerminal covers confirmation and quality_failed', () => {
|
|
assert.equal(isRemoteTaskTerminal('pending_author_confirmation'), true);
|
|
assert.equal(isRemoteTaskTerminal('completed'), true);
|
|
assert.equal(isRemoteTaskTerminal('quality_failed'), true);
|
|
assert.equal(isRemoteTaskTerminal('running'), false);
|
|
});
|
|
|
|
test('nextAttemptOpts carries retained runId for reconnect without new POST', () => {
|
|
const next = nextAttemptOpts<{ reconnectRunId?: string; workDir?: string }>(
|
|
{ workDir: '/w' },
|
|
'run_keep',
|
|
);
|
|
assert.equal(next.reconnectRunId, 'run_keep');
|
|
assert.equal(next.workDir, '/w');
|
|
assert.equal(nextAttemptOpts(undefined, undefined).reconnectRunId, undefined);
|
|
});
|