@xemahq/agent-session-runtime 0.2.0 → 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/dist/lib/composer.js +4 -4
- package/dist/lib/composition-workspace-manifest.d.ts +4 -2
- package/dist/lib/composition-workspace-manifest.d.ts.map +1 -1
- package/dist/lib/composition-workspace-manifest.js +25 -1
- package/dist/lib/composition-workspace-manifest.js.map +1 -1
- package/package.json +3 -3
- package/src/lib/composer.ts +4 -4
- package/src/lib/composition-workspace-manifest.ts +97 -3
package/dist/lib/composer.js
CHANGED
|
@@ -43,7 +43,7 @@ class DefaultWorkspaceImageComposer {
|
|
|
43
43
|
orgId: req.orgId,
|
|
44
44
|
projectId: req.projectId,
|
|
45
45
|
agentSlug: req.manifest.agent.slug,
|
|
46
|
-
|
|
46
|
+
stageKey: req.manifest.agent.stageKey,
|
|
47
47
|
role,
|
|
48
48
|
...(deliverableSpecRef === undefined ? {} : { deliverableSpecRef }),
|
|
49
49
|
...(req.workflowRun?.runId === undefined ? {} : { runId: req.workflowRun.runId }),
|
|
@@ -101,7 +101,7 @@ class DefaultWorkspaceImageComposer {
|
|
|
101
101
|
kind: 'agent-definition',
|
|
102
102
|
orgId: req.orgId,
|
|
103
103
|
agentSlug: req.manifest.agent.slug,
|
|
104
|
-
|
|
104
|
+
stageKey: req.manifest.agent.stageKey,
|
|
105
105
|
agentMode: 'primary',
|
|
106
106
|
},
|
|
107
107
|
}));
|
|
@@ -117,7 +117,7 @@ class DefaultWorkspaceImageComposer {
|
|
|
117
117
|
kind: 'agent-definition',
|
|
118
118
|
orgId: req.orgId,
|
|
119
119
|
agentSlug: sub,
|
|
120
|
-
|
|
120
|
+
stageKey: req.manifest.agent.stageKey,
|
|
121
121
|
agentMode: 'subagent',
|
|
122
122
|
},
|
|
123
123
|
}));
|
|
@@ -160,7 +160,7 @@ class DefaultWorkspaceImageComposer {
|
|
|
160
160
|
orgId: req.orgId,
|
|
161
161
|
sectionKey,
|
|
162
162
|
agentSlug: req.manifest.agent.slug,
|
|
163
|
-
|
|
163
|
+
stageKey: req.manifest.agent.stageKey,
|
|
164
164
|
},
|
|
165
165
|
}));
|
|
166
166
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ModelRef } from '@xemahq/kernel-contracts/workflow';
|
|
1
|
+
import { type CompiledManifestCredential, type CompiledManifestPermissions, type ModelRef } from '@xemahq/kernel-contracts/workflow';
|
|
2
2
|
import type { PermissionMap } from '@xemahq/kernel-contracts/agent-permission';
|
|
3
3
|
import { type CompiledWorkspaceManifest } from '@xemahq/dsl/workspace-manifest';
|
|
4
4
|
export type { CompiledWorkspaceManifest };
|
|
@@ -6,7 +6,7 @@ export declare class CompositionMountLayoutError extends Error {
|
|
|
6
6
|
constructor(compositionRef: string, detail: string);
|
|
7
7
|
}
|
|
8
8
|
export interface CompositionAgentRunConfigInput {
|
|
9
|
-
readonly
|
|
9
|
+
readonly stage: string;
|
|
10
10
|
readonly role: string;
|
|
11
11
|
readonly deliverableSpecRef?: string;
|
|
12
12
|
}
|
|
@@ -38,6 +38,8 @@ export interface CompositionManifestSource {
|
|
|
38
38
|
readonly subAgentBindings: readonly CompositionSubAgentBindingInput[];
|
|
39
39
|
readonly mountLayout: CompositionMountLayoutInput | undefined;
|
|
40
40
|
readonly outputSurface?: CompositionOutputSurfaceInput;
|
|
41
|
+
readonly credentials?: readonly CompiledManifestCredential[];
|
|
42
|
+
readonly permissions?: CompiledManifestPermissions;
|
|
41
43
|
}
|
|
42
44
|
export interface CompositionManifestImplicitInputs {
|
|
43
45
|
readonly orgId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composition-workspace-manifest.d.ts","sourceRoot":"","sources":["../../src/lib/composition-workspace-manifest.ts"],"names":[],"mappings":"AA6BA,OAAO,EAIL,KAAK,QAAQ,EACd,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2C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C,CAChD,MAAM,EAAE,yBAAyB,EACjC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EAC9C,cAAc,EAAE,iCAAiC,GAChD,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA6CnC"}
|
|
@@ -36,11 +36,13 @@ function compileCompositionWorkspaceManifest(source, bindInputs) {
|
|
|
36
36
|
: {}),
|
|
37
37
|
}));
|
|
38
38
|
const outputSurface = projectOutputSurface(source.outputSurface);
|
|
39
|
+
const credentials = projectCredentials(source.credentials);
|
|
40
|
+
const permissions = projectPermissions(source.permissions);
|
|
39
41
|
const spec = {
|
|
40
42
|
mounts: mountLayout.mounts,
|
|
41
43
|
agent: {
|
|
42
44
|
slug: source.primaryAgentSlug,
|
|
43
|
-
|
|
45
|
+
stage: mountLayout.agentRunConfig.stage,
|
|
44
46
|
role: mountLayout.agentRunConfig.role,
|
|
45
47
|
...(mountLayout.agentRunConfig.deliverableSpecRef !== undefined
|
|
46
48
|
? { deliverableSpecRef: mountLayout.agentRunConfig.deliverableSpecRef }
|
|
@@ -58,6 +60,8 @@ function compileCompositionWorkspaceManifest(source, bindInputs) {
|
|
|
58
60
|
}
|
|
59
61
|
: {}),
|
|
60
62
|
...(outputSurface === undefined ? {} : { outputSurface }),
|
|
63
|
+
...(credentials === undefined ? {} : { credentials }),
|
|
64
|
+
...(permissions === undefined ? {} : { permissions }),
|
|
61
65
|
};
|
|
62
66
|
const envelope = {
|
|
63
67
|
apiVersion: 'xema.dev/workspace/v1',
|
|
@@ -94,6 +98,26 @@ function projectOutputSurface(surface) {
|
|
|
94
98
|
: { defaultDocument: surface.defaultDocument }),
|
|
95
99
|
};
|
|
96
100
|
}
|
|
101
|
+
function projectCredentials(credentials) {
|
|
102
|
+
if (credentials === undefined)
|
|
103
|
+
return undefined;
|
|
104
|
+
return credentials.map((credential) => ({
|
|
105
|
+
name: credential.name,
|
|
106
|
+
kind: credential.kind,
|
|
107
|
+
sourceRef: credential.sourceRef,
|
|
108
|
+
required: credential.required,
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
111
|
+
function projectPermissions(permissions) {
|
|
112
|
+
if (permissions === undefined)
|
|
113
|
+
return undefined;
|
|
114
|
+
return {
|
|
115
|
+
tools: {
|
|
116
|
+
allow: permissions.tools.allow,
|
|
117
|
+
deny: permissions.tools.deny,
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
97
121
|
function buildCompositionManifestBindInputs(source, explicitInputs, implicitInputs) {
|
|
98
122
|
const declared = new Set(Object.keys(source.mountLayout?.inputs ?? {}));
|
|
99
123
|
if (declared.size === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composition-workspace-manifest.js","sourceRoot":"","sources":["../../src/lib/composition-workspace-manifest.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"composition-workspace-manifest.js","sourceRoot":"","sources":["../../src/lib/composition-workspace-manifest.ts"],"names":[],"mappings":";;;AAwPA,kFAyGC;AA0GD,gFAiDC;AA/dD,gEAO2C;AAE3C,uEAYwC;AAcxC,MAAa,2BAA4B,SAAQ,KAAK;IACpD,YAAY,cAAsB,EAAE,MAAc;QAChD,KAAK,CACH,gEAAgE;YAC9D,IAAI,cAAc,MAAM,MAAM,EAAE,CACnC,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC;IAC5C,CAAC;CACF;AARD,kEAQC;AAgLD,SAAgB,mCAAmC,CACjD,MAAiC,EACjC,UAA6C;IAE7C,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IACvC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,2BAA2B,CACnC,MAAM,CAAC,cAAc,EACrB,kEAAkE;YAChE,sEAAsE;YACtE,sEAAsE;YACtE,0BAA0B,CAC7B,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,mBA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AiE;YAC/D,mDAAmD,CACtD,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC;AAQD,SAAS,wBAAwB,CAC/B,cAAsB,EACtB,GAAW,EACX,KAAc;IAEd,IACE,KAAK,KAAK,IAAI;QACd,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,SAAS;QAC1B,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EACrB,CAAC;QACD,MAAM,IAAI,2BAA2B,CACnC,cAAc,EACd,mBAAmB,GAAG,wBAAwB;YAC5C,6CAA6C,OAAO,KAAK,EAAE,CAC9D,CAAC;IACJ,CAAC;IACD,IACE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACpB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,EAClD,CAAC;QACD,MAAM,IAAI,2BAA2B,CACnC,cAAc,EACd,mBAAmB,GAAG,gDAAgD,CACvE,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xemahq/agent-session-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"typescript": "5.9.3"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@xemahq/dsl": "^0.
|
|
41
|
-
"@xemahq/kernel-contracts": "^0.
|
|
40
|
+
"@xemahq/dsl": "^0.2.0",
|
|
41
|
+
"@xemahq/kernel-contracts": "^0.4.0"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"clean": "rm -rf dist",
|
package/src/lib/composer.ts
CHANGED
|
@@ -203,7 +203,7 @@ export class DefaultWorkspaceImageComposer implements WorkspaceImageComposer {
|
|
|
203
203
|
orgId: req.orgId,
|
|
204
204
|
projectId: req.projectId,
|
|
205
205
|
agentSlug: req.manifest.agent.slug,
|
|
206
|
-
|
|
206
|
+
stageKey: req.manifest.agent.stageKey,
|
|
207
207
|
role,
|
|
208
208
|
...(deliverableSpecRef === undefined ? {} : { deliverableSpecRef }),
|
|
209
209
|
...(req.workflowRun?.runId === undefined ? {} : { runId: req.workflowRun.runId }),
|
|
@@ -280,7 +280,7 @@ export class DefaultWorkspaceImageComposer implements WorkspaceImageComposer {
|
|
|
280
280
|
kind: 'agent-definition',
|
|
281
281
|
orgId: req.orgId,
|
|
282
282
|
agentSlug: req.manifest.agent.slug,
|
|
283
|
-
|
|
283
|
+
stageKey: req.manifest.agent.stageKey,
|
|
284
284
|
agentMode: 'primary',
|
|
285
285
|
},
|
|
286
286
|
}),
|
|
@@ -297,7 +297,7 @@ export class DefaultWorkspaceImageComposer implements WorkspaceImageComposer {
|
|
|
297
297
|
kind: 'agent-definition',
|
|
298
298
|
orgId: req.orgId,
|
|
299
299
|
agentSlug: sub,
|
|
300
|
-
|
|
300
|
+
stageKey: req.manifest.agent.stageKey,
|
|
301
301
|
agentMode: 'subagent',
|
|
302
302
|
},
|
|
303
303
|
}),
|
|
@@ -366,7 +366,7 @@ export class DefaultWorkspaceImageComposer implements WorkspaceImageComposer {
|
|
|
366
366
|
orgId: req.orgId,
|
|
367
367
|
sectionKey,
|
|
368
368
|
agentSlug: req.manifest.agent.slug,
|
|
369
|
-
|
|
369
|
+
stageKey: req.manifest.agent.stageKey,
|
|
370
370
|
},
|
|
371
371
|
}),
|
|
372
372
|
);
|
|
@@ -31,15 +31,19 @@ import {
|
|
|
31
31
|
ManifestSurface,
|
|
32
32
|
OutputSurfaceKind,
|
|
33
33
|
type AgentRunRole,
|
|
34
|
+
type CompiledManifestCredential,
|
|
35
|
+
type CompiledManifestPermissions,
|
|
34
36
|
type ModelRef,
|
|
35
37
|
} from '@xemahq/kernel-contracts/workflow';
|
|
36
38
|
import type { PermissionMap } from '@xemahq/kernel-contracts/agent-permission';
|
|
37
39
|
import {
|
|
38
40
|
compileManifest,
|
|
39
41
|
type CompiledWorkspaceManifest,
|
|
42
|
+
type ManifestCredential,
|
|
40
43
|
type ManifestInputDeclaration,
|
|
41
44
|
type ManifestMountsBlock,
|
|
42
45
|
type ManifestOutputSurface,
|
|
46
|
+
type ManifestPermissions,
|
|
43
47
|
type ManifestSeedFile,
|
|
44
48
|
type ManifestSubAgent,
|
|
45
49
|
type WorkspaceManifest as DslWorkspaceManifest,
|
|
@@ -74,8 +78,8 @@ export class CompositionMountLayoutError extends Error {
|
|
|
74
78
|
* importing the generated client.
|
|
75
79
|
*/
|
|
76
80
|
export interface CompositionAgentRunConfigInput {
|
|
77
|
-
/**
|
|
78
|
-
readonly
|
|
81
|
+
/** Stage key. */
|
|
82
|
+
readonly stage: string;
|
|
79
83
|
/** Canonical `AgentRunRole` — drives renderer + system-overlay framing. */
|
|
80
84
|
readonly role: string;
|
|
81
85
|
/**
|
|
@@ -175,6 +179,32 @@ export interface CompositionManifestSource {
|
|
|
175
179
|
* `{ kind: 'none' }` default.
|
|
176
180
|
*/
|
|
177
181
|
readonly outputSurface?: CompositionOutputSurfaceInput;
|
|
182
|
+
/**
|
|
183
|
+
* The composition's `workspace.credentials` block. Threaded into the
|
|
184
|
+
* reconstructed manifest's `spec.credentials` so the compiled manifest's
|
|
185
|
+
* `credentials` matches the source-of-truth — the EnvironmentResolver
|
|
186
|
+
* reads the same `{name, kind, sourceRef, required}` entries the
|
|
187
|
+
* authored composition declared (BUG-1 carry-through: authored
|
|
188
|
+
* `spec.credentials` were silently dropped on reconstruction). Carried
|
|
189
|
+
* as the kernel `CompiledManifestCredential[]` because that is the shape
|
|
190
|
+
* `composition.workspace.credentials` holds (the seeder projects the
|
|
191
|
+
* authored entries through the manifest compiler). `undefined` when the
|
|
192
|
+
* composition declared none — the DSL compile then yields `[]`.
|
|
193
|
+
*/
|
|
194
|
+
readonly credentials?: readonly CompiledManifestCredential[];
|
|
195
|
+
/**
|
|
196
|
+
* The composition's `workspace.permissions` block. Threaded into the
|
|
197
|
+
* reconstructed manifest's `spec.permissions` so the compiled manifest's
|
|
198
|
+
* `permissions` matches the source-of-truth — the EnvironmentResolver
|
|
199
|
+
* reads the same `{tools: {allow, deny}}` the authored composition
|
|
200
|
+
* declared (BUG-1 carry-through: authored `spec.permissions` were
|
|
201
|
+
* silently dropped on reconstruction). Carried as the kernel
|
|
202
|
+
* `CompiledManifestPermissions` because that is the shape
|
|
203
|
+
* `composition.workspace.permissions` holds. `undefined` when the
|
|
204
|
+
* composition declared none — the DSL compile then yields
|
|
205
|
+
* `{ tools: { allow: [], deny: [] } }`.
|
|
206
|
+
*/
|
|
207
|
+
readonly permissions?: CompiledManifestPermissions;
|
|
178
208
|
}
|
|
179
209
|
|
|
180
210
|
/**
|
|
@@ -265,11 +295,13 @@ export function compileCompositionWorkspaceManifest(
|
|
|
265
295
|
// `WorkspaceManifestSchema`, so the casts here are checked downstream,
|
|
266
296
|
// not silently trusted.
|
|
267
297
|
const outputSurface = projectOutputSurface(source.outputSurface);
|
|
298
|
+
const credentials = projectCredentials(source.credentials);
|
|
299
|
+
const permissions = projectPermissions(source.permissions);
|
|
268
300
|
const spec: WorkspaceManifestSpec = {
|
|
269
301
|
mounts: mountLayout.mounts as unknown as ManifestMountsBlock,
|
|
270
302
|
agent: {
|
|
271
303
|
slug: source.primaryAgentSlug,
|
|
272
|
-
|
|
304
|
+
stage: mountLayout.agentRunConfig.stage,
|
|
273
305
|
role: mountLayout.agentRunConfig.role as AgentRunRole,
|
|
274
306
|
...(mountLayout.agentRunConfig.deliverableSpecRef !== undefined
|
|
275
307
|
? { deliverableSpecRef: mountLayout.agentRunConfig.deliverableSpecRef }
|
|
@@ -291,6 +323,8 @@ export function compileCompositionWorkspaceManifest(
|
|
|
291
323
|
}
|
|
292
324
|
: {}),
|
|
293
325
|
...(outputSurface === undefined ? {} : { outputSurface }),
|
|
326
|
+
...(credentials === undefined ? {} : { credentials }),
|
|
327
|
+
...(permissions === undefined ? {} : { permissions }),
|
|
294
328
|
};
|
|
295
329
|
|
|
296
330
|
const envelope: DslWorkspaceManifest = {
|
|
@@ -350,6 +384,66 @@ function projectOutputSurface(
|
|
|
350
384
|
};
|
|
351
385
|
}
|
|
352
386
|
|
|
387
|
+
/**
|
|
388
|
+
* Project the composition's `workspace.credentials` block (carried on the
|
|
389
|
+
* runtime-agnostic `CompositionManifestSource` as the kernel
|
|
390
|
+
* `CompiledManifestCredential[]`) into the manifest DSL's authored
|
|
391
|
+
* `ManifestCredential[]` shape so the reconstructed envelope's
|
|
392
|
+
* `spec.credentials` carries the same entries as the source.
|
|
393
|
+
*
|
|
394
|
+
* The compiled shape is a structural superset of the authored shape
|
|
395
|
+
* (`{name, kind, sourceRef}` plus a now-required `required` boolean), so the
|
|
396
|
+
* projection is a 1:1 field copy — `compileManifest`'s Zod schema below
|
|
397
|
+
* re-validates each entry and re-defaults `required` idempotently. The map
|
|
398
|
+
* is explicit (not a pass-through cast) so a malformed entry fails fast at
|
|
399
|
+
* the manifest compile boundary, mirroring {@link projectOutputSurface}.
|
|
400
|
+
*
|
|
401
|
+
* Returns `undefined` when the composition declared no credentials — the DSL
|
|
402
|
+
* `compileManifest` then defaults the compiled `credentials` to `[]`.
|
|
403
|
+
*/
|
|
404
|
+
function projectCredentials(
|
|
405
|
+
credentials: readonly CompiledManifestCredential[] | undefined,
|
|
406
|
+
): readonly ManifestCredential[] | undefined {
|
|
407
|
+
if (credentials === undefined) return undefined;
|
|
408
|
+
return credentials.map((credential) => ({
|
|
409
|
+
name: credential.name,
|
|
410
|
+
kind: credential.kind,
|
|
411
|
+
sourceRef: credential.sourceRef,
|
|
412
|
+
required: credential.required,
|
|
413
|
+
}));
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Project the composition's `workspace.permissions` block (carried on the
|
|
418
|
+
* runtime-agnostic `CompositionManifestSource` as the kernel
|
|
419
|
+
* `CompiledManifestPermissions`) into the manifest DSL's authored
|
|
420
|
+
* `ManifestPermissions` shape so the reconstructed envelope's
|
|
421
|
+
* `spec.permissions` carries the same tool allow/deny lists as the source.
|
|
422
|
+
*
|
|
423
|
+
* The compiled shape is a structural superset of the authored shape (the
|
|
424
|
+
* compiled `tools.allow` / `tools.deny` are always present; the authored
|
|
425
|
+
* ones are optional), so the projection is a 1:1 field copy —
|
|
426
|
+
* `compileManifest`'s Zod schema below re-validates and re-defaults the
|
|
427
|
+
* lists idempotently. Explicit (not a pass-through cast) so a malformed
|
|
428
|
+
* block fails fast at the manifest compile boundary, mirroring
|
|
429
|
+
* {@link projectOutputSurface}.
|
|
430
|
+
*
|
|
431
|
+
* Returns `undefined` when the composition declared no permissions — the DSL
|
|
432
|
+
* `compileManifest` then defaults the compiled `permissions` to
|
|
433
|
+
* `{ tools: { allow: [], deny: [] } }`.
|
|
434
|
+
*/
|
|
435
|
+
function projectPermissions(
|
|
436
|
+
permissions: CompiledManifestPermissions | undefined,
|
|
437
|
+
): ManifestPermissions | undefined {
|
|
438
|
+
if (permissions === undefined) return undefined;
|
|
439
|
+
return {
|
|
440
|
+
tools: {
|
|
441
|
+
allow: permissions.tools.allow,
|
|
442
|
+
deny: permissions.tools.deny,
|
|
443
|
+
},
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
|
|
353
447
|
/**
|
|
354
448
|
* Build the manifest bind-input bag from the caller's explicit input bag
|
|
355
449
|
* and the implicit inputs, validated against the composition's declared
|