@intx/hub-sessions 0.2.2 → 0.4.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/README.md +3 -5
- package/dist/agent-repo.d.ts +23 -7
- package/dist/agent-repo.js +19 -6
- package/dist/agent-state-kind.js +18 -63
- package/dist/asset-service.d.ts +1 -20
- package/dist/asset-service.js +19 -97
- package/dist/committed-source-tree.d.ts +10 -0
- package/dist/committed-source-tree.js +35 -0
- package/dist/credential-push.d.ts +52 -7
- package/dist/credential-push.js +178 -22
- package/dist/event-collector-registry.d.ts +3 -2
- package/dist/event-collector-registry.js +42 -13
- package/dist/event-collector.d.ts +12 -2
- package/dist/event-collector.js +45 -4
- package/dist/hub-session-lookups.d.ts +125 -7
- package/dist/hub-session-lookups.js +541 -86
- package/dist/hub-session-orchestrator.d.ts +2 -3
- package/dist/hub-session-orchestrator.js +22 -56
- package/dist/index.d.ts +19 -9
- package/dist/index.js +16 -7
- package/dist/reconciliation-scheduler.d.ts +14 -0
- package/dist/reconciliation-scheduler.js +55 -0
- package/dist/repo-store/index.d.ts +2 -1
- package/dist/repo-store/index.js +1 -0
- package/dist/repo-store/store.d.ts +1 -1
- package/dist/repo-store/store.js +138 -1
- package/dist/repo-store/subscribe-kind.d.ts +6 -3
- package/dist/repo-store/subscribe-kind.js +42 -77
- package/dist/repo-store/types.d.ts +94 -6
- package/dist/repo-store/user-principal-gate.d.ts +26 -0
- package/dist/repo-store/user-principal-gate.js +78 -0
- package/dist/session-service.d.ts +252 -126
- package/dist/session-service.js +851 -624
- package/dist/sidecar-allocation/capability-policy.d.ts +27 -0
- package/dist/sidecar-allocation/capability-policy.js +124 -0
- package/dist/sidecar-allocation/contracts.d.ts +101 -0
- package/dist/sidecar-allocation/contracts.js +26 -0
- package/dist/sidecar-allocation/index.d.ts +5 -0
- package/dist/sidecar-allocation/index.js +4 -0
- package/dist/sidecar-allocation/operation.d.ts +10 -0
- package/dist/sidecar-allocation/operation.js +54 -0
- package/dist/sidecar-allocation/plugin-registry.d.ts +24 -0
- package/dist/sidecar-allocation/plugin-registry.js +61 -0
- package/dist/sidecar-allocation/reconciler.d.ts +54 -0
- package/dist/sidecar-allocation/reconciler.js +825 -0
- package/dist/skill-kind.js +12 -62
- package/dist/substrate.d.ts +3 -3
- package/dist/substrate.js +1 -1
- package/dist/workflow-allocation-service.d.ts +64 -0
- package/dist/workflow-allocation-service.js +554 -0
- package/dist/workflow-closure-resolution.d.ts +106 -0
- package/dist/workflow-closure-resolution.js +123 -0
- package/dist/workflow-definition-ensure.d.ts +24 -0
- package/dist/workflow-definition-ensure.js +75 -0
- package/dist/workflow-dispatch-service.d.ts +42 -0
- package/dist/workflow-dispatch-service.js +209 -0
- package/dist/workflow-dispatch-settlement.d.ts +29 -0
- package/dist/workflow-dispatch-settlement.js +140 -0
- package/dist/workflow-kind.d.ts +29 -1
- package/dist/workflow-kind.js +143 -139
- package/dist/workflow-probe-gate.d.ts +286 -0
- package/dist/workflow-probe-gate.js +382 -0
- package/dist/workflow-run-kind.d.ts +239 -32
- package/dist/workflow-run-kind.js +874 -188
- package/dist/workflow-run-reader.d.ts +1 -1
- package/dist/workflow-run-reader.js +3 -7
- package/dist/workflow-run-restore.d.ts +16 -0
- package/dist/workflow-run-restore.js +30 -0
- package/dist/workflow-source-closure.d.ts +35 -0
- package/dist/workflow-source-closure.js +342 -0
- package/dist/workflow-source-pins.d.ts +8 -0
- package/dist/workflow-source-pins.js +14 -0
- package/dist/ws/index.d.ts +3 -3
- package/dist/ws/index.js +2 -2
- package/dist/ws/pending-tracker.d.ts +93 -0
- package/dist/ws/pending-tracker.js +132 -0
- package/dist/ws/sidecar-events.d.ts +139 -37
- package/dist/ws/sidecar-events.js +2 -2
- package/dist/ws/sidecar-handler.d.ts +218 -60
- package/dist/ws/sidecar-handler.js +1713 -732
- package/dist/ws/sidecar-handler.test-helpers.d.ts +38 -0
- package/dist/ws/sidecar-handler.test-helpers.js +95 -0
- package/dist/ws/sidecar-token-authenticator.d.ts +3 -1
- package/dist/ws/sidecar-token-authenticator.js +78 -7
- package/package.json +14 -13
- package/dist/available-skills-stanza.d.ts +0 -21
- package/dist/available-skills-stanza.js +0 -32
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import { type DB } from "@intx/db";
|
|
2
|
-
import type {
|
|
1
|
+
import { type DB, type SidecarAllocation } from "@intx/db";
|
|
2
|
+
import type { CredentialDelivery } from "@intx/types/sidecar";
|
|
3
|
+
import type { CredentialCipher } from "@intx/types";
|
|
4
|
+
import type { HarnessConfig, InferenceSource } from "@intx/types/runtime";
|
|
3
5
|
import { type RegistryConfig, type ScopeRoute } from "@intx/tool-packaging";
|
|
4
6
|
import { type ToolPackagePin } from "@intx/types/tool-packages";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
+
import type { SourceRefPin, WorkflowProjectionWithSources, WorkflowSourceAssetMount } from "@intx/types/sidecar";
|
|
8
|
+
import type { WorkflowDefinitionAssetSource, WorkflowDefinitionRegistrySource, WorkflowDefinitionSource } from "@intx/types/workflow-sources";
|
|
9
|
+
import { type DeployContent as OrchestratorDeployContent } from "@intx/workflow-deploy";
|
|
7
10
|
import type { AgentRepoStore, DeployContent } from "./agent-repo.js";
|
|
8
11
|
import { type AssetService } from "./asset-service.js";
|
|
9
|
-
import type { SidecarRouter } from "./ws/sidecar-handler.js";
|
|
12
|
+
import type { AllocatedSidecarTarget, SidecarAllocationRouter, SidecarRouter, WorkflowProbeResult } from "./ws/sidecar-handler.js";
|
|
13
|
+
import { type ResolveAssetAttachmentFn } from "./workflow-closure-resolution.js";
|
|
14
|
+
import { type InstallAndApproveResult } from "./workflow-probe-gate.js";
|
|
15
|
+
import type { SidecarReconciliationContext } from "./sidecar-allocation/operation.js";
|
|
10
16
|
export declare class SessionLaunchError extends Error {
|
|
11
17
|
/** Which phase failed: "write", "provision", "pack", or "start". */
|
|
12
18
|
readonly phase: string;
|
|
@@ -27,128 +33,97 @@ export type SessionService = {
|
|
|
27
33
|
stageWorkflowStep(params: {
|
|
28
34
|
agentAddress: string;
|
|
29
35
|
agentId: string;
|
|
30
|
-
|
|
36
|
+
runId: string;
|
|
31
37
|
config: HarnessConfig;
|
|
32
38
|
deployContent: DeployContent;
|
|
33
39
|
toolPackagePins?: readonly ToolPackagePin[];
|
|
40
|
+
allocationTarget: AllocatedSidecarTarget;
|
|
34
41
|
}): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* Deploy a single-agent instance through the single-step-at-head path,
|
|
37
|
-
* wrapping the harness as a one-step workflow and routing it through the
|
|
38
|
-
* deploy core with the instance's real identity. Replaces `launchSession`
|
|
39
|
-
* as the production instance-deploy entry point: the instance runs as a
|
|
40
|
-
* supervised workflow-process child. Writes no `workflow_deployment`
|
|
41
|
-
* row. Returns the head's agent-key ack (the key the head signs its
|
|
42
|
-
* reconnect challenges with).
|
|
43
|
-
*/
|
|
44
|
-
deployInstanceAtHead(params: {
|
|
45
|
-
agentAddress: string;
|
|
46
|
-
agentId: string;
|
|
47
|
-
instanceId: string;
|
|
48
|
-
config: HarnessConfig;
|
|
49
|
-
deployContent: DeployContent;
|
|
50
|
-
toolPackagePins?: readonly ToolPackagePin[];
|
|
51
|
-
}): Promise<{
|
|
52
|
-
publicKey: string;
|
|
53
|
-
}>;
|
|
54
|
-
/**
|
|
55
|
-
* Deploy a one-step workflow once at the head through the deploy core,
|
|
56
|
-
* without the DB-backed `workflow_deployment` projection row. Stages the
|
|
57
|
-
* head's deploy tree (deploy-tree write, pack, asset fan-out), fires the
|
|
58
|
-
* deployment `agent.deploy` frame carrying the workflow definition +
|
|
59
|
-
* source pin (the sidecar initializes the head repo and spawns the
|
|
60
|
-
* workflow-process child), then delivers the pack to the head. Returns
|
|
61
|
-
* the sidecar supervisor's principal public key. See `DeploySingleStepFn`.
|
|
62
|
-
*/
|
|
63
|
-
deploySingleStepAtHead: DeploySingleStepFn;
|
|
64
|
-
/**
|
|
65
|
-
* Deploy a multi-step `WorkflowDefinition` through the workflow-deploy
|
|
66
|
-
* orchestrator's multi-step branch. This is the general workflow
|
|
67
|
-
* deploy entry point: it is not coupled to a single agent's
|
|
68
|
-
* credential/session model the way `launchSession` is. The
|
|
69
|
-
* orchestrator derives every per-step address
|
|
70
|
-
* from `deploymentId` + `deploymentDomain`, provisions each step's
|
|
71
|
-
* agent-state repo via the shared per-agent deploy phases, writes the
|
|
72
|
-
* workflow repo, and fires the deployment-level `agent.deploy` frame.
|
|
73
|
-
*
|
|
74
|
-
* Persists one `workflow_deployment` projection row keyed by
|
|
75
|
-
* `deploymentId` so the deployment is listable per tenant; the
|
|
76
|
-
* RepoStore substrate has no by-kind listing API of its own.
|
|
77
|
-
*
|
|
78
|
-
* Returns the supervisor's principal public key surfaced by the
|
|
79
|
-
* sidecar's `agent.deploy.ack`.
|
|
80
|
-
*/
|
|
81
|
-
deployWorkflowDefinition(params: DeployWorkflowDefinitionParams): Promise<DeployWorkflowDefinitionResult>;
|
|
82
|
-
/**
|
|
83
|
-
* Compose a signed RFC 2822 message from the user and deliver it to the
|
|
84
|
-
* agent via the mail transport. Throws if the agent is unreachable.
|
|
85
|
-
* Returns the raw MIME bytes of the assembled message.
|
|
86
|
-
*/
|
|
87
|
-
sendUserMessage(params: UserMessageParams): Promise<Uint8Array>;
|
|
88
42
|
/**
|
|
89
43
|
* Undeploy an agent and wait for the sidecar to acknowledge.
|
|
90
44
|
*/
|
|
91
45
|
endSession(agentAddress: string, reason: string): Promise<void>;
|
|
92
46
|
};
|
|
93
|
-
export type DeployWorkflowDefinitionParams = {
|
|
94
|
-
/** Owning tenant; recorded on the projection row. */
|
|
95
|
-
tenantId: string;
|
|
96
|
-
/**
|
|
97
|
-
* Stable deployment identifier. The orchestrator concatenates it into
|
|
98
|
-
* every derived per-step address and the deployment-level address, and
|
|
99
|
-
* it is the `workflow_deployment` row's primary key. The caller owns
|
|
100
|
-
* its generation.
|
|
101
|
-
*/
|
|
102
|
-
deploymentId: string;
|
|
103
|
-
/**
|
|
104
|
-
* Mail domain the deployment's derived addresses live under. The
|
|
105
|
-
* orchestrator derives `ins_<deploymentId>-<stepId>@<deploymentDomain>`
|
|
106
|
-
* per step and `ins_<deploymentId>@<deploymentDomain>` for the
|
|
107
|
-
* deployment-level supervisor address.
|
|
108
|
-
*/
|
|
109
|
-
deploymentDomain: string;
|
|
110
|
-
/** The hydrated workflow definition to deploy. */
|
|
111
|
-
definition: WorkflowDefinition;
|
|
112
|
-
/**
|
|
113
|
-
* The `workflow`-kind asset the definition was hydrated from. Recorded
|
|
114
|
-
* on the projection row so the listing surface can join back to the
|
|
115
|
-
* source asset.
|
|
116
|
-
*/
|
|
117
|
-
definitionAssetId: string;
|
|
118
|
-
/**
|
|
119
|
-
* Harness configuration shared across every step's launch. The
|
|
120
|
-
* orchestrator overrides `agentAddress`, `agentId`, and `systemPrompt`
|
|
121
|
-
* per step.
|
|
122
|
-
*/
|
|
123
|
-
config: HarnessConfig;
|
|
124
|
-
/** Deploy-tree content shared across every step's launch. */
|
|
125
|
-
deployContent: DeployContent;
|
|
126
|
-
/** Tool-package pins to ship with every step's deploy. */
|
|
127
|
-
toolPackagePins?: readonly ToolPackagePin[];
|
|
128
|
-
};
|
|
129
47
|
export type DeployWorkflowDefinitionResult = {
|
|
130
48
|
/** Echoes the deployment id recorded on the projection row. */
|
|
131
|
-
|
|
49
|
+
anchorRunId: string;
|
|
132
50
|
/** Deployment-level mail address the supervisor registers on the bus. */
|
|
133
51
|
deploymentAddress: string;
|
|
134
52
|
/** Supervisor principal public key from the sidecar's deploy ack. */
|
|
135
53
|
publicKey: string;
|
|
136
54
|
};
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Install/probe/gate/freeze inputs for a code-sourced workflow, DECOUPLED from
|
|
57
|
+
* deploy. The provisioned prepare path calls this on probe-scoped capacity,
|
|
58
|
+
* persists the frozen bundle, and deploys it to the workflow allocation later
|
|
59
|
+
* with no re-probe.
|
|
60
|
+
*/
|
|
61
|
+
export type InstallAndApproveWorkflowSourceParams = {
|
|
62
|
+
/** Where the definition's bytes come from at probe time. */
|
|
63
|
+
source: WorkflowDefinitionSource;
|
|
64
|
+
/** The `interchange.workflow` entry-module path the sidecar evaluates. */
|
|
65
|
+
entry: string;
|
|
66
|
+
/**
|
|
67
|
+
* A `name@range` spec for the definition package. REQUIRED for the `registry`
|
|
68
|
+
* and asset-`tarball` variants; omitted for the asset-`source` variant.
|
|
69
|
+
*/
|
|
70
|
+
pin?: string;
|
|
71
|
+
/** The `workflow`-kind asset the frozen definition projects a definition over. */
|
|
72
|
+
definitionAssetId: string;
|
|
73
|
+
/** The exact provisioned generation that executes the probe. */
|
|
74
|
+
allocationTarget: AllocatedSidecarTarget;
|
|
75
|
+
/** Optional durable handoff invoked with the raw probe answer. */
|
|
76
|
+
onProbeResult?: (result: WorkflowProbeResult) => Promise<void>;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Inputs to deploy a previously-frozen code-sourced approval bundle to a
|
|
80
|
+
* dedicated allocation. Mirrors `DeployPreparedWorkflowDefinitionParams` for the
|
|
81
|
+
* source-ref lineage: the anchor `workflow_run` row already exists from prepare
|
|
82
|
+
* time, so the deploy UPDATES it under the allocation-ownership lock rather than
|
|
83
|
+
* inserting a fresh one.
|
|
84
|
+
*/
|
|
85
|
+
export type DeployPreparedCodeSourcedWorkflowParams = {
|
|
86
|
+
/** Owning tenant; the definition's own tenant for credential resolution. */
|
|
147
87
|
tenantId: string;
|
|
148
|
-
|
|
88
|
+
/** The pre-inserted anchor run id, fixed at prepare time. */
|
|
89
|
+
anchorRunId: string;
|
|
90
|
+
/** Mail domain the deployment's derived addresses live under. */
|
|
91
|
+
deploymentDomain: string;
|
|
92
|
+
/** The deployment-level mail address; re-derived and asserted coherent. */
|
|
93
|
+
agentAddress: string;
|
|
94
|
+
/** Where the definition's bytes come from, rehydrated from the frozen bundle. */
|
|
95
|
+
source: WorkflowDefinitionSource;
|
|
96
|
+
/** The frozen approval bundle rehydrated from the launch spec. */
|
|
97
|
+
approved: InstallAndApproveResult;
|
|
98
|
+
/** Harness config carrying the re-resolved per-step inference chain. */
|
|
99
|
+
config: HarnessConfig;
|
|
100
|
+
/** The exact allocation generation to deploy onto. */
|
|
101
|
+
allocationTarget: AllocatedSidecarTarget;
|
|
102
|
+
/** Current owner and cancellation of this initialization attempt. */
|
|
103
|
+
reconciliation: SidecarReconciliationContext;
|
|
104
|
+
/** Cipher for the definition's tenant-owned credential bindings, if any. */
|
|
105
|
+
credentialCipher?: CredentialCipher;
|
|
106
|
+
};
|
|
107
|
+
export type PreparedWorkflowDeployer = {
|
|
108
|
+
/**
|
|
109
|
+
* Install + probe + gate + freeze a code-sourced definition, returning the
|
|
110
|
+
* frozen bundle WITHOUT deploying it. The provisioned
|
|
111
|
+
* prepare path persists the bundle and deploys it later via
|
|
112
|
+
* `deployPreparedCodeSourcedWorkflow`.
|
|
113
|
+
*/
|
|
114
|
+
installAndApproveWorkflowSource(params: InstallAndApproveWorkflowSourceParams): Promise<InstallAndApproveResult>;
|
|
115
|
+
/**
|
|
116
|
+
* Deploy a previously-frozen code-sourced approval bundle to a dedicated
|
|
117
|
+
* allocation, updating the pre-existing anchor run under the
|
|
118
|
+
* allocation-ownership lock. No re-probe: the frozen projection/hash/closure
|
|
119
|
+
* ride verbatim.
|
|
120
|
+
*/
|
|
121
|
+
deployPreparedCodeSourcedWorkflow(params: DeployPreparedCodeSourcedWorkflowParams): Promise<DeployWorkflowDefinitionResult>;
|
|
149
122
|
};
|
|
150
123
|
export type SessionServiceDeps = {
|
|
151
124
|
sidecarRouter: SidecarRouter;
|
|
125
|
+
/** Present when this Hub can route deploy phases to provisioned allocations. */
|
|
126
|
+
sidecarAllocationRouter?: SidecarAllocationRouter;
|
|
152
127
|
agentRepoStore: AgentRepoStore;
|
|
153
128
|
/**
|
|
154
129
|
* Optional asset attachment integration. When set, the deploy flow
|
|
@@ -209,27 +184,178 @@ export type SessionServiceDeps = {
|
|
|
209
184
|
* production multi-step callback does, rather than casting `unknown`.
|
|
210
185
|
*/
|
|
211
186
|
export declare function bridgeOrchestratorDeployContent(content: OrchestratorDeployContent): DeployContent;
|
|
212
|
-
/**
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
* sidecar's deploy router uses field presence to route the frame to
|
|
217
|
-
* the workflow deploy path. The supervisor public key returned by the
|
|
218
|
-
* sidecar's `agent.deploy.ack` is threaded back as the
|
|
219
|
-
* `MultiStepDeployResult.publicKey`.
|
|
220
|
-
*
|
|
221
|
-
* Exported so the co-located caller-site test can assert that the
|
|
222
|
-
* closure constructed in `launchSession` reaches the wire surface via
|
|
223
|
-
* `sendAgentDeploy` with a `workflow` field structurally matching the
|
|
224
|
-
* `AgentDeployFrame.workflow` schema.
|
|
225
|
-
*/
|
|
226
|
-
export declare function sendMultiStepDeployFrame(args: {
|
|
227
|
-
sidecarRouter: SidecarRouter;
|
|
187
|
+
/** Fields the deploy frame carries onto `sendAgentDeploy`. */
|
|
188
|
+
type DeployFrameCommonArgs = {
|
|
189
|
+
sidecarAllocationRouter: SidecarAllocationRouter;
|
|
190
|
+
allocationTarget: AllocatedSidecarTarget;
|
|
228
191
|
agentAddress: string;
|
|
229
192
|
config: HarnessConfig;
|
|
230
|
-
definition: WorkflowDefinition;
|
|
231
193
|
sources: Record<string, InferenceSource[]>;
|
|
232
|
-
}
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* For a code-sourced (npm) deploy the hub never holds the live
|
|
197
|
+
* `WorkflowDefinition` -- it lives only in the airlocked child. The gate/freeze
|
|
198
|
+
* layer hashed the inert projection; the deploy frame carries that hash and the
|
|
199
|
+
* source-ref pin, and the sidecar re-materializes and evaluates the pinned code
|
|
200
|
+
* from the pin, so no inline definition rides the frame. The content hash is
|
|
201
|
+
* owned by the gate, so this frame never recomputes it -- recomputing over a
|
|
202
|
+
* live wire lineage would diverge from the inert projection the child
|
|
203
|
+
* re-verifies against.
|
|
204
|
+
*/
|
|
205
|
+
export type SourceRefDeployFrameArgs = DeployFrameCommonArgs & {
|
|
206
|
+
lineage: "source-ref";
|
|
207
|
+
/**
|
|
208
|
+
* The gate-frozen wire hash of the approved projection -- stamped onto the
|
|
209
|
+
* frame VERBATIM. This arm does not recompute it: the freeze layer owns the
|
|
210
|
+
* content hash, and the child re-verifies its closure evaluation against this
|
|
211
|
+
* exact value.
|
|
212
|
+
*/
|
|
213
|
+
approvedWireHash: string;
|
|
214
|
+
/**
|
|
215
|
+
* The source-ref pin: where the definition's bytes come from plus the frozen
|
|
216
|
+
* dependency closure the hub resolved for it. The two co-travel, so they are
|
|
217
|
+
* one required object on this arm (see `SourceRefPin`) -- the sidecar
|
|
218
|
+
* re-materializes the exact tree from the pin at apply time.
|
|
219
|
+
*/
|
|
220
|
+
sourceRef: SourceRefPin;
|
|
221
|
+
/**
|
|
222
|
+
* Resolved credential material for the definition's credential bindings,
|
|
223
|
+
* delivered to the child on the frame. The hub resolves + decrypts here; the
|
|
224
|
+
* source-ref child decrypts nothing. The grant that AUTHORIZES a credential's
|
|
225
|
+
* use is minted per-run by run-grant materialization, not carried on this
|
|
226
|
+
* frame.
|
|
227
|
+
*/
|
|
228
|
+
credentials?: CredentialDelivery;
|
|
229
|
+
/**
|
|
230
|
+
* The projection's inline onTrigger section bodies, each already in inert wire
|
|
231
|
+
* form with its per-step inference sources pinned and its own wire hash --
|
|
232
|
+
* built by `deployCodeSourcedWorkflow` from the frozen projection. The sidecar
|
|
233
|
+
* seals each body's sources into the run record and re-verifies against its
|
|
234
|
+
* wire hash. Absent when the projection has no inline onTrigger body.
|
|
235
|
+
*/
|
|
236
|
+
referencedDefinitions?: readonly WorkflowProjectionWithSources[];
|
|
237
|
+
/**
|
|
238
|
+
* Source assets the pin's `kind:"asset"` closure entries read from, delivered
|
|
239
|
+
* inline on the frame so the sidecar checks them out into its durable
|
|
240
|
+
* per-deployment source store. Absent for a registry-sourced pin (its tarballs
|
|
241
|
+
* are fetched over HTTP).
|
|
242
|
+
*/
|
|
243
|
+
assets?: readonly WorkflowSourceAssetMount[];
|
|
244
|
+
};
|
|
245
|
+
export type SendMultiStepDeployFrameArgs = SourceRefDeployFrameArgs;
|
|
246
|
+
/**
|
|
247
|
+
* Emit the source-ref deploy frame onto `SidecarRouter.sendAgentDeploy`. The
|
|
248
|
+
* router accepts an optional `workflow` projection on the deploy frame; the
|
|
249
|
+
* sidecar's deploy router uses field presence to route the frame to the
|
|
250
|
+
* workflow deploy path, and returns the supervisor public key on the
|
|
251
|
+
* `agent.deploy.ack`.
|
|
252
|
+
*
|
|
253
|
+
* The gate/freeze layer already hashed the inert projection, so the frozen hash
|
|
254
|
+
* and the inert projection ride the frame verbatim -- this never recomputes the
|
|
255
|
+
* content hash. Recomputing over a live wire lineage would diverge from the
|
|
256
|
+
* inert projection the child re-verifies against.
|
|
257
|
+
*
|
|
258
|
+
* Exported so the co-located caller-site test can assert that the constructed
|
|
259
|
+
* closure reaches the wire surface via `sendAgentDeploy` with a `workflow`
|
|
260
|
+
* field structurally matching the `AgentDeployFrame.workflow` schema.
|
|
261
|
+
*/
|
|
262
|
+
export declare function sendMultiStepDeployFrame(args: SendMultiStepDeployFrameArgs, signal?: AbortSignal, beforeSend?: () => Promise<void>): Promise<{
|
|
263
|
+
publicKey: string;
|
|
264
|
+
}>;
|
|
265
|
+
/**
|
|
266
|
+
* Arguments for `deployCodeSourcedWorkflow`. The `approved` bundle is the
|
|
267
|
+
* `installAndApproveWorkflowDefinition` output verbatim -- the frozen hash,
|
|
268
|
+
* inert projection, and closure travel together inside it so no caller can pair
|
|
269
|
+
* a hash with a mismatched projection or closure. The remaining fields are the
|
|
270
|
+
* operator/asset config the approve step never sees: the per-step inference
|
|
271
|
+
* `sources`, the deploy `config`, the target `agentAddress`, and the `source`
|
|
272
|
+
* ref that names where the definition's bytes are published.
|
|
273
|
+
*/
|
|
274
|
+
type DeployCodeSourcedCommonArgs = DeployFrameCommonArgs & {
|
|
275
|
+
approved: InstallAndApproveResult;
|
|
276
|
+
/**
|
|
277
|
+
* The hub DB handle, the definition's OWN tenant, the deployment's anchor run
|
|
278
|
+
* id, and the mail domain its run address lives under. REQUIRED: this function
|
|
279
|
+
* writes the deployment's anchor `workflow_run` row, and run-grant
|
|
280
|
+
* materialization keys off it. `tenantId` is the definition's own tenant
|
|
281
|
+
* (tenant-owned credential resolution walks up from it); do not pass a
|
|
282
|
+
* request/config tenant that may differ. `anchorRunId` is caller-supplied: the
|
|
283
|
+
* deployment mail address is frozen into the approved package bytes at
|
|
284
|
+
* authoring time, so the run id it derives from is fixed before this runs and
|
|
285
|
+
* cannot be minted here. `deploymentDomain` pairs with `anchorRunId` to
|
|
286
|
+
* re-derive the run address and assert it matches `agentAddress`, failing
|
|
287
|
+
* closed on an incoherent pair.
|
|
288
|
+
*/
|
|
289
|
+
db: DB["db"];
|
|
290
|
+
tenantId: string;
|
|
291
|
+
anchorRunId: string;
|
|
292
|
+
deploymentDomain: string;
|
|
293
|
+
/**
|
|
294
|
+
* Credential cipher, REQUIRED whenever the definition carries credential
|
|
295
|
+
* bindings OR any pinned inference source (top-level or inline body) references
|
|
296
|
+
* a credential; resolution fails closed without it. Omit only for a deploy with
|
|
297
|
+
* neither.
|
|
298
|
+
*/
|
|
299
|
+
credentialCipher?: CredentialCipher;
|
|
300
|
+
};
|
|
301
|
+
/** Deploy a definition published to an npm registry: the sidecar fetches its
|
|
302
|
+
* tarballs over HTTP, so no source asset is delivered. */
|
|
303
|
+
export type DeployCodeSourcedRegistryArgs = DeployCodeSourcedCommonArgs & {
|
|
304
|
+
source: WorkflowDefinitionRegistrySource;
|
|
305
|
+
};
|
|
306
|
+
/** Deploy a definition sourced from a hub `package-registry` asset: the caller
|
|
307
|
+
* mints `resolveAttachment` so this glue delivers the asset packs the sidecar
|
|
308
|
+
* checks out, without importing the asset service. */
|
|
309
|
+
export type DeployCodeSourcedAssetArgs = DeployCodeSourcedCommonArgs & {
|
|
310
|
+
source: WorkflowDefinitionAssetSource;
|
|
311
|
+
resolveAttachment: ResolveAssetAttachmentFn;
|
|
312
|
+
};
|
|
313
|
+
export type DeployCodeSourcedWorkflowArgs = DeployCodeSourcedRegistryArgs | DeployCodeSourcedAssetArgs;
|
|
314
|
+
/**
|
|
315
|
+
* A direct allocation-bound composition entrypoint for tests and low-level
|
|
316
|
+
* callers: prepare, INSERT the deployment's anchor `workflow_run` row, THEN emit
|
|
317
|
+
* the source-ref frame. The anchor row is the deployment's first-class record
|
|
318
|
+
* that owns its routing address and public key. Run-grant materialization keys
|
|
319
|
+
* off this row (address + live status), so WITHOUT it no per-run grants (tool,
|
|
320
|
+
* capability, OR credential) ever materialize for a source-ref deployment. Born
|
|
321
|
+
* "deployed" (live but pre-trigger) with a null public key: the first trigger's
|
|
322
|
+
* materialization flips it to "running" via `anchorWithPrincipal`'s guarded
|
|
323
|
+
* update, which a row born "running" would skip. Its `anchorRunId` equals its
|
|
324
|
+
* own id, so the anchor references itself. The deployer read grant is deferred
|
|
325
|
+
* to the production route, which carries the authenticated deployer principal.
|
|
326
|
+
*
|
|
327
|
+
* ORDERING IS LOAD-BEARING. The anchor row must be committed and visible to the
|
|
328
|
+
* pack-receipt connection BEFORE the frame reaches the wire: the frame spawns
|
|
329
|
+
* the child, whose first events pack races the ack back, and
|
|
330
|
+
* `receiveWorkflowRunPack` fails closed on a missing live anchor. Emitting first
|
|
331
|
+
* (the previous order) rejected that first pack and never bootstrapped the log.
|
|
332
|
+
* This works because `args.db` is the autocommit handle (`DB["db"]`, which the
|
|
333
|
+
* type forbids from being a transaction) and the INSERT is NOT wrapped in a
|
|
334
|
+
* transaction with the emit -- so the row is durably visible the instant the
|
|
335
|
+
* INSERT statement returns. Do NOT relax `db` to a transaction executor or wrap
|
|
336
|
+
* anchor+emit in one transaction to make them atomic: that reopens the race.
|
|
337
|
+
*
|
|
338
|
+
* On emit failure the anchor row is rolled back or fenced by the `frameSent`
|
|
339
|
+
* evidence from the transport. `leakedAgent: false` (safe to fully roll back) is
|
|
340
|
+
* the STRONG claim and is made only on positive proof the frame never reached
|
|
341
|
+
* the wire (`isDeployFrameFailure && frameSent === false`); every other failure
|
|
342
|
+
* -- a sent-but-unacked frame OR any untagged error -- is treated as
|
|
343
|
+
* possibly-live: the anchor is fenced `deployed` -> `failed` and the error is
|
|
344
|
+
* `leakedAgent: true`.
|
|
345
|
+
*
|
|
346
|
+
* The prepared provisioned path does NOT use this composition: its anchor row
|
|
347
|
+
* already exists from prepare time, so it drives `emitSourceRefDeployFrame` and
|
|
348
|
+
* an UPDATE-under-allocation-lock instead.
|
|
349
|
+
*/
|
|
350
|
+
export declare function deployCodeSourcedWorkflow(args: DeployCodeSourcedWorkflowArgs): Promise<{
|
|
233
351
|
publicKey: string;
|
|
234
352
|
}>;
|
|
235
|
-
|
|
353
|
+
/** Resolve deferred sender mail after claiming the previous initializer's lease. */
|
|
354
|
+
export declare function recoverSenderDeploy(args: {
|
|
355
|
+
db: DB["db"];
|
|
356
|
+
sidecarRouter: Pick<SidecarRouter, "noteSenderDeploySettled">;
|
|
357
|
+
allocation: SidecarAllocation;
|
|
358
|
+
reconciliation: SidecarReconciliationContext;
|
|
359
|
+
}): Promise<void>;
|
|
360
|
+
export declare function createSessionService(deps: SessionServiceDeps): SessionService & PreparedWorkflowDeployer;
|
|
361
|
+
export {};
|