@agimon-ai/po-team 0.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +25 -0
- package/README.md +156 -0
- package/dist/agentDiscovery-Whwzc4dP.cjs +1637 -0
- package/dist/agentDiscovery-Whwzc4dP.cjs.map +1 -0
- package/dist/agentDiscovery-ZQlFkKvB.mjs +1529 -0
- package/dist/agentDiscovery-ZQlFkKvB.mjs.map +1 -0
- package/dist/apiContracts.cjs +162 -0
- package/dist/apiContracts.cjs.map +1 -0
- package/dist/apiContracts.d.mts +53 -0
- package/dist/apiContracts.d.mts.map +1 -0
- package/dist/apiContracts.mjs +157 -0
- package/dist/apiContracts.mjs.map +1 -0
- package/dist/atomicJson-D0346bt5.cjs +178 -0
- package/dist/atomicJson-D0346bt5.cjs.map +1 -0
- package/dist/atomicJson-D2t0CDh9.mjs +137 -0
- package/dist/atomicJson-D2t0CDh9.mjs.map +1 -0
- package/dist/capabilityCeiling-C-Y7H8oC.cjs +191 -0
- package/dist/capabilityCeiling-C-Y7H8oC.cjs.map +1 -0
- package/dist/capabilityCeiling-CF7kAS18.mjs +156 -0
- package/dist/capabilityCeiling-CF7kAS18.mjs.map +1 -0
- package/dist/capabilityCeiling.cjs +10 -0
- package/dist/capabilityCeiling.d.mts +46 -0
- package/dist/capabilityCeiling.d.mts.map +1 -0
- package/dist/capabilityCeiling.mjs +3 -0
- package/dist/delegation.cjs +49 -0
- package/dist/delegation.cjs.map +1 -0
- package/dist/delegation.d.mts +269 -0
- package/dist/delegation.d.mts.map +1 -0
- package/dist/delegation.mjs +34 -0
- package/dist/delegation.mjs.map +1 -0
- package/dist/delegationApi.cjs +92 -0
- package/dist/delegationApi.d.mts +2 -0
- package/dist/delegationApi.mjs +2 -0
- package/dist/env.cjs +62 -0
- package/dist/env.d.mts +2 -0
- package/dist/env.mjs +2 -0
- package/dist/environment-CaCW3SgT.cjs +320 -0
- package/dist/environment-CaCW3SgT.cjs.map +1 -0
- package/dist/environment-DrqhrxG_.mjs +75 -0
- package/dist/environment-DrqhrxG_.mjs.map +1 -0
- package/dist/environment-ma5oQ7uM.d.mts +63 -0
- package/dist/environment-ma5oQ7uM.d.mts.map +1 -0
- package/dist/extensions/server.cjs +6940 -0
- package/dist/extensions/server.cjs.map +1 -0
- package/dist/extensions/server.d.mts +5 -0
- package/dist/extensions/server.d.mts.map +1 -0
- package/dist/extensions/server.mjs +6932 -0
- package/dist/extensions/server.mjs.map +1 -0
- package/dist/extensions/web.mjs +2308 -0
- package/dist/extensions/web.mjs.map +1 -0
- package/dist/externalProcessIpc-C-15lJrB.mjs +584 -0
- package/dist/externalProcessIpc-C-15lJrB.mjs.map +1 -0
- package/dist/externalProcessIpc-ojE0pvw0.cjs +690 -0
- package/dist/externalProcessIpc-ojE0pvw0.cjs.map +1 -0
- package/dist/fablePlan.cjs +17 -0
- package/dist/fablePlan.d.mts +2 -0
- package/dist/fablePlan.mjs +2 -0
- package/dist/fablePlanApi-BsHhgVFV.mjs +118 -0
- package/dist/fablePlanApi-BsHhgVFV.mjs.map +1 -0
- package/dist/fablePlanApi-CZ3uUcMi.d.mts +97 -0
- package/dist/fablePlanApi-CZ3uUcMi.d.mts.map +1 -0
- package/dist/fablePlanApi-wBu9bRXU.cjs +207 -0
- package/dist/fablePlanApi-wBu9bRXU.cjs.map +1 -0
- package/dist/fablePlanApi.cjs +17 -0
- package/dist/fablePlanApi.d.mts +2 -0
- package/dist/fablePlanApi.mjs +2 -0
- package/dist/index.cjs +49 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +160 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +45 -0
- package/dist/index.mjs.map +1 -0
- package/dist/runs/background/cliRunnerEntry.cjs +539 -0
- package/dist/runs/background/cliRunnerEntry.cjs.map +1 -0
- package/dist/runs/background/cliRunnerEntry.d.mts +1 -0
- package/dist/runs/background/cliRunnerEntry.mjs +537 -0
- package/dist/runs/background/cliRunnerEntry.mjs.map +1 -0
- package/dist/runtimeSubagentPolicy.cjs +5 -0
- package/dist/runtimeSubagentPolicy.d.mts +2 -0
- package/dist/runtimeSubagentPolicy.mjs +2 -0
- package/dist/runtimeSubagentTool.cjs +11 -0
- package/dist/runtimeSubagentTool.d.mts +2 -0
- package/dist/runtimeSubagentTool.mjs +2 -0
- package/dist/subagentPolicy-ALJam4GN.d.mts +33 -0
- package/dist/subagentPolicy-ALJam4GN.d.mts.map +1 -0
- package/dist/subagentPolicy-DQRyKDH-.cjs +39 -0
- package/dist/subagentPolicy-DQRyKDH-.cjs.map +1 -0
- package/dist/subagentPolicy-DxjsKeyj.mjs +22 -0
- package/dist/subagentPolicy-DxjsKeyj.mjs.map +1 -0
- package/dist/subagentPolicy.cjs +5 -0
- package/dist/subagentPolicy.d.mts +2 -0
- package/dist/subagentPolicy.mjs +2 -0
- package/dist/subagentTool-BTssGLw8.d.mts +103 -0
- package/dist/subagentTool-BTssGLw8.d.mts.map +1 -0
- package/dist/subagentTool-Ca2zQXKw.cjs +227 -0
- package/dist/subagentTool-Ca2zQXKw.cjs.map +1 -0
- package/dist/subagentTool-WOYrjxgT.mjs +186 -0
- package/dist/subagentTool-WOYrjxgT.mjs.map +1 -0
- package/dist/subagentTool.cjs +10 -0
- package/dist/subagentTool.d.mts +2 -0
- package/dist/subagentTool.mjs +2 -0
- package/dist/teamSnapshot-DgaANhBs.mjs +24 -0
- package/dist/teamSnapshot-DgaANhBs.mjs.map +1 -0
- package/dist/teamSnapshot-oKuGFdYc.cjs +35 -0
- package/dist/teamSnapshot-oKuGFdYc.cjs.map +1 -0
- package/dist/teamSnapshot.cjs +4 -0
- package/dist/teamSnapshot.d.mts +59 -0
- package/dist/teamSnapshot.d.mts.map +1 -0
- package/dist/teamSnapshot.mjs +2 -0
- package/package.json +201 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
require("./environment-CaCW3SgT.cjs");
|
|
2
|
+
let node_buffer = require("node:buffer");
|
|
3
|
+
//#region src/schemas/team/capabilityCeiling.ts
|
|
4
|
+
/**
|
|
5
|
+
* Capability-ceiling values, intersection, and the child-process codec.
|
|
6
|
+
*
|
|
7
|
+
* Live extension contributions enter through Team's `doom/subagent-policy`
|
|
8
|
+
* Cordis service. Only the resolved ceiling crosses a process boundary, through
|
|
9
|
+
* the versioned environment value encoded here.
|
|
10
|
+
*/
|
|
11
|
+
const SUBAGENT_CAPABILITY_CEILING_VERSION = 2;
|
|
12
|
+
const MAX_TEXT_BYTES = 256;
|
|
13
|
+
const MAX_TOOL_NAME_BYTES = 128;
|
|
14
|
+
const MAX_ALLOWED_TOOLS = 256;
|
|
15
|
+
const MAX_ALLOWED_EXTERNAL_PROFILES = 32;
|
|
16
|
+
const MAX_EXTERNAL_PROFILE_NAME_BYTES = 128;
|
|
17
|
+
const EXTERNAL_PROFILE_PATTERN = /^[A-Za-z0-9][A-Za-z0-9/_.:-]+$/u;
|
|
18
|
+
const TOOL_NAME_PATTERN = /^[A-Za-z0-9_.:-]+$/u;
|
|
19
|
+
const LAST_C0_CONTROL_CODE = 31;
|
|
20
|
+
const DELETE_CODE = 127;
|
|
21
|
+
/**
|
|
22
|
+
* Ceiling text crosses a process boundary and is rendered in the TUI, so control
|
|
23
|
+
* characters are rejected. Scanning code points avoids a control-character
|
|
24
|
+
* regex, which lints as a hazard even when the escapes are explicit.
|
|
25
|
+
*/
|
|
26
|
+
function hasControlCharacter(value) {
|
|
27
|
+
for (const character of value) {
|
|
28
|
+
const code = character.codePointAt(0);
|
|
29
|
+
if (code !== void 0 && (code <= LAST_C0_CONTROL_CODE || code === DELETE_CODE)) return true;
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
var SubagentCapabilityPolicyStore = class {
|
|
34
|
+
policies = /* @__PURE__ */ new Map();
|
|
35
|
+
register(policy, generation) {
|
|
36
|
+
const ceiling = normalizeCeiling({
|
|
37
|
+
...policy.allowedTools ? { allowedTools: policy.allowedTools } : {},
|
|
38
|
+
...policy.requiredTools ? { requiredTools: policy.requiredTools } : {},
|
|
39
|
+
...policy.allowMcpTools === true ? { allowMcpTools: true } : {},
|
|
40
|
+
...policy.allowedExternalProfiles ? { allowedExternalProfiles: policy.allowedExternalProfiles } : {},
|
|
41
|
+
denyExtensions: policy.denyExtensions === true
|
|
42
|
+
});
|
|
43
|
+
ceiling.sources = [policy.owner];
|
|
44
|
+
this.policies.set(policy.owner, {
|
|
45
|
+
generation,
|
|
46
|
+
ceiling
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
update(policy, generation) {
|
|
50
|
+
if (this.policies.get(policy.owner)?.generation !== generation) return;
|
|
51
|
+
this.register(policy, generation);
|
|
52
|
+
}
|
|
53
|
+
remove(owner, generation) {
|
|
54
|
+
if (this.policies.get(owner)?.generation === generation) this.policies.delete(owner);
|
|
55
|
+
}
|
|
56
|
+
clear() {
|
|
57
|
+
this.policies.clear();
|
|
58
|
+
}
|
|
59
|
+
resolve(inherited) {
|
|
60
|
+
return intersectSubagentCapabilityCeilings(inherited, ...[...this.policies.values()].map(({ ceiling }) => ceiling));
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
function validateText(value, field) {
|
|
64
|
+
if (typeof value !== "string" || !value.trim() || hasControlCharacter(value) || node_buffer.Buffer.byteLength(value.trim(), "utf8") > MAX_TEXT_BYTES) throw new Error(`Invalid capability ceiling ${field}; expected a non-empty string without control characters (max ${MAX_TEXT_BYTES} UTF-8 bytes).`);
|
|
65
|
+
return value.trim();
|
|
66
|
+
}
|
|
67
|
+
function normalizeCeiling(ceiling) {
|
|
68
|
+
if (!ceiling || typeof ceiling !== "object" || Array.isArray(ceiling)) throw new Error("Invalid capability ceiling; expected an object.");
|
|
69
|
+
const hasAllowedTools = Object.hasOwn(ceiling, "allowedTools");
|
|
70
|
+
const hasRequiredTools = Object.hasOwn(ceiling, "requiredTools");
|
|
71
|
+
const hasAllowMcpTools = Object.hasOwn(ceiling, "allowMcpTools");
|
|
72
|
+
const hasAllowedExternalProfiles = Object.hasOwn(ceiling, "allowedExternalProfiles");
|
|
73
|
+
const hasDenyExtensions = Object.hasOwn(ceiling, "denyExtensions");
|
|
74
|
+
if (!hasAllowedTools && !hasRequiredTools && !hasAllowMcpTools && !hasAllowedExternalProfiles && !hasDenyExtensions) throw new Error("Invalid capability ceiling; expected allowedTools, requiredTools, allowMcpTools, allowedExternalProfiles, or denyExtensions.");
|
|
75
|
+
if (hasAllowMcpTools && typeof ceiling.allowMcpTools !== "boolean") throw new Error("Invalid capability ceiling allowMcpTools; expected a boolean.");
|
|
76
|
+
if (hasDenyExtensions && typeof ceiling.denyExtensions !== "boolean") throw new Error("Invalid capability ceiling denyExtensions; expected a boolean.");
|
|
77
|
+
const normalizeTools = (value, field) => {
|
|
78
|
+
if (!Array.isArray(value)) throw new Error(`Invalid capability ceiling ${field}; expected an array.`);
|
|
79
|
+
if (value.length > MAX_ALLOWED_TOOLS) throw new Error(`Invalid capability ceiling ${field}; expected at most ${MAX_ALLOWED_TOOLS} names.`);
|
|
80
|
+
return [...new Set(value.map((tool) => {
|
|
81
|
+
const name = validateText(tool, `${field} entry`);
|
|
82
|
+
if (!TOOL_NAME_PATTERN.test(name)) throw new Error(`Invalid capability ceiling ${field} entry '${name}'.`);
|
|
83
|
+
if (node_buffer.Buffer.byteLength(name, "utf8") > MAX_TOOL_NAME_BYTES) throw new Error(`Invalid capability ceiling ${field} entry '${name}'; max ${MAX_TOOL_NAME_BYTES} UTF-8 bytes.`);
|
|
84
|
+
return name;
|
|
85
|
+
}))].sort((left, right) => left.localeCompare(right));
|
|
86
|
+
};
|
|
87
|
+
const allowedTools = hasAllowedTools ? normalizeTools(ceiling.allowedTools, "allowedTools") : void 0;
|
|
88
|
+
const requiredTools = hasRequiredTools ? normalizeTools(ceiling.requiredTools, "requiredTools") : void 0;
|
|
89
|
+
let allowedExternalProfiles = [];
|
|
90
|
+
if (Object.hasOwn(ceiling, "allowedExternalProfiles")) {
|
|
91
|
+
if (!Array.isArray(ceiling.allowedExternalProfiles)) throw new Error("Invalid capability ceiling allowedExternalProfiles; expected an array.");
|
|
92
|
+
if (ceiling.allowedExternalProfiles.length > MAX_ALLOWED_EXTERNAL_PROFILES) throw new Error(`Invalid capability ceiling allowedExternalProfiles; expected at most ${MAX_ALLOWED_EXTERNAL_PROFILES} names.`);
|
|
93
|
+
allowedExternalProfiles = [...new Set(ceiling.allowedExternalProfiles.map((profile) => {
|
|
94
|
+
const name = validateText(profile, "allowedExternalProfiles entry");
|
|
95
|
+
if (!EXTERNAL_PROFILE_PATTERN.test(name) || node_buffer.Buffer.byteLength(name, "utf8") > MAX_EXTERNAL_PROFILE_NAME_BYTES) throw new Error(`Invalid capability ceiling allowedExternalProfiles entry '${name}'.`);
|
|
96
|
+
return name;
|
|
97
|
+
}))].sort((left, right) => left.localeCompare(right));
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
version: 2,
|
|
101
|
+
...allowedTools ? { allowedTools } : {},
|
|
102
|
+
...requiredTools?.length ? { requiredTools } : {},
|
|
103
|
+
...ceiling.allowMcpTools === true ? { allowMcpTools: true } : {},
|
|
104
|
+
allowedExternalProfiles,
|
|
105
|
+
denyExtensions: ceiling.denyExtensions === true,
|
|
106
|
+
sources: []
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function parseSubagentCapabilityCeiling(value, field = "capability ceiling") {
|
|
110
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`Invalid ${field}; expected an object.`);
|
|
111
|
+
const record = value;
|
|
112
|
+
if (record.version !== 2) throw new Error(`Invalid ${field} version.`);
|
|
113
|
+
const normalized = normalizeCeiling(record);
|
|
114
|
+
const sources = record.sources;
|
|
115
|
+
if (!Array.isArray(sources) || sources.some((source) => typeof source !== "string")) throw new Error(`Invalid ${field} sources; expected an array of strings.`);
|
|
116
|
+
normalized.sources = [...new Set(sources.map((source) => validateText(source, `${field} source`)))].sort();
|
|
117
|
+
return normalized;
|
|
118
|
+
}
|
|
119
|
+
function intersectSubagentCapabilityCeilings(...ceilings) {
|
|
120
|
+
const active = ceilings.filter((ceiling) => ceiling !== void 0);
|
|
121
|
+
if (active.length === 0) return void 0;
|
|
122
|
+
const definedLists = active.filter((ceiling) => ceiling.allowedTools !== void 0).map((ceiling) => new Set(ceiling.allowedTools));
|
|
123
|
+
let allowedTools;
|
|
124
|
+
if (definedLists.length > 0) allowedTools = [...definedLists[0]].filter((tool) => definedLists.every((list) => list.has(tool))).sort();
|
|
125
|
+
const requiredTools = [...new Set(active.flatMap((ceiling) => ceiling.requiredTools ?? []))].filter((tool) => !allowedTools || allowedTools.includes(tool)).sort((left, right) => left.localeCompare(right));
|
|
126
|
+
const profileSets = active.map((ceiling) => new Set(ceiling.allowedExternalProfiles));
|
|
127
|
+
const allowedExternalProfiles = [...profileSets[0]].filter((profile) => profileSets.every((profiles) => profiles.has(profile))).sort((left, right) => left.localeCompare(right));
|
|
128
|
+
return {
|
|
129
|
+
version: 2,
|
|
130
|
+
...allowedTools ? { allowedTools } : {},
|
|
131
|
+
...requiredTools.length ? { requiredTools } : {},
|
|
132
|
+
...active.every((ceiling) => ceiling.allowMcpTools === true) ? { allowMcpTools: true } : {},
|
|
133
|
+
allowedExternalProfiles,
|
|
134
|
+
denyExtensions: active.some((ceiling) => ceiling.denyExtensions),
|
|
135
|
+
sources: [...new Set(active.flatMap((ceiling) => ceiling.sources))].sort()
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function encodeSubagentCapabilityCeiling(ceiling) {
|
|
139
|
+
if (!ceiling) return void 0;
|
|
140
|
+
return node_buffer.Buffer.from(JSON.stringify(ceiling), "utf8").toString("base64url");
|
|
141
|
+
}
|
|
142
|
+
function decodeSubagentCapabilityCeiling(value) {
|
|
143
|
+
if (value === void 0 || value === "") return void 0;
|
|
144
|
+
let parsed;
|
|
145
|
+
try {
|
|
146
|
+
parsed = JSON.parse(node_buffer.Buffer.from(value, "base64url").toString("utf8"));
|
|
147
|
+
} catch (error) {
|
|
148
|
+
throw new Error(`Invalid inherited capability ceiling: ${error instanceof Error ? error.message : String(error)}`);
|
|
149
|
+
}
|
|
150
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed) || parsed.version !== 2) throw new Error("Invalid inherited capability ceiling version.");
|
|
151
|
+
return parseSubagentCapabilityCeiling(parsed, "inherited capability ceiling");
|
|
152
|
+
}
|
|
153
|
+
//#endregion
|
|
154
|
+
Object.defineProperty(exports, "SUBAGENT_CAPABILITY_CEILING_VERSION", {
|
|
155
|
+
enumerable: true,
|
|
156
|
+
get: function() {
|
|
157
|
+
return SUBAGENT_CAPABILITY_CEILING_VERSION;
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
Object.defineProperty(exports, "SubagentCapabilityPolicyStore", {
|
|
161
|
+
enumerable: true,
|
|
162
|
+
get: function() {
|
|
163
|
+
return SubagentCapabilityPolicyStore;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
Object.defineProperty(exports, "decodeSubagentCapabilityCeiling", {
|
|
167
|
+
enumerable: true,
|
|
168
|
+
get: function() {
|
|
169
|
+
return decodeSubagentCapabilityCeiling;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
Object.defineProperty(exports, "encodeSubagentCapabilityCeiling", {
|
|
173
|
+
enumerable: true,
|
|
174
|
+
get: function() {
|
|
175
|
+
return encodeSubagentCapabilityCeiling;
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
Object.defineProperty(exports, "intersectSubagentCapabilityCeilings", {
|
|
179
|
+
enumerable: true,
|
|
180
|
+
get: function() {
|
|
181
|
+
return intersectSubagentCapabilityCeilings;
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
Object.defineProperty(exports, "parseSubagentCapabilityCeiling", {
|
|
185
|
+
enumerable: true,
|
|
186
|
+
get: function() {
|
|
187
|
+
return parseSubagentCapabilityCeiling;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
//# sourceMappingURL=capabilityCeiling-C-Y7H8oC.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilityCeiling-C-Y7H8oC.cjs","names":["Buffer"],"sources":["../src/schemas/team/capabilityCeiling.ts"],"sourcesContent":["/**\n * Capability-ceiling values, intersection, and the child-process codec.\n *\n * Live extension contributions enter through Team's `doom/subagent-policy`\n * Cordis service. Only the resolved ceiling crosses a process boundary, through\n * the versioned environment value encoded here.\n */\n\nimport { Buffer } from 'node:buffer';\n\nimport type { SubagentPolicy } from '../../schemas/subagentPolicy';\nimport { SUBAGENT_CAPABILITY_CEILING_ENV } from '../../types/environment';\n\nexport const SUBAGENT_CAPABILITY_CEILING_VERSION = 2 as const;\nexport { SUBAGENT_CAPABILITY_CEILING_ENV };\n\nconst MAX_TEXT_BYTES = 256;\nconst MAX_TOOL_NAME_BYTES = 128;\nconst MAX_ALLOWED_TOOLS = 256;\nconst MAX_ALLOWED_EXTERNAL_PROFILES = 32;\nconst MAX_EXTERNAL_PROFILE_NAME_BYTES = 128;\nconst EXTERNAL_PROFILE_PATTERN = /^[A-Za-z0-9][A-Za-z0-9/_.:-]+$/u;\nconst TOOL_NAME_PATTERN = /^[A-Za-z0-9_.:-]+$/u;\nconst LAST_C0_CONTROL_CODE = 0x1f;\nconst DELETE_CODE = 0x7f;\n\n/**\n * Ceiling text crosses a process boundary and is rendered in the TUI, so control\n * characters are rejected. Scanning code points avoids a control-character\n * regex, which lints as a hazard even when the escapes are explicit.\n */\nfunction hasControlCharacter(value: string): boolean {\n for (const character of value) {\n const code = character.codePointAt(0);\n if (code !== undefined && (code <= LAST_C0_CONTROL_CODE || code === DELETE_CODE)) return true;\n }\n return false;\n}\n\nexport type SubagentCapabilityCeiling = {\n allowedTools?: readonly string[];\n requiredTools?: readonly string[];\n allowMcpTools?: boolean;\n allowedExternalProfiles?: readonly string[];\n denyExtensions?: boolean;\n};\n\nexport interface ResolvedSubagentCapabilityCeiling {\n version: typeof SUBAGENT_CAPABILITY_CEILING_VERSION;\n allowedTools?: string[];\n requiredTools?: string[];\n allowMcpTools?: boolean;\n allowedExternalProfiles: string[];\n denyExtensions: boolean;\n sources: string[];\n}\n\nexport interface SubagentCapabilityAudit {\n ceiling: ResolvedSubagentCapabilityCeiling;\n requestedTools?: string[];\n effectiveTools: string[];\n removedTools: string[];\n internalTools: string[];\n extensionsDenied: boolean;\n removedExtensionCount: number;\n requestedMcpToolCount: number;\n effectiveMcpTools: string[];\n}\n\ninterface TypedPolicyRegistration {\n generation: string;\n ceiling: ResolvedSubagentCapabilityCeiling;\n}\n\nexport class SubagentCapabilityPolicyStore {\n private readonly policies = new Map<string, TypedPolicyRegistration>();\n\n register(policy: SubagentPolicy, generation: string): void {\n const ceiling = normalizeCeiling({\n ...(policy.allowedTools ? { allowedTools: policy.allowedTools } : {}),\n ...(policy.requiredTools ? { requiredTools: policy.requiredTools } : {}),\n ...(policy.allowMcpTools === true ? { allowMcpTools: true } : {}),\n ...(policy.allowedExternalProfiles ? { allowedExternalProfiles: policy.allowedExternalProfiles } : {}),\n denyExtensions: policy.denyExtensions === true,\n });\n ceiling.sources = [policy.owner];\n this.policies.set(policy.owner, { generation, ceiling });\n }\n\n update(policy: SubagentPolicy, generation: string): void {\n if (this.policies.get(policy.owner)?.generation !== generation) return;\n this.register(policy, generation);\n }\n\n remove(owner: string, generation: string): void {\n if (this.policies.get(owner)?.generation === generation) this.policies.delete(owner);\n }\n\n clear(): void {\n this.policies.clear();\n }\n\n resolve(inherited?: ResolvedSubagentCapabilityCeiling): ResolvedSubagentCapabilityCeiling | undefined {\n return intersectSubagentCapabilityCeilings(inherited, ...[...this.policies.values()].map(({ ceiling }) => ceiling));\n }\n}\n\nfunction validateText(value: unknown, field: string): string {\n if (\n typeof value !== 'string' ||\n !value.trim() ||\n hasControlCharacter(value) ||\n Buffer.byteLength(value.trim(), 'utf8') > MAX_TEXT_BYTES\n ) {\n throw new Error(\n `Invalid capability ceiling ${field}; expected a non-empty string without control characters (max ${MAX_TEXT_BYTES} UTF-8 bytes).`,\n );\n }\n return value.trim();\n}\n\nfunction normalizeCeiling(ceiling: SubagentCapabilityCeiling): ResolvedSubagentCapabilityCeiling {\n if (!ceiling || typeof ceiling !== 'object' || Array.isArray(ceiling)) {\n throw new Error('Invalid capability ceiling; expected an object.');\n }\n const hasAllowedTools = Object.hasOwn(ceiling, 'allowedTools');\n const hasRequiredTools = Object.hasOwn(ceiling, 'requiredTools');\n const hasAllowMcpTools = Object.hasOwn(ceiling, 'allowMcpTools');\n const hasAllowedExternalProfiles = Object.hasOwn(ceiling, 'allowedExternalProfiles');\n const hasDenyExtensions = Object.hasOwn(ceiling, 'denyExtensions');\n if (!hasAllowedTools && !hasRequiredTools && !hasAllowMcpTools && !hasAllowedExternalProfiles && !hasDenyExtensions) {\n throw new Error(\n 'Invalid capability ceiling; expected allowedTools, requiredTools, allowMcpTools, allowedExternalProfiles, or denyExtensions.',\n );\n }\n if (hasAllowMcpTools && typeof ceiling.allowMcpTools !== 'boolean') {\n throw new Error('Invalid capability ceiling allowMcpTools; expected a boolean.');\n }\n if (hasDenyExtensions && typeof ceiling.denyExtensions !== 'boolean') {\n throw new Error('Invalid capability ceiling denyExtensions; expected a boolean.');\n }\n const normalizeTools = (value: readonly string[] | undefined, field: 'allowedTools' | 'requiredTools') => {\n if (!Array.isArray(value)) throw new Error(`Invalid capability ceiling ${field}; expected an array.`);\n if (value.length > MAX_ALLOWED_TOOLS) {\n throw new Error(`Invalid capability ceiling ${field}; expected at most ${MAX_ALLOWED_TOOLS} names.`);\n }\n return [\n ...new Set(\n value.map((tool) => {\n const name = validateText(tool, `${field} entry`);\n if (!TOOL_NAME_PATTERN.test(name)) {\n throw new Error(`Invalid capability ceiling ${field} entry '${name}'.`);\n }\n if (Buffer.byteLength(name, 'utf8') > MAX_TOOL_NAME_BYTES) {\n throw new Error(\n `Invalid capability ceiling ${field} entry '${name}'; max ${MAX_TOOL_NAME_BYTES} UTF-8 bytes.`,\n );\n }\n return name;\n }),\n ),\n ].sort((left, right) => left.localeCompare(right));\n };\n const allowedTools = hasAllowedTools ? normalizeTools(ceiling.allowedTools, 'allowedTools') : undefined;\n const requiredTools = hasRequiredTools ? normalizeTools(ceiling.requiredTools, 'requiredTools') : undefined;\n let allowedExternalProfiles: string[] = [];\n if (Object.hasOwn(ceiling, 'allowedExternalProfiles')) {\n if (!Array.isArray(ceiling.allowedExternalProfiles)) {\n throw new Error('Invalid capability ceiling allowedExternalProfiles; expected an array.');\n }\n if (ceiling.allowedExternalProfiles.length > MAX_ALLOWED_EXTERNAL_PROFILES) {\n throw new Error(\n `Invalid capability ceiling allowedExternalProfiles; expected at most ${MAX_ALLOWED_EXTERNAL_PROFILES} names.`,\n );\n }\n allowedExternalProfiles = [\n ...new Set(\n ceiling.allowedExternalProfiles.map((profile) => {\n const name = validateText(profile, 'allowedExternalProfiles entry');\n if (\n !EXTERNAL_PROFILE_PATTERN.test(name) ||\n Buffer.byteLength(name, 'utf8') > MAX_EXTERNAL_PROFILE_NAME_BYTES\n ) {\n throw new Error(`Invalid capability ceiling allowedExternalProfiles entry '${name}'.`);\n }\n return name;\n }),\n ),\n ].sort((left, right) => left.localeCompare(right));\n }\n return {\n version: SUBAGENT_CAPABILITY_CEILING_VERSION,\n ...(allowedTools ? { allowedTools } : {}),\n ...(requiredTools?.length ? { requiredTools } : {}),\n ...(ceiling.allowMcpTools === true ? { allowMcpTools: true } : {}),\n allowedExternalProfiles,\n denyExtensions: ceiling.denyExtensions === true,\n sources: [],\n };\n}\n\nexport function parseSubagentCapabilityCeiling(\n value: unknown,\n field = 'capability ceiling',\n): ResolvedSubagentCapabilityCeiling {\n if (!value || typeof value !== 'object' || Array.isArray(value)) {\n throw new Error(`Invalid ${field}; expected an object.`);\n }\n const record = value as Record<string, unknown>;\n if (record.version !== SUBAGENT_CAPABILITY_CEILING_VERSION) throw new Error(`Invalid ${field} version.`);\n const normalized = normalizeCeiling(record as SubagentCapabilityCeiling);\n const sources = record.sources;\n if (!Array.isArray(sources) || sources.some((source) => typeof source !== 'string')) {\n throw new Error(`Invalid ${field} sources; expected an array of strings.`);\n }\n normalized.sources = [...new Set(sources.map((source) => validateText(source, `${field} source`)))].sort();\n return normalized;\n}\n\nexport function intersectSubagentCapabilityCeilings(\n ...ceilings: Array<ResolvedSubagentCapabilityCeiling | undefined>\n): ResolvedSubagentCapabilityCeiling | undefined {\n const active = ceilings.filter((ceiling): ceiling is ResolvedSubagentCapabilityCeiling => ceiling !== undefined);\n if (active.length === 0) return undefined;\n const definedLists = active\n .filter((ceiling) => ceiling.allowedTools !== undefined)\n .map((ceiling) => new Set(ceiling.allowedTools));\n let allowedTools: string[] | undefined;\n if (definedLists.length > 0) {\n allowedTools = [...definedLists[0]!].filter((tool) => definedLists.every((list) => list.has(tool))).sort();\n }\n const requiredTools = [...new Set(active.flatMap((ceiling) => ceiling.requiredTools ?? []))]\n .filter((tool) => !allowedTools || allowedTools.includes(tool))\n .sort((left, right) => left.localeCompare(right));\n const profileSets = active.map((ceiling) => new Set(ceiling.allowedExternalProfiles));\n const allowedExternalProfiles = [...profileSets[0]!]\n .filter((profile) => profileSets.every((profiles) => profiles.has(profile)))\n .sort((left, right) => left.localeCompare(right));\n return {\n version: SUBAGENT_CAPABILITY_CEILING_VERSION,\n ...(allowedTools ? { allowedTools } : {}),\n ...(requiredTools.length ? { requiredTools } : {}),\n ...(active.every((ceiling) => ceiling.allowMcpTools === true) ? { allowMcpTools: true } : {}),\n allowedExternalProfiles,\n denyExtensions: active.some((ceiling) => ceiling.denyExtensions),\n sources: [...new Set(active.flatMap((ceiling) => ceiling.sources))].sort(),\n };\n}\n\nexport function encodeSubagentCapabilityCeiling(\n ceiling: ResolvedSubagentCapabilityCeiling | undefined,\n): string | undefined {\n if (!ceiling) return undefined;\n return Buffer.from(JSON.stringify(ceiling), 'utf8').toString('base64url');\n}\n\nexport function decodeSubagentCapabilityCeiling(\n value: string | undefined,\n): ResolvedSubagentCapabilityCeiling | undefined {\n if (value === undefined || value === '') return undefined;\n let parsed: unknown;\n try {\n parsed = JSON.parse(Buffer.from(value, 'base64url').toString('utf8'));\n } catch (error) {\n throw new Error(`Invalid inherited capability ceiling: ${error instanceof Error ? error.message : String(error)}`);\n }\n if (\n !parsed ||\n typeof parsed !== 'object' ||\n Array.isArray(parsed) ||\n (parsed as { version?: unknown }).version !== SUBAGENT_CAPABILITY_CEILING_VERSION\n ) {\n throw new Error('Invalid inherited capability ceiling version.');\n }\n return parseSubagentCapabilityCeiling(parsed, 'inherited capability ceiling');\n}\n"],"mappings":";;;;;;;;;;AAaA,MAAa,sCAAsC;AAGnD,MAAM,iBAAiB;AACvB,MAAM,sBAAsB;AAC5B,MAAM,oBAAoB;AAC1B,MAAM,gCAAgC;AACtC,MAAM,kCAAkC;AACxC,MAAM,2BAA2B;AACjC,MAAM,oBAAoB;AAC1B,MAAM,uBAAuB;AAC7B,MAAM,cAAc;;;;;;AAOpB,SAAS,oBAAoB,OAAwB;CACnD,KAAK,MAAM,aAAa,OAAO;EAC7B,MAAM,OAAO,UAAU,YAAY,CAAC;EACpC,IAAI,SAAS,KAAA,MAAc,QAAQ,wBAAwB,SAAS,cAAc,OAAO;CAC3F;CACA,OAAO;AACT;AAqCA,IAAa,gCAAb,MAA2C;CACzC,2BAA4B,IAAI,IAAqC;CAErE,SAAS,QAAwB,YAA0B;EACzD,MAAM,UAAU,iBAAiB;GAC/B,GAAI,OAAO,eAAe,EAAE,cAAc,OAAO,aAAa,IAAI,CAAC;GACnE,GAAI,OAAO,gBAAgB,EAAE,eAAe,OAAO,cAAc,IAAI,CAAC;GACtE,GAAI,OAAO,kBAAkB,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;GAC/D,GAAI,OAAO,0BAA0B,EAAE,yBAAyB,OAAO,wBAAwB,IAAI,CAAC;GACpG,gBAAgB,OAAO,mBAAmB;EAC5C,CAAC;EACD,QAAQ,UAAU,CAAC,OAAO,KAAK;EAC/B,KAAK,SAA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KAAA;CAChD,IAAI;CACJ,IAAI;EACF,SAAS,KAAK,MAAMA,YAAAA,OAAO,KAAK,OAAO,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC;CACtE,SAAS,OAAO;EACd,MAAM,IAAI,MAAM,yCAAyC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG;CACnH;CACA,IACE,CAAC,UACD,OAAO,WAAW,YAClB,MAAM,QAAQ,MAAM,KACnB,OAAiC,YAAA,GAElC,MAAM,IAAI,MAAM,+CAA+C;CAEjE,OAAO,+BAA+B,QAAQ,8BAA8B;AAC9E"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import "./environment-DrqhrxG_.mjs";
|
|
2
|
+
import { Buffer } from "node:buffer";
|
|
3
|
+
//#region src/schemas/team/capabilityCeiling.ts
|
|
4
|
+
/**
|
|
5
|
+
* Capability-ceiling values, intersection, and the child-process codec.
|
|
6
|
+
*
|
|
7
|
+
* Live extension contributions enter through Team's `doom/subagent-policy`
|
|
8
|
+
* Cordis service. Only the resolved ceiling crosses a process boundary, through
|
|
9
|
+
* the versioned environment value encoded here.
|
|
10
|
+
*/
|
|
11
|
+
const SUBAGENT_CAPABILITY_CEILING_VERSION = 2;
|
|
12
|
+
const MAX_TEXT_BYTES = 256;
|
|
13
|
+
const MAX_TOOL_NAME_BYTES = 128;
|
|
14
|
+
const MAX_ALLOWED_TOOLS = 256;
|
|
15
|
+
const MAX_ALLOWED_EXTERNAL_PROFILES = 32;
|
|
16
|
+
const MAX_EXTERNAL_PROFILE_NAME_BYTES = 128;
|
|
17
|
+
const EXTERNAL_PROFILE_PATTERN = /^[A-Za-z0-9][A-Za-z0-9/_.:-]+$/u;
|
|
18
|
+
const TOOL_NAME_PATTERN = /^[A-Za-z0-9_.:-]+$/u;
|
|
19
|
+
const LAST_C0_CONTROL_CODE = 31;
|
|
20
|
+
const DELETE_CODE = 127;
|
|
21
|
+
/**
|
|
22
|
+
* Ceiling text crosses a process boundary and is rendered in the TUI, so control
|
|
23
|
+
* characters are rejected. Scanning code points avoids a control-character
|
|
24
|
+
* regex, which lints as a hazard even when the escapes are explicit.
|
|
25
|
+
*/
|
|
26
|
+
function hasControlCharacter(value) {
|
|
27
|
+
for (const character of value) {
|
|
28
|
+
const code = character.codePointAt(0);
|
|
29
|
+
if (code !== void 0 && (code <= LAST_C0_CONTROL_CODE || code === DELETE_CODE)) return true;
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
var SubagentCapabilityPolicyStore = class {
|
|
34
|
+
policies = /* @__PURE__ */ new Map();
|
|
35
|
+
register(policy, generation) {
|
|
36
|
+
const ceiling = normalizeCeiling({
|
|
37
|
+
...policy.allowedTools ? { allowedTools: policy.allowedTools } : {},
|
|
38
|
+
...policy.requiredTools ? { requiredTools: policy.requiredTools } : {},
|
|
39
|
+
...policy.allowMcpTools === true ? { allowMcpTools: true } : {},
|
|
40
|
+
...policy.allowedExternalProfiles ? { allowedExternalProfiles: policy.allowedExternalProfiles } : {},
|
|
41
|
+
denyExtensions: policy.denyExtensions === true
|
|
42
|
+
});
|
|
43
|
+
ceiling.sources = [policy.owner];
|
|
44
|
+
this.policies.set(policy.owner, {
|
|
45
|
+
generation,
|
|
46
|
+
ceiling
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
update(policy, generation) {
|
|
50
|
+
if (this.policies.get(policy.owner)?.generation !== generation) return;
|
|
51
|
+
this.register(policy, generation);
|
|
52
|
+
}
|
|
53
|
+
remove(owner, generation) {
|
|
54
|
+
if (this.policies.get(owner)?.generation === generation) this.policies.delete(owner);
|
|
55
|
+
}
|
|
56
|
+
clear() {
|
|
57
|
+
this.policies.clear();
|
|
58
|
+
}
|
|
59
|
+
resolve(inherited) {
|
|
60
|
+
return intersectSubagentCapabilityCeilings(inherited, ...[...this.policies.values()].map(({ ceiling }) => ceiling));
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
function validateText(value, field) {
|
|
64
|
+
if (typeof value !== "string" || !value.trim() || hasControlCharacter(value) || Buffer.byteLength(value.trim(), "utf8") > MAX_TEXT_BYTES) throw new Error(`Invalid capability ceiling ${field}; expected a non-empty string without control characters (max ${MAX_TEXT_BYTES} UTF-8 bytes).`);
|
|
65
|
+
return value.trim();
|
|
66
|
+
}
|
|
67
|
+
function normalizeCeiling(ceiling) {
|
|
68
|
+
if (!ceiling || typeof ceiling !== "object" || Array.isArray(ceiling)) throw new Error("Invalid capability ceiling; expected an object.");
|
|
69
|
+
const hasAllowedTools = Object.hasOwn(ceiling, "allowedTools");
|
|
70
|
+
const hasRequiredTools = Object.hasOwn(ceiling, "requiredTools");
|
|
71
|
+
const hasAllowMcpTools = Object.hasOwn(ceiling, "allowMcpTools");
|
|
72
|
+
const hasAllowedExternalProfiles = Object.hasOwn(ceiling, "allowedExternalProfiles");
|
|
73
|
+
const hasDenyExtensions = Object.hasOwn(ceiling, "denyExtensions");
|
|
74
|
+
if (!hasAllowedTools && !hasRequiredTools && !hasAllowMcpTools && !hasAllowedExternalProfiles && !hasDenyExtensions) throw new Error("Invalid capability ceiling; expected allowedTools, requiredTools, allowMcpTools, allowedExternalProfiles, or denyExtensions.");
|
|
75
|
+
if (hasAllowMcpTools && typeof ceiling.allowMcpTools !== "boolean") throw new Error("Invalid capability ceiling allowMcpTools; expected a boolean.");
|
|
76
|
+
if (hasDenyExtensions && typeof ceiling.denyExtensions !== "boolean") throw new Error("Invalid capability ceiling denyExtensions; expected a boolean.");
|
|
77
|
+
const normalizeTools = (value, field) => {
|
|
78
|
+
if (!Array.isArray(value)) throw new Error(`Invalid capability ceiling ${field}; expected an array.`);
|
|
79
|
+
if (value.length > MAX_ALLOWED_TOOLS) throw new Error(`Invalid capability ceiling ${field}; expected at most ${MAX_ALLOWED_TOOLS} names.`);
|
|
80
|
+
return [...new Set(value.map((tool) => {
|
|
81
|
+
const name = validateText(tool, `${field} entry`);
|
|
82
|
+
if (!TOOL_NAME_PATTERN.test(name)) throw new Error(`Invalid capability ceiling ${field} entry '${name}'.`);
|
|
83
|
+
if (Buffer.byteLength(name, "utf8") > MAX_TOOL_NAME_BYTES) throw new Error(`Invalid capability ceiling ${field} entry '${name}'; max ${MAX_TOOL_NAME_BYTES} UTF-8 bytes.`);
|
|
84
|
+
return name;
|
|
85
|
+
}))].sort((left, right) => left.localeCompare(right));
|
|
86
|
+
};
|
|
87
|
+
const allowedTools = hasAllowedTools ? normalizeTools(ceiling.allowedTools, "allowedTools") : void 0;
|
|
88
|
+
const requiredTools = hasRequiredTools ? normalizeTools(ceiling.requiredTools, "requiredTools") : void 0;
|
|
89
|
+
let allowedExternalProfiles = [];
|
|
90
|
+
if (Object.hasOwn(ceiling, "allowedExternalProfiles")) {
|
|
91
|
+
if (!Array.isArray(ceiling.allowedExternalProfiles)) throw new Error("Invalid capability ceiling allowedExternalProfiles; expected an array.");
|
|
92
|
+
if (ceiling.allowedExternalProfiles.length > MAX_ALLOWED_EXTERNAL_PROFILES) throw new Error(`Invalid capability ceiling allowedExternalProfiles; expected at most ${MAX_ALLOWED_EXTERNAL_PROFILES} names.`);
|
|
93
|
+
allowedExternalProfiles = [...new Set(ceiling.allowedExternalProfiles.map((profile) => {
|
|
94
|
+
const name = validateText(profile, "allowedExternalProfiles entry");
|
|
95
|
+
if (!EXTERNAL_PROFILE_PATTERN.test(name) || Buffer.byteLength(name, "utf8") > MAX_EXTERNAL_PROFILE_NAME_BYTES) throw new Error(`Invalid capability ceiling allowedExternalProfiles entry '${name}'.`);
|
|
96
|
+
return name;
|
|
97
|
+
}))].sort((left, right) => left.localeCompare(right));
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
version: 2,
|
|
101
|
+
...allowedTools ? { allowedTools } : {},
|
|
102
|
+
...requiredTools?.length ? { requiredTools } : {},
|
|
103
|
+
...ceiling.allowMcpTools === true ? { allowMcpTools: true } : {},
|
|
104
|
+
allowedExternalProfiles,
|
|
105
|
+
denyExtensions: ceiling.denyExtensions === true,
|
|
106
|
+
sources: []
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function parseSubagentCapabilityCeiling(value, field = "capability ceiling") {
|
|
110
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`Invalid ${field}; expected an object.`);
|
|
111
|
+
const record = value;
|
|
112
|
+
if (record.version !== 2) throw new Error(`Invalid ${field} version.`);
|
|
113
|
+
const normalized = normalizeCeiling(record);
|
|
114
|
+
const sources = record.sources;
|
|
115
|
+
if (!Array.isArray(sources) || sources.some((source) => typeof source !== "string")) throw new Error(`Invalid ${field} sources; expected an array of strings.`);
|
|
116
|
+
normalized.sources = [...new Set(sources.map((source) => validateText(source, `${field} source`)))].sort();
|
|
117
|
+
return normalized;
|
|
118
|
+
}
|
|
119
|
+
function intersectSubagentCapabilityCeilings(...ceilings) {
|
|
120
|
+
const active = ceilings.filter((ceiling) => ceiling !== void 0);
|
|
121
|
+
if (active.length === 0) return void 0;
|
|
122
|
+
const definedLists = active.filter((ceiling) => ceiling.allowedTools !== void 0).map((ceiling) => new Set(ceiling.allowedTools));
|
|
123
|
+
let allowedTools;
|
|
124
|
+
if (definedLists.length > 0) allowedTools = [...definedLists[0]].filter((tool) => definedLists.every((list) => list.has(tool))).sort();
|
|
125
|
+
const requiredTools = [...new Set(active.flatMap((ceiling) => ceiling.requiredTools ?? []))].filter((tool) => !allowedTools || allowedTools.includes(tool)).sort((left, right) => left.localeCompare(right));
|
|
126
|
+
const profileSets = active.map((ceiling) => new Set(ceiling.allowedExternalProfiles));
|
|
127
|
+
const allowedExternalProfiles = [...profileSets[0]].filter((profile) => profileSets.every((profiles) => profiles.has(profile))).sort((left, right) => left.localeCompare(right));
|
|
128
|
+
return {
|
|
129
|
+
version: 2,
|
|
130
|
+
...allowedTools ? { allowedTools } : {},
|
|
131
|
+
...requiredTools.length ? { requiredTools } : {},
|
|
132
|
+
...active.every((ceiling) => ceiling.allowMcpTools === true) ? { allowMcpTools: true } : {},
|
|
133
|
+
allowedExternalProfiles,
|
|
134
|
+
denyExtensions: active.some((ceiling) => ceiling.denyExtensions),
|
|
135
|
+
sources: [...new Set(active.flatMap((ceiling) => ceiling.sources))].sort()
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function encodeSubagentCapabilityCeiling(ceiling) {
|
|
139
|
+
if (!ceiling) return void 0;
|
|
140
|
+
return Buffer.from(JSON.stringify(ceiling), "utf8").toString("base64url");
|
|
141
|
+
}
|
|
142
|
+
function decodeSubagentCapabilityCeiling(value) {
|
|
143
|
+
if (value === void 0 || value === "") return void 0;
|
|
144
|
+
let parsed;
|
|
145
|
+
try {
|
|
146
|
+
parsed = JSON.parse(Buffer.from(value, "base64url").toString("utf8"));
|
|
147
|
+
} catch (error) {
|
|
148
|
+
throw new Error(`Invalid inherited capability ceiling: ${error instanceof Error ? error.message : String(error)}`);
|
|
149
|
+
}
|
|
150
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed) || parsed.version !== 2) throw new Error("Invalid inherited capability ceiling version.");
|
|
151
|
+
return parseSubagentCapabilityCeiling(parsed, "inherited capability ceiling");
|
|
152
|
+
}
|
|
153
|
+
//#endregion
|
|
154
|
+
export { intersectSubagentCapabilityCeilings as a, encodeSubagentCapabilityCeiling as i, SubagentCapabilityPolicyStore as n, parseSubagentCapabilityCeiling as o, decodeSubagentCapabilityCeiling as r, SUBAGENT_CAPABILITY_CEILING_VERSION as t };
|
|
155
|
+
|
|
156
|
+
//# sourceMappingURL=capabilityCeiling-CF7kAS18.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilityCeiling-CF7kAS18.mjs","names":[],"sources":["../src/schemas/team/capabilityCeiling.ts"],"sourcesContent":["/**\n * Capability-ceiling values, intersection, and the child-process codec.\n *\n * Live extension contributions enter through Team's `doom/subagent-policy`\n * Cordis service. Only the resolved ceiling crosses a process boundary, through\n * the versioned environment value encoded here.\n */\n\nimport { Buffer } from 'node:buffer';\n\nimport type { SubagentPolicy } from '../../schemas/subagentPolicy';\nimport { SUBAGENT_CAPABILITY_CEILING_ENV } from '../../types/environment';\n\nexport const SUBAGENT_CAPABILITY_CEILING_VERSION = 2 as const;\nexport { SUBAGENT_CAPABILITY_CEILING_ENV };\n\nconst MAX_TEXT_BYTES = 256;\nconst MAX_TOOL_NAME_BYTES = 128;\nconst MAX_ALLOWED_TOOLS = 256;\nconst MAX_ALLOWED_EXTERNAL_PROFILES = 32;\nconst MAX_EXTERNAL_PROFILE_NAME_BYTES = 128;\nconst EXTERNAL_PROFILE_PATTERN = /^[A-Za-z0-9][A-Za-z0-9/_.:-]+$/u;\nconst TOOL_NAME_PATTERN = /^[A-Za-z0-9_.:-]+$/u;\nconst LAST_C0_CONTROL_CODE = 0x1f;\nconst DELETE_CODE = 0x7f;\n\n/**\n * Ceiling text crosses a process boundary and is rendered in the TUI, so control\n * characters are rejected. Scanning code points avoids a control-character\n * regex, which lints as a hazard even when the escapes are explicit.\n */\nfunction hasControlCharacter(value: string): boolean {\n for (const character of value) {\n const code = character.codePointAt(0);\n if (code !== undefined && (code <= LAST_C0_CONTROL_CODE || code === DELETE_CODE)) return true;\n }\n return false;\n}\n\nexport type SubagentCapabilityCeiling = {\n allowedTools?: readonly string[];\n requiredTools?: readonly string[];\n allowMcpTools?: boolean;\n allowedExternalProfiles?: readonly string[];\n denyExtensions?: boolean;\n};\n\nexport interface ResolvedSubagentCapabilityCeiling {\n version: typeof SUBAGENT_CAPABILITY_CEILING_VERSION;\n allowedTools?: string[];\n requiredTools?: string[];\n allowMcpTools?: boolean;\n allowedExternalProfiles: string[];\n denyExtensions: boolean;\n sources: string[];\n}\n\nexport interface SubagentCapabilityAudit {\n ceiling: ResolvedSubagentCapabilityCeiling;\n requestedTools?: string[];\n effectiveTools: string[];\n removedTools: string[];\n internalTools: string[];\n extensionsDenied: boolean;\n removedExtensionCount: number;\n requestedMcpToolCount: number;\n effectiveMcpTools: string[];\n}\n\ninterface TypedPolicyRegistration {\n generation: string;\n ceiling: ResolvedSubagentCapabilityCeiling;\n}\n\nexport class SubagentCapabilityPolicyStore {\n private readonly policies = new Map<string, TypedPolicyRegistration>();\n\n register(policy: SubagentPolicy, generation: string): void {\n const ceiling = normalizeCeiling({\n ...(policy.allowedTools ? { allowedTools: policy.allowedTools } : {}),\n ...(policy.requiredTools ? { requiredTools: policy.requiredTools } : {}),\n ...(policy.allowMcpTools === true ? { allowMcpTools: true } : {}),\n ...(policy.allowedExternalProfiles ? { allowedExternalProfiles: policy.allowedExternalProfiles } : {}),\n denyExtensions: policy.denyExtensions === true,\n });\n ceiling.sources = [policy.owner];\n this.policies.set(policy.owner, { generation, ceiling });\n }\n\n update(policy: SubagentPolicy, generation: string): void {\n if (this.policies.get(policy.owner)?.generation !== generation) return;\n this.register(policy, generation);\n }\n\n remove(owner: string, generation: string): void {\n if (this.policies.get(owner)?.generation === generation) this.policies.delete(owner);\n }\n\n clear(): void {\n this.policies.clear();\n }\n\n resolve(inherited?: ResolvedSubagentCapabilityCeiling): ResolvedSubagentCapabilityCeiling | undefined {\n return intersectSubagentCapabilityCeilings(inherited, ...[...this.policies.values()].map(({ ceiling }) => ceiling));\n }\n}\n\nfunction validateText(value: unknown, field: string): string {\n if (\n typeof value !== 'string' ||\n !value.trim() ||\n hasControlCharacter(value) ||\n Buffer.byteLength(value.trim(), 'utf8') > MAX_TEXT_BYTES\n ) {\n throw new Error(\n `Invalid capability ceiling ${field}; expected a non-empty string without control characters (max ${MAX_TEXT_BYTES} UTF-8 bytes).`,\n );\n }\n return value.trim();\n}\n\nfunction normalizeCeiling(ceiling: SubagentCapabilityCeiling): ResolvedSubagentCapabilityCeiling {\n if (!ceiling || typeof ceiling !== 'object' || Array.isArray(ceiling)) {\n throw new Error('Invalid capability ceiling; expected an object.');\n }\n const hasAllowedTools = Object.hasOwn(ceiling, 'allowedTools');\n const hasRequiredTools = Object.hasOwn(ceiling, 'requiredTools');\n const hasAllowMcpTools = Object.hasOwn(ceiling, 'allowMcpTools');\n const hasAllowedExternalProfiles = Object.hasOwn(ceiling, 'allowedExternalProfiles');\n const hasDenyExtensions = Object.hasOwn(ceiling, 'denyExtensions');\n if (!hasAllowedTools && !hasRequiredTools && !hasAllowMcpTools && !hasAllowedExternalProfiles && !hasDenyExtensions) {\n throw new Error(\n 'Invalid capability ceiling; expected allowedTools, requiredTools, allowMcpTools, allowedExternalProfiles, or denyExtensions.',\n );\n }\n if (hasAllowMcpTools && typeof ceiling.allowMcpTools !== 'boolean') {\n throw new Error('Invalid capability ceiling allowMcpTools; expected a boolean.');\n }\n if (hasDenyExtensions && typeof ceiling.denyExtensions !== 'boolean') {\n throw new Error('Invalid capability ceiling denyExtensions; expected a boolean.');\n }\n const normalizeTools = (value: readonly string[] | undefined, field: 'allowedTools' | 'requiredTools') => {\n if (!Array.isArray(value)) throw new Error(`Invalid capability ceiling ${field}; expected an array.`);\n if (value.length > MAX_ALLOWED_TOOLS) {\n throw new Error(`Invalid capability ceiling ${field}; expected at most ${MAX_ALLOWED_TOOLS} names.`);\n }\n return [\n ...new Set(\n value.map((tool) => {\n const name = validateText(tool, `${field} entry`);\n if (!TOOL_NAME_PATTERN.test(name)) {\n throw new Error(`Invalid capability ceiling ${field} entry '${name}'.`);\n }\n if (Buffer.byteLength(name, 'utf8') > MAX_TOOL_NAME_BYTES) {\n throw new Error(\n `Invalid capability ceiling ${field} entry '${name}'; max ${MAX_TOOL_NAME_BYTES} UTF-8 bytes.`,\n );\n }\n return name;\n }),\n ),\n ].sort((left, right) => left.localeCompare(right));\n };\n const allowedTools = hasAllowedTools ? normalizeTools(ceiling.allowedTools, 'allowedTools') : undefined;\n const requiredTools = hasRequiredTools ? normalizeTools(ceiling.requiredTools, 'requiredTools') : undefined;\n let allowedExternalProfiles: string[] = [];\n if (Object.hasOwn(ceiling, 'allowedExternalProfiles')) {\n if (!Array.isArray(ceiling.allowedExternalProfiles)) {\n throw new Error('Invalid capability ceiling allowedExternalProfiles; expected an array.');\n }\n if (ceiling.allowedExternalProfiles.length > MAX_ALLOWED_EXTERNAL_PROFILES) {\n throw new Error(\n `Invalid capability ceiling allowedExternalProfiles; expected at most ${MAX_ALLOWED_EXTERNAL_PROFILES} names.`,\n );\n }\n allowedExternalProfiles = [\n ...new Set(\n ceiling.allowedExternalProfiles.map((profile) => {\n const name = validateText(profile, 'allowedExternalProfiles entry');\n if (\n !EXTERNAL_PROFILE_PATTERN.test(name) ||\n Buffer.byteLength(name, 'utf8') > MAX_EXTERNAL_PROFILE_NAME_BYTES\n ) {\n throw new Error(`Invalid capability ceiling allowedExternalProfiles entry '${name}'.`);\n }\n return name;\n }),\n ),\n ].sort((left, right) => left.localeCompare(right));\n }\n return {\n version: SUBAGENT_CAPABILITY_CEILING_VERSION,\n ...(allowedTools ? { allowedTools } : {}),\n ...(requiredTools?.length ? { requiredTools } : {}),\n ...(ceiling.allowMcpTools === true ? { allowMcpTools: true } : {}),\n allowedExternalProfiles,\n denyExtensions: ceiling.denyExtensions === true,\n sources: [],\n };\n}\n\nexport function parseSubagentCapabilityCeiling(\n value: unknown,\n field = 'capability ceiling',\n): ResolvedSubagentCapabilityCeiling {\n if (!value || typeof value !== 'object' || Array.isArray(value)) {\n throw new Error(`Invalid ${field}; expected an object.`);\n }\n const record = value as Record<string, unknown>;\n if (record.version !== SUBAGENT_CAPABILITY_CEILING_VERSION) throw new Error(`Invalid ${field} version.`);\n const normalized = normalizeCeiling(record as SubagentCapabilityCeiling);\n const sources = record.sources;\n if (!Array.isArray(sources) || sources.some((source) => typeof source !== 'string')) {\n throw new Error(`Invalid ${field} sources; expected an array of strings.`);\n }\n normalized.sources = [...new Set(sources.map((source) => validateText(source, `${field} source`)))].sort();\n return normalized;\n}\n\nexport function intersectSubagentCapabilityCeilings(\n ...ceilings: Array<ResolvedSubagentCapabilityCeiling | undefined>\n): ResolvedSubagentCapabilityCeiling | undefined {\n const active = ceilings.filter((ceiling): ceiling is ResolvedSubagentCapabilityCeiling => ceiling !== undefined);\n if (active.length === 0) return undefined;\n const definedLists = active\n .filter((ceiling) => ceiling.allowedTools !== undefined)\n .map((ceiling) => new Set(ceiling.allowedTools));\n let allowedTools: string[] | undefined;\n if (definedLists.length > 0) {\n allowedTools = [...definedLists[0]!].filter((tool) => definedLists.every((list) => list.has(tool))).sort();\n }\n const requiredTools = [...new Set(active.flatMap((ceiling) => ceiling.requiredTools ?? []))]\n .filter((tool) => !allowedTools || allowedTools.includes(tool))\n .sort((left, right) => left.localeCompare(right));\n const profileSets = active.map((ceiling) => new Set(ceiling.allowedExternalProfiles));\n const allowedExternalProfiles = [...profileSets[0]!]\n .filter((profile) => profileSets.every((profiles) => profiles.has(profile)))\n .sort((left, right) => left.localeCompare(right));\n return {\n version: SUBAGENT_CAPABILITY_CEILING_VERSION,\n ...(allowedTools ? { allowedTools } : {}),\n ...(requiredTools.length ? { requiredTools } : {}),\n ...(active.every((ceiling) => ceiling.allowMcpTools === true) ? { allowMcpTools: true } : {}),\n allowedExternalProfiles,\n denyExtensions: active.some((ceiling) => ceiling.denyExtensions),\n sources: [...new Set(active.flatMap((ceiling) => ceiling.sources))].sort(),\n };\n}\n\nexport function encodeSubagentCapabilityCeiling(\n ceiling: ResolvedSubagentCapabilityCeiling | undefined,\n): string | undefined {\n if (!ceiling) return undefined;\n return Buffer.from(JSON.stringify(ceiling), 'utf8').toString('base64url');\n}\n\nexport function decodeSubagentCapabilityCeiling(\n value: string | undefined,\n): ResolvedSubagentCapabilityCeiling | undefined {\n if (value === undefined || value === '') return undefined;\n let parsed: unknown;\n try {\n parsed = JSON.parse(Buffer.from(value, 'base64url').toString('utf8'));\n } catch (error) {\n throw new Error(`Invalid inherited capability ceiling: ${error instanceof Error ? error.message : String(error)}`);\n }\n if (\n !parsed ||\n typeof parsed !== 'object' ||\n Array.isArray(parsed) ||\n (parsed as { version?: unknown }).version !== SUBAGENT_CAPABILITY_CEILING_VERSION\n ) {\n throw new Error('Invalid inherited capability ceiling version.');\n }\n return parseSubagentCapabilityCeiling(parsed, 'inherited capability ceiling');\n}\n"],"mappings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
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_environment = require("./environment-CaCW3SgT.cjs");
|
|
3
|
+
const require_capabilityCeiling = require("./capabilityCeiling-C-Y7H8oC.cjs");
|
|
4
|
+
exports.SUBAGENT_CAPABILITY_CEILING_ENV = require_environment.SUBAGENT_CAPABILITY_CEILING_ENV;
|
|
5
|
+
exports.SUBAGENT_CAPABILITY_CEILING_VERSION = require_capabilityCeiling.SUBAGENT_CAPABILITY_CEILING_VERSION;
|
|
6
|
+
exports.SubagentCapabilityPolicyStore = require_capabilityCeiling.SubagentCapabilityPolicyStore;
|
|
7
|
+
exports.decodeSubagentCapabilityCeiling = require_capabilityCeiling.decodeSubagentCapabilityCeiling;
|
|
8
|
+
exports.encodeSubagentCapabilityCeiling = require_capabilityCeiling.encodeSubagentCapabilityCeiling;
|
|
9
|
+
exports.intersectSubagentCapabilityCeilings = require_capabilityCeiling.intersectSubagentCapabilityCeilings;
|
|
10
|
+
exports.parseSubagentCapabilityCeiling = require_capabilityCeiling.parseSubagentCapabilityCeiling;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { r as SubagentPolicy } from "./subagentPolicy-ALJam4GN.mjs";
|
|
2
|
+
import { y as SUBAGENT_CAPABILITY_CEILING_ENV } from "./environment-ma5oQ7uM.mjs";
|
|
3
|
+
//#region src/schemas/team/capabilityCeiling.d.ts
|
|
4
|
+
export declare const SUBAGENT_CAPABILITY_CEILING_VERSION: 2;
|
|
5
|
+
export type SubagentCapabilityCeiling = {
|
|
6
|
+
allowedTools?: readonly string[];
|
|
7
|
+
requiredTools?: readonly string[];
|
|
8
|
+
allowMcpTools?: boolean;
|
|
9
|
+
allowedExternalProfiles?: readonly string[];
|
|
10
|
+
denyExtensions?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export interface ResolvedSubagentCapabilityCeiling {
|
|
13
|
+
version: typeof SUBAGENT_CAPABILITY_CEILING_VERSION;
|
|
14
|
+
allowedTools?: string[];
|
|
15
|
+
requiredTools?: string[];
|
|
16
|
+
allowMcpTools?: boolean;
|
|
17
|
+
allowedExternalProfiles: string[];
|
|
18
|
+
denyExtensions: boolean;
|
|
19
|
+
sources: string[];
|
|
20
|
+
}
|
|
21
|
+
export interface SubagentCapabilityAudit {
|
|
22
|
+
ceiling: ResolvedSubagentCapabilityCeiling;
|
|
23
|
+
requestedTools?: string[];
|
|
24
|
+
effectiveTools: string[];
|
|
25
|
+
removedTools: string[];
|
|
26
|
+
internalTools: string[];
|
|
27
|
+
extensionsDenied: boolean;
|
|
28
|
+
removedExtensionCount: number;
|
|
29
|
+
requestedMcpToolCount: number;
|
|
30
|
+
effectiveMcpTools: string[];
|
|
31
|
+
}
|
|
32
|
+
export declare class SubagentCapabilityPolicyStore {
|
|
33
|
+
private readonly policies;
|
|
34
|
+
register(policy: SubagentPolicy, generation: string): void;
|
|
35
|
+
update(policy: SubagentPolicy, generation: string): void;
|
|
36
|
+
remove(owner: string, generation: string): void;
|
|
37
|
+
clear(): void;
|
|
38
|
+
resolve(inherited?: ResolvedSubagentCapabilityCeiling): ResolvedSubagentCapabilityCeiling | undefined;
|
|
39
|
+
}
|
|
40
|
+
export declare function parseSubagentCapabilityCeiling(value: unknown, field?: string): ResolvedSubagentCapabilityCeiling;
|
|
41
|
+
export declare function intersectSubagentCapabilityCeilings(...ceilings: Array<ResolvedSubagentCapabilityCeiling | undefined>): ResolvedSubagentCapabilityCeiling | undefined;
|
|
42
|
+
export declare function encodeSubagentCapabilityCeiling(ceiling: ResolvedSubagentCapabilityCeiling | undefined): string | undefined;
|
|
43
|
+
export declare function decodeSubagentCapabilityCeiling(value: string | undefined): ResolvedSubagentCapabilityCeiling | undefined;
|
|
44
|
+
//#endregion
|
|
45
|
+
export { SUBAGENT_CAPABILITY_CEILING_ENV };
|
|
46
|
+
//# sourceMappingURL=capabilityCeiling.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilityCeiling.d.mts","names":[],"sources":["../src/schemas/team/capabilityCeiling.ts"],"mappings":";;;qBAaa;YA0BD;EACV;EACA;EACA;EACA;EACA;;iBAGe;EACf,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA;;iBAGe;EACf,SAAS;EACT;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;qBAQW;mBACM;EAEjB,SAAS,QAAQ,gBAAgB;EAYjC,OAAO,QAAQ,gBAAgB;EAK/B,OAAO,eAAe;EAItB;EAIA,QAAQ,YAAY,oCAAoC;;wBAmG1C,+BACd,gBACA,iBACC;wBAea,uCACX,UAAU,MAAM,iDAClB;wBA4Ba,gCACd,SAAS;wBAMK,gCACd,4BACC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { y as SUBAGENT_CAPABILITY_CEILING_ENV } from "./environment-DrqhrxG_.mjs";
|
|
2
|
+
import { a as intersectSubagentCapabilityCeilings, i as encodeSubagentCapabilityCeiling, n as SubagentCapabilityPolicyStore, o as parseSubagentCapabilityCeiling, r as decodeSubagentCapabilityCeiling, t as SUBAGENT_CAPABILITY_CEILING_VERSION } from "./capabilityCeiling-CF7kAS18.mjs";
|
|
3
|
+
export { SUBAGENT_CAPABILITY_CEILING_ENV, SUBAGENT_CAPABILITY_CEILING_VERSION, SubagentCapabilityPolicyStore, decodeSubagentCapabilityCeiling, encodeSubagentCapabilityCeiling, intersectSubagentCapabilityCeilings, parseSubagentCapabilityCeiling };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/schemas/team/delegation.ts
|
|
3
|
+
/**
|
|
4
|
+
* Subagent delegation - a cross-extension event protocol.
|
|
5
|
+
*
|
|
6
|
+
* Delegation lets another extension ask this runtime to run a subagent without
|
|
7
|
+
* depending on its internals: the requester emits a request event and receives
|
|
8
|
+
* started/update/response events back over the host event bus.
|
|
9
|
+
*
|
|
10
|
+
* Two generations coexist. V1 correlates purely by `requestId`. V2 adds
|
|
11
|
+
* `ownerRunId` and `nodeId` so one owner can fan out to many nodes and have each
|
|
12
|
+
* reply routed back, and it carries a typed `result` request.
|
|
13
|
+
*
|
|
14
|
+
* PROTOCOL COMPATIBILITY (do not change):
|
|
15
|
+
* The event names and version numbers below are shared with po-subagents
|
|
16
|
+
* and with doom-task and agiflow-pi-extension, which speak this protocol today.
|
|
17
|
+
* The event names deliberately keep their `prompt-template:` prefix: that is the
|
|
18
|
+
* established transport, and renaming it would silently stop delivery. Pinned by
|
|
19
|
+
* contract tests.
|
|
20
|
+
*
|
|
21
|
+
* AVOID:
|
|
22
|
+
* - Adding a required field to an existing version; add a version instead
|
|
23
|
+
*/
|
|
24
|
+
const SUBAGENT_DELEGATION_PROTOCOL_VERSION = 1;
|
|
25
|
+
const SUBAGENT_DELEGATION_V2_PROTOCOL_VERSION = 2;
|
|
26
|
+
const SUBAGENT_DELEGATION_REQUEST_EVENT = "prompt-template:subagent:request";
|
|
27
|
+
const SUBAGENT_DELEGATION_STARTED_EVENT = "prompt-template:subagent:started";
|
|
28
|
+
const SUBAGENT_DELEGATION_UPDATE_EVENT = "prompt-template:subagent:update";
|
|
29
|
+
const SUBAGENT_DELEGATION_RESPONSE_EVENT = "prompt-template:subagent:response";
|
|
30
|
+
const SUBAGENT_DELEGATION_CANCEL_EVENT = "prompt-template:subagent:cancel";
|
|
31
|
+
//#endregion
|
|
32
|
+
exports.SUBAGENT_DELEGATION_CANCEL_EVENT = SUBAGENT_DELEGATION_CANCEL_EVENT;
|
|
33
|
+
exports.SUBAGENT_DELEGATION_PROTOCOL_VERSION = SUBAGENT_DELEGATION_PROTOCOL_VERSION;
|
|
34
|
+
exports.SUBAGENT_DELEGATION_REQUEST_EVENT = SUBAGENT_DELEGATION_REQUEST_EVENT;
|
|
35
|
+
exports.SUBAGENT_DELEGATION_RESPONSE_EVENT = SUBAGENT_DELEGATION_RESPONSE_EVENT;
|
|
36
|
+
exports.SUBAGENT_DELEGATION_STARTED_EVENT = SUBAGENT_DELEGATION_STARTED_EVENT;
|
|
37
|
+
exports.SUBAGENT_DELEGATION_UPDATE_EVENT = SUBAGENT_DELEGATION_UPDATE_EVENT;
|
|
38
|
+
exports.SUBAGENT_DELEGATION_V2_PROTOCOL_VERSION = SUBAGENT_DELEGATION_V2_PROTOCOL_VERSION;
|
|
39
|
+
var _agimon_ai_po_core_delegation = require("@agimon-ai/po-core/delegation");
|
|
40
|
+
Object.keys(_agimon_ai_po_core_delegation).forEach(function(k) {
|
|
41
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function() {
|
|
44
|
+
return _agimon_ai_po_core_delegation[k];
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=delegation.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegation.cjs","names":[],"sources":["../src/schemas/team/delegation.ts"],"sourcesContent":["/**\n * Subagent delegation - a cross-extension event protocol.\n *\n * Delegation lets another extension ask this runtime to run a subagent without\n * depending on its internals: the requester emits a request event and receives\n * started/update/response events back over the host event bus.\n *\n * Two generations coexist. V1 correlates purely by `requestId`. V2 adds\n * `ownerRunId` and `nodeId` so one owner can fan out to many nodes and have each\n * reply routed back, and it carries a typed `result` request.\n *\n * PROTOCOL COMPATIBILITY (do not change):\n * The event names and version numbers below are shared with po-subagents\n * and with doom-task and agiflow-pi-extension, which speak this protocol today.\n * The event names deliberately keep their `prompt-template:` prefix: that is the\n * established transport, and renaming it would silently stop delivery. Pinned by\n * contract tests.\n *\n * AVOID:\n * - Adding a required field to an existing version; add a version instead\n */\n\nexport const SUBAGENT_DELEGATION_PROTOCOL_VERSION = 1 as const;\nexport const SUBAGENT_DELEGATION_V2_PROTOCOL_VERSION = 2 as const;\n\n// This is the established extension-to-extension transport. The public API\n// intentionally reuses it instead of adding a second event protocol.\nexport const SUBAGENT_DELEGATION_REQUEST_EVENT = 'prompt-template:subagent:request';\nexport const SUBAGENT_DELEGATION_STARTED_EVENT = 'prompt-template:subagent:started';\nexport const SUBAGENT_DELEGATION_UPDATE_EVENT = 'prompt-template:subagent:update';\nexport const SUBAGENT_DELEGATION_RESPONSE_EVENT = 'prompt-template:subagent:response';\nexport const SUBAGENT_DELEGATION_CANCEL_EVENT = 'prompt-template:subagent:cancel';\n\nexport interface SubagentDelegationTurnBudget {\n maxTurns: number;\n graceTurns?: number;\n}\n\nexport interface SubagentDelegationToolBudget {\n soft?: number;\n hard: number;\n block?: string[] | '*';\n}\n\nexport interface SubagentDelegationAgentContract {\n version: 1;\n}\n\nexport type SubagentDelegationJsonSchemaObject = Record<string, unknown>;\n\nexport interface SubagentDelegationExecutionResult {\n status: 'completed' | 'failed' | 'paused' | 'stopped' | 'detached';\n success: boolean;\n exitCode: number;\n error?: string;\n interrupted?: boolean;\n timedOut?: boolean;\n stopped?: boolean;\n detached?: boolean;\n}\n\nexport interface SubagentDelegationReviewResult {\n status: 'not-requested' | 'review-required' | 'reviewed' | 'blockers';\n findings?: Array<{ severity: 'blocker' | 'non-blocking'; file?: string; issue: string; rationale: string }>;\n}\n\nexport interface SubagentDelegationEffectsResult {\n fileMutation?: {\n status: 'not-requested' | 'not-applicable' | 'observed' | 'missing';\n expected: boolean;\n attempted: boolean;\n message?: string;\n };\n}\n\nexport type SubagentDelegationAcceptanceEvidence =\n | 'changed-files'\n | 'tests-added'\n | 'commands-run'\n | 'validation-output'\n | 'residual-risks'\n | 'no-staged-files'\n | 'diff-summary'\n | 'review-findings'\n | 'manual-notes';\n\nexport interface SubagentDelegationAcceptanceCriterion {\n id: string;\n must: string;\n evidence?: SubagentDelegationAcceptanceEvidence[];\n severity?: 'required' | 'recommended';\n}\n\nexport interface SubagentDelegationAcceptanceVerifyCommand {\n id: string;\n command: string;\n timeoutMs?: number;\n cwd?: string;\n env?: Record<string, string>;\n allowFailure?: boolean;\n}\n\nexport interface SubagentDelegationAcceptanceReview {\n agent?: string;\n focus?: string;\n required?: boolean;\n}\n\ninterface SubagentDelegationAcceptanceFields {\n criteria?: Array<string | SubagentDelegationAcceptanceCriterion>;\n evidence?: SubagentDelegationAcceptanceEvidence[];\n verify?: SubagentDelegationAcceptanceVerifyCommand[];\n review?: SubagentDelegationAcceptanceReview | false;\n stopRules?: string[];\n}\n\nexport type SubagentDelegationAcceptanceConfig = SubagentDelegationAcceptanceFields &\n ({ level: 'none'; reason: string } | { level?: 'auto' | 'attested' | 'checked' | 'verified'; reason?: string });\n\nexport type SubagentDelegationAcceptance =\n | 'auto'\n | 'attested'\n | 'checked'\n | 'verified'\n | false\n | SubagentDelegationAcceptanceConfig;\n\nexport interface SubagentDelegationRequest {\n version: typeof SUBAGENT_DELEGATION_PROTOCOL_VERSION;\n requestId: string;\n agent: string;\n task: string;\n context: 'fresh' | 'fork';\n cwd: string;\n model?: string;\n timeoutMs?: number;\n turnBudget?: SubagentDelegationTurnBudget;\n toolBudget?: SubagentDelegationToolBudget;\n skill?: string | string[] | boolean;\n output?: string | boolean;\n outputMode?: 'inline' | 'file-only';\n outputSchema?: SubagentDelegationJsonSchemaObject;\n agentContract?: SubagentDelegationAgentContract;\n acceptance?: SubagentDelegationAcceptance;\n artifacts?: boolean;\n /** Foreground remains the compatibility default. */\n runMode?: 'foreground' | 'detached';\n /** Optional task identity shown to active root-session teammates. */\n teamTask?: { id: string; subject: string };\n}\n\nexport interface SubagentDelegationStarted {\n version: typeof SUBAGENT_DELEGATION_PROTOCOL_VERSION;\n requestId: string;\n runId?: string;\n}\n\nexport interface SubagentDelegationUpdate extends SubagentDelegationStarted {\n runId?: string;\n currentTool?: string;\n currentToolArgs?: string;\n recentOutput?: string;\n recentOutputLines?: string[];\n recentTools?: Array<{ tool: string; args: string }>;\n model?: string;\n toolCount?: number;\n durationMs?: number;\n tokens?: number;\n}\n\nexport type SubagentDelegationStatus =\n | 'completed'\n | 'failed'\n | 'timed_out'\n | 'cancelled'\n | 'interrupted'\n | 'turn_budget_exhausted'\n | 'tool_budget_exhausted'\n | 'structured_output_failed'\n | 'acceptance_failed'\n | 'invalid_request'\n | 'unavailable_context';\n\nexport type SubagentDelegationAcceptanceStatus =\n | 'pending'\n | 'not-required'\n | 'claimed'\n | 'attested'\n | 'checked'\n | 'verified'\n | 'review-required'\n | 'reviewed'\n | 'accepted'\n | 'rejected';\n\nexport interface SubagentDelegationAcceptanceResult {\n status: SubagentDelegationAcceptanceStatus;\n evidenceStatus: Exclude<SubagentDelegationAcceptanceStatus, 'review-required' | 'reviewed' | 'accepted'>;\n explicit: boolean;\n}\n\nexport interface SubagentDelegationResponse extends SubagentDelegationStarted {\n status: SubagentDelegationStatus;\n error?: string;\n runId?: string;\n childIndex?: number;\n agent?: string;\n model?: string;\n exitCode?: number;\n execution?: SubagentDelegationExecutionResult;\n output?: string;\n outputPath?: string;\n sessionFile?: string;\n acceptance?: SubagentDelegationAcceptanceResult;\n review?: SubagentDelegationReviewResult;\n effects?: SubagentDelegationEffectsResult;\n turns?: number;\n toolCount?: number;\n durationMs?: number;\n tokens?: number;\n warnings?: string[];\n}\n\nexport interface SubagentDelegationCancel extends SubagentDelegationStarted {}\n\nexport type SubagentDelegationV2Thinking = 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';\n\nexport type SubagentDelegationV2ResultRequest =\n | { kind: 'text' }\n | { kind: 'structured'; schema: SubagentDelegationJsonSchemaObject };\n\nexport interface SubagentDelegationV2Request {\n version: typeof SUBAGENT_DELEGATION_V2_PROTOCOL_VERSION;\n requestId: string;\n ownerRunId: string;\n nodeId: string;\n agent: string;\n task: string;\n context: 'fresh' | 'fork';\n cwd: string;\n model?: string;\n thinking?: SubagentDelegationV2Thinking;\n timeoutMs?: number;\n turnBudget?: SubagentDelegationTurnBudget;\n toolBudget?: SubagentDelegationToolBudget;\n skill?: string | string[] | boolean;\n artifacts?: boolean;\n result: SubagentDelegationV2ResultRequest;\n}\n\nexport interface SubagentDelegationV2Started {\n version: typeof SUBAGENT_DELEGATION_V2_PROTOCOL_VERSION;\n requestId: string;\n ownerRunId: string;\n nodeId: string;\n}\n\nexport interface SubagentDelegationV2Update extends SubagentDelegationV2Started {\n runId?: string;\n currentTool?: string;\n currentToolArgs?: string;\n recentOutput?: string;\n recentOutputLines?: string[];\n recentTools?: Array<{ tool: string; args: string }>;\n model?: string;\n toolCount?: number;\n durationMs?: number;\n tokens?: number;\n}\n\nexport type SubagentDelegationV2Status = SubagentDelegationStatus | 'duplicate_node';\n\nexport type SubagentDelegationV2Value = { kind: 'text'; text: string } | { kind: 'structured'; value: unknown };\n\nexport interface SubagentDelegationV2Usage {\n input: number;\n output: number;\n cacheRead: number;\n cacheWrite: number;\n cost: number;\n turns: number;\n toolCalls: number;\n durationMs: number;\n}\n\nexport interface SubagentDelegationV2TerminalResponse extends SubagentDelegationV2Started {\n status: Exclude<SubagentDelegationV2Status, 'invalid_request'>;\n error?: string;\n runId?: string;\n agent?: string;\n model?: string;\n thinking?: string;\n exitCode?: number;\n launchContractDigest?: string;\n result?: SubagentDelegationV2Value;\n usage?: SubagentDelegationV2Usage;\n}\n\n/** A malformed V2 request can only be correlated by the valid identity fields it supplied. */\nexport interface SubagentDelegationV2InvalidResponse {\n version: typeof SUBAGENT_DELEGATION_V2_PROTOCOL_VERSION;\n requestId: string;\n ownerRunId?: string;\n nodeId?: string;\n status: 'invalid_request';\n error?: string;\n}\n\nexport type SubagentDelegationV2Response = SubagentDelegationV2TerminalResponse | SubagentDelegationV2InvalidResponse;\n\nexport interface SubagentDelegationV2Cancel extends SubagentDelegationV2Started {}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,uCAAuC;AACpD,MAAa,0CAA0C;AAIvD,MAAa,oCAAoC;AACjD,MAAa,oCAAoC;AACjD,MAAa,mCAAmC;AAChD,MAAa,qCAAqC;AAClD,MAAa,mCAAmC"}
|