@intx/hub-sessions 0.2.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/README.md +3 -5
- package/dist/agent-repo.d.ts +9 -5
- package/dist/agent-repo.js +2 -2
- package/dist/agent-state-kind.js +4 -0
- package/dist/asset-service.d.ts +1 -20
- package/dist/asset-service.js +9 -91
- package/dist/committed-source-tree.d.ts +10 -0
- package/dist/committed-source-tree.js +35 -0
- package/dist/credential-push.d.ts +7 -6
- package/dist/credential-push.js +42 -18
- package/dist/event-collector-registry.d.ts +1 -1
- package/dist/event-collector-registry.js +4 -4
- package/dist/event-collector.d.ts +1 -1
- package/dist/event-collector.js +10 -2
- package/dist/hub-session-lookups.d.ts +125 -7
- package/dist/hub-session-lookups.js +539 -80
- package/dist/hub-session-orchestrator.js +14 -49
- package/dist/index.d.ts +17 -8
- package/dist/index.js +14 -6
- package/dist/repo-store/index.d.ts +1 -1
- 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/session-service.d.ts +277 -96
- package/dist/session-service.js +741 -547
- 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.js +4 -0
- package/dist/substrate.d.ts +3 -3
- package/dist/substrate.js +1 -1
- 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 +17 -1
- package/dist/workflow-kind.js +127 -80
- package/dist/workflow-probe-gate.d.ts +214 -0
- package/dist/workflow-probe-gate.js +207 -0
- package/dist/workflow-run-kind.d.ts +128 -14
- package/dist/workflow-run-kind.js +353 -83
- package/dist/workflow-run-reader.d.ts +1 -1
- package/dist/workflow-run-reader.js +3 -7
- 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 -3
- package/dist/ws/index.js +1 -1
- package/dist/ws/sidecar-events.d.ts +100 -12
- package/dist/ws/sidecar-events.js +2 -0
- package/dist/ws/sidecar-handler.d.ts +128 -7
- package/dist/ws/sidecar-handler.js +1069 -135
- package/dist/ws/sidecar-token-authenticator.d.ts +3 -1
- package/dist/ws/sidecar-token-authenticator.js +64 -7
- package/package.json +14 -13
- package/dist/available-skills-stanza.d.ts +0 -21
- package/dist/available-skills-stanza.js +0 -32
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DB } from "@intx/db";
|
|
2
|
+
import type { SidecarCredentialResolver } from "../sidecar-allocation/contracts.js";
|
|
2
3
|
import type { SidecarAuthenticator } from "./sidecar-handler.js";
|
|
3
4
|
export type CreateSidecarTokenAuthenticatorDeps = {
|
|
4
5
|
db: DB["db"];
|
|
@@ -12,4 +13,5 @@ export type CreateSidecarTokenAuthenticatorDeps = {
|
|
|
12
13
|
* `sidecarId` on the frame is ignored: identity is derived from the
|
|
13
14
|
* token alone.
|
|
14
15
|
*/
|
|
15
|
-
export declare function
|
|
16
|
+
export declare function createSidecarCredentialResolver({ db, }: CreateSidecarTokenAuthenticatorDeps): SidecarCredentialResolver;
|
|
17
|
+
export declare function createSidecarTokenAuthenticator(deps: CreateSidecarTokenAuthenticatorDeps): SidecarAuthenticator;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { eq } from "drizzle-orm";
|
|
1
|
+
import { and, eq, inArray } from "drizzle-orm";
|
|
2
2
|
import { sha256 } from "@intx/crypto";
|
|
3
|
-
import { sidecar } from "@intx/db/schema";
|
|
3
|
+
import { sidecar, sidecarAllocation, workflowRun } from "@intx/db/schema";
|
|
4
4
|
/**
|
|
5
5
|
* Builds an authenticator that verifies a sidecar's presented token
|
|
6
6
|
* against the per-sidecar hash stored on the `sidecar` table. The token
|
|
@@ -10,15 +10,72 @@ import { sidecar } from "@intx/db/schema";
|
|
|
10
10
|
* `sidecarId` on the frame is ignored: identity is derived from the
|
|
11
11
|
* token alone.
|
|
12
12
|
*/
|
|
13
|
-
export function
|
|
14
|
-
|
|
13
|
+
export function createSidecarCredentialResolver({ db, }) {
|
|
14
|
+
async function resolve(token) {
|
|
15
15
|
const tokenHash = await sha256(token);
|
|
16
16
|
const row = await db.query.sidecar.findFirst({
|
|
17
17
|
where: eq(sidecar.tokenHashSha256, tokenHash),
|
|
18
18
|
});
|
|
19
|
-
if (row === undefined)
|
|
19
|
+
if (row === undefined)
|
|
20
20
|
return null;
|
|
21
|
+
if (row.credentialScope === "shared") {
|
|
22
|
+
return { kind: "shared", sidecarId: row.id };
|
|
21
23
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
const allocation = await db.query.sidecarAllocation.findFirst({
|
|
25
|
+
where: eq(sidecarAllocation.sidecarId, row.id),
|
|
26
|
+
});
|
|
27
|
+
if (allocation === undefined)
|
|
28
|
+
return null;
|
|
29
|
+
if (allocation.status !== "provisioning" &&
|
|
30
|
+
allocation.status !== "allocated") {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const anchor = await db.query.workflowRun.findFirst({
|
|
34
|
+
columns: { address: true },
|
|
35
|
+
where: eq(workflowRun.id, allocation.anchorRunId),
|
|
36
|
+
});
|
|
37
|
+
if (anchor?.address === null || anchor?.address === undefined)
|
|
38
|
+
return null;
|
|
39
|
+
return {
|
|
40
|
+
kind: "allocated",
|
|
41
|
+
sidecarId: row.id,
|
|
42
|
+
allocationId: allocation.id,
|
|
43
|
+
tenantId: allocation.tenantId,
|
|
44
|
+
anchorRunId: allocation.anchorRunId,
|
|
45
|
+
workflowRunAddress: anchor.address,
|
|
46
|
+
generation: allocation.generation,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
async function isCurrent(identity, use) {
|
|
50
|
+
if (identity.kind === "shared") {
|
|
51
|
+
const allocation = await db.query.sidecarAllocation.findFirst({
|
|
52
|
+
columns: { id: true },
|
|
53
|
+
where: eq(sidecarAllocation.sidecarId, identity.sidecarId),
|
|
54
|
+
});
|
|
55
|
+
return allocation === undefined;
|
|
56
|
+
}
|
|
57
|
+
const statuses = use === "registration"
|
|
58
|
+
? ["provisioning", "allocated"]
|
|
59
|
+
: ["allocated"];
|
|
60
|
+
const allocation = await db.query.sidecarAllocation.findFirst({
|
|
61
|
+
where: and(eq(sidecarAllocation.id, identity.allocationId), eq(sidecarAllocation.sidecarId, identity.sidecarId), eq(sidecarAllocation.tenantId, identity.tenantId), eq(sidecarAllocation.anchorRunId, identity.anchorRunId), eq(sidecarAllocation.generation, identity.generation), inArray(sidecarAllocation.status, statuses)),
|
|
62
|
+
});
|
|
63
|
+
if (allocation === undefined)
|
|
64
|
+
return false;
|
|
65
|
+
if (use === "registration")
|
|
66
|
+
return true;
|
|
67
|
+
if (allocation.ensureAcceptedGeneration !== identity.generation) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
const anchor = await db.query.workflowRun.findFirst({
|
|
71
|
+
columns: { address: true },
|
|
72
|
+
where: eq(workflowRun.id, identity.anchorRunId),
|
|
73
|
+
});
|
|
74
|
+
return anchor?.address === identity.workflowRunAddress;
|
|
75
|
+
}
|
|
76
|
+
return { resolve, isCurrent };
|
|
77
|
+
}
|
|
78
|
+
export function createSidecarTokenAuthenticator(deps) {
|
|
79
|
+
const resolver = createSidecarCredentialResolver(deps);
|
|
80
|
+
return async ({ token }) => resolver.resolve(token);
|
|
24
81
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intx/hub-sessions",
|
|
3
|
-
"
|
|
3
|
+
"description": "Session-orchestration substrate for the hub: sidecar router, session, and asset services",
|
|
4
|
+
"version": "0.3.0",
|
|
4
5
|
"license": "LGPL-2.1-only",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"exports": {
|
|
@@ -16,18 +17,18 @@
|
|
|
16
17
|
}
|
|
17
18
|
},
|
|
18
19
|
"dependencies": {
|
|
19
|
-
"@intx/agent": "0.
|
|
20
|
-
"@intx/crypto": "0.
|
|
21
|
-
"@intx/db": "0.
|
|
22
|
-
"@intx/hub-common": "0.
|
|
23
|
-
"@intx/log": "0.
|
|
24
|
-
"@intx/mime": "0.
|
|
25
|
-
"@intx/pack-transport": "0.
|
|
26
|
-
"@intx/storage-isogit": "0.
|
|
27
|
-
"@intx/tool-packaging": "0.
|
|
28
|
-
"@intx/types": "0.
|
|
29
|
-
"@intx/workflow": "0.
|
|
30
|
-
"@intx/workflow-deploy": "0.
|
|
20
|
+
"@intx/agent": "0.3.0",
|
|
21
|
+
"@intx/crypto": "0.3.0",
|
|
22
|
+
"@intx/db": "0.3.0",
|
|
23
|
+
"@intx/hub-common": "0.3.0",
|
|
24
|
+
"@intx/log": "0.3.0",
|
|
25
|
+
"@intx/mime": "0.3.0",
|
|
26
|
+
"@intx/pack-transport": "0.3.0",
|
|
27
|
+
"@intx/storage-isogit": "0.3.0",
|
|
28
|
+
"@intx/tool-packaging": "0.3.0",
|
|
29
|
+
"@intx/types": "0.3.0",
|
|
30
|
+
"@intx/workflow": "0.3.0",
|
|
31
|
+
"@intx/workflow-deploy": "0.3.0",
|
|
31
32
|
"arktype": "^2.1.29",
|
|
32
33
|
"drizzle-orm": "^0.45.1",
|
|
33
34
|
"isomorphic-git": "^1.27.2",
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export type AvailableSkillEntry = {
|
|
2
|
-
/** Qualified skill identifier in the form `<asset.name>/<skill-name>`. */
|
|
3
|
-
qualifiedName: string;
|
|
4
|
-
/** SKILL.md frontmatter description, verbatim. */
|
|
5
|
-
description: string;
|
|
6
|
-
/** Workspace-relative path the agent's `read_file` should target,
|
|
7
|
-
* shaped like `workspace/<mountPath>/<skill-name>/`. */
|
|
8
|
-
workspacePath: string;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Render the `<available_skills>` stanza appended to the agent's
|
|
12
|
-
* system prompt. Returns the empty string when `entries` is empty —
|
|
13
|
-
* an empty `<available_skills></available_skills>` wrapper would be
|
|
14
|
-
* misleading noise for agents with no skills attached.
|
|
15
|
-
*
|
|
16
|
-
* Values are XML-escaped at the boundary. The skill kind handler
|
|
17
|
-
* already rejects descriptions containing literal `<` or `>` so the
|
|
18
|
-
* `&` escape is the practical case in production; the others are
|
|
19
|
-
* defensive.
|
|
20
|
-
*/
|
|
21
|
-
export declare function buildAvailableSkillsStanza(entries: AvailableSkillEntry[]): string;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Render the `<available_skills>` stanza appended to the agent's
|
|
3
|
-
* system prompt. Returns the empty string when `entries` is empty —
|
|
4
|
-
* an empty `<available_skills></available_skills>` wrapper would be
|
|
5
|
-
* misleading noise for agents with no skills attached.
|
|
6
|
-
*
|
|
7
|
-
* Values are XML-escaped at the boundary. The skill kind handler
|
|
8
|
-
* already rejects descriptions containing literal `<` or `>` so the
|
|
9
|
-
* `&` escape is the practical case in production; the others are
|
|
10
|
-
* defensive.
|
|
11
|
-
*/
|
|
12
|
-
export function buildAvailableSkillsStanza(entries) {
|
|
13
|
-
if (entries.length === 0) {
|
|
14
|
-
return "";
|
|
15
|
-
}
|
|
16
|
-
const lines = ["<available_skills>"];
|
|
17
|
-
for (const entry of entries) {
|
|
18
|
-
lines.push(" <skill>");
|
|
19
|
-
lines.push(` <name>${escapeXml(entry.qualifiedName)}</name>`);
|
|
20
|
-
lines.push(` <description>${escapeXml(entry.description)}</description>`);
|
|
21
|
-
lines.push(` <path>${escapeXml(entry.workspacePath)}</path>`);
|
|
22
|
-
lines.push(" </skill>");
|
|
23
|
-
}
|
|
24
|
-
lines.push("</available_skills>");
|
|
25
|
-
return lines.join("\n");
|
|
26
|
-
}
|
|
27
|
-
function escapeXml(value) {
|
|
28
|
-
return value
|
|
29
|
-
.replaceAll("&", "&")
|
|
30
|
-
.replaceAll("<", "<")
|
|
31
|
-
.replaceAll(">", ">");
|
|
32
|
-
}
|