@zq-silk/yui 0.15.7 → 0.15.8
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 +192 -399
- package/README.md +127 -1149
- package/dist/agent/adapterCatalog.js +15 -2
- package/dist/agent/agent.js +23 -3
- package/dist/agent/argumentPolicy.js +7 -1
- package/dist/agent/connectionPlan.js +62 -0
- package/dist/agent/executionComponents.js +158 -0
- package/dist/agent/launchEnvironment.js +31 -3
- package/dist/agent/managedRuntimeEnvironment.js +3 -5
- package/dist/{turn/turn.js → agentRun/agentRun.js} +166 -109
- package/dist/{turn/turnIdentity.js → agentRun/runIdentity.js} +4 -4
- package/dist/brief/taskBrief.js +12 -0
- package/dist/cli/agentConfigurationPicker.js +13 -0
- package/dist/cli/commandCatalog.js +157 -70
- package/dist/cli/interactionCandidates.js +5 -5
- package/dist/cli/interactionPolicy.js +38 -8
- package/dist/cli/invocationRouter.js +1 -1
- package/dist/cli/managedDiagnostics.js +28 -0
- package/dist/cli/operatorWizard.js +1 -7
- package/dist/cli/roleOptionOrder.js +27 -0
- package/dist/cli/roleWizard.js +50 -14
- package/dist/cli/updateOrchestrator.js +1 -1
- package/dist/cli/updatePorts.js +3 -4
- package/dist/cli.js +178 -95
- package/dist/commands/agentCommands.js +72 -14
- package/dist/commands/capabilityCommands.js +9 -6
- package/dist/commands/configCommands.js +20 -20
- package/dist/commands/deliveryGuardPreflight.js +2 -2
- package/dist/commands/executionAuditCommands.js +24 -24
- package/dist/commands/globalRoleCommands.js +1 -1
- package/dist/commands/grantCommands.js +4 -4
- package/dist/commands/operatorCommands.js +1 -7
- package/dist/commands/projectCommands.js +4 -4
- package/dist/commands/resourcesCommands.js +2 -2
- package/dist/commands/roleConfiguration.js +25 -5
- package/dist/commands/roleRuntimeGuard.js +4 -5
- package/dist/commands/sessionCommands.js +3 -7
- package/dist/commands/taskActivationCommands.js +259 -0
- package/dist/commands/taskActor.js +28 -49
- package/dist/commands/taskCommands.js +1188 -710
- package/dist/commands/taskContextCommand.js +39 -583
- package/dist/commands/taskExecutionCommands.js +32 -32
- package/dist/commands/taskInputCommands.js +40 -104
- package/dist/commands/taskIntegrationCommands.js +3 -2
- package/dist/commands/taskIntegrationQueueCommands.js +1 -1
- package/dist/commands/taskNextActionCommand.js +8 -8
- package/dist/commands/taskOverviewCommand.js +33 -45
- package/dist/commands/taskRemoteDeliveryCommand.js +2 -2
- package/dist/commands/taskRoleRuntimeStatus.js +133 -102
- package/dist/commands/telemetryCommands.js +36 -38
- package/dist/config/configCatalog.js +4 -4
- package/dist/config/yuiConfig.js +8 -8
- package/dist/context/contextSnapshot.js +10 -10
- package/dist/context/dispatchContext.js +11 -11
- package/dist/context/roleSessionContext.js +6 -3
- package/dist/context/{turnContextPack.js → runContextPack.js} +146 -81
- package/dist/context/{turnInputContract.js → runInputContract.js} +73 -60
- package/dist/context/sessionBootstrapManifest.js +21 -2
- package/dist/context/sourceRunContext.js +30 -0
- package/dist/context/taskContext.js +458 -0
- package/dist/context/wakeNotification.js +27 -27
- package/dist/controller/agentRuntimeObserver.js +21 -24
- package/dist/controller/capabilityBridge.js +17 -6
- package/dist/controller/clientRuntime.js +65 -92
- package/dist/controller/controller.js +114 -188
- package/dist/controller/fileSchedulerStoreAdapter.js +787 -887
- package/dist/controller/jobControl.js +54 -85
- package/dist/controller/resourceInventory.js +8 -27
- package/dist/controller/resourceInventoryLinux.js +12 -13
- package/dist/controller/runtime.js +529 -479
- package/dist/controller/runtimeEventInbox.js +55 -25
- package/dist/controller/runtimeEventProcessor.js +22 -31
- package/dist/controller/{runtimeHookTurnFence.js → runtimeHookRunFence.js} +91 -115
- package/dist/controller/runtimeLaunchCoordinator.js +80 -426
- package/dist/controller/runtimeObservationHook.js +14 -18
- package/dist/controller/sessionNotify.js +16 -24
- package/dist/controller/sessionOwnerReconciliation.js +168 -50
- package/dist/controller/structuredProviderObservation.js +138 -99
- package/dist/coordination/workMailbox.js +3 -3
- package/dist/coordination/workMailboxQueue.js +36 -33
- package/dist/core/boundedRpc.js +8 -1
- package/dist/core/controllerClient.js +20 -1
- package/dist/core/controllerServer.js +4 -4
- package/dist/doctor/doctor.js +13 -2
- package/dist/domain/agentResultTransport.js +9 -9
- package/dist/execution/codexThreadNaming.js +2 -8
- package/dist/execution/executionHealth.js +51 -63
- package/dist/execution/reviewMainRun.js +137 -0
- package/dist/execution/workItemExecution.js +28 -29
- package/dist/execution/workItemExecutionProjection.js +99 -107
- package/dist/execution/workItemMainRun.js +141 -0
- package/dist/executor/agentAdapter.js +227 -20
- package/dist/executor/agentConfigurationCatalog.js +126 -4
- package/dist/executor/agentConfigurationProbe.js +162 -4
- package/dist/executor/agentExecutor.js +79 -78
- package/dist/executor/effectiveLaunch.js +105 -18
- package/dist/executor/executorRegistry.js +29 -44
- package/dist/executor/fileRoleLaunchPlanner.js +229 -154
- package/dist/executor/workspacePreflightClassification.js +16 -16
- package/dist/grant/capabilityGrant.js +6 -3
- package/dist/input/inputRequest.js +12 -10
- package/dist/integration/gitIntegrationService.js +4 -11
- package/dist/integration/integrationQueueService.js +4 -4
- package/dist/interaction/operatorPresentation.js +1 -1
- package/dist/kernel/builtinCapabilities.js +247 -12
- package/dist/kernel/capabilityRegistry.js +64 -18
- package/dist/kernel/instanceHost.js +12 -1
- package/dist/kernel/kernelPorts.js +2 -2
- package/dist/lifecycle/canonicalLifecycleEvent.js +44 -49
- package/dist/lifecycle/exactRunTerminalization.js +449 -0
- package/dist/message/message.js +62 -6
- package/dist/message/messageContinuation.js +204 -0
- package/dist/observability/executionAudit.js +70 -72
- package/dist/observability/faultClassification.js +2 -2
- package/dist/observability/orchestrationMetrics.js +8 -8
- package/dist/operator/operatorSessionHistory.js +1 -7
- package/dist/output/agentConfigurationPresentation.js +8 -3
- package/dist/output/agentRunConfigurationPresentation.js +128 -0
- package/dist/output/rolePresentation.js +54 -3
- package/dist/plugins/pluginChild.js +104 -0
- package/dist/plugins/pluginIntent.js +26 -0
- package/dist/plugins/pluginInterpreter.js +43 -0
- package/dist/plugins/pluginPackage.js +101 -0
- package/dist/plugins/pluginProcess.js +112 -0
- package/dist/plugins/pluginService.js +380 -0
- package/dist/profile/agentProfile.js +1 -1
- package/dist/repository/gitWorkspace.js +26 -4
- package/dist/repository/project.js +19 -4
- package/dist/repository/taskBaseFreshness.js +13 -13
- package/dist/repository/taskWorkspaceCoordinator.js +20 -27
- package/dist/repository/taskWorkspacePreparer.js +344 -83
- package/dist/resources/autoResourceGc.js +3 -3
- package/dist/resources/liveReferences.js +3 -3
- package/dist/resources/projectResource.js +123 -0
- package/dist/resources/projectResourceService.js +421 -0
- package/dist/resources/resourceDiscovery.js +6 -6
- package/dist/resources/resourceGc.js +1 -1
- package/dist/resources/resourceRegistrar.js +1 -1
- package/dist/resources/resourceTypes.js +1 -1
- package/dist/review/deltaRecheck.js +3 -3
- package/dist/review/reviewAcceptance.js +16 -16
- package/dist/review/reviewDecision.js +7 -7
- package/dist/review/reviewRound.js +21 -20
- package/dist/review/reviewerAvailability.js +2 -2
- package/dist/role/role.js +51 -7
- package/dist/role/taskRoleUpdate.js +30 -0
- package/dist/runtime/acpProtocol.js +425 -0
- package/dist/runtime/acpSession.js +731 -0
- package/dist/runtime/acpSessionConfiguration.js +260 -0
- package/dist/runtime/agentDriver.js +30 -11
- package/dist/runtime/agentEndpoint.js +278 -0
- package/dist/runtime/agentEndpointIdentity.js +86 -0
- package/dist/runtime/agentEndpointOwnership.js +239 -0
- package/dist/runtime/agentError.js +2 -10
- package/dist/runtime/agentHost.js +565 -314
- package/dist/runtime/agentRunConfiguration.js +258 -0
- package/dist/runtime/builtinAgentDrivers.js +134 -18
- package/dist/runtime/builtinAgentErrorMappers.js +55 -3
- package/dist/runtime/builtinTranscriptUsage.js +1 -1
- package/dist/runtime/claude-process-owner +0 -0
- package/dist/runtime/codexAppServerRuntime.js +38 -30
- package/dist/runtime/codexInteractiveHost.js +41 -6
- package/dist/runtime/continuationManager.js +2 -6
- package/dist/runtime/executionEnvironment.js +30 -0
- package/dist/runtime/firstProgressAdvisory.js +11 -11
- package/dist/runtime/index.js +4 -3
- package/dist/runtime/jsonLineChannel.js +109 -0
- package/dist/runtime/launchBroker.js +91 -16
- package/dist/runtime/launchDiagnostics.js +2 -2
- package/dist/runtime/lifecycleReservation.js +10 -18
- package/dist/runtime/managedCaller.js +61 -17
- package/dist/runtime/nativeSessionControl.js +102 -0
- package/dist/runtime/ports.js +6 -21
- package/dist/runtime/processExitObservation.js +8 -7
- package/dist/runtime/promptEnvelope.js +17 -6
- package/dist/runtime/providerContinuation.js +3 -9
- package/dist/runtime/providerContinuationReconciliationService.js +4 -13
- package/dist/runtime/providerControl.js +2 -7
- package/dist/runtime/providerRuntimeIdentity.js +110 -222
- package/dist/runtime/providerRuntimeReconciler.js +5 -9
- package/dist/runtime/runtimeBinding.js +0 -1
- package/dist/runtime/runtimeContinuationProjection.js +4 -7
- package/dist/runtime/runtimeDeadlines.js +9 -0
- package/dist/runtime/runtimeHealthPolicy.js +1 -1
- package/dist/runtime/runtimeObservation.js +29 -65
- package/dist/runtime/runtimeProjection.js +43 -51
- package/dist/runtime/runtimeSessionCandidate.js +1 -3
- package/dist/runtime/sessionLaunchRequest.js +3 -7
- package/dist/runtime/sessionOwnerIdentity.js +7 -54
- package/dist/runtime/sessionOwnerRegistry.js +22 -17
- package/dist/runtime/sessionReconciliation.js +4 -8
- package/dist/runtime/sessionTerminationGuard.js +70 -259
- package/dist/runtime/sessionTokenMetrics.js +5 -16
- package/dist/runtime/structuredProviderHost.js +237 -117
- package/dist/runtime/taskRuntimeIsolation.js +39 -122
- package/dist/runtime/tmuxAdapters.js +39 -86
- package/dist/scheduler/activeRoleRunDelivery.js +354 -0
- package/dist/scheduler/leaderWakeupProcessor.js +75 -266
- package/dist/scheduler/operatorInputNotificationProcessor.js +1 -1
- package/dist/scheduler/ports.js +80 -9
- package/dist/scheduler/{roleTurnLiveness.js → roleRunLiveness.js} +26 -30
- package/dist/scheduler/{roleTurnStall.js → roleRunStall.js} +128 -139
- package/dist/scheduler/taskExecutionProjection.js +120 -124
- package/dist/scheduler/taskObservabilityProjection.js +29 -29
- package/dist/scheduler/taskWake.js +11 -4
- package/dist/scheduler/wakeReason.js +9 -1
- package/dist/setup/setupCommand.js +1 -0
- package/dist/storage/migrations/agentRunContract.js +159 -0
- package/dist/storage/migrations/removeRuntimeGeneration.js +207 -0
- package/dist/storage/sqliteSchema.js +431 -5
- package/dist/storage/sqliteStore.js +375 -220
- package/dist/storage/storageVersions.js +1 -1
- package/dist/storage/storeRpc.js +10 -5
- package/dist/storage/taskStore.js +13 -11
- package/dist/storage/upgrade/upgradeOrchestrator.js +5 -7
- package/dist/surface/surfaceContributions.js +102 -0
- package/dist/task/completionReadiness.js +32 -6
- package/dist/task/deliveryGuard.js +16 -16
- package/dist/task/draftPlan.js +72 -12
- package/dist/task/nextAction.js +144 -128
- package/dist/task/remoteDelivery.js +6 -6
- package/dist/task/task.js +184 -18
- package/dist/task/taskActivation.js +301 -0
- package/dist/task/taskActivationService.js +392 -0
- package/dist/task/taskRecordReference.js +5 -4
- package/dist/task/taskRecordRetirement.js +1 -1
- package/dist/telemetry/sqliteTelemetryStore.js +55 -68
- package/dist/telemetry/telemetryConfig.js +14 -14
- package/dist/telemetry/telemetryWiring.js +2 -2
- package/dist/web/assets/assetManifest.js +2 -0
- package/dist/web/assets/client/app.js +120 -20
- package/dist/web/assets/client/components.js +87 -54
- package/dist/web/assets/client/i18n.js +83 -41
- package/dist/web/assets/client/markdown.js +1 -1
- package/dist/web/assets/client/taskSurface.js +353 -0
- package/dist/web/assets/client/view.js +49 -44
- package/dist/web/assets/shell.js +1 -1
- package/dist/web/assets/styles/cards.js +22 -4
- package/dist/web/controllerWeb.js +60 -0
- package/dist/web/webMutation.js +28 -0
- package/dist/web/webServer.js +118 -8
- package/dist/web/webSnapshot.js +81 -74
- package/dist/web/webTaskSurface.js +64 -0
- package/dist/workItem/dependencyGate.js +1 -1
- package/dist/workItem/workItem.js +80 -48
- package/dist/workspace/workItemChangeSetManager.js +16 -9
- package/docs/agent-result-consumption.md +94 -0
- package/docs/agent-runtime-drivers.md +91 -0
- package/docs/architecture/README.md +38 -0
- package/docs/architecture/capabilities-and-resources.md +79 -0
- package/docs/managed-turn-and-session-runtime.md +222 -0
- package/docs/observability/README.md +81 -0
- package/docs/plugin-sdk.md +290 -0
- package/docs/provider-runtime.md +163 -0
- package/docs/release-workflow.md +303 -0
- package/docs/roles-and-configuration.md +113 -0
- package/docs/sqlite-control-plane-design.md +76 -0
- package/docs/task-dag-semantics.md +57 -0
- package/docs/task-delivery.md +103 -0
- package/docs/task-local-identity.md +6 -6
- package/docs/testing/verification-levels.md +86 -0
- package/i18n/README.zh-CN.md +98 -739
- package/package.json +2 -2
- package/skills/yui-leader/SKILL.md +130 -103
- package/skills/yui-leader/references/integration.md +39 -0
- package/skills/yui-leader/references/replicated-execution.md +42 -0
- package/skills/yui-leader/references/task-plugins.md +33 -0
- package/skills/yui-operator/SKILL.md +30 -59
- package/skills/yui-reviewer/SKILL.md +35 -36
- package/skills/yui-runtime/SKILL.md +88 -24
- package/skills/yui-runtime/references/publication.md +22 -0
- package/skills/yui-runtime/references/recovery.md +64 -0
- package/skills/yui-worker/SKILL.md +37 -39
- package/dist/cli/roleOptionCatalog.js +0 -68
- package/dist/context/sourceTurnContext.js +0 -30
- package/dist/execution/reviewMainTurn.js +0 -161
- package/dist/execution/workItemMainTurn.js +0 -164
- package/dist/lifecycle/exactTurnTerminalization.js +0 -407
- package/dist/runtime/preallocatedNativeSession.js +0 -13
- package/dist/runtime/runtimeStopReceipt.js +0 -42
- package/dist/scheduler/activeRoleTurnDelivery.js +0 -315
|
@@ -1,43 +1,44 @@
|
|
|
1
1
|
import { normalizedUniqueText, requireIdentity, requireText } from "../domain/validation.js";
|
|
2
2
|
import { validateContextSnapshotRef } from "./contextSnapshot.js";
|
|
3
|
-
export const
|
|
4
|
-
export const
|
|
5
|
-
export const
|
|
6
|
-
export const
|
|
7
|
-
export const
|
|
3
|
+
export const RUN_INPUT_PROTOCOL_VERSION = 1;
|
|
4
|
+
export const RUN_INPUT_PROTOCOL = "yui-run/v1";
|
|
5
|
+
export const RUN_INPUT_MAX_BYTES = 4 * 1024;
|
|
6
|
+
export const RUN_INPUT_MAX_DELTAS = 16;
|
|
7
|
+
export const YUI_RUN_INPUT_CHANNELS = [
|
|
8
8
|
"user-message",
|
|
9
9
|
"input-response",
|
|
10
10
|
"task-dispatch",
|
|
11
11
|
"workitem-dispatch",
|
|
12
|
+
"message-continuation",
|
|
12
13
|
"leader-wakeup",
|
|
13
14
|
"leader-forced-wakeup"
|
|
14
15
|
];
|
|
15
|
-
export function
|
|
16
|
+
export function createRunInput(input) {
|
|
16
17
|
const common = normalizeInput(input);
|
|
17
18
|
return Object.freeze({
|
|
18
|
-
schemaVersion:
|
|
19
|
+
schemaVersion: RUN_INPUT_PROTOCOL_VERSION,
|
|
19
20
|
...common,
|
|
20
21
|
...(input.directive === undefined
|
|
21
22
|
? {}
|
|
22
|
-
: { directive: requireText(input.directive, "
|
|
23
|
+
: { directive: requireText(input.directive, "AgentRun input directive") })
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
|
-
export function
|
|
26
|
-
if (value.schemaVersion !==
|
|
27
|
-
throw new Error("
|
|
26
|
+
export function validateRunInput(value) {
|
|
27
|
+
if (value.schemaVersion !== RUN_INPUT_PROTOCOL_VERSION) {
|
|
28
|
+
throw new Error("AgentRun input must use schemaVersion 1.");
|
|
28
29
|
}
|
|
29
|
-
const normalized =
|
|
30
|
+
const normalized = createRunInput(value);
|
|
30
31
|
if (JSON.stringify(normalized) !== JSON.stringify(value)) {
|
|
31
|
-
throw new Error("
|
|
32
|
+
throw new Error("AgentRun input is not canonical.");
|
|
32
33
|
}
|
|
33
34
|
return value;
|
|
34
35
|
}
|
|
35
|
-
export function
|
|
36
|
-
|
|
36
|
+
export function createRunInputEnvelope(context, input) {
|
|
37
|
+
validateRunInput(input);
|
|
37
38
|
const normalized = normalizeEnvelopeContext(context, input);
|
|
38
39
|
return Object.freeze({
|
|
39
|
-
protocol:
|
|
40
|
-
|
|
40
|
+
protocol: RUN_INPUT_PROTOCOL,
|
|
41
|
+
runId: normalized.runId,
|
|
41
42
|
source: input.source,
|
|
42
43
|
roleName: normalized.roleName,
|
|
43
44
|
purpose: normalized.purpose,
|
|
@@ -48,20 +49,20 @@ export function createTurnInputEnvelope(context, input) {
|
|
|
48
49
|
deltaRefIds: input.deltaRefIds
|
|
49
50
|
});
|
|
50
51
|
}
|
|
51
|
-
export function
|
|
52
|
-
if (value.protocol !==
|
|
53
|
-
throw new Error("
|
|
52
|
+
export function validateRunInputEnvelope(value) {
|
|
53
|
+
if (value.protocol !== RUN_INPUT_PROTOCOL) {
|
|
54
|
+
throw new Error("AgentRun input protocol is unsupported.");
|
|
54
55
|
}
|
|
55
56
|
normalizeEnvelope(value);
|
|
56
|
-
const serialized =
|
|
57
|
-
if (Buffer.byteLength(serialized, "utf8") >
|
|
58
|
-
throw new Error("
|
|
57
|
+
const serialized = serializeRunInputEnvelope(value);
|
|
58
|
+
if (Buffer.byteLength(serialized, "utf8") > RUN_INPUT_MAX_BYTES) {
|
|
59
|
+
throw new Error("AgentRun input envelope exceeds its protocol byte limit.");
|
|
59
60
|
}
|
|
60
61
|
return value;
|
|
61
62
|
}
|
|
62
|
-
export function
|
|
63
|
-
if (value.protocol !==
|
|
64
|
-
throw new Error("
|
|
63
|
+
export function serializeRunInputEnvelope(value) {
|
|
64
|
+
if (value.protocol !== RUN_INPUT_PROTOCOL) {
|
|
65
|
+
throw new Error("AgentRun input protocol is unsupported.");
|
|
65
66
|
}
|
|
66
67
|
const normalized = normalizeEnvelope(value);
|
|
67
68
|
const subject = Object.entries(normalized.subject)
|
|
@@ -69,35 +70,40 @@ export function serializeTurnInputEnvelope(value) {
|
|
|
69
70
|
.join(",");
|
|
70
71
|
const snapshot = normalized.contextSnapshotRef;
|
|
71
72
|
const lines = [
|
|
72
|
-
"Yui
|
|
73
|
-
`${normalized.subject.taskId === undefined ? "" : `task=${normalized.subject.taskId} `}
|
|
73
|
+
"Yui AgentRun input. Follow the Session Manifest and injected Skills.",
|
|
74
|
+
`${normalized.subject.taskId === undefined ? "" : `task=${normalized.subject.taskId} `}run=${normalized.runId} role=${normalized.roleName}`,
|
|
74
75
|
`source=${normalized.source.type}/${normalized.source.channel} purpose=${normalized.purpose} subject=${subject || "global"} snapshot=${snapshot === undefined ? "none" : `${snapshot.id}@${snapshot.digest}`}`,
|
|
75
76
|
normalized.deltaRefIds.length === 0
|
|
76
77
|
? "delta=none"
|
|
77
78
|
: `delta=${normalized.deltaRefIds.join(",")}`,
|
|
78
|
-
|
|
79
|
+
...(normalized.subject.taskId === undefined ? [] : [
|
|
80
|
+
`Load the exact AgentRun context: yui task run context ${normalized.subject.taskId}/${normalized.runId} --json.`
|
|
81
|
+
]),
|
|
82
|
+
"Use the Session Manifest's CLI entry. Fail closed if the exact Context is unavailable or mismatched.",
|
|
83
|
+
"Then read the relevant referenced requirements and perform the assigned work. Context loading is not the deliverable.",
|
|
84
|
+
"During planning, fulfill the user's Draft discussion request without starting delivery before it is requested."
|
|
79
85
|
];
|
|
80
86
|
const serialized = lines.join("\n");
|
|
81
|
-
if (Buffer.byteLength(serialized, "utf8") >
|
|
82
|
-
throw new Error("
|
|
87
|
+
if (Buffer.byteLength(serialized, "utf8") > RUN_INPUT_MAX_BYTES) {
|
|
88
|
+
throw new Error("AgentRun input envelope exceeds its protocol byte limit.");
|
|
83
89
|
}
|
|
84
90
|
return serialized;
|
|
85
91
|
}
|
|
86
92
|
/**
|
|
87
|
-
* Bounded infrastructure-recovery input for an already-submitted
|
|
93
|
+
* Bounded infrastructure-recovery input for an already-submitted AgentRun. It resumes
|
|
88
94
|
* the provider-native transcript after Host/child replacement and never
|
|
89
95
|
* replays the Assignment or its directive.
|
|
90
96
|
*/
|
|
91
|
-
export function
|
|
97
|
+
export function serializeRunHostRecoveryEnvelope(value) {
|
|
92
98
|
const normalized = normalizeEnvelope(value);
|
|
93
99
|
const serialized = [
|
|
94
|
-
"Yui Host recovery for an existing
|
|
95
|
-
`${normalized.subject.taskId === undefined ? "" : `task=${normalized.subject.taskId} `}turn=${normalized.
|
|
100
|
+
"Yui Host recovery for an existing AgentRun.",
|
|
101
|
+
`${normalized.subject.taskId === undefined ? "" : `task=${normalized.subject.taskId} `}turn=${normalized.runId} role=${normalized.roleName}`,
|
|
96
102
|
"Resume the same native conversation from its latest durable state. Do not repeat completed work or replay the original input.",
|
|
97
|
-
"Load the exact
|
|
103
|
+
"Load the exact AgentRun context or delta only if needed, then continue the same AgentRun."
|
|
98
104
|
].join("\n");
|
|
99
|
-
if (Buffer.byteLength(serialized, "utf8") >
|
|
100
|
-
throw new Error("
|
|
105
|
+
if (Buffer.byteLength(serialized, "utf8") > RUN_INPUT_MAX_BYTES) {
|
|
106
|
+
throw new Error("AgentRun Host recovery envelope exceeds its protocol byte limit.");
|
|
101
107
|
}
|
|
102
108
|
return serialized;
|
|
103
109
|
}
|
|
@@ -106,9 +112,9 @@ function normalizeInput(input) {
|
|
|
106
112
|
const snapshot = input.contextSnapshotRef === undefined
|
|
107
113
|
? undefined
|
|
108
114
|
: validateContextSnapshotRef(input.contextSnapshotRef);
|
|
109
|
-
const deltaRefIds = normalizedUniqueText(input.deltaRefIds, "
|
|
110
|
-
if (deltaRefIds.length >
|
|
111
|
-
throw new Error(`
|
|
115
|
+
const deltaRefIds = normalizedUniqueText(input.deltaRefIds, "AgentRun input delta ref");
|
|
116
|
+
if (deltaRefIds.length > RUN_INPUT_MAX_DELTAS) {
|
|
117
|
+
throw new Error(`AgentRun input supports at most ${RUN_INPUT_MAX_DELTAS} delta refs.`);
|
|
112
118
|
}
|
|
113
119
|
return {
|
|
114
120
|
source,
|
|
@@ -118,8 +124,8 @@ function normalizeInput(input) {
|
|
|
118
124
|
}
|
|
119
125
|
function normalizeEnvelopeContext(context, input) {
|
|
120
126
|
const normalized = normalizeEnvelope({
|
|
121
|
-
protocol:
|
|
122
|
-
|
|
127
|
+
protocol: RUN_INPUT_PROTOCOL,
|
|
128
|
+
runId: context.runId,
|
|
123
129
|
source: input.source,
|
|
124
130
|
roleName: context.roleName,
|
|
125
131
|
purpose: context.purpose,
|
|
@@ -130,33 +136,40 @@ function normalizeEnvelopeContext(context, input) {
|
|
|
130
136
|
deltaRefIds: input.deltaRefIds
|
|
131
137
|
});
|
|
132
138
|
return {
|
|
133
|
-
|
|
139
|
+
runId: normalized.runId,
|
|
134
140
|
roleName: normalized.roleName,
|
|
135
141
|
purpose: normalized.purpose,
|
|
136
142
|
subject: normalized.subject
|
|
137
143
|
};
|
|
138
144
|
}
|
|
139
145
|
function normalizeEnvelope(input) {
|
|
140
|
-
if (!["execution", "review", "global"].includes(input.purpose)) {
|
|
146
|
+
if (!["execution", "review", "global", "planning"].includes(input.purpose)) {
|
|
141
147
|
throw new Error("Turn input purpose is invalid.");
|
|
142
148
|
}
|
|
143
149
|
const normalizedInput = normalizeInput(input);
|
|
144
150
|
const subject = normalizeSubject(input.subject);
|
|
145
151
|
if (normalizedInput.contextSnapshotRef !== undefined
|
|
146
152
|
&& normalizedInput.contextSnapshotRef.taskId !== subject.taskId) {
|
|
147
|
-
throw new Error("
|
|
153
|
+
throw new Error("AgentRun input Context Snapshot belongs to another Task.");
|
|
148
154
|
}
|
|
149
155
|
if (input.purpose !== "global" && subject.taskId === undefined) {
|
|
150
|
-
throw new Error("A Task
|
|
156
|
+
throw new Error("A Task AgentRun input requires a Task subject.");
|
|
151
157
|
}
|
|
152
158
|
if (input.purpose === "review" && subject.reviewRoundId === undefined) {
|
|
153
|
-
throw new Error("A review
|
|
159
|
+
throw new Error("A review AgentRun input requires a ReviewRound subject.");
|
|
160
|
+
}
|
|
161
|
+
if (input.purpose === "planning"
|
|
162
|
+
&& (subject.workItemId !== undefined
|
|
163
|
+
|| subject.reviewRoundId !== undefined
|
|
164
|
+
|| subject.executionGroupId !== undefined
|
|
165
|
+
|| subject.sourceExecutionGroupId !== undefined)) {
|
|
166
|
+
throw new Error("A planning Turn input carries only its Task subject.");
|
|
154
167
|
}
|
|
155
168
|
return {
|
|
156
|
-
protocol:
|
|
157
|
-
|
|
169
|
+
protocol: RUN_INPUT_PROTOCOL,
|
|
170
|
+
runId: requireIdentity(input.runId, "AgentRun input AgentRun id"),
|
|
158
171
|
source: normalizedInput.source,
|
|
159
|
-
roleName: requireIdentity(input.roleName, "
|
|
172
|
+
roleName: requireIdentity(input.roleName, "AgentRun input Role name"),
|
|
160
173
|
purpose: input.purpose,
|
|
161
174
|
subject,
|
|
162
175
|
...(normalizedInput.contextSnapshotRef === undefined
|
|
@@ -168,7 +181,7 @@ function normalizeEnvelope(input) {
|
|
|
168
181
|
function normalizeSubject(subject) {
|
|
169
182
|
const normalized = Object.fromEntries(Object.entries(subject).map(([key, value]) => [
|
|
170
183
|
key,
|
|
171
|
-
requireIdentity(value, `
|
|
184
|
+
requireIdentity(value, `AgentRun input ${key}`)
|
|
172
185
|
]));
|
|
173
186
|
const allowed = [
|
|
174
187
|
"taskId",
|
|
@@ -179,33 +192,33 @@ function normalizeSubject(subject) {
|
|
|
179
192
|
"sourceExecutionGroupId"
|
|
180
193
|
];
|
|
181
194
|
if (Object.keys(normalized).some((key) => !allowed.includes(key))) {
|
|
182
|
-
throw new Error("
|
|
195
|
+
throw new Error("AgentRun input subject contains an unknown field.");
|
|
183
196
|
}
|
|
184
197
|
if ((normalized.executionGroupId === undefined) !== (normalized.executionLaneId === undefined)) {
|
|
185
|
-
throw new Error("
|
|
198
|
+
throw new Error("AgentRun input execution lineage is incomplete.");
|
|
186
199
|
}
|
|
187
200
|
if (normalized.sourceExecutionGroupId !== undefined
|
|
188
201
|
&& ((normalized.workItemId === undefined && normalized.reviewRoundId === undefined)
|
|
189
202
|
|| normalized.executionGroupId !== undefined)) {
|
|
190
|
-
throw new Error("
|
|
203
|
+
throw new Error("AgentRun input source ExecutionGroup requires a WorkItem or Review main subject.");
|
|
191
204
|
}
|
|
192
205
|
if (normalized.taskId === undefined
|
|
193
206
|
&& (normalized.workItemId !== undefined || normalized.reviewRoundId !== undefined
|
|
194
207
|
|| normalized.executionGroupId !== undefined
|
|
195
208
|
|| normalized.sourceExecutionGroupId !== undefined)) {
|
|
196
|
-
throw new Error("
|
|
209
|
+
throw new Error("AgentRun input child subject requires a Task id.");
|
|
197
210
|
}
|
|
198
211
|
return Object.freeze(normalized);
|
|
199
212
|
}
|
|
200
213
|
function normalizeSource(source) {
|
|
201
|
-
if (source.type === "yui" &&
|
|
214
|
+
if (source.type === "yui" && YUI_RUN_INPUT_CHANNELS.includes(source.channel)) {
|
|
202
215
|
return Object.freeze({ type: "yui", channel: source.channel });
|
|
203
216
|
}
|
|
204
217
|
if (source.type === "user" && source.channel === "direct") {
|
|
205
218
|
return Object.freeze({ type: "user", channel: "direct" });
|
|
206
219
|
}
|
|
207
|
-
if (source.type === "provider" && source.channel === "goal-continuation") {
|
|
208
|
-
return Object.freeze({ type: "provider", channel:
|
|
220
|
+
if (source.type === "provider" && (source.channel === "goal-continuation" || source.channel === "visible-input")) {
|
|
221
|
+
return Object.freeze({ type: "provider", channel: source.channel });
|
|
209
222
|
}
|
|
210
|
-
throw new Error("
|
|
223
|
+
throw new Error("AgentRun input source is invalid.");
|
|
211
224
|
}
|
|
@@ -5,6 +5,22 @@ import { writeTextFileAtomically } from "../storage/durableFile.js";
|
|
|
5
5
|
import { SESSION_BOOTSTRAP_MANIFEST_SCHEMA_VERSION, SESSION_CONTEXT_PROTOCOL, sessionManifestCompatibilityDigest } from "./sessionProtocolIdentity.js";
|
|
6
6
|
export { SESSION_BOOTSTRAP_MANIFEST_SCHEMA_VERSION, SESSION_CONTEXT_PROTOCOL, sessionManifestCompatibilityDigest } from "./sessionProtocolIdentity.js";
|
|
7
7
|
const ordinarySessionCli = ["#!/bin/sh", "exec yui \"$@\"", ""].join("\n");
|
|
8
|
+
/** Portable read pointers accompany every managed input, including the first
|
|
9
|
+
* notification on a fresh Session. No Task content or credentials are copied. */
|
|
10
|
+
export function withSessionContextPointer(text, environment) {
|
|
11
|
+
const manifest = environment.YUI_SESSION_MANIFEST;
|
|
12
|
+
if (manifest === undefined)
|
|
13
|
+
return text;
|
|
14
|
+
return [
|
|
15
|
+
`Read the Yui Session Manifest at ${manifest}.`,
|
|
16
|
+
"Follow its referenced Role Skills and role profile. It gives the exact Context load command.",
|
|
17
|
+
...(environment.YUI_SESSION_CLI === undefined ? [] : [
|
|
18
|
+
`Use this absolute CLI entry for Yui commands: ${environment.YUI_SESSION_CLI}`
|
|
19
|
+
]),
|
|
20
|
+
"",
|
|
21
|
+
text
|
|
22
|
+
].join("\n");
|
|
23
|
+
}
|
|
8
24
|
/**
|
|
9
25
|
* A managed Session wrapper answers exactly one question: which installation
|
|
10
26
|
* runs this command. It therefore carries only the resolved entry point, never
|
|
@@ -137,8 +153,11 @@ export function materializeSessionBootstrap(input) {
|
|
|
137
153
|
loadCommand: renderGlobalContextCommand(input.entryPoint, home, input.role.name)
|
|
138
154
|
}
|
|
139
155
|
: {
|
|
140
|
-
loadCommand: "\"$YUI_SESSION_CLI\" task
|
|
141
|
-
expandCommand: "\"$YUI_SESSION_CLI\" task
|
|
156
|
+
loadCommand: "\"$YUI_SESSION_CLI\" task run context \"$YUI_TASK_ID/<run-id>\" --json",
|
|
157
|
+
expandCommand: "\"$YUI_SESSION_CLI\" task run context expand \"$YUI_TASK_ID/<run-id>\" <ref-id> --store <store> --mode full --json",
|
|
158
|
+
...(input.role.name === "leader" ? {
|
|
159
|
+
currentCommand: "\"$YUI_SESSION_CLI\" task context \"$YUI_TASK_ID\" --json"
|
|
160
|
+
} : {})
|
|
142
161
|
}
|
|
143
162
|
};
|
|
144
163
|
const manifest = Object.freeze({ ...body, digest: digest(body) });
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { MAX_RUN_RESULT_OUTPUT_BYTES } from "../domain/agentResultTransport.js";
|
|
2
|
+
export const MAX_SYNTHESIS_SOURCE_RUNS = 8;
|
|
3
|
+
export const MAX_CONTEXT_SOURCE_RUNS = MAX_SYNTHESIS_SOURCE_RUNS + 1;
|
|
4
|
+
export const MAX_CONTEXT_SOURCE_RUN_BYTES = MAX_CONTEXT_SOURCE_RUNS * (MAX_RUN_RESULT_OUTPUT_BYTES + 16 * 1024);
|
|
5
|
+
/**
|
|
6
|
+
* Frozen input for synthesis. The main Agent needs the producer identity and
|
|
7
|
+
* exact result, not another copy of its prompt history, launch configuration,
|
|
8
|
+
* or workspace descriptor.
|
|
9
|
+
*/
|
|
10
|
+
export function sourceRunContextValue(run) {
|
|
11
|
+
if (run.result === undefined) {
|
|
12
|
+
throw new Error(`Source AgentRun has no result: ${run.id}.`);
|
|
13
|
+
}
|
|
14
|
+
return Object.freeze({
|
|
15
|
+
schemaVersion: 1,
|
|
16
|
+
id: run.id,
|
|
17
|
+
taskId: run.taskId,
|
|
18
|
+
roleName: run.roleName,
|
|
19
|
+
purpose: run.purpose,
|
|
20
|
+
...(run.workItemId === undefined ? {} : { workItemId: run.workItemId }),
|
|
21
|
+
...(run.reviewRoundId === undefined ? {} : { reviewRoundId: run.reviewRoundId }),
|
|
22
|
+
...(run.executionGroupId === undefined
|
|
23
|
+
? {}
|
|
24
|
+
: { executionGroupId: run.executionGroupId }),
|
|
25
|
+
...(run.executionLaneId === undefined ? {} : { executionLaneId: run.executionLaneId }),
|
|
26
|
+
result: run.result,
|
|
27
|
+
createdAt: run.createdAt,
|
|
28
|
+
updatedAt: run.updatedAt
|
|
29
|
+
});
|
|
30
|
+
}
|