@corenel/harness 0.3.2 → 0.4.0
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/acp/index.js +2 -2
- package/dist/api/backend.js +1 -1
- package/dist/api/fileMirrorSource.js +2 -2
- package/dist/api/mirror.js +1 -1
- package/dist/compression.d.ts +15 -1
- package/dist/compression.d.ts.map +1 -1
- package/dist/compression.js +32 -1
- package/dist/compression.js.map +1 -1
- package/dist/core/loop.d.ts +10 -0
- package/dist/core/loop.d.ts.map +1 -1
- package/dist/core/loop.js +137 -14
- package/dist/core/loop.js.map +1 -1
- package/dist/core/spawn.d.ts +54 -0
- package/dist/core/spawn.d.ts.map +1 -0
- package/dist/core/spawn.js +58 -0
- package/dist/core/spawn.js.map +1 -0
- package/dist/dag/executeNode.js +2 -2
- package/dist/fileSchema.js +1 -1
- package/dist/guardrail/guardrail.js +1 -1
- package/dist/guardrail/index.js +7 -7
- package/dist/guardrail/permission-service.js +1 -1
- package/dist/guardrail/serialize.js +1 -1
- package/dist/guardrail/store.js +2 -2
- package/dist/prompts/config.js +2 -2
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +9 -6
- package/dist/prompts/index.js.map +1 -1
- package/dist/prompts/library/defaults.generated.js +1 -1
- package/dist/prompts/library/defaults.generated.js.map +1 -1
- package/dist/prompts/library/index.js +1 -1
- package/dist/providers/contextWindow.d.ts +19 -0
- package/dist/providers/contextWindow.d.ts.map +1 -0
- package/dist/providers/contextWindow.js +68 -0
- package/dist/providers/contextWindow.js.map +1 -0
- package/dist/providers/gateway.js +1 -1
- package/dist/sessions/apiLeaseStore.js +1 -1
- package/dist/sessions/blobGc.d.ts +62 -0
- package/dist/sessions/blobGc.d.ts.map +1 -0
- package/dist/sessions/blobGc.js +154 -0
- package/dist/sessions/blobGc.js.map +1 -0
- package/dist/sessions/fileRecallStore.js +1 -1
- package/dist/sessions/fileSessionStore.js +1 -1
- package/dist/sidecar/host.d.ts +18 -2
- package/dist/sidecar/host.d.ts.map +1 -1
- package/dist/sidecar/host.js +38 -3
- package/dist/sidecar/host.js.map +1 -1
- package/dist/sidecar/server.d.ts.map +1 -1
- package/dist/sidecar/server.js +12 -0
- package/dist/sidecar/server.js.map +1 -1
- package/dist/sidecar/wsChannel.d.ts +4 -0
- package/dist/sidecar/wsChannel.d.ts.map +1 -0
- package/dist/sidecar/wsChannel.js +62 -0
- package/dist/sidecar/wsChannel.js.map +1 -0
- package/dist/skills.js +2 -2
- package/dist/tools/builtins.js +6 -6
- package/dist/tools/callAgent.d.ts +16 -0
- package/dist/tools/callAgent.d.ts.map +1 -0
- package/dist/tools/callAgent.js +53 -0
- package/dist/tools/callAgent.js.map +1 -0
- package/dist/tools/files.d.ts +10 -0
- package/dist/tools/files.d.ts.map +1 -1
- package/dist/tools/files.js +159 -8
- package/dist/tools/files.js.map +1 -1
- package/dist/tools/http.js +1 -1
- package/dist/tools/namespaces.d.ts.map +1 -1
- package/dist/tools/namespaces.js +16 -2
- package/dist/tools/namespaces.js.map +1 -1
- package/dist/tools/procs.d.ts +18 -0
- package/dist/tools/procs.d.ts.map +1 -0
- package/dist/tools/procs.js +281 -0
- package/dist/tools/procs.js.map +1 -0
- package/package.json +14 -7
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
function str(v) { return typeof v === 'string' ? v.trim() : ''; }
|
|
2
|
+
export function makeCallAgentTool(opts) {
|
|
3
|
+
const allowed = opts.canCall.filter(Boolean);
|
|
4
|
+
const list = allowed.join(', ') || '(none)';
|
|
5
|
+
return {
|
|
6
|
+
name: 'call_agent',
|
|
7
|
+
mutates: true,
|
|
8
|
+
noOffload: true,
|
|
9
|
+
description: 'Delegate a self-contained task to one of the named agents you may call, and get its result. ' +
|
|
10
|
+
`You may call: ${list}. The callee runs with its own role and persona, using a standard tool ` +
|
|
11
|
+
'surface within your governed envelope, and returns its final answer.',
|
|
12
|
+
parameters: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
agent: { type: 'string', description: `The agent to call. One of: ${list}.` },
|
|
16
|
+
message: { type: 'string', description: 'The self-contained task for the callee.' },
|
|
17
|
+
},
|
|
18
|
+
required: ['agent', 'message'],
|
|
19
|
+
},
|
|
20
|
+
async run(args, ctx) {
|
|
21
|
+
const agent = str(args.agent);
|
|
22
|
+
const message = str(args.message);
|
|
23
|
+
if (!agent)
|
|
24
|
+
return 'Provide the `agent` to call.';
|
|
25
|
+
if (!allowed.includes(agent))
|
|
26
|
+
return `You may not call "${agent}". Allowed: ${list}.`;
|
|
27
|
+
if (!message)
|
|
28
|
+
return 'Provide a non-empty `message` (the task for the callee).';
|
|
29
|
+
if (!ctx.spawn)
|
|
30
|
+
return 'Cannot delegate to another agent here (delegation depth limit reached).';
|
|
31
|
+
const system = await opts.resolveSystem(agent);
|
|
32
|
+
if (system == null)
|
|
33
|
+
return `Agent "${agent}" was not found.`;
|
|
34
|
+
const req = {
|
|
35
|
+
task: message,
|
|
36
|
+
system,
|
|
37
|
+
// The callee's governed surface, minus call_agent. The caller supplies
|
|
38
|
+
// names from the already deny-filtered registry, so spawn_agent /
|
|
39
|
+
// spawn_agents are gone too — the callee has no delegation tool at all,
|
|
40
|
+
// making delegation genuinely one level, not just "no call_agent".
|
|
41
|
+
tools: opts.calleeTools().filter((n) => n !== 'call_agent'),
|
|
42
|
+
};
|
|
43
|
+
try {
|
|
44
|
+
const r = await ctx.spawn(req);
|
|
45
|
+
return `${r.text}\n\n[${agent}: ${r.turns} turn(s), ${r.stopReason}]`;
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
return `call_agent(${agent}) failed. Error: ${e instanceof Error ? e.message : String(e)}`;
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=callAgent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callAgent.js","sourceRoot":"","sources":["../../tools/callAgent.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K;gBAAE,OAAO,yEAAyE,CAAC;YACjG,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAC/C,IAAI,MAAM,IAAI,IAAI;gBAAE,OAAO,UAAU,KAAK,kBAAkB,CAAC;YAC7D,MAAM,GAAG,GAAoB;gBAC3B,IAAI,EAAE,OAAO;gBACb,MAAM;gBACN,uEAAuE;gBACvE,kEAAkE;gBAClE,wEAAwE;gBACxE,mEAAmE;gBACnE,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,YAAY,CAAC;aAC5D,CAAC;YACF,IAAI,CAAC;gBACH,MAAM,CAAC,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAC/B,OAAO,GAAG,CAAC,CAAC,IAAI,QAAQ,KAAK,KAAK,CAAC,CAAC,KAAK,aAAa,CAAC,CAAC,UAAU,GAAG,CAAC;YACxE,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,cAAc,KAAK,oBAAoB,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7F,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/tools/files.d.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import type { AgentTool } from '@corenel/protocol';
|
|
2
|
+
/** Cap on entries a single `list_files` call returns. A stranger typing `ls` in
|
|
3
|
+
* a large repo (no `dir`) got the WHOLE tree back — 4,369 entries in one real
|
|
4
|
+
* run, an 87K-token prompt on the very next model call. A few hundred entries
|
|
5
|
+
* is plenty to orient in a repo (see any file's immediate siblings, spot the
|
|
6
|
+
* top-level layout) without paying for the whole thing; 300 is that number —
|
|
7
|
+
* generous enough that an ordinary project's top few levels fit whole, small
|
|
8
|
+
* enough that a monorepo's `node_modules`-scale sprawl can't leak through
|
|
9
|
+
* uncapped. Every host (browser, node CLI, sidecar) shares this file, so the
|
|
10
|
+
* cap applies uniformly rather than per-host. */
|
|
11
|
+
export declare const LIST_FILES_MAX_ENTRIES = 300;
|
|
2
12
|
export declare const listFilesTool: AgentTool;
|
|
3
13
|
export declare const readFileTool: AgentTool;
|
|
4
14
|
export declare const statFileTool: AgentTool;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../tools/files.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../tools/files.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,mBAAmB,CAAC;AA8DhE;;;;;;;;iDAQiD;AACjD,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAuG1C,eAAO,MAAM,aAAa,EAAE,SA+B3B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,SAY1B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,SAc1B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,SAa7B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,SAqB3B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,SAmB5B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,SAgB5B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,SAqB5B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,SAAS,EAShC,CAAC"}
|
package/dist/tools/files.js
CHANGED
|
@@ -15,26 +15,177 @@ function ensureWritable(path) {
|
|
|
15
15
|
throw new Error(`${PROMPD_INSTALL_DIR}/ install dirs are read-only (managed by package install). Refusing to modify "${path}". Install or remove packages instead of editing them directly.`);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
function describe(n) {
|
|
19
|
+
return `${n.kind === 'directory' ? '[dir] ' : ''}${n.path}${n.kind === 'file' && n.size != null ? ` (${n.size}b)` : ''}`;
|
|
20
|
+
}
|
|
21
|
+
/** Every node in the ALREADY-MATERIALIZED tree, in BFS (level) order: every
|
|
22
|
+
* depth-0 node before ANY depth-1 node, every depth-1 before any depth-2, and
|
|
23
|
+
* so on. Used only to decide WHICH nodes survive the cap (see
|
|
24
|
+
* `selectByBreadthFirstCap` below) — never to render, because that reordering
|
|
25
|
+
* has its own cost (see the doc comment there). Also doubles as the total
|
|
26
|
+
* node count.
|
|
27
|
+
*
|
|
28
|
+
* IMPORTANT — what `maxDepth` does and does not save: `roots` here is the
|
|
29
|
+
* full result of `FileService.list()`, which has ALREADY recursed the whole
|
|
30
|
+
* subtree by the time this function ever sees it — `FileService.list(dir?:
|
|
31
|
+
* string)` (`packages/protocol/files.ts`) has no depth parameter, and none of
|
|
32
|
+
* its implementations (`packages/tools-node/fileService.ts`,
|
|
33
|
+
* `src/services/files/DirectoryHandleFileService.ts`,
|
|
34
|
+
* `src/services/files/SidecarFileService.ts`) stop early. So `maxDepth`
|
|
35
|
+
* bounds what is COLLECTED FROM that in-memory listing into `out` (and
|
|
36
|
+
* therefore what is returned to the model) — it does NOT reduce the
|
|
37
|
+
* `fs.readdir`/`fs.stat`/IPC cost of producing `roots` in the first place.
|
|
38
|
+
* That deeper fix belongs in the `FileService.list` port and its
|
|
39
|
+
* implementations, not here. Omit `maxDepth` for the unlimited,
|
|
40
|
+
* today's-behavior case. */
|
|
41
|
+
function bfsNodes(roots, maxDepth = Infinity) {
|
|
42
|
+
const out = [];
|
|
43
|
+
let level = roots;
|
|
44
|
+
let depth = 1;
|
|
45
|
+
while (level.length) {
|
|
46
|
+
const next = [];
|
|
47
|
+
for (const n of level) {
|
|
48
|
+
out.push(n);
|
|
49
|
+
if (n.kind === 'directory' && n.children?.length && depth < maxDepth)
|
|
50
|
+
next.push(...n.children);
|
|
51
|
+
}
|
|
52
|
+
level = next;
|
|
53
|
+
depth++;
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
/** Cap on entries a single `list_files` call returns. A stranger typing `ls` in
|
|
58
|
+
* a large repo (no `dir`) got the WHOLE tree back — 4,369 entries in one real
|
|
59
|
+
* run, an 87K-token prompt on the very next model call. A few hundred entries
|
|
60
|
+
* is plenty to orient in a repo (see any file's immediate siblings, spot the
|
|
61
|
+
* top-level layout) without paying for the whole thing; 300 is that number —
|
|
62
|
+
* generous enough that an ordinary project's top few levels fit whole, small
|
|
63
|
+
* enough that a monorepo's `node_modules`-scale sprawl can't leak through
|
|
64
|
+
* uncapped. Every host (browser, node CLI, sidecar) shares this file, so the
|
|
65
|
+
* cap applies uniformly rather than per-host. */
|
|
66
|
+
export const LIST_FILES_MAX_ENTRIES = 300;
|
|
67
|
+
/** WHICH nodes survive: the first `LIST_FILES_MAX_ENTRIES` in BFS order —
|
|
68
|
+
* see `bfsNodes`'s comment for why breadth-first is what makes a global count
|
|
69
|
+
* cap keep the top of the tree instead of one arbitrary deep branch. Returns
|
|
70
|
+
* the surviving set plus the true total (for the marker). */
|
|
71
|
+
function selectByBreadthFirstCap(roots, maxDepth) {
|
|
72
|
+
const bfs = bfsNodes(roots, maxDepth);
|
|
73
|
+
return { keep: new Set(bfs.slice(0, LIST_FILES_MAX_ENTRIES)), total: bfs.length };
|
|
74
|
+
}
|
|
75
|
+
/** Render the surviving nodes in ORIGINAL TREE ORDER (depth-first pre-order —
|
|
76
|
+
* the natural, readable shape: a directory immediately followed by its own
|
|
77
|
+
* contents), not the BFS order used to select them.
|
|
78
|
+
*
|
|
79
|
+
* BFS decides WHICH 300 entries survive; it must not also decide how they are
|
|
80
|
+
* DISPLAYED. In a small repo that was never truncated, every node survives
|
|
81
|
+
* (`keep` has everything), and rendering in BFS order would still separate
|
|
82
|
+
* every directory from its own contents — level by level instead of subtree
|
|
83
|
+
* by subtree — which is a strictly worse read for the overwhelmingly common
|
|
84
|
+
* case (no truncation at all) to fix a problem that only exists when
|
|
85
|
+
* truncation happens. So: select breadth-first, render depth-first, over the
|
|
86
|
+
* SAME `keep` set — a directory's children only appear here if the directory
|
|
87
|
+
* itself survived (BFS always keeps a parent before any of its children, so
|
|
88
|
+
* that's automatic, not a race), and only the children that themselves
|
|
89
|
+
* survived. */
|
|
90
|
+
function describeInTreeOrder(roots, keep, maxDepth = Infinity, depth = 1, out = []) {
|
|
91
|
+
for (const n of roots) {
|
|
92
|
+
if (!keep.has(n))
|
|
93
|
+
continue;
|
|
94
|
+
out.push(describe(n));
|
|
95
|
+
if (n.kind === 'directory' && n.children?.length && depth < maxDepth) {
|
|
96
|
+
describeInTreeOrder(n.children, keep, maxDepth, depth + 1, out);
|
|
97
|
+
}
|
|
23
98
|
}
|
|
24
99
|
return out;
|
|
25
100
|
}
|
|
101
|
+
/** The unmistakable trailing marker — never let the model believe a
|
|
102
|
+
* truncated listing is the whole tree.
|
|
103
|
+
*
|
|
104
|
+
* `total` (and therefore `omitted`) is always the count of entries within the
|
|
105
|
+
* scope this call actually collected FROM — i.e. `bfsNodes`'s output length,
|
|
106
|
+
* which a depth limit already shrank before this is ever called (see
|
|
107
|
+
* `bfsNodes`'s doc comment — the underlying `FileService.list` still walked
|
|
108
|
+
* the full subtree; `maxDepth` only bounds what was collected from that
|
|
109
|
+
* result). So when `depth` is given, `total` here is the count within that
|
|
110
|
+
* depth, not the size of the whole tree, and the two truncation reasons — a
|
|
111
|
+
* depth limit excluding lower levels, vs. the entry cap additionally cutting
|
|
112
|
+
* within the collected scope — are DIFFERENT signals the model needs to tell
|
|
113
|
+
* apart to decide what to do next.
|
|
114
|
+
*
|
|
115
|
+
* Written as plain consecutive sentences, not a parenthetical nested inside
|
|
116
|
+
* the count — a model parses "340 total (not the whole tree (because...))"
|
|
117
|
+
* less reliably than separate sentences saying the same things in order. And
|
|
118
|
+
* when `depth` is in force, the right remedy is a LARGER `depth` (to see
|
|
119
|
+
* deeper), never "limit how many levels" (it's already limited) — telling the
|
|
120
|
+
* model to narrow further when it already narrowed is the wrong direction. */
|
|
121
|
+
function truncationMarker(total, maxDepth) {
|
|
122
|
+
const omitted = total - LIST_FILES_MAX_ENTRIES;
|
|
123
|
+
const omittedEntries = `${omitted} more entr${omitted === 1 ? 'y' : 'ies'} omitted`;
|
|
124
|
+
if (maxDepth != null && Number.isFinite(maxDepth)) {
|
|
125
|
+
return `… truncated: ${omittedEntries}. ${total} entries were collected within depth ${maxDepth}; ` +
|
|
126
|
+
'deeper levels were not counted, so this is not the size of the whole tree. ' +
|
|
127
|
+
'Pass `dir` to narrow by subdirectory, or a larger `depth` to go deeper.';
|
|
128
|
+
}
|
|
129
|
+
return `… truncated: ${omittedEntries} (${total} total). ` +
|
|
130
|
+
'Pass `dir` to list a specific subdirectory (narrower breadth), or `depth` to limit how many levels deep the listing goes (narrower depth), instead of the whole tree.';
|
|
131
|
+
}
|
|
132
|
+
/** Normalizes model-supplied `depth` into a safe, meaningful bound, or
|
|
133
|
+
* `undefined` for "unlimited" (today's behavior — full recursive listing,
|
|
134
|
+
* still subject to the entry cap). Never throws: `depth` is model output and
|
|
135
|
+
* may be anything.
|
|
136
|
+
*
|
|
137
|
+
* Rules:
|
|
138
|
+
* - missing / null / not coercible to a finite number -> `undefined`
|
|
139
|
+
* (unlimited) — the safest fallback, since it reproduces the behavior
|
|
140
|
+
* every existing caller already relies on.
|
|
141
|
+
* - a numeric string ("2") is accepted the same as a number.
|
|
142
|
+
* - non-finite (`NaN`, `Infinity`) -> `undefined` (unlimited).
|
|
143
|
+
* - fractional values are floored (2.7 -> 2): depth is a count of whole
|
|
144
|
+
* levels, there is no such thing as "2.7 levels deep".
|
|
145
|
+
* - anything below 1 (0, negative) is clamped up to 1 — the shallowest
|
|
146
|
+
* depth that still means something ("immediate children only"), rather
|
|
147
|
+
* than being rejected or treated as unlimited.
|
|
148
|
+
* - very large values (1e9) are accepted as-is; they behave as
|
|
149
|
+
* "effectively unlimited" and are still bounded by `LIST_FILES_MAX_ENTRIES`
|
|
150
|
+
* like the unlimited case, so there's no separate ceiling to enforce. */
|
|
151
|
+
function normalizeDepth(args) {
|
|
152
|
+
const v = args['depth'];
|
|
153
|
+
if (v == null)
|
|
154
|
+
return undefined;
|
|
155
|
+
const n = typeof v === 'number' ? v : typeof v === 'string' ? Number(v) : NaN;
|
|
156
|
+
if (!Number.isFinite(n))
|
|
157
|
+
return undefined;
|
|
158
|
+
const floored = Math.floor(n);
|
|
159
|
+
return floored < 1 ? 1 : floored;
|
|
160
|
+
}
|
|
26
161
|
export const listFilesTool = {
|
|
27
162
|
name: 'list_files',
|
|
28
163
|
description: 'List files and directories in the workspace (the open folder or the virtual workspace). ' +
|
|
29
|
-
'
|
|
164
|
+
'Start shallow and drill in: pass `depth` to limit how many levels deep the listing goes ' +
|
|
165
|
+
'(vertical narrowing — `depth: 1` returns just the immediate children of the target, a quick ' +
|
|
166
|
+
'orientation call) and/or `dir` to list a specific subdirectory instead of the whole tree ' +
|
|
167
|
+
'(horizontal narrowing). Omit `depth` for a full recursive listing. Returns paths relative to ' +
|
|
168
|
+
'the workspace root.',
|
|
30
169
|
parameters: {
|
|
31
170
|
type: 'object',
|
|
32
|
-
properties: {
|
|
171
|
+
properties: {
|
|
172
|
+
dir: { type: 'string', description: 'Subdirectory to list (optional; omit for the root).' },
|
|
173
|
+
depth: {
|
|
174
|
+
type: 'number',
|
|
175
|
+
description: 'How many levels deep to list (optional; omit for the full recursive tree). ' +
|
|
176
|
+
'1 = immediate children of `dir` (or the root) only, 2 = two levels, and so on. ' +
|
|
177
|
+
'Values below 1 (0, negative) are treated as 1, not rejected.',
|
|
178
|
+
},
|
|
179
|
+
},
|
|
33
180
|
},
|
|
34
181
|
async run(args, ctx) {
|
|
35
182
|
const files = requireFiles(ctx);
|
|
36
183
|
const nodes = await files.list(str(args, 'dir') || undefined);
|
|
37
|
-
const
|
|
184
|
+
const maxDepth = normalizeDepth(args);
|
|
185
|
+
const { keep, total } = selectByBreadthFirstCap(nodes, maxDepth);
|
|
186
|
+
const lines = describeInTreeOrder(nodes, keep, maxDepth);
|
|
187
|
+
if (total > LIST_FILES_MAX_ENTRIES)
|
|
188
|
+
lines.push(truncationMarker(total, maxDepth));
|
|
38
189
|
return lines.length ? lines.join('\n') : '(empty)';
|
|
39
190
|
},
|
|
40
191
|
};
|
package/dist/tools/files.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../tools/files.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAExE,SAAS,GAAG,CAAC,IAA6B,EAAE,GAAW;IACrD,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACpB,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,YAAY,CAAC,GAAgB;IACpC,IAAI,CAAC,GAAG,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACnE,OAAO,GAAG,CAAC,KAAK,CAAC;AACnB,CAAC;AAED;sFACsF;AACtF,SAAS,cAAc,CAAC,IAAY;IAClC,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,GAAG,kBAAkB,kFAAkF,IAAI,iEAAiE,CAAC,CAAC;IAChM,CAAC;AACH,CAAC;AAED,SAAS,OAAO,CAAC,KAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../tools/files.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,kB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|
-
{"version":3,"file":"namespaces.d.ts","sourceRoot":"","sources":["../../tools/namespaces.ts"],"names":[],"mappings":"AAcA,MAAM,MAAM,aAAa,GACrB,IAAI,GASJ,SAAS,GACT,QAAQ,GACR,KAAK,GACL,QAAQ,GACR,OAAO,GACP,OAAO,GACP,QAAQ,GACR,KAAK,GACL,OAAO,GACP,OAAO,CAAC;AAEZ,+EAA+E;AAC/E,eAAO,MAAM,gBAAgB,EAAE;IAAE,EAAE,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAYlE,CAAC;
|
|
1
|
+
{"version":3,"file":"namespaces.d.ts","sourceRoot":"","sources":["../../tools/namespaces.ts"],"names":[],"mappings":"AAcA,MAAM,MAAM,aAAa,GACrB,IAAI,GASJ,SAAS,GACT,QAAQ,GACR,KAAK,GACL,QAAQ,GACR,OAAO,GACP,OAAO,GACP,QAAQ,GACR,KAAK,GACL,OAAO,GACP,OAAO,CAAC;AAEZ,+EAA+E;AAC/E,eAAO,MAAM,gBAAgB,EAAE;IAAE,EAAE,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAYlE,CAAC;AAiCF,wEAAwE;AACxE,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,2FAA2F;AAC3F,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,GAAG,aAAa,CAUpE;AAED;;;4CAG4C;AAC5C,wBAAgB,WAAW,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAsBxD;AAED;6EAC6E;AAC7E,wBAAgB,eAAe,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,EAAE,CAE9D;AAED,iEAAiE;AACjE,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAI1F;AAED,iFAAiF;AACjF,wBAAgB,aAAa,CAAC,EAAE,EAAE,aAAa,GAAG,MAAM,CAEvD"}
|
package/dist/tools/namespaces.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* Policy globs may target a whole namespace (fs:*) or one tool (fs:write_file),
|
|
12
12
|
* and legacy bare-name globs (write_file) still match for back-compat. */
|
|
13
|
-
import { matchesAnyGlob } from '../guardrail/glob';
|
|
13
|
+
import { matchesAnyGlob } from '../guardrail/glob.js';
|
|
14
14
|
/** Display order + labels for the namespaces (capabilities panel grouping). */
|
|
15
15
|
export const NAMESPACE_LABELS = [
|
|
16
16
|
{ ns: 'fs', label: 'Files' },
|
|
@@ -34,7 +34,7 @@ const BUILTIN_NAMESPACES = {
|
|
|
34
34
|
web_search: 'web',
|
|
35
35
|
save_memory: 'memory', recall_memory: 'memory', recall_result: 'memory',
|
|
36
36
|
kv_get: 'memory', kv_set: 'memory', search_sessions: 'memory',
|
|
37
|
-
ask_user: 'agent', spawn_agent: 'agent', spawn_agents: 'agent', todo_write: 'agent',
|
|
37
|
+
ask_user: 'agent', spawn_agent: 'agent', spawn_agents: 'agent', call_agent: 'agent', todo_write: 'agent',
|
|
38
38
|
// Named here as a backstop; the sidecar's own decls also carry `namespace`,
|
|
39
39
|
// and an explicit field always wins (resolveNamespace). Both say the same
|
|
40
40
|
// thing so a sidecar that predates this still lands in the right namespace.
|
|
@@ -46,6 +46,14 @@ const BUILTIN_NAMESPACES = {
|
|
|
46
46
|
// policy, so they need a canonical address like everything else.
|
|
47
47
|
create_strategy: 'agent', edit_strategy: 'agent', view_strategy: 'agent', run_strategy: 'agent',
|
|
48
48
|
list_strategies: 'agent', list_saved_strategies: 'agent',
|
|
49
|
+
// Long-lived process control (proc_start/proc_stop/proc_list, see tools/procs.ts).
|
|
50
|
+
// `shell` is its own subject, deliberately distinct from the one-shot exec's
|
|
51
|
+
// `sidecar:shell_exec`: a process that stays running is a different risk from
|
|
52
|
+
// one that returns, and one address lets an operator ban (or allow) both
|
|
53
|
+
// start and stop together. proc_list is a read - it namespaces as `sidecar`
|
|
54
|
+
// (like the other machine-state reads) so it is NOT swept up by a `shell:*`
|
|
55
|
+
// deny; listing what is running carries none of spawn/kill's risk.
|
|
56
|
+
proc_start: 'shell', proc_stop: 'shell', proc_list: 'sidecar',
|
|
49
57
|
};
|
|
50
58
|
/** Resolve a tool's namespace: explicit field > built-in table > wire prefix > 'other'. */
|
|
51
59
|
export function resolveNamespace(tool) {
|
|
@@ -86,6 +94,12 @@ export function toolAddress(tool) {
|
|
|
86
94
|
}
|
|
87
95
|
}
|
|
88
96
|
}
|
|
97
|
+
// proc_start and proc_stop are two ends of the SAME governed capability
|
|
98
|
+
// (starting a long-lived process, and ending one) — they share the one
|
|
99
|
+
// address `shell:spawn` on purpose, so a policy rule can only ever gate both
|
|
100
|
+
// together, never start-without-stop or the reverse.
|
|
101
|
+
if (ns === 'shell' && (leaf === 'proc_start' || leaf === 'proc_stop'))
|
|
102
|
+
leaf = 'spawn';
|
|
89
103
|
return `${ns}:${leaf}`;
|
|
90
104
|
}
|
|
91
105
|
/** Candidate strings a policy glob may target for this tool: its address and its
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespaces.js","sourceRoot":"","sources":["../../tools/namespaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;0EAW0E;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAuBnD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,gBAAgB,GAA2C;IACtE,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE;IAC5B,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,cAAc,EAAE;IACxC,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;IACjC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;IAC3B,EAAE,EAAE,EAAE,QAAQ,EAA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AwB;IAC/E,IAAI,CAAC,KAAK,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAChC,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACtC,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/F,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,aAAa,CAAC,EAAiB;IAC7C,OAAO,GAAG,EAAE,IAAI,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AgentTool, SidecarProcs } from '@corenel/protocol';
|
|
2
|
+
export interface ProcToolsOptions {
|
|
3
|
+
/** Identifies the run/session starting processes through these tools. Stamped
|
|
4
|
+
* onto every ProcInfo.label this factory produces (agentLabel()) so a dock
|
|
5
|
+
* listing can show provenance even after a reload. Optional — omitting it
|
|
6
|
+
* still marks the process as agent-started, just without a session name. */
|
|
7
|
+
session?: string;
|
|
8
|
+
/** Cap on concurrent agent-started RUNNING processes (see AGENT_TAG /
|
|
9
|
+
* isAgentStarted) — independent of, and smaller than, the daemon's own
|
|
10
|
+
* MAX_RUNNING. Default DEFAULT_AGENT_BUDGET. */
|
|
11
|
+
agentBudget?: number;
|
|
12
|
+
}
|
|
13
|
+
/** Build the proc_start / proc_stop / proc_list tools over a live SidecarProcs.
|
|
14
|
+
* `procs` is expected to be a real, already-constructed process table (node
|
|
15
|
+
* child_process-backed in production, a fake in tests) — this file never
|
|
16
|
+
* constructs one itself. */
|
|
17
|
+
export declare function procTools(procs: SidecarProcs, opts?: ProcToolsOptions): AgentTool[];
|
|
18
|
+
//# sourceMappingURL=procs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"procs.d.ts","sourceRoot":"","sources":["../../tools/procs.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,SAAS,EAAoC,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA0JnG,MAAM,WAAW,gBAAgB;IAC/B;;;gFAG4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;oDAEgD;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;4BAG4B;AAC5B,wBAAgB,SAAS,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,GAAE,gBAAqB,GAAG,SAAS,EAAE,CA2JvF"}
|