@zq-silk/yui 0.15.6 → 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 +167 -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 +188 -95
- package/dist/commands/agentCommands.js +72 -14
- package/dist/commands/capabilityCommands.js +57 -0
- 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 +1216 -730
- 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 +77 -0
- package/dist/controller/clientRuntime.js +65 -92
- package/dist/controller/controller.js +127 -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 +530 -476
- 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 +423 -0
- package/dist/kernel/capabilityRegistry.js +314 -0
- package/dist/kernel/capabilitySchema.js +91 -0
- package/dist/kernel/instanceHost.js +18 -1
- package/dist/kernel/kernelPorts.js +4 -1
- 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 +5 -5
- 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
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
import { updateTaskMetadataCommand, sendTaskMessageCommand } from "../commands/taskCommands.js";
|
|
2
|
+
import { runConfigCommand } from "../commands/configCommands.js";
|
|
3
|
+
import { readTaskContext, readTaskContextDelta, inspectTaskContext, withContextObservations } from "../context/taskContext.js";
|
|
4
|
+
import { CONFIG_DOMAINS } from "../config/configCatalog.js";
|
|
5
|
+
import { createJobCallAuthority, parseDurableJobStartParams } from "../controller/jobControl.js";
|
|
6
|
+
import { inspectJobOperation } from "./kernelPorts.js";
|
|
7
|
+
import { CapabilityRegistry, } from "./capabilityRegistry.js";
|
|
8
|
+
import { createProjectResources } from "../resources/projectResourceService.js";
|
|
9
|
+
import { artifactSummary } from "../resources/projectResource.js";
|
|
10
|
+
import { createPluginService } from "../plugins/pluginService.js";
|
|
11
|
+
const text = { type: "string", minLength: 1 };
|
|
12
|
+
const strings = { type: "object", additionalProperties: { type: "string" } };
|
|
13
|
+
const object = (properties, required = Object.keys(properties)) => ({
|
|
14
|
+
type: "object", properties, required, additionalProperties: false
|
|
15
|
+
});
|
|
16
|
+
const taskInput = object({ taskId: text });
|
|
17
|
+
const recordOutput = { type: "object" };
|
|
18
|
+
const artifactBase = { displayName: text, provenance: text, mediaType: text };
|
|
19
|
+
const taskOutput = { type: "object", required: ["id", "status", "title"], properties: {
|
|
20
|
+
id: text, status: text, title: text
|
|
21
|
+
} };
|
|
22
|
+
const provider = Object.freeze({ id: "yui:builtin-capabilities", generation: "1" });
|
|
23
|
+
/** Source locators identify the existing semantic owner, not a new Store. */
|
|
24
|
+
const definitions = [
|
|
25
|
+
{
|
|
26
|
+
name: "message.send", summary: "Save collaboration for Leader or continue the same dispatched work owner.",
|
|
27
|
+
effect: "local-mutation", requiredPermissions: ["task:read"], source: "sendTaskMessageCommand",
|
|
28
|
+
inputSchema: object({ taskId: text, body: text,
|
|
29
|
+
wakePolicy: { enum: ["leader", "none"] },
|
|
30
|
+
recipient: object({ roleName: text, workItemId: text, reviewRoundId: text }, ["roleName"])
|
|
31
|
+
}, ["taskId", "body"]), outputSchema: recordOutput
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "context.read", summary: "Read a bounded authorized Task working set and atomic core cursor.",
|
|
35
|
+
effect: "query", requiredPermissions: ["task:read"], source: "readTaskContext",
|
|
36
|
+
inputSchema: taskInput, outputSchema: { type: "object", required: ["records", "coreCursor", "omitted"] }
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "context.delta", summary: "Read immutable Task events with a fixed pagination upper bound.",
|
|
40
|
+
effect: "query", requiredPermissions: ["task:read"], source: "readTaskContextDelta",
|
|
41
|
+
inputSchema: object({ taskId: text, after: text, continuation: text, limit: { type: "integer" } }, ["taskId", "after"]),
|
|
42
|
+
outputSchema: { type: "object", required: ["events", "throughCursor"] }
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "context.inspect", summary: "Expand an authorized current record; optionally require its exact digest.",
|
|
46
|
+
effect: "query", requiredPermissions: ["task:read"], source: "inspectTaskContext",
|
|
47
|
+
inputSchema: object({ taskId: text, store: text, refId: text, digest: text }, ["taskId", "store", "refId"]),
|
|
48
|
+
outputSchema: { type: "object", required: ["ref", "value", "coreCursor"] }
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "artifact.save", summary: "Save immutable text, external version evidence, a Job receipt, or reference material.",
|
|
52
|
+
effect: "local-mutation", requiredPermissions: ["task:read"], source: "ProjectResources.saveArtifact",
|
|
53
|
+
inputSchema: object({ taskId: text, artifact: { anyOf: [
|
|
54
|
+
object({ ...artifactBase, kind: { const: "content" }, content: { type: "string" } }, ["kind", "displayName", "provenance", "content"]),
|
|
55
|
+
object({ ...artifactBase, kind: { const: "external-version" }, resourceId: text, version: text, verification: text }, ["kind", "displayName", "provenance", "resourceId", "version", "verification"]),
|
|
56
|
+
object({ ...artifactBase, kind: { const: "receipt" }, jobId: text, receiptRef: text }, ["kind", "displayName", "provenance", "jobId", "receiptRef"]),
|
|
57
|
+
object({ ...artifactBase, kind: { const: "reference" }, locator: text, observedAt: text }, ["kind", "displayName", "provenance", "locator", "observedAt"])
|
|
58
|
+
] } }), outputSchema: recordOutput
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "artifact.read", summary: "Read saved results without starting the original Runtime or plugin.",
|
|
62
|
+
effect: "query", requiredPermissions: ["task:read"], source: "TaskStore.getArtifact",
|
|
63
|
+
inputSchema: object({ taskId: text, artifactId: text }), outputSchema: recordOutput
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "artifact.list", summary: "List this Task's saved results and references.",
|
|
67
|
+
effect: "query", requiredPermissions: ["task:read"], source: "TaskStore.listArtifacts",
|
|
68
|
+
inputSchema: taskInput, outputSchema: { type: "array", items: recordOutput }
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: "environment.prepare", summary: "Prepare empty, Task-owned scratch, or explicitly granted trusted-local directory; does not adopt it or create a sandbox.",
|
|
72
|
+
effect: "local-mutation", requiredPermissions: ["task:manage"], source: "ProjectResources.prepare",
|
|
73
|
+
inputSchema: object({ taskId: text, plan: { anyOf: [
|
|
74
|
+
object({ kind: { const: "empty" } }), object({ kind: { const: "scratch" } }),
|
|
75
|
+
object({ kind: { const: "local" }, resourceId: text, access: { enum: ["read", "write"] } })
|
|
76
|
+
] } }), outputSchema: recordOutput
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "environment.adopt", summary: "Recheck current resource intent, grants and conflicts, then record Task ownership.",
|
|
80
|
+
effect: "local-mutation", requiredPermissions: ["task:manage"], source: "ProjectResources.adopt",
|
|
81
|
+
inputSchema: object({ taskId: text, preparationId: text }), outputSchema: recordOutput
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "environment.bind", summary: "Select an adopted environment for a Role's next native Session; null restores managed workspace. Active Sessions keep their environment.",
|
|
85
|
+
effect: "local-mutation", requiredPermissions: ["task:manage"], source: "ProjectResources.bindEnvironment",
|
|
86
|
+
inputSchema: object({ taskId: text, roleName: text, preparationId: { anyOf: [text, { const: null }] } }),
|
|
87
|
+
outputSchema: recordOutput
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "environment.release", summary: "Release exact preparation; adopted resources need actual quiescence evidence. Never deletes user directories.",
|
|
91
|
+
effect: "local-mutation", requiredPermissions: ["task:manage"], source: "ProjectResources.release",
|
|
92
|
+
inputSchema: object({ taskId: text, preparationId: text, quiescence: text }, ["taskId", "preparationId"]), outputSchema: recordOutput
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: "environment.list", summary: "Read preparation/adoption facts, not inferred process state.",
|
|
96
|
+
effect: "query", requiredPermissions: ["task:read"], source: "TaskStore.listEnvironmentPreparations",
|
|
97
|
+
inputSchema: taskInput, outputSchema: { type: "array", items: recordOutput }
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: "resource.local.register", summary: "Register a user-owned local directory by canonical identity (Operator); registration does not grant use.",
|
|
101
|
+
effect: "local-mutation", requiredPermissions: ["resource:register"], source: "ProjectResources.registerLocalDirectory",
|
|
102
|
+
inputSchema: object({ displayName: text, path: text }), outputSchema: recordOutput
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "resource.local.read", summary: "Read an explicitly granted local resource.",
|
|
106
|
+
effect: "query", requiredPermissions: ["task:read"], source: "ProjectResources.readLocalResource",
|
|
107
|
+
inputSchema: object({ taskId: text, resourceId: text }), outputSchema: recordOutput
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "project.context", summary: "Read Project Knowledge, resource references and default Provider references; no credential grant.",
|
|
111
|
+
effect: "query", requiredPermissions: ["task:read"], source: "TaskStore.getProject",
|
|
112
|
+
inputSchema: object({ taskId: text, projectId: text }), outputSchema: recordOutput
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: "project.resources.configure", summary: "Configure existing Project resource and Provider references (Operator).",
|
|
116
|
+
effect: "local-mutation", requiredPermissions: ["resource:register"], source: "ProjectResources.configureProject",
|
|
117
|
+
inputSchema: object({ projectId: text, resourceRefs: { type: "array", items: text }, defaultCapabilityProviders: strings }),
|
|
118
|
+
outputSchema: recordOutput
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: "task.read", summary: "Read the current Task record.", effect: "query",
|
|
122
|
+
inputSchema: taskInput, outputSchema: taskOutput, requiredPermissions: ["task:read"],
|
|
123
|
+
source: "TaskStore.getTask (task show)"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: "task.update", summary: "Update Task metadata through the existing command transaction.",
|
|
127
|
+
effect: "local-mutation", requiredPermissions: ["task:manage"],
|
|
128
|
+
source: "updateTaskMetadataCommand (task update)",
|
|
129
|
+
inputSchema: object({
|
|
130
|
+
taskId: text,
|
|
131
|
+
patch: object({
|
|
132
|
+
title: text, description: { type: "string" },
|
|
133
|
+
priority: { enum: ["low", "medium", "high", "urgent"] },
|
|
134
|
+
tags: { type: "array", items: text }
|
|
135
|
+
}, [])
|
|
136
|
+
}), outputSchema: taskOutput
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: "config.read", summary: "Read effective global configuration (Operator only).",
|
|
140
|
+
effect: "query", requiredPermissions: ["config:read"],
|
|
141
|
+
source: "runConfigCommand (config <domain> show)",
|
|
142
|
+
inputSchema: object({ domain: { enum: CONFIG_DOMAINS } }),
|
|
143
|
+
outputSchema: { type: "object" }
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: "resource.git.result", summary: "Read an original fixed Git ChangeSet and its external-version reference.",
|
|
147
|
+
effect: "query", requiredPermissions: ["task:read"], source: "TaskStore.getChangeSet",
|
|
148
|
+
inputSchema: object({ taskId: text, changeSetId: text }), outputSchema: recordOutput
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: "resource.workspaces", summary: "Read the Task's managed workspace resources.",
|
|
152
|
+
effect: "query", requiredPermissions: ["task:read"],
|
|
153
|
+
source: "TaskStore.listManagedWorkspaces (task workspace list)",
|
|
154
|
+
inputSchema: taskInput, outputSchema: { type: "array", items: { type: "object", required: ["owner", "root", "entries"] } }
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
name: "job.get", summary: "Read the original Job and its operation evidence.",
|
|
158
|
+
effect: "query", requiredPermissions: ["task:read"],
|
|
159
|
+
source: "DurableJobControlPort.getJob (job.get RPC)",
|
|
160
|
+
inputSchema: object({ taskId: text, jobId: text }),
|
|
161
|
+
outputSchema: { type: "object", required: ["job", "operation"] }
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: "job.start", summary: "Request an idempotent Job through the existing Controller owner.",
|
|
165
|
+
effect: "external-operation", requiredPermissions: ["job:start"],
|
|
166
|
+
source: "DurableJobControlPort.startJob (job.start RPC)",
|
|
167
|
+
inputSchema: object({
|
|
168
|
+
taskId: text, projectId: text, head: text, workspace: text,
|
|
169
|
+
owner: { anyOf: [
|
|
170
|
+
object({ kind: { const: "task" } }),
|
|
171
|
+
object({ kind: { const: "work-item" }, workItemId: text }),
|
|
172
|
+
object({ kind: { const: "integration-attempt" }, integrationAttemptId: text })
|
|
173
|
+
] },
|
|
174
|
+
env: strings,
|
|
175
|
+
steps: { type: "array", minItems: 1, items: object({
|
|
176
|
+
name: text, command: text, timeoutMs: { type: "integer" }
|
|
177
|
+
}, ["name", "command"]) },
|
|
178
|
+
retryOf: text
|
|
179
|
+
}, ["taskId", "projectId", "head", "workspace", "owner", "env", "steps"]),
|
|
180
|
+
outputSchema: { type: "object", required: ["job", "created", "operation"], properties: { created: { type: "boolean" } } }
|
|
181
|
+
},
|
|
182
|
+
...[
|
|
183
|
+
{ action: "create", summary: "Create an independent data or trusted-local package in an adopted environment; executes no author code.",
|
|
184
|
+
inputSchema: object({ preparationId: text, id: text, kind: { enum: ["declarative", "trusted-local"] } }) },
|
|
185
|
+
{ action: "validate", summary: "Validate captured package bytes in an explicit environment; author build/test code needs a separate execution grant.",
|
|
186
|
+
inputSchema: object({ preparationId: text, directory: text }) },
|
|
187
|
+
{ action: "activate", summary: "Recheck validated bytes, current authority and dependencies; publish one complete Task-local provider.",
|
|
188
|
+
inputSchema: object({ validationId: text }) },
|
|
189
|
+
{ action: "disable", summary: "Stop new plugin calls and drain the exact Host instance before disposal.",
|
|
190
|
+
inputSchema: object({ id: text }) }
|
|
191
|
+
].map(({ action, summary, inputSchema }) => ({
|
|
192
|
+
name: `plugin.${action}`, summary, inputSchema,
|
|
193
|
+
effect: "local-mutation", requiredPermissions: ["plugin:manage"],
|
|
194
|
+
source: "PluginService", outputSchema: recordOutput
|
|
195
|
+
})),
|
|
196
|
+
{
|
|
197
|
+
name: "plugin.scan", summary: "Data-only package digest and manifest inspection; never executes author code.",
|
|
198
|
+
effect: "query", requiredPermissions: ["plugin:manage"], source: "PluginService.scan",
|
|
199
|
+
inputSchema: object({ preparationId: text, directory: text }), outputSchema: recordOutput
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
name: "plugin.validation", summary: "Read immutable validation evidence without starting the plugin.",
|
|
203
|
+
effect: "query", requiredPermissions: ["task:read"], source: "PluginService.inspect",
|
|
204
|
+
inputSchema: object({ validationId: text }), outputSchema: recordOutput
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: "plugin.inspect", summary: "Read durable desired selection, actual Host selection/references and latest intent failure; never activates code.",
|
|
208
|
+
effect: "query", requiredPermissions: ["task:read"], source: "PluginService.current",
|
|
209
|
+
inputSchema: object({ id: text }), outputSchema: recordOutput
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
name: "plugin.list", summary: "List this Task's explicit plugin choices and current Host observations without executing code.",
|
|
213
|
+
effect: "query", requiredPermissions: ["task:read"], source: "PluginService.list",
|
|
214
|
+
inputSchema: object({}), outputSchema: { type: "array", items: recordOutput }
|
|
215
|
+
}
|
|
216
|
+
];
|
|
217
|
+
export const BUILTIN_CAPABILITIES = definitions.map((entry) => ({
|
|
218
|
+
...entry, contractVersion: "1", provider, scope: { kind: "global" }
|
|
219
|
+
}));
|
|
220
|
+
/** One registry with separate managed credentials and in-process Web query
|
|
221
|
+
* issuance. Socket possession or caller-scope JSON never issues a Web context. */
|
|
222
|
+
export function createBuiltinCapabilities(host, store, jobs, signal = () => undefined, contextProviders = []) {
|
|
223
|
+
const authority = createJobCallAuthority(store);
|
|
224
|
+
const resources = createProjectResources(store);
|
|
225
|
+
const callers = new WeakMap();
|
|
226
|
+
// Issued only by the Controller's in-process, token-authenticated Web root.
|
|
227
|
+
// This is not accepted by the managed RPC credential adapter.
|
|
228
|
+
const webQueries = new WeakSet();
|
|
229
|
+
const current = (context) => {
|
|
230
|
+
if (webQueries.has(context)) {
|
|
231
|
+
requireTask(store, context.targetId);
|
|
232
|
+
return { scope: "user" };
|
|
233
|
+
}
|
|
234
|
+
authority.authorize(context, context.targetId);
|
|
235
|
+
const caller = callers.get(context);
|
|
236
|
+
if (!caller)
|
|
237
|
+
throw new Error("Untrusted capability ingress.");
|
|
238
|
+
return caller;
|
|
239
|
+
};
|
|
240
|
+
const implementation = {
|
|
241
|
+
invoke(name, input, invocation) {
|
|
242
|
+
const caller = current(invocation.context);
|
|
243
|
+
const params = input;
|
|
244
|
+
if (params.taskId !== undefined && params.taskId !== invocation.context.targetId) {
|
|
245
|
+
throw new Error("Capability target is outside the authenticated Task.");
|
|
246
|
+
}
|
|
247
|
+
const taskId = invocation.context.targetId;
|
|
248
|
+
if (name === "message.send") {
|
|
249
|
+
const result = sendTaskMessageCommand(store, taskId, params.body, params.wakePolicy, { environment: callerEnvironment(caller) }, params.recipient);
|
|
250
|
+
signal(taskId);
|
|
251
|
+
return result.message;
|
|
252
|
+
}
|
|
253
|
+
if (name === "plugin.create")
|
|
254
|
+
return plugins.create(taskId, params.preparationId, params.id, params.kind);
|
|
255
|
+
if (name === "plugin.scan")
|
|
256
|
+
return plugins.scan(taskId, params.preparationId, params.directory);
|
|
257
|
+
if (name === "plugin.validate")
|
|
258
|
+
return plugins.validate(invocation.context, params.preparationId, params.directory);
|
|
259
|
+
if (name === "plugin.validation")
|
|
260
|
+
return plugins.inspect(taskId, params.validationId);
|
|
261
|
+
if (name === "plugin.inspect")
|
|
262
|
+
return plugins.current(taskId, params.id);
|
|
263
|
+
if (name === "plugin.list")
|
|
264
|
+
return plugins.list(taskId);
|
|
265
|
+
if (name === "plugin.activate")
|
|
266
|
+
return plugins.activate(invocation.context, params.validationId);
|
|
267
|
+
if (name === "plugin.disable")
|
|
268
|
+
return plugins.disable(taskId, params.id);
|
|
269
|
+
if (name === "context.read") {
|
|
270
|
+
const core = readTaskContext(store, taskId, callerEnvironment(caller));
|
|
271
|
+
return withContextObservations(core, contextProviders);
|
|
272
|
+
}
|
|
273
|
+
if (name === "context.delta")
|
|
274
|
+
return readTaskContextDelta(store, taskId, {
|
|
275
|
+
after: params.after, continuation: params.continuation,
|
|
276
|
+
limit: params.limit
|
|
277
|
+
}, callerEnvironment(caller));
|
|
278
|
+
if (name === "context.inspect")
|
|
279
|
+
return inspectTaskContext(store, taskId, {
|
|
280
|
+
store: params.store, refId: params.refId, digest: params.digest
|
|
281
|
+
}, callerEnvironment(caller));
|
|
282
|
+
if (name === "artifact.save")
|
|
283
|
+
return resources.saveArtifact(taskId, params.artifact);
|
|
284
|
+
if (name === "artifact.read") {
|
|
285
|
+
const artifact = store.getArtifact(taskId, params.artifactId);
|
|
286
|
+
if (!artifact)
|
|
287
|
+
throw new Error("Artifact not found in this Task.");
|
|
288
|
+
return artifact;
|
|
289
|
+
}
|
|
290
|
+
if (name === "artifact.list")
|
|
291
|
+
return store.listArtifacts(taskId).map(artifactSummary);
|
|
292
|
+
if (name === "environment.prepare")
|
|
293
|
+
return resources.prepare(taskId, params.plan);
|
|
294
|
+
if (name === "environment.adopt")
|
|
295
|
+
return resources.adopt(taskId, params.preparationId);
|
|
296
|
+
if (name === "environment.bind") {
|
|
297
|
+
const role = resources.bindEnvironment(taskId, params.roleName, params.preparationId, {
|
|
298
|
+
source: name, actorId: invocation.context.actorId, requestId: invocation.requestId
|
|
299
|
+
});
|
|
300
|
+
signal(taskId);
|
|
301
|
+
return role;
|
|
302
|
+
}
|
|
303
|
+
if (name === "environment.release") {
|
|
304
|
+
plugins.assertEnvironmentUnused(taskId, params.preparationId);
|
|
305
|
+
return resources.release(taskId, params.preparationId, params.quiescence === undefined ? undefined : { quiescence: params.quiescence });
|
|
306
|
+
}
|
|
307
|
+
if (name === "environment.list")
|
|
308
|
+
return store.listEnvironmentPreparations(taskId);
|
|
309
|
+
if (name === "resource.local.register")
|
|
310
|
+
return resources.registerLocalDirectory(params.displayName, params.path);
|
|
311
|
+
if (name === "resource.local.read")
|
|
312
|
+
return resources.readLocalResource(taskId, params.resourceId);
|
|
313
|
+
if (name === "project.context")
|
|
314
|
+
return resources.projectContext(taskId, params.projectId);
|
|
315
|
+
if (name === "project.resources.configure")
|
|
316
|
+
return resources.configureProject(params.projectId, params.resourceRefs, params.defaultCapabilityProviders);
|
|
317
|
+
if (name === "task.read")
|
|
318
|
+
return requireTask(store, taskId);
|
|
319
|
+
if (name === "resource.workspaces")
|
|
320
|
+
return store.listManagedWorkspaces(taskId);
|
|
321
|
+
if (name === "resource.git.result")
|
|
322
|
+
return resources.gitResult(taskId, params.changeSetId);
|
|
323
|
+
if (name === "config.read")
|
|
324
|
+
return runConfigCommand(params.domain, ["show"], store).data;
|
|
325
|
+
if (name === "task.update") {
|
|
326
|
+
const patch = params.patch;
|
|
327
|
+
return updateTaskMetadataCommand(store, taskId, {
|
|
328
|
+
...patch,
|
|
329
|
+
...(patch.description === "" ? { description: null } : {}),
|
|
330
|
+
...(patch.tags?.length === 0 ? { tags: null } : {})
|
|
331
|
+
}, {
|
|
332
|
+
environment: callerEnvironment(caller),
|
|
333
|
+
runtime: { notifyStateChanged: signal, reconcileTask: signal }
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
if (name === "job.get") {
|
|
337
|
+
const job = jobs.getJob(taskId, params.jobId);
|
|
338
|
+
if (!job)
|
|
339
|
+
throw new Error(`Job not found: ${taskId}/${params.jobId}.`);
|
|
340
|
+
const operation = inspectJobOperation(job);
|
|
341
|
+
invocation.observe(operation);
|
|
342
|
+
return { job, operation };
|
|
343
|
+
}
|
|
344
|
+
if (name === "job.start") {
|
|
345
|
+
const parsed = parseDurableJobStartParams({
|
|
346
|
+
...params, caller, requestId: invocation.requestId
|
|
347
|
+
});
|
|
348
|
+
const { job, created } = jobs.startJob(parsed, new Date());
|
|
349
|
+
const operation = inspectJobOperation(job);
|
|
350
|
+
invocation.observe(operation);
|
|
351
|
+
if (created)
|
|
352
|
+
signal(taskId);
|
|
353
|
+
return { job, created, operation };
|
|
354
|
+
}
|
|
355
|
+
throw new Error(`Builtin capability unavailable: ${name}.`);
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
host.attach(provider, implementation);
|
|
359
|
+
const registry = new CapabilityRegistry(host, (context, descriptor, input) => {
|
|
360
|
+
const caller = current(context);
|
|
361
|
+
const task = requireTask(store, context.targetId);
|
|
362
|
+
if (caller.scope === "user" && descriptor !== undefined && descriptor.effect !== "query") {
|
|
363
|
+
throw new Error("Web panels may only query capabilities.");
|
|
364
|
+
}
|
|
365
|
+
if (typeof input === "object" && input !== null && "taskId" in input && input.taskId !== task.id) {
|
|
366
|
+
throw new Error("Capability target is outside the authenticated Task.");
|
|
367
|
+
}
|
|
368
|
+
for (const permission of descriptor?.requiredPermissions ?? []) {
|
|
369
|
+
if (permission === "job:start" && caller.scope === "task") {
|
|
370
|
+
const sessions = store.getTaskRoleSessionSet(task.id, caller.role);
|
|
371
|
+
if (sessions?.sessions[sessions.activeAgentId]?.effective.executionAuthority !== "delivery") {
|
|
372
|
+
throw new Error("Planning Sessions cannot start delivery Jobs.");
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
if (permission === "task:read" || permission === "job:start")
|
|
376
|
+
continue;
|
|
377
|
+
if (permission === "task:manage" && ((caller.scope === "task" && caller.role === "leader")
|
|
378
|
+
|| (caller.scope === "global" && caller.role === "operator")))
|
|
379
|
+
continue;
|
|
380
|
+
// PluginService binds every management target to this authenticated
|
|
381
|
+
// Task. This admits package management, not author-code execution:
|
|
382
|
+
// adopted environments and exact plugin.execute grants remain separate.
|
|
383
|
+
if (permission === "plugin:manage" && caller.scope === "task" && caller.role === "leader")
|
|
384
|
+
continue;
|
|
385
|
+
if ((permission === "config:read" || permission === "plugin:manage" || permission === "resource:register")
|
|
386
|
+
&& caller.scope === "global" && caller.role === "operator")
|
|
387
|
+
continue;
|
|
388
|
+
throw new Error(`Permission unavailable: ${permission}.`);
|
|
389
|
+
}
|
|
390
|
+
return { taskIds: [task.id], projectIds: task.projectBindings.map((binding) => binding.projectId) };
|
|
391
|
+
}, BUILTIN_CAPABILITIES);
|
|
392
|
+
const plugins = createPluginService(store, host, registry);
|
|
393
|
+
return {
|
|
394
|
+
registry,
|
|
395
|
+
authenticateWebQuery(taskId) {
|
|
396
|
+
requireTask(store, taskId);
|
|
397
|
+
const context = Object.freeze({ actorId: "local-web-user", targetId: taskId });
|
|
398
|
+
webQueries.add(context);
|
|
399
|
+
return context;
|
|
400
|
+
},
|
|
401
|
+
authenticate(caller, taskId) {
|
|
402
|
+
const credential = Object.freeze({ ...caller });
|
|
403
|
+
const context = authority.authenticate(credential, taskId);
|
|
404
|
+
callers.set(context, credential);
|
|
405
|
+
return context;
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
function requireTask(store, taskId) {
|
|
410
|
+
const task = store.getTask(taskId);
|
|
411
|
+
if (!task)
|
|
412
|
+
throw new Error(`Task not found: ${taskId}.`);
|
|
413
|
+
return task;
|
|
414
|
+
}
|
|
415
|
+
function callerEnvironment(caller) {
|
|
416
|
+
if (caller.scope === "user")
|
|
417
|
+
return {};
|
|
418
|
+
return {
|
|
419
|
+
YUI_SESSION_SCOPE: caller.scope, YUI_TASK_ID: caller.taskId,
|
|
420
|
+
YUI_ROLE: caller.role, YUI_AGENT_ID: caller.agentId,
|
|
421
|
+
YUI_ADAPTER_ID: caller.adapterId, YUI_NATIVE_SESSION_ID: caller.nativeSessionId
|
|
422
|
+
};
|
|
423
|
+
}
|