pi-subagents 0.80.0 → 0.81.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/CHANGELOG.md +28 -0
- package/bundle/agents.js +18 -0
- package/bundle/background-work.js +16 -0
- package/bundle/capability-ceiling.js +22 -0
- package/bundle/child-tool-plan.js +11 -0
- package/bundle/chunk-26C3WLYQ.js +8388 -0
- package/bundle/chunk-2XYWN7QJ.js +128 -0
- package/bundle/chunk-2ZSNH26H.js +4164 -0
- package/bundle/chunk-3DC5KBVP.js +235 -0
- package/bundle/chunk-3IF2PGW7.js +380 -0
- package/bundle/chunk-4QFZZV3O.js +57 -0
- package/bundle/chunk-563BHAZ5.js +1365 -0
- package/bundle/chunk-5LFLVSTM.js +260 -0
- package/bundle/chunk-62OCY2S4.js +14 -0
- package/bundle/chunk-74RT5YQE.js +326 -0
- package/bundle/chunk-7F6RKT6W.js +132 -0
- package/bundle/chunk-7J4ZXMY7.js +18 -0
- package/bundle/chunk-ARRKBB2B.js +179 -0
- package/bundle/chunk-BJN5LUQY.js +458 -0
- package/bundle/chunk-BPS2AGBZ.js +5421 -0
- package/bundle/chunk-CEKS3TFO.js +1337 -0
- package/bundle/chunk-CTPAE36Y.js +94 -0
- package/bundle/chunk-D4EHT5SJ.js +14 -0
- package/bundle/chunk-EYNJ6VL6.js +526 -0
- package/bundle/chunk-G5DKFLLI.js +1185 -0
- package/bundle/chunk-KSWQVGDW.js +1027 -0
- package/bundle/chunk-L5ZHE4L4.js +946 -0
- package/bundle/chunk-LSRUTHT7.js +57 -0
- package/bundle/chunk-N2BN7BF5.js +159 -0
- package/bundle/chunk-NF7IEKBH.js +490 -0
- package/bundle/chunk-NIXWDZZV.js +9 -0
- package/bundle/chunk-NNLASTQE.js +4082 -0
- package/bundle/chunk-TUWLXTAM.js +935 -0
- package/bundle/chunk-UKG4V45O.js +228 -0
- package/bundle/chunk-V2JWDB5U.js +753 -0
- package/bundle/chunk-V3BIUPLU.js +9163 -0
- package/bundle/chunk-V6MR5TOQ.js +270 -0
- package/bundle/chunk-VJHOELQP.js +8245 -0
- package/bundle/chunk-WSBNENFS.js +732 -0
- package/bundle/chunk-XMFLCKMQ.js +16664 -0
- package/bundle/chunk-YFCK7H2S.js +129 -0
- package/bundle/chunk-YYREO77V.js +137 -0
- package/bundle/chunk-Z7KVHQHL.js +173 -0
- package/bundle/chunk-ZBC44JJ3.js +8606 -0
- package/bundle/chunk-ZP3HODFH.js +175 -0
- package/bundle/control-channel.js +11 -0
- package/bundle/delegation.js +14 -0
- package/bundle/external-job-provider.js +20 -0
- package/bundle/external-runs.js +21 -0
- package/bundle/index.js +30 -0
- package/bundle/inspectors.js +8 -0
- package/bundle/intercom-bridge.js +11 -0
- package/bundle/preflight.js +425 -0
- package/bundle/project-panes.js +28 -0
- package/bundle/required-child-extensions.js +6 -0
- package/bundle/shared-types.js +8 -0
- package/bundle/workflow-resources.js +7 -0
- package/docs/extension-api.md +27 -0
- package/docs/observability.md +6 -2
- package/package.json +18 -18
- package/src/agents/frontmatter.d.ts +2 -0
- package/src/agents/frontmatter.js +9 -2
- package/src/api/delegation.d.ts +20 -0
- package/src/extension/index.js +27 -7
- package/src/runs/background/run-child-session.js +18 -0
- package/src/runs/background/stale-run-reconciler.js +2 -0
- package/src/runs/foreground/execution.js +39 -2
- package/src/runs/shared/structured-output.d.ts +1 -0
- package/src/runs/shared/structured-output.js +1 -0
- package/src/shared/accessible-dir.js +4 -1
- package/src/shared/provider-diagnostics.d.ts +9 -0
- package/src/shared/provider-diagnostics.js +75 -0
- package/src/shared/types.d.ts +3 -0
- package/src/slash/delegation-adapters.d.ts +3 -1
- package/src/slash/delegation-adapters.js +7 -0
- package/src/slash/prompt-template-bridge.js +3 -1
- package/src/slash/subagents-admin.d.ts +1 -0
- package/src/slash/subagents-admin.js +1 -1
- package/src/tui/fleet-layout.d.ts +20 -0
- package/src/tui/fleet-layout.js +17 -0
- package/src/tui/fleet-viewport.d.ts +12 -0
- package/src/tui/fleet-viewport.js +35 -0
- package/src/tui/fleet.d.ts +5 -6
- package/src/tui/fleet.js +69 -51
- package/src/workflows/structured-workflow-scripts.d.ts +1 -0
- package/src/workflows/structured-workflow-scripts.js +5 -4
- package/src/workflows/workflow-resources.js +2 -2
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {
|
|
2
|
+
registerRuntimeAgent
|
|
3
|
+
} from "./chunk-3IF2PGW7.js";
|
|
4
|
+
|
|
5
|
+
// src/agents/runtime-agent-events.ts
|
|
6
|
+
var RUNTIME_AGENT_REGISTER_EVENT = "pi-subagents:runtime-agent-register:v1";
|
|
7
|
+
var RUNTIME_AGENT_REGISTER_VERSION = 1;
|
|
8
|
+
function errorFrom(value) {
|
|
9
|
+
return value instanceof Error ? value : new Error(String(value));
|
|
10
|
+
}
|
|
11
|
+
function registerAgentViaEvents(input) {
|
|
12
|
+
const request = {
|
|
13
|
+
version: RUNTIME_AGENT_REGISTER_VERSION,
|
|
14
|
+
name: input.name,
|
|
15
|
+
definition: input.definition
|
|
16
|
+
};
|
|
17
|
+
input.pi.events.emit(RUNTIME_AGENT_REGISTER_EVENT, request);
|
|
18
|
+
const result = request.result;
|
|
19
|
+
if (result === void 0) {
|
|
20
|
+
throw new Error("pi-subagents is not installed, not ready, or does not support runtime agent event registration.");
|
|
21
|
+
}
|
|
22
|
+
if (result && typeof result === "object" && !Array.isArray(result)) {
|
|
23
|
+
const candidate = result;
|
|
24
|
+
if (candidate.ok === true && candidate.registration && typeof candidate.registration === "object" && typeof candidate.registration.dispose === "function") {
|
|
25
|
+
return candidate.registration;
|
|
26
|
+
}
|
|
27
|
+
if (candidate.ok === false && candidate.error instanceof Error) throw candidate.error;
|
|
28
|
+
}
|
|
29
|
+
throw new Error("pi-subagents returned a malformed runtime agent registration result.");
|
|
30
|
+
}
|
|
31
|
+
function registerRuntimeAgentEventListener(pi) {
|
|
32
|
+
return pi.events.on(RUNTIME_AGENT_REGISTER_EVENT, (rawRequest) => {
|
|
33
|
+
if (!rawRequest || typeof rawRequest !== "object" || Array.isArray(rawRequest)) return;
|
|
34
|
+
const request = rawRequest;
|
|
35
|
+
if (request.result !== void 0) return;
|
|
36
|
+
try {
|
|
37
|
+
if (request.version !== RUNTIME_AGENT_REGISTER_VERSION) {
|
|
38
|
+
throw new Error(`Unsupported runtime agent registration event version '${String(request.version)}'.`);
|
|
39
|
+
}
|
|
40
|
+
const registration = registerRuntimeAgent({
|
|
41
|
+
pi,
|
|
42
|
+
name: request.name,
|
|
43
|
+
definition: request.definition
|
|
44
|
+
});
|
|
45
|
+
request.result = { ok: true, registration };
|
|
46
|
+
} catch (error) {
|
|
47
|
+
request.result = { ok: false, error: errorFrom(error) };
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export {
|
|
53
|
+
RUNTIME_AGENT_REGISTER_EVENT,
|
|
54
|
+
RUNTIME_AGENT_REGISTER_VERSION,
|
|
55
|
+
registerAgentViaEvents,
|
|
56
|
+
registerRuntimeAgentEventListener
|
|
57
|
+
};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// src/api/background-work.ts
|
|
2
|
+
var BACKGROUND_WORK_PROTOCOL_VERSION = 1;
|
|
3
|
+
var BACKGROUND_WORK_REGISTRY_KEY = "pi-subagents.background-work.v1";
|
|
4
|
+
var MAX_PROVIDER_NAME_LENGTH = 128;
|
|
5
|
+
var MAX_PROVIDERS = 100;
|
|
6
|
+
var MAX_ITEM_ID_LENGTH = 256;
|
|
7
|
+
var MAX_SESSION_ID_LENGTH = 4096;
|
|
8
|
+
var MAX_WAKE_CHANNEL_LENGTH = 256;
|
|
9
|
+
var MAX_ITEMS_PER_PROVIDER = 1e4;
|
|
10
|
+
function registry() {
|
|
11
|
+
const key = Symbol.for(BACKGROUND_WORK_REGISTRY_KEY);
|
|
12
|
+
const globalObject = globalThis;
|
|
13
|
+
const existing = globalObject[key];
|
|
14
|
+
if (existing === void 0) {
|
|
15
|
+
const created = {
|
|
16
|
+
version: BACKGROUND_WORK_PROTOCOL_VERSION,
|
|
17
|
+
providers: /* @__PURE__ */ new Map()
|
|
18
|
+
};
|
|
19
|
+
globalObject[key] = created;
|
|
20
|
+
return created;
|
|
21
|
+
}
|
|
22
|
+
if (!existing || typeof existing !== "object" || Array.isArray(existing)) {
|
|
23
|
+
throw new Error(`Malformed background-work registry at Symbol.for("${BACKGROUND_WORK_REGISTRY_KEY}").`);
|
|
24
|
+
}
|
|
25
|
+
const candidate = existing;
|
|
26
|
+
if (candidate.version !== BACKGROUND_WORK_PROTOCOL_VERSION || !(candidate.providers instanceof Map)) {
|
|
27
|
+
throw new Error(`Unsupported background-work registry at Symbol.for("${BACKGROUND_WORK_REGISTRY_KEY}").`);
|
|
28
|
+
}
|
|
29
|
+
return candidate;
|
|
30
|
+
}
|
|
31
|
+
function validateString(value, field, maxLength) {
|
|
32
|
+
if (typeof value !== "string" || value.length === 0 || value.trim() !== value) {
|
|
33
|
+
throw new Error(`${field} must be a non-empty string without leading or trailing whitespace.`);
|
|
34
|
+
}
|
|
35
|
+
if (value.length > maxLength) throw new Error(`${field} must be at most ${maxLength} characters.`);
|
|
36
|
+
if (value.includes("\0")) throw new Error(`${field} must not contain NUL characters.`);
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
function validateProvider(value) {
|
|
40
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
41
|
+
throw new Error("Background-work provider must be an object.");
|
|
42
|
+
}
|
|
43
|
+
const provider = value;
|
|
44
|
+
const unknownFields = Object.keys(provider).filter((key) => !["name", "listActiveWork", "wakeChannels", "reconcile"].includes(key));
|
|
45
|
+
if (unknownFields.length > 0) throw new Error(`Background-work provider has unknown fields: ${unknownFields.join(", ")}.`);
|
|
46
|
+
const name = validateString(provider.name, "Background-work provider name", MAX_PROVIDER_NAME_LENGTH);
|
|
47
|
+
if (typeof provider.listActiveWork !== "function") {
|
|
48
|
+
throw new Error(`Background-work provider '${name}' must expose listActiveWork().`);
|
|
49
|
+
}
|
|
50
|
+
if (provider.reconcile !== void 0 && typeof provider.reconcile !== "function") {
|
|
51
|
+
throw new Error(`Background-work provider '${name}' reconcile must be a function when provided.`);
|
|
52
|
+
}
|
|
53
|
+
if (provider.wakeChannels !== void 0) {
|
|
54
|
+
if (!Array.isArray(provider.wakeChannels)) {
|
|
55
|
+
throw new Error(`Background-work provider '${name}' wakeChannels must be an array when provided.`);
|
|
56
|
+
}
|
|
57
|
+
const channels = provider.wakeChannels.map((channel, index) => validateString(channel, `Background-work provider '${name}' wakeChannels[${index}]`, MAX_WAKE_CHANNEL_LENGTH));
|
|
58
|
+
if (new Set(channels).size !== channels.length) {
|
|
59
|
+
throw new Error(`Background-work provider '${name}' wakeChannels must not contain duplicates.`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
64
|
+
function validateItem(provider, value, index) {
|
|
65
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
66
|
+
throw new Error(`Background-work provider '${provider}' item ${index} must be an object.`);
|
|
67
|
+
}
|
|
68
|
+
const item = value;
|
|
69
|
+
const unknownFields = Object.keys(item).filter((key) => key !== "id" && key !== "sessionId");
|
|
70
|
+
if (unknownFields.length > 0) {
|
|
71
|
+
throw new Error(`Background-work provider '${provider}' item ${index} has unknown fields: ${unknownFields.join(", ")}.`);
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
id: validateString(item.id, `Background-work provider '${provider}' item ${index} id`, MAX_ITEM_ID_LENGTH),
|
|
75
|
+
sessionId: validateString(item.sessionId, `Background-work provider '${provider}' item ${index} sessionId`, MAX_SESSION_ID_LENGTH)
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function registerBackgroundWorkProvider(provider) {
|
|
79
|
+
const validated = validateProvider(provider);
|
|
80
|
+
const current = registry();
|
|
81
|
+
if (!current.providers.has(validated.name) && current.providers.size >= MAX_PROVIDERS) {
|
|
82
|
+
throw new Error(`Background-work registry supports at most ${MAX_PROVIDERS} providers.`);
|
|
83
|
+
}
|
|
84
|
+
current.providers.set(validated.name, validated);
|
|
85
|
+
return () => {
|
|
86
|
+
if (current.providers.get(validated.name) === validated) current.providers.delete(validated.name);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function listBackgroundWorkProviders() {
|
|
90
|
+
const current = registry();
|
|
91
|
+
if (current.providers.size > MAX_PROVIDERS) throw new Error(`Background-work registry contains more than ${MAX_PROVIDERS} providers.`);
|
|
92
|
+
const providers = [];
|
|
93
|
+
for (const [key, value] of current.providers) {
|
|
94
|
+
const provider = validateProvider(value);
|
|
95
|
+
if (key !== provider.name) throw new Error(`Background-work registry key '${key}' does not match provider name '${provider.name}'.`);
|
|
96
|
+
providers.push(provider);
|
|
97
|
+
}
|
|
98
|
+
return providers;
|
|
99
|
+
}
|
|
100
|
+
function listBackgroundWorkWakeChannels() {
|
|
101
|
+
const channels = /* @__PURE__ */ new Set();
|
|
102
|
+
for (const provider of listBackgroundWorkProviders()) {
|
|
103
|
+
for (const channel of provider.wakeChannels ?? []) channels.add(channel);
|
|
104
|
+
}
|
|
105
|
+
return [...channels];
|
|
106
|
+
}
|
|
107
|
+
function snapshotBackgroundWork(sessionId, nowMs = Date.now()) {
|
|
108
|
+
validateString(sessionId, "Background-work snapshot sessionId", MAX_SESSION_ID_LENGTH);
|
|
109
|
+
const providers = listBackgroundWorkProviders();
|
|
110
|
+
const items = [];
|
|
111
|
+
const identities = /* @__PURE__ */ new Set();
|
|
112
|
+
for (const provider of providers) {
|
|
113
|
+
try {
|
|
114
|
+
provider.reconcile?.({ sessionId, nowMs });
|
|
115
|
+
} catch (error) {
|
|
116
|
+
throw new Error(
|
|
117
|
+
`Background-work provider '${provider.name}' reconcile failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
118
|
+
{ cause: error }
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
let active;
|
|
122
|
+
try {
|
|
123
|
+
active = provider.listActiveWork({ sessionId, nowMs });
|
|
124
|
+
} catch (error) {
|
|
125
|
+
throw new Error(
|
|
126
|
+
`Background-work provider '${provider.name}' listActiveWork failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
127
|
+
{ cause: error }
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
if (!Array.isArray(active)) {
|
|
131
|
+
throw new Error(`Background-work provider '${provider.name}' listActiveWork() must return an array.`);
|
|
132
|
+
}
|
|
133
|
+
if (active.length > MAX_ITEMS_PER_PROVIDER) {
|
|
134
|
+
throw new Error(`Background-work provider '${provider.name}' returned ${active.length} items; maximum is ${MAX_ITEMS_PER_PROVIDER}.`);
|
|
135
|
+
}
|
|
136
|
+
active.forEach((value, index) => {
|
|
137
|
+
const item = validateItem(provider.name, value, index);
|
|
138
|
+
const identity = `${provider.name}\0${item.sessionId}\0${item.id}`;
|
|
139
|
+
if (identities.has(identity)) {
|
|
140
|
+
throw new Error(`Background-work provider '${provider.name}' returned duplicate item '${item.id}' for session '${item.sessionId}'.`);
|
|
141
|
+
}
|
|
142
|
+
identities.add(identity);
|
|
143
|
+
if (item.sessionId === sessionId) items.push({ provider: provider.name, ...item });
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
providers: providers.map((provider) => provider.name),
|
|
148
|
+
items
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export {
|
|
153
|
+
BACKGROUND_WORK_PROTOCOL_VERSION,
|
|
154
|
+
BACKGROUND_WORK_REGISTRY_KEY,
|
|
155
|
+
registerBackgroundWorkProvider,
|
|
156
|
+
listBackgroundWorkProviders,
|
|
157
|
+
listBackgroundWorkWakeChannels,
|
|
158
|
+
snapshotBackgroundWork
|
|
159
|
+
};
|