@xemahq/agent-session-runtime 0.6.6 → 0.6.7

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 CHANGED
@@ -1,175 +1,176 @@
1
- Xema Business Source License 1.1
2
-
3
- License text copyright (c) 2020 MariaDB Corporation Ab, All Rights Reserved.
4
- "Business Source License" is a trademark of MariaDB Corporation Ab.
5
-
6
- -----------------------------------------------------------------------------
7
-
8
- Parameters
9
-
10
- Licensor: Neuralchowder Inc.
11
-
12
- Licensed Work: Xema. The Licensed Work is (c) 2026 Neuralchowder Inc..
13
-
14
- The Licensed Work includes, without limitation, Xema Core, Xema Runtime,
15
- Xema Kernel, Xema control plane, Xema application runtime, Xema biome
16
- runtime, Xema biome registry, Xema store services, Xema orchestration
17
- services, Xema agents, Xema skills, Xema memory services, Xema APIs, Xema
18
- user interfaces, Xema command-line tools, Xema deployment artifacts, Xema
19
- templates, Xema specifications, Xema schemas, Xema manifests, Xema
20
- documentation, Xema examples, and all source code, object code, binaries,
21
- packages, modules, configuration files, manifests, schemas, examples,
22
- templates, documentation, and derivative works included in or distributed
23
- as part of the Xema software project.
24
-
25
- The Licensed Work does not include any third-party software, libraries,
26
- dependencies, packages, assets, or components that are distributed with the
27
- Licensed Work but are governed by their own separate license terms. Such
28
- third-party materials remain subject to their respective licenses.
29
-
30
- A specific file, package, component, or directory may state that it is
31
- governed by a different license. In that case, that specific file, package,
32
- component, or directory is governed by the license expressly stated therein.
33
-
34
- Additional Use Grant:
35
-
36
- You may make production use of the Licensed Work, provided that your use
37
- does not include offering, providing, making available, distributing,
38
- hosting, managing, embedding, reselling, white-labeling, sublicensing,
39
- commercializing, or otherwise making the Licensed Work, or any modified
40
- version or derivative work of the Licensed Work, available to Third Parties
41
- as part of a Competitive Offering.
42
-
43
- The following definitions and clarifications form part of, and govern
44
- the interpretation of, the Additional Use Grant set out above.
45
-
46
- 1. "Production Use" means any use of the Licensed Work other than for
47
- development, testing, evaluation, demonstration, experimentation,
48
- benchmarking, or other non-production purposes.
49
-
50
- 2. "Affiliate" means any entity that, directly or indirectly,
51
- controls, is controlled by, or is under common control with you,
52
- where "control" means ownership of more than fifty percent (50%) of
53
- the voting interests of the entity, or the power to direct its
54
- management.
55
-
56
- 3. "Third Party" means any natural person or legal entity other than
57
- you and your Affiliates.
58
-
59
- 4. "Competitive Offering" means any product or service, made available
60
- to one or more Third Parties for a fee or other consideration
61
- (including without limitation on a paid, subscription,
62
- advertising-supported, hosted, or managed-service basis), that is
63
- offered or marketed as, or that competes with, a software platform,
64
- runtime, orchestration system, agent or automation system,
65
- extension or distribution marketplace, or other software system
66
- that provides, in substantial part, the same or substantially
67
- similar capabilities as those provided by the Licensed Work. A
68
- product or service is a Competitive Offering whether the Licensed
69
- Work is provided in whole or in part, alone or bundled with other
70
- software, and whether modified or unmodified.
71
-
72
- 5. Providing, hosting, or managing the Licensed Work for a Third Party,
73
- or otherwise making the Licensed Work available to a Third Party as
74
- a hosted or managed service such that the Third Party obtains the
75
- principal value or functionality of the Licensed Work, is a
76
- Competitive Offering and is not permitted by the Additional Use
77
- Grant.
78
-
79
- 6. Subject to the foregoing, the Additional Use Grant permits you to
80
- make Production Use of the Licensed Work for your own internal
81
- business purposes and to build, operate, and provide your own
82
- products and services to Third Parties, provided that the Licensed
83
- Work itself (whether modified or unmodified) is not the product or
84
- service, and is not a Competitive Offering, made available to those
85
- Third Parties.
86
-
87
- 7. You may modify the Licensed Work and create derivative works for
88
- any purpose permitted by this License. Any Production Use of such
89
- modified or derivative works remains subject to the same
90
- restrictions as the Licensed Work, including the prohibition on
91
- Competitive Offerings.
92
-
93
- 8. Use of the Licensed Work by your own employees, contractors, and
94
- agents, acting on your behalf and for your benefit, is not by
95
- itself making the Licensed Work available to a Third Party.
96
-
97
- 9. Embedding or distributing the Licensed Work as a component of your
98
- own product or service is permitted only where the Licensed Work
99
- does not constitute the principal value of that product or service
100
- and the product or service is not a Competitive Offering.
101
-
102
- 10. Nothing in this Additional Use Grant grants any right to use any
103
- name, trademark, service mark, or logo of the Licensor or its
104
- Affiliates, except as reasonably required for customary
105
- attribution.
106
-
107
- 11. The rights stated in this Additional Use Grant are the maximum
108
- rights granted for Production Use prior to the Change Date. Any
109
- Production Use not expressly permitted requires a separate
110
- commercial license from the Licensor.
111
-
112
- 12. If any provision of this Additional Use Grant is held invalid or
113
- unenforceable, that provision shall be limited or eliminated to
114
- the minimum extent necessary so that the remainder of this
115
- Additional Use Grant, and of this License, remains in full force
116
- and effect. The Licensor reserves all rights not expressly granted
117
- by this License.
118
-
119
-
120
- Change Date: Four years from the date the specific version of the Licensed
121
- Work is first publicly released by Licensor.
122
-
123
- Change License: Mozilla Public License, Version 2.0
124
-
125
- For information about alternative licensing arrangements, commercial
126
- licensing, enterprise licensing, OEM licensing, appliance licensing, managed
127
- service licensing, cloud provider licensing, or other commercial use of the
128
- Licensed Work, please contact: licensing@neuralchowder.com
129
-
130
- -----------------------------------------------------------------------------
131
-
132
- Notice
133
-
134
- Business Source License 1.1
135
-
136
- Terms
137
-
138
- The Licensor hereby grants you the right to copy, modify, create derivative
139
- works, redistribute, and make non-production use of the Licensed Work. The
140
- Licensor may make an Additional Use Grant, above, permitting limited
141
- production use.
142
-
143
- Effective on the Change Date, or the fourth anniversary of the first publicly
144
- available distribution of a specific version of the Licensed Work under this
145
- License, whichever comes first, the Licensor hereby grants you rights under
146
- the terms of the Change License, and the rights granted in the paragraph above
147
- terminate.
148
-
149
- If your use of the Licensed Work does not comply with the requirements
150
- currently in effect as described in this License, you must purchase a
151
- commercial license from the Licensor, its affiliated entities, or authorized
152
- resellers, or you must refrain from using the Licensed Work.
153
-
154
- All copies of the original and modified Licensed Work, and derivative works of
155
- the Licensed Work, are subject to this License. This License applies separately
156
- for each version of the Licensed Work and the Change Date may vary for each
157
- version of the Licensed Work released by Licensor.
158
-
159
- You must conspicuously display this License on each original or modified copy
160
- of the Licensed Work. If you receive the Licensed Work in original or modified
161
- form from a third party, the terms and conditions set forth in this License
162
- apply to your use of that work.
163
-
164
- Any use of the Licensed Work in violation of this License will automatically
165
- terminate your rights under this License for the current and all other
166
- versions of the Licensed Work.
167
-
168
- This License does not grant you any right in any trademark or logo of Licensor
169
- or its affiliates, provided that you may use a trademark or logo of Licensor
170
- as expressly required by this License.
171
-
172
- TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN
173
- "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS
174
- OR IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS
175
- FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE.
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,43 @@
1
+ import { type ModelRef, type NodeOverlayFragment, type SubAgentBinding } from '@xemahq/kernel-contracts/workflow';
2
+ import type { ResolvedAgent, ResolvedAgentNode } from '@xemahq/kernel-contracts/agent-composition';
3
+ import type { PermissionMap } from '@xemahq/kernel-contracts/agent-permission';
4
+ import { type ToolSelectionEntry } from '@xemahq/kernel-contracts/mcp-tool';
5
+ export declare class AgentResolutionError extends Error {
6
+ constructor(context: string, detail: string);
7
+ }
8
+ export interface FlattenedAgentNode {
9
+ readonly slug: string;
10
+ readonly alias?: string;
11
+ readonly modelOverride?: ModelRef;
12
+ readonly instructions?: string;
13
+ readonly permission?: PermissionMap;
14
+ }
15
+ export interface CollectScopeOptions {
16
+ readonly scope?: 'tree' | 'root';
17
+ }
18
+ export interface RuntimeAgentConfig {
19
+ readonly agentRef: string;
20
+ readonly primaryAgentSlug: string;
21
+ readonly primaryInstructions: string | null;
22
+ readonly primaryPermission: PermissionMap | null;
23
+ readonly primaryModelOverride: ModelRef | null;
24
+ readonly subAgentBindings: readonly SubAgentBinding[];
25
+ readonly subAgentInstructionsBySlug: Readonly<Record<string, string>>;
26
+ readonly subAgentPermissionBySlug: Readonly<Record<string, PermissionMap>>;
27
+ readonly subAgentModelOverridesBySlug: Readonly<Record<string, ModelRef>>;
28
+ readonly defaultSkillSlugs: readonly string[];
29
+ readonly allSkillSlugs: readonly string[];
30
+ readonly defaultToolSelection: readonly ToolSelectionEntry[];
31
+ }
32
+ export declare function flattenAgentTree(root: ResolvedAgentNode): readonly FlattenedAgentNode[];
33
+ export declare function collectSkills(root: ResolvedAgentNode, opts?: CollectScopeOptions): readonly string[];
34
+ export declare function collectTools(root: ResolvedAgentNode, opts?: CollectScopeOptions): readonly ToolSelectionEntry[];
35
+ export declare function collectInstructionsBySlug(root: ResolvedAgentNode): Readonly<Record<string, string>>;
36
+ export declare function collectPermissionsBySlug(root: ResolvedAgentNode): Readonly<Record<string, PermissionMap>>;
37
+ export declare function collectModelOverridesBySlug(root: ResolvedAgentNode): Readonly<Record<string, ModelRef>>;
38
+ export declare function appendInstructions(baseSystemPrompt: string, nodeInstructions: string | null): string;
39
+ export declare function normalizeInstructions(raw: string | undefined): string | null;
40
+ export declare function normalizePermission(raw: PermissionMap | undefined): PermissionMap | null;
41
+ export declare function projectModelOverride(raw: ModelRef | undefined, context: string): ModelRef | null;
42
+ export declare function projectAgentToRuntimeConfig(resolved: ResolvedAgent, overlay?: NodeOverlayFragment): RuntimeAgentConfig;
43
+ //# sourceMappingURL=composition-resolution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composition-resolution.d.ts","sourceRoot":"","sources":["../../src/lib/composition-resolution.ts"],"names":[],"mappings":"AA4BA,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACrB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EAClB,MAAM,4CAA4C,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAC/E,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,mCAAmC,CAAC;AAU3C,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAI5C;AAWD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAC;IAClC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC;CACrC;AAGD,MAAM,WAAW,mBAAmB;IAKlC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAClC;AAOD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC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C,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAIzC;AAOD,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,iBAAiB,GACtB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAIpC;AA2CD,wBAAgB,kBAAkB,CAChC,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAC9B,MAAM,CAWR;AAWD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAM5E;AAQD,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,aAAa,GAAG,SAAS,GAC7B,aAAa,GAAG,IAAI,CAKtB;AAOD,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,QAAQ,GAAG,SAAS,EACzB,OAAO,EAAE,MAAM,GACd,QAAQ,GAAG,IAAI,CA4BjB;AAqGD,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,kBAAkB,CAyCpB"}
@@ -0,0 +1,236 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AgentResolutionError = void 0;
4
+ exports.flattenAgentTree = flattenAgentTree;
5
+ exports.collectSkills = collectSkills;
6
+ exports.collectTools = collectTools;
7
+ exports.collectInstructionsBySlug = collectInstructionsBySlug;
8
+ exports.collectPermissionsBySlug = collectPermissionsBySlug;
9
+ exports.collectModelOverridesBySlug = collectModelOverridesBySlug;
10
+ exports.appendInstructions = appendInstructions;
11
+ exports.normalizeInstructions = normalizeInstructions;
12
+ exports.normalizePermission = normalizePermission;
13
+ exports.projectModelOverride = projectModelOverride;
14
+ exports.projectAgentToRuntimeConfig = projectAgentToRuntimeConfig;
15
+ const workflow_1 = require("@xemahq/kernel-contracts/workflow");
16
+ const mcp_tool_1 = require("@xemahq/kernel-contracts/mcp-tool");
17
+ class AgentResolutionError extends Error {
18
+ constructor(context, detail) {
19
+ super(`Agent resolution failed for "${context}": ${detail}`);
20
+ this.name = 'AgentResolutionError';
21
+ }
22
+ }
23
+ exports.AgentResolutionError = AgentResolutionError;
24
+ function flattenAgentTree(root) {
25
+ const seen = new Set();
26
+ const out = [];
27
+ const visit = (node) => {
28
+ for (const child of node.children) {
29
+ const slug = child.kernel.slug;
30
+ if (slug.length === 0) {
31
+ continue;
32
+ }
33
+ if (!seen.has(slug)) {
34
+ seen.add(slug);
35
+ out.push({
36
+ slug,
37
+ ...(child.alias ? { alias: child.alias } : {}),
38
+ ...(child.modelOverride
39
+ ? { modelOverride: child.modelOverride }
40
+ : {}),
41
+ ...(child.instructions ? { instructions: child.instructions } : {}),
42
+ ...(child.permission ? { permission: child.permission } : {}),
43
+ });
44
+ }
45
+ visit(child);
46
+ }
47
+ };
48
+ visit(root);
49
+ return out;
50
+ }
51
+ function collectSkills(root, opts) {
52
+ const scope = opts?.scope ?? 'tree';
53
+ const seen = new Set();
54
+ const out = [];
55
+ const addNode = (node) => {
56
+ for (const slug of projectSkillSlugs(node.skills)) {
57
+ if (!seen.has(slug)) {
58
+ seen.add(slug);
59
+ out.push(slug);
60
+ }
61
+ }
62
+ };
63
+ addNode(root);
64
+ if (scope === 'tree') {
65
+ const visit = (node) => {
66
+ for (const child of node.children) {
67
+ addNode(child);
68
+ visit(child);
69
+ }
70
+ };
71
+ visit(root);
72
+ }
73
+ return out;
74
+ }
75
+ function collectTools(root, opts) {
76
+ const scope = opts?.scope ?? 'root';
77
+ const ctx = root.kernel.slug;
78
+ if (scope === 'root') {
79
+ return projectToolSelection(root.tools, ctx);
80
+ }
81
+ const out = [...projectToolSelection(root.tools, ctx)];
82
+ const visit = (node) => {
83
+ for (const child of node.children) {
84
+ out.push(...projectToolSelection(child.tools, child.kernel.slug));
85
+ visit(child);
86
+ }
87
+ };
88
+ visit(root);
89
+ return out;
90
+ }
91
+ function collectInstructionsBySlug(root) {
92
+ return collectDescendantOverlay(root, (child) => normalizeInstructions(child.instructions));
93
+ }
94
+ function collectPermissionsBySlug(root) {
95
+ return collectDescendantOverlay(root, (child) => normalizePermission(child.permission));
96
+ }
97
+ function collectModelOverridesBySlug(root) {
98
+ return collectDescendantOverlay(root, (child) => projectModelOverride(child.modelOverride, child.kernel.slug));
99
+ }
100
+ function collectDescendantOverlay(root, project) {
101
+ const out = {};
102
+ const seen = new Set();
103
+ const visit = (node) => {
104
+ for (const child of node.children) {
105
+ const slug = child.kernel.slug;
106
+ if (slug.length === 0) {
107
+ continue;
108
+ }
109
+ if (!seen.has(slug)) {
110
+ seen.add(slug);
111
+ const value = project(child);
112
+ if (value !== null) {
113
+ out[slug] = value;
114
+ }
115
+ }
116
+ visit(child);
117
+ }
118
+ };
119
+ visit(root);
120
+ return out;
121
+ }
122
+ function appendInstructions(baseSystemPrompt, nodeInstructions) {
123
+ const trimmed = nodeInstructions === null ? '' : nodeInstructions.trim();
124
+ if (trimmed.length === 0) {
125
+ return baseSystemPrompt;
126
+ }
127
+ if (baseSystemPrompt.length === 0) {
128
+ return trimmed;
129
+ }
130
+ return `${baseSystemPrompt}\n\n${trimmed}`;
131
+ }
132
+ function normalizeInstructions(raw) {
133
+ if (typeof raw !== 'string') {
134
+ return null;
135
+ }
136
+ const trimmed = raw.trim();
137
+ return trimmed.length > 0 ? trimmed : null;
138
+ }
139
+ function normalizePermission(raw) {
140
+ if (!raw || typeof raw !== 'object' || Object.keys(raw).length === 0) {
141
+ return null;
142
+ }
143
+ return raw;
144
+ }
145
+ function projectModelOverride(raw, context) {
146
+ if (raw === undefined) {
147
+ return null;
148
+ }
149
+ if (raw.kind === workflow_1.ModelRefKind.CONCRETE) {
150
+ if (typeof raw.modelId !== 'string' || raw.modelId.trim().length === 0) {
151
+ throw new AgentResolutionError(context, 'concrete modelOverride is missing a modelId');
152
+ }
153
+ return raw;
154
+ }
155
+ const modelClass = raw.modelClass;
156
+ if (modelClass === undefined ||
157
+ !workflow_1.MODEL_CLASS_VALUES.includes(modelClass)) {
158
+ throw new AgentResolutionError(context, `strategy modelOverride.modelClass must be one of ${workflow_1.MODEL_CLASS_VALUES.join(', ')}`);
159
+ }
160
+ return raw;
161
+ }
162
+ function projectSkillSlugs(skills) {
163
+ if (!Array.isArray(skills)) {
164
+ return [];
165
+ }
166
+ return skills
167
+ .map((s) => s.slug)
168
+ .filter((slug) => typeof slug === 'string' && slug.length > 0);
169
+ }
170
+ function projectToolSelection(tools, context) {
171
+ if (!Array.isArray(tools)) {
172
+ return [];
173
+ }
174
+ const validKinds = new Set(Object.values(mcp_tool_1.ToolProviderKind));
175
+ const out = [];
176
+ for (const [idx, tool] of tools.entries()) {
177
+ if (typeof tool.providerKind !== 'string' ||
178
+ !validKinds.has(tool.providerKind)) {
179
+ throw new AgentResolutionError(context, `tools[${idx}].providerKind must be one of ${Object.values(mcp_tool_1.ToolProviderKind).join(', ')}`);
180
+ }
181
+ if (typeof tool.resourceId !== 'string' ||
182
+ tool.resourceId.trim().length === 0) {
183
+ throw new AgentResolutionError(context, `tools[${idx}].resourceId must be a non-empty string`);
184
+ }
185
+ if (tool.kind === 'provider') {
186
+ out.push({
187
+ kind: 'provider',
188
+ providerKind: tool.providerKind,
189
+ resourceId: tool.resourceId,
190
+ });
191
+ }
192
+ else if (tool.kind === 'tool') {
193
+ if (typeof tool.toolName !== 'string' ||
194
+ tool.toolName.trim().length === 0) {
195
+ throw new AgentResolutionError(context, `tools[${idx}].toolName must be a non-empty string for kind='tool'`);
196
+ }
197
+ out.push({
198
+ kind: 'tool',
199
+ providerKind: tool.providerKind,
200
+ resourceId: tool.resourceId,
201
+ toolName: tool.toolName,
202
+ });
203
+ }
204
+ else {
205
+ throw new AgentResolutionError(context, `tools[${idx}].kind must be "provider" or "tool"`);
206
+ }
207
+ }
208
+ return out;
209
+ }
210
+ function projectAgentToRuntimeConfig(resolved, overlay) {
211
+ const root = resolved.root;
212
+ const agentRef = `${resolved.slug}@${resolved.version}`;
213
+ const rootInstructions = normalizeInstructions(root.instructions);
214
+ const overlayInstructions = normalizeInstructions(overlay?.instructions);
215
+ const primaryInstructions = appendInstructions(rootInstructions ?? '', overlayInstructions);
216
+ const rootModelOverride = projectModelOverride(root.modelOverride, agentRef);
217
+ const overlayModelOverride = projectModelOverride(overlay?.modelOverride, `${agentRef}#overlay`);
218
+ const rootPermission = normalizePermission(root.permission);
219
+ const overlayPermission = normalizePermission(overlay?.permission);
220
+ const flattened = flattenAgentTree(root);
221
+ return {
222
+ agentRef,
223
+ primaryAgentSlug: root.kernel.slug,
224
+ primaryInstructions: primaryInstructions.length > 0 ? primaryInstructions : null,
225
+ primaryPermission: overlayPermission ?? rootPermission,
226
+ primaryModelOverride: overlayModelOverride ?? rootModelOverride,
227
+ subAgentBindings: flattened.map((n) => ({ ...n })),
228
+ subAgentInstructionsBySlug: collectInstructionsBySlug(root),
229
+ subAgentPermissionBySlug: collectPermissionsBySlug(root),
230
+ subAgentModelOverridesBySlug: collectModelOverridesBySlug(root),
231
+ defaultSkillSlugs: collectSkills(root, { scope: 'root' }),
232
+ allSkillSlugs: collectSkills(root, { scope: 'tree' }),
233
+ defaultToolSelection: collectTools(root, { scope: 'root' }),
234
+ };
235
+ }
236
+ //# sourceMappingURL=composition-resolution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composition-resolution.js","sourceRoot":"","sources":["../../src/lib/composition-resolution.ts"],"names":[],"mappings":";;;AA6HA,4CA4BC;AAQD,sCA0BC;AAQD,oCAkBC;AAOD,8DAMC;AAMD,4DAMC;AAOD,kEAMC;AA2CD,gDAcC;AAWD,sDAMC;AAQD,kDAOC;AAOD,oDA+BC;AAqGD,kEA4CC;AA/eD,gEAO2C;AAM3C,gEAG2C;AAU3C,MAAa,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,OAAe,EAAE,MAAc;QACzC,KAAK,CAAC,gCAAgC,OAAO,MAAM,MAAM,EAAE,CAAC,CAAC;QAC7D,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IAC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AAU,CAAC,CAAC;IAC5D,MAAM,iBAAiB,GAAG,mBAAmB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAEnE,MAAM,SAAS,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAEzC,OAAO;QACL,QAAQ;QACR,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;QAClC,mBAAmB,EACjB,mBAAmB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI;QAC7D,iBAAiB,EAAE,iBAAiB,IAAI,cAAc;QACtD,oBAAoB,EAAE,oBAAoB,IAAI,iBAAiB;QAC/D,gBAAgB,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;QAClD,0BAA0B,EAAE,yBAAyB,CAAC,IAAI,CAAC;QAC3D,wBAAwB,EAAE,wBAAwB,CAAC,IAAI,CAAC;QACxD,4BAA4B,EAAE,2BAA2B,CAAC,IAAI,CAAC;QAC/D,iBAAiB,EAAE,aAAa,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QACzD,aAAa,EAAE,aAAa,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QACrD,oBAAoB,EAAE,YAAY,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;KAC5D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,51 @@
1
+ import { type CompiledManifestCredential, type CompiledManifestPermissions, type ModelRef } from '@xemahq/kernel-contracts/workflow';
2
+ import type { PermissionMap } from '@xemahq/kernel-contracts/agent-permission';
3
+ import { type CompiledWorkspaceManifest } from '@xemahq/dsl/workspace-manifest';
4
+ export type { CompiledWorkspaceManifest };
5
+ export declare class AgentMountLayoutError extends Error {
6
+ constructor(agentRef: string, detail: string);
7
+ }
8
+ export interface AgentRunConfigInput {
9
+ readonly stage: string;
10
+ readonly role: string;
11
+ readonly deliverableSpecRef?: string;
12
+ }
13
+ export interface AgentMountLayoutInput {
14
+ readonly mounts: Readonly<Record<string, unknown>>;
15
+ readonly agentRunConfig: AgentRunConfigInput;
16
+ readonly seedFiles: readonly unknown[];
17
+ readonly inputs: Readonly<Record<string, unknown>>;
18
+ }
19
+ export interface AgentSubAgentBindingInput {
20
+ readonly slug: string;
21
+ readonly alias?: string;
22
+ readonly modelOverride?: ModelRef;
23
+ readonly instructions?: string;
24
+ readonly permission?: PermissionMap;
25
+ }
26
+ export interface AgentOutputSurfaceInput {
27
+ readonly kind: 'none' | 'web' | 'static' | 'app' | 'tunnel';
28
+ readonly port?: number;
29
+ readonly healthPath?: string;
30
+ readonly autoOpen?: boolean;
31
+ readonly mode?: 'single' | 'multi';
32
+ readonly root?: string;
33
+ readonly defaultDocument?: string;
34
+ }
35
+ export interface AgentManifestSource {
36
+ readonly agentRef: string;
37
+ readonly primaryAgentSlug: string;
38
+ readonly subAgentBindings: readonly AgentSubAgentBindingInput[];
39
+ readonly mountLayout: AgentMountLayoutInput | undefined;
40
+ readonly outputSurface?: AgentOutputSurfaceInput;
41
+ readonly credentials?: readonly CompiledManifestCredential[];
42
+ readonly permissions?: CompiledManifestPermissions;
43
+ }
44
+ export interface AgentManifestImplicitInputs {
45
+ readonly orgId: string;
46
+ readonly projectId: string;
47
+ readonly sessionId?: string;
48
+ }
49
+ export declare function compileAgentWorkspaceManifest(source: AgentManifestSource, bindInputs: Readonly<Record<string, unknown>>): CompiledWorkspaceManifest;
50
+ export declare function buildAgentManifestBindInputs(source: AgentManifestSource, explicitInputs: Record<string, unknown> | null, implicitInputs: AgentManifestImplicitInputs): Readonly<Record<string, unknown>>;
51
+ //# sourceMappingURL=composition-workspace-manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composition-workspace-manifest.d.ts","sourceRoot":"","sources":["../../src/lib/composition-workspace-manifest.ts"],"names":[],"mappings":"AA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,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA6CnC"}
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AgentMountLayoutError = void 0;
4
+ exports.compileAgentWorkspaceManifest = compileAgentWorkspaceManifest;
5
+ exports.buildAgentManifestBindInputs = buildAgentManifestBindInputs;
6
+ const workflow_1 = require("@xemahq/kernel-contracts/workflow");
7
+ const workspace_manifest_1 = require("@xemahq/dsl/workspace-manifest");
8
+ class AgentMountLayoutError extends Error {
9
+ constructor(agentRef, detail) {
10
+ super(`Cannot derive a workspace mount layout from Agent ` +
11
+ `"${agentRef}": ${detail}`);
12
+ this.name = 'AgentMountLayoutError';
13
+ }
14
+ }
15
+ exports.AgentMountLayoutError = AgentMountLayoutError;
16
+ function compileAgentWorkspaceManifest(source, bindInputs) {
17
+ const mountLayout = source.mountLayout;
18
+ if (!mountLayout) {
19
+ throw new AgentMountLayoutError(source.agentRef, 'the composition declares no `workspace.mountLayout` block — its ' +
20
+ 'source workspace manifest was not projected by the llm-registry-api ' +
21
+ 'composition seeder. Re-seed compositions (boot llm-registry-api) or ' +
22
+ 'fix the source manifest.');
23
+ }
24
+ const [slug, version] = splitAgentRef(source.agentRef);
25
+ const subAgents = source.subAgentBindings.map((binding) => ({
26
+ slug: binding.slug,
27
+ ...(binding.alias !== undefined ? { alias: binding.alias } : {}),
28
+ ...(binding.modelOverride !== undefined
29
+ ? { defaultModel: binding.modelOverride }
30
+ : {}),
31
+ ...(binding.instructions !== undefined
32
+ ? { instructions: binding.instructions }
33
+ : {}),
34
+ ...(binding.permission !== undefined
35
+ ? { permission: binding.permission }
36
+ : {}),
37
+ }));
38
+ const outputSurface = projectOutputSurface(source.outputSurface);
39
+ const credentials = projectCredentials(source.credentials);
40
+ const permissions = projectPermissions(source.permissions);
41
+ const spec = {
42
+ mounts: mountLayout.mounts,
43
+ agent: {
44
+ slug: source.primaryAgentSlug,
45
+ stage: mountLayout.agentRunConfig.stage,
46
+ role: mountLayout.agentRunConfig.role,
47
+ ...(mountLayout.agentRunConfig.deliverableSpecRef !== undefined
48
+ ? { deliverableSpecRef: mountLayout.agentRunConfig.deliverableSpecRef }
49
+ : {}),
50
+ ...(subAgents.length > 0 ? { subAgents } : {}),
51
+ },
52
+ ...(Object.keys(mountLayout.inputs).length > 0
53
+ ? {
54
+ inputs: mountLayout.inputs,
55
+ }
56
+ : {}),
57
+ ...(mountLayout.seedFiles.length > 0
58
+ ? {
59
+ seedFiles: mountLayout.seedFiles,
60
+ }
61
+ : {}),
62
+ ...(outputSurface === undefined ? {} : { outputSurface }),
63
+ ...(credentials === undefined ? {} : { credentials }),
64
+ ...(permissions === undefined ? {} : { permissions }),
65
+ };
66
+ const envelope = {
67
+ apiVersion: 'xema.dev/workspace/v1',
68
+ kind: 'WorkspaceManifest',
69
+ metadata: {
70
+ slug,
71
+ version,
72
+ surfaceCompat: [workflow_1.ManifestSurface.AGENT_SESSION],
73
+ },
74
+ spec,
75
+ };
76
+ const result = (0, workspace_manifest_1.compileManifest)(envelope, bindInputs);
77
+ if (!result.ok) {
78
+ throw new AgentMountLayoutError(source.agentRef, `reconstructed manifest failed to compile: ${result.errors
79
+ .map((e) => `${e.path}: ${e.message}`)
80
+ .join('; ')}`);
81
+ }
82
+ return result.compiled;
83
+ }
84
+ function projectOutputSurface(surface) {
85
+ if (!surface)
86
+ return undefined;
87
+ return {
88
+ kind: surface.kind,
89
+ ...(surface.port === undefined ? {} : { port: surface.port }),
90
+ ...(surface.healthPath === undefined
91
+ ? {}
92
+ : { healthPath: surface.healthPath }),
93
+ ...(surface.autoOpen === undefined ? {} : { autoOpen: surface.autoOpen }),
94
+ ...(surface.mode === undefined ? {} : { mode: surface.mode }),
95
+ ...(surface.root === undefined ? {} : { root: surface.root }),
96
+ ...(surface.defaultDocument === undefined
97
+ ? {}
98
+ : { defaultDocument: surface.defaultDocument }),
99
+ };
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
+ }
121
+ function buildAgentManifestBindInputs(source, explicitInputs, implicitInputs) {
122
+ const declared = new Set(Object.keys(source.mountLayout?.inputs ?? {}));
123
+ if (declared.size === 0) {
124
+ return {};
125
+ }
126
+ if (explicitInputs !== null &&
127
+ (typeof explicitInputs !== 'object' || Array.isArray(explicitInputs))) {
128
+ throw new AgentMountLayoutError(source.agentRef, 'explicit manifest inputs must be an object when provided');
129
+ }
130
+ const explicit = explicitInputs ?? {};
131
+ for (const [key, value] of Object.entries(explicit)) {
132
+ if (!declared.has(key)) {
133
+ throw new AgentMountLayoutError(source.agentRef, `manifest inputs contain undeclared key "${key}"`);
134
+ }
135
+ assertManifestInputValue(source.agentRef, key, value);
136
+ }
137
+ const implicit = {
138
+ orgId: implicitInputs.orgId,
139
+ projectId: implicitInputs.projectId,
140
+ ...(implicitInputs.sessionId !== undefined
141
+ ? { sessionId: implicitInputs.sessionId }
142
+ : {}),
143
+ };
144
+ const out = {};
145
+ for (const key of declared) {
146
+ if (Object.hasOwn(explicit, key)) {
147
+ out[key] = explicit[key];
148
+ continue;
149
+ }
150
+ if (Object.hasOwn(implicit, key)) {
151
+ out[key] = implicit[key];
152
+ }
153
+ }
154
+ return out;
155
+ }
156
+ function splitAgentRef(ref) {
157
+ const at = ref.lastIndexOf('@');
158
+ if (at <= 0 || at === ref.length - 1) {
159
+ throw new AgentMountLayoutError(ref, 'expected a version-pinned `slug@version` composition ref — the ' +
160
+ 'session resolver always pins the resolved version');
161
+ }
162
+ return [ref.slice(0, at), ref.slice(at + 1)];
163
+ }
164
+ function assertManifestInputValue(agentRef, key, value) {
165
+ if (value !== null &&
166
+ typeof value !== 'string' &&
167
+ typeof value !== 'number' &&
168
+ typeof value !== 'boolean' &&
169
+ !Array.isArray(value)) {
170
+ throw new AgentMountLayoutError(agentRef, `manifest input "${key}" must be a primitive ` +
171
+ `(string, number, boolean, string[]) — got ${typeof value}`);
172
+ }
173
+ if (Array.isArray(value) &&
174
+ !value.every((entry) => typeof entry === 'string')) {
175
+ throw new AgentMountLayoutError(agentRef, `manifest input "${key}" is an array — every element must be a string`);
176
+ }
177
+ }
178
+ //# sourceMappingURL=composition-workspace-manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composition-workspace-manifest.js","sourceRoot":"","sources":["../../src/lib/composition-workspace-manifest.ts"],"names":[],"mappings":";;;AAwPA,sEAyGC;AA0GD,oEAiDC;AA/dD,gEAO2C;AAE3C,uEAYwC;AAcxC,MAAa,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,QAAgB,EAAE,MAAc;QAC1C,KAAK,CACH,oDAAoD;YAClD,IAAI,QAAQ,MAAM,MAAM,EAAE,CAC7B,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AARD,sDAQC;AAgLD,SAAgB,6BAA6B,CAC3C,MAA2B,EAC3B,UAA6C;IAE7C,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IACvC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,qBAAqB,CAC7B,MAAM,CAAC,QAAQ,EACf,kEAAkE;YAChE,sEAAsE;YACtE,sEAAsE;YACtE,0BAA0B,CAC7B,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAOvD,MAAM,SAAS,GAAuB,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAC/D,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACZ,IA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GAAG,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC;AAQD,SAAS,wBAAwB,CAC/B,QAAgB,EAChB,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,qBAAqB,CAC7B,QAAQ,EACR,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,qBAAqB,CAC7B,QAAQ,EACR,mBAAmB,GAAG,gDAAgD,CACvE,CAAC;IACJ,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,16 @@
1
1
  {
2
2
  "name": "@xemahq/agent-session-runtime",
3
- "version": "0.6.6",
3
+ "version": "0.6.7",
4
+ "description": "Runtime for composing and running Xema agent sessions — workspace manifests, skill bundles, environment resolution, and drift detection.",
5
+ "license": "Apache-2.0",
6
+ "author": "Neuralchowder Inc. <developer@xema.dev> (https://xema.dev)",
7
+ "homepage": "https://xema.dev",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/xema-dev/xema-runtime-core.git",
11
+ "directory": "packages/runtime/agent-session-runtime"
12
+ },
13
+ "bugs": "https://github.com/xema-dev/xema-runtime-core/issues",
4
14
  "publishConfig": {
5
15
  "registry": "https://registry.npmjs.org/",
6
16
  "access": "public"
@@ -35,11 +45,11 @@
35
45
  "prettier": "3.6.2",
36
46
  "ts-jest": "^29.4.9",
37
47
  "typescript": "5.9.3",
38
- "@xemahq/kernel-contracts": "^0.15.0"
48
+ "@xemahq/kernel-contracts": "^0.58.0"
39
49
  },
