@zq-silk/yui 0.14.0 → 0.14.2
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/ARCHITECTURE.md +64 -35
- package/README.md +258 -125
- package/dist/agent/argumentPolicy.js +2 -1
- package/dist/agent/managedRuntimeEnvironment.js +5 -8
- package/dist/cli/commandCatalog.js +74 -109
- package/dist/cli/helpRenderer.js +1 -2
- package/dist/cli/interactionCandidates.js +10 -0
- package/dist/cli/interactionPolicy.js +76 -37
- package/dist/cli/roleWizard.js +5 -6
- package/dist/cli/updateOrchestrator.js +10 -8
- package/dist/cli/updatePorts.js +17 -13
- package/dist/cli/upgradeCommand.js +2 -5
- package/dist/cli.js +268 -231
- package/dist/commands/agentCommands.js +13 -0
- package/dist/commands/configCommands.js +7 -19
- package/dist/commands/configOverview.js +3 -2
- package/dist/commands/durableJobCommands.js +1 -1
- package/dist/commands/executionAuditCommands.js +4 -9
- package/dist/commands/globalRoleCommands.js +17 -0
- package/dist/commands/profileCommands.js +200 -30
- package/dist/commands/sessionCommands.js +1 -1
- package/dist/commands/taskActor.js +29 -127
- package/dist/commands/taskChangeSetCommands.js +1 -3
- package/dist/commands/taskCommands.js +1771 -2107
- package/dist/commands/taskCompletionGate.js +27 -103
- package/dist/commands/taskContextCommand.js +47 -80
- package/dist/commands/taskExecutionCommands.js +9 -27
- package/dist/commands/taskInputCommands.js +10 -10
- package/dist/commands/taskIntegrationCommands.js +69 -61
- package/dist/commands/taskIntegrationQueueCommands.js +1 -1
- package/dist/commands/taskNextActionCommand.js +8 -29
- package/dist/commands/taskOverviewCommand.js +25 -3
- package/dist/commands/taskPublicationCommands.js +151 -85
- package/dist/commands/taskPublicationVerifyCommand.js +181 -0
- package/dist/commands/taskRemoteDeliveryCommand.js +134 -0
- package/dist/commands/taskRoleRuntimeStatus.js +5 -6
- package/dist/commands/taskUpstreamCommands.js +79 -95
- package/dist/config/configCatalog.js +1 -1
- package/dist/context/contextSnapshot.js +17 -2
- package/dist/context/sessionBootstrapManifest.js +18 -1
- package/dist/context/sourceTurnContext.js +30 -0
- package/dist/context/turnContextPack.js +107 -48
- package/dist/context/turnInputContract.js +11 -4
- package/dist/context/wakeNotification.js +84 -22
- package/dist/controller/agentRuntimeObserver.js +9 -12
- package/dist/controller/clientRuntime.js +13 -13
- package/dist/controller/controller.js +11 -11
- package/dist/controller/fileSchedulerStoreAdapter.js +262 -219
- package/dist/controller/jobControl.js +11 -10
- package/dist/controller/resourceInventory.js +6 -6
- package/dist/controller/resourceInventoryLinux.js +2 -2
- package/dist/controller/runtime.js +18 -61
- package/dist/controller/runtimeEventInbox.js +57 -34
- package/dist/controller/runtimeEventProcessor.js +36 -96
- package/dist/controller/runtimeHookTurnFence.js +33 -57
- package/dist/controller/runtimeLaunchCoordinator.js +44 -40
- package/dist/controller/runtimeObservationHook.js +18 -12
- package/dist/controller/sessionNotify.js +43 -28
- package/dist/controller/sessionOwnerReconciliation.js +21 -21
- package/dist/controller/structuredProviderObservation.js +13 -16
- package/dist/coordination/workMailboxQueue.js +132 -0
- package/dist/core/controllerServer.js +1 -0
- package/dist/domain/agentResultTransport.js +60 -0
- package/dist/execution/executionHealth.js +111 -118
- package/dist/execution/reviewMainTurn.js +161 -0
- package/dist/execution/workItemExecution.js +454 -0
- package/dist/execution/workItemExecutionProjection.js +309 -0
- package/dist/execution/workItemMainTurn.js +164 -0
- package/dist/executor/agentExecutor.js +19 -19
- package/dist/executor/executorRegistry.js +7 -28
- package/dist/executor/fileRoleLaunchPlanner.js +51 -83
- package/dist/external/githubPublicationVerifier.js +114 -0
- package/dist/external/gitlabPublicationVerifier.js +158 -0
- package/dist/external/pinnedCommandRunner.js +73 -0
- package/dist/integration/changeSetManifest.js +0 -3
- package/dist/integration/deliveryObligation.js +43 -6
- package/dist/integration/gitIntegrationService.js +284 -101
- package/dist/integration/integrationAttempt.js +64 -14
- package/dist/integration/integrationQueueEntry.js +5 -35
- package/dist/integration/integrationQueueService.js +65 -194
- package/dist/lifecycle/canonicalLifecycleEvent.js +16 -15
- package/dist/lifecycle/exactTurnTerminalization.js +100 -97
- package/dist/message/message.js +16 -0
- package/dist/observability/executionAudit.js +4 -25
- package/dist/observability/faultClassification.js +58 -70
- package/dist/observability/orchestrationMetrics.js +8 -50
- package/dist/profile/agentProfile.js +60 -15
- package/dist/profile/agentProfileRuntime.js +100 -0
- package/dist/release/releaseWorkflowPorts.js +5 -68
- package/dist/repository/executionLaneGitSnapshot.js +80 -0
- package/dist/repository/gitWorkspace.js +9 -67
- package/dist/repository/taskBaseFreshness.js +3 -1
- package/dist/repository/taskWorkspaceCoordinator.js +32 -4
- package/dist/repository/taskWorkspacePreparer.js +252 -411
- package/dist/resources/liveReferences.js +6 -55
- package/dist/resources/resourceDiscovery.js +1 -30
- package/dist/resources/resourceRegistrar.js +0 -23
- package/dist/review/deltaRecheck.js +8 -65
- package/dist/review/reviewAcceptance.js +22 -19
- package/dist/review/reviewConfig.js +0 -10
- package/dist/review/reviewDecision.js +2 -2
- package/dist/review/reviewRound.js +147 -273
- package/dist/review/reviewerAvailability.js +13 -23
- package/dist/role/role.js +3 -0
- package/dist/runtime/agentDriverObservation.js +1 -1
- package/dist/runtime/agentHost.js +51 -51
- package/dist/runtime/builtinAgentDrivers.js +9 -2
- package/dist/runtime/codexAppServerRuntime.js +23 -5
- package/dist/runtime/exactControlPlane.js +2 -267
- package/dist/runtime/firstProgressAdvisory.js +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/launchBroker.js +11 -11
- package/dist/runtime/lifecycleReservation.js +2 -2
- package/dist/runtime/managedCaller.js +111 -0
- package/dist/runtime/ports.js +16 -3
- package/dist/runtime/preallocatedNativeSession.js +2 -2
- package/dist/runtime/processExitObservation.js +3 -2
- package/dist/runtime/providerContinuationReconciliationService.js +1 -1
- package/dist/runtime/runtimeBinding.js +1 -1
- package/dist/runtime/runtimeObservation.js +33 -16
- package/dist/runtime/runtimeSessionCandidate.js +2 -2
- package/dist/runtime/runtimeStopReceipt.js +11 -11
- package/dist/runtime/sessionLaunchRequest.js +2 -2
- package/dist/runtime/sessionOwnerIdentity.js +9 -9
- package/dist/runtime/sessionOwnerRegistry.js +13 -13
- package/dist/runtime/sessionReconciliation.js +4 -4
- package/dist/runtime/sessionTerminationGuard.js +9 -9
- package/dist/runtime/sessionTokenMetrics.js +5 -7
- package/dist/runtime/structuredProviderHost.js +5 -5
- package/dist/runtime/taskRuntimeIsolation.js +24 -24
- package/dist/runtime/tmuxAdapters.js +32 -30
- package/dist/scheduler/activeRoleTurnDelivery.js +37 -15
- package/dist/scheduler/leaderWakeupProcessor.js +78 -55
- package/dist/scheduler/roleTurnLiveness.js +6 -6
- package/dist/scheduler/roleTurnStall.js +8 -9
- package/dist/scheduler/taskExecutionProjection.js +19 -41
- package/dist/scheduler/taskObservabilityProjection.js +75 -122
- package/dist/storage/sqliteSchema.js +1 -21
- package/dist/storage/sqliteStore.js +62 -47
- package/dist/storage/storageSchema.js +1 -8
- package/dist/storage/storageVersions.js +7 -4
- package/dist/storage/taskStore.js +8 -8
- package/dist/storage/upgrade/upgradeOrchestrator.js +112 -83
- package/dist/task/completionReadiness.js +17 -98
- package/dist/task/deliveryGuard.js +9 -11
- package/dist/task/draftPlan.js +142 -0
- package/dist/task/nextAction.js +179 -477
- package/dist/task/publicationVerification.js +1 -0
- package/dist/task/remoteDelivery.js +233 -0
- package/dist/task/task.js +108 -4
- package/dist/task/taskRecordReference.js +0 -1
- package/dist/turn/turn.js +109 -16
- package/dist/verification/verificationGateService.js +0 -26
- package/dist/web/assets/client/components.js +99 -121
- package/dist/web/assets/client/i18n.js +136 -58
- package/dist/web/assets/client/view.js +44 -0
- package/dist/web/assets/styles/cards.js +3 -15
- package/dist/web/assets/styles/widgets.js +4 -0
- package/dist/web/webSnapshot.js +29 -14
- package/dist/workItem/dependencyGate.js +34 -0
- package/dist/workItem/workItem.js +99 -266
- package/dist/workspace/workItemChangeSetManager.js +15 -59
- package/docs/task-local-identity.md +1 -1
- package/i18n/README.zh-CN.md +165 -59
- package/package.json +1 -1
- package/skills/yui-leader/SKILL.md +272 -782
- package/skills/yui-operator/SKILL.md +190 -365
- package/skills/yui-reviewer/SKILL.md +40 -33
- package/skills/yui-runtime/SKILL.md +27 -6
- package/skills/yui-worker/SKILL.md +19 -6
- package/dist/execution/candidateConvergence.js +0 -623
- package/dist/execution/executionGroup.js +0 -854
- package/dist/execution/resourceBroker.js +0 -426
- package/dist/executor/launchPlan.js +0 -16
- package/dist/review/reviewFinding.js +0 -240
- package/dist/review/reviewFindingLedger.js +0 -550
- package/dist/review/reviewOutcomeClassifier.js +0 -255
- package/dist/scheduler/resourceQueueProjection.js +0 -71
- package/dist/task/repairWave.js +0 -150
|
@@ -17,7 +17,7 @@ import { persistRuntimeProcessExitObservation, replayRuntimeProcessExitOutbox }
|
|
|
17
17
|
import { readRuntimeStopReceipt, removeRuntimeStopReceipt } from "./runtimeStopReceipt.js";
|
|
18
18
|
import { AGENT_HOST_CONTROL_TIMEOUT_MS, AGENT_HOST_READY_TIMEOUT_MS } from "./runtimeDeadlines.js";
|
|
19
19
|
import { serializeAgentErrorRaw } from "./agentError.js";
|
|
20
|
-
export const AGENT_HOST_CONTROL_PROTOCOL = "yui-agent-host/
|
|
20
|
+
export const AGENT_HOST_CONTROL_PROTOCOL = "yui-agent-host/v4";
|
|
21
21
|
const HOST_CONTROL_MAX_BYTES = 32 * 1024;
|
|
22
22
|
const CODEX_CLIENT_STABLE_MS = 5_000;
|
|
23
23
|
const MAX_CONSECUTIVE_CODEX_DISCONNECTS = 3;
|
|
@@ -27,7 +27,7 @@ export function serializeAgentHostLaunchControl(control) {
|
|
|
27
27
|
export async function runAgentHost(input) {
|
|
28
28
|
const hostInstanceId = randomUUID();
|
|
29
29
|
let hostSequence = 0;
|
|
30
|
-
let payload = await redeem(input.home, input.
|
|
30
|
+
let payload = await redeem(input.home, input.runtimeGenerationId, input.ticket);
|
|
31
31
|
let session;
|
|
32
32
|
let sessionPayload;
|
|
33
33
|
let activeTurnPayload;
|
|
@@ -56,7 +56,7 @@ export async function runAgentHost(input) {
|
|
|
56
56
|
if (started.clientOwned || observedPayload === undefined)
|
|
57
57
|
return;
|
|
58
58
|
updateSnapshot(hostSnapshot("busy", {
|
|
59
|
-
|
|
59
|
+
runtimeGenerationId: observedPayload.runtimeGenerationId,
|
|
60
60
|
adapterId: observedPayload.providerControl?.adapterId,
|
|
61
61
|
processInstanceId: session?.processInstanceId,
|
|
62
62
|
nativeSessionId: started.nativeSessionId,
|
|
@@ -64,7 +64,7 @@ export async function runAgentHost(input) {
|
|
|
64
64
|
nativeTurnId: started.nativeTurnId,
|
|
65
65
|
...authorityFields()
|
|
66
66
|
}));
|
|
67
|
-
const directActivationId = activationId ?? observedPayload.
|
|
67
|
+
const directActivationId = activationId ?? observedPayload.runtimeGenerationId;
|
|
68
68
|
void enqueueSerialized(async () => {
|
|
69
69
|
await publishStructuredProviderStarted({
|
|
70
70
|
home: input.home,
|
|
@@ -85,7 +85,7 @@ export async function runAgentHost(input) {
|
|
|
85
85
|
// A direct Provider client shares the Session but still produces a Yui
|
|
86
86
|
// Turn audit record. It has no WorkItem ownership and no managed input
|
|
87
87
|
// fence; the runtime observer records only visible input/output.
|
|
88
|
-
const directActivationId = activationId ?? busyPayload.
|
|
88
|
+
const directActivationId = activationId ?? busyPayload.runtimeGenerationId;
|
|
89
89
|
void enqueueSerialized(async () => {
|
|
90
90
|
await publishStructuredProviderTerminal({
|
|
91
91
|
home: input.home,
|
|
@@ -95,7 +95,7 @@ export async function runAgentHost(input) {
|
|
|
95
95
|
});
|
|
96
96
|
if (session !== undefined && terminal.conversationId === session.conversationId) {
|
|
97
97
|
updateSnapshot(hostSnapshot(session.activeTurnId === undefined ? "idle" : "busy", {
|
|
98
|
-
|
|
98
|
+
runtimeGenerationId: busyPayload.runtimeGenerationId,
|
|
99
99
|
adapterId: session.adapterId,
|
|
100
100
|
processInstanceId: session.processInstanceId,
|
|
101
101
|
nativeSessionId: session.nativeSessionId,
|
|
@@ -110,13 +110,13 @@ export async function runAgentHost(input) {
|
|
|
110
110
|
const terminalPayload = activeTurnPayload;
|
|
111
111
|
if (terminalPayload === undefined)
|
|
112
112
|
return;
|
|
113
|
-
const terminalActivationId = activationId ?? terminalPayload.
|
|
113
|
+
const terminalActivationId = activationId ?? terminalPayload.runtimeGenerationId;
|
|
114
114
|
void enqueueSerialized(async () => {
|
|
115
115
|
if (activeTurnPayload !== terminalPayload)
|
|
116
116
|
return;
|
|
117
117
|
if (session !== undefined) {
|
|
118
118
|
updateSnapshot(hostSnapshot("settling", {
|
|
119
|
-
|
|
119
|
+
runtimeGenerationId: terminalPayload.runtimeGenerationId,
|
|
120
120
|
adapterId: terminalPayload.providerControl.adapterId,
|
|
121
121
|
processInstanceId: session.processInstanceId,
|
|
122
122
|
nativeSessionId: terminal.nativeSessionId,
|
|
@@ -141,7 +141,7 @@ export async function runAgentHost(input) {
|
|
|
141
141
|
return;
|
|
142
142
|
const currentPayload = sessionPayload ?? terminalPayload;
|
|
143
143
|
updateSnapshot(hostSnapshot(session.activeTurnId === undefined ? "idle" : "busy", {
|
|
144
|
-
|
|
144
|
+
runtimeGenerationId: currentPayload.runtimeGenerationId,
|
|
145
145
|
adapterId: currentPayload.providerControl.adapterId,
|
|
146
146
|
processInstanceId: session.processInstanceId,
|
|
147
147
|
nativeSessionId: terminal.nativeSessionId,
|
|
@@ -152,7 +152,7 @@ export async function runAgentHost(input) {
|
|
|
152
152
|
}
|
|
153
153
|
catch (error) {
|
|
154
154
|
updateSnapshot(hostSnapshot("failed", {
|
|
155
|
-
|
|
155
|
+
runtimeGenerationId: terminalPayload.runtimeGenerationId,
|
|
156
156
|
adapterId: terminalPayload.providerControl.adapterId,
|
|
157
157
|
processInstanceId: session?.processInstanceId,
|
|
158
158
|
nativeSessionId: terminal.nativeSessionId,
|
|
@@ -169,7 +169,7 @@ export async function runAgentHost(input) {
|
|
|
169
169
|
const currentSession = session;
|
|
170
170
|
if (currentPayload === undefined || currentSession === undefined)
|
|
171
171
|
return;
|
|
172
|
-
const currentActivationId = activationId ?? currentPayload.
|
|
172
|
+
const currentActivationId = activationId ?? currentPayload.runtimeGenerationId;
|
|
173
173
|
void enqueueSerialized(async () => {
|
|
174
174
|
await publishStructuredProviderGoal({
|
|
175
175
|
home: input.home,
|
|
@@ -233,7 +233,7 @@ export async function runAgentHost(input) {
|
|
|
233
233
|
? ownedTurn === undefined ? "delivery-unknown" : "ready"
|
|
234
234
|
: started.session.activeTurnId === undefined ? "idle" : "busy";
|
|
235
235
|
updateSnapshot(hostSnapshot(reconnectState, {
|
|
236
|
-
|
|
236
|
+
runtimeGenerationId: currentPayload.runtimeGenerationId,
|
|
237
237
|
adapterId: "codex",
|
|
238
238
|
processInstanceId: started.session.processInstanceId,
|
|
239
239
|
nativeSessionId: started.session.nativeSessionId,
|
|
@@ -268,7 +268,7 @@ export async function runAgentHost(input) {
|
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
270
|
updateSnapshot(hostSnapshot("failed", {
|
|
271
|
-
|
|
271
|
+
runtimeGenerationId: currentPayload.runtimeGenerationId,
|
|
272
272
|
adapterId: "codex",
|
|
273
273
|
processInstanceId: disconnectedSession.processInstanceId,
|
|
274
274
|
nativeSessionId: disconnectedSession.nativeSessionId,
|
|
@@ -284,10 +284,10 @@ export async function runAgentHost(input) {
|
|
|
284
284
|
const ownsCurrentSession = session === providerSession;
|
|
285
285
|
const currentPayload = ownsCurrentSession ? sessionPayload ?? launched : launched;
|
|
286
286
|
const currentActivationId = ownsCurrentSession
|
|
287
|
-
? activationId ?? launched.
|
|
288
|
-
: launched.
|
|
287
|
+
? activationId ?? launched.runtimeGenerationId
|
|
288
|
+
: launched.runtimeGenerationId;
|
|
289
289
|
const exitAuthority = authorityFields();
|
|
290
|
-
const stopReceipt = readRuntimeStopReceipt(input.home, currentPayload.
|
|
290
|
+
const stopReceipt = readRuntimeStopReceipt(input.home, currentPayload.runtimeGenerationId);
|
|
291
291
|
const reconnectableCodexClient = ownsCurrentSession
|
|
292
292
|
&& providerSession.adapterId === "codex"
|
|
293
293
|
&& !hostStopRequested
|
|
@@ -301,7 +301,7 @@ export async function runAgentHost(input) {
|
|
|
301
301
|
consecutiveCodexDisconnects += 1;
|
|
302
302
|
if (consecutiveCodexDisconnects > MAX_CONSECUTIVE_CODEX_DISCONNECTS) {
|
|
303
303
|
updateSnapshot(hostSnapshot("failed", {
|
|
304
|
-
|
|
304
|
+
runtimeGenerationId: currentPayload.runtimeGenerationId,
|
|
305
305
|
adapterId: "codex",
|
|
306
306
|
processInstanceId: result.processInstanceId,
|
|
307
307
|
nativeSessionId: providerSession.nativeSessionId,
|
|
@@ -314,7 +314,7 @@ export async function runAgentHost(input) {
|
|
|
314
314
|
return;
|
|
315
315
|
}
|
|
316
316
|
updateSnapshot(hostSnapshot("starting", {
|
|
317
|
-
|
|
317
|
+
runtimeGenerationId: currentPayload.runtimeGenerationId,
|
|
318
318
|
adapterId: "codex",
|
|
319
319
|
processInstanceId: result.processInstanceId,
|
|
320
320
|
nativeSessionId: providerSession.nativeSessionId,
|
|
@@ -353,7 +353,7 @@ export async function runAgentHost(input) {
|
|
|
353
353
|
let exitPersisted = false;
|
|
354
354
|
try {
|
|
355
355
|
await persistAndSubmitExit(input.home, validateRuntimeProcessExitObservation({
|
|
356
|
-
schemaVersion:
|
|
356
|
+
schemaVersion: 2,
|
|
357
357
|
observationId: `${hostInstanceId}-${hostSequence}`,
|
|
358
358
|
hostSequence,
|
|
359
359
|
hostInstanceId,
|
|
@@ -365,7 +365,7 @@ export async function runAgentHost(input) {
|
|
|
365
365
|
...(currentPayload.environment.YUI_TURN_ID === undefined
|
|
366
366
|
? {}
|
|
367
367
|
: { turnId: currentPayload.environment.YUI_TURN_ID }),
|
|
368
|
-
|
|
368
|
+
runtimeGenerationId: currentPayload.runtimeGenerationId,
|
|
369
369
|
...(providerSession.nativeSessionId.length === 0
|
|
370
370
|
? {}
|
|
371
371
|
: { nativeSessionId: providerSession.nativeSessionId }),
|
|
@@ -381,12 +381,12 @@ export async function runAgentHost(input) {
|
|
|
381
381
|
failures.push(`process exit: ${errorText(error)}`);
|
|
382
382
|
}
|
|
383
383
|
if (stopReceipt !== null && exitPersisted) {
|
|
384
|
-
removeRuntimeStopReceipt(input.home, currentPayload.
|
|
384
|
+
removeRuntimeStopReceipt(input.home, currentPayload.runtimeGenerationId);
|
|
385
385
|
}
|
|
386
386
|
if (hostStopRequested || !ownsCurrentSession)
|
|
387
387
|
return;
|
|
388
388
|
updateSnapshot(hostSnapshot(failures.length === 0 ? "exited" : "failed", {
|
|
389
|
-
|
|
389
|
+
runtimeGenerationId: currentPayload.runtimeGenerationId,
|
|
390
390
|
adapterId: currentPayload.providerControl?.adapterId,
|
|
391
391
|
processInstanceId: result.processInstanceId,
|
|
392
392
|
nativeSessionId: providerSession.nativeSessionId,
|
|
@@ -399,7 +399,7 @@ export async function runAgentHost(input) {
|
|
|
399
399
|
: { detail: "Provider process exited before the active Turn reached a terminal boundary." })
|
|
400
400
|
}));
|
|
401
401
|
})).catch((error) => updateSnapshot(hostSnapshot("failed", {
|
|
402
|
-
|
|
402
|
+
runtimeGenerationId: launched.runtimeGenerationId,
|
|
403
403
|
adapterId: launched.providerControl?.adapterId,
|
|
404
404
|
processInstanceId: providerSession.processInstanceId,
|
|
405
405
|
...authorityFields(),
|
|
@@ -427,7 +427,7 @@ export async function runAgentHost(input) {
|
|
|
427
427
|
throw new Error("Agent Host launch carries a stale Provider authority fence.");
|
|
428
428
|
}
|
|
429
429
|
updateSnapshot(hostSnapshot("starting", {
|
|
430
|
-
|
|
430
|
+
runtimeGenerationId: next.runtimeGenerationId,
|
|
431
431
|
adapterId: providerControl.adapterId,
|
|
432
432
|
...(session === undefined ? {} : {
|
|
433
433
|
processInstanceId: session.processInstanceId,
|
|
@@ -447,7 +447,7 @@ export async function runAgentHost(input) {
|
|
|
447
447
|
sessionPayload = next;
|
|
448
448
|
}
|
|
449
449
|
else {
|
|
450
|
-
activationId = next.
|
|
450
|
+
activationId = next.runtimeGenerationId;
|
|
451
451
|
conversationRecoverability = providerControl.adapterId === "codex"
|
|
452
452
|
? "recoverable"
|
|
453
453
|
: "unknown";
|
|
@@ -488,7 +488,7 @@ export async function runAgentHost(input) {
|
|
|
488
488
|
environment: next.environment,
|
|
489
489
|
conversationId: session.conversationId,
|
|
490
490
|
nativeSessionId: session.nativeSessionId,
|
|
491
|
-
activationId: activationId ?? next.
|
|
491
|
+
activationId: activationId ?? next.runtimeGenerationId,
|
|
492
492
|
recoverability: conversationRecoverability,
|
|
493
493
|
observedAt: new Date().toISOString()
|
|
494
494
|
});
|
|
@@ -496,7 +496,7 @@ export async function runAgentHost(input) {
|
|
|
496
496
|
await publishStructuredProviderGoal({
|
|
497
497
|
home: input.home,
|
|
498
498
|
environment: next.environment,
|
|
499
|
-
activationId: activationId ?? next.
|
|
499
|
+
activationId: activationId ?? next.runtimeGenerationId,
|
|
500
500
|
conversationId: session.conversationId,
|
|
501
501
|
goal: recoveredGoal
|
|
502
502
|
});
|
|
@@ -508,7 +508,7 @@ export async function runAgentHost(input) {
|
|
|
508
508
|
? "ready"
|
|
509
509
|
: session.activeTurnId === undefined ? "idle" : "busy";
|
|
510
510
|
updateSnapshot(hostSnapshot(providerState, {
|
|
511
|
-
|
|
511
|
+
runtimeGenerationId: next.runtimeGenerationId,
|
|
512
512
|
adapterId: providerControl.adapterId,
|
|
513
513
|
processInstanceId: session.processInstanceId,
|
|
514
514
|
nativeSessionId: session.nativeSessionId,
|
|
@@ -529,7 +529,7 @@ export async function runAgentHost(input) {
|
|
|
529
529
|
home: input.home,
|
|
530
530
|
environment: next.environment,
|
|
531
531
|
conversationId: error.conversationId,
|
|
532
|
-
activationId: activationId ?? next.
|
|
532
|
+
activationId: activationId ?? next.runtimeGenerationId,
|
|
533
533
|
recoverability: "unrecoverable",
|
|
534
534
|
observedAt: new Date().toISOString()
|
|
535
535
|
}).catch(() => { });
|
|
@@ -543,7 +543,7 @@ export async function runAgentHost(input) {
|
|
|
543
543
|
? "busy"
|
|
544
544
|
: error instanceof ProviderTurnRejectedError ? "rejected" : "failed";
|
|
545
545
|
updateSnapshot(hostSnapshot(state, {
|
|
546
|
-
|
|
546
|
+
runtimeGenerationId: next.runtimeGenerationId,
|
|
547
547
|
adapterId: providerControl.adapterId,
|
|
548
548
|
processInstanceId: session?.processInstanceId,
|
|
549
549
|
nativeSessionId: session?.nativeSessionId ?? providerControl.nativeSessionId,
|
|
@@ -588,7 +588,7 @@ export async function runAgentHost(input) {
|
|
|
588
588
|
activeTurnAttemptId = request.turn.attemptId;
|
|
589
589
|
activeNativeTurnId = undefined;
|
|
590
590
|
updateSnapshot(hostSnapshot("starting", {
|
|
591
|
-
|
|
591
|
+
runtimeGenerationId: request.runtimeGenerationId,
|
|
592
592
|
adapterId: session.adapterId,
|
|
593
593
|
processInstanceId: session.processInstanceId,
|
|
594
594
|
nativeSessionId: session.nativeSessionId,
|
|
@@ -607,7 +607,7 @@ export async function runAgentHost(input) {
|
|
|
607
607
|
await publishStructuredProviderAccepted({
|
|
608
608
|
home: input.home,
|
|
609
609
|
environment: activeTurnPayload.environment,
|
|
610
|
-
activationId: activationId ?? sessionPayload.
|
|
610
|
+
activationId: activationId ?? sessionPayload.runtimeGenerationId,
|
|
611
611
|
receipt
|
|
612
612
|
});
|
|
613
613
|
}
|
|
@@ -617,7 +617,7 @@ export async function runAgentHost(input) {
|
|
|
617
617
|
throw unknown;
|
|
618
618
|
}
|
|
619
619
|
updateSnapshot(hostSnapshot("ready", {
|
|
620
|
-
|
|
620
|
+
runtimeGenerationId: request.runtimeGenerationId,
|
|
621
621
|
adapterId: session.adapterId,
|
|
622
622
|
processInstanceId: session.processInstanceId,
|
|
623
623
|
nativeSessionId: receipt.nativeSessionId,
|
|
@@ -639,7 +639,7 @@ export async function runAgentHost(input) {
|
|
|
639
639
|
? "busy"
|
|
640
640
|
: error instanceof ProviderTurnRejectedError ? "rejected" : "failed";
|
|
641
641
|
updateSnapshot(hostSnapshot(state, {
|
|
642
|
-
|
|
642
|
+
runtimeGenerationId: request.runtimeGenerationId,
|
|
643
643
|
adapterId: session.adapterId,
|
|
644
644
|
processInstanceId: session.processInstanceId,
|
|
645
645
|
nativeSessionId: session.nativeSessionId,
|
|
@@ -700,7 +700,7 @@ export async function runAgentHost(input) {
|
|
|
700
700
|
}
|
|
701
701
|
authority = next;
|
|
702
702
|
updateSnapshot(hostSnapshot("idle", {
|
|
703
|
-
|
|
703
|
+
runtimeGenerationId: sessionPayload?.runtimeGenerationId ?? snapshot.runtimeGenerationId,
|
|
704
704
|
adapterId: session.adapterId,
|
|
705
705
|
processInstanceId: session.processInstanceId,
|
|
706
706
|
nativeSessionId: session.nativeSessionId,
|
|
@@ -726,14 +726,14 @@ export async function runAgentHost(input) {
|
|
|
726
726
|
const accepted = await enqueueSerialized(async () => setAuthority(request));
|
|
727
727
|
return controlResult("accepted", accepted);
|
|
728
728
|
}
|
|
729
|
-
if (snapshot.
|
|
729
|
+
if (snapshot.runtimeGenerationId === request.runtimeGenerationId
|
|
730
730
|
&& ["starting", "ready", "settling", "delivery-unknown"].includes(snapshot.state)) {
|
|
731
|
-
return controlResult("active-same-
|
|
731
|
+
return controlResult("active-same-generation", snapshot);
|
|
732
732
|
}
|
|
733
|
-
const redeemed = await redeem(input.home, request.
|
|
733
|
+
const redeemed = await redeem(input.home, request.runtimeGenerationId, request.ticket);
|
|
734
734
|
if (activeTurnPayload !== undefined
|
|
735
735
|
|| ["starting", "ready", "settling", "delivery-unknown"].includes(snapshot.state)) {
|
|
736
|
-
return controlResult("active-other-
|
|
736
|
+
return controlResult("active-other-generation", snapshot);
|
|
737
737
|
}
|
|
738
738
|
const accepted = await enqueueDispatch(redeemed);
|
|
739
739
|
return controlResult("accepted", accepted);
|
|
@@ -767,7 +767,7 @@ export async function runAgentHost(input) {
|
|
|
767
767
|
const turnControl = {
|
|
768
768
|
protocol: AGENT_HOST_CONTROL_PROTOCOL,
|
|
769
769
|
type: "submit-turn",
|
|
770
|
-
|
|
770
|
+
runtimeGenerationId: currentPayload.runtimeGenerationId,
|
|
771
771
|
nativeSessionId: currentSession.nativeSessionId,
|
|
772
772
|
authority: currentAuthority,
|
|
773
773
|
turn: {
|
|
@@ -863,7 +863,7 @@ export async function waitForAgentHostLaunchAck(input) {
|
|
|
863
863
|
while (Date.now() < deadline) {
|
|
864
864
|
try {
|
|
865
865
|
const snapshot = await inspectAgentHost(input);
|
|
866
|
-
if (snapshot.
|
|
866
|
+
if (snapshot.runtimeGenerationId === input.runtimeGenerationId) {
|
|
867
867
|
if (snapshot.state === "ready"
|
|
868
868
|
|| (input.requireTurnAck !== true && snapshot.state === "idle"))
|
|
869
869
|
return snapshot;
|
|
@@ -885,7 +885,7 @@ export async function waitForAgentHostLaunchAck(input) {
|
|
|
885
885
|
}
|
|
886
886
|
await new Promise((resolvePromise) => setTimeout(resolvePromise, 50));
|
|
887
887
|
}
|
|
888
|
-
throw new Error(`Agent Host did not acknowledge Provider launch ${input.
|
|
888
|
+
throw new Error(`Agent Host did not acknowledge Provider launch ${input.runtimeGenerationId}: ${errorText(lastError)}.`);
|
|
889
889
|
}
|
|
890
890
|
async function sendAgentHostControl(input) {
|
|
891
891
|
const path = agentHostControlSocketPath(input);
|
|
@@ -923,9 +923,9 @@ async function sendAgentHostControl(input) {
|
|
|
923
923
|
});
|
|
924
924
|
});
|
|
925
925
|
}
|
|
926
|
-
async function redeem(home,
|
|
926
|
+
async function redeem(home, runtimeGenerationId, ticket) {
|
|
927
927
|
const result = await callController(home, "runtime.launch-redeem", {
|
|
928
|
-
|
|
928
|
+
runtimeGenerationId,
|
|
929
929
|
ticket,
|
|
930
930
|
hostPid: process.pid
|
|
931
931
|
});
|
|
@@ -1031,7 +1031,7 @@ function validateControl(control) {
|
|
|
1031
1031
|
if (control.type === "status")
|
|
1032
1032
|
return Object.freeze({ ...control });
|
|
1033
1033
|
if (control.type === "submit-turn" || control.type === "steer-turn") {
|
|
1034
|
-
|
|
1034
|
+
validateRuntimeGenerationId(control.runtimeGenerationId);
|
|
1035
1035
|
validateIdentity(control.nativeSessionId, "native Session id");
|
|
1036
1036
|
if (control.type === "submit-turn" && control.turnId !== undefined) {
|
|
1037
1037
|
validateIdentity(control.turnId, "Turn id");
|
|
@@ -1059,13 +1059,13 @@ function validateControl(control) {
|
|
|
1059
1059
|
}
|
|
1060
1060
|
if (control.type !== "launch")
|
|
1061
1061
|
throw new Error("Agent Host control type is invalid.");
|
|
1062
|
-
|
|
1062
|
+
validateRuntimeGenerationId(control.runtimeGenerationId);
|
|
1063
1063
|
if (typeof control.ticket !== "string" || !/^[a-f0-9]{64}$/u.test(control.ticket)) {
|
|
1064
1064
|
throw new Error("Agent Host launch control ticket is invalid.");
|
|
1065
1065
|
}
|
|
1066
1066
|
return Object.freeze({ ...control });
|
|
1067
1067
|
}
|
|
1068
|
-
function
|
|
1068
|
+
function validateRuntimeGenerationId(value) {
|
|
1069
1069
|
if (typeof value !== "string" || value.length === 0
|
|
1070
1070
|
|| value.length > 256 || value.includes("\0")) {
|
|
1071
1071
|
throw new Error("Agent Host launch control identity is invalid.");
|
|
@@ -1078,13 +1078,13 @@ function validateIdentity(value, label) {
|
|
|
1078
1078
|
}
|
|
1079
1079
|
function validateControlResult(result) {
|
|
1080
1080
|
if (result.protocol !== AGENT_HOST_CONTROL_PROTOCOL
|
|
1081
|
-
|| !["status", "accepted", "rejected", "active-same-
|
|
1081
|
+
|| !["status", "accepted", "rejected", "active-same-generation", "active-other-generation"].includes(result.outcome)) {
|
|
1082
1082
|
throw new Error("Agent Host control response is invalid.");
|
|
1083
1083
|
}
|
|
1084
1084
|
return Object.freeze({ ...result, snapshot: validateSnapshot(result.snapshot) });
|
|
1085
1085
|
}
|
|
1086
1086
|
function validateSnapshot(snapshot) {
|
|
1087
|
-
if (snapshot.schemaVersion !==
|
|
1087
|
+
if (snapshot.schemaVersion !== 2
|
|
1088
1088
|
|| !["idle", "starting", "ready", "settling", "delivery-unknown", "busy", "rejected", "failed", "exited"]
|
|
1089
1089
|
.includes(snapshot.state)) {
|
|
1090
1090
|
throw new Error("Agent Host snapshot is invalid.");
|
|
@@ -1111,7 +1111,7 @@ function validateSnapshot(snapshot) {
|
|
|
1111
1111
|
}
|
|
1112
1112
|
function hostSnapshot(state, fields = {}) {
|
|
1113
1113
|
return validateSnapshot({
|
|
1114
|
-
schemaVersion:
|
|
1114
|
+
schemaVersion: 2,
|
|
1115
1115
|
state,
|
|
1116
1116
|
...definedFields(fields),
|
|
1117
1117
|
updatedAt: new Date().toISOString()
|
|
@@ -1150,7 +1150,7 @@ function hostTurnControlParams(payload, nativeSessionId, authority, attemptId, t
|
|
|
1150
1150
|
roleName: requiredEnvironment(environment.YUI_ROLE, "Role name"),
|
|
1151
1151
|
...(turnId === undefined ? {} : { turnId: requiredEnvironment(turnId, "Turn id") }),
|
|
1152
1152
|
agentId: requiredEnvironment(environment.YUI_AGENT_ID, "Agent id"),
|
|
1153
|
-
|
|
1153
|
+
runtimeGenerationId: payload.runtimeGenerationId,
|
|
1154
1154
|
nativeSessionId: requiredEnvironment(nativeSessionId, "native Session id"),
|
|
1155
1155
|
attemptId,
|
|
1156
1156
|
authorityEpoch: authority.epoch,
|
|
@@ -2,6 +2,7 @@ import { AgentDriverRegistry } from "./agentDriver.js";
|
|
|
2
2
|
import { claudeTranscriptObserver, codexTranscriptObserver, transcriptObserverSource } from "./builtinTranscriptObserver.js";
|
|
3
3
|
import { mapClaudeAgentError, mapCodexAgentError } from "./builtinAgentErrorMappers.js";
|
|
4
4
|
import { serializeAgentErrorRaw, standardAgentError } from "./agentError.js";
|
|
5
|
+
import { transportAgentResult } from "../domain/agentResultTransport.js";
|
|
5
6
|
export const CODEX_DRIVER_ID = "openai/codex";
|
|
6
7
|
export const CLAUDE_CODE_DRIVER_ID = "anthropic/claude-code";
|
|
7
8
|
export function builtinDriverIdForAdapter(adapterId) {
|
|
@@ -243,7 +244,7 @@ function mapClaudeLifecycleHook(name, payload, occurrenceId) {
|
|
|
243
244
|
];
|
|
244
245
|
case "Stop":
|
|
245
246
|
return [
|
|
246
|
-
mapped("turn.completed",
|
|
247
|
+
mapped("turn.completed", optionalResultOutput(payload)),
|
|
247
248
|
mapped("native-work.snapshot", {
|
|
248
249
|
snapshotComplete: payload.background_tasks_complete === true,
|
|
249
250
|
observationQuality: payload.background_tasks_complete === true ? "exact" : "partial"
|
|
@@ -372,7 +373,7 @@ function mapCodexHook(name, payload, occurrenceId) {
|
|
|
372
373
|
})
|
|
373
374
|
];
|
|
374
375
|
case "Stop":
|
|
375
|
-
return mapped("turn.completed",
|
|
376
|
+
return mapped("turn.completed", optionalResultOutput(payload));
|
|
376
377
|
case "SessionEnd":
|
|
377
378
|
return mapped("activation.ended");
|
|
378
379
|
default:
|
|
@@ -455,6 +456,12 @@ function optionalSummary(payload, preferred = "last_assistant_message") {
|
|
|
455
456
|
}
|
|
456
457
|
return {};
|
|
457
458
|
}
|
|
459
|
+
function optionalResultOutput(payload) {
|
|
460
|
+
const result = transportAgentResult(payload.last_assistant_message);
|
|
461
|
+
return result.status === "completed"
|
|
462
|
+
? { output: result.output }
|
|
463
|
+
: { resultTransportDiagnostic: result.diagnostic };
|
|
464
|
+
}
|
|
458
465
|
function claudeFailure(payload) {
|
|
459
466
|
const code = firstIdentity(payload, ["error"], "Claude StopFailure error");
|
|
460
467
|
const details = optionalText(payload.error_details);
|
|
@@ -277,12 +277,12 @@ function parseThreadSnapshot(result, expectedThreadId, loaded) {
|
|
|
277
277
|
if (turnId === undefined)
|
|
278
278
|
return [];
|
|
279
279
|
const status = optionalTurnStatus(turn.status);
|
|
280
|
-
const
|
|
280
|
+
const output = codexTurnOutput(turn);
|
|
281
281
|
const error = providerError(turn.error);
|
|
282
282
|
return [{
|
|
283
283
|
turnId,
|
|
284
284
|
...(status === undefined ? {} : { status }),
|
|
285
|
-
...(
|
|
285
|
+
...(output === undefined ? {} : { output }),
|
|
286
286
|
...(error === undefined ? {} : { error })
|
|
287
287
|
}];
|
|
288
288
|
});
|
|
@@ -300,8 +300,8 @@ function parseThreadSnapshot(result, expectedThreadId, loaded) {
|
|
|
300
300
|
raw: result
|
|
301
301
|
};
|
|
302
302
|
}
|
|
303
|
-
/** Extract the last assistant message from one native Codex Turn. */
|
|
304
|
-
export function
|
|
303
|
+
/** Extract the last assistant message from one native Codex Turn without rewriting it. */
|
|
304
|
+
export function codexTurnOutput(turn) {
|
|
305
305
|
for (const value of [...arrayMember(turn, "items")].reverse()) {
|
|
306
306
|
const item = object(value);
|
|
307
307
|
if (item === null)
|
|
@@ -313,12 +313,30 @@ export function codexTurnSummary(turn) {
|
|
|
313
313
|
|| (type === "message" && (item.role === "assistant" || message?.role === "assistant"));
|
|
314
314
|
if (!agentMessage)
|
|
315
315
|
continue;
|
|
316
|
-
const text =
|
|
316
|
+
const text = messageOutput(item) ?? (message === null ? undefined : messageOutput(message));
|
|
317
317
|
if (text !== undefined)
|
|
318
318
|
return text;
|
|
319
319
|
}
|
|
320
320
|
return undefined;
|
|
321
321
|
}
|
|
322
|
+
function messageOutput(message) {
|
|
323
|
+
for (const value of [message.text, message.content]) {
|
|
324
|
+
if (typeof value === "string" && value.trim().length > 0)
|
|
325
|
+
return value;
|
|
326
|
+
if (!Array.isArray(value))
|
|
327
|
+
continue;
|
|
328
|
+
const parts = value.flatMap((part) => {
|
|
329
|
+
if (typeof part === "string" && part.trim().length > 0)
|
|
330
|
+
return [part];
|
|
331
|
+
const record = object(part);
|
|
332
|
+
const text = record?.text ?? record?.content;
|
|
333
|
+
return typeof text === "string" && text.trim().length > 0 ? [text] : [];
|
|
334
|
+
});
|
|
335
|
+
if (parts.length > 0)
|
|
336
|
+
return parts.join("\n");
|
|
337
|
+
}
|
|
338
|
+
return undefined;
|
|
339
|
+
}
|
|
322
340
|
/** Extract the provider-visible human input without copying tool or reasoning items. */
|
|
323
341
|
export function codexTurnInput(turn) {
|
|
324
342
|
for (const value of arrayMember(turn, "items")) {
|