@nexrall/code-core 1.4.71 → 1.4.72
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.map +1 -1
- package/dist/agent/agentRegistry.js +28 -10
- package/dist/agent/agentTypes.d.ts.map +1 -1
- package/dist/agent/agentTypes.js +159 -48
- package/dist/agent/askOnce.d.ts.map +1 -1
- package/dist/agent/askOnce.js +14 -5
- package/dist/agent/backgroundAgents.d.ts.map +1 -1
- package/dist/agent/backgroundAgents.js +22 -8
- package/dist/agent/claimEvidence.d.ts.map +1 -1
- package/dist/agent/claimEvidence.js +2 -1
- package/dist/agent/compaction.d.ts.map +1 -1
- package/dist/agent/compaction.js +31 -10
- package/dist/agent/crossProcessLock.d.ts.map +1 -1
- package/dist/agent/crossProcessLock.js +14 -6
- package/dist/agent/editCompleteness.d.ts.map +1 -1
- package/dist/agent/fileLocks.d.ts.map +1 -1
- package/dist/agent/fileLocks.js +14 -5
- package/dist/agent/flaky.d.ts.map +1 -1
- package/dist/agent/hooks.d.ts.map +1 -1
- package/dist/agent/hooks.js +284 -75
- package/dist/agent/iterationPolicy.d.ts.map +1 -1
- package/dist/agent/iterationPolicy.js +26 -23
- package/dist/agent/lifecycleHost.d.ts.map +1 -1
- package/dist/agent/lifecycleHost.js +35 -11
- package/dist/agent/loop.d.ts +22 -4
- package/dist/agent/loop.d.ts.map +1 -1
- package/dist/agent/loop.js +223 -51
- package/dist/agent/memory.d.ts.map +1 -1
- package/dist/agent/memory.js +13 -7
- package/dist/agent/modelCatalogue.d.ts.map +1 -1
- package/dist/agent/modelCatalogue.js +4 -1
- package/dist/agent/nestedInstructions.d.ts +122 -0
- package/dist/agent/nestedInstructions.d.ts.map +1 -0
- package/dist/agent/nestedInstructions.js +696 -0
- package/dist/agent/peerRegistry.d.ts.map +1 -1
- package/dist/agent/peerRegistry.js +44 -6
- package/dist/agent/peerTransport.d.ts.map +1 -1
- package/dist/agent/peerTransport.js +18 -6
- package/dist/agent/planMode.d.ts.map +1 -1
- package/dist/agent/planMode.js +194 -41
- package/dist/agent/readDedupe.d.ts.map +1 -1
- package/dist/agent/readDedupe.js +3 -1
- package/dist/agent/securityLint.d.ts.map +1 -1
- package/dist/agent/sharedTasks.d.ts.map +1 -1
- package/dist/agent/sharedTasks.js +20 -5
- package/dist/agent/skills.d.ts +79 -0
- package/dist/agent/skills.d.ts.map +1 -1
- package/dist/agent/skills.js +403 -14
- package/dist/agent/subAgentBudget.d.ts.map +1 -1
- package/dist/agent/subTask.d.ts.map +1 -1
- package/dist/agent/subTask.js +87 -37
- package/dist/agent/subTaskSupport.d.ts.map +1 -1
- package/dist/agent/subTaskSupport.js +43 -14
- package/dist/agent/testIntegrity.d.ts.map +1 -1
- package/dist/agent/testIntegrity.js +4 -2
- package/dist/agent/toolDescriptions.d.ts.map +1 -1
- package/dist/agent/toolPrefetch.d.ts.map +1 -1
- package/dist/agent/toolPrefetch.js +15 -11
- package/dist/agent/trust.d.ts.map +1 -1
- package/dist/agent/trust.js +6 -2
- package/dist/agent/worktree.d.ts.map +1 -1
- package/dist/agent/worktree.js +70 -16
- package/dist/agent/worktreeEnforcement.d.ts.map +1 -1
- package/dist/agent/worktreeEnforcement.js +9 -4
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +63 -31
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +3 -1
- package/dist/checkpoint/manager.d.ts.map +1 -1
- package/dist/checkpoint/manager.js +22 -7
- package/dist/commands/loader.d.ts.map +1 -1
- package/dist/commands/loader.js +6 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/mcp/client.d.ts +34 -0
- package/dist/mcp/client.d.ts.map +1 -1
- package/dist/mcp/client.js +89 -24
- package/dist/mcp/httpClient.d.ts +24 -1
- package/dist/mcp/httpClient.d.ts.map +1 -1
- package/dist/mcp/httpClient.js +80 -14
- package/dist/mcp/instructions.d.ts +11 -0
- package/dist/mcp/instructions.d.ts.map +1 -0
- package/dist/mcp/instructions.js +42 -0
- package/dist/mcp/manager.d.ts +24 -0
- package/dist/mcp/manager.d.ts.map +1 -1
- package/dist/mcp/manager.js +117 -24
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +48 -14
- package/dist/mcp/sseClient.d.ts +9 -1
- package/dist/mcp/sseClient.d.ts.map +1 -1
- package/dist/mcp/sseClient.js +43 -10
- package/dist/mcp/stats.d.ts.map +1 -1
- package/dist/permissions/bashClassify.d.ts.map +1 -1
- package/dist/permissions/bashClassify.js +25 -3
- package/dist/permissions/destructive.d.ts.map +1 -1
- package/dist/permissions/destructive.js +7 -2
- package/dist/permissions/destructiveTokens.d.ts.map +1 -1
- package/dist/permissions/destructiveTokens.js +104 -24
- package/dist/permissions/modePolicy.d.ts.map +1 -1
- package/dist/permissions/modePolicy.js +40 -17
- package/dist/permissions/rules.d.ts.map +1 -1
- package/dist/permissions/rules.js +7 -5
- package/dist/plugins/data.d.ts.map +1 -1
- package/dist/plugins/data.js +6 -2
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +18 -7
- package/dist/plugins/installer.d.ts.map +1 -1
- package/dist/plugins/installer.js +17 -10
- package/dist/plugins/sources.d.ts.map +1 -1
- package/dist/plugins/sources.js +9 -3
- package/dist/tools/executor.d.ts.map +1 -1
- package/dist/tools/executor.js +454 -168
- package/dist/tools/sandbox.d.ts.map +1 -1
- package/dist/tools/sandbox.js +5 -1
- package/dist/tools/symbols.d.ts.map +1 -1
- package/dist/tools/symbols.js +30 -8
- package/dist/tools/tsLangService.d.ts.map +1 -1
- package/dist/tools/tsLangService.js +12 -4
- package/dist/types.d.ts +17 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/util/frontmatter.d.ts.map +1 -1
- package/dist/util/miniYaml.d.ts.map +1 -1
- package/dist/util/miniYaml.js +3 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iterationPolicy.d.ts","sourceRoot":"","sources":["../../src/agent/iterationPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAWrD,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"iterationPolicy.d.ts","sourceRoot":"","sources":["../../src/agent/iterationPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAWrD,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAU3C,eAAO,MAAM,WAAW,IAAI,CAAC;AAK7B,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAuBrC,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAKxC,yFAAyF;AACzF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAG1G;AAED,kDAAkD;AAClD,eAAO,MAAM,eAAe;;;CAAuD,CAAC;AAEpF;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,MAAM,CAK3F;AAED,+CAA+C;AAC/C,eAAO,MAAM,YAAY;;;CAAsC,CAAC;AAEhE;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AAEtD;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;CAgB3B,CAAC;AAEX,mEAAmE;AACnE,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,gBAAgB,CAAC;CACzB;AAED;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,EAAE,kBAAkB,GAAG,SAAS,EACvC,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,UAAU,CAAC,CA8BrB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAClB,OAAO,GACP,SAAS,GACT,oBAAoB,GACpB,gBAAgB,GAChB,cAAc,GACd,YAAY,GACZ,gBAAgB,GAChB,kBAAkB,GAClB,SAAS,GACT,gBAAgB,GAChB,QAAQ,GACR,cAAc,GACd,SAAS,CAAC;AAEd;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,UAAU,EAClB,GAAG,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAO,GACrF,MAAM,GAAG,IAAI,CAgFf;AAMD,eAAO,MAAM,sBAAsB,EAAE,WAAW,CAAC,MAAM,CAMrD,CAAC;AAaH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,EAAE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAelH;AAKD,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,OAAO,GAAG,SAAS,EAAE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAQnH"}
|
|
@@ -196,9 +196,9 @@ function stopReasonNotice(reason, ctx = {}) {
|
|
|
196
196
|
// continue to retry" without that context reads as if nothing was tried, and the
|
|
197
197
|
// user's manual retry is then the fourth identical attempt — so name the attempts.
|
|
198
198
|
case 'empty-response':
|
|
199
|
-
return `\n\u26a0\ufe0f The model returned an empty response ${exports.EMPTY_TURN_RETRY_LIMIT} times in a row, so nothing was done. ` +
|
|
199
|
+
return (`\n\u26a0\ufe0f The model returned an empty response ${exports.EMPTY_TURN_RETRY_LIMIT} times in a row, so nothing was done. ` +
|
|
200
200
|
`This is usually a transient upstream hiccup that the agent retries by itself; it did not clear this time. ` +
|
|
201
|
-
`Send "continue" to try again, or switch model with /model if it persists.\n
|
|
201
|
+
`Send "continue" to try again, or switch model with /model if it persists.\n`);
|
|
202
202
|
// Deliberately NOT folded into 'empty-response'. Both arrive as an assistant
|
|
203
203
|
// message with no content once thinking blocks are stripped, so they used to
|
|
204
204
|
// be indistinguishable — and the user was told the truncation case was "a
|
|
@@ -207,40 +207,40 @@ function stopReasonNotice(reason, ctx = {}) {
|
|
|
207
207
|
// with the same budget and the same reasoning behaviour, reproducing it
|
|
208
208
|
// exactly. Naming the cause is the fix; the advice has to change with it.
|
|
209
209
|
case 'output-limit':
|
|
210
|
-
return `\n\u26a0\ufe0f The model used its entire output budget on internal reasoning and was cut off ` +
|
|
210
|
+
return (`\n\u26a0\ufe0f The model used its entire output budget on internal reasoning and was cut off ` +
|
|
211
211
|
`before it could reply, so nothing was done. This will repeat identically if you just retry \u2014 ` +
|
|
212
|
-
`lower the reasoning effort (/effort) or split the task into smaller steps.\n
|
|
212
|
+
`lower the reasoning effort (/effort) or split the task into smaller steps.\n`);
|
|
213
213
|
case 'no-balance':
|
|
214
|
-
return `\n\ud83d\udcb3 Stopped: your balance is empty, so the request was rejected before it started. ` +
|
|
215
|
-
`Top up and send "continue" \u2014 no tokens were used for this turn.\n
|
|
214
|
+
return (`\n\ud83d\udcb3 Stopped: your balance is empty, so the request was rejected before it started. ` +
|
|
215
|
+
`Top up and send "continue" \u2014 no tokens were used for this turn.\n`);
|
|
216
216
|
case 'no-team-budget':
|
|
217
|
-
return `\n\ud83d\udcb3 Stopped: the team budget you are billing to is empty, so the request was rejected ` +
|
|
217
|
+
return (`\n\ud83d\udcb3 Stopped: the team budget you are billing to is empty, so the request was rejected ` +
|
|
218
218
|
`before it started. Ask your team admin to add funds \u2014 or switch "Bill to" back to Personal \u2014 ` +
|
|
219
|
-
`and send "continue". No tokens were used for this turn.\n
|
|
219
|
+
`and send "continue". No tokens were used for this turn.\n`);
|
|
220
220
|
case 'team-unavailable':
|
|
221
|
-
return `\n\u26a0\ufe0f Stopped: that team is no longer available for billing (you may have been removed, or the ` +
|
|
221
|
+
return (`\n\u26a0\ufe0f Stopped: that team is no longer available for billing (you may have been removed, or the ` +
|
|
222
222
|
`team was suspended). "Bill to" has been reset to your Personal account, so sending "continue" will ` +
|
|
223
|
-
`run on your own wallet.\n
|
|
223
|
+
`run on your own wallet.\n`);
|
|
224
224
|
case 'stalled':
|
|
225
|
-
return `\n\ud83d\uded1 Stopped: the last ${exports.STALL_LIMIT} tool rounds all failed, so the agent looked stuck. ` +
|
|
226
|
-
`Fix the underlying error (or grant the needed permission) and send "continue".\n
|
|
225
|
+
return (`\n\ud83d\uded1 Stopped: the last ${exports.STALL_LIMIT} tool rounds all failed, so the agent looked stuck. ` +
|
|
226
|
+
`Fix the underlying error (or grant the needed permission) and send "continue".\n`);
|
|
227
227
|
case 'stalled-repeat':
|
|
228
|
-
return `\n\ud83d\uded1 Stopped: the same tool error repeated ${exports.REPEAT_STALL_LIMIT} rounds in a row, so the agent ` +
|
|
228
|
+
return (`\n\ud83d\uded1 Stopped: the same tool error repeated ${exports.REPEAT_STALL_LIMIT} rounds in a row, so the agent ` +
|
|
229
229
|
`was looping without making progress.` +
|
|
230
230
|
(ctx.repeatError ? ` The recurring error was:\n${ctx.repeatError}\n` : '\n') +
|
|
231
|
-
`Fix that underlying cause (or grant the needed permission) and send "continue".\n
|
|
231
|
+
`Fix that underlying cause (or grant the needed permission) and send "continue".\n`);
|
|
232
232
|
case 'hook-blocked':
|
|
233
|
-
return `\n\u26d4 A PostToolBatch hook stopped the turn before the next model call` +
|
|
233
|
+
return (`\n\u26d4 A PostToolBatch hook stopped the turn before the next model call` +
|
|
234
234
|
(ctx.hookReason ? `: ${ctx.hookReason}` : '.') +
|
|
235
|
-
`\nThe reason is in the conversation, so send "continue" once the cause is handled.\n
|
|
235
|
+
`\nThe reason is in the conversation, so send "continue" once the cause is handled.\n`);
|
|
236
236
|
case 'budget':
|
|
237
|
-
return `\n\u23f8\ufe0f Stopped at the ${ctx.budget}-step safety limit \u2014 the task may be incomplete. ` +
|
|
237
|
+
return (`\n\u23f8\ufe0f Stopped at the ${ctx.budget}-step safety limit \u2014 the task may be incomplete. ` +
|
|
238
238
|
`Send "continue" to resume, or raise the limit via "maxIterations" in .nexrall/settings.json ` +
|
|
239
|
-
`(or the NEXRALL_MAX_ITERATIONS env var). Auto-continue can be disabled with "autoContinue": false.\n
|
|
239
|
+
`(or the NEXRALL_MAX_ITERATIONS env var). Auto-continue can be disabled with "autoContinue": false.\n`);
|
|
240
240
|
case 'unknown':
|
|
241
241
|
default:
|
|
242
|
-
return `\n\u26a0\ufe0f The run ended unexpectedly without completing. Your work so far is preserved \u2014 ` +
|
|
243
|
-
`send "continue" to resume.\n
|
|
242
|
+
return (`\n\u26a0\ufe0f The run ended unexpectedly without completing. Your work so far is preserved \u2014 ` +
|
|
243
|
+
`send "continue" to resume.\n`);
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
// Error codes that mean "this team cannot pay for anything right now" — the
|
|
@@ -268,9 +268,12 @@ exports.TEAM_SCOPE_ERROR_CODES = new Set([
|
|
|
268
268
|
function resolveMaxIterations(optionValue, settingsRaw) {
|
|
269
269
|
const fromEnv = Number(process.env.NEXRALL_MAX_ITERATIONS);
|
|
270
270
|
const fromSettings = Number(settingsRaw.maxIterations);
|
|
271
|
-
const explicit =
|
|
272
|
-
|
|
273
|
-
|
|
271
|
+
const explicit = typeof optionValue === 'number' && optionValue > 0
|
|
272
|
+
? optionValue
|
|
273
|
+
: Number.isFinite(fromEnv) && fromEnv > 0
|
|
274
|
+
? fromEnv
|
|
275
|
+
: Number.isFinite(fromSettings) && fromSettings > 0
|
|
276
|
+
? fromSettings
|
|
274
277
|
: undefined;
|
|
275
278
|
if (explicit === undefined)
|
|
276
279
|
return DEFAULT_MAX_ITERATIONS;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycleHost.d.ts","sourceRoot":"","sources":["../../src/agent/lifecycleHost.ts"],"names":[],"mappings":"AAeA,kFAAkF;AAClF,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,0FAA0F;IAC1F,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IACtD,oHAAoH;IACpH,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;;;;;GAMG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,iBAAiB,EAAE,GACzB,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"lifecycleHost.d.ts","sourceRoot":"","sources":["../../src/agent/lifecycleHost.ts"],"names":[],"mappings":"AAeA,kFAAkF;AAClF,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,0FAA0F;IAC1F,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IACtD,oHAAoH;IACpH,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;;;;;GAMG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,iBAAiB,EAAE,GACzB,OAAO,CAAC,IAAI,CAAC,CAuBf;AAED,MAAM,WAAW,kBAAkB;IACjC,6EAA6E;IAC7E,IAAI,IAAI,IAAI,CAAC;IACb,8FAA8F;IAC9F,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACxC,wFAAwF;IACxF,YAAY,IAAI,MAAM,EAAE,CAAC;CAC1B;AAiBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE;IACL,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GACA,kBAAkB,GAAG,IAAI,CAyK3B;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,EACvB,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACzB,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAC9B,MAAM,EAAE,CAIV"}
|
|
@@ -73,13 +73,21 @@ async function fireInstructionsLoadedHooks(workDir, sessionId, files) {
|
|
|
73
73
|
}, f.load_reason).catch(() => undefined);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
catch {
|
|
76
|
+
catch {
|
|
77
|
+
/* a hook must never break startup */
|
|
78
|
+
}
|
|
77
79
|
}
|
|
78
80
|
/** Only basenames in the working directory can be watched — a matcher is a filename, not a path. */
|
|
79
81
|
function isWatchableName(name) {
|
|
80
82
|
// Claude Code is narrower still (letters, digits, _, |); we allow the characters a real
|
|
81
83
|
// filename needs and drop anything that tries to be a path or a glob.
|
|
82
|
-
return !!name &&
|
|
84
|
+
return (!!name &&
|
|
85
|
+
!name.includes('/') &&
|
|
86
|
+
!name.includes('\\') &&
|
|
87
|
+
!name.includes('*') &&
|
|
88
|
+
!name.includes('?') &&
|
|
89
|
+
name !== '.' &&
|
|
90
|
+
name !== '..');
|
|
83
91
|
}
|
|
84
92
|
/**
|
|
85
93
|
* Start watching the files named by the FileChanged hooks' matchers ("a.txt|b.txt").
|
|
@@ -134,7 +142,9 @@ function startFileChangedWatcher(workDir, sessionId, opts) {
|
|
|
134
142
|
if (fs.existsSync(path.join(workDir, n)))
|
|
135
143
|
known.add(n);
|
|
136
144
|
}
|
|
137
|
-
catch {
|
|
145
|
+
catch {
|
|
146
|
+
/* best-effort */
|
|
147
|
+
}
|
|
138
148
|
}
|
|
139
149
|
};
|
|
140
150
|
seedKnown(staticNames);
|
|
@@ -153,8 +163,10 @@ function startFileChangedWatcher(workDir, sessionId, opts) {
|
|
|
153
163
|
}
|
|
154
164
|
};
|
|
155
165
|
const seen = new Map();
|
|
156
|
-
const snapshot = (names) => {
|
|
157
|
-
|
|
166
|
+
const snapshot = (names) => {
|
|
167
|
+
for (const n of names)
|
|
168
|
+
seen.set(n, stamp(n));
|
|
169
|
+
};
|
|
158
170
|
snapshot(staticNames);
|
|
159
171
|
const pending = new Map();
|
|
160
172
|
let closed = false;
|
|
@@ -178,14 +190,17 @@ function startFileChangedWatcher(workDir, sessionId, opts) {
|
|
|
178
190
|
else
|
|
179
191
|
known.delete(name);
|
|
180
192
|
seen.set(name, stamp(name));
|
|
181
|
-
void fireChanged(workDir, sessionId, name, event, items, dynamicNames.has(name))
|
|
193
|
+
void fireChanged(workDir, sessionId, name, event, items, dynamicNames.has(name))
|
|
194
|
+
.then((o) => {
|
|
182
195
|
if (!o)
|
|
183
196
|
return;
|
|
184
197
|
if (o.systemMessage && opts?.onSystemMessage) {
|
|
185
198
|
try {
|
|
186
199
|
opts.onSystemMessage(o.systemMessage);
|
|
187
200
|
}
|
|
188
|
-
catch {
|
|
201
|
+
catch {
|
|
202
|
+
/* host callback */
|
|
203
|
+
}
|
|
189
204
|
}
|
|
190
205
|
if (o.watchPaths) {
|
|
191
206
|
// watchPaths REPLACES the dynamic list (Claude Code semantics); the static
|
|
@@ -199,7 +214,10 @@ function startFileChangedWatcher(workDir, sessionId, opts) {
|
|
|
199
214
|
seedKnown(dynamicNames);
|
|
200
215
|
snapshot(dynamicNames);
|
|
201
216
|
}
|
|
202
|
-
})
|
|
217
|
+
})
|
|
218
|
+
.catch(() => {
|
|
219
|
+
/* a hook must never break the session */
|
|
220
|
+
});
|
|
203
221
|
}, 250));
|
|
204
222
|
};
|
|
205
223
|
let watcher = null;
|
|
@@ -215,7 +233,9 @@ function startFileChangedWatcher(workDir, sessionId, opts) {
|
|
|
215
233
|
scheduleFire(name);
|
|
216
234
|
});
|
|
217
235
|
// A watcher that failed to attach must not hold a dead object.
|
|
218
|
-
watcher.on('error', () => {
|
|
236
|
+
watcher.on('error', () => {
|
|
237
|
+
/* best-effort; events simply stop */
|
|
238
|
+
});
|
|
219
239
|
}
|
|
220
240
|
catch {
|
|
221
241
|
return null;
|
|
@@ -244,7 +264,9 @@ function startFileChangedWatcher(workDir, sessionId, opts) {
|
|
|
244
264
|
try {
|
|
245
265
|
watcher?.close();
|
|
246
266
|
}
|
|
247
|
-
catch {
|
|
267
|
+
catch {
|
|
268
|
+
/* already closed */
|
|
269
|
+
}
|
|
248
270
|
watcher = null;
|
|
249
271
|
},
|
|
250
272
|
updateWatchPaths(paths) {
|
|
@@ -257,7 +279,9 @@ function startFileChangedWatcher(workDir, sessionId, opts) {
|
|
|
257
279
|
seedKnown(dynamicNames);
|
|
258
280
|
snapshot(dynamicNames);
|
|
259
281
|
},
|
|
260
|
-
watchedFiles() {
|
|
282
|
+
watchedFiles() {
|
|
283
|
+
return [...watched()].sort();
|
|
284
|
+
},
|
|
261
285
|
};
|
|
262
286
|
}
|
|
263
287
|
/**
|
package/dist/agent/loop.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import type { Message, ToolResult, AgentLoopOptions } from '../types';
|
|
2
2
|
import { type BackgroundAgentHub } from './backgroundAgents';
|
|
3
3
|
import { type AgentType } from './agentTypes';
|
|
4
|
+
import { type Skill } from './skills';
|
|
4
5
|
import { bashNeedsRepoLock } from '../permissions/bashClassify';
|
|
5
6
|
export { bashNeedsRepoLock };
|
|
6
7
|
export { loadHooks, parsePromptHookReply, classifyStopFailure, runLifecycleHooks, runPermissionRequestHooks, fireNotificationHooks, fireManualPostCompactHook, fireManualPreCompactHook, fireObserverHook, drainHookDeliveries, takeHookWakes, hasPendingHookWake, formatHookDeliveries, setHookWakeListener, setHookStatusListener, setHookMcpCaller, resetHookOnceState, setHookEventListener, hasHookEventListener, runElicitationHooks, runElicitationResultHooks, } from './hooks';
|
|
7
|
-
export type { HookDef, HookEntry, HooksConfig, ObserverEvent, HookDelivery, HookMcpCaller, HookLifecycleEvent, ElicitationAnswer, ElicitationAction } from './hooks';
|
|
8
|
+
export type { HookDef, HookEntry, HooksConfig, ObserverEvent, HookDelivery, HookMcpCaller, HookLifecycleEvent, ElicitationAnswer, ElicitationAction, } from './hooks';
|
|
8
9
|
export { contextWindowFor, compactionLimits, compactionThresholds, pruneReclaimFloor, estimateBodyBytes, WRITE_TOOL_NAMES, allowsTestOnlyWrite, VERIFY_CMD_RE, findSafeCutIndex, persistRuntimeContext, transcriptOf, createLedger, ledgerRecord, ledgerSummary, pruneOldToolResults, makeCachedSummarizer, estimateTokensRough, compactMessagesForResume, } from './compaction';
|
|
9
10
|
export type { ProgressLedger, CachedSummarizer } from './compaction';
|
|
10
|
-
export { emptyTurnBackoffMs, shouldRetryEmptyTurn, _emptyTurnRetry, errorRoundSignature, _stallLimits, AGENT_MEMORY_TOOL, AGENT_MEMORY_TOOL_SCHEMA, executeAgentMemoryWrite, stopReasonNotice, resolveMaxIterations } from './iterationPolicy';
|
|
11
|
+
export { emptyTurnBackoffMs, shouldRetryEmptyTurn, _emptyTurnRetry, errorRoundSignature, _stallLimits, AGENT_MEMORY_TOOL, AGENT_MEMORY_TOOL_SCHEMA, executeAgentMemoryWrite, stopReasonNotice, resolveMaxIterations, } from './iterationPolicy';
|
|
11
12
|
export type { AgentMemoryBinding, StopReason } from './iterationPolicy';
|
|
12
13
|
export { lockPathsFor } from './fileLocks';
|
|
13
|
-
export { resolveMaxConcurrentSubtasks, resolveMaxSubagentsPerSession, createLimiter, _resetSubTaskLimiter, resetSessionSubAgentBudget, _sessionSubAgentCount } from './subAgentBudget';
|
|
14
|
-
export { resolveMaxSubagentDepth, noSpawnReason, intersectAllowlists, canSpawnSubAgents, resolveSubtaskTimeoutMs, ToolNotAllowedError, extractSubTaskText, capSubTaskText, summariseSubTaskProgress, lastToolResults } from './subTaskSupport';
|
|
14
|
+
export { resolveMaxConcurrentSubtasks, resolveMaxSubagentsPerSession, createLimiter, _resetSubTaskLimiter, resetSessionSubAgentBudget, _sessionSubAgentCount, } from './subAgentBudget';
|
|
15
|
+
export { resolveMaxSubagentDepth, noSpawnReason, intersectAllowlists, canSpawnSubAgents, resolveSubtaskTimeoutMs, ToolNotAllowedError, extractSubTaskText, capSubTaskText, summariseSubTaskProgress, lastToolResults, } from './subTaskSupport';
|
|
15
16
|
import { type ForkContext } from './subTask';
|
|
16
17
|
export type { ForkContext };
|
|
17
18
|
/**
|
|
@@ -56,6 +57,23 @@ export declare function dispatchForkedSubAgent(conversation: Message[], prompt:
|
|
|
56
57
|
} | {
|
|
57
58
|
error: string;
|
|
58
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* Run a `context: fork` skill as an ISOLATED sub-agent (Claude Code parity):
|
|
62
|
+
* the expanded body is the child's prompt and the parent conversation is NOT
|
|
63
|
+
* copied in — a forked skill must stand on its own, which is the point of the
|
|
64
|
+
* fork (the invoking context stays clean and the child cannot lean on it).
|
|
65
|
+
*
|
|
66
|
+
* Background by default (CC 2.1.x), exactly like `task(run_in_background)`: the
|
|
67
|
+
* call returns as soon as the child starts and the report arrives later as a
|
|
68
|
+
* <task-notification>; `background: false` awaits the child and returns its
|
|
69
|
+
* report as the tool result. Hosts with no hub (headless `-p`/SDK callers)
|
|
70
|
+
* always await — the same place CC waits regardless of the frontmatter.
|
|
71
|
+
*
|
|
72
|
+
* The `subagent_type` rides the ordinary `task` dispatch, so `deny:
|
|
73
|
+
* ["task(<name>)"]` rules, the depth limit and the session sub-agent budget all
|
|
74
|
+
* apply unchanged (see runSubTask / dispatchSubAgent).
|
|
75
|
+
*/
|
|
76
|
+
export declare function runForkedSkill(skill: Skill, args: string, options: AgentLoopOptions, agentTypes: AgentType[]): Promise<ToolResult>;
|
|
59
77
|
export declare function runAgentLoop(initialMessages: Message[], options: AgentLoopOptions): Promise<Message[]>;
|
|
60
78
|
/**
|
|
61
79
|
* 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/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;AAK5F,OAAO,EAA8D,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
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;AAK5F,OAAO,EAA8D,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC1G,OAAO,EAOL,KAAK,KAAK,EACX,MAAM,UAAU,CAAC;AAQlB,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,CAAC;AA6B7B,OAAO,EACL,SAAS,EACT,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,yBAAyB,EACzB,qBAAqB,EACrB,yBAAyB,EACzB,wBAAwB,EACxB,gBAAgB,EAGhB,mBAAmB,E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