@cydm/pie 4.2.0 → 4.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builtin/extensions/im-forward/index.js +717 -176
- package/dist/builtin/extensions/pie-ipc/index.js +126 -348
- package/dist/builtin/extensions/pie-proc/index.js +1 -27
- package/dist/chunks/chunk-GJLSYBFN.js +359 -0
- package/dist/chunks/{concierge-cli-R3RIBGJL.js → concierge-cli-CQMIAGWJ.js} +20 -23
- package/dist/cli.js +46 -20
- package/package.json +3 -3
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// builtin/extensions/pie-ipc/pure.ts
|
|
4
|
+
import { randomBytes } from "node:crypto";
|
|
5
|
+
var IPC_PROTOCOL_VERSION = 2;
|
|
6
|
+
var INSTANCE_ID_PATTERN = /^pie-[a-z0-9]{12}$/;
|
|
7
|
+
var MAX_STATUS_FILE_BYTES = 128 * 1024;
|
|
8
|
+
var MAX_DISPLAY_NAME_CHARS = 64;
|
|
9
|
+
var MAX_STATUS_TEXT_FIELD_CHARS = 4096;
|
|
10
|
+
var MAX_BODY_CHARS = 8e3;
|
|
11
|
+
var MAX_STATUS_BODY_CHARS = 2e3;
|
|
12
|
+
var STATUS_FILE_STALE_MS = 12e4;
|
|
13
|
+
var HEARTBEAT_INTERVAL_MS = 2e4;
|
|
14
|
+
var DEFAULT_SEND_WAIT_MS = 12e4;
|
|
15
|
+
var MAX_SEEN_ENVELOPE_IDS = 1e3;
|
|
16
|
+
var MAX_INBOX_MESSAGES = 100;
|
|
17
|
+
var MAX_INFLIGHT_SENDS = 8;
|
|
18
|
+
var INSTANCE_ID_ALPHABET = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
19
|
+
function generateInstanceId(randomSource = defaultRandomBytes) {
|
|
20
|
+
const bytes = randomSource(12);
|
|
21
|
+
let id = "";
|
|
22
|
+
for (const byte of bytes) {
|
|
23
|
+
id += INSTANCE_ID_ALPHABET[byte % INSTANCE_ID_ALPHABET.length];
|
|
24
|
+
}
|
|
25
|
+
return `pie-${id}`;
|
|
26
|
+
}
|
|
27
|
+
function defaultRandomBytes(count) {
|
|
28
|
+
return randomBytes(count);
|
|
29
|
+
}
|
|
30
|
+
function isValidInstanceId(id) {
|
|
31
|
+
return INSTANCE_ID_PATTERN.test(id);
|
|
32
|
+
}
|
|
33
|
+
function peerLabel(instanceId, displayName) {
|
|
34
|
+
const name = displayName?.trim();
|
|
35
|
+
if (name) return name;
|
|
36
|
+
return instanceId.length > 12 ? instanceId.slice(0, 12) : instanceId;
|
|
37
|
+
}
|
|
38
|
+
var ENVELOPE_KINDS = /* @__PURE__ */ new Set([
|
|
39
|
+
"hello",
|
|
40
|
+
"bye",
|
|
41
|
+
"ping",
|
|
42
|
+
"message",
|
|
43
|
+
"ack",
|
|
44
|
+
"result",
|
|
45
|
+
"state.get",
|
|
46
|
+
"state",
|
|
47
|
+
"result.get",
|
|
48
|
+
"control"
|
|
49
|
+
]);
|
|
50
|
+
var LIFECYCLE_STATES = /* @__PURE__ */ new Set(["working", "idle", "blocked"]);
|
|
51
|
+
function parseEnvelope(raw) {
|
|
52
|
+
let parsed;
|
|
53
|
+
try {
|
|
54
|
+
parsed = JSON.parse(raw);
|
|
55
|
+
} catch {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return null;
|
|
59
|
+
const record = parsed;
|
|
60
|
+
if (typeof record.v !== "number" || record.v !== IPC_PROTOCOL_VERSION) return null;
|
|
61
|
+
if (typeof record.id !== "string" || !/^[a-zA-Z0-9:-]{1,128}$/.test(record.id)) return null;
|
|
62
|
+
if (typeof record.from !== "string" || !isValidInstanceId(record.from)) return null;
|
|
63
|
+
if (typeof record.to !== "string" || !isValidInstanceId(record.to)) return null;
|
|
64
|
+
if (record.text !== void 0 && (typeof record.text !== "string" || record.text.length > MAX_BODY_CHARS + 100)) return null;
|
|
65
|
+
if (record.sessionId !== void 0 && (typeof record.sessionId !== "string" || record.sessionId.length > 256)) return null;
|
|
66
|
+
if (record.replyTo !== void 0 && (typeof record.replyTo !== "string" || !/^[a-zA-Z0-9:-]{1,128}$/.test(record.replyTo))) return null;
|
|
67
|
+
if (record.waitMs !== void 0 && (typeof record.waitMs !== "number" || !Number.isFinite(record.waitMs) || record.waitMs < 0 || record.waitMs > 6e5)) return null;
|
|
68
|
+
if (record.notifyCompletion !== void 0 && typeof record.notifyCompletion !== "boolean") return null;
|
|
69
|
+
if (record.subscriberSession !== void 0 && (typeof record.subscriberSession !== "string" || record.subscriberSession.length > 256)) return null;
|
|
70
|
+
if (typeof record.kind !== "string" || !ENVELOPE_KINDS.has(record.kind)) return null;
|
|
71
|
+
if (typeof record.createdAt !== "number" || !Number.isSafeInteger(record.createdAt) || record.createdAt < 0) return null;
|
|
72
|
+
const envelope = {
|
|
73
|
+
v: record.v,
|
|
74
|
+
id: record.id,
|
|
75
|
+
from: record.from,
|
|
76
|
+
to: record.to,
|
|
77
|
+
kind: record.kind,
|
|
78
|
+
createdAt: record.createdAt
|
|
79
|
+
};
|
|
80
|
+
if (typeof record.auth === "string" && /^[a-f0-9]{64}$/.test(record.auth)) envelope.auth = record.auth;
|
|
81
|
+
if (typeof record.sessionId === "string") envelope.sessionId = record.sessionId;
|
|
82
|
+
if (typeof record.text === "string") envelope.text = record.text;
|
|
83
|
+
if (typeof record.replyTo === "string") envelope.replyTo = record.replyTo;
|
|
84
|
+
if (typeof record.waitMs === "number" && Number.isFinite(record.waitMs)) envelope.waitMs = record.waitMs;
|
|
85
|
+
if (record.notifyCompletion === true) envelope.notifyCompletion = true;
|
|
86
|
+
if (record.control === true) envelope.control = true;
|
|
87
|
+
if (record.userAssigned === true) envelope.userAssigned = true;
|
|
88
|
+
if (typeof record.subscriberSession === "string") envelope.subscriberSession = record.subscriberSession;
|
|
89
|
+
return envelope;
|
|
90
|
+
}
|
|
91
|
+
var FrameTooLargeError = class extends Error {
|
|
92
|
+
constructor() {
|
|
93
|
+
super("pie-ipc frame exceeds byte cap");
|
|
94
|
+
this.name = "FrameTooLargeError";
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
var FrameDecoder = class {
|
|
98
|
+
buffer = "";
|
|
99
|
+
get partial() {
|
|
100
|
+
return this.buffer.length > 0;
|
|
101
|
+
}
|
|
102
|
+
push(chunk) {
|
|
103
|
+
this.buffer += chunk;
|
|
104
|
+
if (this.buffer.split("\n").some((line) => Buffer.byteLength(line, "utf8") > 64 * 1024)) {
|
|
105
|
+
this.buffer = "";
|
|
106
|
+
throw new FrameTooLargeError();
|
|
107
|
+
}
|
|
108
|
+
const envelopes = [];
|
|
109
|
+
let newline = this.buffer.indexOf("\n");
|
|
110
|
+
while (newline !== -1) {
|
|
111
|
+
const line = this.buffer.slice(0, newline).trim();
|
|
112
|
+
this.buffer = this.buffer.slice(newline + 1);
|
|
113
|
+
if (line) {
|
|
114
|
+
const envelope = parseEnvelope(line);
|
|
115
|
+
if (envelope) envelopes.push(envelope);
|
|
116
|
+
}
|
|
117
|
+
newline = this.buffer.indexOf("\n");
|
|
118
|
+
}
|
|
119
|
+
return envelopes;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
var WRAP_PREFIX = "[pie-ipc]";
|
|
123
|
+
function wrapInboundText(fromLabel, text, at = Date.now(), messageId) {
|
|
124
|
+
const stamp = new Date(at).toISOString().slice(11, 19);
|
|
125
|
+
const marker = messageId ? ` #${clipMarker(messageId)} ` : " ";
|
|
126
|
+
return `${WRAP_PREFIX} ${stamp}${marker}peer "${clipLabel(fromLabel)}" says:
|
|
127
|
+
${clipBody(text, MAX_BODY_CHARS)}`;
|
|
128
|
+
}
|
|
129
|
+
function isWrappedInboundText(text) {
|
|
130
|
+
return text.startsWith(`${WRAP_PREFIX} `);
|
|
131
|
+
}
|
|
132
|
+
function wrappedMessageMarker(text) {
|
|
133
|
+
if (!isWrappedInboundText(text)) return null;
|
|
134
|
+
const firstLine = text.split("\n", 1)[0];
|
|
135
|
+
const match = / #(\S+) peer "/.exec(firstLine);
|
|
136
|
+
return match ? match[1] : null;
|
|
137
|
+
}
|
|
138
|
+
function clipMarker(id) {
|
|
139
|
+
const clipped = id;
|
|
140
|
+
return clipped || "noid";
|
|
141
|
+
}
|
|
142
|
+
function clipLabel(label) {
|
|
143
|
+
const collapsed = label.replace(/\s+/g, " ").trim().slice(0, 60);
|
|
144
|
+
return collapsed || "unknown";
|
|
145
|
+
}
|
|
146
|
+
function clipBody(text, maxChars = MAX_BODY_CHARS) {
|
|
147
|
+
if (text.length <= maxChars) return text;
|
|
148
|
+
return `${text.slice(0, maxChars)}\u2026[truncated ${text.length - maxChars} chars]`;
|
|
149
|
+
}
|
|
150
|
+
var BoundedIdSet = class {
|
|
151
|
+
constructor(max = MAX_SEEN_ENVELOPE_IDS) {
|
|
152
|
+
this.max = max;
|
|
153
|
+
}
|
|
154
|
+
max;
|
|
155
|
+
seen = /* @__PURE__ */ new Map();
|
|
156
|
+
/** Returns true when the id is new (and records it). */
|
|
157
|
+
add(id, now = Date.now()) {
|
|
158
|
+
if (this.seen.has(id)) return false;
|
|
159
|
+
this.seen.set(id, now);
|
|
160
|
+
if (this.seen.size > this.max) {
|
|
161
|
+
const drop = Math.max(1, Math.floor(this.max / 4));
|
|
162
|
+
let dropped = 0;
|
|
163
|
+
for (const key of this.seen.keys()) {
|
|
164
|
+
if (dropped >= drop) break;
|
|
165
|
+
this.seen.delete(key);
|
|
166
|
+
dropped += 1;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
has(id) {
|
|
172
|
+
return this.seen.has(id);
|
|
173
|
+
}
|
|
174
|
+
get size() {
|
|
175
|
+
return this.seen.size;
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
var signalAliveCheck = (pid) => {
|
|
179
|
+
try {
|
|
180
|
+
process.kill(pid, 0);
|
|
181
|
+
return true;
|
|
182
|
+
} catch (error) {
|
|
183
|
+
return error.code === "EPERM";
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
function peerHealth(file, now = Date.now(), aliveCheck = signalAliveCheck) {
|
|
187
|
+
if (Number.isInteger(file.pid) && file.pid > 0 && !aliveCheck(file.pid)) return "dead";
|
|
188
|
+
if (now - file.updatedAt > STATUS_FILE_STALE_MS) return "stale";
|
|
189
|
+
return "alive";
|
|
190
|
+
}
|
|
191
|
+
function parseStatusFile(raw) {
|
|
192
|
+
let parsed;
|
|
193
|
+
try {
|
|
194
|
+
parsed = JSON.parse(raw);
|
|
195
|
+
} catch {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return null;
|
|
199
|
+
const record = parsed;
|
|
200
|
+
if (record.schema !== 1) return null;
|
|
201
|
+
if (typeof record.instanceId !== "string" || !isValidInstanceId(record.instanceId)) return null;
|
|
202
|
+
if (typeof record.pid !== "number" || !Number.isInteger(record.pid) || record.pid <= 0 || record.pid > 99999999) return null;
|
|
203
|
+
if (typeof record.protocol !== "number" || record.protocol !== IPC_PROTOCOL_VERSION) return null;
|
|
204
|
+
if (typeof record.displayName !== "string" || !record.displayName || record.displayName.length > MAX_DISPLAY_NAME_CHARS) return null;
|
|
205
|
+
if (hasControlChars(record.displayName)) return null;
|
|
206
|
+
if (record.sessionId !== null && (typeof record.sessionId !== "string" || record.sessionId.length > 256 || hasControlChars(record.sessionId))) return null;
|
|
207
|
+
if (typeof record.cwd !== "string" || record.cwd.length > MAX_STATUS_TEXT_FIELD_CHARS || hasControlChars(record.cwd)) return null;
|
|
208
|
+
if (typeof record.startedAt !== "number" || !Number.isSafeInteger(record.startedAt) || record.startedAt < 0) return null;
|
|
209
|
+
if (typeof record.updatedAt !== "number" || !Number.isSafeInteger(record.updatedAt) || record.updatedAt < 0) return null;
|
|
210
|
+
if (typeof record.state !== "string" || !LIFECYCLE_STATES.has(record.state)) return null;
|
|
211
|
+
const file = {
|
|
212
|
+
schema: 1,
|
|
213
|
+
instanceId: record.instanceId,
|
|
214
|
+
pid: record.pid,
|
|
215
|
+
protocol: record.protocol,
|
|
216
|
+
displayName: record.displayName,
|
|
217
|
+
sessionId: record.sessionId,
|
|
218
|
+
cwd: record.cwd,
|
|
219
|
+
startedAt: record.startedAt,
|
|
220
|
+
updatedAt: record.updatedAt,
|
|
221
|
+
state: record.state
|
|
222
|
+
};
|
|
223
|
+
if (Array.isArray(record.allowPeers) && record.allowPeers.length <= 1e3 && record.allowPeers.every((id) => typeof id === "string" && (id === "*" || isValidInstanceId(id)))) file.allowPeers = record.allowPeers;
|
|
224
|
+
if (typeof record.secret === "string" && /^[a-f0-9]{64}$/.test(record.secret)) file.secret = record.secret;
|
|
225
|
+
if (typeof record.sessionName === "string" && !hasControlChars(record.sessionName) && record.sessionName.length <= MAX_DISPLAY_NAME_CHARS) file.sessionName = record.sessionName;
|
|
226
|
+
if (typeof record.currentTool === "string" && !hasControlChars(record.currentTool) && record.currentTool.length <= 200) file.currentTool = record.currentTool;
|
|
227
|
+
if (typeof record.blockedSince === "number" && Number.isSafeInteger(record.blockedSince) && record.blockedSince >= 0) file.blockedSince = record.blockedSince;
|
|
228
|
+
if (typeof record.turnStartedAt === "number" && Number.isSafeInteger(record.turnStartedAt) && record.turnStartedAt >= 0) file.turnStartedAt = record.turnStartedAt;
|
|
229
|
+
if (typeof record.undeliveredInjections === "number" && Number.isFinite(record.undeliveredInjections)) file.undeliveredInjections = Math.min(100, Math.max(0, Math.floor(record.undeliveredInjections)));
|
|
230
|
+
if (typeof record.lastBodyText === "string" && record.lastBodyText.length <= MAX_STATUS_TEXT_FIELD_CHARS && !/[\u0000-\u0008\u000b-\u001f\u007f]/.test(record.lastBodyText)) file.lastBodyText = record.lastBodyText;
|
|
231
|
+
if (typeof record.lastBodyAt === "number" && Number.isSafeInteger(record.lastBodyAt) && record.lastBodyAt >= 0) file.lastBodyAt = record.lastBodyAt;
|
|
232
|
+
if (typeof record.port === "number" && Number.isInteger(record.port) && record.port > 0 && record.port <= 65535) file.port = record.port;
|
|
233
|
+
return file;
|
|
234
|
+
}
|
|
235
|
+
function hasControlChars(text) {
|
|
236
|
+
return /[\u0000-\u001f\u007f]/.test(text);
|
|
237
|
+
}
|
|
238
|
+
var BLOCKING_TOOL_NAMES = /* @__PURE__ */ new Set(["ask_user_multi"]);
|
|
239
|
+
function isBlockingTool(toolName) {
|
|
240
|
+
return BLOCKING_TOOL_NAMES.has(toolName);
|
|
241
|
+
}
|
|
242
|
+
function foldLifecycleEvent(current, event, now = Date.now()) {
|
|
243
|
+
switch (event.type) {
|
|
244
|
+
case "turn:start":
|
|
245
|
+
case "agent:start": {
|
|
246
|
+
const next = { state: "working", turnStartedAt: now };
|
|
247
|
+
if (current.blockedSince !== void 0) next.blockedSince = current.blockedSince;
|
|
248
|
+
return next;
|
|
249
|
+
}
|
|
250
|
+
case "tool:execution:start": {
|
|
251
|
+
if (current.state === "idle") return { ...current, state: "working", turnStartedAt: current.turnStartedAt ?? now };
|
|
252
|
+
if (event.toolName && isBlockingTool(event.toolName) && current.state !== "blocked") {
|
|
253
|
+
return { ...current, state: "blocked", blockedSince: now, currentTool: event.toolName };
|
|
254
|
+
}
|
|
255
|
+
return { ...current, currentTool: event.toolName };
|
|
256
|
+
}
|
|
257
|
+
case "tool:execution:end": {
|
|
258
|
+
if (current.state === "blocked" && (!event.toolName || isBlockingTool(event.toolName))) {
|
|
259
|
+
return { ...current, state: "working", blockedSince: void 0, currentTool: void 0 };
|
|
260
|
+
}
|
|
261
|
+
return current;
|
|
262
|
+
}
|
|
263
|
+
case "turn:completed":
|
|
264
|
+
case "turn:failed":
|
|
265
|
+
case "turn:cancelled":
|
|
266
|
+
case "agent:end": {
|
|
267
|
+
if (current.state === "idle") return current;
|
|
268
|
+
return { state: "idle" };
|
|
269
|
+
}
|
|
270
|
+
default:
|
|
271
|
+
return current;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function resolveIpcConfig(configLayers) {
|
|
275
|
+
const problems = [];
|
|
276
|
+
let invalidConfig = false;
|
|
277
|
+
const merged = {};
|
|
278
|
+
for (const layer of configLayers) {
|
|
279
|
+
if (layer.content === void 0) continue;
|
|
280
|
+
try {
|
|
281
|
+
const parsed = JSON.parse(layer.content);
|
|
282
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
283
|
+
problems.push(`${layer.file}: root is not an object`);
|
|
284
|
+
invalidConfig = true;
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
Object.assign(merged, parsed);
|
|
288
|
+
} catch (error) {
|
|
289
|
+
problems.push(`${layer.file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
290
|
+
invalidConfig = true;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
if (merged.enabled !== void 0 && typeof merged.enabled !== "boolean") {
|
|
294
|
+
problems.push("pie-ipc: enabled must be a boolean");
|
|
295
|
+
invalidConfig = true;
|
|
296
|
+
}
|
|
297
|
+
if (invalidConfig || merged.enabled === false) return { config: null, problems };
|
|
298
|
+
const config = { enabled: true, allowPeers: ["*"], autoInject: true };
|
|
299
|
+
if (typeof merged.displayName === "string" && merged.displayName.trim()) {
|
|
300
|
+
config.displayName = merged.displayName.replace(/[\u0000-\u001f\u007f]/g, " ").trim().slice(0, 60);
|
|
301
|
+
}
|
|
302
|
+
const envName = process.env.PIE_IPC_DISPLAY_NAME;
|
|
303
|
+
if (typeof envName === "string" && envName.trim()) {
|
|
304
|
+
config.displayName = envName.replace(/[\u0000-\u001f\u007f]/g, " ").trim().slice(0, 60);
|
|
305
|
+
}
|
|
306
|
+
if (Array.isArray(merged.allowPeers)) {
|
|
307
|
+
config.allowPeers = merged.allowPeers.filter((id) => typeof id === "string" && (id === "*" || isValidInstanceId(id))).slice(0, 1e3);
|
|
308
|
+
} else if (merged.allowPeers !== void 0) {
|
|
309
|
+
config.allowPeers = [];
|
|
310
|
+
problems.push("pie-ipc: allowPeers must be an array");
|
|
311
|
+
}
|
|
312
|
+
if (merged.autoInject !== void 0) config.autoInject = merged.autoInject === true;
|
|
313
|
+
if (typeof merged.maxBodyChars === "number" && Number.isFinite(merged.maxBodyChars)) {
|
|
314
|
+
const bounded = Math.min(Math.max(Math.floor(merged.maxBodyChars), 100), MAX_BODY_CHARS);
|
|
315
|
+
if (bounded !== merged.maxBodyChars) {
|
|
316
|
+
problems.push(`pie-ipc: maxBodyChars clamped to ${bounded}`);
|
|
317
|
+
}
|
|
318
|
+
config.maxBodyChars = bounded;
|
|
319
|
+
}
|
|
320
|
+
return { config, problems };
|
|
321
|
+
}
|
|
322
|
+
function assistantBodyText(message) {
|
|
323
|
+
if (message?.role !== "assistant" || !Array.isArray(message.content)) return "";
|
|
324
|
+
let text = "";
|
|
325
|
+
let hasToolCalls = false;
|
|
326
|
+
for (const block of message.content) {
|
|
327
|
+
if (typeof block !== "object" || block === null) continue;
|
|
328
|
+
const record = block;
|
|
329
|
+
if (record.type === "text" && typeof record.text === "string") text += record.text;
|
|
330
|
+
else if (record.type === "toolCall") hasToolCalls = true;
|
|
331
|
+
}
|
|
332
|
+
if (hasToolCalls) return "";
|
|
333
|
+
return text.trim();
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export {
|
|
337
|
+
IPC_PROTOCOL_VERSION,
|
|
338
|
+
MAX_STATUS_FILE_BYTES,
|
|
339
|
+
MAX_BODY_CHARS,
|
|
340
|
+
MAX_STATUS_BODY_CHARS,
|
|
341
|
+
HEARTBEAT_INTERVAL_MS,
|
|
342
|
+
DEFAULT_SEND_WAIT_MS,
|
|
343
|
+
MAX_INBOX_MESSAGES,
|
|
344
|
+
MAX_INFLIGHT_SENDS,
|
|
345
|
+
generateInstanceId,
|
|
346
|
+
isValidInstanceId,
|
|
347
|
+
peerLabel,
|
|
348
|
+
FrameDecoder,
|
|
349
|
+
wrapInboundText,
|
|
350
|
+
isWrappedInboundText,
|
|
351
|
+
wrappedMessageMarker,
|
|
352
|
+
clipBody,
|
|
353
|
+
BoundedIdSet,
|
|
354
|
+
peerHealth,
|
|
355
|
+
parseStatusFile,
|
|
356
|
+
foldLifecycleEvent,
|
|
357
|
+
resolveIpcConfig,
|
|
358
|
+
assistantBodyText
|
|
359
|
+
};
|
|
@@ -14,15 +14,6 @@ import * as fs from "node:fs";
|
|
|
14
14
|
import * as os from "node:os";
|
|
15
15
|
import * as path from "node:path";
|
|
16
16
|
var require_ = createRequire(import.meta.url);
|
|
17
|
-
var MAI_SECTION_MARKER = "## \u591A\u4F1A\u8BDD\u534F\u4F5C";
|
|
18
|
-
var MAI_SECTION = `
|
|
19
|
-
${MAI_SECTION_MARKER}
|
|
20
|
-
|
|
21
|
-
- IM \u547D\u4EE4\u9762\uFF08\u7528\u6237\u5728 IM \u91CC\u5BF9\u4F60\u8BF4\u8FD9\u4E9B\u8BCD\uFF0C\u4F60\u76F4\u63A5\u6267\u884C\uFF09\uFF1A\`\u72B6\u6001\`=\u5217\u540D\u518C\uFF08ipc_list_peers\uFF09\uFF1B\`\u8BE6\u60C5 <\u540D>\`=\u8BE5\u4F1A\u8BDD\u753B\u50CF\uFF1B\`\u63A5\u7BA1 <\u540D>\`=\u901A\u77E5\u8BE5\u4F1A\u8BDD\u7528 im_relay \u53D1\u4E0A\u4E00\u8F6E\u6B63\u6587\u5F00\u76F4\u8FDE\u901A\u9053\uFF08\u89C1\u4E0B\uFF09\uFF1B\`\u6539\u540D <\u540D> <\u65B0\u540D>\`=ipc \u901A\u77E5\u8BE5\u4F1A\u8BDD\u6267\u884C\u3002\u6CE8\u610F\uFF1A\`\u9759\u97F3 <\u540D>\`\u76EE\u524D\u6CA1\u6709\u673A\u5668\u5B9E\u73B0\uFF0C\u5982\u5B9E\u544A\u8BC9\u7528\u6237\u9700\u5728 IM \u4FA7\u81EA\u884C\u8BBE\u7F6E\u6D88\u606F\u514D\u6253\u6270\uFF0C\u4E0D\u8981\u5047\u88C5\u5DF2\u9759\u97F3\u3002
|
|
22
|
-
- \u6D3E\u6D3B\u67E5\u8868\uFF08\u8BED\u4E49\u6D3E\u6D3B\uFF0C\u6E90\u5934\u5B9A\u6B7B\u3001\u96F6\u95EE\u8BE2\uFF09\uFF1A\u63A5\u6D3B\u5148\u58F0\u660E\u4E09\u8981\u7D20\u2014\u2014\u9879\u76EE\uFF08\u54EA\u4E2A\u4ED3\u5E93\uFF09\u3001\u9886\u57DF\uFF08\u4EE3\u7801/\u6570\u636E/\u8C03\u67E5/\u5199\u4F5C\u2026\uFF09\u3001\u7D27\u6025\u5EA6\uFF1B\u7136\u540E\u6309 ipc_list_peers \u67E5\u8868\uFF1A\u2460\u9879\u76EE\u5BF9\u53E3\u7684\u7A7A\u95F2\u8005\u4F18\u5148\uFF1B\u2461\u9879\u76EE\u4E0D\u7B26\u4F46\u9886\u57DF\u5BF9\u53E3 \u2192 \u5148\u95EE\u7528\u6237\u4E00\u53E5\uFF1B\u2462\u5168\u90E8\u5728\u5FD9 \u2192 \u6392\u961F\u5E76\u544A\u77E5\u4F4D\u6B21\uFF1B\u2463\u5168\u65B0\u9886\u57DF \u2192 pie_proc \u8D77\u65B0 worker\uFF08cwd \u6307\u5411\u5BF9\u7684\u4ED3\u5E93\uFF0C\u5F53\u573A\u8D77\u540D\u5E76\u544A\u77E5\u7528\u6237\uFF09\u3002\u6D3E\u6D3B\u6D88\u606F\u5FC5\u987B\u5199\u660E"\u4E3A\u4EC0\u4E48\u6D3E\u7ED9\u5B83"\u3002\u7EDD\u4E0D\u628A\u6D3B\u6D3E\u7ED9\u9879\u76EE+\u9886\u57DF\u90FD\u4E0D\u6CBE\u8FB9\u7684\u4F1A\u8BDD\uFF0C\u54EA\u6015\u5B83\u7A7A\u95F2\u3002
|
|
23
|
-
- \u6D3E\u6D3B\u5448\u73B0\uFF1A\u6D3E\u6D3B\u65F6\u5199\u660E"\u6D3E\u7ED9\u8C01\u3001\u5E72\u4EC0\u4E48\u3001\u9884\u671F\u591A\u4E45"\uFF1Bworker \u56DE\u62A5\uFF08ipc \u5B8C\u6210\u901A\u77E5\uFF09\u5230\u4E86\u540E\u8F6C\u8FF0**\u6B63\u6587\u7EA7\u6458\u8981**\u5E76\u6CE8\u660E\u51FA\u5904\uFF08"\uFF08\u6570\u636E\u5206\u6790\uFF09\u56DE\u62A5\uFF1A\u2026"\uFF09\uFF0C\u4E0D\u590D\u8FF0\u5168\u6587\u3002
|
|
24
|
-
- \u63A5\u7BA1\u534F\u8BAE\uFF1A\u7528\u6237\u8BF4"\u63A5\u7BA1 <\u540D>"/"\u6211\u6765\u63A5\u7BA1 <\u540D>"\u65F6\uFF0Cipc_send_notify \u901A\u77E5\u8BE5\u4F1A\u8BDD\uFF1A"\u7528\u6237\u63A5\u7BA1\u76F4\u8FDE\uFF1A\u8C03\u7528 im_relay \u628A\u4F60\u4E0A\u4E00\u8F6E\u6B63\u6587\u539F\u6837\u53D1\u7ED9\u7528\u6237\uFF08root \u6D88\u606F\uFF0C\u4E0D\u5E26 replyTo\uFF09\uFF0C\u5F00\u5934\u52A0\u4E00\u884C\u4F60\u7684\u540D\u5B57\u3002"\u8BE5\u4F1A\u8BDD\u53D1\u51FA\u540E\u5373\u63A5\u7BA1\u5B8C\u6210\uFF1A\u7528\u6237\u540E\u7EED\u5728\u8BE5\u8BDD\u9898\u4E0B\u7684\u6D88\u606F\u4F1A\u76F4\u63A5\u8DEF\u7531\u7ED9\u5B83\uFF0C\u4F60\u4E0D\u518D\u63D2\u8BDD\u3002\u6CE8\u610F\uFF1A\u82E5\u76EE\u6807\u4F1A\u8BDD\u6CA1\u6709 im_relay \u5DE5\u5177\uFF08\u5982 print/one-shot \u5BBF\u4E3B\uFF09\uFF0C\u5982\u5B9E\u544A\u77E5\u7528\u6237\u63A5\u7BA1\u4E0D\u53EF\u884C\u3002
|
|
25
|
-
`;
|
|
26
17
|
var CRON_SECTION_MARKER = "## \u5B9A\u65F6\u4EFB\u52A1";
|
|
27
18
|
var CRON_SECTION = `
|
|
28
19
|
${CRON_SECTION_MARKER}
|
|
@@ -36,22 +27,26 @@ var SEED_AGENTS_MD = `# Pie Concierge\uFF08\u7BA1\u5BB6\uFF09
|
|
|
36
27
|
|
|
37
28
|
## \u89D2\u8272\u51C6\u5219
|
|
38
29
|
|
|
39
|
-
- \u6D88\u606F\u8DEF\u7531\u89C4\u5219\uFF08\u8DEF\u7531\u7531\u7CFB\u7EDF\u786E\u5B9A\u6027\u6267\u884C\uFF0C\u4E0D\u9760\u4F60\u731C\uFF1B\u4F60\u53EA\u7BA1\u56DE\u590D\
|
|
30
|
+
- \u6D88\u606F\u8DEF\u7531\u89C4\u5219\uFF08\u8DEF\u7531\u7531\u7CFB\u7EDF\u786E\u5B9A\u6027\u6267\u884C\uFF0C\u4E0D\u9760\u4F60\u731C\uFF1B\u4F60\u53EA\u7BA1\u56DE\u590D\uFF09\uFF1A
|
|
40
31
|
1. \u7528\u6237\u5728 IM \u76F4\u63A5\u53D1\u6D88\u606F\uFF08\u4E0D\u5F15\u7528\u3001\u4E0D\u56DE\u590D\u4EFB\u4F55\u6D88\u606F\uFF09\u6216\u7FA4\u91CC @app \u2014\u2014 \u90FD\u662F\u627E\u4F60\u3002
|
|
41
32
|
2. \u7528\u6237\u76F4\u63A5\u56DE\u590D\u67D0\u6761\u8F6C\u53D1\u6D88\u606F\u3001\u6216\u5728\u8BE5\u4F1A\u8BDD\u5F00\u542F\u7684 thread \u91CC\u53D1\u8A00 \u2014\u2014 \u56DE\u5230\u90A3\u4E2A\u4F1A\u8BDD\uFF08\u53EF\u80FD\u662F\u4F60\uFF0C\u4E5F\u53EF\u80FD\u662F\u67D0\u4E2A worker \u6216\u684C\u9762\u4F1A\u8BDD\uFF09\u3002
|
|
42
|
-
3. \
|
|
43
|
-
4. \u6536\u5230 \`\u4F1A\u8BDD\u540D: \u6B63\u6587\` \u5F62\u5F0F\u7684\u663E\u5F0F\u5BFB\u5740\u65F6\uFF0C\u771F\u6B63\u8981\u5904\u7406\u7684\u6B63\u6587\u662F\u5192\u53F7\u540E\u9762\u90A3\u90E8\u5206\u3002
|
|
33
|
+
3. \u5F52\u5C5E\u4E0D\u5230\u4EFB\u4F55\u4F1A\u8BDD\u7684\u6D88\u606F\u4F1A\u88AB\u9759\u9ED8\u4E22\u5F03\uFF08IM \u4E0A\u6CA1\u6709 reaction \u5C31\u662F\u4FE1\u53F7\uFF09\u3002\u82E5\u7528\u6237\u62B1\u6028\u6CA1\u53CD\u5E94\uFF0C\u8BA9\u4ED6\uFF1A\u5728\u6D88\u606F\u5F00\u5934\u52A0 \`\u4F1A\u8BDD\u540D: \`\uFF08\u5982 \`work: \u770B\u4E0B\u8FD9\u4E2A\`\uFF09\uFF0C\u6216\u76F4\u63A5\u56DE\u590D\u67D0\u4E2A\u4F1A\u8BDD\u7684\u8F6C\u53D1\u6D88\u606F\u3002\u53EF\u7528 ipc_list_peers \u67E5\u770B\u5F53\u524D\u4F1A\u8BDD\u540D\u3002
|
|
34
|
+
4. \u6536\u5230 \`\u4F1A\u8BDD\u540D: \u6B63\u6587\` \u5F62\u5F0F\u7684\u663E\u5F0F\u5BFB\u5740\u65F6\uFF0C\u771F\u6B63\u8981\u5904\u7406\u7684\u6B63\u6587\u662F\u5192\u53F7\u540E\u9762\u90A3\u90E8\u5206\u3002
|
|
44
35
|
5. \u540C\u4E00\u4E2A app \u5728\u8FD9\u53F0\u7535\u8111\u4E0A\u53EA\u6709\u4E00\u4E2A\u5E38\u9A7B\u63A5\u6536\u8005\uFF08\u4F60\uFF09\uFF1B\u684C\u9762 pie \u53EA\u63A5\u56DE\u590D\u5B83\u81EA\u5DF1\u8F6C\u53D1\u6D88\u606F\u7684\u6D88\u606F\uFF0C\u4E0D\u4F1A\u8DDF\u4F60\u62A2\u666E\u901A\u6D88\u606F\u3002
|
|
45
|
-
- \u4F60\u662F\
|
|
36
|
+
- \u4F60\u662F\u88AB\u52A8\u8D77\u6B65\u7684\uFF1A\u53EA\u6709\u672C turn \u7684\u8F93\u5165\u662F\u7528\u6237\u7684 IM \u6D88\u606F\u65F6\u4F60\u624D\u56DE\u590D\uFF1B\u4F60\u4E0E worker \u7684 IPC \u6C9F\u901A\u4E0D\u4F1A\u51FA\u73B0\u5728 IM \u4E0A\u3002\u5728\u54EA\u804A\u5C31\u5728\u54EA\u56DE\uFF1A\u7528\u6237\u5728 DM \u95EE\u4F60\u5C31\u5728 DM \u7B54\uFF0C\u5728 thread \u91CC\u95EE\u5C31\u5728 thread \u91CC\u7B54\u3002
|
|
37
|
+
- \u4EA4\u4ED8\u5FC5\u8FBE\uFF1A\u7528\u6237\u6D3E\u7684\u6D3B\uFF08\u7167\u770B\u3001\u8D77\u65B0\u8FDB\u7A0B\u3001\u5B9A\u65F6\u4EFB\u52A1\u7684\u4EA7\u51FA\uFF09\uFF0C\u65E0\u8BBA\u7ED3\u679C\u4ECE\u54EA\u4E2A worker/cron \u56DE\u6D41\uFF0C\u4F60\u90FD\u8981\u628A\u7ED3\u679C\u9001\u5230\u7528\u6237\u6D3E\u6D3B\u7684\u5730\u65B9\uFF08DM \u6216\u5BF9\u5E94 thread\uFF09\uFF0C\u4E0D\u8981\u53EA\u5728 IPC \u91CC\u786E\u8BA4\u4E86\u4E8B\u3002
|
|
38
|
+
- \u804C\u8D23\u6536\u7A84\u4E3A\u56DB\u4EF6\u4E8B\uFF1A\u7167\u770B\u67D0\u4E2A session\uFF08\u89C2\u5BDF\u5E76\u6C47\u62A5\uFF09\u3001\u8D77\u65B0\u8FDB\u7A0B\uFF08pie_proc spawn\uFF09\u3001\u5E2E\u7528\u6237\u5207\u67D0\u4E2A\u4F1A\u8BDD\u7684\u6A21\u578B\uFF08ipc_control_notify\uFF0C\u63A7\u5236\u5E27\u4E0D\u8FDB\u5BF9\u65B9\u4F1A\u8BDD\u5386\u53F2\uFF09\u3001\u6309\u7528\u6237\u5F53\u6B21\u7684\u5429\u5490\u529E\u4E8B\u3002
|
|
39
|
+
- \u9ED8\u8BA4\u6D3E\u6D3B\uFF1A\u7F16\u7801\u3001\u8C03\u67E5\u3001\u89C4\u5212\u3001\u590D\u73B0\u3001\u5BA1\u8BA1\u7B49\u4E00\u5207\u9879\u76EE\u5DE5\u4F5C\u90FD\u4EA4\u7ED9 worker \u53BB\u505A\uFF0C\u4F60\u8D1F\u8D23\u5206\u6D3E\u4E0E\u76D1\u7763\u2014\u2014\u4E0D\u8981\u81EA\u5DF1\u52A8\u624B\u505A\u9879\u76EE\u5DE5\u4F5C\uFF0C\u4F60\u7684\u4E0A\u4E0B\u6587\u662F\u7A00\u7F3A\u8D44\u6E90\u3002
|
|
46
40
|
- \u53EA\u6709\u8F7B\u91CF\u7684\u64CD\u4F5C\u6027\u5C0F\u4E8B\u624D\u76F4\u63A5\u505A\uFF1A\u4E00\u6B21\u6027\u67E5\u8BE2\u3001\u8BFB\u4E2A\u6587\u4EF6\u3001\u8DD1\u4E00\u6761\u53EA\u8BFB\u547D\u4EE4\u8FD9\u7C7B\u201C\u4E0D\u6539\u52A8\u9879\u76EE\u72B6\u6001\u3001\u4E0D\u4EA7\u751F\u957F\u8F93\u51FA\u201D\u7684\u4E8B\uFF1B\u4E14\u4F18\u5148\u8D70\u6700\u7B80\u5355\u7684\u7AEF\u5230\u7AEF\u8DEF\u5F84\uFF0C\u4E0D\u4E3A\u5C0F\u4E8B\u642D\u6D41\u7A0B\u3002\u62FF\u4E0D\u51C6\u5C31\u6D3E\u6D3B\u3002
|
|
47
41
|
- \u6D3E\u6D3B\u4F18\u5148\u7EA7\uFF1A\u684C\u9762\u5DF2\u5F00\u7684\u7A7A\u95F2 pie\uFF08ipc_list_peers \u89C1 idle\uFF09\u2192 \u65B0\u5F00 worker\uFF08pie_proc spawn\uFF09\u3002
|
|
48
|
-
- \u6D3E\u6D3B\u7528 ipc_send_notify\uFF08\u9ED8\u8BA4\u8BA2\u9605\u5B8C\u6210\uFF09\uFF1B\u7ED3\u679C\u56DE\u6D41\u540E\
|
|
42
|
+
- \u6D3E\u6D3B\u7528 ipc_send_notify\uFF08\u9ED8\u8BA4\u8BA2\u9605\u5B8C\u6210\uFF09\uFF1B\u7ED3\u679C\u56DE\u6D41\u540E\u6309\u201C\u4EA4\u4ED8\u5FC5\u8FBE\u201D\u9001\u7ED9\u7528\u6237\uFF0C\u5F15\u7528\u4EA7\u7269\u6587\u4EF6\u8DEF\u5F84\u8BA9\u9644\u4EF6\u81EA\u52A8\u968F\u884C\u3002
|
|
49
43
|
- worker \u7A7A\u95F2\u8FC7\u4E45\u6309 TTL \u56DE\u6536\uFF1B\u5173\u95ED\u524D\u786E\u8BA4\u4E0D\u5728 working\u3002
|
|
50
44
|
- \u4F60\u65E0\u4EBA\u503C\u5B88\uFF1A\u6CA1\u6709\u4EBA\u5728\u7EC8\u7AEF\u65C1\u3002\u9700\u8981\u7528\u6237\u51B3\u7B56\u65F6\u628A\u95EE\u9898\u539F\u6837\u53D1\u5230 IM\uFF0C\u4E0D\u8981\u5047\u8BBE\u7B54\u6848\u3002
|
|
51
45
|
- \u6210\u672C\u610F\u8BC6\uFF1A\u4E0D\u5E38\u5F00\u65E0\u7528\u7684 worker\uFF1B\u4E00\u6B21\u6027\u4EFB\u52A1\u7528 pie -p\uFF0C\u9000\u51FA\u5373\u5B8C\u6210\u3002
|
|
52
|
-
- \u7528\u6237\
|
|
46
|
+
- \u4FE1\u4EFB\u9012\u8FDB\uFF1A\u540C\u7C7B\u52A8\u4F5C\u88AB\u7528\u6237\u9A8C\u6536\u591A\u6B21\u540E\u53EF\u4EE5\u51CF\u5C11\u8BF7\u793A\uFF0C\u76F4\u63A5\u505A\u6389\u5E76\u6C47\u62A5\uFF1B\u7528\u6237\u7EA0\u6B63\u8FC7\u7684\u4E8B\u4E0D\u8981\u91CD\u72AF\u3002
|
|
47
|
+
- \u5207\u6A21\u578B\uFF1A\u7528\u6237\u8BF4\u67D0\u4F1A\u8BDD\u989D\u5EA6\u8017\u5C3D/\u60F3\u6362\u6A21\u578B\u65F6\uFF0C\u7528 ipc_control_notify\uFF08to=\u4F1A\u8BDD\u540D\uFF0C control=model.set\uFF0C payload={model: "provider/modelId"}\uFF09\uFF1B\u56DE\u6267\u4F1A\u544A\u8BC9\u4F60\u6210\u529F\u6216\u7ED3\u6784\u5316\u7684\u62D2\u7EDD\u539F\u56E0\u3002\u8FD9\u662F\u9065\u63A7\uFF0C\u4E0D\u4F1A\u5728\u5BF9\u65B9\u4F1A\u8BDD\u91CC\u7559\u4E0B\u4EFB\u4F55\u6D88\u606F\u3002
|
|
53
48
|
- \u6D88\u606F\u6CA1\u6536\u5230 reaction \u65F6\u4E0D\u8981\u8BA9\u5B83\u60AC\u7740\uFF1A\u540C\u4E00\u4EFD\u6B63\u6587\u518D\u53D1\u4E00\u6B21\u5373\u53EF\uFF08\u4E0D\u5E26\u5F15\u7528\uFF09\uFF0C\u6216\u52A0 \`\u4F1A\u8BDD\u540D:\` \u6307\u5B9A\u76EE\u6807\u3002
|
|
54
|
-
${CRON_SECTION}
|
|
49
|
+
${CRON_SECTION}`;
|
|
55
50
|
function workspaceDir() {
|
|
56
51
|
return path.join(os.homedir(), ".pie", "concierge");
|
|
57
52
|
}
|
|
@@ -175,12 +170,11 @@ function seedWorkspace(dir) {
|
|
|
175
170
|
} catch {
|
|
176
171
|
return;
|
|
177
172
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
173
|
+
if (!current.includes(CRON_SECTION_MARKER)) fs.appendFileSync(agents, CRON_SECTION);
|
|
174
|
+
const v1Marker = "\u4F60\u662F\u7528\u6237\u5728 IM \u4E0A\u7684\u552F\u4E00\u8054\u7EDC\u70B9\u3002\u9ED8\u8BA4\u6D3E\u6D3B";
|
|
175
|
+
const v2Marker = "\u4F60\u662F\u88AB\u52A8\u8D77\u6B65\u7684";
|
|
176
|
+
if (current.includes(v1Marker) && !current.includes(v2Marker)) {
|
|
177
|
+
fs.writeFileSync(agents, SEED_AGENTS_MD);
|
|
184
178
|
}
|
|
185
179
|
}
|
|
186
180
|
function isTooBroadForWorkerSandbox(input) {
|
|
@@ -280,7 +274,10 @@ function spawnResident(state, dir) {
|
|
|
280
274
|
detached: true,
|
|
281
275
|
stdio: ["ignore", out, out],
|
|
282
276
|
windowsHide: true,
|
|
283
|
-
|
|
277
|
+
// PIE_PROC_CURATED_NAME: the resident's display name is 管家 from the
|
|
278
|
+
// very first composition (v2 Phase 1.3) — never the first IM/terminal
|
|
279
|
+
// message title, never a flip-flopping derived label.
|
|
280
|
+
env: { ...process.env, PIE_PROC_CURATED_NAME: "\u7BA1\u5BB6" }
|
|
284
281
|
});
|
|
285
282
|
child.unref();
|
|
286
283
|
writeState({ ...state, pid: child.pid, startedAt: Date.now() });
|
package/dist/cli.js
CHANGED
|
@@ -55227,16 +55227,21 @@ function createExtensionContext(extension, cwd, uiContext, abortFn, isIdleFn, ca
|
|
|
55227
55227
|
if (!actions?.setSessionName) throw new Error("setSessionName is not available in this host mode");
|
|
55228
55228
|
return actions.setSessionName(name);
|
|
55229
55229
|
},
|
|
55230
|
+
// MULTI-AGENT IM v2 Phase 2.3: control frames (ipc_control_notify). The
|
|
55231
|
+
// loader context is a WHITELIST forwarder — a field absent here is absent
|
|
55232
|
+
// on the extension ctx even when the host actions provide it (the gap the
|
|
55233
|
+
// paid dogfood caught: the runner shell had it, this loader did not, so
|
|
55234
|
+
// real hosts answered 'does not support control frames').
|
|
55235
|
+
applyIpcControl(control, payload) {
|
|
55236
|
+
if (!actions?.applyIpcControl) return Promise.resolve({ ok: false, message: "host does not support control frames" });
|
|
55237
|
+
return actions.applyIpcControl(control, payload);
|
|
55238
|
+
},
|
|
55230
55239
|
getSessionName() {
|
|
55231
55240
|
return actions?.getSessionName?.();
|
|
55232
55241
|
},
|
|
55233
55242
|
getSessionDisplayName() {
|
|
55234
55243
|
return actions?.getSessionDisplayName?.() ?? actions?.getSessionName?.();
|
|
55235
55244
|
},
|
|
55236
|
-
setCuratedSessionName(name) {
|
|
55237
|
-
if (!actions?.setCuratedSessionName) throw new Error("setCuratedSessionName is not available in this host mode");
|
|
55238
|
-
actions.setCuratedSessionName(name);
|
|
55239
|
-
},
|
|
55240
55245
|
registerProvider(name, config) {
|
|
55241
55246
|
if (!actions?.registerProvider) throw new Error("registerProvider is not available in this host mode");
|
|
55242
55247
|
return actions.registerProvider(name, config);
|
|
@@ -63645,9 +63650,12 @@ var ExtensionRunner = class {
|
|
|
63645
63650
|
if (!runner.actions.setSessionName) throw new Error("setSessionName is not available in this host mode");
|
|
63646
63651
|
return runner.actions.setSessionName(name);
|
|
63647
63652
|
},
|
|
63653
|
+
applyIpcControl: async (control, payload) => {
|
|
63654
|
+
if (!runner.actions.applyIpcControl) return { ok: false, message: "host does not support control frames" };
|
|
63655
|
+
return runner.actions.applyIpcControl(control, payload);
|
|
63656
|
+
},
|
|
63648
63657
|
getSessionName: () => runner.actions.getSessionName?.(),
|
|
63649
63658
|
getSessionDisplayName: () => runner.actions.getSessionDisplayName?.() ?? runner.actions.getSessionName?.(),
|
|
63650
|
-
setCuratedSessionName: (name) => runner.actions.setCuratedSessionName?.(name),
|
|
63651
63659
|
registerProvider: (name, config) => {
|
|
63652
63660
|
if (!runner.actions.registerProvider) throw new Error("registerProvider is not available in this host mode");
|
|
63653
63661
|
return runner.trackUnregisterHandle(runner.actions.registerProvider(name, config));
|
|
@@ -82428,7 +82436,6 @@ async function loadInteractiveExtensions(host) {
|
|
|
82428
82436
|
appendEntry: (customType, data) => host.sessionManager.appendCustomEntry(customType, data).id,
|
|
82429
82437
|
setLabel: (entryId, label) => host.sessionManager.setLabel(entryId, label),
|
|
82430
82438
|
setSessionName: (name) => host.sessionManager.setSessionName(name),
|
|
82431
|
-
setCuratedSessionName: (name) => host.sessionManager.setCuratedSessionName(name),
|
|
82432
82439
|
getSessionName: () => host.sessionManager.getSessionName(),
|
|
82433
82440
|
// Optional on purpose: hand-rolled test harnesses and older hosts may
|
|
82434
82441
|
// not implement it; falling back to the routing name keeps display sane.
|
|
@@ -83526,6 +83533,8 @@ async function composeCliRuntime(params) {
|
|
|
83526
83533
|
syncSessionModelMetadata(sessionManager, model, resolveInitialThinkingLevel({ session: activeSession, settingsManager }));
|
|
83527
83534
|
if (activeSession && createdNewSession) {
|
|
83528
83535
|
activeSession.metadata.cwd = cwd;
|
|
83536
|
+
const curatedName = process.env.PIE_PROC_CURATED_NAME?.trim();
|
|
83537
|
+
if (curatedName) sessionManager.setCuratedSessionName(curatedName);
|
|
83529
83538
|
await sessionManager.save();
|
|
83530
83539
|
}
|
|
83531
83540
|
const sessionId = sessionManager.getActiveSession()?.id;
|
|
@@ -84454,7 +84463,6 @@ async function loadJsonModeExtensions(params) {
|
|
|
84454
84463
|
},
|
|
84455
84464
|
getSessionName: () => params.runtime.sessionManager.getSessionName(),
|
|
84456
84465
|
getSessionDisplayName: () => params.runtime.sessionManager.getSessionDisplayName(),
|
|
84457
|
-
setCuratedSessionName: (name) => params.runtime.sessionManager.setCuratedSessionName(name),
|
|
84458
84466
|
getSessionMetadata: () => ({
|
|
84459
84467
|
...params.runtime.sessionManager.getActiveSession()?.metadata ?? {}
|
|
84460
84468
|
}),
|
|
@@ -84464,21 +84472,39 @@ async function loadJsonModeExtensions(params) {
|
|
|
84464
84472
|
session.metadata[key] = value;
|
|
84465
84473
|
session.isDirty = true;
|
|
84466
84474
|
},
|
|
84467
|
-
|
|
84468
|
-
|
|
84469
|
-
|
|
84470
|
-
|
|
84471
|
-
|
|
84472
|
-
|
|
84473
|
-
|
|
84474
|
-
|
|
84475
|
+
// MULTI-AGENT IM v2 Phase 2.3 — machine-remote control frames
|
|
84476
|
+
// (ipc_control_notify). Distinct from queueExternalInput: a control
|
|
84477
|
+
// mutates host state directly; it NEVER enters the turn pipeline or the
|
|
84478
|
+
// session history. Whitelist is hardcoded here; the extension sender
|
|
84479
|
+
// validates shape first, this is the semantic authority.
|
|
84480
|
+
applyIpcControl: async (control, payload) => {
|
|
84481
|
+
if (control === "model.set") {
|
|
84482
|
+
const ref = payload && typeof payload === "object" && "model" in payload ? String(payload.model) : void 0;
|
|
84483
|
+
if (!ref || !/^[^/\s]+\/[^/\s]+$/.test(ref))
|
|
84484
|
+
return { ok: false, message: "model.set requires payload.model as 'provider/modelId'" };
|
|
84475
84485
|
try {
|
|
84476
|
-
|
|
84477
|
-
|
|
84486
|
+
const { provider, modelId } = { provider: ref.slice(0, ref.indexOf("/")), modelId: ref.slice(ref.indexOf("/") + 1) };
|
|
84487
|
+
const liveAgent = params.getAgent();
|
|
84488
|
+
if (!liveAgent) return { ok: false, message: "runtime not composed" };
|
|
84489
|
+
const model = params.runtime.modelRegistry.find(provider, modelId);
|
|
84490
|
+
if (!model) return { ok: false, message: `model "${ref}" not found` };
|
|
84491
|
+
const apiKey = params.runtime.modelRegistry.getApiKey(model);
|
|
84492
|
+
liveAgent.setModel(model);
|
|
84493
|
+
liveAgent.apiKey = apiKey;
|
|
84494
|
+
params.runtime.model = model;
|
|
84495
|
+
params.runtime.provider = provider;
|
|
84496
|
+
params.runtime.modelId = modelId;
|
|
84497
|
+
params.runtime.apiKey = apiKey;
|
|
84498
|
+
return { ok: true, message: `model set to ${ref}` };
|
|
84499
|
+
} catch (error) {
|
|
84500
|
+
return { ok: false, message: error instanceof Error ? error.message : String(error) };
|
|
84478
84501
|
}
|
|
84479
84502
|
}
|
|
84480
|
-
|
|
84481
|
-
|
|
84503
|
+
return { ok: false, message: `unknown control: ${control}` };
|
|
84504
|
+
},
|
|
84505
|
+
yoloMode: false
|
|
84506
|
+
};
|
|
84507
|
+
const isIdleNow = () => hostIsIdle(params.getController());
|
|
84482
84508
|
const { extensions, errors } = await loadExtensions(
|
|
84483
84509
|
params.runtime.extensionPaths,
|
|
84484
84510
|
params.runtime.cwd,
|
|
@@ -86756,7 +86782,7 @@ async function main() {
|
|
|
86756
86782
|
return;
|
|
86757
86783
|
}
|
|
86758
86784
|
if (args[0] === STABLE_CLI_COMMANDS.concierge) {
|
|
86759
|
-
const { runConciergeCommand } = await import("./chunks/concierge-cli-
|
|
86785
|
+
const { runConciergeCommand } = await import("./chunks/concierge-cli-CQMIAGWJ.js");
|
|
86760
86786
|
try {
|
|
86761
86787
|
await runConciergeCommand(args.slice(1));
|
|
86762
86788
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cydm/pie",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.1",
|
|
4
4
|
"description": "Pie AI Agent CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"test:skill-regressions": "node --test --test-force-exit --import tsx test/axi-bridge-lifecycle.test.ts test/bash-lifecycle.test.ts test/bash-powershell-display.test.ts test/skill-creator-runner.test.ts test/tui-use-contract.test.ts test/tui-use-runtime.test.ts test/tui-use-reap.test.ts test/tui-use-kill-escalation.test.ts test/browser-runtime.test.ts test/axi-stop-semantics.test.ts test/axi-page-routing.test.ts test/computer-use-axi.test.ts test/computer-evidence.test.ts test/interactive-lifecycle.test.ts",
|
|
21
21
|
"test:offline:post": "node --test --test-force-exit --import tsx test/remote-model-catalog.test.ts",
|
|
22
22
|
"test:offline": "node ../../scripts/run-cli-offline.mjs",
|
|
23
|
-
"test:offline:main": "node --test --test-concurrency=2 --test-force-exit --import tsx test/cli-attention.test.ts test/cron.test.ts test/cron-process.test.ts test/cron-poll-gate.test.ts test/memory-distill.test.ts test/memory-injection-freeze.test.ts test/memory-consumption-e2e.test.ts test/memory-frozen-matching.test.ts test/memory-soul-injection.test.ts test/config-dir-fail-closed.test.ts test/cron-concurrency.test.ts test/cron-dogfood.test.ts test/cron.terminal.test.ts test/cron-journey.terminal.test.ts test/builtin-extensions.test.ts test/im-forward.test.ts test/im-forward-cli.test.ts test/im-forward-integration.test.ts test/im-forward-dogfood.terminal.test.ts test/thread-registry.test.ts test/extension-user-input.test.ts test/pie-ipc-pure.test.ts test/pie-ipc-discovery.test.ts test/pie-ipc-transport.test.ts test/pie-ipc-delivery.test.ts test/pie-ipc-extension.test.ts test/pie-ipc-e2e.test.ts test/pie-ipc-security.test.ts test/pie-ipc-dogfood.test.ts test/pie-ipc-resident-dispatch.test.ts test/pie-proc.test.ts test/pie-ipc-host.terminal.test.ts test/core-services.test.ts test/cli.test.ts test/cli-auto-compaction.test.ts test/execution-state-manager.test.ts test/queued-steer-execution-state.test.ts test/todo-steering-ownership.test.ts test/architecture-boundaries.test.ts test/attachment-resolver.test.ts test/kimi-attachment-provider.test.ts test/document-attachment-extension.test.ts test/auto-compact-overflow.test.ts test/auto-compaction-ui.test.ts test/tool-compaction-dogfood.terminal.test.ts test/hierarchical-command-system.test.ts test/mcp-adapter.test.ts test/herdr-agent-state.test.ts test/extensions-enablement.test.ts test/extension-selector-shortcuts.test.ts test/skill-tool-enablement.test.ts test/message-queue-unit.test.ts test/evals-harness.test.ts test/session-trace.test.ts test/json-events-event-sink.test.ts test/json-events-lifecycle-bridge.test.ts test/json-events-self-input.test.ts test/json-events-idle-mode.test.ts test/concierge-cli.test.ts test/json-events-sidechat-diagnostics.test.ts test/json-events-prewarm-shutdown.test.ts test/json-envelope-composition.test.ts test/subagent-session-store.test.ts test/supervisor-anchor-inject.test.ts test/runtime-mode-context.test.ts test/tool-policy.test.ts test/retry-policy.test.ts test/yolo-command.test.ts test/footer-lifecycle.test.ts test/footer-waiting-for-user.test.ts test/files-utils.test.ts test/source-size-guard.test.ts test/runtime-logger.test.ts test/release-readiness.test.ts test/package-artifacts.test.ts test/init-extension-contract.test.ts test/skills-runtime.test.ts test/skills-agents-discovery.test.ts test/skills-symlink.test.ts test/model-overrides.test.ts test/auth-storage.test.ts test/extension-register-provider.test.ts test/extension-reload.test.ts test/extension-terminal-input.test.ts test/extension-session-before-events.test.ts test/extension-widgets.test.ts test/extension-render-hint.test.ts test/extension-oauth-restore.test.ts test/cross-host-parity.test.ts test/tool-name-rendering.test.ts test/session-selector.test.ts test/tree-selector-pagination.test.ts test/context-report.test.ts test/context-signals.test.ts test/plan-cache-stability.test.ts test/cache-invalidation-trace.test.ts test/cache-retention.test.ts test/trace-report.test.ts test/boot-report.test.ts test/compaction-diff.test.ts test/entry-body-and-usage.test.ts test/session-control.test.ts test/terminal-title.test.ts test/interactive-controller-title.test.ts test/todo-title.terminal.test.ts test/host-envelope-dogfood.terminal.test.ts test/host-envelope-cross-mode.test.ts test/host-envelope-registry-lifecycle.test.ts test/host-envelope-migration-roundtrip.test.ts test/host-envelope-intake-order.test.ts test/plan-mode-extension.test.ts test/extension-interaction-signals.test.ts test/rendered-page-reader.test.ts test/tools-registry.test.ts test/system-prompt-contract.test.ts test/bash-yolo.test.ts test/bash-contract.test.ts test/bash-confirm-pending.test.ts test/interaction-status-lifecycle.test.ts test/bash-process-group.test.ts test/bash-artifact-sink.test.ts test/direct-bash.test.ts test/terminal-bell.test.ts test/ctrl-d-exit.test.ts test/session-display-title.test.ts test/calm-mode.test.ts test/stream-render-throttle.test.ts test/assistant-message-performance.test.ts test/streaming-split-parity.test.ts test/message-display-resync.test.ts test/project-root.test.ts test/guard-advisory-context.test.ts test/clear-command-usage.test.ts test/daily-agent-smoke.terminal.test.ts test/slash-menu-toggles.terminal.test.ts test/cli-args.test.ts test/session-resume-cwd.test.ts test/session-resume-restart.test.ts test/session-resume-picker.test.ts test/extensions-configured-paths.test.ts test/extensions-loader-path.test.ts test/file-picker.test.ts test/interrupt-recovery.test.ts test/mention-insert-regression.test.ts test/image-paste.test.ts test/clipboard-read-image.test.ts test/clipboard-races.test.ts test/clipboard-dogfood.terminal.test.ts test/mention-picker-navigation.test.ts test/pie-unity-rpc-skill.test.ts test/skill-creator-scripts.test.ts test/interactive-compact-command.test.ts test/computer-use-broker.test.ts test/computer-use-review-regressions.test.ts test/computer-use-safety.test.ts ../../scripts/node-test-diagnostics.test.js ../../scripts/offline-test-runner.test.js ../../scripts/unity-consumer.test.mjs ../../scripts/owned-process-cleanup.test.mjs",
|
|
23
|
+
"test:offline:main": "node --test --test-concurrency=2 --test-force-exit --import tsx test/cli-attention.test.ts test/cron.test.ts test/cron-process.test.ts test/cron-poll-gate.test.ts test/memory-distill.test.ts test/memory-injection-freeze.test.ts test/memory-consumption-e2e.test.ts test/memory-frozen-matching.test.ts test/memory-soul-injection.test.ts test/config-dir-fail-closed.test.ts test/cron-concurrency.test.ts test/cron-dogfood.test.ts test/cron.terminal.test.ts test/cron-journey.terminal.test.ts test/builtin-extensions.test.ts test/im-forward.test.ts test/im-forward-cli.test.ts test/im-forward-integration.test.ts test/im-forward-dogfood.terminal.test.ts test/thread-registry.test.ts test/im-forward-event-hub.test.ts test/im-forward-session-anchors.test.ts test/extension-user-input.test.ts test/pie-ipc-pure.test.ts test/pie-ipc-discovery.test.ts test/pie-ipc-transport.test.ts test/pie-ipc-delivery.test.ts test/pie-ipc-extension.test.ts test/pie-ipc-e2e.test.ts test/pie-ipc-security.test.ts test/pie-ipc-dogfood.test.ts test/pie-ipc-resident-dispatch.test.ts test/pie-proc.test.ts test/pie-ipc-host.terminal.test.ts test/core-services.test.ts test/cli.test.ts test/cli-auto-compaction.test.ts test/execution-state-manager.test.ts test/queued-steer-execution-state.test.ts test/todo-steering-ownership.test.ts test/architecture-boundaries.test.ts test/attachment-resolver.test.ts test/kimi-attachment-provider.test.ts test/document-attachment-extension.test.ts test/auto-compact-overflow.test.ts test/auto-compaction-ui.test.ts test/tool-compaction-dogfood.terminal.test.ts test/hierarchical-command-system.test.ts test/mcp-adapter.test.ts test/herdr-agent-state.test.ts test/extensions-enablement.test.ts test/extension-selector-shortcuts.test.ts test/skill-tool-enablement.test.ts test/message-queue-unit.test.ts test/evals-harness.test.ts test/session-trace.test.ts test/json-events-event-sink.test.ts test/json-events-lifecycle-bridge.test.ts test/json-events-self-input.test.ts test/json-events-idle-mode.test.ts test/concierge-cli.test.ts test/json-events-sidechat-diagnostics.test.ts test/json-events-prewarm-shutdown.test.ts test/json-envelope-composition.test.ts test/subagent-session-store.test.ts test/supervisor-anchor-inject.test.ts test/runtime-mode-context.test.ts test/tool-policy.test.ts test/retry-policy.test.ts test/yolo-command.test.ts test/footer-lifecycle.test.ts test/footer-waiting-for-user.test.ts test/files-utils.test.ts test/source-size-guard.test.ts test/runtime-logger.test.ts test/release-readiness.test.ts test/package-artifacts.test.ts test/init-extension-contract.test.ts test/skills-runtime.test.ts test/skills-agents-discovery.test.ts test/skills-symlink.test.ts test/model-overrides.test.ts test/auth-storage.test.ts test/extension-register-provider.test.ts test/extension-reload.test.ts test/extension-terminal-input.test.ts test/extension-session-before-events.test.ts test/extension-widgets.test.ts test/extension-render-hint.test.ts test/extension-oauth-restore.test.ts test/cross-host-parity.test.ts test/tool-name-rendering.test.ts test/session-selector.test.ts test/tree-selector-pagination.test.ts test/context-report.test.ts test/context-signals.test.ts test/plan-cache-stability.test.ts test/cache-invalidation-trace.test.ts test/cache-retention.test.ts test/trace-report.test.ts test/boot-report.test.ts test/compaction-diff.test.ts test/entry-body-and-usage.test.ts test/session-control.test.ts test/terminal-title.test.ts test/interactive-controller-title.test.ts test/todo-title.terminal.test.ts test/host-envelope-dogfood.terminal.test.ts test/host-envelope-cross-mode.test.ts test/host-envelope-registry-lifecycle.test.ts test/host-envelope-migration-roundtrip.test.ts test/host-envelope-intake-order.test.ts test/plan-mode-extension.test.ts test/extension-interaction-signals.test.ts test/rendered-page-reader.test.ts test/tools-registry.test.ts test/system-prompt-contract.test.ts test/bash-yolo.test.ts test/bash-contract.test.ts test/bash-confirm-pending.test.ts test/interaction-status-lifecycle.test.ts test/bash-process-group.test.ts test/bash-artifact-sink.test.ts test/direct-bash.test.ts test/terminal-bell.test.ts test/ctrl-d-exit.test.ts test/session-display-title.test.ts test/calm-mode.test.ts test/stream-render-throttle.test.ts test/assistant-message-performance.test.ts test/streaming-split-parity.test.ts test/message-display-resync.test.ts test/project-root.test.ts test/guard-advisory-context.test.ts test/clear-command-usage.test.ts test/daily-agent-smoke.terminal.test.ts test/slash-menu-toggles.terminal.test.ts test/cli-args.test.ts test/session-resume-cwd.test.ts test/session-resume-restart.test.ts test/session-resume-picker.test.ts test/extensions-configured-paths.test.ts test/extensions-loader-path.test.ts test/file-picker.test.ts test/interrupt-recovery.test.ts test/mention-insert-regression.test.ts test/image-paste.test.ts test/clipboard-read-image.test.ts test/clipboard-races.test.ts test/clipboard-dogfood.terminal.test.ts test/mention-picker-navigation.test.ts test/pie-unity-rpc-skill.test.ts test/skill-creator-scripts.test.ts test/interactive-compact-command.test.ts test/computer-use-broker.test.ts test/computer-use-review-regressions.test.ts test/computer-use-safety.test.ts ../../scripts/node-test-diagnostics.test.js ../../scripts/offline-test-runner.test.js ../../scripts/unity-consumer.test.mjs ../../scripts/owned-process-cleanup.test.mjs",
|
|
24
24
|
"test:all": "npm run test:offline && npm run test:terminal:vitest",
|
|
25
25
|
"test:cron:tui": "node ../../scripts/run-with-env.mjs PIE_REAL_CRON_TUI=1 -- --test --import tsx test/cron.terminal.test.ts test/cron-journey.terminal.test.ts",
|
|
26
26
|
"test:ipc:tui": "node ../../scripts/run-with-env.mjs PIE_REAL_IPC_TUI=1 -- --test --import tsx test/pie-ipc-host.terminal.test.ts",
|
|
@@ -104,4 +104,4 @@
|
|
|
104
104
|
"typescript": "^5.7.3",
|
|
105
105
|
"vitest": "4.1.11"
|
|
106
106
|
}
|
|
107
|
-
}
|
|
107
|
+
}
|