@jskit-ai/assistant-core 0.1.240 → 0.1.242
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/examples/conversation/package.json +5 -5
- package/package.json +5 -5
- package/src/client/conversation/AssistantTranscript.vue +26 -29
- package/src/client/conversation/LongTextPreviewBlocks.vue +11 -0
- package/src/client/conversation/messageDelivery.js +8 -2
- package/src/client/conversation/useAssistantAttachments.js +1 -1
- package/src/server/conversation/agentRun.js +12 -198
- package/src/server/conversation/attachments.js +6 -5
- package/src/server/conversation/boundedToolLoop.js +160 -0
- package/src/server/conversation/claudeHistory.js +37 -23
- package/src/server/conversation/claudeProcess.js +2 -2
- package/src/server/conversation/claudeTurn.js +41 -38
- package/src/server/conversation/codexAuthPreflight.js +104 -0
- package/src/server/conversation/codexClient.js +11 -16
- package/src/server/conversation/codexConfiguration.js +112 -98
- package/src/server/conversation/codexConversationStore.js +189 -0
- package/src/server/conversation/codexConversations.js +47 -44
- package/src/server/conversation/codexDetachedTurn.js +12 -11
- package/src/server/conversation/codexEvents.js +95 -99
- package/src/server/conversation/codexHelperExecution.js +3 -13
- package/src/server/conversation/codexHelperThreadLedger.js +7 -13
- package/src/server/conversation/codexHelperThreadRecovery.js +2 -16
- package/src/server/conversation/codexHelperThreads.js +5 -6
- package/src/server/conversation/codexHistoryAdapter.js +32 -26
- package/src/server/conversation/codexMessageCommands.js +22 -22
- package/src/server/conversation/codexMessageDelivery.js +12 -7
- package/src/server/conversation/codexModelCatalog.js +97 -0
- package/src/server/conversation/codexNotificationObserver.js +24 -40
- package/src/server/conversation/codexNotificationQueue.js +2 -3
- package/src/server/conversation/codexOutput.js +20 -27
- package/src/server/conversation/codexProcess.js +123 -127
- package/src/server/conversation/codexProcessLeader.js +3 -3
- package/src/server/conversation/codexProvider.js +31 -614
- package/src/server/conversation/codexProviderOwner.js +2 -2
- package/src/server/conversation/codexProviderSelection.js +38 -40
- package/src/server/conversation/codexRenewalCommands.js +13 -10
- package/src/server/conversation/codexRenewalThreads.js +412 -0
- package/src/server/conversation/codexRunJournal.js +24 -42
- package/src/server/conversation/codexRuntimeLifecycle.js +19 -15
- package/src/server/conversation/codexSessionCleanup.js +11 -10
- package/src/server/conversation/codexSessionReconciliation.js +6 -6
- package/src/server/conversation/codexThreadReadiness.js +19 -33
- package/src/server/conversation/codexThreadStatus.js +3 -3
- package/src/server/conversation/codexTurn.js +124 -297
- package/src/server/conversation/codexTurnRecovery.js +49 -28
- package/src/server/conversation/codexTurnState.js +34 -13
- package/src/server/conversation/commandWrapper.js +3 -0
- package/src/server/conversation/deliveryTiming.js +14 -5
- package/src/server/conversation/index.js +1 -0
- package/src/server/conversation/localExecution.js +13 -17
- package/src/server/conversation/normalize.js +8 -3
- package/src/server/conversation/openCodeClient.js +9 -10
- package/src/server/conversation/openCodeProcess.js +9 -5
- package/src/server/conversation/openCodeRuntime.js +10 -11
- package/src/server/conversation/openCodeTurn.js +43 -29
- package/src/server/conversation/providers/claudeDriver.js +8 -16
- package/src/server/conversation/providers/codexDriver.js +25 -41
- package/src/server/conversation/providers/opencodeDriver.js +17 -42
- package/src/server/conversation/providers/scoped.js +48 -4
- package/src/server/conversation/runtime.js +50 -49
- package/src/server/conversation/runtimeStateUpgrade.js +34 -22
- package/src/server/conversation/transcript.js +10 -10
- package/src/server/hosts/codexConfiguration.js +1 -0
- package/src/server/hosts/codexProvider.js +8 -6
- package/src/server/index.js +2 -1
- package/src/server/lib/assistantToolLoop.js +1 -153
- package/src/server/lib/serviceToolCatalog.js +17 -42
- package/src/shared/assistantResource.js +4 -2
- package/src/shared/conversation/attachments.js +4 -0
- package/src/shared/conversation/longTextBlocks.js +54 -19
- package/src/shared/conversation/numberedQuestionSugar.js +17 -10
- package/src/shared/conversation/pagination.js +4 -6
- package/src/shared/conversation/patches.js +1 -4
- package/src/shared/conversation/streaming.js +3 -11
- package/src/shared/conversation/turns.js +11 -0
- package/src/shared/index.js +1 -0
- package/test/assistantBoundedToolLoop.test.js +2 -2
- package/test/assistantResource.test.js +4 -4
- package/test/assistantSettingsResource.test.js +2 -2
- package/test/claudeConversationSession.test.js +11 -1
- package/test/claudeTurn.test.js +35 -7
- package/test/codexClient.test.js +20 -0
- package/test/codexConversationSession.test.js +2 -2
- package/test/codexConversationsCheckpoint.test.js +51 -0
- package/test/codexModelCatalog.test.js +1 -1
- package/test/codexProviderHome.test.js +51 -0
- package/test/codexProviderSelection.test.js +71 -0
- package/test/codexTurn.test.js +222 -6
- package/test/conversationAgentRun.test.js +2 -1
- package/test/conversationAttachments.test.js +27 -2
- package/test/conversationDeliveryTiming.test.js +21 -0
- package/test/conversationNormalize.test.js +11 -0
- package/test/fixtures/nestedListQuestionMessage.md +37 -0
- package/test/frameworkActions.test.js +2 -2
- package/test/longTextBlocks.test.js +102 -0
- package/test/messageDelivery.test.js +7 -1
- package/test/openCodeClient.test.js +20 -0
- package/test/openCodeRuntime.test.js +1 -1
- package/test/openCodeTurn.test.js +90 -0
- package/test/opencodeConversationSession.test.js +1 -1
- package/test/serviceToolCatalog.test.js +27 -0
|
@@ -64,8 +64,7 @@ export { createCodexAppServerDetachedTurnWatcher, waitForCodexAppServerTurn } fr
|
|
|
64
64
|
export { createCodexAppServerNotificationQueue } from "./codexNotificationQueue.js";
|
|
65
65
|
import {
|
|
66
66
|
assertCodexAppServerHelperAccountIdentity,
|
|
67
|
-
createCodexHelperOwnershipError
|
|
68
|
-
readCodexAppServerAccountIdentity
|
|
67
|
+
createCodexHelperOwnershipError
|
|
69
68
|
} from "./codexHelperExecution.js";
|
|
70
69
|
export { sendPreparedCodexAppServerHelperTurn } from "./codexHelperExecution.js";
|
|
71
70
|
import { createCodexHelperThreadLifecycle } from "./codexHelperThreads.js";
|
|
@@ -168,19 +167,11 @@ export function createCodexAppServerRunOwner({
|
|
|
168
167
|
modelCatalogCacheMs,
|
|
169
168
|
errorPrefix
|
|
170
169
|
});
|
|
171
|
-
const {
|
|
172
|
-
ensureCodexAppServerProviderForActiveTurn,
|
|
173
|
-
acquireCodexAppServerOutputProvider,
|
|
174
|
-
codexAppServerRuntimeForVisibleTerminal,
|
|
175
|
-
codexAppServerMessageContext,
|
|
176
|
-
codexAppServerControlContext,
|
|
177
|
-
codexAppServerObservationRecoveryContext
|
|
178
|
-
} = codexProviderSelection;
|
|
179
170
|
const acquireOutputProvider = providerSessions?.outputContext
|
|
180
171
|
? async ({ sessionId, runtime, session }) => {
|
|
181
172
|
const prepared = await providerSessions.outputContext({ sessionId, runtime, session });
|
|
182
173
|
if (!prepared) return null;
|
|
183
|
-
return acquireCodexAppServerOutputProvider(
|
|
174
|
+
return codexProviderSelection.acquireCodexAppServerOutputProvider(
|
|
184
175
|
sessionId, session, prepared.managedIdentity, prepared.providerOptions
|
|
185
176
|
);
|
|
186
177
|
}
|
|
@@ -202,31 +193,6 @@ export function createCodexAppServerRunOwner({
|
|
|
202
193
|
messageMetadata,
|
|
203
194
|
snapshotRecoveryItemLimit
|
|
204
195
|
});
|
|
205
|
-
const {
|
|
206
|
-
finalizedTurns: codexAppServerFinalizedTurns,
|
|
207
|
-
finalAssistantResults: codexAppServerFinalAssistantResults,
|
|
208
|
-
reasoningTurns: codexAppServerReasoningTurns,
|
|
209
|
-
reasoningPersistQueues: codexAppServerReasoningPersistQueues,
|
|
210
|
-
liveProgressItems: codexAppServerLiveProgressItems,
|
|
211
|
-
liveProgressFingerprints: codexAppServerLiveProgressFingerprints,
|
|
212
|
-
mirroredTerminalItems: codexAppServerMirroredTerminalItems,
|
|
213
|
-
resultFinalizationKey: codexAppServerResultFinalizationKey,
|
|
214
|
-
liveProgressCandidate: codexAppServerLiveProgressCandidate,
|
|
215
|
-
conversationMessageId: codexAppServerConversationMessageId,
|
|
216
|
-
readAgentRunForSession: readCodexAppServerAgentRunForSession,
|
|
217
|
-
readFinalAssistantResult: readCodexAppServerFinalAssistantResult,
|
|
218
|
-
persistAssistantReply: persistCodexAppServerAssistantReply,
|
|
219
|
-
recordFinalAssistantResult: recordCodexAppServerFinalAssistantResult,
|
|
220
|
-
recordReasoningForSession: recordCodexAppServerReasoningForSession,
|
|
221
|
-
flushReasoningPersist: flushCodexAppServerReasoningPersist,
|
|
222
|
-
splitReasoningTurn: splitCodexAppServerReasoningTurn,
|
|
223
|
-
cleanupUntrackedTurn: cleanupCodexAppServerUntrackedTurn,
|
|
224
|
-
streamMessage: codexAppServerStreamMessage,
|
|
225
|
-
writeStream: writeCodexAppServerStream,
|
|
226
|
-
writeLiveProgress: writeCodexAppServerLiveProgress,
|
|
227
|
-
submitAssistantResult: submitCodexAppServerAssistantResult,
|
|
228
|
-
reconcileObservedTurnItems: reconcileCodexAppServerObservedTurnItems
|
|
229
|
-
} = codexAppServerOutput;
|
|
230
196
|
|
|
231
197
|
const codexRunJournal = createCodexRunJournal({
|
|
232
198
|
namespace,
|
|
@@ -247,25 +213,6 @@ export function createCodexAppServerRunOwner({
|
|
|
247
213
|
admissionTaskFinished,
|
|
248
214
|
orphanedPromptMessage
|
|
249
215
|
});
|
|
250
|
-
const {
|
|
251
|
-
completedTurns: codexAppServerCompletedTurns,
|
|
252
|
-
processedTurns: codexAppServerProcessedTurns,
|
|
253
|
-
activeTimers: codexAppServerActiveTimers,
|
|
254
|
-
finalizingTimers: codexAppServerFinalizingTimers,
|
|
255
|
-
turnResultWasProcessed: codexAppServerTurnResultWasProcessed,
|
|
256
|
-
claimTurnStart: claimCodexAppServerTurnStart,
|
|
257
|
-
claimMessageStart: claimCodexAppServerMessageStart,
|
|
258
|
-
writeAgentRun: writeCodexAppServerAgentRun,
|
|
259
|
-
clearActiveTimer: clearCodexAppServerActiveTimer,
|
|
260
|
-
clearFinalizingTimer: clearCodexAppServerFinalizingTimer,
|
|
261
|
-
clearSessionRecoveryTimers: clearCodexAppServerSessionRecoveryTimers,
|
|
262
|
-
agentRunRealtimePayload: codexAppServerAgentRunRealtimePayload,
|
|
263
|
-
publishAgentRun: publishCodexAppServerAgentRun,
|
|
264
|
-
markTurnFinalizing: markCodexAppServerTurnFinalizing,
|
|
265
|
-
markTurnIdle: markCodexAppServerTurnIdle,
|
|
266
|
-
resolveTurnId: resolveCodexAppServerTurnId,
|
|
267
|
-
writeUserMessageOwnership: writeCodexAppServerUserMessageOwnership
|
|
268
|
-
} = codexRunJournal;
|
|
269
216
|
|
|
270
217
|
const codexResultSettlement = createCodexResultSettlement({
|
|
271
218
|
journal: codexRunJournal,
|
|
@@ -276,12 +223,6 @@ export function createCodexAppServerRunOwner({
|
|
|
276
223
|
debugError,
|
|
277
224
|
turnState
|
|
278
225
|
});
|
|
279
|
-
const {
|
|
280
|
-
resultFinalizations: codexAppServerResultFinalizations,
|
|
281
|
-
finalizeAssistantResult: finalizeCodexAppServerAssistantResult,
|
|
282
|
-
recoverFinalResponseBeforeOutcome: recoverCodexAppServerFinalResponseBeforeOutcome,
|
|
283
|
-
adoptSuccessorTurn: adoptCodexAppServerSuccessorTurn
|
|
284
|
-
} = codexResultSettlement;
|
|
285
226
|
|
|
286
227
|
const codexTurnRecovery = createCodexTurnRecovery({
|
|
287
228
|
journal: codexRunJournal,
|
|
@@ -308,13 +249,6 @@ export function createCodexAppServerRunOwner({
|
|
|
308
249
|
outcomeNotice,
|
|
309
250
|
resultDeliveryFailureMessage
|
|
310
251
|
});
|
|
311
|
-
const {
|
|
312
|
-
scheduleActiveRecovery: scheduleCodexAppServerActiveRecovery,
|
|
313
|
-
markTurnActive: markCodexAppServerTurnActive,
|
|
314
|
-
recoverActiveTurn: recoverCodexAppServerActiveTurn,
|
|
315
|
-
completeTurn: completeCodexAppServerTurn,
|
|
316
|
-
stopTurnWithProviderFailure: stopCodexAppServerTurnWithProviderFailure
|
|
317
|
-
} = codexTurnRecovery;
|
|
318
252
|
|
|
319
253
|
const codexThreadStatus = createCodexThreadStatus({
|
|
320
254
|
journal: codexRunJournal,
|
|
@@ -327,10 +261,6 @@ export function createCodexAppServerRunOwner({
|
|
|
327
261
|
debugLog,
|
|
328
262
|
debugError
|
|
329
263
|
});
|
|
330
|
-
const {
|
|
331
|
-
reconcileThreadStatus: reconcileCodexAppServerThreadStatus,
|
|
332
|
-
reconcileLoadedThreadStatus: reconcileCodexAppServerLoadedThreadStatus
|
|
333
|
-
} = codexThreadStatus;
|
|
334
264
|
|
|
335
265
|
const codexMessageDelivery = createCodexAppServerMessageDelivery({
|
|
336
266
|
namespace,
|
|
@@ -343,13 +273,6 @@ export function createCodexAppServerRunOwner({
|
|
|
343
273
|
journal: codexRunJournal,
|
|
344
274
|
recovery: codexTurnRecovery
|
|
345
275
|
});
|
|
346
|
-
const {
|
|
347
|
-
messageDeliveries: codexAppServerMessageDeliveries,
|
|
348
|
-
pendingUserMessages: codexAppServerPendingUserMessages,
|
|
349
|
-
withMessageDelivery: withCodexAppServerMessageDelivery,
|
|
350
|
-
writeDeliveredUserMessage: writeCodexAppServerDeliveredUserMessage,
|
|
351
|
-
mirrorTerminalUserMessage: mirrorCodexAppServerTerminalUserMessage
|
|
352
|
-
} = codexMessageDelivery;
|
|
353
276
|
|
|
354
277
|
const codexNotificationObserver = createCodexNotificationObserver({
|
|
355
278
|
journal: codexRunJournal,
|
|
@@ -367,15 +290,6 @@ export function createCodexAppServerRunOwner({
|
|
|
367
290
|
onNotificationSignal,
|
|
368
291
|
turnStateFromAgentRun
|
|
369
292
|
});
|
|
370
|
-
const {
|
|
371
|
-
eventSubscriptions: codexAppServerEventSubscriptions,
|
|
372
|
-
automaticHookThreads: codexAppServerAutomaticHookThreads,
|
|
373
|
-
eventSubscriptionKey: codexAppServerEventSubscriptionKey,
|
|
374
|
-
eventSubscriptionIsCurrent: codexAppServerEventSubscriptionIsCurrent,
|
|
375
|
-
unsubscribeEventSubscription: unsubscribeCodexAppServerEventSubscription,
|
|
376
|
-
reconcileGoalUpdated: reconcileCodexAppServerGoalUpdated,
|
|
377
|
-
subscribeEvents: subscribeCodexAppServerEvents
|
|
378
|
-
} = codexNotificationObserver;
|
|
379
293
|
|
|
380
294
|
const codexThreadReadiness = createCodexThreadReadiness({
|
|
381
295
|
providerSessions,
|
|
@@ -387,58 +301,24 @@ export function createCodexAppServerRunOwner({
|
|
|
387
301
|
debugLog,
|
|
388
302
|
debugError
|
|
389
303
|
});
|
|
390
|
-
const {
|
|
391
|
-
threadReconciliations: codexAppServerThreadReconciliations,
|
|
392
|
-
ensureThreadReady: ensureCodexAppServerThreadReady,
|
|
393
|
-
reconcileThread: reconcileCodexAppServerThreadForSession,
|
|
394
|
-
waitForThreadReconciliations: waitForOtherCodexAppServerThreadReconciliations,
|
|
395
|
-
checkManagedConnection: checkCodexAppServerManagedConnection,
|
|
396
|
-
restoreLoadedThread: restoreCodexAppServerLoadedThread
|
|
397
|
-
} = codexThreadReadiness;
|
|
398
304
|
|
|
399
305
|
const codexConversations = createCodexConversationCommands({
|
|
400
306
|
checkpoint,
|
|
401
|
-
codexAppServerConversationMessageId,
|
|
402
|
-
codexAppServerStreamMessage,
|
|
307
|
+
codexAppServerConversationMessageId: codexAppServerOutput.conversationMessageId,
|
|
308
|
+
codexAppServerStreamMessage: codexAppServerOutput.streamMessage,
|
|
403
309
|
conversationPreparation,
|
|
404
|
-
ensureCodexAppServerProviderForActiveTurn,
|
|
310
|
+
ensureCodexAppServerProviderForActiveTurn: codexProviderSelection.ensureCodexAppServerProviderForActiveTurn,
|
|
405
311
|
errorPrefix,
|
|
406
312
|
helperLifecycle,
|
|
407
313
|
helperOwnershipError,
|
|
408
314
|
interruptFailedCode,
|
|
409
315
|
namespace,
|
|
410
316
|
providerSessions,
|
|
411
|
-
|
|
317
|
+
sessionConnection: codexProviderSelection.sessionConnection,
|
|
318
|
+
ensureSessionProvider: codexProviderSelection.ensureSessionProvider,
|
|
319
|
+
steerFailedCode,
|
|
320
|
+
turnOutcomes
|
|
412
321
|
});
|
|
413
|
-
const {
|
|
414
|
-
codexAppServerConversations,
|
|
415
|
-
codexAppServerConversationTurnStarts,
|
|
416
|
-
codexAppServerConversation,
|
|
417
|
-
withCodexAppServerConversationTurnStart,
|
|
418
|
-
observeCodexConversation,
|
|
419
|
-
readPersistentCodexConversation,
|
|
420
|
-
codexAppServerEphemeralConversationSnapshot,
|
|
421
|
-
prepareCodexAppServerConversationThread,
|
|
422
|
-
codexAppServerConversationContext,
|
|
423
|
-
codexAppServerEphemeralScopeContext,
|
|
424
|
-
createCodexAppServerConversation,
|
|
425
|
-
runDetachedCodexAppServerConversation,
|
|
426
|
-
startCodexAppServerConversationTurn,
|
|
427
|
-
readCodexAppServerConversation,
|
|
428
|
-
waitForCodexAppServerConversationTurn,
|
|
429
|
-
stopCodexAppServerConversation,
|
|
430
|
-
deleteScopedCodexAppServerConversation,
|
|
431
|
-
closeCodexAppServerConversations,
|
|
432
|
-
interruptDetachedCodexAppServerConversationTurn,
|
|
433
|
-
deleteDetachedCodexAppServerConversationThread,
|
|
434
|
-
steerCodexAppServerConversationTurn,
|
|
435
|
-
acquireCodexAppServerDetachedThread,
|
|
436
|
-
codexAppServerDetachedThreadId,
|
|
437
|
-
dispatchCodexAppServerDetachedTurn,
|
|
438
|
-
runDetachedCodexAppServerTurn,
|
|
439
|
-
interruptCodexAppServerConversation,
|
|
440
|
-
stopPersistentCodexConversation
|
|
441
|
-
} = codexConversations;
|
|
442
322
|
|
|
443
323
|
const codexObservationControl = createCodexObservationControl({
|
|
444
324
|
conversations: codexConversations,
|
|
@@ -451,11 +331,6 @@ export function createCodexAppServerRunOwner({
|
|
|
451
331
|
turnState,
|
|
452
332
|
errorPrefix
|
|
453
333
|
});
|
|
454
|
-
const {
|
|
455
|
-
assertThreadCanResume: assertCodexAppServerThreadCanResume,
|
|
456
|
-
createObservation: createCodexAppServerObservation,
|
|
457
|
-
recoverObservationLoss: recoverCodexAppServerObservationLoss
|
|
458
|
-
} = codexObservationControl;
|
|
459
334
|
|
|
460
335
|
const codexTurnControl = createCodexTurnControl({
|
|
461
336
|
journal: codexRunJournal,
|
|
@@ -469,7 +344,6 @@ export function createCodexAppServerRunOwner({
|
|
|
469
344
|
turnOutcomes,
|
|
470
345
|
turnState
|
|
471
346
|
});
|
|
472
|
-
const { interruptTurn: interruptCodexAppServerTurn } = codexTurnControl;
|
|
473
347
|
|
|
474
348
|
const codexMessageCommands = createCodexMessageCommands({
|
|
475
349
|
output: codexAppServerOutput,
|
|
@@ -493,47 +367,34 @@ export function createCodexAppServerRunOwner({
|
|
|
493
367
|
turnAlreadyRunningError,
|
|
494
368
|
turnState
|
|
495
369
|
});
|
|
496
|
-
const {
|
|
497
|
-
selectMessageTurn: selectCodexAppServerMessageTurn,
|
|
498
|
-
dispatchMessage: dispatchCodexAppServerMessage,
|
|
499
|
-
startTurn: startCodexAppServerTurn,
|
|
500
|
-
steerTurn: steerCodexAppServerTurn
|
|
501
|
-
} = codexMessageCommands;
|
|
502
370
|
|
|
503
|
-
const {
|
|
504
|
-
|
|
505
|
-
runCodexAppServerRenewalSeed
|
|
506
|
-
} = createCodexRenewalCommands({
|
|
507
|
-
claimCodexAppServerTurnStart,
|
|
371
|
+
const codexRenewalCommands = createCodexRenewalCommands({
|
|
372
|
+
claimCodexAppServerTurnStart: codexRunJournal.claimTurnStart,
|
|
508
373
|
codexAppServerNotificationQueue,
|
|
509
|
-
completeCodexAppServerTurn,
|
|
374
|
+
completeCodexAppServerTurn: codexTurnRecovery.completeTurn,
|
|
510
375
|
errorPrefix,
|
|
511
|
-
markCodexAppServerTurnActive,
|
|
512
|
-
markCodexAppServerTurnIdle,
|
|
376
|
+
markCodexAppServerTurnActive: codexTurnRecovery.markTurnActive,
|
|
377
|
+
markCodexAppServerTurnIdle: codexRunJournal.markTurnIdle,
|
|
513
378
|
observer: codexNotificationObserver,
|
|
514
379
|
selection: codexProviderSelection,
|
|
515
380
|
turnAlreadyRunningError,
|
|
516
|
-
writeCodexAppServerUserMessageOwnership
|
|
381
|
+
writeCodexAppServerUserMessageOwnership: codexRunJournal.writeUserMessageOwnership
|
|
517
382
|
});
|
|
518
383
|
|
|
519
|
-
const {
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
updateCodexAppServerGoal
|
|
523
|
-
} = createCodexGoalCommands({
|
|
524
|
-
conversationContext: codexAppServerConversationContext,
|
|
525
|
-
ensureThreadReady: ensureCodexAppServerThreadReady,
|
|
384
|
+
const codexGoalCommands = createCodexGoalCommands({
|
|
385
|
+
conversationContext: codexConversations.codexAppServerConversationContext,
|
|
386
|
+
ensureThreadReady: codexThreadReadiness.ensureThreadReady,
|
|
526
387
|
publish,
|
|
527
|
-
readCodexAppServerAgentRunForSession,
|
|
528
|
-
reconcileCodexAppServerGoalUpdated,
|
|
529
|
-
submitCodexAppServerAssistantResult,
|
|
530
|
-
subscribeCodexAppServerEvents,
|
|
388
|
+
readCodexAppServerAgentRunForSession: codexAppServerOutput.readAgentRunForSession,
|
|
389
|
+
reconcileCodexAppServerGoalUpdated: codexNotificationObserver.reconcileGoalUpdated,
|
|
390
|
+
submitCodexAppServerAssistantResult: codexAppServerOutput.submitAssistantResult,
|
|
391
|
+
subscribeCodexAppServerEvents: codexNotificationObserver.subscribeEvents,
|
|
531
392
|
turnState
|
|
532
393
|
});
|
|
533
394
|
|
|
534
395
|
function recoverSessionObservationLoss(sessionId, runtime, session, preparation) {
|
|
535
|
-
return
|
|
536
|
-
codexAppServerObservationRecoveryContext(sessionId, preparation));
|
|
396
|
+
return codexObservationControl.recoverObservationLoss(runtime, session,
|
|
397
|
+
codexProviderSelection.codexAppServerObservationRecoveryContext(sessionId, preparation));
|
|
537
398
|
}
|
|
538
399
|
|
|
539
400
|
async function ensureSessionReadiness(sessionId, prepared) {
|
|
@@ -546,7 +407,7 @@ export function createCodexAppServerRunOwner({
|
|
|
546
407
|
turn = turnState(session);
|
|
547
408
|
}
|
|
548
409
|
if (!turn.active) {
|
|
549
|
-
const recovered = await
|
|
410
|
+
const recovered = await codexAppServerOutput.submitAssistantResult(sessionId, turn.threadId, turn.turnId, { recoverFromProvider: true });
|
|
550
411
|
if (recovered.reason === "error") throw new Error(recovered.error);
|
|
551
412
|
}
|
|
552
413
|
// A verified stop is a usable composer state, not a reconnect loop.
|
|
@@ -557,18 +418,18 @@ export function createCodexAppServerRunOwner({
|
|
|
557
418
|
if (threadId && connection.available && turnState(session).state !== "starting") {
|
|
558
419
|
const providerKey = codexProviderSelection.managedProviderKeyForThread(sessionId, workdir, threadId);
|
|
559
420
|
if (providerKey !== null) {
|
|
560
|
-
const observed = await
|
|
421
|
+
const observed = await codexThreadReadiness.checkManagedConnection(providerKey, { reconnect: false });
|
|
561
422
|
if (!observed.requiresPreparation) {
|
|
562
423
|
return prepared.ready(threadId);
|
|
563
424
|
}
|
|
564
425
|
}
|
|
565
426
|
}
|
|
566
|
-
return prepared.prepare(
|
|
427
|
+
return prepared.prepare(codexThreadReadiness.ensureThreadReady);
|
|
567
428
|
}
|
|
568
429
|
|
|
569
430
|
async function readExecutionProfileModelCatalog(sessionId, preparation) {
|
|
570
431
|
if (preparation.assistantScope) {
|
|
571
|
-
const context = await codexAppServerEphemeralScopeContext(
|
|
432
|
+
const context = await codexConversations.codexAppServerEphemeralScopeContext(
|
|
572
433
|
sessionId, { agentSettings: preparation.agentSettings }, preparation.assistantScope
|
|
573
434
|
);
|
|
574
435
|
if (context.ok === false) return context;
|
|
@@ -583,153 +444,105 @@ export function createCodexAppServerRunOwner({
|
|
|
583
444
|
|
|
584
445
|
const runOwner = {
|
|
585
446
|
helperThreads: helperLifecycle,
|
|
586
|
-
readAccountIdentity: provider => readCodexAppServerAccountIdentity(provider, helperOwnershipError),
|
|
587
447
|
assertAccountIdentity: (provider, expectedSignature) => assertCodexAppServerHelperAccountIdentity(
|
|
588
448
|
provider, expectedSignature, helperOwnershipError
|
|
589
449
|
),
|
|
590
|
-
checkManagedConnection: checkCodexAppServerManagedConnection,
|
|
591
450
|
ensureSessionReadiness,
|
|
592
|
-
|
|
593
|
-
restoreLoadedThread: restoreCodexAppServerLoadedThread,
|
|
594
|
-
reconcileThread: reconcileCodexAppServerThreadForSession,
|
|
595
|
-
threadReconciliations: codexAppServerThreadReconciliations,
|
|
596
|
-
waitForThreadReconciliations: waitForOtherCodexAppServerThreadReconciliations,
|
|
597
|
-
conversations: codexAppServerConversations,
|
|
451
|
+
conversations: codexConversations.codexAppServerConversations,
|
|
598
452
|
hasActiveTemporaryConversation: codexConversations.hasActiveConversation,
|
|
599
453
|
readExecutionProfileModelCatalog,
|
|
600
454
|
readProviderAccountIdentity: codexProviderSelection.readProviderAccountIdentity,
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
stopPersistentConversation: stopPersistentCodexConversation,
|
|
626
|
-
waitForConversationTurn: waitForCodexAppServerConversationTurn,
|
|
627
|
-
withMessageDelivery: withCodexAppServerMessageDelivery,
|
|
628
|
-
dispatchMessage: dispatchCodexAppServerMessage,
|
|
629
|
-
ensureThreadReady: ensureCodexAppServerThreadReady,
|
|
630
|
-
messageContext: codexAppServerMessageContext,
|
|
631
|
-
outputProvider: acquireCodexAppServerOutputProvider,
|
|
632
|
-
runtimeForVisibleTerminal: codexAppServerRuntimeForVisibleTerminal,
|
|
633
|
-
controlContext: codexAppServerControlContext,
|
|
634
|
-
observationRecoveryContext: codexAppServerObservationRecoveryContext,
|
|
635
|
-
claimMessageStart: claimCodexAppServerMessageStart,
|
|
636
|
-
assertThreadCanResume: assertCodexAppServerThreadCanResume,
|
|
455
|
+
conversation: codexConversations.codexAppServerConversation,
|
|
456
|
+
readPersistentConversation: codexConversations.readPersistentCodexConversation,
|
|
457
|
+
createConversation: codexConversations.createCodexAppServerConversation,
|
|
458
|
+
runDetachedConversation: codexConversations.runDetachedCodexAppServerConversation,
|
|
459
|
+
startConversationTurn: codexConversations.startCodexAppServerConversationTurn,
|
|
460
|
+
acquireDetachedThread: codexConversations.acquireCodexAppServerDetachedThread,
|
|
461
|
+
detachedThreadId: codexConversations.codexAppServerDetachedThreadId,
|
|
462
|
+
dispatchDetachedTurn: codexConversations.dispatchCodexAppServerDetachedTurn,
|
|
463
|
+
runDetachedTurn: codexConversations.runDetachedCodexAppServerTurn,
|
|
464
|
+
deleteConversation: codexConversations.deleteScopedCodexAppServerConversation,
|
|
465
|
+
readConversation: codexConversations.readCodexAppServerConversation,
|
|
466
|
+
stopConversation: codexConversations.stopCodexAppServerConversation,
|
|
467
|
+
conversationContext: codexConversations.codexAppServerConversationContext,
|
|
468
|
+
prepareConversationThread: codexConversations.prepareCodexAppServerConversationThread,
|
|
469
|
+
interruptDetachedTurn: codexConversations.interruptDetachedCodexAppServerConversationTurn,
|
|
470
|
+
deleteDetachedThread: codexConversations.deleteDetachedCodexAppServerConversationThread,
|
|
471
|
+
stopPersistentConversation: codexConversations.stopPersistentCodexConversation,
|
|
472
|
+
waitForConversationTurn: codexConversations.waitForCodexAppServerConversationTurn,
|
|
473
|
+
withMessageDelivery: codexMessageDelivery.withMessageDelivery,
|
|
474
|
+
dispatchMessage: codexMessageCommands.dispatchMessage,
|
|
475
|
+
ensureThreadReady: codexThreadReadiness.ensureThreadReady,
|
|
476
|
+
runtimeForVisibleTerminal: codexProviderSelection.codexAppServerRuntimeForVisibleTerminal,
|
|
477
|
+
controlContext: codexProviderSelection.codexAppServerControlContext,
|
|
478
|
+
assertThreadCanResume: codexObservationControl.assertThreadCanResume,
|
|
637
479
|
createObservation(sessionId, context = {}) {
|
|
638
|
-
if (!providerSessions) return
|
|
480
|
+
if (!providerSessions) return codexObservationControl.createObservation(sessionId, context);
|
|
639
481
|
const { providerKey } = context;
|
|
640
|
-
return
|
|
482
|
+
return codexObservationControl.createObservation(sessionId, {
|
|
641
483
|
...context,
|
|
642
484
|
retireProvider: () => runOwner.runtimeLifecycle.retireProvider(providerKey)
|
|
643
485
|
});
|
|
644
486
|
},
|
|
645
|
-
selectMessageTurn:
|
|
646
|
-
interruptTurn:
|
|
647
|
-
recoverObservationLoss:
|
|
648
|
-
runRenewalHandover: runCodexAppServerRenewalHandover,
|
|
649
|
-
runRenewalSeed: runCodexAppServerRenewalSeed,
|
|
650
|
-
startTurn:
|
|
651
|
-
steerTurn:
|
|
652
|
-
prepareGoalContext: prepareCodexAppServerGoalContext,
|
|
653
|
-
validateGoalInput: validateCodexAppServerGoalInput,
|
|
654
|
-
updateGoal: updateCodexAppServerGoal,
|
|
487
|
+
selectMessageTurn: codexMessageCommands.selectMessageTurn,
|
|
488
|
+
interruptTurn: codexTurnControl.interruptTurn,
|
|
489
|
+
recoverObservationLoss: codexObservationControl.recoverObservationLoss,
|
|
490
|
+
runRenewalHandover: codexRenewalCommands.runCodexAppServerRenewalHandover,
|
|
491
|
+
runRenewalSeed: codexRenewalCommands.runCodexAppServerRenewalSeed,
|
|
492
|
+
startTurn: codexMessageCommands.startTurn,
|
|
493
|
+
steerTurn: codexMessageCommands.steerTurn,
|
|
494
|
+
prepareGoalContext: codexGoalCommands.prepareCodexAppServerGoalContext,
|
|
495
|
+
validateGoalInput: codexGoalCommands.validateCodexAppServerGoalInput,
|
|
496
|
+
updateGoal: codexGoalCommands.updateCodexAppServerGoal,
|
|
655
497
|
notificationQueue: codexAppServerNotificationQueue,
|
|
656
|
-
messageDeliveries:
|
|
657
|
-
pendingUserMessages:
|
|
658
|
-
eventSubscriptions:
|
|
659
|
-
completedTurns: codexAppServerCompletedTurns,
|
|
498
|
+
messageDeliveries: codexMessageDelivery.messageDeliveries,
|
|
499
|
+
pendingUserMessages: codexMessageDelivery.pendingUserMessages,
|
|
500
|
+
eventSubscriptions: codexNotificationObserver.eventSubscriptions,
|
|
660
501
|
promptDeliveries: codexAppServerPromptDeliveries,
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
finalizedTurns: codexAppServerFinalizedTurns,
|
|
693
|
-
finalAssistantResults: codexAppServerFinalAssistantResults,
|
|
694
|
-
reasoningTurns: codexAppServerReasoningTurns,
|
|
695
|
-
reasoningPersistQueues: codexAppServerReasoningPersistQueues,
|
|
696
|
-
liveProgressItems: codexAppServerLiveProgressItems,
|
|
697
|
-
liveProgressFingerprints: codexAppServerLiveProgressFingerprints,
|
|
698
|
-
mirroredTerminalItems: codexAppServerMirroredTerminalItems,
|
|
699
|
-
liveProgressCandidate: codexAppServerLiveProgressCandidate,
|
|
700
|
-
conversationMessageId: codexAppServerConversationMessageId,
|
|
701
|
-
readAgentRunForSession: readCodexAppServerAgentRunForSession,
|
|
702
|
-
readFinalAssistantResult: readCodexAppServerFinalAssistantResult,
|
|
703
|
-
persistAssistantReply: persistCodexAppServerAssistantReply,
|
|
704
|
-
recordFinalAssistantResult: recordCodexAppServerFinalAssistantResult,
|
|
705
|
-
recordReasoningForSession: recordCodexAppServerReasoningForSession,
|
|
706
|
-
flushReasoningPersist: flushCodexAppServerReasoningPersist,
|
|
707
|
-
splitReasoningTurn: splitCodexAppServerReasoningTurn,
|
|
708
|
-
cleanupUntrackedTurn: cleanupCodexAppServerUntrackedTurn,
|
|
709
|
-
writeStream: writeCodexAppServerStream,
|
|
710
|
-
writeLiveProgress: writeCodexAppServerLiveProgress,
|
|
711
|
-
submitAssistantResult: submitCodexAppServerAssistantResult,
|
|
712
|
-
processedTurns: codexAppServerProcessedTurns,
|
|
713
|
-
resultFinalizationKey: codexAppServerResultFinalizationKey,
|
|
714
|
-
turnResultWasProcessed: codexAppServerTurnResultWasProcessed,
|
|
715
|
-
claimTurnStart: claimCodexAppServerTurnStart,
|
|
716
|
-
writeAgentRun: writeCodexAppServerAgentRun
|
|
502
|
+
unsubscribeEventSubscription: codexNotificationObserver.unsubscribeEventSubscription,
|
|
503
|
+
scheduleActiveRecovery: codexTurnRecovery.scheduleActiveRecovery,
|
|
504
|
+
reconcileThreadStatus: codexThreadStatus.reconcileThreadStatus,
|
|
505
|
+
mirrorTerminalUserMessage: codexMessageDelivery.mirrorTerminalUserMessage,
|
|
506
|
+
recoverActiveTurn: codexTurnRecovery.recoverActiveTurn,
|
|
507
|
+
completeTurn: codexTurnRecovery.completeTurn,
|
|
508
|
+
stopTurnWithProviderFailure: codexTurnRecovery.stopTurnWithProviderFailure,
|
|
509
|
+
writeDeliveredUserMessage: codexMessageDelivery.writeDeliveredUserMessage,
|
|
510
|
+
subscribeEvents: codexNotificationObserver.subscribeEvents,
|
|
511
|
+
activeTimers: codexRunJournal.activeTimers,
|
|
512
|
+
finalizingTimers: codexRunJournal.finalizingTimers,
|
|
513
|
+
resultFinalizations: codexResultSettlement.resultFinalizations,
|
|
514
|
+
clearSessionRecoveryTimers: codexRunJournal.clearSessionRecoveryTimers,
|
|
515
|
+
publishAgentRun: codexRunJournal.publishAgentRun,
|
|
516
|
+
markTurnIdle: codexRunJournal.markTurnIdle,
|
|
517
|
+
finalizeAssistantResult: codexResultSettlement.finalizeAssistantResult,
|
|
518
|
+
finalizedTurns: codexAppServerOutput.finalizedTurns,
|
|
519
|
+
liveProgressItems: codexAppServerOutput.liveProgressItems,
|
|
520
|
+
liveProgressFingerprints: codexAppServerOutput.liveProgressFingerprints,
|
|
521
|
+
readAgentRunForSession: codexAppServerOutput.readAgentRunForSession,
|
|
522
|
+
readFinalAssistantResult: codexAppServerOutput.readFinalAssistantResult,
|
|
523
|
+
persistAssistantReply: codexAppServerOutput.persistAssistantReply,
|
|
524
|
+
recordFinalAssistantResult: codexAppServerOutput.recordFinalAssistantResult,
|
|
525
|
+
recordReasoningForSession: codexAppServerOutput.recordReasoningForSession,
|
|
526
|
+
writeStream: codexAppServerOutput.writeStream,
|
|
527
|
+
writeLiveProgress: codexAppServerOutput.writeLiveProgress,
|
|
528
|
+
submitAssistantResult: codexAppServerOutput.submitAssistantResult,
|
|
529
|
+
processedTurns: codexRunJournal.processedTurns,
|
|
530
|
+
resultFinalizationKey: codexAppServerOutput.resultFinalizationKey,
|
|
531
|
+
claimTurnStart: codexRunJournal.claimTurnStart,
|
|
532
|
+
writeAgentRun: codexRunJournal.writeAgentRun
|
|
717
533
|
};
|
|
718
|
-
const cleanup = createCodexSessionCleanup({
|
|
719
|
-
namespace,
|
|
720
|
-
runOwner,
|
|
721
|
-
providerSessions,
|
|
722
|
-
helperLifecycle,
|
|
723
|
-
journal: codexRunJournal,
|
|
724
|
-
conversations: codexConversations,
|
|
725
|
-
debugLog,
|
|
726
|
-
debugError
|
|
727
|
-
});
|
|
728
|
-
runOwner.closeSession = cleanup.closeSession;
|
|
729
|
-
runOwner.closeProject = cleanup.closeProject;
|
|
730
534
|
if (providerSessions) {
|
|
731
535
|
runOwner.runtimeLifecycle = createCodexRuntimeLifecycle({
|
|
732
|
-
|
|
536
|
+
pendingWork: {
|
|
537
|
+
conversationTurnStarts: codexConversations.codexAppServerConversationTurnStarts,
|
|
538
|
+
messageDeliveries: codexMessageDelivery.messageDeliveries,
|
|
539
|
+
reasoningPersistQueues: codexAppServerOutput.reasoningPersistQueues,
|
|
540
|
+
resultFinalizations: codexResultSettlement.resultFinalizations,
|
|
541
|
+
threadReconciliations: codexThreadReadiness.threadReconciliations,
|
|
542
|
+
notificationTasks: codexAppServerNotificationQueue.tasks
|
|
543
|
+
},
|
|
544
|
+
observer: codexNotificationObserver,
|
|
545
|
+
checkManagedConnection: codexThreadReadiness.checkManagedConnection,
|
|
733
546
|
providerSessions,
|
|
734
547
|
helperLifecycle,
|
|
735
548
|
captureContext,
|
|
@@ -744,9 +557,23 @@ export function createCodexAppServerRunOwner({
|
|
|
744
557
|
}
|
|
745
558
|
runOwner.invalidateRuntimes = runOwner.runtimeLifecycle.invalidateRuntimes;
|
|
746
559
|
Object.assign(runOwner, createCodexSessionReconciliation({
|
|
747
|
-
|
|
560
|
+
readiness: codexThreadReadiness, recoverSessionObservationLoss,
|
|
561
|
+
providerSessions, helperLifecycle, lifecycle: runOwner.runtimeLifecycle,
|
|
748
562
|
createRuntime, namespace, turnState, sessionIdRequiredError, debugLog, debugError
|
|
749
563
|
}));
|
|
750
564
|
}
|
|
565
|
+
const cleanup = createCodexSessionCleanup({
|
|
566
|
+
namespace,
|
|
567
|
+
runOwner,
|
|
568
|
+
providerSessions,
|
|
569
|
+
sessionClosures: runOwner.runtimeLifecycle?.sessionClosures,
|
|
570
|
+
helperLifecycle,
|
|
571
|
+
journal: codexRunJournal,
|
|
572
|
+
conversations: codexConversations,
|
|
573
|
+
debugLog,
|
|
574
|
+
debugError
|
|
575
|
+
});
|
|
576
|
+
runOwner.closeSession = cleanup.closeSession;
|
|
577
|
+
runOwner.closeProject = cleanup.closeProject;
|
|
751
578
|
return runOwner;
|
|
752
579
|
}
|