@nexrall/code-core 1.4.72 → 1.4.74
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/agent/compaction.d.ts.map +1 -1
- package/dist/agent/compaction.js +17 -13
- package/dist/agent/hooks.d.ts +13 -0
- package/dist/agent/hooks.d.ts.map +1 -1
- package/dist/agent/hooks.js +1 -0
- package/dist/agent/loop.d.ts.map +1 -1
- package/dist/agent/loop.js +82 -2
- package/dist/agent/sharedTasks.d.ts +21 -6
- package/dist/agent/sharedTasks.d.ts.map +1 -1
- package/dist/agent/sharedTasks.js +69 -17
- package/dist/agent/taskEvents.d.ts +73 -0
- package/dist/agent/taskEvents.d.ts.map +1 -0
- package/dist/agent/taskEvents.js +297 -0
- package/dist/api/client.d.ts +6 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/mcp/client.d.ts +8 -0
- package/dist/mcp/client.d.ts.map +1 -1
- package/dist/mcp/manager.d.ts +11 -0
- package/dist/mcp/manager.d.ts.map +1 -1
- package/dist/mcp/manager.js +18 -0
- package/dist/tools/executor.d.ts +6 -0
- package/dist/tools/executor.d.ts.map +1 -1
- package/dist/tools/executor.js +116 -6
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compaction.d.ts","sourceRoot":"","sources":["../../src/agent/compaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAgB,gBAAgB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAIpF,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAyB,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAiCnE,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM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,CAAC,CAAC,CAAC,CAAC,EACtD,WAAW,CAAC,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,GACjC,gBAAgB,CAuBlB;AASD,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,EAAE,gBAAgB,EACzB,MAAM,CAAC,EAAE,cAAc,EACvB,eAAe,CAAC,EAAE,gBAAgB,GACjC,OAAO,CAAC,OAAO,CAAC,CAmJlB;AAaD,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAgCrG;AAwBD,gFAAgF;AAChF,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,CAE/D;AAED;;;;;;;;;GASG;AACH,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,OAAO,EAAE,EACnB,IAAI,EAAE;IACJ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,UAAU,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC,GACA,OAAO,CAAC,OAAO,CAAC,CAqFlB"}
|
package/dist/agent/compaction.js
CHANGED
|
@@ -150,20 +150,23 @@ function envFraction(name, fallback) {
|
|
|
150
150
|
}
|
|
151
151
|
// Where auto-compaction fires, in TOKENS — Claude Code's rule, not a fraction of a 1M window.
|
|
152
152
|
//
|
|
153
|
-
// Claude Code summarises at `window − min(maxOutput, 20K) − 13K buffer
|
|
154
|
-
//
|
|
155
|
-
//
|
|
156
|
-
// the same
|
|
157
|
-
//
|
|
158
|
-
// the
|
|
153
|
+
// Claude Code summarises at `window − min(maxOutput, 20K) − 13K buffer` on the MODEL's own
|
|
154
|
+
// window. That window used to be a flat 200K (~167K tokens) — and so was ours, matching the
|
|
155
|
+
// 200K-window era. Since Claude Code 2.1.197 its 1M-context models (Sonnet 5, Opus 4.7+,
|
|
156
|
+
// Fable) put the same line near ~967K, only dropping back to 200K when a model fallback
|
|
157
|
+
// swaps the window out; a flat 200K cap beside a 1M model summarised at roughly a sixth of
|
|
158
|
+
// the conversation Claude Code keeps. The default now follows the model's real window.
|
|
159
159
|
//
|
|
160
|
-
//
|
|
161
|
-
//
|
|
162
|
-
//
|
|
163
|
-
|
|
160
|
+
// The cost note that motivated the old cap still stands (a long prefix re-read from cache
|
|
161
|
+
// every turn is real money), so an explicit cap is one setting away:
|
|
162
|
+
//
|
|
163
|
+
// NEXRALL_COMPACT_WINDOW / settings.json "autoCompactWindow": an explicit cap (tokens).
|
|
164
|
+
// e.g. 200000 tidies up early (the pre-2026-10-04 default), 1000000 allows a full window.
|
|
165
|
+
// NEXRALL_PRUNE_THRESHOLD / NEXRALL_COMPACT_THRESHOLD: fractions of the effective window.
|
|
164
166
|
const COMPACT_OUTPUT_RESERVE = 20000; // Claude Code: min(model max output, 20K)
|
|
165
167
|
const COMPACT_BUFFER_TOKENS = 13000; // Claude Code's autocompact buffer
|
|
166
|
-
const DEFAULT_PRUNE_FRACTION = 0.6; // cheap lossless prune
|
|
168
|
+
const DEFAULT_PRUNE_FRACTION = 0.6; // cheap lossless prune at 0.6x the window, before the summarise
|
|
169
|
+
/** Explicit cap from env/settings, or undefined to use the model's own window. */
|
|
167
170
|
function compactWindowCap(settingsRaw) {
|
|
168
171
|
const fromEnv = Number(process.env.NEXRALL_COMPACT_WINDOW);
|
|
169
172
|
if (Number.isFinite(fromEnv) && fromEnv >= 50000)
|
|
@@ -171,11 +174,12 @@ function compactWindowCap(settingsRaw) {
|
|
|
171
174
|
const fromSettings = Number(settingsRaw?.autoCompactWindow);
|
|
172
175
|
if (Number.isFinite(fromSettings) && fromSettings >= 50000)
|
|
173
176
|
return fromSettings;
|
|
174
|
-
return
|
|
177
|
+
return undefined;
|
|
175
178
|
}
|
|
176
179
|
/** Token counts at which auto-prune and auto-compact (summarise) fire for a model window. */
|
|
177
180
|
function compactionLimits(contextWindow, settingsRaw) {
|
|
178
|
-
const
|
|
181
|
+
const cap = compactWindowCap(settingsRaw);
|
|
182
|
+
const eff = cap === undefined ? contextWindow : Math.min(contextWindow, cap);
|
|
179
183
|
const compactFrac = envFraction('NEXRALL_COMPACT_THRESHOLD', 0);
|
|
180
184
|
const pruneFrac = envFraction('NEXRALL_PRUNE_THRESHOLD', 0);
|
|
181
185
|
const compact = compactFrac
|
package/dist/agent/hooks.d.ts
CHANGED
|
@@ -153,6 +153,19 @@ export interface HooksConfig {
|
|
|
153
153
|
* the task stays open. No matcher.
|
|
154
154
|
*/
|
|
155
155
|
TaskCompleted?: Array<HookEntry | HookDef>;
|
|
156
|
+
/**
|
|
157
|
+
* ANOTHER process changed the shared task board and this session noticed — the
|
|
158
|
+
* cross-session counterpart of TaskCreated/TaskCompleted, which only ever fire
|
|
159
|
+
* inside the session that acted. Delivered at the loop's normal drain points
|
|
160
|
+
* (before the next model request / with tool results), never for this process's
|
|
161
|
+
* own writes, and never for events that predate the session. Matcher = event
|
|
162
|
+
* type: `created`, `claimed`, `released`, `reopened`, `completed`, `removed`.
|
|
163
|
+
* Payload: `task_id`, `task_subject`, `task_event`, `actor?`, plus
|
|
164
|
+
* `unblocked_task_ids` when a completion freed tasks up. Observer: exit code is
|
|
165
|
+
* ignored; `additionalContext` / `systemMessage` ride along with the board
|
|
166
|
+
* note the model receives.
|
|
167
|
+
*/
|
|
168
|
+
TaskUpdated?: Array<HookEntry | HookDef>;
|
|
156
169
|
/**
|
|
157
170
|
* An MCP server asked the user for input mid-tool-call (its `elicitation/create`
|
|
158
171
|
* request). Runs BEFORE the interactive dialog: a hook whose stdout carries
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/agent/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA0C,UAAU,EAAE,U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;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,iBAAiB,EACzB,IAAI,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAO,GACvE,OAAO,CAAC,iBAAiB,CAAC,CAuD5B;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CASjB;AAED,mGAAmG;AACnG,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,SAAsB,GAAG,IAAI,CAUxG;AAED,iHAAiH;AACjH,uFAAuF;AACvF,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,kBAAkB,EAAE,MAAM,GACzB,OAAO,CAAC,IAAI,CAAC,CAcf;AAED,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,mBAAmB,EAAE,MAAM,GAC1B,OAAO,CAAC,IAAI,CAAC,CAcf"}
|
package/dist/agent/hooks.js
CHANGED
package/dist/agent/loop.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../src/agent/loop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAKP,UAAU,EACV,gBAAgB,EAEjB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAiC,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"loop.d.ts","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,kBAAkB,GACtB;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAwD9F;AAyBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,cAAc,CAClC,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,gBAAgB,EACzB,UAAU,EAAE,SAAS,EAAE,GACtB,OAAO,CAAC,UAAU,CAAC,CAkBrB;AAID,wBAAsB,YAAY,CAAC,eAAe,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAu3D5G;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,CAmCtE"}
|
package/dist/agent/loop.js
CHANGED
|
@@ -15,6 +15,7 @@ const types_1 = require("../types");
|
|
|
15
15
|
const client_1 = require("../api/client");
|
|
16
16
|
const executor_1 = require("../tools/executor");
|
|
17
17
|
const sharedTasks_1 = require("./sharedTasks");
|
|
18
|
+
const taskEvents_1 = require("./taskEvents");
|
|
18
19
|
const agentTypes_1 = require("./agentTypes");
|
|
19
20
|
const skills_1 = require("./skills");
|
|
20
21
|
const nestedInstructions_1 = require("./nestedInstructions");
|
|
@@ -581,6 +582,17 @@ async function runAgentLoop(initialMessages, options) {
|
|
|
581
582
|
// servers its allowlist names (another server's notes are not its business).
|
|
582
583
|
// The size caps live in mcp/instructions.ts.
|
|
583
584
|
const mcpInstructionsBlock = () => (0, instructions_1.formatMcpInstructions)((options.mcpManager?.serverInstructions() ?? []).filter((e) => !options._mcpServerAllowlist || options._mcpServerAllowlist.has(e.server)));
|
|
585
|
+
// Per-server `alwaysLoad` (CC parity): names the user pinned in mcp.json. The
|
|
586
|
+
// backend keeps their `<server>__*` tools out of BOTH deferral paths (tool-search
|
|
587
|
+
// `defer_loading` and the cap selector's droppable set). Sub-agent runs narrow the
|
|
588
|
+
// list to servers their own allowlist can actually reach — naming a server the run
|
|
589
|
+
// cannot use would protect nothing and leak the catalogue's shape. Empty →
|
|
590
|
+
// undefined so older backends receive the exact same body as before.
|
|
591
|
+
const alwaysLoadServerNames = (() => {
|
|
592
|
+
const named = options.mcpManager?.alwaysLoadServers() ?? [];
|
|
593
|
+
const scoped = named.filter((n) => !options._mcpServerAllowlist || options._mcpServerAllowlist.has(n));
|
|
594
|
+
return scoped.length ? scoped : undefined;
|
|
595
|
+
})();
|
|
584
596
|
// The request options every main-loop call sends. Shared with the compaction
|
|
585
597
|
// summariser so its request has the SAME system prompt and tools as the conversation
|
|
586
598
|
// — that is what lets the summary call read the whole history from cache (0.10×)
|
|
@@ -633,6 +645,10 @@ async function runAgentLoop(initialMessages, options) {
|
|
|
633
645
|
// (and gets refused on) write, office and image tools. Sorted so the tools cache
|
|
634
646
|
// prefix is identical for every run of the same agent type.
|
|
635
647
|
toolAllowlist: options._allowedTools ? [...options._allowedTools].sort() : undefined,
|
|
648
|
+
// Servers the user pinned with `alwaysLoad: true` (computed above). The backend
|
|
649
|
+
// keeps their `<server>__*` tools out of the tool cap and both deferral paths;
|
|
650
|
+
// undefined (not []) when nothing is pinned so older backends see the same body.
|
|
651
|
+
alwaysLoadServers: alwaysLoadServerNames,
|
|
636
652
|
// Withholds the `task` schema and its instructions when this run cannot
|
|
637
653
|
// delegate — see canSpawnSubAgents.
|
|
638
654
|
canSpawnSubAgents: maySpawn,
|
|
@@ -654,6 +670,54 @@ async function runAgentLoop(initialMessages, options) {
|
|
|
654
670
|
const readDedupe = new readDedupe_1.ReadDedupe(options.workDir);
|
|
655
671
|
// Only the main agent owns background agents (runSubTask never passes the hub down).
|
|
656
672
|
const drainBackgroundNotifications = () => (depth === 0 ? (options.backgroundAgents?.takeNotifications() ?? []) : []);
|
|
673
|
+
// Cross-session task-board events (see agent/taskEvents.ts): board changes
|
|
674
|
+
// OTHER processes made on this project — "the task you were waiting on just
|
|
675
|
+
// completed" — rendered as notes the model can act on, and fed through this
|
|
676
|
+
// session's TaskUpdated hooks on the way. Drained at the same boundaries as
|
|
677
|
+
// peer messages, for the same reason: never mid-tool-call, always before the
|
|
678
|
+
// next request. depth>0 returns [] BEFORE touching the cursor: a sub-agent
|
|
679
|
+
// shares this process's event cursor, and a child's drain would consume
|
|
680
|
+
// events the parent session was about to see.
|
|
681
|
+
const collectTaskEventTexts = async () => {
|
|
682
|
+
if (depth > 0)
|
|
683
|
+
return [];
|
|
684
|
+
const events = (0, taskEvents_1.takeNewTaskEvents)(options.workDir, { sessionKey: options.sessionId });
|
|
685
|
+
if (!events.length)
|
|
686
|
+
return [];
|
|
687
|
+
const notes = (0, taskEvents_1.formatTaskEventNotes)(events, (0, sharedTasks_1.listSharedTasks)(options.workDir));
|
|
688
|
+
// Hand the same notes to the host's UI (chat.ts prints a dim one-liner)
|
|
689
|
+
// BEFORE rendering hook additions: the UI shows the board fact, the model
|
|
690
|
+
// additionally gets whatever TaskUpdated hooks add below.
|
|
691
|
+
if (notes.length)
|
|
692
|
+
options.onTaskNotes?.(notes);
|
|
693
|
+
const noteFor = (id, ts, type) => notes.find((n) => n.event.taskId === id && n.event.ts === ts && n.event.type === type);
|
|
694
|
+
const texts = [];
|
|
695
|
+
for (const ev of events) {
|
|
696
|
+
const note = noteFor(ev.taskId, ev.ts, ev.type);
|
|
697
|
+
let text = note?.text ?? '';
|
|
698
|
+
if (hooks.TaskUpdated?.length) {
|
|
699
|
+
// Observer (exit code ignored): the board change already happened in
|
|
700
|
+
// another process — there is nothing here to veto. Matcher = event type.
|
|
701
|
+
const outcome = await (0, hooks_1.runLifecycleHooks)(hooks.TaskUpdated, 'TaskUpdated', options.workDir, {
|
|
702
|
+
task_id: ev.taskId,
|
|
703
|
+
task_subject: ev.subject,
|
|
704
|
+
task_event: ev.type,
|
|
705
|
+
...(ev.actor ? { actor: ev.actor } : {}),
|
|
706
|
+
unblocked_task_ids: note?.unblocked ?? [],
|
|
707
|
+
}, ev.type, (0, hooks_1.hookRunOptsFor)(options));
|
|
708
|
+
const extra = [outcome.context, outcome.systemMessage].filter(Boolean).join('\n');
|
|
709
|
+
// A hook that bothers to say something outranks the default note: its
|
|
710
|
+
// text rides along WITH the note when there is one, or becomes the
|
|
711
|
+
// delivered message on its own for events no note would have covered
|
|
712
|
+
// (e.g. a `created` matcher that wants the model told about new work).
|
|
713
|
+
if (extra)
|
|
714
|
+
text = text ? `${text}\n\n${extra}` : extra;
|
|
715
|
+
}
|
|
716
|
+
if (text)
|
|
717
|
+
texts.push(text);
|
|
718
|
+
}
|
|
719
|
+
return texts;
|
|
720
|
+
};
|
|
657
721
|
// Live prompt-size estimate, updated from usage events after every stream.
|
|
658
722
|
let lastPromptTokens = 0;
|
|
659
723
|
let compacting = false; // re-entrancy guard — compaction itself calls streamChat
|
|
@@ -1107,7 +1171,9 @@ async function runAgentLoop(initialMessages, options) {
|
|
|
1107
1171
|
const bgDone = drainBackgroundNotifications();
|
|
1108
1172
|
// Background hooks (async / asyncRewake) queued since the last request.
|
|
1109
1173
|
const hookMsgs = (0, hooks_1.drainHookDeliveries)();
|
|
1110
|
-
|
|
1174
|
+
// Board changes from other sessions/scripts (see taskEvents.ts).
|
|
1175
|
+
const taskEvts = await collectTaskEventTexts();
|
|
1176
|
+
if (queued.length || peerMsgs.length || bgDone.length || hookMsgs.length || taskEvts.length) {
|
|
1111
1177
|
const parts = [];
|
|
1112
1178
|
if (queued.length) {
|
|
1113
1179
|
parts.push(queued.join('\n\n'));
|
|
@@ -1121,6 +1187,8 @@ async function runAgentLoop(initialMessages, options) {
|
|
|
1121
1187
|
parts.push((0, backgroundAgents_1.formatBackgroundNotifications)(bgDone));
|
|
1122
1188
|
if (hookMsgs.length)
|
|
1123
1189
|
parts.push((0, hooks_1.formatHookDeliveries)(hookMsgs));
|
|
1190
|
+
if (taskEvts.length)
|
|
1191
|
+
parts.push(taskEvts.join('\n\n'));
|
|
1124
1192
|
messages.push({ role: 'user', content: [{ type: 'text', text: parts.join('\n\n') }] });
|
|
1125
1193
|
continue;
|
|
1126
1194
|
}
|
|
@@ -1220,7 +1288,9 @@ async function runAgentLoop(initialMessages, options) {
|
|
|
1220
1288
|
// A background hook may have landed while this turn ran — the model must see it
|
|
1221
1289
|
// before the session would otherwise go idle.
|
|
1222
1290
|
const hookMsgs = (0, hooks_1.drainHookDeliveries)();
|
|
1223
|
-
|
|
1291
|
+
// Board changes from other sessions/scripts (see taskEvents.ts).
|
|
1292
|
+
const taskEvts = await collectTaskEventTexts();
|
|
1293
|
+
if (queued.length || peerMsgs.length || bgDone.length || hookMsgs.length || taskEvts.length) {
|
|
1224
1294
|
const parts = [];
|
|
1225
1295
|
if (queued.length) {
|
|
1226
1296
|
parts.push(queued.join('\n\n'));
|
|
@@ -1234,6 +1304,8 @@ async function runAgentLoop(initialMessages, options) {
|
|
|
1234
1304
|
parts.push((0, backgroundAgents_1.formatBackgroundNotifications)(bgDone));
|
|
1235
1305
|
if (hookMsgs.length)
|
|
1236
1306
|
parts.push((0, hooks_1.formatHookDeliveries)(hookMsgs));
|
|
1307
|
+
if (taskEvts.length)
|
|
1308
|
+
parts.push(taskEvts.join('\n\n'));
|
|
1237
1309
|
messages.push({ role: 'user', content: [{ type: 'text', text: parts.join('\n\n') }] });
|
|
1238
1310
|
continue;
|
|
1239
1311
|
}
|
|
@@ -1840,6 +1912,14 @@ async function runAgentLoop(initialMessages, options) {
|
|
|
1840
1912
|
if (hookDeliveries.length) {
|
|
1841
1913
|
toolResultContent.push({ type: 'text', text: (0, hooks_1.formatHookDeliveries)(hookDeliveries) });
|
|
1842
1914
|
}
|
|
1915
|
+
// Cross-session task-board events (see taskEvents.ts) — same boundary as
|
|
1916
|
+
// the peer messages above, and for the same reason: a board change made
|
|
1917
|
+
// by another process while our tools ran is news the model should have
|
|
1918
|
+
// before it decides what to do next.
|
|
1919
|
+
const taskEvts = await collectTaskEventTexts();
|
|
1920
|
+
if (taskEvts.length) {
|
|
1921
|
+
toolResultContent.push({ type: 'text', text: taskEvts.join('\n\n') });
|
|
1922
|
+
}
|
|
1843
1923
|
// PostToolBatch (Claude Code): fires exactly ONCE per batch, after every call resolved
|
|
1844
1924
|
// and before the next model call — the place for context that depends on the SET of
|
|
1845
1925
|
// tools that ran, where PostToolUse could only see one at a time (and would race itself
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { taskScopeDir as scopeDir, taskScopeRoot as tasksRoot } from './taskEvents';
|
|
1
2
|
export type TaskStatus = 'pending' | 'in_progress' | 'completed' | 'blocked';
|
|
2
3
|
export interface SharedTask {
|
|
3
4
|
id: string;
|
|
@@ -13,11 +14,17 @@ export interface SharedTask {
|
|
|
13
14
|
updatedAt: number;
|
|
14
15
|
claimedAt?: number;
|
|
15
16
|
}
|
|
16
|
-
declare function tasksRoot(): string;
|
|
17
|
-
declare function scopeDir(workDir: string): string;
|
|
18
17
|
declare function taskPath(workDir: string, taskId: string): string;
|
|
19
|
-
/**
|
|
20
|
-
|
|
18
|
+
/**
|
|
19
|
+
* A claimed task whose owning process is gone, or whose claim has gone stale with
|
|
20
|
+
* no update, is treated as abandoned.
|
|
21
|
+
*
|
|
22
|
+
* Public because more than the claim path itself needs this verdict: `nex tasks`
|
|
23
|
+
* prints it — a board that shows a dead claim as plainly "in progress" is lying
|
|
24
|
+
* about what a session would actually be allowed to take — and any UI that
|
|
25
|
+
* renders `in_progress` should ask this rather than re-deriving the rule.
|
|
26
|
+
*/
|
|
27
|
+
export declare function isClaimAbandoned(task: SharedTask): boolean;
|
|
21
28
|
/** Whether every task ID in `blockedBy` is `completed` — i.e. this task is actually claimable right now. */
|
|
22
29
|
declare function isUnblocked(workDir: string, task: SharedTask): boolean;
|
|
23
30
|
/** List every task registered for `workDir`, newest first isn't guaranteed — sort by createdAt if display order matters to the caller. */
|
|
@@ -38,8 +45,14 @@ export type ClaimResult = {
|
|
|
38
45
|
* Atomically claim `taskId` for `claimedBy` (a peer/session name). Race-free
|
|
39
46
|
* against another process calling this at the same instant — see this
|
|
40
47
|
* module's header comment for exactly why.
|
|
48
|
+
*
|
|
49
|
+
* `opts.trackPid` (default true) records `process.pid` so a crashed session's
|
|
50
|
+
* claim is detectable. Pass false for a claim typed from a short-lived shell
|
|
51
|
+
* process (`nex tasks claim`) — see the spread comment in the body.
|
|
41
52
|
*/
|
|
42
|
-
export declare function claimTask(workDir: string, taskId: string, claimedBy: string
|
|
53
|
+
export declare function claimTask(workDir: string, taskId: string, claimedBy: string, opts?: {
|
|
54
|
+
trackPid?: boolean;
|
|
55
|
+
}): Promise<ClaimResult>;
|
|
43
56
|
/**
|
|
44
57
|
* Update a task's status. Used for both normal progress (in_progress →
|
|
45
58
|
* completed) and releasing a claim early (in_progress → pending, e.g. a
|
|
@@ -65,6 +78,8 @@ export declare const _sharedTasksInternal: {
|
|
|
65
78
|
* model as the tool's error; so "no task remains" is the observable contract of a veto,
|
|
66
79
|
* and this is the only place that needs to make it true.
|
|
67
80
|
*/
|
|
68
|
-
export declare function deleteSharedTask(workDir: string, taskId: string
|
|
81
|
+
export declare function deleteSharedTask(workDir: string, taskId: string, opts?: {
|
|
82
|
+
actor?: string;
|
|
83
|
+
}): boolean;
|
|
69
84
|
export {};
|
|
70
85
|
//# sourceMappingURL=sharedTasks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedTasks.d.ts","sourceRoot":"","sources":["../../src/agent/sharedTasks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sharedTasks.d.ts","sourceRoot":"","sources":["../../src/agent/sharedTasks.ts"],"names":[],"mappings":"AA+DA,OAAO,EAAE,YAAY,IAAI,QAAQ,EAAE,aAAa,IAAI,SAAS,EAAqC,MAAM,cAAc,CAAC;AAEvH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,aAAa,GAAG,WAAW,GAAG,SAA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,EACf,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,IAAI,GAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAO,GAChC,OAAO,CAAC,WAAW,CAAC,CAiDtB;AAED;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,UAAU,EAClB,IAAI,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GAChC,OAAO,CAAC,WAAW,CAAC,CA8CtB;AAED,eAAO,MAAM,oBAAoB;;;;;;;;CAQhC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,OAAO,CAexG"}
|
|
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports._sharedTasksInternal = void 0;
|
|
37
|
+
exports.isClaimAbandoned = isClaimAbandoned;
|
|
37
38
|
exports.listSharedTasks = listSharedTasks;
|
|
38
39
|
exports.createSharedTask = createSharedTask;
|
|
39
40
|
exports.claimTask = claimTask;
|
|
@@ -95,10 +96,14 @@ exports.deleteSharedTask = deleteSharedTask;
|
|
|
95
96
|
* same race-free claim path above.
|
|
96
97
|
*/
|
|
97
98
|
const fs = __importStar(require("fs"));
|
|
98
|
-
const os = __importStar(require("os"));
|
|
99
99
|
const path = __importStar(require("path"));
|
|
100
100
|
const crypto = __importStar(require("crypto"));
|
|
101
101
|
const crossProcessLock_1 = require("./crossProcessLock");
|
|
102
|
+
// taskEvents owns the scope-directory hash — one canonical function, so this
|
|
103
|
+
// module's task files and its event log always land in the same directory
|
|
104
|
+
// without importing the mutators back (the dependency arrow points THIS WAY
|
|
105
|
+
// only: sharedTasks → taskEvents, never the reverse).
|
|
106
|
+
const taskEvents_1 = require("./taskEvents");
|
|
102
107
|
// A claim older than this with no update is treated the same as a dead-pid
|
|
103
108
|
// claim — reclaimable. Longer than crossProcessLock's STALE_MS (that guards a
|
|
104
109
|
// single tool call; this guards an entire unit of work a session might
|
|
@@ -121,15 +126,8 @@ const CLAIM_STALE_MS = 30 * 60 * 1000; // 30 minutes
|
|
|
121
126
|
// mode of "wait a couple seconds longer to reclaim a genuinely dead claim" is
|
|
122
127
|
// far cheaper than "two sessions think they both own the same unit of work".
|
|
123
128
|
const MIN_CLAIM_AGE_FOR_DEATH_CHECK_MS = 2000;
|
|
124
|
-
function tasksRoot() {
|
|
125
|
-
return process.env.NEXRALL_SHARED_TASKS_DIR || path.join(os.homedir(), '.nexrall', 'peers', 'tasks');
|
|
126
|
-
}
|
|
127
|
-
function scopeDir(workDir) {
|
|
128
|
-
const hash = crypto.createHash('sha256').update(path.resolve(workDir)).digest('hex').slice(0, 24);
|
|
129
|
-
return path.join(tasksRoot(), hash);
|
|
130
|
-
}
|
|
131
129
|
function taskPath(workDir, taskId) {
|
|
132
|
-
return path.join(
|
|
130
|
+
return path.join((0, taskEvents_1.taskScopeDir)(workDir), `${taskId}.json`);
|
|
133
131
|
}
|
|
134
132
|
function readTask(workDir, taskId) {
|
|
135
133
|
try {
|
|
@@ -143,7 +141,7 @@ function readTask(workDir, taskId) {
|
|
|
143
141
|
}
|
|
144
142
|
}
|
|
145
143
|
function writeTask(workDir, task) {
|
|
146
|
-
const dir =
|
|
144
|
+
const dir = (0, taskEvents_1.taskScopeDir)(workDir);
|
|
147
145
|
fs.mkdirSync(dir, { recursive: true });
|
|
148
146
|
const p = taskPath(workDir, task.id);
|
|
149
147
|
// Same atomic-write-via-temp-then-rename reasoning as core's
|
|
@@ -162,7 +160,15 @@ function isPidAlive(pid) {
|
|
|
162
160
|
return false;
|
|
163
161
|
}
|
|
164
162
|
}
|
|
165
|
-
/**
|
|
163
|
+
/**
|
|
164
|
+
* A claimed task whose owning process is gone, or whose claim has gone stale with
|
|
165
|
+
* no update, is treated as abandoned.
|
|
166
|
+
*
|
|
167
|
+
* Public because more than the claim path itself needs this verdict: `nex tasks`
|
|
168
|
+
* prints it — a board that shows a dead claim as plainly "in progress" is lying
|
|
169
|
+
* about what a session would actually be allowed to take — and any UI that
|
|
170
|
+
* renders `in_progress` should ask this rather than re-deriving the rule.
|
|
171
|
+
*/
|
|
166
172
|
function isClaimAbandoned(task) {
|
|
167
173
|
if (task.status !== 'in_progress')
|
|
168
174
|
return false;
|
|
@@ -189,7 +195,7 @@ function isUnblocked(workDir, task) {
|
|
|
189
195
|
function listSharedTasks(workDir) {
|
|
190
196
|
let entries;
|
|
191
197
|
try {
|
|
192
|
-
entries = fs.readdirSync(
|
|
198
|
+
entries = fs.readdirSync((0, taskEvents_1.taskScopeDir)(workDir));
|
|
193
199
|
}
|
|
194
200
|
catch {
|
|
195
201
|
return [];
|
|
@@ -218,14 +224,19 @@ function createSharedTask(workDir, content, opts = {}) {
|
|
|
218
224
|
updatedAt: now,
|
|
219
225
|
};
|
|
220
226
|
writeTask(workDir, task);
|
|
227
|
+
(0, taskEvents_1.emitTaskEvent)((0, taskEvents_1.taskScopeDir)(workDir), { type: 'created', taskId: task.id, subject: task.content });
|
|
221
228
|
return task;
|
|
222
229
|
}
|
|
223
230
|
/**
|
|
224
231
|
* Atomically claim `taskId` for `claimedBy` (a peer/session name). Race-free
|
|
225
232
|
* against another process calling this at the same instant — see this
|
|
226
233
|
* module's header comment for exactly why.
|
|
234
|
+
*
|
|
235
|
+
* `opts.trackPid` (default true) records `process.pid` so a crashed session's
|
|
236
|
+
* claim is detectable. Pass false for a claim typed from a short-lived shell
|
|
237
|
+
* process (`nex tasks claim`) — see the spread comment in the body.
|
|
227
238
|
*/
|
|
228
|
-
async function claimTask(workDir, taskId, claimedBy) {
|
|
239
|
+
async function claimTask(workDir, taskId, claimedBy, opts = {}) {
|
|
229
240
|
// Lock scoped to (workDir, taskId) specifically — via crossProcessLock's
|
|
230
241
|
// opaque-key + workDir scoping (see its own header) — so claiming task A
|
|
231
242
|
// never blocks a concurrent claim of unrelated task B in the same project.
|
|
@@ -249,11 +260,25 @@ async function claimTask(workDir, taskId, claimedBy) {
|
|
|
249
260
|
...task,
|
|
250
261
|
status: 'in_progress',
|
|
251
262
|
claimedBy,
|
|
252
|
-
|
|
263
|
+
// A session that claims through the task tools records its pid so a crash
|
|
264
|
+
// is detectable (isClaimAbandoned's liveness check). A claim typed from a
|
|
265
|
+
// one-shot shell (`nex tasks claim`) passes trackPid: false: that process
|
|
266
|
+
// exits milliseconds later, and a dead pid would make a perfectly valid
|
|
267
|
+
// human-held claim look abandoned almost immediately (after only
|
|
268
|
+
// MIN_CLAIM_AGE_FOR_DEATH_CHECK_MS). Without a pid the claim rests on the
|
|
269
|
+
// CLAIM_STALE_MS window alone. `undefined` also CLEARS any pid left by an
|
|
270
|
+
// abandoned claim being re-claimed (JSON.stringify drops the key).
|
|
271
|
+
...(opts.trackPid === false ? { claimedByPid: undefined } : { claimedByPid: process.pid }),
|
|
253
272
|
claimedAt: now,
|
|
254
273
|
updatedAt: now,
|
|
255
274
|
};
|
|
256
275
|
writeTask(workDir, updated);
|
|
276
|
+
(0, taskEvents_1.emitTaskEvent)((0, taskEvents_1.taskScopeDir)(workDir), {
|
|
277
|
+
type: 'claimed',
|
|
278
|
+
taskId: updated.id,
|
|
279
|
+
subject: updated.content,
|
|
280
|
+
actor: claimedBy,
|
|
281
|
+
});
|
|
257
282
|
return { ok: true, task: updated };
|
|
258
283
|
}, workDir);
|
|
259
284
|
}
|
|
@@ -285,12 +310,31 @@ async function updateSharedTaskStatus(workDir, taskId, status, opts = {}) {
|
|
|
285
310
|
: {}),
|
|
286
311
|
};
|
|
287
312
|
writeTask(workDir, updated);
|
|
313
|
+
// Emit only on a real transition: calling `done` on an already-completed
|
|
314
|
+
// task is a no-op write (existing behaviour, kept), and a no-op must not
|
|
315
|
+
// fire an event — every other session would get a duplicate notification
|
|
316
|
+
// for a state that did not change.
|
|
317
|
+
if (task.status !== status) {
|
|
318
|
+
const type = status === 'completed'
|
|
319
|
+
? 'completed'
|
|
320
|
+
: status === 'in_progress'
|
|
321
|
+
? 'claimed'
|
|
322
|
+
: task.status === 'completed'
|
|
323
|
+
? 'reopened'
|
|
324
|
+
: 'released';
|
|
325
|
+
(0, taskEvents_1.emitTaskEvent)((0, taskEvents_1.taskScopeDir)(workDir), {
|
|
326
|
+
type,
|
|
327
|
+
taskId: updated.id,
|
|
328
|
+
subject: updated.content,
|
|
329
|
+
actor: opts.claimedBy ?? task.claimedBy,
|
|
330
|
+
});
|
|
331
|
+
}
|
|
288
332
|
return { ok: true, task: updated };
|
|
289
333
|
}, workDir);
|
|
290
334
|
}
|
|
291
335
|
exports._sharedTasksInternal = {
|
|
292
|
-
tasksRoot,
|
|
293
|
-
scopeDir,
|
|
336
|
+
tasksRoot: taskEvents_1.taskScopeRoot,
|
|
337
|
+
scopeDir: taskEvents_1.taskScopeDir,
|
|
294
338
|
taskPath,
|
|
295
339
|
isClaimAbandoned,
|
|
296
340
|
isUnblocked,
|
|
@@ -303,9 +347,17 @@ exports._sharedTasksInternal = {
|
|
|
303
347
|
* model as the tool's error; so "no task remains" is the observable contract of a veto,
|
|
304
348
|
* and this is the only place that needs to make it true.
|
|
305
349
|
*/
|
|
306
|
-
function deleteSharedTask(workDir, taskId) {
|
|
350
|
+
function deleteSharedTask(workDir, taskId, opts = {}) {
|
|
351
|
+
// Read BEFORE unlinking: the `removed` event is the only place outside the
|
|
352
|
+
// task file that can still carry the subject, and a watcher rendering
|
|
353
|
+
// "[id] was removed" with no subject would send people looking for a task
|
|
354
|
+
// that no longer exists to explain itself.
|
|
355
|
+
const task = readTask(workDir, taskId);
|
|
307
356
|
try {
|
|
308
357
|
fs.unlinkSync(taskPath(workDir, taskId));
|
|
358
|
+
if (task) {
|
|
359
|
+
(0, taskEvents_1.emitTaskEvent)((0, taskEvents_1.taskScopeDir)(workDir), { type: 'removed', taskId, subject: task.content, actor: opts.actor });
|
|
360
|
+
}
|
|
309
361
|
return true;
|
|
310
362
|
}
|
|
311
363
|
catch {
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { SharedTask } from './sharedTasks';
|
|
2
|
+
export type TaskEventType = 'created' | 'claimed' | 'released' | 'reopened' | 'completed' | 'removed';
|
|
3
|
+
export interface TaskEvent {
|
|
4
|
+
/** Milliseconds since epoch, from the mutating process's clock. */
|
|
5
|
+
ts: number;
|
|
6
|
+
type: TaskEventType;
|
|
7
|
+
taskId: string;
|
|
8
|
+
/** The task's subject at the time of the event — the only place a `removed` event can carry it. */
|
|
9
|
+
subject: string;
|
|
10
|
+
/** Who performed it: a claim name (`shell:henry`, a peer name); absent when the caller had no identity. */
|
|
11
|
+
actor?: string;
|
|
12
|
+
/** pid of the mutating process; readers use it to skip their own actions. */
|
|
13
|
+
pid: number;
|
|
14
|
+
}
|
|
15
|
+
/** The root directory all board scopes live under (env-overridable — tests redirect it). */
|
|
16
|
+
export declare function taskScopeRoot(): string;
|
|
17
|
+
/** The board scope directory for a project — one per resolved workDir, shared by every process. */
|
|
18
|
+
export declare function taskScopeDir(workDir: string): string;
|
|
19
|
+
export declare function taskEventsFile(workDir: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Append one event to the board's log. Called by every mutator in sharedTasks
|
|
22
|
+
* right after its atomic write lands. Best-effort by contract: a failure here
|
|
23
|
+
* must NEVER surface to the caller — the mutation itself already succeeded.
|
|
24
|
+
*/
|
|
25
|
+
export declare function emitTaskEvent(dir: string, event: Omit<TaskEvent, 'ts' | 'pid'> & {
|
|
26
|
+
ts?: number;
|
|
27
|
+
pid?: number;
|
|
28
|
+
}): void;
|
|
29
|
+
declare function eventsFileIn(dir: string): string;
|
|
30
|
+
export interface TakeTaskEventsOptions {
|
|
31
|
+
/** Disambiguates readers that share a process (two VS Code panels on one workspace). */
|
|
32
|
+
sessionKey?: string;
|
|
33
|
+
/** Override for tests; defaults to this process's pid. */
|
|
34
|
+
selfPid?: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* New events for this reader — everything appended since the last call, minus
|
|
38
|
+
* this process's own writes. The FIRST call for a (scope, session) adopts the
|
|
39
|
+
* current end of the log and returns nothing: events describe change relative
|
|
40
|
+
* to when you started looking, never the board's backstory.
|
|
41
|
+
*/
|
|
42
|
+
export declare function takeNewTaskEvents(workDir: string, opts?: TakeTaskEventsOptions): TaskEvent[];
|
|
43
|
+
export interface TaskEventNote {
|
|
44
|
+
event: TaskEvent;
|
|
45
|
+
/** The text injected into the receiving session's conversation. */
|
|
46
|
+
text: string;
|
|
47
|
+
/** Deps this event just unblocked (`completed` only) — also handed to the receiving session's TaskUpdated hooks. */
|
|
48
|
+
unblocked: string[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Turn raw events into model-bound notes — but only for the events that
|
|
52
|
+
* actually changed what somebody can DO, because the rest are board gossip:
|
|
53
|
+
*
|
|
54
|
+
* completed → every open task waiting on it is now unblocked (or one dep
|
|
55
|
+
* closer), for whoever gets there first;
|
|
56
|
+
* reopened → the reverse: waiting tasks are stuck again;
|
|
57
|
+
* removed → waiting tasks are stuck FOREVER (a dep that can never
|
|
58
|
+
* complete) unless it comes back — the one case the board
|
|
59
|
+
* itself cannot express, since the task file is gone.
|
|
60
|
+
*
|
|
61
|
+
* created / claimed / released produce no note: they change no one's options
|
|
62
|
+
* (released → the task is pending again, which its `blockedBy` already gates).
|
|
63
|
+
* Hooks still see every event — the matcher decides — but the model only gets
|
|
64
|
+
* told about consequences.
|
|
65
|
+
*/
|
|
66
|
+
export declare function formatTaskEventNotes(events: TaskEvent[], tasks: SharedTask[]): TaskEventNote[];
|
|
67
|
+
/** Test-only handles — the cursor map is module state and must be observable/resettable. */
|
|
68
|
+
export declare const _taskEventsInternal: {
|
|
69
|
+
_cursors: Map<string, number>;
|
|
70
|
+
eventsFileIn: typeof eventsFileIn;
|
|
71
|
+
};
|
|
72
|
+
export {};
|
|
73
|
+
//# sourceMappingURL=taskEvents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taskEvents.d.ts","sourceRoot":"","sources":["../../src/agent/taskEvents.ts"],"names":[],"mappings":"AA8CA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,CAAC;AAEtG,MAAM,WAAW,SAAS;IACxB,mEAAmE;IACnE,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,mGAAmG;IACnG,OAAO,EAAE,MAAM,CAAC;IAChB,2GAA2G;IAC3G,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6EAA6E;IAC7E,GAAG,EAAE,MAAM,CAAC;CACb;AAWD,4FAA4F;AAC5F,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,mGAAmG;AACnG,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGpD;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtD;AAID;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,GAAG,KAAK,CAAC,GAAG;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAWrH;AAED,iBAAS,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEzC;AAOD,MAAM,WAAW,qBAAqB;IACpC,wFAAwF;IACxF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB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