@harperfast/harper 5.2.0-alpha.4 → 5.2.0-alpha.6
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/agent/agent.ts +152 -10
- package/agent/bestPractices.ts +58 -0
- package/agent/mcpTools.ts +122 -0
- package/agent/operations.ts +10 -1
- package/agent/registryTools.ts +117 -0
- package/agent/session.ts +16 -7
- package/agent/tools/fsTools.ts +74 -27
- package/agent/tools/inspectorTool.ts +459 -0
- package/agent/toolset.ts +27 -7
- package/agent/types.ts +2 -0
- package/components/Application.ts +566 -85
- package/components/OptionsWatcher.ts +62 -2
- package/components/Scope.ts +31 -8
- package/components/componentLoader.ts +5 -1
- package/components/componentSecrets.ts +514 -55
- package/components/deploymentRecorder.ts +7 -6
- package/components/gitCredentialHelper.js +115 -0
- package/components/gitCredentialServer.ts +251 -0
- package/components/mcp/tools/application.ts +197 -23
- package/components/mcp/tools/operations.ts +1 -1
- package/components/mcp/tools/schemas/derive.ts +6 -2
- package/components/operations.js +21 -19
- package/components/operationsValidation.js +86 -21
- package/components/secretOperations.ts +110 -30
- package/config/harperConfigEnvVars.ts +90 -5
- package/config-root.schema.json +4 -0
- package/dist/agent/agent.d.ts +24 -3
- package/dist/agent/agent.js +172 -10
- package/dist/agent/agent.js.map +1 -1
- package/dist/agent/bestPractices.d.ts +24 -0
- package/dist/agent/bestPractices.js +60 -0
- package/dist/agent/bestPractices.js.map +1 -0
- package/dist/agent/mcpTools.d.ts +24 -0
- package/dist/agent/mcpTools.js +115 -0
- package/dist/agent/mcpTools.js.map +1 -0
- package/dist/agent/operations.js +10 -1
- package/dist/agent/operations.js.map +1 -1
- package/dist/agent/registryTools.d.ts +45 -0
- package/dist/agent/registryTools.js +113 -0
- package/dist/agent/registryTools.js.map +1 -0
- package/dist/agent/session.js +16 -7
- package/dist/agent/session.js.map +1 -1
- package/dist/agent/tools/fsTools.js +70 -28
- package/dist/agent/tools/fsTools.js.map +1 -1
- package/dist/agent/tools/inspectorTool.d.ts +40 -0
- package/dist/agent/tools/inspectorTool.js +428 -0
- package/dist/agent/tools/inspectorTool.js.map +1 -0
- package/dist/agent/toolset.d.ts +16 -6
- package/dist/agent/toolset.js +17 -7
- package/dist/agent/toolset.js.map +1 -1
- package/dist/agent/types.d.ts +2 -0
- package/dist/components/Application.d.ts +73 -18
- package/dist/components/Application.js +475 -64
- package/dist/components/Application.js.map +1 -1
- package/dist/components/OptionsWatcher.d.ts +1 -1
- package/dist/components/OptionsWatcher.js +65 -2
- package/dist/components/OptionsWatcher.js.map +1 -1
- package/dist/components/Scope.d.ts +8 -6
- package/dist/components/Scope.js +22 -6
- package/dist/components/Scope.js.map +1 -1
- package/dist/components/componentLoader.js +5 -1
- package/dist/components/componentLoader.js.map +1 -1
- package/dist/components/componentSecrets.d.ts +33 -7
- package/dist/components/componentSecrets.js +473 -59
- package/dist/components/componentSecrets.js.map +1 -1
- package/dist/components/deploymentRecorder.d.ts +2 -2
- package/dist/components/deploymentRecorder.js +1 -1
- package/dist/components/deploymentRecorder.js.map +1 -1
- package/dist/components/gitCredentialHelper.d.ts +1 -0
- package/dist/components/gitCredentialHelper.js +113 -0
- package/dist/components/gitCredentialHelper.js.map +1 -0
- package/dist/components/gitCredentialServer.d.ts +33 -0
- package/dist/components/gitCredentialServer.js +236 -0
- package/dist/components/gitCredentialServer.js.map +1 -0
- package/dist/components/mcp/tools/application.d.ts +19 -0
- package/dist/components/mcp/tools/application.js +180 -22
- package/dist/components/mcp/tools/application.js.map +1 -1
- package/dist/components/mcp/tools/operations.d.ts +13 -0
- package/dist/components/mcp/tools/operations.js +1 -0
- package/dist/components/mcp/tools/operations.js.map +1 -1
- package/dist/components/mcp/tools/schemas/derive.js +6 -2
- package/dist/components/mcp/tools/schemas/derive.js.map +1 -1
- package/dist/components/operations.js +23 -21
- package/dist/components/operations.js.map +1 -1
- package/dist/components/operationsValidation.js +84 -21
- package/dist/components/operationsValidation.js.map +1 -1
- package/dist/components/secretOperations.d.ts +33 -11
- package/dist/components/secretOperations.js +90 -26
- package/dist/components/secretOperations.js.map +1 -1
- package/dist/config/harperConfigEnvVars.d.ts +21 -0
- package/dist/config/harperConfigEnvVars.js +95 -5
- package/dist/config/harperConfigEnvVars.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +14 -1
- package/dist/index.js.map +1 -1
- package/dist/resources/Resource.d.ts +19 -0
- package/dist/resources/Resource.js +93 -2
- package/dist/resources/Resource.js.map +1 -1
- package/dist/resources/Table.d.ts +9 -0
- package/dist/resources/Table.js +256 -50
- package/dist/resources/Table.js.map +1 -1
- package/dist/resources/analytics/read.js +28 -25
- package/dist/resources/analytics/read.js.map +1 -1
- package/dist/resources/defineResource.d.ts +180 -0
- package/dist/resources/defineResource.js +505 -0
- package/dist/resources/defineResource.js.map +1 -0
- package/dist/resources/defineTable.d.ts +221 -0
- package/dist/resources/defineTable.js +227 -0
- package/dist/resources/defineTable.js.map +1 -0
- package/dist/resources/jsonSchemaTypes.d.ts +2 -0
- package/dist/resources/jsonSchemaTypes.js +12 -4
- package/dist/resources/jsonSchemaTypes.js.map +1 -1
- package/dist/resources/openApi.js +69 -13
- package/dist/resources/openApi.js.map +1 -1
- package/dist/resources/search.js +6 -8
- package/dist/resources/search.js.map +1 -1
- package/dist/server/graphqlQuerying.js +4 -2
- package/dist/server/graphqlQuerying.js.map +1 -1
- package/dist/server/http.d.ts +12 -0
- package/dist/server/http.js +35 -15
- package/dist/server/http.js.map +1 -1
- package/dist/server/serverHelpers/serverUtilities.js +8 -5
- package/dist/server/serverHelpers/serverUtilities.js.map +1 -1
- package/dist/server/serverHelpers/uwsServer.js +23 -0
- package/dist/server/serverHelpers/uwsServer.js.map +1 -1
- package/dist/utility/errors/hdbError.d.ts +21 -0
- package/dist/utility/errors/hdbError.js +23 -1
- package/dist/utility/errors/hdbError.js.map +1 -1
- package/dist/validation/configValidator.js +22 -6
- package/dist/validation/configValidator.js.map +1 -1
- package/index.ts +33 -0
- package/npm-shrinkwrap.json +9197 -15236
- package/package.json +5 -3
- package/resources/DESIGN.md +42 -15
- package/resources/Resource.ts +99 -2
- package/resources/Table.ts +275 -71
- package/resources/analytics/read.ts +30 -25
- package/resources/defineResource.ts +651 -0
- package/resources/defineTable.ts +407 -0
- package/resources/jsonSchemaTypes.ts +12 -4
- package/resources/openApi.ts +68 -16
- package/resources/search.ts +5 -8
- package/server/graphqlQuerying.ts +4 -2
- package/server/http.ts +40 -16
- package/server/serverHelpers/serverUtilities.ts +19 -6
- package/server/serverHelpers/uwsServer.ts +24 -0
- package/studio/web/assets/{Chat-D4FIaBu7.js → Chat-CTjtL8Z4.js} +2 -2
- package/studio/web/assets/{Chat-D4FIaBu7.js.map → Chat-CTjtL8Z4.js.map} +1 -1
- package/studio/web/assets/{FloatingChat-DGUC3L4r.js → FloatingChat-CafHR4Ur.js} +4 -4
- package/studio/web/assets/{FloatingChat-DGUC3L4r.js.map → FloatingChat-CafHR4Ur.js.map} +1 -1
- package/studio/web/assets/{applications-D8Am9ikM.js → applications-Buh_q0Vj.js} +2 -2
- package/studio/web/assets/{applications-D8Am9ikM.js.map → applications-Buh_q0Vj.js.map} +1 -1
- package/studio/web/assets/{index-HGL4WHdb.js → index-0hXeECkS.js} +6 -6
- package/studio/web/assets/{index-HGL4WHdb.js.map → index-0hXeECkS.js.map} +1 -1
- package/studio/web/assets/{index.lazy-Dk5j1AoQ.js → index.lazy-B00B7VBT.js} +4 -4
- package/studio/web/assets/{index.lazy-Dk5j1AoQ.js.map → index.lazy-B00B7VBT.js.map} +1 -1
- package/studio/web/assets/{profile-7bu_CF1f.js → profile-Cg2wwYPn.js} +2 -2
- package/studio/web/assets/{profile-7bu_CF1f.js.map → profile-Cg2wwYPn.js.map} +1 -1
- package/studio/web/assets/{setComponentFile-MfYm9F94.js → setComponentFile-DCaDIvyB.js} +2 -2
- package/studio/web/assets/{setComponentFile-MfYm9F94.js.map → setComponentFile-DCaDIvyB.js.map} +1 -1
- package/studio/web/assets/{setup-SKA4UhdE.js → setup-CAVcAQjK.js} +2 -2
- package/studio/web/assets/{setup-SKA4UhdE.js.map → setup-CAVcAQjK.js.map} +1 -1
- package/studio/web/assets/{status-DetVLUxR.js → status-BRXorNdD.js} +2 -2
- package/studio/web/assets/{status-DetVLUxR.js.map → status-BRXorNdD.js.map} +1 -1
- package/studio/web/assets/{swagger-ui-react-DLeYARY2.js → swagger-ui-react-Dy1D62vO.js} +2 -2
- package/studio/web/assets/{swagger-ui-react-DLeYARY2.js.map → swagger-ui-react-Dy1D62vO.js.map} +1 -1
- package/studio/web/assets/{tsMode-DGO-jIF7.js → tsMode-A8gbL74v.js} +2 -2
- package/studio/web/assets/{tsMode-DGO-jIF7.js.map → tsMode-A8gbL74v.js.map} +1 -1
- package/studio/web/assets/{useEntityRestURL-4M2i6bo4.js → useEntityRestURL-cDodrVcQ.js} +2 -2
- package/studio/web/assets/{useEntityRestURL-4M2i6bo4.js.map → useEntityRestURL-cDodrVcQ.js.map} +1 -1
- package/studio/web/index.html +1 -1
- package/utility/errors/hdbError.ts +32 -0
- package/validation/configValidator.ts +23 -6
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* V8 inspector (CDP) tools for the built-in agent (#626).
|
|
4
|
+
*
|
|
5
|
+
* The agent runs on the main thread; these tools attach over the Chrome
|
|
6
|
+
* DevTools Protocol to *worker* thread inspector ports so it can evaluate,
|
|
7
|
+
* set breakpoints/logpoints, and CPU-profile a worker without stalling the
|
|
8
|
+
* thread it runs on. A worker's debug port is `threads_debug_startingPort +
|
|
9
|
+
* workerIndex` (see `server/threads/threadServer.js`); attaching therefore
|
|
10
|
+
* requires `threads_debug: true` and a configured `threads_debug_startingPort`.
|
|
11
|
+
*
|
|
12
|
+
* Attaching to the main thread (`workerIndex < 0`) is rejected — that's the
|
|
13
|
+
* agent's own thread, and a self-attach + breakpoint would deadlock. This is
|
|
14
|
+
* the operator-only counterpart to the app-developer agent, which runs on a
|
|
15
|
+
* worker and must never inspector-attach to itself.
|
|
16
|
+
*
|
|
17
|
+
* Safety against wedging a live worker: every connection registers a
|
|
18
|
+
* `Debugger.paused` handler that logs a stack snapshot and immediately resumes,
|
|
19
|
+
* so a breakpoint hit is observable (via the Harper log) but never leaves the
|
|
20
|
+
* worker paused. CDP calls carry a per-call abort signal + timeout so an
|
|
21
|
+
* unresponsive worker can't hang the agent loop.
|
|
22
|
+
*
|
|
23
|
+
* Dependencies (debug config + live worker count) are injected so the tool is
|
|
24
|
+
* unit-testable without booting a server.
|
|
25
|
+
*/
|
|
26
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.summarizeProfile = summarizeProfile;
|
|
31
|
+
exports.buildInspectorTools = buildInspectorTools;
|
|
32
|
+
exports._closeInspectorSessions = _closeInspectorSessions;
|
|
33
|
+
const ws_1 = __importDefault(require("ws"));
|
|
34
|
+
const harper_logger_ts_1 = __importDefault(require("../../utility/logging/harper_logger.js"));
|
|
35
|
+
const log = harper_logger_ts_1.default.loggerWithTag('agent');
|
|
36
|
+
const DEFAULT_CALL_TIMEOUT_MS = 30_000;
|
|
37
|
+
const MAX_TCP_PORT = 65535;
|
|
38
|
+
// One live CDP connection per worker debug port, reused across tool calls. Keyed by port and
|
|
39
|
+
// storing the *promise* so concurrent opens dedupe onto a single connection.
|
|
40
|
+
const sessions = new Map();
|
|
41
|
+
/** Strictly parse a worker index — reject `""`/`null`/`false`/`[]`, which `Number()` would coerce to 0. */
|
|
42
|
+
function toWorkerIndex(raw) {
|
|
43
|
+
if (typeof raw === 'number' && Number.isInteger(raw))
|
|
44
|
+
return raw;
|
|
45
|
+
if (typeof raw === 'string' && raw.trim() !== '' && Number.isInteger(Number(raw)))
|
|
46
|
+
return Number(raw);
|
|
47
|
+
throw new Error('workerIndex must be an integer');
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Resolve the worker's inspector port, enforcing the safety envelope:
|
|
51
|
+
* debug enabled, a starting port configured, and an in-range worker index that
|
|
52
|
+
* is NOT the main thread (`< 0`).
|
|
53
|
+
*/
|
|
54
|
+
function resolvePort(deps, workerIndex) {
|
|
55
|
+
if (!deps.debugEnabled) {
|
|
56
|
+
throw new Error('threads_debug is not enabled; set threads_debug: true to allow inspector attach');
|
|
57
|
+
}
|
|
58
|
+
if (deps.startingPort == null) {
|
|
59
|
+
throw new Error('threads_debug_startingPort is not configured; per-worker inspector ports are unavailable');
|
|
60
|
+
}
|
|
61
|
+
if (workerIndex < 0) {
|
|
62
|
+
throw new Error('cannot attach to the main thread (the agent runs there); specify a worker index >= 0');
|
|
63
|
+
}
|
|
64
|
+
const count = deps.getWorkerCount();
|
|
65
|
+
if (workerIndex >= count)
|
|
66
|
+
throw new Error(`no worker at index ${workerIndex} (worker count is ${count})`);
|
|
67
|
+
const port = deps.startingPort + workerIndex;
|
|
68
|
+
if (port > MAX_TCP_PORT)
|
|
69
|
+
throw new Error(`resolved inspector port ${port} exceeds ${MAX_TCP_PORT}`);
|
|
70
|
+
return port;
|
|
71
|
+
}
|
|
72
|
+
async function fetchWebSocketUrl(host, port, signal) {
|
|
73
|
+
const res = await fetch(`http://${host}:${port}/json/list`, { signal });
|
|
74
|
+
if (!res.ok)
|
|
75
|
+
throw new Error(`inspector /json/list on ${host}:${port} returned ${res.status}`);
|
|
76
|
+
const targets = (await res.json());
|
|
77
|
+
const target = Array.isArray(targets) ? targets.find((t) => t.webSocketDebuggerUrl) : undefined;
|
|
78
|
+
if (!target?.webSocketDebuggerUrl) {
|
|
79
|
+
throw new Error(`no debuggable target at ${host}:${port} (is the worker inspector open?)`);
|
|
80
|
+
}
|
|
81
|
+
return { wsUrl: target.webSocketDebuggerUrl, title: target.title };
|
|
82
|
+
}
|
|
83
|
+
function openCdp(wsUrl, opts) {
|
|
84
|
+
return new Promise((resolve, reject) => {
|
|
85
|
+
const ws = new ws_1.default(wsUrl);
|
|
86
|
+
let opened = false;
|
|
87
|
+
let nextId = 1;
|
|
88
|
+
const pending = new Map();
|
|
89
|
+
const listeners = new Map();
|
|
90
|
+
const failPending = (err) => {
|
|
91
|
+
for (const p of pending.values())
|
|
92
|
+
p.reject(err);
|
|
93
|
+
pending.clear();
|
|
94
|
+
};
|
|
95
|
+
// The connect signal guards ONLY the handshake — once open, per-call signals take over, so
|
|
96
|
+
// aborting the first caller must not tear down the shared connection.
|
|
97
|
+
const onConnectAbort = () => {
|
|
98
|
+
try {
|
|
99
|
+
ws.terminate();
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
/* already gone */
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
if (opts.signal) {
|
|
106
|
+
if (opts.signal.aborted) {
|
|
107
|
+
onConnectAbort();
|
|
108
|
+
return reject(new Error('aborted'));
|
|
109
|
+
}
|
|
110
|
+
opts.signal.addEventListener('abort', onConnectAbort, { once: true });
|
|
111
|
+
}
|
|
112
|
+
ws.on('message', (data) => {
|
|
113
|
+
let msg;
|
|
114
|
+
try {
|
|
115
|
+
msg = JSON.parse(data.toString());
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (msg.id != null && pending.has(msg.id)) {
|
|
121
|
+
const p = pending.get(msg.id);
|
|
122
|
+
pending.delete(msg.id);
|
|
123
|
+
if (msg.error)
|
|
124
|
+
p.reject(new Error(msg.error.message ?? 'CDP error'));
|
|
125
|
+
else
|
|
126
|
+
p.resolve(msg.result);
|
|
127
|
+
}
|
|
128
|
+
else if (msg.method) {
|
|
129
|
+
for (const cb of listeners.get(msg.method) ?? [])
|
|
130
|
+
cb(msg.params);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
ws.on('error', (err) => {
|
|
134
|
+
if (!opened)
|
|
135
|
+
reject(err);
|
|
136
|
+
failPending(err instanceof Error ? err : new Error(String(err)));
|
|
137
|
+
});
|
|
138
|
+
ws.on('close', () => {
|
|
139
|
+
opts.signal?.removeEventListener('abort', onConnectAbort);
|
|
140
|
+
if (!opened)
|
|
141
|
+
reject(new Error('CDP connection closed before it opened'));
|
|
142
|
+
failPending(new Error('CDP connection closed'));
|
|
143
|
+
opts.onClose();
|
|
144
|
+
});
|
|
145
|
+
ws.on('open', () => {
|
|
146
|
+
opened = true;
|
|
147
|
+
opts.signal?.removeEventListener('abort', onConnectAbort);
|
|
148
|
+
const session = {
|
|
149
|
+
send(method, params, signal) {
|
|
150
|
+
return new Promise((res, rej) => {
|
|
151
|
+
if (signal?.aborted)
|
|
152
|
+
return rej(new Error('aborted'));
|
|
153
|
+
const id = nextId++;
|
|
154
|
+
const timer = setTimeout(() => {
|
|
155
|
+
if (pending.delete(id))
|
|
156
|
+
rej(new Error(`CDP ${method} timed out after ${DEFAULT_CALL_TIMEOUT_MS}ms`));
|
|
157
|
+
}, DEFAULT_CALL_TIMEOUT_MS);
|
|
158
|
+
const onAbort = () => {
|
|
159
|
+
if (pending.delete(id)) {
|
|
160
|
+
clearTimeout(timer);
|
|
161
|
+
rej(new Error('aborted'));
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
165
|
+
pending.set(id, {
|
|
166
|
+
resolve: (v) => {
|
|
167
|
+
clearTimeout(timer);
|
|
168
|
+
signal?.removeEventListener('abort', onAbort);
|
|
169
|
+
res(v);
|
|
170
|
+
},
|
|
171
|
+
reject: (e) => {
|
|
172
|
+
clearTimeout(timer);
|
|
173
|
+
signal?.removeEventListener('abort', onAbort);
|
|
174
|
+
rej(e);
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
try {
|
|
178
|
+
ws.send(JSON.stringify({ id, method, params: params ?? {} }));
|
|
179
|
+
}
|
|
180
|
+
catch (e) {
|
|
181
|
+
if (pending.delete(id)) {
|
|
182
|
+
clearTimeout(timer);
|
|
183
|
+
rej(e);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
},
|
|
188
|
+
on(event, cb) {
|
|
189
|
+
let set = listeners.get(event);
|
|
190
|
+
if (!set)
|
|
191
|
+
listeners.set(event, (set = new Set()));
|
|
192
|
+
set.add(cb);
|
|
193
|
+
},
|
|
194
|
+
close() {
|
|
195
|
+
try {
|
|
196
|
+
ws.close();
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
/* already closing */
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
// A breakpoint hit pauses the worker; log a stack snapshot and resume immediately so the
|
|
204
|
+
// worker is never left wedged. Fires only when Debugger is enabled (i.e. a breakpoint was set).
|
|
205
|
+
session.on('Debugger.paused', (params) => {
|
|
206
|
+
const frames = (params?.callFrames ?? [])
|
|
207
|
+
.slice(0, 5)
|
|
208
|
+
.map((f) => `${f.functionName || '(anonymous)'}@${f.url}:${f.location?.lineNumber}`);
|
|
209
|
+
log.info?.(`[agent breakpoint hit] reason=${params?.reason} ${frames.join(' <- ')}`);
|
|
210
|
+
session.send('Debugger.resume').catch(() => { });
|
|
211
|
+
});
|
|
212
|
+
resolve(session);
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
function sessionFor(port, host, signal) {
|
|
217
|
+
const existing = sessions.get(port);
|
|
218
|
+
if (existing)
|
|
219
|
+
return existing;
|
|
220
|
+
const promise = (async () => {
|
|
221
|
+
const { wsUrl, title } = await fetchWebSocketUrl(host, port, signal);
|
|
222
|
+
const session = await openCdp(wsUrl, {
|
|
223
|
+
signal,
|
|
224
|
+
// Evict only if this exact promise is still the cached one — a stale close from a replaced
|
|
225
|
+
// connection must not drop a newer active session.
|
|
226
|
+
onClose: () => {
|
|
227
|
+
if (sessions.get(port) === promise)
|
|
228
|
+
sessions.delete(port);
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
session.title = title;
|
|
232
|
+
return session;
|
|
233
|
+
})();
|
|
234
|
+
// Drop a failed connect from the cache so the next call retries instead of re-awaiting a rejection.
|
|
235
|
+
promise.catch(() => {
|
|
236
|
+
if (sessions.get(port) === promise)
|
|
237
|
+
sessions.delete(port);
|
|
238
|
+
});
|
|
239
|
+
sessions.set(port, promise);
|
|
240
|
+
return promise;
|
|
241
|
+
}
|
|
242
|
+
function sleep(ms, signal) {
|
|
243
|
+
return new Promise((resolve, reject) => {
|
|
244
|
+
if (signal?.aborted)
|
|
245
|
+
return reject(new Error('aborted'));
|
|
246
|
+
const timer = setTimeout(resolve, ms);
|
|
247
|
+
signal?.addEventListener('abort', () => {
|
|
248
|
+
clearTimeout(timer);
|
|
249
|
+
reject(new Error('aborted'));
|
|
250
|
+
}, { once: true });
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
/** Reduce a CDP CPU profile to the hottest functions by self time — the raw profile is megabytes. */
|
|
254
|
+
function summarizeProfile(profile, topN) {
|
|
255
|
+
const nodes = profile?.nodes ?? [];
|
|
256
|
+
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
257
|
+
const samples = profile?.samples ?? [];
|
|
258
|
+
const deltas = profile?.timeDeltas ?? [];
|
|
259
|
+
const selfUs = new Map();
|
|
260
|
+
for (let i = 0; i < samples.length; i++) {
|
|
261
|
+
const id = samples[i];
|
|
262
|
+
selfUs.set(id, (selfUs.get(id) ?? 0) + (deltas[i] ?? 0));
|
|
263
|
+
}
|
|
264
|
+
const topFunctions = [...selfUs.entries()]
|
|
265
|
+
.map(([id, us]) => {
|
|
266
|
+
const cf = byId.get(id)?.callFrame ?? {};
|
|
267
|
+
return {
|
|
268
|
+
function: cf.functionName || '(anonymous)',
|
|
269
|
+
url: cf.url,
|
|
270
|
+
line: cf.lineNumber,
|
|
271
|
+
selfMs: +(us / 1000).toFixed(1),
|
|
272
|
+
};
|
|
273
|
+
})
|
|
274
|
+
.sort((a, b) => b.selfMs - a.selfMs)
|
|
275
|
+
.slice(0, topN);
|
|
276
|
+
const totalMs = deltas.reduce((a, b) => a + b, 0) / 1000;
|
|
277
|
+
return { totalMs: +totalMs.toFixed(1), sampleCount: samples.length, topFunctions };
|
|
278
|
+
}
|
|
279
|
+
const workerIndexProp = { type: 'integer', minimum: 0, description: '0-based worker thread index' };
|
|
280
|
+
function buildInspectorTools(deps) {
|
|
281
|
+
const attach = {
|
|
282
|
+
def: {
|
|
283
|
+
name: 'inspector_attach',
|
|
284
|
+
description: 'Attach the V8 inspector to a worker thread so it can be evaluated, breakpointed, or CPU-profiled. Requires threads_debug + threads_debug_startingPort. Rejects the main thread.',
|
|
285
|
+
parameters: { type: 'object', properties: { workerIndex: workerIndexProp }, required: ['workerIndex'] },
|
|
286
|
+
},
|
|
287
|
+
handler: async (args, ctx) => {
|
|
288
|
+
const workerIndex = toWorkerIndex(args.workerIndex);
|
|
289
|
+
const port = resolvePort(deps, workerIndex);
|
|
290
|
+
const session = await sessionFor(port, deps.host, ctx.signal);
|
|
291
|
+
await session.send('Runtime.enable', {}, ctx.signal);
|
|
292
|
+
await session.send('Debugger.enable', {}, ctx.signal);
|
|
293
|
+
return { attached: true, workerIndex, port, target: session.title };
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
const evaluate = {
|
|
297
|
+
def: {
|
|
298
|
+
name: 'inspector_evaluate',
|
|
299
|
+
description: 'Evaluate a JavaScript expression in a worker thread and return the result. Runs arbitrary code in the worker.',
|
|
300
|
+
parameters: {
|
|
301
|
+
type: 'object',
|
|
302
|
+
properties: {
|
|
303
|
+
workerIndex: workerIndexProp,
|
|
304
|
+
expression: { type: 'string' },
|
|
305
|
+
awaitPromise: { type: 'boolean', description: 'Await the result if it is a promise.' },
|
|
306
|
+
},
|
|
307
|
+
required: ['workerIndex', 'expression'],
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
destructive: true, // arbitrary in-worker code execution
|
|
311
|
+
handler: async (args, ctx) => {
|
|
312
|
+
const port = resolvePort(deps, toWorkerIndex(args.workerIndex));
|
|
313
|
+
const session = await sessionFor(port, deps.host, ctx.signal);
|
|
314
|
+
await session.send('Runtime.enable', {}, ctx.signal);
|
|
315
|
+
const res = await session.send('Runtime.evaluate', { expression: String(args.expression), returnByValue: true, awaitPromise: !!args.awaitPromise }, ctx.signal);
|
|
316
|
+
if (res.exceptionDetails) {
|
|
317
|
+
throw new Error(res.exceptionDetails.exception?.description ?? res.exceptionDetails.text ?? 'evaluation threw');
|
|
318
|
+
}
|
|
319
|
+
return { value: res.result?.value, type: res.result?.type };
|
|
320
|
+
},
|
|
321
|
+
};
|
|
322
|
+
const setBreakpoint = {
|
|
323
|
+
def: {
|
|
324
|
+
name: 'inspector_set_breakpoint',
|
|
325
|
+
description: 'Set a breakpoint by script URL + line in a worker. lineNumber is 0-based (CDP). On hit, a stack snapshot is written to the Harper log and the worker is auto-resumed (it is NOT left paused).',
|
|
326
|
+
parameters: {
|
|
327
|
+
type: 'object',
|
|
328
|
+
properties: {
|
|
329
|
+
workerIndex: workerIndexProp,
|
|
330
|
+
url: { type: 'string', description: 'Exact script URL (usually file:///…) to break in.' },
|
|
331
|
+
lineNumber: { type: 'integer', minimum: 0, description: '0-based line number.' },
|
|
332
|
+
columnNumber: { type: 'integer', minimum: 0 },
|
|
333
|
+
condition: { type: 'string', description: 'Optional JS condition; breaks only when it is truthy.' },
|
|
334
|
+
},
|
|
335
|
+
required: ['workerIndex', 'url', 'lineNumber'],
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
destructive: true, // runs a condition in the worker; a hit briefly pauses it before auto-resume
|
|
339
|
+
handler: async (args, ctx) => {
|
|
340
|
+
const port = resolvePort(deps, toWorkerIndex(args.workerIndex));
|
|
341
|
+
const session = await sessionFor(port, deps.host, ctx.signal);
|
|
342
|
+
await session.send('Debugger.enable', {}, ctx.signal);
|
|
343
|
+
const res = await session.send('Debugger.setBreakpointByUrl', {
|
|
344
|
+
url: String(args.url),
|
|
345
|
+
lineNumber: Number(args.lineNumber),
|
|
346
|
+
...(args.columnNumber != null ? { columnNumber: Number(args.columnNumber) } : {}),
|
|
347
|
+
...(args.condition ? { condition: String(args.condition) } : {}),
|
|
348
|
+
}, ctx.signal);
|
|
349
|
+
return { breakpointId: res.breakpointId, locations: res.locations };
|
|
350
|
+
},
|
|
351
|
+
};
|
|
352
|
+
const setLogpoint = {
|
|
353
|
+
def: {
|
|
354
|
+
name: 'inspector_set_logpoint',
|
|
355
|
+
description: 'Set a non-pausing logpoint: logs an expression each time the line is hit, without stopping the worker. lineNumber is 0-based. Runs the expression in the worker.',
|
|
356
|
+
parameters: {
|
|
357
|
+
type: 'object',
|
|
358
|
+
properties: {
|
|
359
|
+
workerIndex: workerIndexProp,
|
|
360
|
+
url: { type: 'string', description: 'Exact script URL (usually file:///…).' },
|
|
361
|
+
lineNumber: { type: 'integer', minimum: 0, description: '0-based line number.' },
|
|
362
|
+
logExpression: { type: 'string', description: 'JS expression whose value is logged on each hit.' },
|
|
363
|
+
},
|
|
364
|
+
required: ['workerIndex', 'url', 'lineNumber', 'logExpression'],
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
destructive: true, // runs an arbitrary expression in the worker on every hit
|
|
368
|
+
handler: async (args, ctx) => {
|
|
369
|
+
const port = resolvePort(deps, toWorkerIndex(args.workerIndex));
|
|
370
|
+
const session = await sessionFor(port, deps.host, ctx.signal);
|
|
371
|
+
await session.send('Debugger.enable', {}, ctx.signal);
|
|
372
|
+
// A logpoint is a breakpoint whose condition logs and returns false, so it never pauses. The
|
|
373
|
+
// expression is JSON-encoded into a string and eval'd (not spliced as raw code), so it can't
|
|
374
|
+
// break out of the wrapper to force a pause; a stray pause would auto-resume anyway (see
|
|
375
|
+
// openCdp). Direct eval keeps the paused frame's locals in scope.
|
|
376
|
+
const condition = `(function(){try{console.log('[agent logpoint]',eval(${JSON.stringify(String(args.logExpression))}));}catch(e){}return false;})()`;
|
|
377
|
+
const res = await session.send('Debugger.setBreakpointByUrl', { url: String(args.url), lineNumber: Number(args.lineNumber), condition }, ctx.signal);
|
|
378
|
+
return { breakpointId: res.breakpointId, locations: res.locations };
|
|
379
|
+
},
|
|
380
|
+
};
|
|
381
|
+
const profileCpu = {
|
|
382
|
+
def: {
|
|
383
|
+
name: 'inspector_profile_cpu',
|
|
384
|
+
description: 'Record a CPU profile of a worker for durationMs and return the hottest functions by self time.',
|
|
385
|
+
parameters: {
|
|
386
|
+
type: 'object',
|
|
387
|
+
properties: {
|
|
388
|
+
workerIndex: workerIndexProp,
|
|
389
|
+
durationMs: { type: 'integer', minimum: 100, maximum: 60000 },
|
|
390
|
+
topN: {
|
|
391
|
+
type: 'integer',
|
|
392
|
+
minimum: 1,
|
|
393
|
+
maximum: 50,
|
|
394
|
+
description: 'How many hot functions to return (default 15).',
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
required: ['workerIndex', 'durationMs'],
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
handler: async (args, ctx) => {
|
|
401
|
+
const port = resolvePort(deps, toWorkerIndex(args.workerIndex));
|
|
402
|
+
const duration = Math.min(Math.max(Number(args.durationMs), 100), 60000);
|
|
403
|
+
const session = await sessionFor(port, deps.host, ctx.signal);
|
|
404
|
+
await session.send('Profiler.enable', {}, ctx.signal);
|
|
405
|
+
await session.send('Profiler.start', {}, ctx.signal);
|
|
406
|
+
let stopped;
|
|
407
|
+
try {
|
|
408
|
+
await sleep(duration, ctx.signal);
|
|
409
|
+
}
|
|
410
|
+
finally {
|
|
411
|
+
// Always stop + disable the profiler even if aborted, so we don't leave it running on the worker.
|
|
412
|
+
stopped = await session.send('Profiler.stop').catch(() => undefined);
|
|
413
|
+
await session.send('Profiler.disable').catch(() => { });
|
|
414
|
+
}
|
|
415
|
+
if (!stopped?.profile)
|
|
416
|
+
throw new Error('profiling produced no profile');
|
|
417
|
+
return summarizeProfile(stopped.profile, args.topN ? Number(args.topN) : 15);
|
|
418
|
+
},
|
|
419
|
+
};
|
|
420
|
+
return [attach, evaluate, setBreakpoint, setLogpoint, profileCpu];
|
|
421
|
+
}
|
|
422
|
+
/** Close all live inspector connections (agent shutdown / test teardown). Handles in-flight opens. */
|
|
423
|
+
function _closeInspectorSessions() {
|
|
424
|
+
for (const promise of sessions.values())
|
|
425
|
+
promise.then((s) => s.close()).catch(() => { });
|
|
426
|
+
sessions.clear();
|
|
427
|
+
}
|
|
428
|
+
//# sourceMappingURL=inspectorTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspectorTool.js","sourceRoot":"","sources":["../../../agent/tools/inspectorTool.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;AA+OH,4CAwBC;AAID,kDAkKC;AAGD,0DAGC;AAjbD,4CAA2B;AAC3B,8FAAkE;AAGlE,MAAM,GAAG,GAAG,0BAAY,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;AAEhD,MAAM,uBAAuB,GAAG,MAAM,CAAC;AACvC,MAAM,YAAY,GAAG,KAAK,CAAC;AAoB3B,6FAA6F;AAC7F,6EAA6E;AAC7E,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA+B,CAAC;AAExD,2GAA2G;AAC3G,SAAS,aAAa,CAAC,GAAY;IAClC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IACjE,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAAE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;IACtG,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;AACnD,CAAC;AAED;;;;GAIG;AACH,SAAS,WAAW,CAAC,IAAmB,EAAE,WAAmB;IAC5D,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;QACxB,M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C,+BAA+B,CAAC,CAAC;YACxE,OAAO,gBAAgB,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC9E,CAAC;KACD,CAAC;IAEF,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;AACnE,CAAC;AAED,sGAAsG;AACtG,SAAgB,uBAAuB;IACtC,KAAK,MAAM,OAAO,IAAI,QAAQ,CAAC,MAAM,EAAE;QAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACxF,QAAQ,CAAC,KAAK,EAAE,CAAC;AAClB,CAAC"}
|
package/dist/agent/toolset.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tool composer for the built-in agent (#626).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
4
|
+
* Two sources merge here: operator-only tools (FS, schedule, fetch, inspector)
|
|
5
|
+
* that are private to this component, and RBAC-filtered tools drained from the
|
|
6
|
+
* unified MCP tool registry (#615) for the agent's configured user — the
|
|
7
|
+
* Operations profile (#617) today, adapted in `registryTools.ts`. Operator-only
|
|
8
|
+
* tools win on a name collision: a private tool must never be shadowed by a
|
|
9
|
+
* same-named registry tool, since the two have different runtime assumptions.
|
|
10
10
|
*/
|
|
11
11
|
import { type ScheduleToolDeps, type ScheduledFollowup } from './tools/scheduleTool.ts';
|
|
12
12
|
import type { AgentTool } from './types.ts';
|
|
@@ -15,6 +15,16 @@ export interface ComposeToolsetOpts extends ScheduleToolDeps {
|
|
|
15
15
|
allowDestructive?: boolean;
|
|
16
16
|
/** Operator-injected extras (tests, custom plugins). */
|
|
17
17
|
extraTools?: AgentTool[];
|
|
18
|
+
/**
|
|
19
|
+
* V8 inspector (CDP) tools, built from runtime debug config (`buildInspectorTools`).
|
|
20
|
+
* Operator-only, like the FS/schedule/fetch tools.
|
|
21
|
+
*/
|
|
22
|
+
inspectorTools?: AgentTool[];
|
|
23
|
+
/**
|
|
24
|
+
* RBAC-filtered registry tools for the agent's configured user (from
|
|
25
|
+
* `composeRegistryTools`). Shadowed by any operator-only tool of the same name.
|
|
26
|
+
*/
|
|
27
|
+
registryTools?: AgentTool[];
|
|
18
28
|
}
|
|
19
29
|
export interface ComposedToolset {
|
|
20
30
|
tools: AgentTool[];
|
package/dist/agent/toolset.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Tool composer for the built-in agent (#626).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
5
|
+
* Two sources merge here: operator-only tools (FS, schedule, fetch, inspector)
|
|
6
|
+
* that are private to this component, and RBAC-filtered tools drained from the
|
|
7
|
+
* unified MCP tool registry (#615) for the agent's configured user — the
|
|
8
|
+
* Operations profile (#617) today, adapted in `registryTools.ts`. Operator-only
|
|
9
|
+
* tools win on a name collision: a private tool must never be shadowed by a
|
|
10
|
+
* same-named registry tool, since the two have different runtime assumptions.
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.composeToolset = composeToolset;
|
|
@@ -17,7 +17,17 @@ const httpFetchTool_ts_1 = require("./tools/httpFetchTool.js");
|
|
|
17
17
|
const scheduleTool_ts_1 = require("./tools/scheduleTool.js");
|
|
18
18
|
function composeToolset(opts) {
|
|
19
19
|
const schedule = (0, scheduleTool_ts_1.buildScheduleTool)(opts);
|
|
20
|
-
|
|
20
|
+
// Operator-only tools first — they own their names. Registry tools that collide are dropped.
|
|
21
|
+
const operator = [
|
|
22
|
+
...fsTools_ts_1.fsTools,
|
|
23
|
+
httpFetchTool_ts_1.httpFetchTool,
|
|
24
|
+
schedule.tool,
|
|
25
|
+
...(opts.inspectorTools ?? []),
|
|
26
|
+
...(opts.extraTools ?? []),
|
|
27
|
+
];
|
|
28
|
+
const operatorNames = new Set(operator.map((t) => t.def.name));
|
|
29
|
+
const registry = (opts.registryTools ?? []).filter((t) => !operatorNames.has(t.def.name));
|
|
30
|
+
const all = [...operator, ...registry];
|
|
21
31
|
const tools = opts.allowDestructive === false ? all.filter((t) => !t.destructive) : all;
|
|
22
32
|
return { tools, scheduled: schedule.pending };
|
|
23
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolset.js","sourceRoot":"","sources":["../../agent/toolset.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;
|
|
1
|
+
{"version":3,"file":"toolset.js","sourceRoot":"","sources":["../../agent/toolset.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AA6BH,wCAeC;AAED,sCAOC;AAnDD,mDAA6C;AAC7C,+DAAyD;AACzD,6DAA2G;AAyB3G,SAAgB,cAAc,CAAC,IAAwB;IACtD,MAAM,QAAQ,GAAG,IAAA,mCAAiB,EAAC,IAAI,CAAC,CAAC;IACzC,6FAA6F;IAC7F,MAAM,QAAQ,GAAgB;QAC7B,GAAG,oBAAO;QACV,gCAAa;QACb,QAAQ,CAAC,IAAI;QACb,GAAG,CAAC,IAAI,CAAC,cAAc,IAAI,EAAE,CAAC;QAC9B,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC;KAC1B,CAAC;IACF,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/D,MAAM,QAA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