40
50
  "dependencies": {
41
- "@xemahq/dsl": "^0.5.4",
42
- "@xemahq/kernel-contracts": "^0.15.0"
51
+ "@xemahq/dsl": "^0.6.1",
52
+ "@xemahq/kernel-contracts": "^0.58.0"
43
53
  },
44
54
  "peerDependencies": {
45
55
  "@xemahq/kernel-contracts": ">=0.13.0"
@@ -1,7 +1,7 @@
1
1
  // ═══════════════════════════════════════════════════════════════════════════
2
2
  // ── Agent → CompiledWorkspaceManifest reconstruction ──
3
3
  //
4
- // Phase 10 (`workspace-manifests-api` retirement). The composer turns a
4
+ // The composer turns a
5
5
  // `CompiledWorkspaceManifest` into a `WorkspaceMountPlan`; before this
6
6
  // module the only way to obtain that compiled manifest was to fetch the
7
7
  // `WorkspaceManifest` row from `workspace-manifests-api` and run
@@ -47,7 +47,7 @@ import {
47
47
  type ManifestSeedFile,
48
48
  type ManifestSubAgent,
49
49
  type ManifestWorkingFile,
50
- type WorkspaceManifest as DslWorkspaceManifest,
50
+ type AgentWorkspaceSpec as DslWorkspaceManifest,
51
51
  type WorkspaceManifestSpec,
52
52
  } from '@xemahq/dsl/workspace-manifest';
53
53
 
@@ -328,8 +328,8 @@ export class DefaultWorkspaceImageComposer implements WorkspaceImageComposer {
328
328
  // `/<skillKey>` in a session loads and applies that skill natively.
329
329
  //
330
330
  // Kernel-shipped System skills are PREPENDED to whatever skills the
331
- // caller already named in `agentContext.skills` (see
332
- // `.claude/rules/skills-and-composition.md` — `SkillSpace.System`
331
+ // caller already named in `agentContext.skills` (per the skill
332
+ // composition rules — `SkillSpace.System`
333
333
  // skills are auto-injected into every agent's mounted bundle).
334
334
  // `dedupe` collapses any overlap so a caller that re-mentions a
335
335
  // System skill in `agentContext.skills` does not double-mount it.
@@ -57,8 +57,8 @@ export enum DriftKind {
57
57
 
58
58
  /**
59
59
  * Advisory drift severity — `info` (benign) or `warning` (worth a look).
60
- * There is deliberately no `critical`: resume is non-blocking by design
61
- * (plan Epic D §D4), so severity only drives how the operator's drift
60
+ * There is deliberately no `critical`: resume is non-blocking by design,
61
+ * so severity only drives how the operator's drift
62
62
  * toast renders, never whether the session resumes.
63
63
  */
64
64
  export type DriftSeverity = 'info' | 'warning';
@@ -124,7 +124,7 @@ export interface EnvironmentResolverRequest {
124
124
  */
125
125
  readonly systemSkillSlugs?: readonly string[];
126
126
  /**
127
- * Optional MCP stanza resolver (Phase D1). Translates the manifest's
127
+ * Optional MCP stanza resolver. Translates the manifest's
128
128
  * `toolSelection` into a `mcpServers` map suitable for direct write
129
129
  * into `opencode.jsonc:mcp`. When absent, the resolved environment
130
130
  * carries no MCP stanzas — appropriate for workflow surfaces today
@@ -205,7 +205,7 @@ export interface ResolvedEnvironment {
205
205
  readonly mountPlan: WorkspaceMountPlan;
206
206
  readonly env: readonly { readonly name: string; readonly value: string }[];
207
207
  /**
208
- * Phase D1: resolved `mcpServers` map ready to drop into
208
+ * Resolved `mcpServers` map ready to drop into
209
209
  * `opencode.jsonc:mcp`. Empty `{}` when the manifest declares no
210
210
  * toolSelection or when the request omits an `mcpResolver`. Keeps
211
211
  * the snapshot self-contained so downstream callers (workflow
@@ -279,7 +279,7 @@ export class DefaultEnvironmentResolver implements EnvironmentResolver {
279
279
  req.briefcase?.mcpTools,
280
280
  );
281
281
 
282
- // Phase H.2: capability federation. When an `mcpResolver` is wired
282
+ // Capability federation. When an `mcpResolver` is wired
283
283
  // (session-boot, workflow-runtime-worker) the resolver ALWAYS runs —
284
284
  // the returned stanza is the fixed three meta-tool surface
285
285
  // (`xema-capabilities-{list,describe,invoke}`), regardless of
@@ -1,7 +1,7 @@
1
1
  // ═══════════════════════════════════════════════════════════════════════════
2
2
  // ── Skill-bundle-backed TemplateResolver ──
3
3
  //
4
- // Phase 10 (workspace-manifests-api retirement). Seed-file templates used to
4
+ // Seed-file templates used to
5
5
  // live in `workspace-manifests-api` (the `workspace_manifest_templates` table)
6
6
  // and were fetched by name. They are now SKILL-BUNDLE RESOURCES served by
7
7
  // `skill-registry-api` (`GET /skills/bundle`): a biome that ships templates
package/src/lib/types.ts CHANGED
@@ -69,7 +69,7 @@ export interface ComposeWorkspaceImageRequest {
69
69
  readonly templateResolver?: TemplateResolver;
70
70
  /**
71
71
  * Kernel-shipped System-scope skill slugs to PREPEND to the composer's
72
- * mounted skill set. Per `.claude/rules/skills-and-composition.md`,
72
+ * mounted skill set. Per the skill composition rules,
73
73
  * skills owned by `SkillSpace.System` are auto-injected into every
74
74
  * agent's mounted bundle — they ship from `@xemahq/system-skills`
75
75
  * via the System-tier seeder in `skill-registry-api`. The caller