@zq-silk/yui 0.13.9 → 0.14.0
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 +69 -428
- package/README.md +108 -298
- package/dist/agent/managedRuntimeEnvironment.js +2 -2
- package/dist/cli/commandCatalog.js +39 -77
- package/dist/cli/interactionCandidates.js +4 -4
- package/dist/cli/interactionPolicy.js +7 -10
- package/dist/cli/invocationRouter.js +1 -1
- package/dist/cli/updateCommand.js +6 -27
- package/dist/cli/updateOrchestrator.js +63 -484
- package/dist/cli/updatePorts.js +15 -333
- package/dist/cli/upgradeCommand.js +8 -65
- package/dist/cli.js +57 -242
- package/dist/commands/configCommands.js +11 -62
- package/dist/commands/executionAuditCommands.js +23 -23
- package/dist/commands/globalRoleCommands.js +2 -7
- package/dist/commands/jobCommands.js +1 -4
- package/dist/commands/projectCommands.js +5 -5
- package/dist/commands/releaseCommands.js +3 -10
- package/dist/commands/resourcesCommands.js +2 -2
- package/dist/commands/sessionCommands.js +2 -2
- package/dist/commands/taskActor.js +31 -39
- package/dist/commands/taskChangeSetCommands.js +5 -12
- package/dist/commands/taskCommands.js +464 -1249
- package/dist/commands/taskContextCommand.js +35 -36
- package/dist/commands/taskExecutionCommands.js +33 -46
- package/dist/commands/taskInputCommands.js +20 -42
- package/dist/commands/taskNextActionCommand.js +9 -9
- package/dist/commands/taskOverviewCommand.js +56 -95
- package/dist/commands/taskRoleRuntimeStatus.js +77 -107
- package/dist/commands/taskUpstreamCommands.js +3 -3
- package/dist/commands/taskWorkspaceCommands.js +7 -79
- package/dist/commands/telemetryCommands.js +32 -124
- package/dist/commands/workflowCommands.js +3 -3
- package/dist/completion/fileCompletionManager.js +1 -1
- package/dist/config/configCatalog.js +4 -6
- package/dist/config/yuiConfig.js +6 -43
- package/dist/context/dispatchContext.js +14 -30
- package/dist/context/roleSessionContext.js +2 -2
- package/dist/context/sessionBootstrapManifest.js +2 -2
- package/dist/context/{runContextPack.js → turnContextPack.js} +58 -73
- package/dist/context/turnInputContract.js +204 -0
- package/dist/context/wakeNotification.js +2 -2
- package/dist/controller/agentRuntimeObserver.js +18 -18
- package/dist/controller/clientRuntime.js +13 -20
- package/dist/controller/controller.js +89 -116
- package/dist/controller/fileSchedulerStoreAdapter.js +511 -742
- package/dist/controller/jobControl.js +17 -17
- package/dist/controller/resourceInventory.js +6 -6
- package/dist/controller/resourceInventoryLinux.js +38 -59
- package/dist/controller/resourceInventoryRpc.js +3 -3
- package/dist/controller/resourceInventoryWorker.js +1 -1
- package/dist/controller/runtime.js +46 -53
- package/dist/controller/runtimeEventInbox.js +23 -31
- package/dist/controller/runtimeEventProcessor.js +15 -15
- package/dist/controller/{runtimeHookRunFence.js → runtimeHookTurnFence.js} +87 -81
- package/dist/controller/runtimeLaunchCoordinator.js +3 -3
- package/dist/controller/runtimeObservationHook.js +11 -8
- package/dist/controller/sessionNotify.js +11 -11
- package/dist/controller/structuredProviderObservation.js +89 -16
- package/dist/coordination/workMailbox.js +309 -579
- package/dist/coordination/workMailboxQueue.js +5 -6
- package/dist/core/controllerClient.js +1 -91
- package/dist/core/controllerServer.js +3 -6
- package/dist/doctor/doctor.js +51 -314
- package/dist/execution/candidateConvergence.js +3 -3
- package/dist/execution/executionGroup.js +32 -33
- package/dist/execution/executionHealth.js +36 -38
- package/dist/execution/resourceBroker.js +12 -12
- package/dist/executor/agentExecutor.js +30 -265
- package/dist/executor/effectiveLaunch.js +9 -19
- package/dist/executor/executorRegistry.js +43 -17
- package/dist/executor/fileRoleLaunchPlanner.js +56 -56
- package/dist/executor/launchPlan.js +3 -3
- package/dist/executor/workspacePreflightClassification.js +16 -16
- package/dist/grant/capabilityGrant.js +20 -25
- package/dist/input/inputRequest.js +12 -12
- package/dist/integration/changeSet.js +9 -13
- package/dist/integration/changeSetManifest.js +1 -1
- package/dist/integration/gitIntegrationService.js +2 -2
- package/dist/integration/integrationQueueService.js +5 -21
- package/dist/integration/overlapDiagnostics.js +2 -2
- package/dist/interaction/operatorPresentation.js +1 -1
- package/dist/job/jobRunner.js +1 -1
- package/dist/lifecycle/canonicalLifecycleEvent.js +25 -25
- package/dist/lifecycle/{exactRunTerminalization.js → exactTurnTerminalization.js} +116 -232
- package/dist/message/message.js +6 -6
- package/dist/observability/executionAudit.js +74 -86
- package/dist/observability/faultClassification.js +7 -24
- package/dist/observability/orchestrationMetrics.js +5 -5
- package/dist/observability/runtimeIdentity.js +34 -101
- package/dist/profile/agentProfile.js +1 -1
- package/dist/release/cliHomeReleaseFence.js +3 -3
- package/dist/release/releaseWorkflowEngine.js +6 -10
- package/dist/release/releaseWorkflowPorts.js +2 -2
- package/dist/release/workflowFileLock.js +1 -1
- package/dist/repository/checkoutSwap.js +1 -1
- package/dist/repository/gitWorkspace.js +0 -13
- package/dist/repository/project.js +1 -1
- package/dist/repository/projectMaintenanceLock.js +1 -2
- package/dist/repository/taskBaseFreshness.js +13 -13
- package/dist/repository/taskWorkspaceCoordinator.js +21 -25
- package/dist/repository/taskWorkspaceIdentity.js +8 -21
- package/dist/repository/taskWorkspacePreparer.js +63 -620
- package/dist/resources/autoResourceGc.js +3 -3
- package/dist/resources/liveReferences.js +1 -1
- package/dist/resources/resourceGc.js +1 -1
- package/dist/resources/sqliteResourceRegistry.js +1 -1
- package/dist/review/reviewDecision.js +7 -7
- package/dist/review/reviewFindingLedger.js +1 -1
- package/dist/review/reviewOutcomeClassifier.js +35 -50
- package/dist/review/reviewRound.js +14 -25
- package/dist/review/reviewerAvailability.js +4 -4
- package/dist/review/taskFinalReviewContractResolution.js +41 -0
- package/dist/role/role.js +6 -3
- package/dist/runtime/agentDriver.js +4 -0
- package/dist/runtime/agentHost.js +151 -36
- package/dist/runtime/builtinAgentDrivers.js +79 -2
- package/dist/runtime/codexAppServerRuntime.js +122 -0
- package/dist/runtime/continuationManager.js +3 -5
- package/dist/runtime/exactControlPlane.js +17 -42
- package/dist/runtime/firstProgressAdvisory.js +1 -1
- package/dist/runtime/index.js +2 -2
- package/dist/runtime/launchDiagnostics.js +2 -2
- package/dist/runtime/lifecycleReservation.js +4 -4
- package/dist/runtime/processExitObservation.js +1 -1
- package/dist/runtime/processExitOutbox.js +0 -32
- package/dist/runtime/promptEnvelope.js +9 -9
- package/dist/runtime/providerContinuation.js +2 -2
- package/dist/runtime/providerContinuationReconciliationService.js +2 -2
- package/dist/runtime/providerRuntimeIdentity.js +76 -24
- package/dist/runtime/recentTurnIds.js +38 -0
- package/dist/runtime/runtimeContinuationProjection.js +2 -2
- package/dist/runtime/runtimeHealthPolicy.js +1 -1
- package/dist/runtime/runtimeObservation.js +58 -21
- package/dist/runtime/runtimeProjection.js +19 -27
- package/dist/runtime/sessionLaunchRequest.js +2 -2
- package/dist/runtime/structuredProviderHost.js +177 -12
- package/dist/runtime/tmuxAdapters.js +46 -11
- package/dist/scheduler/activeRoleTurnDelivery.js +245 -0
- package/dist/scheduler/leaderWakeupProcessor.js +147 -445
- package/dist/scheduler/operatorEvent.js +4 -6
- package/dist/scheduler/resourceQueueProjection.js +71 -0
- package/dist/scheduler/{roleRunLiveness.js → roleTurnLiveness.js} +24 -28
- package/dist/scheduler/{roleRunStall.js → roleTurnStall.js} +162 -247
- package/dist/scheduler/taskExecutionProjection.js +99 -99
- package/dist/scheduler/taskObservabilityProjection.js +10 -10
- package/dist/scheduler/taskWake.js +4 -4
- package/dist/scheduler/wakeReason.js +6 -10
- package/dist/scheduler/wakeupQueue.js +0 -9
- package/dist/setup/setupCommand.js +2 -2
- package/dist/storage/currentTaskStore.js +46 -0
- package/dist/storage/persistenceWorker.js +1 -1
- package/dist/storage/sqliteSchema.js +81 -485
- package/dist/storage/sqliteStore.js +206 -365
- package/dist/storage/storageSchema.js +1 -15
- package/dist/storage/storageVersions.js +8 -9
- package/dist/storage/storeRpc.js +10 -34
- package/dist/storage/taskStore.js +63 -3415
- package/dist/storage/upgrade/recordVersions.js +55 -149
- package/dist/storage/upgrade/upgradeOrchestrator.js +89 -1752
- package/dist/task/completionReadiness.js +5 -5
- package/dist/task/deliveryGuard.js +10 -10
- package/dist/task/nextAction.js +74 -77
- package/dist/task/task.js +2 -4
- package/dist/task/taskRecordReference.js +3 -3
- package/dist/task/taskRecordRetirement.js +1 -1
- package/dist/telemetry/sqliteTelemetryStore.js +53 -53
- package/dist/telemetry/telemetryConfig.js +14 -14
- package/dist/telemetry/telemetryWiring.js +8 -14
- package/dist/turn/turn.js +356 -0
- package/dist/{run/runIdentity.js → turn/turnIdentity.js} +4 -4
- package/dist/verification/gateArtifactStore.js +2 -2
- package/dist/web/assets/client/app.js +1 -1
- package/dist/web/assets/client/components.js +29 -54
- package/dist/web/assets/client/i18n.js +17 -37
- package/dist/web/assets/client/view.js +37 -37
- package/dist/web/assets/shell.js +1 -1
- package/dist/web/assets/styles/cards.js +5 -5
- package/dist/web/assets/styles/widgets.js +1 -2
- package/dist/web/webSnapshot.js +65 -60
- package/dist/workItem/workItem.js +11 -11
- package/dist/workspace/workItemChangeSetManager.js +1 -1
- package/docs/task-local-identity.md +5 -5
- package/i18n/README.zh-CN.md +41 -54
- package/package.json +1 -1
- package/skills/yui-leader/SKILL.md +85 -83
- package/skills/yui-operator/SKILL.md +16 -16
- package/skills/yui-reviewer/SKILL.md +10 -10
- package/skills/yui-runtime/SKILL.md +17 -18
- package/skills/yui-worker/SKILL.md +16 -18
- package/dist/context/runContextContract.js +0 -162
- package/dist/executor/turnCompletion.js +0 -126
- package/dist/review/taskFinalReviewContractEvent.js +0 -1
- package/dist/review/taskFinalReviewContractRebind.js +0 -367
- package/dist/run/agentRun.js +0 -356
- package/dist/run/rejectedYieldAttempt.js +0 -221
- package/dist/run/runControlRequest.js +0 -50
- package/dist/run/yieldReceipt.js +0 -65
- package/dist/runtime/turnCompletion.js +0 -3
- package/dist/scheduler/actionability.js +0 -323
- package/dist/scheduler/activeRoleRunDelivery.js +0 -868
- package/dist/scheduler/activeTaskProgress.js +0 -126
- package/dist/storage/compatibleTaskStore.js +0 -248
- package/dist/storage/migration/baseline.js +0 -78
- package/dist/storage/migration/classifier.js +0 -51
- package/dist/storage/migration/compatibleCodec.js +0 -53
- package/dist/storage/migration/engine.js +0 -147
- package/dist/storage/migration/index.js +0 -33
- package/dist/storage/migration/planner.js +0 -154
- package/dist/storage/migration/productionRegistry.js +0 -3931
- package/dist/storage/migration/registry.js +0 -169
- package/dist/storage/migration/report.js +0 -54
- package/dist/storage/migration/types.js +0 -31
- package/dist/storage/upgrade/homeClassification.js +0 -353
- package/dist/storage/upgrade/homeMigrationTarget.js +0 -595
- package/dist/storage/upgrade/migrationReceipt.js +0 -67
- package/dist/storage/upgrade/offlineUpgradeInventory.js +0 -453
- package/dist/storage/upgrade/productionMigrationRegistry.js +0 -6
- package/dist/storage/upgrade/pseudoLayoutRepair.js +0 -241
- package/dist/storage/upgrade/recordVersionScan.js +0 -176
- package/dist/storage/upgrade/sqliteFileSet.js +0 -50
- package/dist/storage/upgrade/sqliteMigrationTarget.js +0 -375
- package/dist/storage/upgrade/sqliteRecordMigrationTarget.js +0 -305
- package/dist/storage/upgrade/sqliteStateMigration.js +0 -918
- package/dist/storage/upgrade/switchProgress.js +0 -80
- package/dist/storage/upgrade/upgradeReceipt.js +0 -161
- package/dist/storage/upgradeCoordination.js +0 -187
- package/dist/storage/upgradeFence.js +0 -366
- package/dist/telemetry/telemetryCompaction.js +0 -252
|
@@ -2,7 +2,7 @@ import { callController } from "../core/controllerClient.js";
|
|
|
2
2
|
import { FileRuntimeEventInbox } from "./runtimeEventInbox.js";
|
|
3
3
|
import { runtimeLifecycleSignalKey } from "../runtime/lifecycleReservation.js";
|
|
4
4
|
import { setCodexThreadName } from "../execution/codexThreadNaming.js";
|
|
5
|
-
import {
|
|
5
|
+
import { openCurrentTaskStore } from "../storage/currentTaskStore.js";
|
|
6
6
|
const NO_FINAL_ASSISTANT_MESSAGE_SUMMARY = "Native Turn completed without a final assistant message.";
|
|
7
7
|
/** Hidden CLI entrypoint used by Codex's structured notify hook. */
|
|
8
8
|
export async function runSessionNotifyCommand(payloadArgument, environment = process.env, call, setThreadName = setCodexThreadName) {
|
|
@@ -16,8 +16,8 @@ export async function runSessionNotifyCommand(payloadArgument, environment = pro
|
|
|
16
16
|
adapterId: params.adapterId,
|
|
17
17
|
launchId: params.launchId,
|
|
18
18
|
nativeSessionId: params.nativeSessionId,
|
|
19
|
-
|
|
20
|
-
...(params.
|
|
19
|
+
nativeTurnId: params.nativeTurnId,
|
|
20
|
+
...(params.turnId === undefined ? {} : { turnId: params.turnId }),
|
|
21
21
|
...(params.title === undefined ? {} : { title: params.title }),
|
|
22
22
|
summary: params.lastAssistantMessage
|
|
23
23
|
});
|
|
@@ -47,11 +47,11 @@ export function parseCodexSessionNotification(payloadArgument, environment) {
|
|
|
47
47
|
throw new Error("Codex notify payload type is invalid.");
|
|
48
48
|
}
|
|
49
49
|
const nativeSessionId = requireText(payload["thread-id"], "Codex thread-id");
|
|
50
|
-
const
|
|
50
|
+
const nativeTurnId = requireText(payload["turn-id"], "Codex turn-id");
|
|
51
51
|
const lastAssistantMessage = requireAssistantMessage(payload["last-assistant-message"]);
|
|
52
|
-
const
|
|
52
|
+
const turnId = environment.YUI_TURN_ID === undefined
|
|
53
53
|
? undefined
|
|
54
|
-
: requireText(environment.
|
|
54
|
+
: requireText(environment.YUI_TURN_ID, "YUI_TURN_ID");
|
|
55
55
|
const title = environment.YUI_SESSION_TITLE === undefined
|
|
56
56
|
? undefined
|
|
57
57
|
: requireText(environment.YUI_SESSION_TITLE, "YUI_SESSION_TITLE");
|
|
@@ -66,8 +66,8 @@ export function parseCodexSessionNotification(payloadArgument, environment) {
|
|
|
66
66
|
adapterId: requireCodexAdapter(environment.YUI_ADAPTER_ID),
|
|
67
67
|
launchId: requireText(environment.YUI_LAUNCH_ID, "YUI_LAUNCH_ID"),
|
|
68
68
|
nativeSessionId,
|
|
69
|
-
|
|
70
|
-
...(
|
|
69
|
+
nativeTurnId,
|
|
70
|
+
...(turnId === undefined ? {} : { turnId }),
|
|
71
71
|
...(title === undefined ? {} : { title }),
|
|
72
72
|
lastAssistantMessage
|
|
73
73
|
};
|
|
@@ -121,11 +121,11 @@ function requireAssistantMessage(value) {
|
|
|
121
121
|
function shouldSetThreadName(home, params) {
|
|
122
122
|
if (params.scope !== "task"
|
|
123
123
|
|| params.title === undefined
|
|
124
|
-
|| params.
|
|
124
|
+
|| params.turnId === undefined)
|
|
125
125
|
return false;
|
|
126
126
|
try {
|
|
127
|
-
const store =
|
|
128
|
-
return store.
|
|
127
|
+
const store = openCurrentTaskStore(home);
|
|
128
|
+
return store.getTurn(params.taskId, params.turnId)?.mode === "new";
|
|
129
129
|
}
|
|
130
130
|
catch {
|
|
131
131
|
return false;
|
|
@@ -6,21 +6,54 @@ import { createRuntimeObservation, runtimeObservationSemanticKey } from "../runt
|
|
|
6
6
|
import { runtimeLifecycleSignalKey } from "../runtime/lifecycleReservation.js";
|
|
7
7
|
import { isForeignHandoverLockHeld } from "../release/runtimeRelease.js";
|
|
8
8
|
import { FileRuntimeEventInbox } from "./runtimeEventInbox.js";
|
|
9
|
-
import {
|
|
9
|
+
import { resolveRuntimeHookTurnFence } from "./runtimeHookTurnFence.js";
|
|
10
10
|
let structuredSequence = 0;
|
|
11
|
+
export async function publishStructuredProviderStarted(input) {
|
|
12
|
+
if (input.started.clientOwned)
|
|
13
|
+
return;
|
|
14
|
+
const adapterId = requireIdentity(input.environment.YUI_ADAPTER_ID, "Agent adapter id");
|
|
15
|
+
const driver = builtinAgentDriverRegistry().requireByAdapterId(adapterId);
|
|
16
|
+
const fence = resolveRuntimeHookTurnFence(input.environment, adapterId, input.started.nativeSessionId, {
|
|
17
|
+
nativeTurnId: input.started.nativeTurnId,
|
|
18
|
+
sessionOnly: true
|
|
19
|
+
});
|
|
20
|
+
const receiptId = `direct:${input.started.nativeTurnId}`;
|
|
21
|
+
const startedObservation = observation({
|
|
22
|
+
kind: "turn.accepted",
|
|
23
|
+
observedAt: input.started.observedAt,
|
|
24
|
+
sequence: nextStructuredSequence(),
|
|
25
|
+
ordinal: 0,
|
|
26
|
+
fence: {
|
|
27
|
+
taskId: fence.taskId,
|
|
28
|
+
roleName: fence.roleName,
|
|
29
|
+
agentId: fence.agentId,
|
|
30
|
+
driverId: driver.id,
|
|
31
|
+
launchId: fence.launchId,
|
|
32
|
+
sessionGenerationId: fence.launchId,
|
|
33
|
+
conversationId: input.started.conversationId,
|
|
34
|
+
activationId: requireIdentity(input.activationId, "Provider Activation id"),
|
|
35
|
+
nativeSessionId: input.started.nativeSessionId,
|
|
36
|
+
nativeTurnId: input.started.nativeTurnId,
|
|
37
|
+
receiptId
|
|
38
|
+
},
|
|
39
|
+
payload: input.started.input === undefined ? {} : { input: input.started.input }
|
|
40
|
+
});
|
|
41
|
+
await persistAndApply(input.home, [startedObservation], fence.taskId, fence.roleName);
|
|
42
|
+
}
|
|
11
43
|
export async function publishStructuredProviderAccepted(input) {
|
|
12
44
|
const adapterId = requireIdentity(input.environment.YUI_ADAPTER_ID, "Agent adapter id");
|
|
13
45
|
const driver = builtinAgentDriverRegistry().requireByAdapterId(adapterId);
|
|
14
46
|
const startupSession = driver.capabilities.observation.sessionBootstrap;
|
|
15
|
-
const fence =
|
|
47
|
+
const fence = resolveRuntimeHookTurnFence(input.environment, adapterId, input.receipt.nativeSessionId, {
|
|
16
48
|
startupSession,
|
|
17
|
-
nativeTurnId: input.receipt.nativeTurnId
|
|
49
|
+
nativeTurnId: input.receipt.nativeTurnId,
|
|
50
|
+
attemptId: input.receipt.attemptId
|
|
18
51
|
});
|
|
19
52
|
const observedAt = input.receipt.acceptedAt;
|
|
20
53
|
const commonFence = {
|
|
21
54
|
taskId: fence.taskId,
|
|
22
55
|
roleName: fence.roleName,
|
|
23
|
-
|
|
56
|
+
...(fence.turnId === undefined ? {} : { turnId: fence.turnId }),
|
|
24
57
|
agentId: fence.agentId,
|
|
25
58
|
driverId: driver.id,
|
|
26
59
|
launchId: fence.launchId,
|
|
@@ -30,7 +63,7 @@ export async function publishStructuredProviderAccepted(input) {
|
|
|
30
63
|
nativeSessionId: input.receipt.nativeSessionId,
|
|
31
64
|
nativeTurnId: input.receipt.nativeTurnId,
|
|
32
65
|
// The structured Host owns the exact input attempt identity. Runtime
|
|
33
|
-
// descriptor receipts name the
|
|
66
|
+
// descriptor receipts name the Turn bootstrap and must not overwrite a
|
|
34
67
|
// continuation or human-takeover Turn.
|
|
35
68
|
receiptId: input.receipt.attemptId
|
|
36
69
|
};
|
|
@@ -67,11 +100,11 @@ export async function publishStructuredProviderOpened(input) {
|
|
|
67
100
|
const adapterId = requireIdentity(input.environment.YUI_ADAPTER_ID, "Agent adapter id");
|
|
68
101
|
const driver = builtinAgentDriverRegistry().requireByAdapterId(adapterId);
|
|
69
102
|
const startupSession = driver.capabilities.observation.sessionBootstrap;
|
|
70
|
-
const fence =
|
|
103
|
+
const fence = resolveRuntimeHookTurnFence(input.environment, adapterId, input.nativeSessionId, { startupSession });
|
|
71
104
|
const commonFence = {
|
|
72
105
|
taskId: fence.taskId,
|
|
73
106
|
roleName: fence.roleName,
|
|
74
|
-
|
|
107
|
+
...(fence.turnId === undefined ? {} : { turnId: fence.turnId }),
|
|
75
108
|
agentId: fence.agentId,
|
|
76
109
|
driverId: driver.id,
|
|
77
110
|
launchId: fence.launchId,
|
|
@@ -104,15 +137,47 @@ export async function publishStructuredProviderOpened(input) {
|
|
|
104
137
|
})];
|
|
105
138
|
await persistAndApply(input.home, observations, fence.taskId, fence.roleName);
|
|
106
139
|
}
|
|
140
|
+
export async function publishStructuredProviderGoal(input) {
|
|
141
|
+
const adapterId = requireIdentity(input.environment.YUI_ADAPTER_ID, "Agent adapter id");
|
|
142
|
+
const driver = builtinAgentDriverRegistry().requireByAdapterId(adapterId);
|
|
143
|
+
const fence = resolveRuntimeHookTurnFence(input.environment, adapterId, input.conversationId, { sessionOnly: true });
|
|
144
|
+
const goal = input.goal;
|
|
145
|
+
const observedAt = input.observedAt ?? goal?.updatedAt ?? new Date().toISOString();
|
|
146
|
+
const goalObservation = observation({
|
|
147
|
+
kind: goal === null ? "goal.cleared" : "goal.updated",
|
|
148
|
+
observedAt,
|
|
149
|
+
sequence: nextStructuredSequence(),
|
|
150
|
+
ordinal: 0,
|
|
151
|
+
fence: {
|
|
152
|
+
taskId: fence.taskId,
|
|
153
|
+
roleName: fence.roleName,
|
|
154
|
+
agentId: fence.agentId,
|
|
155
|
+
driverId: driver.id,
|
|
156
|
+
launchId: fence.launchId,
|
|
157
|
+
sessionGenerationId: fence.launchId,
|
|
158
|
+
conversationId: input.conversationId,
|
|
159
|
+
activationId: requireIdentity(input.activationId, "Provider Activation id"),
|
|
160
|
+
nativeSessionId: input.conversationId
|
|
161
|
+
},
|
|
162
|
+
payload: goal === null ? {} : {
|
|
163
|
+
goalStatus: goal.status,
|
|
164
|
+
goalObjective: goal.objective,
|
|
165
|
+
goalUpdatedAt: goal.updatedAt,
|
|
166
|
+
...(goal.nativeTurnId === undefined ? {} : { goalNativeTurnId: goal.nativeTurnId }),
|
|
167
|
+
...(goal.tokenBudget === undefined ? {} : { goalTokenBudget: goal.tokenBudget })
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
await persistAndApply(input.home, [goalObservation], fence.taskId, fence.roleName);
|
|
171
|
+
}
|
|
107
172
|
export async function publishStructuredConversationRecoverability(input) {
|
|
108
173
|
const adapterId = requireIdentity(input.environment.YUI_ADAPTER_ID, "Agent adapter id");
|
|
109
174
|
const driver = builtinAgentDriverRegistry().requireByAdapterId(adapterId);
|
|
110
|
-
const fence =
|
|
175
|
+
const fence = resolveRuntimeHookTurnFence(input.environment, adapterId, input.conversationId);
|
|
111
176
|
const sequence = nextStructuredSequence();
|
|
112
177
|
const observationFence = {
|
|
113
178
|
taskId: fence.taskId,
|
|
114
179
|
roleName: fence.roleName,
|
|
115
|
-
|
|
180
|
+
...(fence.turnId === undefined ? {} : { turnId: fence.turnId }),
|
|
116
181
|
agentId: fence.agentId,
|
|
117
182
|
driverId: driver.id,
|
|
118
183
|
launchId: fence.launchId,
|
|
@@ -151,12 +216,19 @@ export async function publishStructuredConversationRecoverability(input) {
|
|
|
151
216
|
export async function publishStructuredProviderTerminal(input) {
|
|
152
217
|
const adapterId = requireIdentity(input.environment.YUI_ADAPTER_ID, "Agent adapter id");
|
|
153
218
|
const driver = builtinAgentDriverRegistry().requireByAdapterId(adapterId);
|
|
154
|
-
const fence =
|
|
219
|
+
const fence = resolveRuntimeHookTurnFence(input.environment, adapterId, input.terminal.nativeSessionId, {
|
|
220
|
+
terminal: true,
|
|
221
|
+
nativeTurnId: input.terminal.nativeTurnId,
|
|
222
|
+
...(input.terminal.clientOwned ? {} : { sessionOnly: true })
|
|
223
|
+
});
|
|
155
224
|
const kind = input.terminal.status === "completed"
|
|
156
225
|
? "turn.completed"
|
|
157
226
|
: input.terminal.status === "cancelled" ? "turn.cancelled" : "turn.failed";
|
|
158
227
|
const payload = kind === "turn.completed"
|
|
159
|
-
? {
|
|
228
|
+
? {
|
|
229
|
+
...(input.terminal.input === undefined ? {} : { input: input.terminal.input }),
|
|
230
|
+
...(input.terminal.summary === undefined ? {} : { summary: input.terminal.summary })
|
|
231
|
+
}
|
|
160
232
|
: kind === "turn.failed"
|
|
161
233
|
? {
|
|
162
234
|
failure: {
|
|
@@ -176,7 +248,8 @@ export async function publishStructuredProviderTerminal(input) {
|
|
|
176
248
|
inputDisposition: "accepted"
|
|
177
249
|
})
|
|
178
250
|
},
|
|
179
|
-
summary: input.terminal.error ?? "Provider Turn failed."
|
|
251
|
+
summary: input.terminal.error ?? "Provider Turn failed.",
|
|
252
|
+
...(input.terminal.input === undefined ? {} : { input: input.terminal.input })
|
|
180
253
|
}
|
|
181
254
|
: {};
|
|
182
255
|
const terminalObservation = observation({
|
|
@@ -187,7 +260,7 @@ export async function publishStructuredProviderTerminal(input) {
|
|
|
187
260
|
fence: {
|
|
188
261
|
taskId: fence.taskId,
|
|
189
262
|
roleName: fence.roleName,
|
|
190
|
-
|
|
263
|
+
...(fence.turnId === undefined ? {} : { turnId: fence.turnId }),
|
|
191
264
|
agentId: fence.agentId,
|
|
192
265
|
driverId: driver.id,
|
|
193
266
|
launchId: fence.launchId,
|
|
@@ -205,7 +278,7 @@ export async function publishStructuredProviderTerminal(input) {
|
|
|
205
278
|
export async function publishStructuredProviderActivationTerminal(input) {
|
|
206
279
|
const adapterId = requireIdentity(input.environment.YUI_ADAPTER_ID, "Agent adapter id");
|
|
207
280
|
const driver = builtinAgentDriverRegistry().requireByAdapterId(adapterId);
|
|
208
|
-
const fence =
|
|
281
|
+
const fence = resolveRuntimeHookTurnFence(input.environment, adapterId, input.nativeSessionId, { sessionOnly: true });
|
|
209
282
|
const terminal = observation({
|
|
210
283
|
kind: input.status === "failed" ? "activation.failed" : "activation.ended",
|
|
211
284
|
observedAt: input.observedAt,
|
|
@@ -214,7 +287,7 @@ export async function publishStructuredProviderActivationTerminal(input) {
|
|
|
214
287
|
fence: {
|
|
215
288
|
taskId: fence.taskId,
|
|
216
289
|
roleName: fence.roleName,
|
|
217
|
-
|
|
290
|
+
...(fence.turnId === undefined ? {} : { turnId: fence.turnId }),
|
|
218
291
|
agentId: fence.agentId,
|
|
219
292
|
driverId: driver.id,
|
|
220
293
|
launchId: fence.launchId,
|
|
@@ -291,7 +364,7 @@ async function persistAndApply(home, observations, taskId, roleName) {
|
|
|
291
364
|
throw error;
|
|
292
365
|
}
|
|
293
366
|
// A fast Provider can accept the initial Turn before the scheduler call
|
|
294
|
-
// that launched this Host has returned and committed `
|
|
367
|
+
// that launched this Host has returned and committed `turn.pushed`. The
|
|
295
368
|
// immutable inbox entry already makes that exact fenced fact durable;
|
|
296
369
|
// `deferred` therefore means "retained for replay", not delivery failure.
|
|
297
370
|
// The signal below schedules the replay after the transport transaction.
|