forked from zbirenbaum/copilot.lua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoolSet.js
More file actions
107 lines (107 loc) · 3.33 KB
/
Copy pathtoolSet.js
File metadata and controls
107 lines (107 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var toolSet_exports = {};
__export(toolSet_exports, {
BuiltInTools: () => BuiltInTools,
ToolSet: () => ToolSet
});
module.exports = __toCommonJS(toolSet_exports);
const VALID_TOOL_NAME = /^[a-zA-Z0-9_-]+$/;
function validateName(kind, name) {
if (name === "*") {
return;
}
if (!VALID_TOOL_NAME.test(name)) {
throw new Error(
`Invalid ${kind} tool name '${name}': tool names must match /^[a-zA-Z0-9_-]+$/ or be the wildcard '*'.`
);
}
}
class ToolSet {
items = [];
addBuiltIn(nameOrNames) {
const names = typeof nameOrNames === "string" ? [nameOrNames] : nameOrNames;
for (const name of names) {
validateName("builtin", name);
this.items.push(`builtin:${name}`);
}
return this;
}
/**
* Adds a custom tool pattern. Matches tools registered via the SDK's
* `tools` option or via custom agents.
*
* @param name A specific custom tool name or `"*"` to match all custom tools.
*/
addCustom(name) {
validateName("custom", name);
this.items.push(`custom:${name}`);
return this;
}
/**
* Adds an MCP tool pattern. Matches tools advertised by any configured
* MCP server.
*
* @param toolName The runtime's canonical wire name for the MCP tool
* (e.g. `"github-list_issues"`), or `"*"` to match all MCP tools from
* any server.
*/
addMcp(toolName) {
validateName("mcp", toolName);
this.items.push(`mcp:${toolName}`);
return this;
}
/**
* Returns a defensive copy of the accumulated filter strings, suitable for
* passing as {@link SessionConfigBase.availableTools}.
*/
toArray() {
return [...this.items];
}
}
const BuiltInTools = {
/**
* Built-in tools that operate only within the bounds of a single session —
* no host filesystem access outside the session, no cross-session state,
* no host environment access, no network. Safe to enable in `Mode = "empty"`
* scenarios (e.g. multi-tenant servers) without leaking host capabilities.
*
* **Contract:** tools in this set MUST NOT be extended (even behind options
* or args) to read or write state outside the session boundary. Adding
* cross-session or host-state behavior to one of these tools is a
* breaking change that requires removing it from this set.
*/
Isolated: [
"ask_user",
"task_complete",
"exit_plan_mode",
"task",
"read_agent",
"write_agent",
"list_agents",
"send_inbox",
"context_board",
"skill"
]
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
BuiltInTools,
ToolSet
});