@nexrall/code-core 1.4.63 → 1.4.65
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/agentRegistry.d.ts +14 -3
- package/dist/agent/agentRegistry.d.ts.map +1 -1
- package/dist/agent/agentRegistry.js +136 -6
- package/dist/agent/agentTypes.d.ts +51 -1
- package/dist/agent/agentTypes.d.ts.map +1 -1
- package/dist/agent/agentTypes.js +194 -11
- package/dist/agent/backgroundAgents.d.ts +66 -0
- package/dist/agent/backgroundAgents.d.ts.map +1 -0
- package/dist/agent/backgroundAgents.js +145 -0
- package/dist/agent/loop.d.ts +43 -6
- package/dist/agent/loop.d.ts.map +1 -1
- package/dist/agent/loop.js +942 -259
- package/dist/agent/modelCatalogue.d.ts +15 -0
- package/dist/agent/modelCatalogue.d.ts.map +1 -1
- package/dist/agent/modelCatalogue.js +46 -0
- package/dist/agent/readDedupe.d.ts +15 -0
- package/dist/agent/readDedupe.d.ts.map +1 -0
- package/dist/agent/readDedupe.js +146 -0
- package/dist/agent/toolPrefetch.d.ts +44 -0
- package/dist/agent/toolPrefetch.d.ts.map +1 -0
- package/dist/agent/toolPrefetch.js +101 -0
- package/dist/agent/trust.d.ts +0 -5
- package/dist/agent/trust.d.ts.map +1 -1
- package/dist/agent/trust.js +41 -0
- package/dist/api/client.d.ts +14 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +88 -8
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/permissions/modePolicy.d.ts +10 -0
- package/dist/permissions/modePolicy.d.ts.map +1 -1
- package/dist/permissions/modePolicy.js +11 -0
- package/dist/tools/executor.d.ts +36 -0
- package/dist/tools/executor.d.ts.map +1 -1
- package/dist/tools/executor.js +408 -85
- package/dist/tools/tsLangService.d.ts.map +1 -1
- package/dist/tools/tsLangService.js +107 -21
- package/dist/types.d.ts +99 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +12 -1
- package/dist/util/miniYaml.d.ts +10 -0
- package/dist/util/miniYaml.d.ts.map +1 -0
- package/dist/util/miniYaml.js +149 -0
- package/package.json +8 -17
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { ToolResult } from '../types';
|
|
2
|
+
export type BackgroundStatus = 'running' | 'completed' | 'failed' | 'stopped';
|
|
3
|
+
export interface BackgroundAgentInfo {
|
|
4
|
+
id: string;
|
|
5
|
+
description: string;
|
|
6
|
+
agentType: string;
|
|
7
|
+
status: BackgroundStatus;
|
|
8
|
+
startedAt: number;
|
|
9
|
+
finishedAt?: number;
|
|
10
|
+
toolCalls: number;
|
|
11
|
+
lastTool?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface BackgroundNotification {
|
|
14
|
+
id: string;
|
|
15
|
+
description: string;
|
|
16
|
+
agentType: string;
|
|
17
|
+
status: Exclude<BackgroundStatus, 'running'>;
|
|
18
|
+
durationMs: number;
|
|
19
|
+
toolCalls: number;
|
|
20
|
+
/** The sub-agent's final report (or error + salvaged partial work). */
|
|
21
|
+
text: string;
|
|
22
|
+
}
|
|
23
|
+
/** Hard ceiling on simultaneously running background agents per session. */
|
|
24
|
+
export declare const MAX_BACKGROUND_AGENTS = 8;
|
|
25
|
+
export declare class BackgroundAgentHub {
|
|
26
|
+
private readonly entries;
|
|
27
|
+
private readonly pending;
|
|
28
|
+
private readonly listeners;
|
|
29
|
+
private counter;
|
|
30
|
+
/**
|
|
31
|
+
* Start `run` detached. `run` receives this agent's own abort signal and progress
|
|
32
|
+
* hooks, and must resolve (never reject) with the sub-agent's ToolResult.
|
|
33
|
+
*/
|
|
34
|
+
start(meta: {
|
|
35
|
+
description: string;
|
|
36
|
+
agentType: string;
|
|
37
|
+
}, run: (ctx: {
|
|
38
|
+
abort: {
|
|
39
|
+
aborted: boolean;
|
|
40
|
+
};
|
|
41
|
+
onToolUse: (name: string) => void;
|
|
42
|
+
}) => Promise<ToolResult>): {
|
|
43
|
+
id: string;
|
|
44
|
+
} | {
|
|
45
|
+
error: string;
|
|
46
|
+
};
|
|
47
|
+
private finish;
|
|
48
|
+
/** Running agents, oldest first. */
|
|
49
|
+
list(): BackgroundAgentInfo[];
|
|
50
|
+
runningCount(): number;
|
|
51
|
+
hasPending(): boolean;
|
|
52
|
+
/** Remove and return every undelivered completion. */
|
|
53
|
+
takeNotifications(): BackgroundNotification[];
|
|
54
|
+
/** Ask one agent to stop. Its (partial) result is still delivered as a notification. */
|
|
55
|
+
stop(id: string): boolean;
|
|
56
|
+
/** Stop everything and drop undelivered notifications (session cleared / closed). */
|
|
57
|
+
stopAll(opts?: {
|
|
58
|
+
dropPending?: boolean;
|
|
59
|
+
}): void;
|
|
60
|
+
/** Subscribe to any change (start, progress, finish, delivery). Returns an unsubscribe. */
|
|
61
|
+
onChange(cb: () => void): () => void;
|
|
62
|
+
private emit;
|
|
63
|
+
}
|
|
64
|
+
/** The text block a notification becomes in the model's context. */
|
|
65
|
+
export declare function formatBackgroundNotifications(list: BackgroundNotification[]): string;
|
|
66
|
+
//# sourceMappingURL=backgroundAgents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backgroundAgents.d.ts","sourceRoot":"","sources":["../../src/agent/backgroundAgents.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE9E,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,gBAAgB,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AA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;KAAO,GAAG,IAAI;IAMnD,2FAA2F;IAC3F,QAAQ,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAKpC,OAAO,CAAC,IAAI;CAKb;AAOD,oEAAoE;AACpE,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,sBAAsB,EAAE,GAAG,MAAM,CAYpF"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Background sub-agents — Claude Code's `run_in_background` for the `task` tool.
|
|
3
|
+
//
|
|
4
|
+
// A foreground `task` blocks the main agent until the sub-agent finishes. A background
|
|
5
|
+
// one returns immediately with an id; the main agent keeps working (or the turn ends)
|
|
6
|
+
// and the sub-agent's final report is delivered later as a <task-notification>:
|
|
7
|
+
// • while a turn is running — the loop folds pending notifications into the next
|
|
8
|
+
// tool-result turn, exactly like a queued user message;
|
|
9
|
+
// • while idle — the host (VS Code / CLI / desktop) is told via onChange and starts a
|
|
10
|
+
// follow-up turn with the notification (see deliverPendingAsPrompt).
|
|
11
|
+
//
|
|
12
|
+
// One hub per SESSION, owned by the host. Background agents have their OWN abort
|
|
13
|
+
// signal: pressing Stop on the main turn does not kill them (same as Claude Code);
|
|
14
|
+
// stop()/stopAll() do, and hosts call stopAll() when the session is cleared/closed.
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.BackgroundAgentHub = exports.MAX_BACKGROUND_AGENTS = void 0;
|
|
17
|
+
exports.formatBackgroundNotifications = formatBackgroundNotifications;
|
|
18
|
+
/** Hard ceiling on simultaneously running background agents per session. */
|
|
19
|
+
exports.MAX_BACKGROUND_AGENTS = 8;
|
|
20
|
+
class BackgroundAgentHub {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.entries = new Map();
|
|
23
|
+
this.pending = [];
|
|
24
|
+
this.listeners = new Set();
|
|
25
|
+
this.counter = 0;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Start `run` detached. `run` receives this agent's own abort signal and progress
|
|
29
|
+
* hooks, and must resolve (never reject) with the sub-agent's ToolResult.
|
|
30
|
+
*/
|
|
31
|
+
start(meta, run) {
|
|
32
|
+
if (this.runningCount() >= exports.MAX_BACKGROUND_AGENTS) {
|
|
33
|
+
return {
|
|
34
|
+
error: `${exports.MAX_BACKGROUND_AGENTS} background agents are already running in this session. Wait for one ` +
|
|
35
|
+
'to finish (its result arrives as a <task-notification>), or run this one in the foreground.',
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const id = `bg_${++this.counter}_${Math.random().toString(36).slice(2, 7)}`;
|
|
39
|
+
const entry = {
|
|
40
|
+
id,
|
|
41
|
+
description: meta.description,
|
|
42
|
+
agentType: meta.agentType,
|
|
43
|
+
status: 'running',
|
|
44
|
+
startedAt: Date.now(),
|
|
45
|
+
toolCalls: 0,
|
|
46
|
+
abort: { aborted: false },
|
|
47
|
+
};
|
|
48
|
+
this.entries.set(id, entry);
|
|
49
|
+
this.emit();
|
|
50
|
+
const onToolUse = (name) => { entry.toolCalls++; entry.lastTool = name; this.emit(); };
|
|
51
|
+
void run({ abort: entry.abort, onToolUse })
|
|
52
|
+
.catch((err) => ({ error: `Background agent crashed: ${err?.message ?? err}` }))
|
|
53
|
+
.then((result) => this.finish(entry, result));
|
|
54
|
+
return { id };
|
|
55
|
+
}
|
|
56
|
+
finish(entry, result) {
|
|
57
|
+
if (entry.status !== 'running')
|
|
58
|
+
return;
|
|
59
|
+
entry.status = entry.abort.aborted ? 'stopped' : result.error !== undefined ? 'failed' : 'completed';
|
|
60
|
+
entry.finishedAt = Date.now();
|
|
61
|
+
const text = entry.status === 'stopped'
|
|
62
|
+
? (result.output || result.error || '(stopped before it produced a report)')
|
|
63
|
+
: (result.error !== undefined ? result.error : (result.output ?? ''));
|
|
64
|
+
this.pending.push({
|
|
65
|
+
id: entry.id,
|
|
66
|
+
description: entry.description,
|
|
67
|
+
agentType: entry.agentType,
|
|
68
|
+
status: entry.status,
|
|
69
|
+
durationMs: entry.finishedAt - entry.startedAt,
|
|
70
|
+
toolCalls: entry.toolCalls,
|
|
71
|
+
text,
|
|
72
|
+
});
|
|
73
|
+
// Finished entries are only history for the UI; keep the map from growing forever.
|
|
74
|
+
this.entries.delete(entry.id);
|
|
75
|
+
this.emit();
|
|
76
|
+
}
|
|
77
|
+
/** Running agents, oldest first. */
|
|
78
|
+
list() {
|
|
79
|
+
return [...this.entries.values()]
|
|
80
|
+
.filter((e) => e.status === 'running')
|
|
81
|
+
.map(({ abort: _a, ...info }) => ({ ...info }));
|
|
82
|
+
}
|
|
83
|
+
runningCount() {
|
|
84
|
+
let n = 0;
|
|
85
|
+
for (const e of this.entries.values())
|
|
86
|
+
if (e.status === 'running')
|
|
87
|
+
n++;
|
|
88
|
+
return n;
|
|
89
|
+
}
|
|
90
|
+
hasPending() { return this.pending.length > 0; }
|
|
91
|
+
/** Remove and return every undelivered completion. */
|
|
92
|
+
takeNotifications() {
|
|
93
|
+
const out = this.pending.splice(0);
|
|
94
|
+
if (out.length)
|
|
95
|
+
this.emit();
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
/** Ask one agent to stop. Its (partial) result is still delivered as a notification. */
|
|
99
|
+
stop(id) {
|
|
100
|
+
const e = this.entries.get(id);
|
|
101
|
+
if (!e || e.status !== 'running')
|
|
102
|
+
return false;
|
|
103
|
+
e.abort.aborted = true;
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
/** Stop everything and drop undelivered notifications (session cleared / closed). */
|
|
107
|
+
stopAll(opts = {}) {
|
|
108
|
+
for (const e of this.entries.values())
|
|
109
|
+
e.abort.aborted = true;
|
|
110
|
+
if (opts.dropPending)
|
|
111
|
+
this.pending.length = 0;
|
|
112
|
+
this.emit();
|
|
113
|
+
}
|
|
114
|
+
/** Subscribe to any change (start, progress, finish, delivery). Returns an unsubscribe. */
|
|
115
|
+
onChange(cb) {
|
|
116
|
+
this.listeners.add(cb);
|
|
117
|
+
return () => { this.listeners.delete(cb); };
|
|
118
|
+
}
|
|
119
|
+
emit() {
|
|
120
|
+
for (const cb of [...this.listeners]) {
|
|
121
|
+
try {
|
|
122
|
+
cb();
|
|
123
|
+
}
|
|
124
|
+
catch { /* a broken listener must not break the agents */ }
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.BackgroundAgentHub = BackgroundAgentHub;
|
|
129
|
+
function fmtDuration(ms) {
|
|
130
|
+
const s = Math.round(ms / 1000);
|
|
131
|
+
return s < 60 ? `${s}s` : `${Math.floor(s / 60)}m ${s % 60}s`;
|
|
132
|
+
}
|
|
133
|
+
/** The text block a notification becomes in the model's context. */
|
|
134
|
+
function formatBackgroundNotifications(list) {
|
|
135
|
+
return list.map((n) => {
|
|
136
|
+
const verb = n.status === 'completed' ? 'completed' : n.status === 'failed' ? 'FAILED' : 'was stopped';
|
|
137
|
+
return (`<task-notification>\n` +
|
|
138
|
+
`Background agent "${n.description}" (${n.agentType}, id ${n.id}) ${verb} after ` +
|
|
139
|
+
`${fmtDuration(n.durationMs)} and ${n.toolCalls} tool call(s). This is an automated notification, ` +
|
|
140
|
+
`not a message from the user. Its report (the user has NOT seen it — relay what matters):\n\n` +
|
|
141
|
+
`${n.text.trim() || '(no text output)'}\n` +
|
|
142
|
+
`</task-notification>`);
|
|
143
|
+
}).join('\n\n');
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=backgroundAgents.js.map
|
package/dist/agent/loop.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Message, ToolResult, AgentLoopOptions, EnvContext } from '../types';
|
|
2
|
+
import { type BackgroundAgentHub } from './backgroundAgents';
|
|
3
|
+
import { streamChat } from '../api/client';
|
|
2
4
|
import { type AgentType, type AgentMemoryScope } from './agentTypes';
|
|
3
5
|
import { bashNeedsRepoLock } from '../permissions/bashClassify';
|
|
4
6
|
export { bashNeedsRepoLock };
|
|
@@ -129,9 +131,10 @@ export declare function lockPathsFor(name: string, input: Record<string, unknown
|
|
|
129
131
|
*
|
|
130
132
|
* Was env-ONLY, the same gap as the sub-task timeout: a project on a small machine that
|
|
131
133
|
* wanted 2, or a big one that wanted 6, had to set a shell variable, and nobody reading
|
|
132
|
-
* settings.json could see what the limit even was. Capped at
|
|
133
|
-
*
|
|
134
|
-
*
|
|
134
|
+
* settings.json could see what the limit even was. Capped at HARD_MAX_CONCURRENT_SUBTASKS
|
|
135
|
+
* (32 — above Claude Code's default 20, so a user who wants that width can have it)
|
|
136
|
+
* because this bounds real shared resources (CPU, the API rate limit, file handles) and a
|
|
137
|
+
* typo like 400 should degrade to "a lot" rather than fork-bomb the machine.
|
|
135
138
|
*/
|
|
136
139
|
export declare function resolveMaxConcurrentSubtasks(settingsRaw?: Record<string, unknown>): number;
|
|
137
140
|
/** Resolve the session-total sub-agent ceiling: env → settings.json → default. */
|
|
@@ -151,9 +154,9 @@ export declare function _resetSubTaskLimiter(): void;
|
|
|
151
154
|
* host). A client that never calls it gets process-lifetime semantics, which is correct
|
|
152
155
|
* for a one-shot CLI invocation.
|
|
153
156
|
*/
|
|
154
|
-
export declare function resetSessionSubAgentBudget(): void;
|
|
157
|
+
export declare function resetSessionSubAgentBudget(sessionKey?: string): void;
|
|
155
158
|
/** Test-only: observe the session counter without exporting the mutable binding. */
|
|
156
|
-
export declare function _sessionSubAgentCount(): number;
|
|
159
|
+
export declare function _sessionSubAgentCount(sessionKey?: string): number;
|
|
157
160
|
/**
|
|
158
161
|
* Deepest nesting level allowed to spawn: env → settings.json → default 3.
|
|
159
162
|
*
|
|
@@ -308,11 +311,17 @@ export declare function lastToolResults(messages: Message[], count: number, maxC
|
|
|
308
311
|
* Guessing low only costs an earlier, lossy compaction — annoying, not broken.
|
|
309
312
|
*/
|
|
310
313
|
export declare function contextWindowFor(model?: string): number;
|
|
314
|
+
/** Token counts at which auto-prune and auto-compact (summarise) fire for a model window. */
|
|
315
|
+
export declare function compactionLimits(contextWindow: number, settingsRaw?: Record<string, unknown>): {
|
|
316
|
+
prune: number;
|
|
317
|
+
compact: number;
|
|
318
|
+
};
|
|
311
319
|
/** Auto-prune / auto-compact thresholds as fractions of the context window — for UI display (e.g. `/context`). */
|
|
312
|
-
export declare function compactionThresholds(): {
|
|
320
|
+
export declare function compactionThresholds(contextWindow?: number, settingsRaw?: Record<string, unknown>): {
|
|
313
321
|
prune: number;
|
|
314
322
|
compact: number;
|
|
315
323
|
};
|
|
324
|
+
export declare function pruneReclaimFloor(lastCallEndedAt: number | undefined, now?: number): number;
|
|
316
325
|
/** Approximate serialised request-body size (bytes) for the messages array. */
|
|
317
326
|
export declare function estimateBodyBytes(messages: Message[]): number;
|
|
318
327
|
/** Tools that mutate the filesystem — used by the verification nudge (GAP D). */
|
|
@@ -361,6 +370,12 @@ export declare function findSafeCutIndex(messages: Message[], maxIdx: number): n
|
|
|
361
370
|
* middle — a middle-out elision that preserves both "what we set out to do" and
|
|
362
371
|
* "where we are now", which is what the continuation summary needs most.
|
|
363
372
|
*/
|
|
373
|
+
/**
|
|
374
|
+
* Appends the backend-announced runtime-context block to the user message it was
|
|
375
|
+
* attached to. No-op if that message is not a user turn or already ends with the
|
|
376
|
+
* identical block. Exported for tests.
|
|
377
|
+
*/
|
|
378
|
+
export declare function persistRuntimeContext(messages: Message[], idx: number, text: string): boolean;
|
|
364
379
|
export declare function transcriptOf(messages: Message[]): string;
|
|
365
380
|
export interface ProgressLedger {
|
|
366
381
|
filesTouched: Map<string, {
|
|
@@ -437,6 +452,17 @@ export declare function ledgerSummary(ledger: ProgressLedger): string;
|
|
|
437
452
|
* cache by the time the caller declined).
|
|
438
453
|
*/
|
|
439
454
|
export declare function pruneOldToolResults(messages: Message[], minReclaimBytes?: number): number;
|
|
455
|
+
/**
|
|
456
|
+
* Summarises the WHOLE conversation by appending the instruction to its final user
|
|
457
|
+
* message and sending it with the conversation's own request options — Claude Code's
|
|
458
|
+
* approach. The prefix is byte-identical to the previous request, so the history is a
|
|
459
|
+
* cache READ (0.10×) instead of a fresh uncached transcript of up to 600K chars.
|
|
460
|
+
* Returns '' when it cannot be used (last turn is not the user's) or yields no text.
|
|
461
|
+
*/
|
|
462
|
+
export type CachedSummarizer = (instruction: string) => Promise<string>;
|
|
463
|
+
export declare function makeCachedSummarizer(messages: Message[], requestOptions: () => Parameters<typeof streamChat>[1], abortSignal?: {
|
|
464
|
+
aborted: boolean;
|
|
465
|
+
}): CachedSummarizer;
|
|
440
466
|
/** Rough token estimate for a resumed transcript — no API round-trip needed. */
|
|
441
467
|
export declare function estimateTokensRough(messages: Message[]): number;
|
|
442
468
|
/**
|
|
@@ -471,6 +497,17 @@ export declare function compactMessagesForResume(messages: Message[], opts: {
|
|
|
471
497
|
* own about where agent definitions come from.
|
|
472
498
|
*/
|
|
473
499
|
export declare function dispatchSubAgent(input: Record<string, unknown>, options: AgentLoopOptions, agentTypes: AgentType[]): Promise<ToolResult>;
|
|
500
|
+
/**
|
|
501
|
+
* `task` with run_in_background — start the sub-agent detached and return at once.
|
|
502
|
+
*
|
|
503
|
+
* The child runs with its OWN abort signal (the user's Stop on the main turn does not
|
|
504
|
+
* kill it; the hub's stop() does), renders nothing into the chat (its tool calls are
|
|
505
|
+
* only counted for the "N agents" badge), and cannot prompt the user: a call that the
|
|
506
|
+
* project's rules or the session mode do not already allow is refused with an
|
|
507
|
+
* explanation, which the child then reports (Claude Code auto-denies the same way).
|
|
508
|
+
* Its final report reaches the main agent as a <task-notification>.
|
|
509
|
+
*/
|
|
510
|
+
export declare function dispatchBackgroundSubAgent(input: Record<string, unknown>, options: AgentLoopOptions, agentTypes: AgentType[], hub: BackgroundAgentHub): ToolResult;
|
|
474
511
|
export declare function runAgentLoop(initialMessages: Message[], options: AgentLoopOptions): Promise<Message[]>;
|
|
475
512
|
/**
|
|
476
513
|
* Cut a history back to the last point the API will accept as a resumable
|
package/dist/agent/loop.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../src/agent/lo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