@cydm/pie 2.8.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builtin/extensions/ask-user/index.js +8 -4
- package/dist/builtin/extensions/changelog/index.js +2 -2
- package/dist/builtin/extensions/cron/index.js +295 -33
- package/dist/builtin/extensions/document-attachments/index.js +1 -1
- package/dist/builtin/extensions/herdr-agent-state/index.js +2 -2
- package/dist/builtin/extensions/im-forward/README.md +20 -5
- package/dist/builtin/extensions/im-forward/index.js +415 -142
- package/dist/builtin/extensions/memory/index.js +83 -30
- package/dist/builtin/extensions/pie-ipc/README.md +2 -2
- package/dist/builtin/extensions/pie-ipc/index.js +269 -30
- package/dist/builtin/extensions/pie-proc/README.md +93 -0
- package/dist/builtin/extensions/pie-proc/index.js +630 -0
- package/dist/builtin/extensions/pie-proc/package.json +11 -0
- package/dist/builtin/extensions/plan-mode/index.js +4 -4
- package/dist/builtin/extensions/subagent/index.js +6 -6
- package/dist/builtin/extensions/todo/index.js +4 -4
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-bridge.js +106 -2
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-cli.js +1 -0
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-runtime.js +1 -1
- package/dist/builtin/skills/chrome-devtools-axi/{chunk-BNSAEVRT.js → chunk-WOGAQ4P5.js} +2 -2
- package/dist/builtin/skills/chrome-devtools-axi/{cli-AO2ZTPRM.js → cli-CHC7XYFU.js} +27 -3
- package/dist/builtin/skills/computer-use-axi/computer-use-axi-broker.js +2 -2
- package/dist/builtin/skills/computer-use-axi/computer-use-axi-cli.js +1 -0
- package/dist/builtin/skills/computer-use-axi/scripts/setup-helper.mjs +6 -2
- package/dist/builtin/skills/tui-use/tui-use-daemon.cjs +179 -9
- package/dist/chunks/{chunk-PK72LVWQ.js → chunk-FDLLNPIE.js} +143 -53
- package/dist/chunks/{chunk-3BC5KGDQ.js → chunk-JQRZLVPY.js} +12 -1
- package/dist/chunks/{chunk-GH4VW2OT.js → chunk-NCP264ZE.js} +8 -2
- package/dist/chunks/{chunk-YRR6C43W.js → chunk-QX6WS73C.js} +1 -1
- package/dist/chunks/{chunk-3NHP7HK5.js → chunk-TDKNKNPL.js} +6 -5
- package/dist/chunks/{chunk-GDIYSMTS.js → chunk-UOZHQ73X.js} +25 -17
- package/dist/chunks/{chunk-RSL7E4R7.js → chunk-WK4N5HT5.js} +66 -23
- package/dist/chunks/chunk-X6LBWHK3.js +37 -0
- package/dist/chunks/concierge-cli-PIOGXKDR.js +939 -0
- package/dist/chunks/{model-registry-LI5THXV4.js → model-registry-YA6U366L.js} +2 -2
- package/dist/chunks/{src-BPSQMSSC.js → src-AB7PLORG.js} +6 -4
- package/dist/chunks/{src-YG5M2H44.js → src-ODLT57PQ.js} +2 -2
- package/dist/chunks/{src-66XSMIAM.js → src-XSLD2IQ2.js} +1 -1
- package/dist/chunks/{src-OPPYTPWG.js → src-ZZZO4HSR.js} +11 -3
- package/dist/chunks/{test-stream-JBWXKOQA.js → test-stream-GIUD5JWS.js} +1 -1
- package/dist/cli.js +1433 -235
- package/package.json +105 -105
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
distillWorkerLogPath,
|
|
4
4
|
readDistillWorkerLog,
|
|
5
5
|
spawnDistillWorker
|
|
6
|
-
} from "../../../chunks/chunk-
|
|
6
|
+
} from "../../../chunks/chunk-TDKNKNPL.js";
|
|
7
7
|
import {
|
|
8
8
|
getConfigDir,
|
|
9
9
|
getSettingsPath
|
|
@@ -12,16 +12,17 @@ import {
|
|
|
12
12
|
DEFAULT_MEMORY_INJECTION_BUDGET,
|
|
13
13
|
MemoryStore,
|
|
14
14
|
consumptionSummary,
|
|
15
|
+
materialConsumedIn,
|
|
15
16
|
projectKeyForDir,
|
|
16
17
|
recordConsumption,
|
|
17
18
|
recordInjection,
|
|
18
19
|
saveAttestedEntry,
|
|
19
20
|
searchMemory,
|
|
20
21
|
todayKey
|
|
21
|
-
} from "../../../chunks/chunk-
|
|
22
|
-
import "../../../chunks/chunk-
|
|
23
|
-
import "../../../chunks/chunk-
|
|
24
|
-
import "../../../chunks/chunk-
|
|
22
|
+
} from "../../../chunks/chunk-FDLLNPIE.js";
|
|
23
|
+
import "../../../chunks/chunk-WK4N5HT5.js";
|
|
24
|
+
import "../../../chunks/chunk-NCP264ZE.js";
|
|
25
|
+
import "../../../chunks/chunk-JQRZLVPY.js";
|
|
25
26
|
import {
|
|
26
27
|
Type
|
|
27
28
|
} from "../../../chunks/chunk-XXGYUYXI.js";
|
|
@@ -108,30 +109,44 @@ function memoryExtension(ctx) {
|
|
|
108
109
|
const project = projectKeyForDir(ctx.cwd);
|
|
109
110
|
let activeSessionId = null;
|
|
110
111
|
ctx.on("session:changed", (event) => {
|
|
111
|
-
|
|
112
|
+
const next = event.sessionId;
|
|
113
|
+
if (activeSessionId !== null && next === null) {
|
|
112
114
|
sessionConsumedIds = /* @__PURE__ */ new Set();
|
|
115
|
+
turnInjectedIds = [];
|
|
113
116
|
injectionMemo = null;
|
|
114
|
-
|
|
115
|
-
ctx.log(`[memory] session
|
|
117
|
+
pendingDistillHint = false;
|
|
118
|
+
ctx.log(`[memory] session unbound (${activeSessionId.slice(0, 8)} \u2192 none): injection memo + consumption scope reset`);
|
|
119
|
+
} else if (activeSessionId !== null && next !== null && activeSessionId !== next) {
|
|
120
|
+
sessionConsumedIds = /* @__PURE__ */ new Set();
|
|
121
|
+
turnInjectedIds = [];
|
|
122
|
+
injectionMemo = null;
|
|
123
|
+
pendingDistillHint = false;
|
|
124
|
+
ctx.log(`[memory] session switch (${activeSessionId.slice(0, 8)} \u2192 ${next.slice(0, 8)}): injection memo + consumption scope reset`);
|
|
116
125
|
}
|
|
117
|
-
activeSessionId =
|
|
126
|
+
activeSessionId = next;
|
|
118
127
|
});
|
|
119
|
-
const INJECTION_IDLE_REFRESH_MS = 60 * 60 * 1e3;
|
|
120
128
|
let injectionMemo = null;
|
|
129
|
+
let turnInjectedIds = [];
|
|
130
|
+
let turnSnapshots = [];
|
|
121
131
|
let sessionConsumedIds = /* @__PURE__ */ new Set();
|
|
122
|
-
let
|
|
132
|
+
let pendingDistillHint = false;
|
|
123
133
|
const distillWatermark = () => Math.max(0, ...Object.values(store.loadState().runs).map((run) => run.ops > 0 ? run.ranAt : 0));
|
|
124
134
|
const updateFooterTag = () => {
|
|
125
|
-
ctx.ui.setStatus?.("memory", readInjectSetting() ? "[MEM]" : void 0);
|
|
135
|
+
ctx.ui.setStatus?.("memory", readInjectSetting() ? pendingDistillHint && injectionMemo !== null ? "[MEM*]" : "[MEM]" : void 0);
|
|
126
136
|
};
|
|
127
137
|
updateFooterTag();
|
|
128
138
|
const refreshInjection = (reason) => {
|
|
139
|
+
pendingDistillHint = false;
|
|
129
140
|
if (injectionMemo === null) return;
|
|
130
141
|
injectionMemo = null;
|
|
131
142
|
ctx.log(`[memory] injection memo dropped (${reason})`);
|
|
132
143
|
};
|
|
133
144
|
ctx.on("agent:end", (event) => {
|
|
134
|
-
|
|
145
|
+
const injectedIds = turnInjectedIds;
|
|
146
|
+
turnInjectedIds = [];
|
|
147
|
+
const snapshots = turnSnapshots;
|
|
148
|
+
turnSnapshots = [];
|
|
149
|
+
if (injectedIds.length === 0) return;
|
|
135
150
|
try {
|
|
136
151
|
const textOf = (message) => {
|
|
137
152
|
if (typeof message.content === "string") return message.content;
|
|
@@ -141,9 +156,16 @@ function memoryExtension(ctx) {
|
|
|
141
156
|
return "";
|
|
142
157
|
};
|
|
143
158
|
const output = event.messages.filter((message) => message.role === "assistant" || message.role === "toolResult").map(textOf).join("\n");
|
|
144
|
-
const eligible =
|
|
159
|
+
const eligible = injectedIds.filter((id) => !sessionConsumedIds.has(id));
|
|
145
160
|
if (eligible.length === 0) return;
|
|
146
|
-
const
|
|
161
|
+
const eligibleSnapshots = snapshots.filter((s) => eligible.includes(s.id));
|
|
162
|
+
const consumed = eligibleSnapshots.filter((s) => snapshotConsumedIn(s, output)).map((s) => s.id);
|
|
163
|
+
if (consumed.length > 0) {
|
|
164
|
+
try {
|
|
165
|
+
recordConsumption(store, consumed, output);
|
|
166
|
+
} catch {
|
|
167
|
+
}
|
|
168
|
+
}
|
|
147
169
|
for (const id of consumed) sessionConsumedIds.add(id);
|
|
148
170
|
if (consumed.length > 0) {
|
|
149
171
|
ctx.log(`[memory] consumption credited: ${consumed.length} entr${consumed.length === 1 ? "y" : "ies"} this session`);
|
|
@@ -153,27 +175,33 @@ function memoryExtension(ctx) {
|
|
|
153
175
|
}
|
|
154
176
|
});
|
|
155
177
|
ctx.on("before_agent_start", (event) => {
|
|
178
|
+
turnInjectedIds = [];
|
|
156
179
|
try {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
lastTurnAt = now;
|
|
161
|
-
if (!readInjectSetting()) return {};
|
|
180
|
+
const injectOn = readInjectSetting();
|
|
181
|
+
ctx.ui.setStatus?.("memory", injectOn ? pendingDistillHint && injectionMemo !== null ? "[MEM*]" : "[MEM]" : void 0);
|
|
182
|
+
if (!injectOn) return {};
|
|
162
183
|
const watermark = distillWatermark();
|
|
163
|
-
if (injectionMemo === null
|
|
184
|
+
if (injectionMemo === null) {
|
|
164
185
|
const built = buildInjectionSectionWithIds(store, budget, project.key);
|
|
165
186
|
injectionMemo = {
|
|
166
187
|
text: built.text,
|
|
167
188
|
watermark,
|
|
168
|
-
injectedIds: built.injectedIds
|
|
189
|
+
injectedIds: built.injectedIds,
|
|
190
|
+
snapshots: built.snapshots
|
|
169
191
|
};
|
|
192
|
+
pendingDistillHint = false;
|
|
170
193
|
try {
|
|
171
194
|
recordInjection(store, built.injectedIds);
|
|
172
195
|
} catch (error) {
|
|
173
196
|
ctx.log(`[memory] injection accounting failed (skipped): ${String(error)}`);
|
|
174
197
|
}
|
|
198
|
+
} else if (watermark > injectionMemo.watermark) {
|
|
199
|
+
pendingDistillHint = true;
|
|
200
|
+
ctx.ui.setStatus?.("memory", "[MEM*]");
|
|
175
201
|
}
|
|
176
202
|
if (!injectionMemo.text) return;
|
|
203
|
+
turnInjectedIds = [...injectionMemo.injectedIds];
|
|
204
|
+
turnSnapshots = injectionMemo.snapshots;
|
|
177
205
|
return { systemPrompt: `${event.baseSystemPrompt}
|
|
178
206
|
|
|
179
207
|
${injectionMemo.text}` };
|
|
@@ -182,6 +210,7 @@ ${injectionMemo.text}` };
|
|
|
182
210
|
return {};
|
|
183
211
|
}
|
|
184
212
|
});
|
|
213
|
+
const snapshotConsumedIn = (snapshot, output) => materialConsumedIn(snapshot.text, snapshot.quotes, output);
|
|
185
214
|
ctx.registerTool({
|
|
186
215
|
name: "memory_save",
|
|
187
216
|
description: 'Explicitly save a durable memory. HIGHEST-PRIORITY RULE: when the user explicitly asks to remember something (e.g. "\u8BB0\u4F4F\u2026", "from now on\u2026", "always\u2026"), you MUST call this tool \u2014 never claim you will remember without a successful call. Supersedes conflicting entries of the same kind automatically. After success, confirm briefly (e.g. "\u5DF2\u8BB0\u4F4F\uFF1A\u2026"). If this tool is unavailable, say the request only holds for the current session.',
|
|
@@ -192,8 +221,8 @@ ${injectionMemo.text}` };
|
|
|
192
221
|
Type.Literal("project"),
|
|
193
222
|
Type.Literal("thread")
|
|
194
223
|
]),
|
|
195
|
-
text: Type.String({ description: "The durable memory,
|
|
196
|
-
quote: Type.String({ description: "The user's verbatim phrasing that attests this memory, <= 240 chars", maxLength: 240, minLength: 1 })
|
|
224
|
+
text: Type.String({ description: "The durable memory, MAX 240 characters \u2014 write one compact line and count the length before sending; over-length calls are rejected. In the user's dominant language", maxLength: 240 }),
|
|
225
|
+
quote: Type.String({ description: "The user's verbatim phrasing that attests this memory, <= 240 chars \u2014 trim with an ellipsis if the source is longer", maxLength: 240, minLength: 1 })
|
|
197
226
|
}),
|
|
198
227
|
async execute(args) {
|
|
199
228
|
const { ops, entryId } = saveAttestedEntry(store, {
|
|
@@ -272,8 +301,26 @@ function buildInjectionSectionWithIds(store, budget, projectKey) {
|
|
|
272
301
|
const memory = take("memory", budget.memory);
|
|
273
302
|
const threads = take("threads", budget.threads);
|
|
274
303
|
const projectLines = projectKey ? take("project", budget.project, (entry) => entry.projectKey === projectKey) : [];
|
|
304
|
+
const soulRaw = store.readSoul();
|
|
305
|
+
let soulBudgetTokens = 0;
|
|
306
|
+
let soulText;
|
|
307
|
+
if (soulRaw) {
|
|
308
|
+
const candidate = soulRaw.slice(0, 2e3);
|
|
309
|
+
if (estimateTokens(candidate) <= budget.soul) {
|
|
310
|
+
soulText = candidate;
|
|
311
|
+
soulBudgetTokens = estimateTokens(candidate);
|
|
312
|
+
} else {
|
|
313
|
+
let fit = candidate;
|
|
314
|
+
while (fit.length > 0 && estimateTokens(fit) > budget.soul) {
|
|
315
|
+
const cut = fit.lastIndexOf("\n");
|
|
316
|
+
fit = cut > 0 ? fit.slice(0, cut) : fit.slice(0, Math.floor(fit.length / 2));
|
|
317
|
+
}
|
|
318
|
+
soulText = fit.length > 0 ? `${fit}
|
|
319
|
+
\u2026\uFF08\u4EBA\u683C\u622A\u65AD\uFF1ASOUL.md \u8D85\u51FA\u9884\u7B97\uFF0C\u5B8C\u6574\u7248\u8BF7\u7F16\u8F91 ~/.pie/memory/SOUL.md \u7F29\u77ED\uFF09` : void 0;
|
|
320
|
+
soulBudgetTokens = fit.length > 0 ? estimateTokens(fit) : 0;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
275
323
|
const recentDates = store.listJournalDates().slice(-3);
|
|
276
|
-
let digestUsed = 0;
|
|
277
324
|
const digest = [];
|
|
278
325
|
for (const date of recentDates.reverse()) {
|
|
279
326
|
const journal = store.readJournal(date);
|
|
@@ -285,10 +332,11 @@ function buildInjectionSectionWithIds(store, budget, projectKey) {
|
|
|
285
332
|
digest.push(`- ${date}: ${snippet}`);
|
|
286
333
|
digestUsed += cost;
|
|
287
334
|
}
|
|
288
|
-
if (user.length === 0 && memory.length === 0 && threads.length === 0 && projectLines.length === 0 && digest.length === 0) {
|
|
289
|
-
return { text: "", injectedIds: [] };
|
|
335
|
+
if (user.length === 0 && memory.length === 0 && threads.length === 0 && projectLines.length === 0 && digest.length === 0 && !soulText) {
|
|
336
|
+
return { text: "", injectedIds: [], snapshots: [] };
|
|
290
337
|
}
|
|
291
338
|
const sections = [];
|
|
339
|
+
if (soulText) sections.push({ heading: "Soul (persona)", items: [{ line: soulText }] });
|
|
292
340
|
if (user.length > 0) sections.push({ heading: "User (stable preferences)", items: user });
|
|
293
341
|
if (projectLines.length > 0) sections.push({ heading: "This project", items: projectLines });
|
|
294
342
|
if (memory.length > 0) sections.push({ heading: "Durable facts", items: memory });
|
|
@@ -301,9 +349,14 @@ function buildInjectionSectionWithIds(store, budget, projectKey) {
|
|
|
301
349
|
const render = (list) => ["## Memory", "", ...list.flatMap((section) => [`### ${section.heading}`, ...section.items.map((item) => item.line), ""]), footer].join("\n").trim();
|
|
302
350
|
while (sections.length > 0) {
|
|
303
351
|
const rendered = render(sections);
|
|
304
|
-
if (estimateTokens(rendered) <= ceiling) {
|
|
352
|
+
if (estimateTokens(rendered) <= ceiling + soulBudgetTokens) {
|
|
305
353
|
const injectedIds = sections.flatMap((section) => section.items.map((item) => item.id).filter((id) => id !== void 0));
|
|
306
|
-
|
|
354
|
+
const byId = new Map(entries.map((entry) => [entry.id, entry]));
|
|
355
|
+
const snapshots = injectedIds.map((id) => {
|
|
356
|
+
const entry = byId.get(id);
|
|
357
|
+
return { id, text: entry?.text ?? "", quotes: entry?.evidence.map((ev) => ev.quote) ?? [] };
|
|
358
|
+
});
|
|
359
|
+
return { text: rendered, injectedIds, snapshots };
|
|
307
360
|
}
|
|
308
361
|
const last = sections[sections.length - 1];
|
|
309
362
|
if (last.items.length > 0) {
|
|
@@ -313,7 +366,7 @@ function buildInjectionSectionWithIds(store, budget, projectKey) {
|
|
|
313
366
|
sections.pop();
|
|
314
367
|
}
|
|
315
368
|
}
|
|
316
|
-
return { text: "", injectedIds: [] };
|
|
369
|
+
return { text: "", injectedIds: [], snapshots: [] };
|
|
317
370
|
}
|
|
318
371
|
function memoryOverview(store) {
|
|
319
372
|
const entries = store.loadEntries();
|
|
@@ -12,10 +12,10 @@ No configuration is required. By default IPC trusts authenticated local clients
|
|
|
12
12
|
}
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
Absent `allowPeers` defaults to `["*"]`, trusting authenticated local clients; an explicit empty array **denies** messages and bodies. `/tools/ipc allow <instance-id>` approves one peer for this runtime. `autoInject` defaults to `true`; set it to `false` for inbox + poll delivery. Unreadable config files disable IPC rather than selecting these defaults. Same-user processes are trusted, not isolated. Auto-injection
|
|
15
|
+
Absent `allowPeers` defaults to `["*"]`, trusting authenticated local clients; an explicit empty array **denies** messages and bodies. `/tools/ipc allow <instance-id>` approves one peer for this runtime. `autoInject` defaults to `true`; set it to `false` for inbox + poll delivery. Unreadable config files disable IPC rather than selecting these defaults. Same-user processes are trusted, not isolated. Auto-injection works on interactive TUI hosts AND long-lived embedded hosts (json-events residents): since S1 the resident's sendUserMessage is real controller-queue intake, so injected messages queue as genuine follow-up turns. One-shot headless (`pie -p`) clients can send and wait without advertising but are never injected.
|
|
16
16
|
|
|
17
17
|
Use `/tools/ipc peers`, `/tools/ipc status <peer>`, `/tools/ipc send <peer> <text>`, `/tools/ipc result <peer> [requestId]`, `/tools/ipc poll`, `/tools/ipc name`, `/tools/ipc mute [off]`, and `/tools/ipc allow <id|*>`. Only explicit `/tools/ipc poll` submits command output to the model; other commands notify the user. Changes from commands are ephemeral.
|
|
18
18
|
|
|
19
|
-
Tools: `ipc_list_peers`, `ipc_status`, `
|
|
19
|
+
Tools: `ipc_list_peers`, `ipc_status`, `ipc_send_notify`, `ipc_result`, `ipc_poll`. Every send exposes a requestId. `ipc_send_notify` — the name is the contract: sending subscribes to completion by DEFAULT (returns after the receipt ack; the peer pushes one `[ipc-done]` message with outcome + bounded answer when its turn settles). On interactive AND embedded resident hosts it is injected (single wake — both are editorInjection hosts); on one-shot headless clients it lands in the pollable inbox with an informational `[ipc-done-check]` hint. A local fallback timer (`fallbackMs`) wakes a result check if no push arrives. Explicit `notify:false` opts out to fire-and-forget (no wake, receipt unconfirmed). Non-waiting requests can be polled with `ipc_result` through accepted/running/done or failed; omitting requestId lists recent results. Reads do not consume results. Results are session-scoped, bounded, retained in memory only, and unknown after eviction/restart. A receipt is not a result: waited results use the original authenticated socket after input consumption and execution settlement. Queued/muted input never receives unrelated turn output. Delivery is bounded, best-effort, not durable; uncertain busy followups are never automatically duplicated. Restart every peer after protocol changes; there is no compatibility layer. Windows uses native HANDLE-based ACL verification and atomic protected directory and temporary-file creation. Ancestors with public add-file/write-data, write-attributes, write-EA, delete or control grants are rejected (including standard ProgramData when it has these rights). No-delete handles prevent rename/delete; ACL checks, not a reparse lock, exclude untrusted in-place mutation. Unsafe profile/TEMP/drive ancestry fails closed without repair or insecure fallback; use an explicitly provisioned safe `PIE_IPC_CONFIG_DIR` if needed. Same-user isolation and the stale-advertisement/first-send unencrypted endpoint-identity limitation remain outside this guarantee; see the release checklist below.
|
|
20
20
|
|
|
21
21
|
See [the complete contract](../../../../../docs/pie-ipc.md) for configuration, HMAC/permissions, snapshot freshness, limits, recovery limitations, and reproducible tests including a checked-in two-process factory dogfood driver.
|