@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsLangService.d.ts","sourceRoot":"","sources":["../../src/tools/tsLangService.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAsB3C,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAElD;
|
|
1
|
+
{"version":3,"file":"tsLangService.d.ts","sourceRoot":"","sources":["../../src/tools/tsLangService.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAsB3C,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAElD;AA8MD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wFAAwF;AACxF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,YAAY,GAAG,UAAU,GAAG,IAAI,CAgBtE;AAED,2FAA2F;AAC3F,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,YAAY,GAAG;IAAE,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,UAAU,GAAG,IAAI,CAmBzG;AAED,+EAA+E;AAC/E,wBAAgB,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,UAAU,GAAG,IAAI,CAchE;AAED,0FAA0F;AAC1F,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED,8DAA8D;AAC9D,wBAAgB,oBAAoB,IAAI,IAAI,CAI3C"}
|
|
@@ -95,43 +95,129 @@ function loadTs(workDir) {
|
|
|
95
95
|
return null;
|
|
96
96
|
}
|
|
97
97
|
const _services = new Map();
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
/**
|
|
99
|
+
* The tsconfig that governs `filePath`: nearest one walking up from the file, else the
|
|
100
|
+
* one above workDir. Nearest-to-file matters in monorepos, where the workspace root
|
|
101
|
+
* often has no tsconfig (or only a solution-style one) and each package has its own.
|
|
102
|
+
*/
|
|
103
|
+
function findGoverningConfig(ts, workDir, filePath) {
|
|
104
|
+
try {
|
|
105
|
+
if (filePath) {
|
|
106
|
+
const near = ts.findConfigFile(path.dirname(filePath), ts.sys.fileExists, 'tsconfig.json');
|
|
107
|
+
if (near)
|
|
108
|
+
return near;
|
|
109
|
+
}
|
|
110
|
+
return ts.findConfigFile(workDir, ts.sys.fileExists, 'tsconfig.json') || undefined;
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/** Cap on root files handed to the language service, so a giant program stays bounded. */
|
|
117
|
+
const MAX_ROOT_FILES = 20000;
|
|
118
|
+
/** Minimum gap between re-expansions of the tsconfig file list (picks up NEW files). */
|
|
119
|
+
const ROOT_RESCAN_MS = Number(process.env.NEXRALL_TS_ROOT_RESCAN_MS ?? 2000);
|
|
120
|
+
function getService(workDir, filePath) {
|
|
102
121
|
const ts = loadTs(workDir);
|
|
103
122
|
if (!ts)
|
|
104
123
|
return null;
|
|
124
|
+
const cfgPath = findGoverningConfig(ts, workDir, filePath);
|
|
125
|
+
// One service per governing tsconfig (not per workDir): two packages with different
|
|
126
|
+
// compiler options / file sets must not share a program.
|
|
127
|
+
const key = cfgPath ?? workDir;
|
|
128
|
+
const cached = _services.get(key);
|
|
129
|
+
if (cached)
|
|
130
|
+
return cached;
|
|
105
131
|
const versions = new Map();
|
|
106
132
|
const snapshots = new Map();
|
|
133
|
+
// mtime per file at the time its snapshot was read. Now that every project file is a
|
|
134
|
+
// root (not just the ones the tool opened), a file the agent edits AFTER the service
|
|
135
|
+
// was built must be re-read: versions are derived from mtime, so an on-disk change
|
|
136
|
+
// bumps the version and the language service picks up the new text.
|
|
137
|
+
const mtimes = new Map();
|
|
138
|
+
const mtimeOf = (fileName) => {
|
|
139
|
+
try {
|
|
140
|
+
return fs.statSync(fileName).mtimeMs;
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
return -1;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
107
146
|
const readSource = (fileName) => {
|
|
108
147
|
const cachedSrc = snapshots.get(fileName);
|
|
109
|
-
|
|
148
|
+
const m = mtimeOf(fileName);
|
|
149
|
+
if (cachedSrc !== undefined && mtimes.get(fileName) === m)
|
|
110
150
|
return cachedSrc;
|
|
111
151
|
try {
|
|
112
152
|
const src = fs.readFileSync(fileName, 'utf-8');
|
|
113
153
|
snapshots.set(fileName, src);
|
|
154
|
+
mtimes.set(fileName, m);
|
|
114
155
|
return src;
|
|
115
156
|
}
|
|
116
157
|
catch {
|
|
117
|
-
return
|
|
158
|
+
return cachedSrc;
|
|
118
159
|
}
|
|
119
160
|
};
|
|
120
|
-
// Seed compiler options
|
|
161
|
+
// Seed compiler options AND the project's file list from the governing tsconfig.
|
|
162
|
+
//
|
|
163
|
+
// The file list is the fix for find_references silently under-reporting: the host
|
|
164
|
+
// used to report only files the tool had already opened, so the program contained
|
|
165
|
+
// just the queried file plus its imports, and "who calls X" found callers only in
|
|
166
|
+
// files that happened to be open — typically none. Measured: `class ReadDedupe`
|
|
167
|
+
// returned 1 reference (its own declaration) while loop.ts imports it.
|
|
168
|
+
//
|
|
169
|
+
// A solution-style tsconfig (`files: []` + `references`) has no files of its own, so
|
|
170
|
+
// its direct references are expanded one level.
|
|
121
171
|
let options = { allowJs: true, checkJs: false, target: 99 /* ESNext */, module: 99 };
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const parsed = ts.readConfigFile(
|
|
126
|
-
const conf = ts.parseJsonConfigFileContent(parsed.config ?? {}, ts.sys, path.dirname(
|
|
127
|
-
if (conf.options)
|
|
172
|
+
let rootFiles = new Set();
|
|
173
|
+
const addConfig = (cfg, depth) => {
|
|
174
|
+
try {
|
|
175
|
+
const parsed = ts.readConfigFile(cfg, ts.sys.readFile);
|
|
176
|
+
const conf = ts.parseJsonConfigFileContent(parsed.config ?? {}, ts.sys, path.dirname(cfg));
|
|
177
|
+
if (depth === 0 && conf.options)
|
|
128
178
|
options = { ...conf.options, allowJs: true };
|
|
179
|
+
for (const f of conf.fileNames ?? []) {
|
|
180
|
+
if (rootFiles.size >= MAX_ROOT_FILES)
|
|
181
|
+
break;
|
|
182
|
+
rootFiles.add(path.resolve(f));
|
|
183
|
+
}
|
|
184
|
+
if (depth === 0 && rootFiles.size === 0) {
|
|
185
|
+
for (const ref of conf.projectReferences ?? []) {
|
|
186
|
+
const refCfg = ts.resolveProjectReferencePath ? ts.resolveProjectReferencePath(ref) : ref.path;
|
|
187
|
+
if (refCfg && ts.sys.fileExists(refCfg))
|
|
188
|
+
addConfig(refCfg, depth + 1);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
129
191
|
}
|
|
130
|
-
|
|
131
|
-
|
|
192
|
+
catch { /* keep defaults */ }
|
|
193
|
+
};
|
|
194
|
+
if (cfgPath)
|
|
195
|
+
addConfig(cfgPath, 0);
|
|
196
|
+
// The file list is re-expanded (throttled) so a file the agent CREATES after the service
|
|
197
|
+
// was built becomes a root too — otherwise its references stay invisible for the whole
|
|
198
|
+
// session. Measured ~1 ms per re-expansion on this repo's packages.
|
|
199
|
+
let rootsScannedAt = Date.now();
|
|
200
|
+
const refreshRoots = () => {
|
|
201
|
+
if (!cfgPath || Date.now() - rootsScannedAt < ROOT_RESCAN_MS)
|
|
202
|
+
return;
|
|
203
|
+
rootsScannedAt = Date.now();
|
|
204
|
+
const prev = rootFiles;
|
|
205
|
+
rootFiles = new Set();
|
|
206
|
+
addConfig(cfgPath, 0);
|
|
207
|
+
if (rootFiles.size === 0)
|
|
208
|
+
rootFiles = prev; // a transient parse failure keeps the old list
|
|
209
|
+
};
|
|
132
210
|
const host = {
|
|
133
|
-
getScriptFileNames: () =>
|
|
134
|
-
|
|
211
|
+
getScriptFileNames: () => {
|
|
212
|
+
refreshRoots();
|
|
213
|
+
if (versions.size === 0)
|
|
214
|
+
return Array.from(rootFiles);
|
|
215
|
+
const all = new Set(rootFiles);
|
|
216
|
+
for (const f of versions.keys())
|
|
217
|
+
all.add(f);
|
|
218
|
+
return Array.from(all);
|
|
219
|
+
},
|
|
220
|
+
getScriptVersion: (f) => `${versions.get(f) ?? 0}:${mtimeOf(f)}`,
|
|
135
221
|
getScriptSnapshot: (f) => {
|
|
136
222
|
const src = readSource(f);
|
|
137
223
|
return src === undefined ? undefined : ts.ScriptSnapshot.fromString(src);
|
|
@@ -147,7 +233,7 @@ function getService(workDir) {
|
|
|
147
233
|
};
|
|
148
234
|
const service = ts.createLanguageService(host, ts.createDocumentRegistry());
|
|
149
235
|
const svc = { ts, service, root: workDir, versions, snapshots };
|
|
150
|
-
_services.set(
|
|
236
|
+
_services.set(key, svc);
|
|
151
237
|
return svc;
|
|
152
238
|
}
|
|
153
239
|
/** Register/refresh a file in the service, re-reading from disk (picks up edits). */
|
|
@@ -194,7 +280,7 @@ function relOf(root, abs) {
|
|
|
194
280
|
}
|
|
195
281
|
/** go_to_definition — resolve the symbol at (line, character) to its declaration(s). */
|
|
196
282
|
function tsGoToDefinition(deps) {
|
|
197
|
-
const svc = getService(deps.workDir);
|
|
283
|
+
const svc = getService(deps.workDir, deps.filePath);
|
|
198
284
|
if (!svc)
|
|
199
285
|
return null; // caller falls back to regex
|
|
200
286
|
if (!ensureFile(svc, deps.filePath))
|
|
@@ -219,7 +305,7 @@ function tsGoToDefinition(deps) {
|
|
|
219
305
|
}
|
|
220
306
|
/** find_references — every usage of the symbol at (line, character) across the project. */
|
|
221
307
|
function tsFindReferences(deps) {
|
|
222
|
-
const svc = getService(deps.workDir);
|
|
308
|
+
const svc = getService(deps.workDir, deps.filePath);
|
|
223
309
|
if (!svc)
|
|
224
310
|
return null;
|
|
225
311
|
if (!ensureFile(svc, deps.filePath))
|
|
@@ -248,7 +334,7 @@ function tsFindReferences(deps) {
|
|
|
248
334
|
}
|
|
249
335
|
/** get_hover — the inferred type + doc for the symbol at (line, character). */
|
|
250
336
|
function tsGetHover(deps) {
|
|
251
|
-
const svc = getService(deps.workDir);
|
|
337
|
+
const svc = getService(deps.workDir, deps.filePath);
|
|
252
338
|
if (!svc)
|
|
253
339
|
return null;
|
|
254
340
|
if (!ensureFile(svc, deps.filePath))
|
package/dist/types.d.ts
CHANGED
|
@@ -140,6 +140,35 @@ export interface SSEBalanceStatusEvent {
|
|
|
140
140
|
balance: number;
|
|
141
141
|
zero: boolean;
|
|
142
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* The exact `<runtime_context>` block (git status, editor, diagnostics, tree) the
|
|
145
|
+
* backend appended to the final user message of this request. The agent loop
|
|
146
|
+
* persists it into that message, so on the next round it is part of the cached
|
|
147
|
+
* history and the backend does NOT re-send it — before this, the same ~1-2.5K
|
|
148
|
+
* tokens went out uncached on every tool round-trip of a turn.
|
|
149
|
+
*/
|
|
150
|
+
export interface SSERuntimeContextEvent {
|
|
151
|
+
type: 'runtime_context';
|
|
152
|
+
text: string;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* One tool_use block is complete (input fully parsed) while the rest of the message
|
|
156
|
+
* is still generating. Preview only — dispatch still happens from message_complete;
|
|
157
|
+
* the loop uses it to start pure-read tools early (agent/toolPrefetch.ts).
|
|
158
|
+
*/
|
|
159
|
+
export interface SSEToolUseReadyEvent {
|
|
160
|
+
type: 'tool_use_ready';
|
|
161
|
+
id: string;
|
|
162
|
+
name: string;
|
|
163
|
+
input: Record<string, unknown>;
|
|
164
|
+
}
|
|
165
|
+
/** Opening tag shared with the backend (services/codeMessageCache.js). */
|
|
166
|
+
export declare const RUNTIME_CONTEXT_OPEN_TAG = "<runtime_context>";
|
|
167
|
+
/**
|
|
168
|
+
* True for a persisted runtime-context block. It is API scaffolding, not something
|
|
169
|
+
* the user typed — UI replay, export, titles and summaries must skip it.
|
|
170
|
+
*/
|
|
171
|
+
export declare function isRuntimeContextBlock(b: unknown): boolean;
|
|
143
172
|
/**
|
|
144
173
|
* Emitted when a stream attempt died AFTER partial output had already been
|
|
145
174
|
* rendered, and the network layer is restarting the SAME turn from scratch.
|
|
@@ -173,7 +202,7 @@ export interface SSEStreamRestartEvent {
|
|
|
173
202
|
*/
|
|
174
203
|
discardedChars: number;
|
|
175
204
|
}
|
|
176
|
-
export type SSEEvent = SSETextEvent | SSEToolUseEvent | SSEMessageCompleteEvent | SSEUsageEvent | SSEDoneEvent | SSEErrorEvent | SSEThinkingEvent | SSEThinkingProgressEvent | SSEThinkingDeltaEvent | SSERetryEvent | SSERetryResolvedEvent | SSEStreamRestartEvent | SSEBalanceStatusEvent;
|
|
205
|
+
export type SSEEvent = SSETextEvent | SSEToolUseEvent | SSEMessageCompleteEvent | SSEUsageEvent | SSEDoneEvent | SSEErrorEvent | SSEThinkingEvent | SSEThinkingProgressEvent | SSEThinkingDeltaEvent | SSERetryEvent | SSERetryResolvedEvent | SSEStreamRestartEvent | SSEBalanceStatusEvent | SSERuntimeContextEvent | SSEToolUseReadyEvent;
|
|
177
206
|
export interface UsageInfo {
|
|
178
207
|
input_tokens: number;
|
|
179
208
|
output_tokens: number;
|
|
@@ -205,6 +234,14 @@ export interface ToolResult {
|
|
|
205
234
|
*/
|
|
206
235
|
linesAdded?: number;
|
|
207
236
|
linesRemoved?: number;
|
|
237
|
+
/**
|
|
238
|
+
* `task` only: build/test commands the sub-agent ran, so the PARENT's ledger counts
|
|
239
|
+
* a verification that happened one level down instead of nudging "no test was run".
|
|
240
|
+
*/
|
|
241
|
+
childVerifications?: Array<{
|
|
242
|
+
cmd: string;
|
|
243
|
+
ok: boolean;
|
|
244
|
+
}>;
|
|
208
245
|
}
|
|
209
246
|
export interface AuthConfig {
|
|
210
247
|
/** Short-lived access token (the backend issues these with a 2-hour TTL). */
|
|
@@ -230,6 +267,23 @@ export interface PermissionRequest {
|
|
|
230
267
|
tool: string;
|
|
231
268
|
input: Record<string, unknown>;
|
|
232
269
|
description: string;
|
|
270
|
+
/** Set when a SUB-AGENT is asking — which one, so the prompt can say so. */
|
|
271
|
+
agent?: {
|
|
272
|
+
name: string;
|
|
273
|
+
description?: string;
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Identity of one tool call, passed with every tool event. `id` is the model's
|
|
278
|
+
* tool_use id (unique per call); `parentId` is the id of the `task` call whose
|
|
279
|
+
* sub-agent made it (undefined for the main agent). UIs match a result to its row by
|
|
280
|
+
* `id` — matching in arrival order broke as soon as sub-agents ran in parallel.
|
|
281
|
+
*/
|
|
282
|
+
export interface ToolEventMeta {
|
|
283
|
+
id: string;
|
|
284
|
+
parentId?: string;
|
|
285
|
+
/** The sub-agent type making the call (for labelling). */
|
|
286
|
+
agentName?: string;
|
|
233
287
|
}
|
|
234
288
|
export interface EnvContext {
|
|
235
289
|
cwd?: string;
|
|
@@ -275,8 +329,8 @@ export interface AgentLoopOptions {
|
|
|
275
329
|
onThinking?: (text: string) => void;
|
|
276
330
|
onThinkingDelta?: (text: string) => void;
|
|
277
331
|
onThinkingProgress?: (tokens: number) => void;
|
|
278
|
-
onToolUse: (name: string, input: Record<string, unknown>, isSubTask?: boolean) => void;
|
|
279
|
-
onToolResult: (name: string, result: ToolResult, isSubTask?: boolean) => void;
|
|
332
|
+
onToolUse: (name: string, input: Record<string, unknown>, isSubTask?: boolean, meta?: ToolEventMeta) => void;
|
|
333
|
+
onToolResult: (name: string, result: ToolResult, isSubTask?: boolean, meta?: ToolEventMeta) => void;
|
|
280
334
|
/**
|
|
281
335
|
* Fired with raw stdout/stderr chunks AS a foreground `bash` command runs —
|
|
282
336
|
* before the command finishes and before onToolResult fires. Lets a UI show
|
|
@@ -287,7 +341,7 @@ export interface AgentLoopOptions {
|
|
|
287
341
|
* omitting it changes nothing (falls back to the old spinner-only behavior).
|
|
288
342
|
* Not fired for `run_in_background` commands (poll bash_output instead).
|
|
289
343
|
*/
|
|
290
|
-
onToolStreamChunk?: (name: string, chunk: string, isSubTask?: boolean) => void;
|
|
344
|
+
onToolStreamChunk?: (name: string, chunk: string, isSubTask?: boolean, meta?: ToolEventMeta) => void;
|
|
291
345
|
/**
|
|
292
346
|
* Token usage for a model call. `partial` marks tokens from an attempt that was cut
|
|
293
347
|
* short and restarted — real, already-billed spend that should be counted toward
|
|
@@ -297,7 +351,8 @@ export interface AgentLoopOptions {
|
|
|
297
351
|
* to an older backend that doesn't send it yet. Both extra args are optional, so
|
|
298
352
|
* existing implementations keep compiling unchanged.
|
|
299
353
|
*/
|
|
300
|
-
|
|
354
|
+
/** `isSubTask` — usage of a sub-agent's request: add its cost, but it is NOT the main conversation's context size. */
|
|
355
|
+
onUsage: (u: UsageInfo, partial?: boolean, costUsd?: number, isSubTask?: boolean) => void;
|
|
301
356
|
/**
|
|
302
357
|
* Fired when the network layer is about to transparently retry a turn after
|
|
303
358
|
* a transient disconnect (network drop, machine sleep/wake, overloaded
|
|
@@ -556,6 +611,45 @@ export interface AgentLoopOptions {
|
|
|
556
611
|
* See docs/NEXRALL_AUDIT_TRAIL_LAYER.md.
|
|
557
612
|
*/
|
|
558
613
|
audit?: import('./agent/audit').AuditConfig;
|
|
614
|
+
/**
|
|
615
|
+
* Session-scoped registry of background sub-agents (`task` with run_in_background).
|
|
616
|
+
* Owned by the host, which renders the "N agents" badge and delivers completions
|
|
617
|
+
* that arrive while no turn is running. Absent → run_in_background falls back to
|
|
618
|
+
* running in the foreground. Never passed to sub-agents (only the main agent may
|
|
619
|
+
* start background work).
|
|
620
|
+
*/
|
|
621
|
+
backgroundAgents?: import('./agent/backgroundAgents').BackgroundAgentHub;
|
|
622
|
+
/**
|
|
623
|
+
* Internal (sub-agents): receives the run's stop reason and its user-facing notice
|
|
624
|
+
* INSTEAD of the notice going to onNotice — a child's "stopped: budget" belongs in
|
|
625
|
+
* its parent's tool result, not in the user's chat as if the main agent stopped.
|
|
626
|
+
*/
|
|
627
|
+
_onStopReason?: (reason: string, notice: string | null) => void;
|
|
628
|
+
/** Internal (sub-agents): verification commands the run executed, reported at the end. */
|
|
629
|
+
_onVerifications?: (records: Array<{
|
|
630
|
+
cmd: string;
|
|
631
|
+
ok: boolean;
|
|
632
|
+
}>) => void;
|
|
633
|
+
/**
|
|
634
|
+
* Internal: the project's own instructions (nexrall.md + memory), WITHOUT any
|
|
635
|
+
* sub-agent role layered on top. A grandchild composes its prompt from this, never
|
|
636
|
+
* from its parent's composite role prompt.
|
|
637
|
+
*/
|
|
638
|
+
_projectNexrallMd?: string;
|
|
639
|
+
/** Internal: hooks declared by THIS run's agent definition (not inherited by its children). */
|
|
640
|
+
_agentHooks?: import('./agent/agentTypes').AgentHooks;
|
|
641
|
+
/** Internal: MCP servers this run may use (intersection of ancestors' `mcpServers`). Absent = all. */
|
|
642
|
+
_mcpServerAllowlist?: Set<string>;
|
|
643
|
+
/** Internal: tools refused for this run and every run it spawns (union of `disallowedTools`). */
|
|
644
|
+
_disallowedTools?: Set<string>;
|
|
645
|
+
/**
|
|
646
|
+
* The conversation this run belongs to (VS Code session id, CLI session id, desktop
|
|
647
|
+
* task id). Scopes the sub-agent budget and resumable sub-agent ids to that chat when
|
|
648
|
+
* several chats share one process. Optional: absent = one process-wide scope.
|
|
649
|
+
*/
|
|
650
|
+
sessionId?: string;
|
|
651
|
+
/** Internal: tool_use id of the `task` call that spawned this run (for ToolEventMeta.parentId). */
|
|
652
|
+
_taskToolUseId?: string;
|
|
559
653
|
}
|
|
560
654
|
/**
|
|
561
655
|
* Thrown by `runAgentLoop` when a turn cannot continue (stream died, upstream
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,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AAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAOzF;AAED,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,cAAc,CAEpE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,EAAE,GAAG,IAAI,CAG7D"}
|
package/dist/types.js
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// ─── Content Blocks ───────────────────────────────────────────────────────────
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.AgentTurnError = void 0;
|
|
4
|
+
exports.AgentTurnError = exports.RUNTIME_CONTEXT_OPEN_TAG = void 0;
|
|
5
|
+
exports.isRuntimeContextBlock = isRuntimeContextBlock;
|
|
5
6
|
exports.isAgentTurnError = isAgentTurnError;
|
|
6
7
|
exports.salvageHistory = salvageHistory;
|
|
8
|
+
/** Opening tag shared with the backend (services/codeMessageCache.js). */
|
|
9
|
+
exports.RUNTIME_CONTEXT_OPEN_TAG = '<runtime_context>';
|
|
10
|
+
/**
|
|
11
|
+
* True for a persisted runtime-context block. It is API scaffolding, not something
|
|
12
|
+
* the user typed — UI replay, export, titles and summaries must skip it.
|
|
13
|
+
*/
|
|
14
|
+
function isRuntimeContextBlock(b) {
|
|
15
|
+
const x = b;
|
|
16
|
+
return !!x && x.type === 'text' && typeof x.text === 'string' && x.text.startsWith(exports.RUNTIME_CONTEXT_OPEN_TAG);
|
|
17
|
+
}
|
|
7
18
|
// ─── Turn failure that preserves work already done ───────────────────────────
|
|
8
19
|
/**
|
|
9
20
|
* Thrown by `runAgentLoop` when a turn cannot continue (stream died, upstream
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class MiniYamlError extends Error {
|
|
2
|
+
}
|
|
3
|
+
/** Parse YAML-subset text (already de-indented or not) into plain JS values. */
|
|
4
|
+
export declare function parseMiniYaml(text: string): unknown;
|
|
5
|
+
/**
|
|
6
|
+
* The value of a top-level `key:` in a frontmatter block, parsed with parseMiniYaml.
|
|
7
|
+
* Returns undefined when the key is absent. Throws MiniYamlError when present but unparseable.
|
|
8
|
+
*/
|
|
9
|
+
export declare function frontmatterBlock(raw: string, key: string): unknown;
|
|
10
|
+
//# sourceMappingURL=miniYaml.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"miniYaml.d.ts","sourceRoot":"","sources":["../../src/util/miniYaml.ts"],"names":[],"mappings":"AAQA,qBAAa,aAAc,SAAQ,KAAK;CAAG;AA6E3C,gFAAgF;AAChF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAgBnD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAclE"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// A deliberately small YAML subset parser — block maps, block lists ("- "), and scalars.
|
|
3
|
+
//
|
|
4
|
+
// Exists for exactly one caller today: the nested `hooks:` block in an agent definition's
|
|
5
|
+
// frontmatter (Claude Code's format), which the flat frontmatter parser collapses into a
|
|
6
|
+
// single string. Anything outside the subset (anchors, flow collections, multi-line
|
|
7
|
+
// scalars, tags) is a parse error rather than a guess, so a hook is never run from a
|
|
8
|
+
// structure we misread. Inline JSON (`hooks: {"PreToolUse": [...]}`) is accepted too.
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.MiniYamlError = void 0;
|
|
11
|
+
exports.parseMiniYaml = parseMiniYaml;
|
|
12
|
+
exports.frontmatterBlock = frontmatterBlock;
|
|
13
|
+
class MiniYamlError extends Error {
|
|
14
|
+
}
|
|
15
|
+
exports.MiniYamlError = MiniYamlError;
|
|
16
|
+
function scalar(raw) {
|
|
17
|
+
const v = raw.trim();
|
|
18
|
+
if (v === '')
|
|
19
|
+
return null;
|
|
20
|
+
if ((v.startsWith('"') && v.endsWith('"')) || (v.startsWith("'") && v.endsWith("'"))) {
|
|
21
|
+
const inner = v.slice(1, -1);
|
|
22
|
+
return v.startsWith('"') ? inner.replace(/\\"/g, '"').replace(/\\\\/g, '\\') : inner.replace(/''/g, "'");
|
|
23
|
+
}
|
|
24
|
+
if (/^(true|false)$/i.test(v))
|
|
25
|
+
return v.toLowerCase() === 'true';
|
|
26
|
+
if (/^-?\d+(\.\d+)?$/.test(v))
|
|
27
|
+
return Number(v);
|
|
28
|
+
if (/^[[{&*!|>]/.test(v))
|
|
29
|
+
throw new MiniYamlError(`unsupported YAML value: ${v}`);
|
|
30
|
+
// Strip a trailing comment on an unquoted scalar.
|
|
31
|
+
return v.replace(/\s+#.*$/, '');
|
|
32
|
+
}
|
|
33
|
+
function splitKey(text, no) {
|
|
34
|
+
const m = text.match(/^("[^"]*"|'[^']*'|[^:#][^:]*?):(?:\s+(.*))?$/);
|
|
35
|
+
if (!m)
|
|
36
|
+
throw new MiniYamlError(`line ${no}: expected "key: value", got "${text}"`);
|
|
37
|
+
const key = m[1].replace(/^["']|["']$/g, '').trim();
|
|
38
|
+
return [key, m[2] ?? ''];
|
|
39
|
+
}
|
|
40
|
+
function parseBlock(lines, start, indent) {
|
|
41
|
+
if (start >= lines.length)
|
|
42
|
+
return [null, start];
|
|
43
|
+
const first = lines[start];
|
|
44
|
+
if (first.indent < indent)
|
|
45
|
+
return [null, start];
|
|
46
|
+
const isList = first.text.startsWith('- ') || first.text === '-';
|
|
47
|
+
if (isList) {
|
|
48
|
+
const out = [];
|
|
49
|
+
let i = start;
|
|
50
|
+
const itemIndent = first.indent;
|
|
51
|
+
while (i < lines.length && lines[i].indent === itemIndent && (lines[i].text.startsWith('- ') || lines[i].text === '-')) {
|
|
52
|
+
const rest = lines[i].text === '-' ? '' : lines[i].text.slice(2);
|
|
53
|
+
if (!rest.trim()) {
|
|
54
|
+
const [v, next] = parseBlock(lines, i + 1, itemIndent + 1);
|
|
55
|
+
out.push(v);
|
|
56
|
+
i = next;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
// "- key: value" starts a map whose further keys sit at itemIndent + 2.
|
|
60
|
+
if (/^[^\s"'][^:]*:(\s|$)|^["'][^"']*["']:(\s|$)/.test(rest)) {
|
|
61
|
+
const virtual = [{ indent: itemIndent + 2, text: rest, no: lines[i].no }];
|
|
62
|
+
let j = i + 1;
|
|
63
|
+
while (j < lines.length && lines[j].indent > itemIndent) {
|
|
64
|
+
virtual.push(lines[j]);
|
|
65
|
+
j++;
|
|
66
|
+
}
|
|
67
|
+
const [v] = parseBlock(virtual, 0, itemIndent + 2);
|
|
68
|
+
out.push(v);
|
|
69
|
+
i = j;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
out.push(scalar(rest));
|
|
73
|
+
i++;
|
|
74
|
+
}
|
|
75
|
+
return [out, i];
|
|
76
|
+
}
|
|
77
|
+
const obj = {};
|
|
78
|
+
let i = start;
|
|
79
|
+
const mapIndent = first.indent;
|
|
80
|
+
while (i < lines.length && lines[i].indent >= indent) {
|
|
81
|
+
const ln = lines[i];
|
|
82
|
+
if (ln.indent > mapIndent)
|
|
83
|
+
throw new MiniYamlError(`line ${ln.no}: unexpected indentation`);
|
|
84
|
+
if (ln.indent < mapIndent)
|
|
85
|
+
break;
|
|
86
|
+
const [key, rest] = splitKey(ln.text, ln.no);
|
|
87
|
+
if (rest.trim()) {
|
|
88
|
+
obj[key] = scalar(rest);
|
|
89
|
+
i++;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
const [v, next] = parseBlock(lines, i + 1, mapIndent + 1);
|
|
93
|
+
obj[key] = v;
|
|
94
|
+
i = next;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return [obj, i];
|
|
98
|
+
}
|
|
99
|
+
/** Parse YAML-subset text (already de-indented or not) into plain JS values. */
|
|
100
|
+
function parseMiniYaml(text) {
|
|
101
|
+
const trimmed = text.trim();
|
|
102
|
+
if (trimmed.startsWith('{') || trimmed.startsWith('[')) {
|
|
103
|
+
try {
|
|
104
|
+
return JSON.parse(trimmed);
|
|
105
|
+
}
|
|
106
|
+
catch (e) {
|
|
107
|
+
throw new MiniYamlError(`invalid inline JSON: ${e.message}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const lines = [];
|
|
111
|
+
text.split('\n').forEach((raw, idx) => {
|
|
112
|
+
if (!raw.trim() || raw.trim().startsWith('#'))
|
|
113
|
+
return;
|
|
114
|
+
if (/\t/.test(raw.match(/^\s*/)?.[0] ?? ''))
|
|
115
|
+
throw new MiniYamlError(`line ${idx + 1}: tabs are not allowed for indentation`);
|
|
116
|
+
const indent = raw.length - raw.trimStart().length;
|
|
117
|
+
lines.push({ indent, text: raw.trim(), no: idx + 1 });
|
|
118
|
+
});
|
|
119
|
+
if (!lines.length)
|
|
120
|
+
return null;
|
|
121
|
+
const [v, end] = parseBlock(lines, 0, lines[0].indent);
|
|
122
|
+
if (end < lines.length)
|
|
123
|
+
throw new MiniYamlError(`line ${lines[end].no}: could not parse "${lines[end].text}"`);
|
|
124
|
+
return v;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The value of a top-level `key:` in a frontmatter block, parsed with parseMiniYaml.
|
|
128
|
+
* Returns undefined when the key is absent. Throws MiniYamlError when present but unparseable.
|
|
129
|
+
*/
|
|
130
|
+
function frontmatterBlock(raw, key) {
|
|
131
|
+
const m = raw.replace(/^/, '').match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
132
|
+
if (!m)
|
|
133
|
+
return undefined;
|
|
134
|
+
const lines = m[1].split(/\r?\n/);
|
|
135
|
+
const at = lines.findIndex((l) => new RegExp(`^${key}\\s*:`, 'i').test(l));
|
|
136
|
+
if (at < 0)
|
|
137
|
+
return undefined;
|
|
138
|
+
const inline = lines[at].replace(new RegExp(`^${key}\\s*:`, 'i'), '').trim();
|
|
139
|
+
if (inline)
|
|
140
|
+
return parseMiniYaml(inline);
|
|
141
|
+
const block = [];
|
|
142
|
+
for (let i = at + 1; i < lines.length; i++) {
|
|
143
|
+
if (lines[i].trim() && !/^\s/.test(lines[i]))
|
|
144
|
+
break; // next top-level key
|
|
145
|
+
block.push(lines[i]);
|
|
146
|
+
}
|
|
147
|
+
return parseMiniYaml(block.join('\n'));
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=miniYaml.js.map
|
package/package.json
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexrall/code-core",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.65",
|
|
4
4
|
"description": "Core agent loop, tools, and extension primitives for Nexrall Code — embed an AI coding agent in any Node.js application.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Nexrall <support@nexrall.com> (https://nexrall.com)",
|
|
7
|
-
"homepage": "https://
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/nexrall/nexrall-code.git",
|
|
11
|
-
"directory": "packages/core"
|
|
12
|
-
},
|
|
13
|
-
"bugs": {
|
|
14
|
-
"url": "https://github.com/nexrall/nexrall-code/issues"
|
|
15
|
-
},
|
|
7
|
+
"homepage": "https://nexrall.com",
|
|
16
8
|
"keywords": [
|
|
17
9
|
"ai",
|
|
18
10
|
"agent",
|
|
@@ -87,12 +79,6 @@
|
|
|
87
79
|
"engines": {
|
|
88
80
|
"node": ">=18.0.0"
|
|
89
81
|
},
|
|
90
|
-
"scripts": {
|
|
91
|
-
"build": "tsc",
|
|
92
|
-
"dev": "tsc --watch",
|
|
93
|
-
"test": "npm run build && node --test test/*.test.mjs",
|
|
94
|
-
"prepublishOnly": "npm run build && npm test"
|
|
95
|
-
},
|
|
96
82
|
"dependencies": {
|
|
97
83
|
"eventsource-parser": "^1.1.2",
|
|
98
84
|
"node-fetch": "^3.3.2",
|
|
@@ -103,5 +89,10 @@
|
|
|
103
89
|
"devDependencies": {
|
|
104
90
|
"@types/node": "^26.0.1",
|
|
105
91
|
"typescript": "^6.0.3"
|
|
92
|
+
},
|
|
93
|
+
"scripts": {
|
|
94
|
+
"build": "tsc",
|
|
95
|
+
"dev": "tsc --watch",
|
|
96
|
+
"test": "npm run build && node --test test/*.test.mjs"
|
|
106
97
|
}
|
|
107
|
-
}
|
|
98
|
+
}
|