@robota-sdk/agent-tool-defaults 3.0.0-beta.100
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/CHANGELOG.md +313 -0
- package/LICENSE +661 -0
- package/README.md +80 -0
- package/dist/node/index.cjs +1 -0
- package/dist/node/index.d.cts +49 -0
- package/dist/node/index.d.cts.map +1 -0
- package/dist/node/index.d.ts +49 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +2 -0
- package/dist/node/index.js.map +1 -0
- package/package.json +77 -0
- package/src/__tests__/create-default-tools.test.ts +289 -0
- package/src/create-default-tools.ts +124 -0
- package/src/index.ts +14 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The DEFAULT TOOL SET — a composition leaf.
|
|
3
|
+
*
|
|
4
|
+
* ARCH-035 moved this out of `@robota-sdk/agent-framework`. It is a defaults aggregator, and
|
|
5
|
+
* `.agents/project-structure.md` classifies that family as a composition leaf "imported only at
|
|
6
|
+
* composition roots (entry-point-only)" — not something a mid-layer assembly library owns, publishes
|
|
7
|
+
* and self-consumes.
|
|
8
|
+
*
|
|
9
|
+
* The move is what carries the guarantee. `agent-subagent-runner` may depend on `agent-framework`
|
|
10
|
+
* (it needs `createSubagentSession` and friends) but has no manifest edge to THIS package, so
|
|
11
|
+
* `import { createDefaultTools } from '@robota-sdk/agent-tool-defaults'` does not resolve there at
|
|
12
|
+
* all. A neutral runner composing the product's tool surface is now a compile error rather than a
|
|
13
|
+
* scan finding — the same shape ARCH-021 achieved on the provider axis with
|
|
14
|
+
* `@robota-sdk/agent-builtin-providers`.
|
|
15
|
+
*
|
|
16
|
+
* `DEFAULT_TOOL_DESCRIPTIONS` deliberately did NOT come along: its only consumer builds the system
|
|
17
|
+
* prompt synchronously, and dragging it here would force either a static edge back into this leaf or
|
|
18
|
+
* a second async hop through prompt building. It stays beside its consumer in `agent-framework`.
|
|
19
|
+
*/
|
|
20
|
+
import {
|
|
21
|
+
createAskUserQuestionTool,
|
|
22
|
+
createShellTool,
|
|
23
|
+
createBashTool,
|
|
24
|
+
createReadTool,
|
|
25
|
+
createWriteTool,
|
|
26
|
+
createEditTool,
|
|
27
|
+
createRetrievalTool,
|
|
28
|
+
createComputerTool,
|
|
29
|
+
createGlobTool,
|
|
30
|
+
createGrepTool,
|
|
31
|
+
createWebFetchTool,
|
|
32
|
+
createWebSearchTool,
|
|
33
|
+
routesFilesThroughSandbox,
|
|
34
|
+
} from '@robota-sdk/agent-tools';
|
|
35
|
+
|
|
36
|
+
import type { FunctionTool } from '@robota-sdk/agent-core';
|
|
37
|
+
import type {
|
|
38
|
+
IComputerDriver,
|
|
39
|
+
IEditorFileAccess,
|
|
40
|
+
IRetrievalAdapter,
|
|
41
|
+
ISandboxClient,
|
|
42
|
+
} from '@robota-sdk/agent-tools';
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Create the default set of CLI tools.
|
|
46
|
+
* Returns the standard tools.
|
|
47
|
+
*/
|
|
48
|
+
export interface ICreateDefaultToolsOptions {
|
|
49
|
+
sandboxClient?: ISandboxClient;
|
|
50
|
+
/** Host-selected executable for Shell and Bash. */
|
|
51
|
+
shellExecutable?: string;
|
|
52
|
+
httpUserAgent?: string;
|
|
53
|
+
/**
|
|
54
|
+
* The execution root every file tool is contained by. REQUIRED — ARCH-010.
|
|
55
|
+
*
|
|
56
|
+
* It was optional, and `child-process-subagent-worker.ts` called this factory with no argument at
|
|
57
|
+
* all: `cwd` was `undefined`, the path guard was fail-open, and the subagent's `Read` returned
|
|
58
|
+
* `/etc/hostname`. Requiring it means a construction site that forgets does not compile, which is
|
|
59
|
+
* the only way a containment root stays a contract rather than a convention.
|
|
60
|
+
*/
|
|
61
|
+
cwd: string;
|
|
62
|
+
/**
|
|
63
|
+
* An editor that has the workspace open, asked at each call. The host file tools read and write
|
|
64
|
+
* through what it offers and the searches say they read the disk; commands never use it, and a
|
|
65
|
+
* sandbox with its own filesystem keeps every file tool, since its files are not the editor's.
|
|
66
|
+
*/
|
|
67
|
+
editorFiles?: () => IEditorFileAccess | undefined;
|
|
68
|
+
/** SELFHOST-003: when present, adds the adapter-gated `CodebaseRetrieval` tool (absent otherwise). */
|
|
69
|
+
retrievalAdapter?: IRetrievalAdapter;
|
|
70
|
+
/**
|
|
71
|
+
* SELFHOST-010: when present, adds the adapter-gated `ComputerView` + `Computer` tools. Unlike the
|
|
72
|
+
* shell tool's host `spawn` fallback, computer-use has NO host fallback — with no driver the tools are
|
|
73
|
+
* simply ABSENT (there is no safe library-side "local" screen to fall back to).
|
|
74
|
+
*/
|
|
75
|
+
computerDriver?: IComputerDriver;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* ARCH-035: returns `FunctionTool[]`, which is what every factory below actually returns.
|
|
80
|
+
*
|
|
81
|
+
* An earlier revision cast each one to `IToolWithEventService` because session assembly consumes that
|
|
82
|
+
* interface. The cast was lossy in the direction that mattered: `ICapabilityPack.tools` is
|
|
83
|
+
* `readonly FunctionTool[]`, so a pack CONSUMING this set could not assign it without a second cast
|
|
84
|
+
* back — one erasure creating the need for another. `FunctionTool` satisfies `IToolWithEventService`,
|
|
85
|
+
* so session assembly is unaffected and no cast is needed at either end.
|
|
86
|
+
*/
|
|
87
|
+
export function createDefaultTools(options: ICreateDefaultToolsOptions): FunctionTool[] {
|
|
88
|
+
// Issue #3081: the sandbox's filesystem relation decides where file tools read and write. On a
|
|
89
|
+
// SEPARATE filesystem every file tool goes through the sandbox — and `Glob`/`Grep`, which have no
|
|
90
|
+
// sandbox path, are withheld, so a search can never read the host while an edit writes the
|
|
91
|
+
// sandbox. On a SHARED filesystem (commands confined over the host's) file tools stay on the host
|
|
92
|
+
// under the path guard, and only commands run through the sandbox.
|
|
93
|
+
const separate = routesFilesThroughSandbox(options.sandboxClient);
|
|
94
|
+
// An editor holds the host's files, so it reaches only the tools that work on them; commands keep
|
|
95
|
+
// the agent's own sandbox.
|
|
96
|
+
const { editorFiles: _hostFilesOnly, ...commandOptions } = options;
|
|
97
|
+
const { sandboxClient: _commandsOnly, ...hostFileOptions } = options;
|
|
98
|
+
const fileOptions = separate ? commandOptions : hostFileOptions;
|
|
99
|
+
return [
|
|
100
|
+
createShellTool(commandOptions),
|
|
101
|
+
createBashTool(commandOptions),
|
|
102
|
+
createReadTool(fileOptions),
|
|
103
|
+
createWriteTool(fileOptions),
|
|
104
|
+
createEditTool(fileOptions),
|
|
105
|
+
// SEC-007: built per call, NOT the module-level singletons. A singleton is context-free by
|
|
106
|
+
// construction, so registering one meant `Glob`/`Grep` could enumerate outside the session's
|
|
107
|
+
// working directory while `Read`/`Write`/`Edit` were contained.
|
|
108
|
+
...(separate ? [] : [createGlobTool(hostFileOptions), createGrepTool(hostFileOptions)]),
|
|
109
|
+
// MUST 4: also built per call, for the same reason — `webFetchTool`/`webSearchTool` are
|
|
110
|
+
// module-level singletons in `agent-tools`, so two concurrently open sessions built from this
|
|
111
|
+
// set (e.g. two `sessionParticipant`s) shared them and tripped `resource-reused` even though
|
|
112
|
+
// nothing about a WebFetch/WebSearch tool actually needs to be shared across sessions.
|
|
113
|
+
createWebFetchTool({ userAgent: options.httpUserAgent }),
|
|
114
|
+
createWebSearchTool(),
|
|
115
|
+
createAskUserQuestionTool(),
|
|
116
|
+
// Retrieval is adapter-gated: absent when no adapter is supplied (there is no host fallback).
|
|
117
|
+
...(options.retrievalAdapter
|
|
118
|
+
? [createRetrievalTool({ adapter: options.retrievalAdapter })]
|
|
119
|
+
: []),
|
|
120
|
+
// Computer-use is adapter-gated on the driver: absent when no driver is supplied. There is NO host
|
|
121
|
+
// fallback (unlike the shell tool's host spawn) — no library-side "local" screen exists.
|
|
122
|
+
...(options.computerDriver ? createComputerTool({ driver: options.computerDriver }) : []),
|
|
123
|
+
];
|
|
124
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@robota-sdk/agent-tool-defaults` — the SDK's built-in default tool set, as a composition leaf.
|
|
3
|
+
*
|
|
4
|
+
* WHOSE defaults (#2202): the agent runtime SDK's own — the tools every product session gets unless the
|
|
5
|
+
* composition root supplies its own list. It composes ONE lower-layer package (`agent-tools`); it does
|
|
6
|
+
* not bundle same-level `agent-tool-*` siblings, so it is not an aggregator in the STRUCT-011 sense
|
|
7
|
+
* and keeps its name. Only the description had to say whose.
|
|
8
|
+
*
|
|
9
|
+
* Import this at a composition root. It is deliberately NOT re-exported by
|
|
10
|
+
* `@robota-sdk/agent-framework`: a pass-through re-export would restore the very route ARCH-035
|
|
11
|
+
* closed, and STRUCT-07 bans it independently.
|
|
12
|
+
*/
|
|
13
|
+
export { createDefaultTools } from './create-default-tools.js';
|
|
14
|
+
export type { ICreateDefaultToolsOptions } from './create-default-tools.js';
|