@intx/hub-sessions 0.1.2 → 0.3.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/LICENSE +176 -0
- package/README.md +82 -1
- package/dist/agent-repo.d.ts +93 -0
- package/dist/agent-repo.js +109 -0
- package/dist/agent-state-kind.d.ts +12 -0
- package/dist/agent-state-kind.js +189 -0
- package/dist/asset-service.d.ts +104 -0
- package/dist/asset-service.js +267 -0
- package/dist/committed-source-tree.d.ts +10 -0
- package/dist/committed-source-tree.js +35 -0
- package/dist/credential-push.d.ts +33 -0
- package/dist/credential-push.js +109 -0
- package/dist/event-collector-registry.d.ts +20 -0
- package/dist/event-collector-registry.js +115 -0
- package/dist/event-collector.d.ts +39 -0
- package/dist/event-collector.js +365 -0
- package/dist/hub-session-lookups.d.ts +135 -0
- package/dist/hub-session-lookups.js +663 -0
- package/dist/hub-session-orchestrator.d.ts +25 -0
- package/dist/hub-session-orchestrator.js +87 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +24 -0
- package/dist/package-registry-kind.d.ts +70 -0
- package/dist/package-registry-kind.js +260 -0
- package/dist/repo-store/index.d.ts +4 -0
- package/dist/repo-store/index.js +3 -0
- package/dist/repo-store/store.d.ts +41 -0
- package/dist/repo-store/store.js +1829 -0
- package/dist/repo-store/subscribe-kind.d.ts +56 -0
- package/dist/repo-store/subscribe-kind.js +144 -0
- package/dist/repo-store/types.d.ts +571 -0
- package/dist/repo-store/types.js +42 -0
- package/dist/session-service.d.ts +416 -0
- package/dist/session-service.js +1191 -0
- package/dist/sidecar-allocation/contracts.d.ts +78 -0
- package/dist/sidecar-allocation/contracts.js +21 -0
- package/dist/sidecar-allocation/index.d.ts +4 -0
- package/dist/sidecar-allocation/index.js +3 -0
- package/dist/sidecar-allocation/placement-policy.d.ts +11 -0
- package/dist/sidecar-allocation/placement-policy.js +21 -0
- package/dist/sidecar-allocation/plugin-registry.d.ts +11 -0
- package/dist/sidecar-allocation/plugin-registry.js +37 -0
- package/dist/sidecar-allocation/reconciler.d.ts +42 -0
- package/dist/sidecar-allocation/reconciler.js +431 -0
- package/dist/skill-kind.d.ts +41 -0
- package/dist/skill-kind.js +292 -0
- package/dist/substrate.d.ts +8 -0
- package/dist/substrate.js +21 -0
- package/dist/workflow-allocation-service.d.ts +58 -0
- package/dist/workflow-allocation-service.js +239 -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 +40 -0
- package/dist/workflow-dispatch-service.js +146 -0
- package/dist/workflow-dispatch-settlement.d.ts +29 -0
- package/dist/workflow-dispatch-settlement.js +140 -0
- package/dist/workflow-kind.d.ts +37 -0
- package/dist/workflow-kind.js +310 -0
- package/dist/workflow-probe-gate.d.ts +214 -0
- package/dist/workflow-probe-gate.js +207 -0
- package/dist/workflow-run-event-log.d.ts +21 -0
- package/dist/workflow-run-event-log.js +51 -0
- package/dist/workflow-run-kind.d.ts +440 -0
- package/dist/workflow-run-kind.js +2916 -0
- package/dist/workflow-run-reader.d.ts +47 -0
- package/dist/workflow-run-reader.js +153 -0
- package/dist/workflow-run-restore.d.ts +15 -0
- package/dist/workflow-run-restore.js +26 -0
- package/dist/workflow-source-closure.d.ts +35 -0
- package/dist/workflow-source-closure.js +342 -0
- package/dist/ws/index.d.ts +3 -0
- package/dist/ws/index.js +3 -0
- package/dist/ws/sidecar-events.d.ts +222 -0
- package/dist/ws/sidecar-events.js +72 -0
- package/dist/ws/sidecar-handler.d.ts +305 -0
- package/dist/ws/sidecar-handler.js +2537 -0
- package/dist/ws/sidecar-token-authenticator.d.ts +17 -0
- package/dist/ws/sidecar-token-authenticator.js +81 -0
- package/package.json +35 -12
- package/src/agent-repo.test.ts +0 -310
- package/src/agent-repo.ts +0 -165
- package/src/agent-state-kind.test.ts +0 -247
- package/src/agent-state-kind.ts +0 -204
- package/src/asset-service.test.ts +0 -540
- package/src/asset-service.ts +0 -378
- package/src/available-skills-stanza.test.ts +0 -87
- package/src/available-skills-stanza.ts +0 -47
- package/src/credential-push.ts +0 -65
- package/src/event-collector-registry.test.ts +0 -73
- package/src/event-collector-registry.ts +0 -171
- package/src/event-collector.test.ts +0 -1387
- package/src/event-collector.ts +0 -424
- package/src/hub-session-lookups.ts +0 -206
- package/src/hub-session-orchestrator.test.ts +0 -510
- package/src/hub-session-orchestrator.ts +0 -213
- package/src/index.ts +0 -78
- package/src/repo-store/index.ts +0 -15
- package/src/repo-store/store.test.ts +0 -1169
- package/src/repo-store/store.ts +0 -428
- package/src/repo-store/types.ts +0 -253
- package/src/session-service.test.ts +0 -895
- package/src/session-service.ts +0 -464
- package/src/skill-kind.test.ts +0 -599
- package/src/skill-kind.ts +0 -350
- package/src/ws/index.ts +0 -18
- package/src/ws/sidecar-events.test.ts +0 -96
- package/src/ws/sidecar-events.ts +0 -231
- package/src/ws/sidecar-handler.test.ts +0 -2217
- package/src/ws/sidecar-handler.ts +0 -1574
- package/tsconfig.json +0 -4
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
import { type DB } from "@intx/db";
|
|
2
|
+
import type { CredentialDelivery } from "@intx/types/sidecar";
|
|
3
|
+
import type { CredentialCipher } from "@intx/types";
|
|
4
|
+
import type { CryptoProvider, HarnessConfig, InferenceSource, MessageAttachment } from "@intx/types/runtime";
|
|
5
|
+
import { type RegistryConfig, type ScopeRoute } from "@intx/tool-packaging";
|
|
6
|
+
import { type ToolPackagePin } from "@intx/types/tool-packages";
|
|
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";
|
|
10
|
+
import type { AgentRepoStore, DeployContent } from "./agent-repo.js";
|
|
11
|
+
import { type AssetService } from "./asset-service.js";
|
|
12
|
+
import type { AllocatedSidecarTarget, SidecarAllocationRouter, SidecarRouter } from "./ws/sidecar-handler.js";
|
|
13
|
+
import { type ResolveAssetAttachmentFn } from "./workflow-closure-resolution.js";
|
|
14
|
+
import { type InstallAndApproveResult } from "./workflow-probe-gate.js";
|
|
15
|
+
export declare class SessionLaunchError extends Error {
|
|
16
|
+
/** Which phase failed: "write", "provision", "pack", or "start". */
|
|
17
|
+
readonly phase: string;
|
|
18
|
+
/** True if the sidecar has a provisioned agent that could not be cleaned up. */
|
|
19
|
+
readonly leakedAgent: boolean;
|
|
20
|
+
constructor(phase: string, cause: unknown, leakedAgent: boolean);
|
|
21
|
+
}
|
|
22
|
+
export type SessionService = {
|
|
23
|
+
/**
|
|
24
|
+
* Stage one step of a multi-step workflow deploy: bind a transient route
|
|
25
|
+
* for the step address, fire a no-spawn provision frame (init the step's
|
|
26
|
+
* agent-state repo and record the hub key), deliver the deploy + asset
|
|
27
|
+
* packs, and unbind the route -- no warm harness. The multi-step branch
|
|
28
|
+
* stages every step this way before firing the deployment-level workflow
|
|
29
|
+
* frame that spawns the supervised child; the child reads each staged step
|
|
30
|
+
* tree from disk and runs the step itself.
|
|
31
|
+
*/
|
|
32
|
+
stageWorkflowStep(params: {
|
|
33
|
+
agentAddress: string;
|
|
34
|
+
agentId: string;
|
|
35
|
+
runId: string;
|
|
36
|
+
config: HarnessConfig;
|
|
37
|
+
deployContent: DeployContent;
|
|
38
|
+
toolPackagePins?: readonly ToolPackagePin[];
|
|
39
|
+
allocationTarget?: AllocatedSidecarTarget;
|
|
40
|
+
}): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Deploy a CODE-SOURCED workflow definition end to end: install + probe +
|
|
43
|
+
* gate + freeze (`approve-probed`), then deploy the frozen definition by
|
|
44
|
+
* source-ref. This is the general workflow deploy entry point the
|
|
45
|
+
* `POST /deployments` route drives; it never hydrates a live definition from a
|
|
46
|
+
* static `workflow.json`.
|
|
47
|
+
*
|
|
48
|
+
* The service owns the source-read wiring (`repoStore` committed reads and
|
|
49
|
+
* asset pack fan-out) and the registry configuration, so the caller passes
|
|
50
|
+
* only the deploy intent: where the definition's bytes come from
|
|
51
|
+
* (`source`/`entry`/`pin`), the `workflow`-kind asset the definition projects
|
|
52
|
+
* over (`definitionAssetId`), and the shared harness config. The method
|
|
53
|
+
* dispatches on `source.kind`/`source.package.format` to build the install
|
|
54
|
+
* args, pins every top-level step's inference source under the frozen
|
|
55
|
+
* approval, and persists the deployment's anchor run.
|
|
56
|
+
*
|
|
57
|
+
* Persists the deployment's anchor `workflow_run` (id = `anchorRunId`) via
|
|
58
|
+
* `deployCodeSourcedWorkflow`, so the deployment is listable per tenant.
|
|
59
|
+
* Returns the supervisor's principal public key from the sidecar deploy ack.
|
|
60
|
+
*/
|
|
61
|
+
deployWorkflowFromSource(params: DeployWorkflowFromSourceParams): Promise<DeployWorkflowDefinitionResult>;
|
|
62
|
+
/**
|
|
63
|
+
* Compose a signed RFC 2822 message from the user and deliver it to the
|
|
64
|
+
* agent via the mail transport. Throws if the agent is unreachable.
|
|
65
|
+
* Returns the raw MIME bytes of the assembled message.
|
|
66
|
+
*/
|
|
67
|
+
sendUserMessage(params: UserMessageParams): Promise<Uint8Array>;
|
|
68
|
+
/**
|
|
69
|
+
* Undeploy an agent and wait for the sidecar to acknowledge.
|
|
70
|
+
*/
|
|
71
|
+
endSession(agentAddress: string, reason: string): Promise<void>;
|
|
72
|
+
};
|
|
73
|
+
export type DeployWorkflowDefinitionResult = {
|
|
74
|
+
/** Echoes the deployment id recorded on the projection row. */
|
|
75
|
+
anchorRunId: string;
|
|
76
|
+
/** Deployment-level mail address the supervisor registers on the bus. */
|
|
77
|
+
deploymentAddress: string;
|
|
78
|
+
/** Supervisor principal public key from the sidecar's deploy ack. */
|
|
79
|
+
publicKey: string;
|
|
80
|
+
};
|
|
81
|
+
export type DeployWorkflowFromSourceParams = {
|
|
82
|
+
/** Owning tenant; recorded on the deployment's anchor run. */
|
|
83
|
+
tenantId: string;
|
|
84
|
+
/**
|
|
85
|
+
* Stable deployment identifier and anchor-run id. The deployment-level
|
|
86
|
+
* address derives from it; the caller owns its generation.
|
|
87
|
+
*/
|
|
88
|
+
anchorRunId: string;
|
|
89
|
+
/** Mail domain the deployment's derived addresses live under. */
|
|
90
|
+
deploymentDomain: string;
|
|
91
|
+
/**
|
|
92
|
+
* The deployment-level mail address, derived by the caller from `anchorRunId`
|
|
93
|
+
* + `deploymentDomain`. Re-derived and asserted coherent inside
|
|
94
|
+
* `deployCodeSourcedWorkflow`.
|
|
95
|
+
*/
|
|
96
|
+
agentAddress: string;
|
|
97
|
+
/** Where the definition's bytes come from at apply time. */
|
|
98
|
+
source: WorkflowDefinitionSource;
|
|
99
|
+
/** The `interchange.workflow` entry-module path the sidecar evaluates. */
|
|
100
|
+
entry: string;
|
|
101
|
+
/**
|
|
102
|
+
* A `name@range` spec for the definition package. REQUIRED for the `registry`
|
|
103
|
+
* and asset-`tarball` variants (the pin selects the member); omitted for the
|
|
104
|
+
* asset-`source` variant, whose member is selected by `package.packageName`.
|
|
105
|
+
*/
|
|
106
|
+
pin?: string;
|
|
107
|
+
/**
|
|
108
|
+
* The `workflow`-kind asset the frozen definition projects a
|
|
109
|
+
* `workflow_definition` over. Distinct from a `source.kind === "asset"`
|
|
110
|
+
* source's `assetId`, which names where the bytes live.
|
|
111
|
+
*/
|
|
112
|
+
definitionAssetId: string;
|
|
113
|
+
/**
|
|
114
|
+
* Harness config shared across the deployment. Its `sources`/`defaultSource`
|
|
115
|
+
* are the operator-supplied inference chain; the method pins each top-level
|
|
116
|
+
* step to one approved source from it.
|
|
117
|
+
*/
|
|
118
|
+
config: HarnessConfig;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Install/probe/gate/freeze inputs for a code-sourced workflow, DECOUPLED from
|
|
122
|
+
* deploy. The exclusive prepare path calls this on shared capacity at request
|
|
123
|
+
* time to freeze the approval, persists the frozen bundle, and deploys it to a
|
|
124
|
+
* dedicated allocation later with no re-probe.
|
|
125
|
+
*/
|
|
126
|
+
export type InstallAndApproveWorkflowSourceParams = {
|
|
127
|
+
/** Where the definition's bytes come from at probe time. */
|
|
128
|
+
source: WorkflowDefinitionSource;
|
|
129
|
+
/** The `interchange.workflow` entry-module path the sidecar evaluates. */
|
|
130
|
+
entry: string;
|
|
131
|
+
/**
|
|
132
|
+
* A `name@range` spec for the definition package. REQUIRED for the `registry`
|
|
133
|
+
* and asset-`tarball` variants; omitted for the asset-`source` variant.
|
|
134
|
+
*/
|
|
135
|
+
pin?: string;
|
|
136
|
+
/** The `workflow`-kind asset the frozen definition projects a definition over. */
|
|
137
|
+
definitionAssetId: string;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Inputs to deploy a previously-frozen code-sourced approval bundle to a
|
|
141
|
+
* dedicated allocation. Mirrors `DeployPreparedWorkflowDefinitionParams` for the
|
|
142
|
+
* source-ref lineage: the anchor `workflow_run` row already exists from prepare
|
|
143
|
+
* time, so the deploy UPDATES it under the allocation-ownership lock rather than
|
|
144
|
+
* inserting a fresh one.
|
|
145
|
+
*/
|
|
146
|
+
export type DeployPreparedCodeSourcedWorkflowParams = {
|
|
147
|
+
/** Owning tenant; the definition's own tenant for credential resolution. */
|
|
148
|
+
tenantId: string;
|
|
149
|
+
/** The pre-inserted anchor run id, fixed at prepare time. */
|
|
150
|
+
anchorRunId: string;
|
|
151
|
+
/** Mail domain the deployment's derived addresses live under. */
|
|
152
|
+
deploymentDomain: string;
|
|
153
|
+
/** The deployment-level mail address; re-derived and asserted coherent. */
|
|
154
|
+
agentAddress: string;
|
|
155
|
+
/** Where the definition's bytes come from, rehydrated from the frozen bundle. */
|
|
156
|
+
source: WorkflowDefinitionSource;
|
|
157
|
+
/** The frozen approval bundle rehydrated from the launch spec. */
|
|
158
|
+
approved: InstallAndApproveResult;
|
|
159
|
+
/** Harness config carrying the re-resolved per-step inference chain. */
|
|
160
|
+
config: HarnessConfig;
|
|
161
|
+
/** The exact allocation generation to deploy onto. */
|
|
162
|
+
allocationTarget: AllocatedSidecarTarget;
|
|
163
|
+
/** Cipher for the definition's tenant-owned credential bindings, if any. */
|
|
164
|
+
credentialCipher?: CredentialCipher;
|
|
165
|
+
};
|
|
166
|
+
export type PreparedWorkflowDeployer = {
|
|
167
|
+
/**
|
|
168
|
+
* Install + probe + gate + freeze a code-sourced definition on shared
|
|
169
|
+
* capacity, returning the frozen bundle WITHOUT deploying it. The exclusive
|
|
170
|
+
* prepare path persists the bundle and deploys it later via
|
|
171
|
+
* `deployPreparedCodeSourcedWorkflow`.
|
|
172
|
+
*/
|
|
173
|
+
installAndApproveWorkflowSource(params: InstallAndApproveWorkflowSourceParams): Promise<InstallAndApproveResult>;
|
|
174
|
+
/**
|
|
175
|
+
* Deploy a previously-frozen code-sourced approval bundle to a dedicated
|
|
176
|
+
* allocation, updating the pre-existing anchor run under the
|
|
177
|
+
* allocation-ownership lock. No re-probe: the frozen projection/hash/closure
|
|
178
|
+
* ride verbatim.
|
|
179
|
+
*/
|
|
180
|
+
deployPreparedCodeSourcedWorkflow(params: DeployPreparedCodeSourcedWorkflowParams): Promise<DeployWorkflowDefinitionResult>;
|
|
181
|
+
};
|
|
182
|
+
export type UserMessageParams = {
|
|
183
|
+
agentAddress: string;
|
|
184
|
+
from: string;
|
|
185
|
+
messageId: string;
|
|
186
|
+
date: Date;
|
|
187
|
+
content: string;
|
|
188
|
+
attachments?: MessageAttachment[];
|
|
189
|
+
inReplyTo?: string;
|
|
190
|
+
references?: string[];
|
|
191
|
+
sessionId: string;
|
|
192
|
+
tenantId: string;
|
|
193
|
+
cryptoProvider: CryptoProvider;
|
|
194
|
+
};
|
|
195
|
+
export type SessionServiceDeps = {
|
|
196
|
+
sidecarRouter: SidecarRouter;
|
|
197
|
+
/** Present when this Hub can route deploy phases to exclusive allocations. */
|
|
198
|
+
sidecarAllocationRouter?: SidecarAllocationRouter;
|
|
199
|
+
agentRepoStore: AgentRepoStore;
|
|
200
|
+
/**
|
|
201
|
+
* Optional asset attachment integration. When set, the deploy flow
|
|
202
|
+
* fans out per-attachment packs after the deploy pack lands and
|
|
203
|
+
* inserts a `session_asset` row per attachment. When unset, only
|
|
204
|
+
* the deploy pack is sent — the single-pack path is preserved
|
|
205
|
+
* bit-for-bit.
|
|
206
|
+
*/
|
|
207
|
+
assetService?: AssetService;
|
|
208
|
+
/** DB handle used for `session_asset` manifest inserts. Required
|
|
209
|
+
* iff `assetService` is set. */
|
|
210
|
+
db?: DB["db"];
|
|
211
|
+
/**
|
|
212
|
+
* Tool-package registry configuration. Required iff any agent the
|
|
213
|
+
* service launches has non-empty `toolPackagePins`. When set, the
|
|
214
|
+
* service builds a per-agent `ClosureResolver` at launch time: the
|
|
215
|
+
* registry map combines (a) every `package-registry` asset visible
|
|
216
|
+
* to the agent's tenant via the INTR-178 walker — keyed by
|
|
217
|
+
* `asset.name` — and (b) the statically-configured HTTP registries
|
|
218
|
+
* in `httpRegistries`.
|
|
219
|
+
*
|
|
220
|
+
* **Name-collision policy.** When an asset and an HTTP registry
|
|
221
|
+
* both claim the same registry name, the asset wins. This mirrors
|
|
222
|
+
* the inner-shadows-outer rule the tenancy walker already applies
|
|
223
|
+
* to asset resolution and gives operators a single mental model:
|
|
224
|
+
* closer-scope shadows wider-scope. The rule is a contract this
|
|
225
|
+
* service guarantees, not an iteration-order accident — consumers
|
|
226
|
+
* may rely on it to override a wider-scope HTTP registry by
|
|
227
|
+
* publishing an asset at a closer tenancy.
|
|
228
|
+
*
|
|
229
|
+
* `defaultRegistry` names the entry the resolver consults for any
|
|
230
|
+
* package whose scope does not match `scopeRouting`. The name must
|
|
231
|
+
* resolve in the combined map for the given agent — if no asset and
|
|
232
|
+
* no HTTP entry carries that name, launch fails at the
|
|
233
|
+
* registry-resolution step.
|
|
234
|
+
*/
|
|
235
|
+
toolPackageRegistries?: {
|
|
236
|
+
/**
|
|
237
|
+
* Registry identifier → registry config. The key is the
|
|
238
|
+
* identifier `scopeRouting` entries and manifest `registry`
|
|
239
|
+
* references point at; the value carries url plus optional auth.
|
|
240
|
+
*/
|
|
241
|
+
readonly httpRegistries: ReadonlyMap<string, RegistryConfig>;
|
|
242
|
+
readonly defaultRegistry: string;
|
|
243
|
+
readonly scopeRouting?: readonly ScopeRoute[];
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* Translate the orchestrator's structural `DeployContent` (which types
|
|
248
|
+
* `toolPackageManifest` as `unknown`) back into the hub-sessions
|
|
249
|
+
* `DeployContent` shape. The orchestrator round-trips whatever the
|
|
250
|
+
* caller supplied, but the surface type widens `toolPackageManifest` to
|
|
251
|
+
* `unknown`; the validator narrows it back to the canonical shape
|
|
252
|
+
* `agentRepoStore.writeDeployTree` consumes.
|
|
253
|
+
*
|
|
254
|
+
* Exported so a test fixture that forwards orchestrator-shaped deploy
|
|
255
|
+
* content into `launchSession` narrows it the same validated way the
|
|
256
|
+
* production multi-step callback does, rather than casting `unknown`.
|
|
257
|
+
*/
|
|
258
|
+
export declare function bridgeOrchestratorDeployContent(content: OrchestratorDeployContent): DeployContent;
|
|
259
|
+
/** Fields the deploy frame carries onto `sendAgentDeploy`. */
|
|
260
|
+
type DeployFrameCommonArgs = {
|
|
261
|
+
sidecarRouter: SidecarRouter;
|
|
262
|
+
sidecarAllocationRouter?: SidecarAllocationRouter;
|
|
263
|
+
allocationTarget?: AllocatedSidecarTarget;
|
|
264
|
+
agentAddress: string;
|
|
265
|
+
config: HarnessConfig;
|
|
266
|
+
sources: Record<string, InferenceSource[]>;
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* For a code-sourced (npm) deploy the hub never holds the live
|
|
270
|
+
* `WorkflowDefinition` -- it lives only in the airlocked child. The gate/freeze
|
|
271
|
+
* layer hashed the inert projection; the deploy frame carries that hash and the
|
|
272
|
+
* source-ref pin, and the sidecar re-materializes and evaluates the pinned code
|
|
273
|
+
* from the pin, so no inline definition rides the frame. The content hash is
|
|
274
|
+
* owned by the gate, so this frame never recomputes it -- recomputing over a
|
|
275
|
+
* live wire lineage would diverge from the inert projection the child
|
|
276
|
+
* re-verifies against.
|
|
277
|
+
*/
|
|
278
|
+
export type SourceRefDeployFrameArgs = DeployFrameCommonArgs & {
|
|
279
|
+
lineage: "source-ref";
|
|
280
|
+
/**
|
|
281
|
+
* The gate-frozen wire hash of the approved projection -- stamped onto the
|
|
282
|
+
* frame VERBATIM. This arm does not recompute it: the freeze layer owns the
|
|
283
|
+
* content hash, and the child re-verifies its closure evaluation against this
|
|
284
|
+
* exact value.
|
|
285
|
+
*/
|
|
286
|
+
approvedWireHash: string;
|
|
287
|
+
/**
|
|
288
|
+
* The source-ref pin: where the definition's bytes come from plus the frozen
|
|
289
|
+
* dependency closure the hub resolved for it. The two co-travel, so they are
|
|
290
|
+
* one required object on this arm (see `SourceRefPin`) -- the sidecar
|
|
291
|
+
* re-materializes the exact tree from the pin at apply time.
|
|
292
|
+
*/
|
|
293
|
+
sourceRef: SourceRefPin;
|
|
294
|
+
/**
|
|
295
|
+
* Resolved credential material for the definition's credential bindings,
|
|
296
|
+
* delivered to the child on the frame. The hub resolves + decrypts here; the
|
|
297
|
+
* source-ref child decrypts nothing. The grant that AUTHORIZES a credential's
|
|
298
|
+
* use is minted per-run by run-grant materialization, not carried on this
|
|
299
|
+
* frame.
|
|
300
|
+
*/
|
|
301
|
+
credentials?: CredentialDelivery;
|
|
302
|
+
/**
|
|
303
|
+
* The projection's inline onTrigger section bodies, each already in inert wire
|
|
304
|
+
* form with its per-step inference sources pinned and its own wire hash --
|
|
305
|
+
* built by `deployCodeSourcedWorkflow` from the frozen projection. The sidecar
|
|
306
|
+
* stages each body's `sources.json` (and re-verify hash). Absent when the
|
|
307
|
+
* projection has no inline onTrigger body.
|
|
308
|
+
*/
|
|
309
|
+
referencedDefinitions?: readonly WorkflowProjectionWithSources[];
|
|
310
|
+
/**
|
|
311
|
+
* Source assets the pin's `kind:"asset"` closure entries read from, delivered
|
|
312
|
+
* inline on the frame so the sidecar checks them out into its durable
|
|
313
|
+
* per-deployment source store. Absent for a registry-sourced pin (its tarballs
|
|
314
|
+
* are fetched over HTTP).
|
|
315
|
+
*/
|
|
316
|
+
assets?: readonly WorkflowSourceAssetMount[];
|
|
317
|
+
};
|
|
318
|
+
export type SendMultiStepDeployFrameArgs = SourceRefDeployFrameArgs;
|
|
319
|
+
/**
|
|
320
|
+
* Emit the source-ref deploy frame onto `SidecarRouter.sendAgentDeploy`. The
|
|
321
|
+
* router accepts an optional `workflow` projection on the deploy frame; the
|
|
322
|
+
* sidecar's deploy router uses field presence to route the frame to the
|
|
323
|
+
* workflow deploy path, and returns the supervisor public key on the
|
|
324
|
+
* `agent.deploy.ack`.
|
|
325
|
+
*
|
|
326
|
+
* The gate/freeze layer already hashed the inert projection, so the frozen hash
|
|
327
|
+
* and the inert projection ride the frame verbatim -- this never recomputes the
|
|
328
|
+
* content hash. Recomputing over a live wire lineage would diverge from the
|
|
329
|
+
* inert projection the child re-verifies against.
|
|
330
|
+
*
|
|
331
|
+
* Exported so the co-located caller-site test can assert that the constructed
|
|
332
|
+
* closure reaches the wire surface via `sendAgentDeploy` with a `workflow`
|
|
333
|
+
* field structurally matching the `AgentDeployFrame.workflow` schema.
|
|
334
|
+
*/
|
|
335
|
+
export declare function sendMultiStepDeployFrame(args: SendMultiStepDeployFrameArgs): Promise<{
|
|
336
|
+
publicKey: string;
|
|
337
|
+
}>;
|
|
338
|
+
/**
|
|
339
|
+
* Arguments for `deployCodeSourcedWorkflow`. The `approved` bundle is the
|
|
340
|
+
* `installAndApproveWorkflowDefinition` output verbatim -- the frozen hash,
|
|
341
|
+
* inert projection, and closure travel together inside it so no caller can pair
|
|
342
|
+
* a hash with a mismatched projection or closure. The remaining fields are the
|
|
343
|
+
* operator/asset config the approve step never sees: the per-step inference
|
|
344
|
+
* `sources`, the deploy `config`, the target `agentAddress`, and the `source`
|
|
345
|
+
* ref that names where the definition's bytes are published.
|
|
346
|
+
*/
|
|
347
|
+
type DeployCodeSourcedCommonArgs = DeployFrameCommonArgs & {
|
|
348
|
+
approved: InstallAndApproveResult;
|
|
349
|
+
/**
|
|
350
|
+
* The hub DB handle, the definition's OWN tenant, the deployment's anchor run
|
|
351
|
+
* id, and the mail domain its run address lives under. REQUIRED: this function
|
|
352
|
+
* writes the deployment's anchor `workflow_run` row, and run-grant
|
|
353
|
+
* materialization keys off it. `tenantId` is the definition's own tenant
|
|
354
|
+
* (tenant-owned credential resolution walks up from it); do not pass a
|
|
355
|
+
* request/config tenant that may differ. `anchorRunId` is caller-supplied: the
|
|
356
|
+
* deployment mail address is frozen into the approved package bytes at
|
|
357
|
+
* authoring time, so the run id it derives from is fixed before this runs and
|
|
358
|
+
* cannot be minted here. `deploymentDomain` pairs with `anchorRunId` to
|
|
359
|
+
* re-derive the run address and assert it matches `agentAddress`, failing
|
|
360
|
+
* closed on an incoherent pair.
|
|
361
|
+
*/
|
|
362
|
+
db: DB["db"];
|
|
363
|
+
tenantId: string;
|
|
364
|
+
anchorRunId: string;
|
|
365
|
+
deploymentDomain: string;
|
|
366
|
+
/**
|
|
367
|
+
* Credential cipher, REQUIRED only when the definition carries credential
|
|
368
|
+
* bindings (resolution fails closed without it); omit for a binding-free
|
|
369
|
+
* deployment.
|
|
370
|
+
*/
|
|
371
|
+
credentialCipher?: CredentialCipher;
|
|
372
|
+
/**
|
|
373
|
+
* Present only for a prepared exclusive deploy: route the source-ref frame to
|
|
374
|
+
* this dedicated allocation instead of the shared router. `sidecarAllocationRouter`
|
|
375
|
+
* carries the allocation transport and is REQUIRED whenever `allocationTarget`
|
|
376
|
+
* is set. A shared deploy omits both.
|
|
377
|
+
*/
|
|
378
|
+
allocationTarget?: AllocatedSidecarTarget;
|
|
379
|
+
sidecarAllocationRouter?: SidecarAllocationRouter;
|
|
380
|
+
};
|
|
381
|
+
/** Deploy a definition published to an npm registry: the sidecar fetches its
|
|
382
|
+
* tarballs over HTTP, so no source asset is delivered. */
|
|
383
|
+
export type DeployCodeSourcedRegistryArgs = DeployCodeSourcedCommonArgs & {
|
|
384
|
+
source: WorkflowDefinitionRegistrySource;
|
|
385
|
+
};
|
|
386
|
+
/** Deploy a definition sourced from a hub `package-registry` asset: the caller
|
|
387
|
+
* mints `resolveAttachment` so this glue delivers the asset packs the sidecar
|
|
388
|
+
* checks out, without importing the asset service. */
|
|
389
|
+
export type DeployCodeSourcedAssetArgs = DeployCodeSourcedCommonArgs & {
|
|
390
|
+
source: WorkflowDefinitionAssetSource;
|
|
391
|
+
resolveAttachment: ResolveAssetAttachmentFn;
|
|
392
|
+
};
|
|
393
|
+
export type DeployCodeSourcedWorkflowArgs = DeployCodeSourcedRegistryArgs | DeployCodeSourcedAssetArgs;
|
|
394
|
+
/**
|
|
395
|
+
* The single public composition entrypoint for a SHARED code-sourced (npm)
|
|
396
|
+
* deploy: emit the source-ref frame, then INSERT the deployment's anchor
|
|
397
|
+
* `workflow_run` row -- the deployment's first-class record that owns its
|
|
398
|
+
* routing address and public key. Run-grant materialization keys off this row
|
|
399
|
+
* (address + live status), so WITHOUT it no per-run grants (tool, capability, OR
|
|
400
|
+
* credential) ever materialize for a source-ref deployment. Born "deployed"
|
|
401
|
+
* (live but pre-trigger): the first trigger's materialization flips it to
|
|
402
|
+
* "running" via `anchorWithPrincipal`'s guarded update, which a row born
|
|
403
|
+
* "running" would skip. Its `anchorRunId` equals its own id, so the anchor
|
|
404
|
+
* references itself. The deployer read grant is deferred to the production
|
|
405
|
+
* route, which carries the authenticated deployer principal; this stays a
|
|
406
|
+
* single insert with no grant row to pair atomically.
|
|
407
|
+
*
|
|
408
|
+
* The prepared exclusive path does NOT use this wrapper: its anchor row already
|
|
409
|
+
* exists from prepare time, so it wraps `emitSourceRefDeployFrame` with an
|
|
410
|
+
* UPDATE-under-allocation-lock instead of this INSERT.
|
|
411
|
+
*/
|
|
412
|
+
export declare function deployCodeSourcedWorkflow(args: DeployCodeSourcedWorkflowArgs): Promise<{
|
|
413
|
+
publicKey: string;
|
|
414
|
+
}>;
|
|
415
|
+
export declare function createSessionService(deps: SessionServiceDeps): SessionService & PreparedWorkflowDeployer;
|
|
416
|
+
export {};
|