@nexrall/code-core 1.4.32 → 1.4.33
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/agentTypes.d.ts.map +1 -1
- package/dist/agent/agentTypes.js +11 -0
- package/dist/agent/loop.d.ts +15 -0
- package/dist/agent/loop.d.ts.map +1 -1
- package/dist/agent/loop.js +56 -3
- package/dist/api/client.d.ts +11 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +2 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentTypes.d.ts","sourceRoot":"","sources":["../../src/agent/agentTypes.ts"],"names":[],"mappings":"AAiCA,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,iDAAiD;IACjD,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,OAAO,CAAC;IAClC,qEAAqE;IACrE,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;IACpD;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B;;;;;;;;;;;;OAYG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,qDAAqD;AACrD,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AA4U5D;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;
|
|
1
|
+
{"version":3,"file":"ag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B,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,MAAM,CAY1D;AAQD,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAIjG"}
|
package/dist/agent/agentTypes.js
CHANGED
|
@@ -478,6 +478,17 @@ function loadDir(dir, source, into, warnings) {
|
|
|
478
478
|
message: `lists unknown tool name(s): ${unknown.join(', ')}. An allowlist only grants, so these silently do nothing and the agent cannot use them. Tool names are lower_snake_case (read_file, search_files, glob, bash).`,
|
|
479
479
|
});
|
|
480
480
|
}
|
|
481
|
+
// `task` is a VALID tool name (the main agent has it), which is exactly why it
|
|
482
|
+
// needs its own warning rather than falling under the typo check above: listing it
|
|
483
|
+
// looks like it works and grants nothing. Nesting is capped by MAX_TASK_DEPTH, so
|
|
484
|
+
// sub-agents are never sent the tool at all.
|
|
485
|
+
if ((tools ?? []).includes('task')) {
|
|
486
|
+
warnings.push({
|
|
487
|
+
file: full,
|
|
488
|
+
agent: name,
|
|
489
|
+
message: 'lists `task`, which cannot be granted: sub-agents are never sent that tool because they cannot spawn further sub-agents. Remove it — delegation stays with the main agent.',
|
|
490
|
+
});
|
|
491
|
+
}
|
|
481
492
|
const strayKeys = Object.keys(meta).filter((k) => !KNOWN_META_KEYS.has(k));
|
|
482
493
|
if (strayKeys.length) {
|
|
483
494
|
warnings.push({
|
package/dist/agent/loop.d.ts
CHANGED
|
@@ -116,6 +116,21 @@ export declare function resolveMaxConcurrentSubtasks(settingsRaw?: Record<string
|
|
|
116
116
|
export declare function createLimiter(max: number): <T>(fn: () => Promise<T>) => Promise<T>;
|
|
117
117
|
/** Test-only: forget the memoised limiter so a new limit can take effect. */
|
|
118
118
|
export declare function _resetSubTaskLimiter(): void;
|
|
119
|
+
export declare const NO_NESTED_SUBAGENTS_MSG: string;
|
|
120
|
+
/**
|
|
121
|
+
* Whether a run at `depth` may spawn sub-agents.
|
|
122
|
+
*
|
|
123
|
+
* The single source of truth for THREE things that must agree: the `<available_subagents>`
|
|
124
|
+
* catalogue in the system prompt, whether the backend is asked to send the `task` tool
|
|
125
|
+
* schema at all, and which prompt block teaches delegation. They used to be decided
|
|
126
|
+
* independently, and the result was a sub-agent that got the tool plus instructions to use
|
|
127
|
+
* it but no catalogue — then a permission-gate refusal telling it not to ask for approval.
|
|
128
|
+
*
|
|
129
|
+
* `depth < MAX_TASK_DEPTH` mirrors runSubTask's own guard (which refuses at
|
|
130
|
+
* `depth >= MAX_TASK_DEPTH`), because the children this run would create land at
|
|
131
|
+
* `depth + 1`. Pure and exported so raising MAX_TASK_DEPTH is one edit, not four.
|
|
132
|
+
*/
|
|
133
|
+
export declare function canSpawnSubAgents(depth: number, allowedTools?: Set<string>): boolean;
|
|
119
134
|
/**
|
|
120
135
|
* How long a sub-agent may make NO progress before it is stopped.
|
|
121
136
|
*
|
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,EAChB,UAAU,EACX,MAAM,UAAU,CAAC;AAIlB,OAAO,EAAkE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAMrH,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAiK7B;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,GAC9C,MAAM,CAKR;AAED,+CAA+C;AAC/C,eAAO,MAAM,YAAY;;;CAAsC,CAAC;AAEhE;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AAEtD;;;;;GAKG;A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,MAAM,CAE/D;AAED;;;;;;;;;GASG;AACH,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,OAAO,EAAE,EACnB,IAAI,EAAE;IACJ,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,OAAO,CAAC;IAClC,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,CAqElB;AAID,wBAAsB,YAAY,CAChC,eAAe,EAAE,OAAO,EAAE,EAC1B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,OAAO,EAAE,CAAC,CAk9BpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,CAqCtE"}
|
package/dist/agent/loop.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.VERIFY_CMD_RE = exports.WRITE_TOOL_NAMES = exports.ToolNotAllowedError = exports.AGENT_MEMORY_TOOL_SCHEMA = exports.AGENT_MEMORY_TOOL = exports._stallLimits = exports.bashNeedsRepoLock = void 0;
|
|
36
|
+
exports.VERIFY_CMD_RE = exports.WRITE_TOOL_NAMES = exports.ToolNotAllowedError = exports.NO_NESTED_SUBAGENTS_MSG = exports.AGENT_MEMORY_TOOL_SCHEMA = exports.AGENT_MEMORY_TOOL = exports._stallLimits = exports.bashNeedsRepoLock = void 0;
|
|
37
37
|
exports.errorRoundSignature = errorRoundSignature;
|
|
38
38
|
exports.executeAgentMemoryWrite = executeAgentMemoryWrite;
|
|
39
39
|
exports.stopReasonNotice = stopReasonNotice;
|
|
@@ -42,6 +42,7 @@ exports.lockPathsFor = lockPathsFor;
|
|
|
42
42
|
exports.resolveMaxConcurrentSubtasks = resolveMaxConcurrentSubtasks;
|
|
43
43
|
exports.createLimiter = createLimiter;
|
|
44
44
|
exports._resetSubTaskLimiter = _resetSubTaskLimiter;
|
|
45
|
+
exports.canSpawnSubAgents = canSpawnSubAgents;
|
|
45
46
|
exports.resolveSubtaskTimeoutMs = resolveSubtaskTimeoutMs;
|
|
46
47
|
exports.extractSubTaskText = extractSubTaskText;
|
|
47
48
|
exports.capSubTaskText = capSubTaskText;
|
|
@@ -629,6 +630,37 @@ function humanDescription(name, input) {
|
|
|
629
630
|
// sub-agents", and quietly making the worst-case fan-out quadratic. The value and
|
|
630
631
|
// the documented behaviour now agree.
|
|
631
632
|
const MAX_TASK_DEPTH = 1;
|
|
633
|
+
// The ONE explanation for "you cannot spawn a sub-agent", shared by both places that
|
|
634
|
+
// can refuse it: the permission gate (an allowlist without `task`) and the depth guard
|
|
635
|
+
// inside runSubTask (a general-purpose sub-task, whose `allowed` set is null, reaches
|
|
636
|
+
// that instead). The same impossibility used to produce two different messages, and the
|
|
637
|
+
// allowlist one framed it as "a restriction of the agent definition" that "needs a
|
|
638
|
+
// different agent" — sending the model off to look for an agent that can nest, when none
|
|
639
|
+
// can. Nesting is structural, so say that once and say it the same way.
|
|
640
|
+
exports.NO_NESTED_SUBAGENTS_MSG = 'Sub-agents cannot spawn further sub-agents — this is a structural limit, not a ' +
|
|
641
|
+
'permission, so no other agent type and no approval can lift it. Do this work directly ' +
|
|
642
|
+
'with the tools you have, or report back so the main agent can delegate it.';
|
|
643
|
+
/**
|
|
644
|
+
* Whether a run at `depth` may spawn sub-agents.
|
|
645
|
+
*
|
|
646
|
+
* The single source of truth for THREE things that must agree: the `<available_subagents>`
|
|
647
|
+
* catalogue in the system prompt, whether the backend is asked to send the `task` tool
|
|
648
|
+
* schema at all, and which prompt block teaches delegation. They used to be decided
|
|
649
|
+
* independently, and the result was a sub-agent that got the tool plus instructions to use
|
|
650
|
+
* it but no catalogue — then a permission-gate refusal telling it not to ask for approval.
|
|
651
|
+
*
|
|
652
|
+
* `depth < MAX_TASK_DEPTH` mirrors runSubTask's own guard (which refuses at
|
|
653
|
+
* `depth >= MAX_TASK_DEPTH`), because the children this run would create land at
|
|
654
|
+
* `depth + 1`. Pure and exported so raising MAX_TASK_DEPTH is one edit, not four.
|
|
655
|
+
*/
|
|
656
|
+
function canSpawnSubAgents(depth, allowedTools) {
|
|
657
|
+
if (depth >= MAX_TASK_DEPTH)
|
|
658
|
+
return false;
|
|
659
|
+
// An allowlist that omits `task` is the other reason a run cannot delegate. No
|
|
660
|
+
// allowlist at all (the main agent, or a general-purpose sub-task) means no
|
|
661
|
+
// restriction from this clause — the depth check above still applies.
|
|
662
|
+
return allowedTools ? allowedTools.has('task') : true;
|
|
663
|
+
}
|
|
632
664
|
let _subTaskCounter = 0; // unique per-process id → per-sub-agent todo scope
|
|
633
665
|
// A sub-agent that stalls (hung tool, model provider stuck, infinite tool-call
|
|
634
666
|
// loop bypassing the iteration budget somehow) used to have NO ceiling of its
|
|
@@ -854,7 +886,7 @@ async function runSubTask(input, options, agentTypes) {
|
|
|
854
886
|
return { error: 'task tool requires a non-empty prompt' };
|
|
855
887
|
const depth = options._depth ?? 0;
|
|
856
888
|
if (depth >= MAX_TASK_DEPTH) {
|
|
857
|
-
return { error:
|
|
889
|
+
return { error: exports.NO_NESTED_SUBAGENTS_MSG };
|
|
858
890
|
}
|
|
859
891
|
// Resolve an optional custom agent type (subagent_type).
|
|
860
892
|
//
|
|
@@ -973,6 +1005,21 @@ async function runSubTask(input, options, agentTypes) {
|
|
|
973
1005
|
'`memory:` scope (project, user or local). Report anything worth remembering in your final ' +
|
|
974
1006
|
'message instead — the main agent decides what to persist.');
|
|
975
1007
|
}
|
|
1008
|
+
// `task` is not an allowlist matter — it is the depth ceiling, so it is refused here
|
|
1009
|
+
// unconditionally rather than via `allowed`. gatedPermission is only ever built inside
|
|
1010
|
+
// runSubTask, so every run it governs is already at depth >= 1 and can never spawn.
|
|
1011
|
+
//
|
|
1012
|
+
// Checking the allowlist instead left a gap: a hand-written `tools: read_file, task`
|
|
1013
|
+
// made the name PRESENT, so neither this branch nor the allowlist branch below fired,
|
|
1014
|
+
// and the call was permitted here only to be refused one frame deeper by runSubTask's
|
|
1015
|
+
// depth guard. Same outcome, but the invariant stopped being local. Refusing on the
|
|
1016
|
+
// tool name keeps it local and cannot be re-opened by an agent file.
|
|
1017
|
+
//
|
|
1018
|
+
// The generic allowlist text is also wrong for this case: it says "report back that
|
|
1019
|
+
// the task needs a different agent", pointing at an escape hatch that cannot exist.
|
|
1020
|
+
if (req.tool === 'task') {
|
|
1021
|
+
throw new ToolNotAllowedError(exports.NO_NESTED_SUBAGENTS_MSG);
|
|
1022
|
+
}
|
|
976
1023
|
if (allowed && !allowed.has(req.tool)) {
|
|
977
1024
|
throw new ToolNotAllowedError(`The "${agent.name}" sub-agent is not allowed to use \`${req.tool}\` — it is not in that agent's ` +
|
|
978
1025
|
'tool allowlist. This is a restriction of the agent definition, NOT a user decision: do not ask ' +
|
|
@@ -1901,7 +1948,10 @@ async function runAgentLoop(initialMessages, options) {
|
|
|
1901
1948
|
// error path would name it again. Enforcement still happens at dispatch
|
|
1902
1949
|
// (runSubTask) — this is the cosmetic half; that is the load-bearing half.
|
|
1903
1950
|
const agentTypes = (0, agentTypes_1.loadAgentTypes)(options.workDir).filter((t) => (0, rules_1.evaluatePermission)(settings.permissions, 'task', { subagent_type: t.name }, options.workDir) !== 'deny');
|
|
1904
|
-
|
|
1951
|
+
// Can THIS run delegate at all? Previously only the catalogue was gated (`depth === 0`)
|
|
1952
|
+
// while the tool schema and its instructions went to every run — see canSpawnSubAgents.
|
|
1953
|
+
const maySpawn = canSpawnSubAgents(depth, options._allowedTools);
|
|
1954
|
+
const agentsCatalogue = maySpawn ? (0, agentTypes_1.summariseAgents)(agentTypes) : '';
|
|
1905
1955
|
// Skills catalogue — unlike agentsCatalogue, available at every depth: a skill is
|
|
1906
1956
|
// just a reusable prompt template (via use_skill), not another spawn point, so
|
|
1907
1957
|
// sub-agents benefit from the same playbooks without the recursion concerns that
|
|
@@ -2224,6 +2274,9 @@ async function runAgentLoop(initialMessages, options) {
|
|
|
2224
2274
|
? options._allowedTools.has('memory_write')
|
|
2225
2275
|
: true, // no allowlist = main agent = may write
|
|
2226
2276
|
hasOwnAgentStore: !!options._agentMemory,
|
|
2277
|
+
// Withholds the `task` schema and its instructions when this run cannot
|
|
2278
|
+
// delegate — see canSpawnSubAgents.
|
|
2279
|
+
canSpawnSubAgents: maySpawn,
|
|
2227
2280
|
agents: agentsCatalogue || undefined,
|
|
2228
2281
|
skills: skillsCatalogue || undefined,
|
|
2229
2282
|
// Only allow a post-render restart when the caller actually implements the
|
package/dist/api/client.d.ts
CHANGED
|
@@ -55,6 +55,17 @@ export interface StreamChatOptions {
|
|
|
55
55
|
canWriteSharedMemory?: boolean;
|
|
56
56
|
/** Whether this run is a sub-agent with its own `memory:` store (agent_memory_write). */
|
|
57
57
|
hasOwnAgentStore?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Whether THIS run may spawn sub-agents, i.e. whether the backend should send the
|
|
60
|
+
* `task` tool schema and the prompt block that teaches it.
|
|
61
|
+
*
|
|
62
|
+
* Same rule as canWriteSharedMemory, applied to a worse case: `task` was in the
|
|
63
|
+
* backend's static catalogue, so every sub-agent SAW the tool and was told to use it,
|
|
64
|
+
* then got refused by its own allowlist at the permission gate. Withholding the schema
|
|
65
|
+
* is the fix — a tool the model cannot see is one it cannot try. Undefined means
|
|
66
|
+
* "main agent" (may spawn).
|
|
67
|
+
*/
|
|
68
|
+
canSpawnSubAgents?: boolean;
|
|
58
69
|
/**
|
|
59
70
|
* Opt in to restarting a turn that died AFTER partial output was rendered.
|
|
60
71
|
*
|
package/dist/api/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../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AAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CA+B1E;AAID,wBAAsB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CA0BhF"}
|
package/dist/api/client.js
CHANGED
|
@@ -243,7 +243,7 @@ function sleep(ms) {
|
|
|
243
243
|
* the nested product (36) exists to bound pathological cases, not to be reached. */
|
|
244
244
|
const MAX_TOTAL_ATTEMPTS = (MAX_RETRIES + 1) * (MAX_RETRIES + 1);
|
|
245
245
|
async function streamChat(messages, options, onEvent) {
|
|
246
|
-
const { model, env, editorContext, nexrallMd, mode, effort, clientType, abortSignal, extraTools, agents, skills, allowRestartAfterRender, canWriteSharedMemory, hasOwnAgentStore } = options;
|
|
246
|
+
const { model, env, editorContext, nexrallMd, mode, effort, clientType, abortSignal, extraTools, agents, skills, allowRestartAfterRender, canWriteSharedMemory, hasOwnAgentStore, canSpawnSubAgents } = options;
|
|
247
247
|
// IDEMPOTENCY KEY for this logical turn, generated ONCE and reused by every retry
|
|
248
248
|
// below (that reuse is the entire point — a fresh id per attempt would be useless).
|
|
249
249
|
//
|
|
@@ -331,7 +331,7 @@ async function streamChat(messages, options, onEvent) {
|
|
|
331
331
|
{
|
|
332
332
|
method: 'POST',
|
|
333
333
|
headers: authHeaders(),
|
|
334
|
-
body: JSON.stringify({ messages, model, env, editorContext, nexrallMd, mode, effort, clientType, extraTools, agents, skills, turnId, canWriteSharedMemory, hasOwnAgentStore }),
|
|
334
|
+
body: JSON.stringify({ messages, model, env, editorContext, nexrallMd, mode, effort, clientType, extraTools, agents, skills, turnId, canWriteSharedMemory, hasOwnAgentStore, canSpawnSubAgents }),
|
|
335
335
|
signal: controller.signal,
|
|
336
336
|
},
|
|
337
337
|
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexrall/code-core",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.33",
|
|
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)",
|