@intx/hub-sessions 0.1.2 → 0.2.2
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 +84 -1
- package/dist/agent-repo.d.ts +89 -0
- package/dist/agent-repo.js +109 -0
- package/dist/agent-state-kind.d.ts +12 -0
- package/dist/agent-state-kind.js +185 -0
- package/dist/asset-service.d.ts +123 -0
- package/dist/asset-service.js +349 -0
- package/dist/available-skills-stanza.d.ts +21 -0
- package/dist/available-skills-stanza.js +32 -0
- package/dist/credential-push.d.ts +32 -0
- package/dist/credential-push.js +85 -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 +357 -0
- package/dist/hub-session-lookups.d.ts +17 -0
- package/dist/hub-session-lookups.js +204 -0
- package/dist/hub-session-orchestrator.d.ts +25 -0
- package/dist/hub-session-orchestrator.js +122 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +16 -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 +1692 -0
- package/dist/repo-store/subscribe-kind.d.ts +53 -0
- package/dist/repo-store/subscribe-kind.js +179 -0
- package/dist/repo-store/types.d.ts +483 -0
- package/dist/repo-store/types.js +42 -0
- package/dist/session-service.d.ts +235 -0
- package/dist/session-service.js +997 -0
- package/dist/skill-kind.d.ts +41 -0
- package/dist/skill-kind.js +288 -0
- package/dist/substrate.d.ts +8 -0
- package/dist/substrate.js +21 -0
- package/dist/workflow-kind.d.ts +21 -0
- package/dist/workflow-kind.js +263 -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 +326 -0
- package/dist/workflow-run-kind.js +2646 -0
- package/dist/workflow-run-reader.d.ts +47 -0
- package/dist/workflow-run-reader.js +157 -0
- package/dist/ws/index.d.ts +3 -0
- package/dist/ws/index.js +3 -0
- package/dist/ws/sidecar-events.d.ts +134 -0
- package/dist/ws/sidecar-events.js +70 -0
- package/dist/ws/sidecar-handler.d.ts +184 -0
- package/dist/ws/sidecar-handler.js +1603 -0
- package/dist/ws/sidecar-token-authenticator.d.ts +15 -0
- package/dist/ws/sidecar-token-authenticator.js +24 -0
- package/package.json +34 -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,235 @@
|
|
|
1
|
+
import { type DB } from "@intx/db";
|
|
2
|
+
import type { CryptoProvider, HarnessConfig, InferenceSource, MessageAttachment } from "@intx/types/runtime";
|
|
3
|
+
import { type RegistryConfig, type ScopeRoute } from "@intx/tool-packaging";
|
|
4
|
+
import { type ToolPackagePin } from "@intx/types/tool-packages";
|
|
5
|
+
import { type WorkflowDefinition } from "@intx/workflow/definition";
|
|
6
|
+
import { type DeployContent as OrchestratorDeployContent, type DeploySingleStepFn } from "@intx/workflow-deploy";
|
|
7
|
+
import type { AgentRepoStore, DeployContent } from "./agent-repo.js";
|
|
8
|
+
import { type AssetService } from "./asset-service.js";
|
|
9
|
+
import type { SidecarRouter } from "./ws/sidecar-handler.js";
|
|
10
|
+
export declare class SessionLaunchError extends Error {
|
|
11
|
+
/** Which phase failed: "write", "provision", "pack", or "start". */
|
|
12
|
+
readonly phase: string;
|
|
13
|
+
/** True if the sidecar has a provisioned agent that could not be cleaned up. */
|
|
14
|
+
readonly leakedAgent: boolean;
|
|
15
|
+
constructor(phase: string, cause: unknown, leakedAgent: boolean);
|
|
16
|
+
}
|
|
17
|
+
export type SessionService = {
|
|
18
|
+
/**
|
|
19
|
+
* Stage one step of a multi-step workflow deploy: bind a transient route
|
|
20
|
+
* for the step address, fire a no-spawn provision frame (init the step's
|
|
21
|
+
* agent-state repo and record the hub key), deliver the deploy + asset
|
|
22
|
+
* packs, and unbind the route -- no warm harness. The multi-step branch
|
|
23
|
+
* stages every step this way before firing the deployment-level workflow
|
|
24
|
+
* frame that spawns the supervised child; the child reads each staged step
|
|
25
|
+
* tree from disk and runs the step itself.
|
|
26
|
+
*/
|
|
27
|
+
stageWorkflowStep(params: {
|
|
28
|
+
agentAddress: string;
|
|
29
|
+
agentId: string;
|
|
30
|
+
instanceId: string;
|
|
31
|
+
config: HarnessConfig;
|
|
32
|
+
deployContent: DeployContent;
|
|
33
|
+
toolPackagePins?: readonly ToolPackagePin[];
|
|
34
|
+
}): 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
|
+
/**
|
|
89
|
+
* Undeploy an agent and wait for the sidecar to acknowledge.
|
|
90
|
+
*/
|
|
91
|
+
endSession(agentAddress: string, reason: string): Promise<void>;
|
|
92
|
+
};
|
|
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
|
+
export type DeployWorkflowDefinitionResult = {
|
|
130
|
+
/** Echoes the deployment id recorded on the projection row. */
|
|
131
|
+
deploymentId: string;
|
|
132
|
+
/** Deployment-level mail address the supervisor registers on the bus. */
|
|
133
|
+
deploymentAddress: string;
|
|
134
|
+
/** Supervisor principal public key from the sidecar's deploy ack. */
|
|
135
|
+
publicKey: string;
|
|
136
|
+
};
|
|
137
|
+
export type UserMessageParams = {
|
|
138
|
+
agentAddress: string;
|
|
139
|
+
from: string;
|
|
140
|
+
messageId: string;
|
|
141
|
+
date: Date;
|
|
142
|
+
content: string;
|
|
143
|
+
attachments?: MessageAttachment[];
|
|
144
|
+
inReplyTo?: string;
|
|
145
|
+
references?: string[];
|
|
146
|
+
sessionId: string;
|
|
147
|
+
tenantId: string;
|
|
148
|
+
cryptoProvider: CryptoProvider;
|
|
149
|
+
};
|
|
150
|
+
export type SessionServiceDeps = {
|
|
151
|
+
sidecarRouter: SidecarRouter;
|
|
152
|
+
agentRepoStore: AgentRepoStore;
|
|
153
|
+
/**
|
|
154
|
+
* Optional asset attachment integration. When set, the deploy flow
|
|
155
|
+
* fans out per-attachment packs after the deploy pack lands and
|
|
156
|
+
* inserts a `session_asset` row per attachment. When unset, only
|
|
157
|
+
* the deploy pack is sent — the single-pack path is preserved
|
|
158
|
+
* bit-for-bit.
|
|
159
|
+
*/
|
|
160
|
+
assetService?: AssetService;
|
|
161
|
+
/** DB handle used for `session_asset` manifest inserts. Required
|
|
162
|
+
* iff `assetService` is set. */
|
|
163
|
+
db?: DB["db"];
|
|
164
|
+
/**
|
|
165
|
+
* Tool-package registry configuration. Required iff any agent the
|
|
166
|
+
* service launches has non-empty `toolPackagePins`. When set, the
|
|
167
|
+
* service builds a per-agent `ClosureResolver` at launch time: the
|
|
168
|
+
* registry map combines (a) every `package-registry` asset visible
|
|
169
|
+
* to the agent's tenant via the INTR-178 walker — keyed by
|
|
170
|
+
* `asset.name` — and (b) the statically-configured HTTP registries
|
|
171
|
+
* in `httpRegistries`.
|
|
172
|
+
*
|
|
173
|
+
* **Name-collision policy.** When an asset and an HTTP registry
|
|
174
|
+
* both claim the same registry name, the asset wins. This mirrors
|
|
175
|
+
* the inner-shadows-outer rule the tenancy walker already applies
|
|
176
|
+
* to asset resolution and gives operators a single mental model:
|
|
177
|
+
* closer-scope shadows wider-scope. The rule is a contract this
|
|
178
|
+
* service guarantees, not an iteration-order accident — consumers
|
|
179
|
+
* may rely on it to override a wider-scope HTTP registry by
|
|
180
|
+
* publishing an asset at a closer tenancy.
|
|
181
|
+
*
|
|
182
|
+
* `defaultRegistry` names the entry the resolver consults for any
|
|
183
|
+
* package whose scope does not match `scopeRouting`. The name must
|
|
184
|
+
* resolve in the combined map for the given agent — if no asset and
|
|
185
|
+
* no HTTP entry carries that name, launch fails at the
|
|
186
|
+
* registry-resolution step.
|
|
187
|
+
*/
|
|
188
|
+
toolPackageRegistries?: {
|
|
189
|
+
/**
|
|
190
|
+
* Registry identifier → registry config. The key is the
|
|
191
|
+
* identifier `scopeRouting` entries and manifest `registry`
|
|
192
|
+
* references point at; the value carries url plus optional auth.
|
|
193
|
+
*/
|
|
194
|
+
readonly httpRegistries: ReadonlyMap<string, RegistryConfig>;
|
|
195
|
+
readonly defaultRegistry: string;
|
|
196
|
+
readonly scopeRouting?: readonly ScopeRoute[];
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* Translate the orchestrator's structural `DeployContent` (which types
|
|
201
|
+
* `toolPackageManifest` as `unknown`) back into the hub-sessions
|
|
202
|
+
* `DeployContent` shape. The orchestrator round-trips whatever the
|
|
203
|
+
* caller supplied, but the surface type widens `toolPackageManifest` to
|
|
204
|
+
* `unknown`; the validator narrows it back to the canonical shape
|
|
205
|
+
* `agentRepoStore.writeDeployTree` consumes.
|
|
206
|
+
*
|
|
207
|
+
* Exported so a test fixture that forwards orchestrator-shaped deploy
|
|
208
|
+
* content into `launchSession` narrows it the same validated way the
|
|
209
|
+
* production multi-step callback does, rather than casting `unknown`.
|
|
210
|
+
*/
|
|
211
|
+
export declare function bridgeOrchestratorDeployContent(content: OrchestratorDeployContent): DeployContent;
|
|
212
|
+
/**
|
|
213
|
+
* Wire the workflow-deploy orchestrator's `sendMultiStepDeploy`
|
|
214
|
+
* dependency against `SidecarRouter.sendAgentDeploy`. The router
|
|
215
|
+
* accepts an optional `workflow` projection on the deploy frame; the
|
|
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;
|
|
228
|
+
agentAddress: string;
|
|
229
|
+
config: HarnessConfig;
|
|
230
|
+
definition: WorkflowDefinition;
|
|
231
|
+
sources: Record<string, InferenceSource[]>;
|
|
232
|
+
}): Promise<{
|
|
233
|
+
publicKey: string;
|
|
234
|
+
}>;
|
|
235
|
+
export declare function createSessionService(deps: SessionServiceDeps): SessionService;
|