@chengchenccc/oh-my-agent 0.2.0-rc.3 → 0.2.0-rc.5
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/cli/args.d.ts +6 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +47 -0
- package/dist/cli/gateway-commands.d.ts +12 -0
- package/dist/cli/gateway-commands.d.ts.map +1 -1
- package/dist/cli/gateway-commands.js +11 -6
- package/dist/cli/update-command.d.ts +57 -0
- package/dist/cli/update-command.d.ts.map +1 -0
- package/dist/cli/update-command.js +220 -0
- package/dist/core/gateway/doctor.d.ts +18 -0
- package/dist/core/gateway/doctor.d.ts.map +1 -1
- package/dist/core/gateway/doctor.js +109 -1
- package/dist/core/runtime/agent-event.d.ts +19 -1
- package/dist/core/runtime/agent-event.d.ts.map +1 -1
- package/dist/core/runtime/agent-loop-run.d.ts.map +1 -1
- package/dist/core/runtime/agent-loop-run.js +43 -8
- package/dist/core/runtime/agent-loop-runner.d.ts.map +1 -1
- package/dist/core/runtime/agent-loop-runner.js +19 -0
- package/dist/core/runtime/agent-loop-types.d.ts +2 -0
- package/dist/core/runtime/agent-loop-types.d.ts.map +1 -1
- package/dist/core/runtime/approval.d.ts +7 -1
- package/dist/core/runtime/approval.d.ts.map +1 -1
- package/dist/core/runtime/approval.js +7 -1
- package/dist/core/runtime/plugin.d.ts +10 -1
- package/dist/core/runtime/plugin.d.ts.map +1 -1
- package/dist/core/runtime/run-runtime.d.ts +14 -0
- package/dist/core/runtime/run-runtime.d.ts.map +1 -1
- package/dist/core/runtime/run-runtime.js +46 -12
- package/dist/core/runtime/runtime-catalog.js +17 -4
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +10 -0
- package/dist/core/tools/eval.d.ts.map +1 -1
- package/dist/core/tools/eval.js +7 -0
- package/dist/core/tools/file-tools.d.ts.map +1 -1
- package/dist/core/tools/file-tools.js +20 -0
- package/dist/core/tools/glob.d.ts.map +1 -1
- package/dist/core/tools/glob.js +5 -0
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +29 -0
- package/dist/core/tools/mcp-mount.d.ts +17 -0
- package/dist/core/tools/mcp-mount.d.ts.map +1 -1
- package/dist/core/tools/mcp-mount.js +31 -8
- package/dist/core/tools/presentation.d.ts +19 -0
- package/dist/core/tools/presentation.d.ts.map +1 -0
- package/dist/core/tools/presentation.js +139 -0
- package/dist/core/update/release.d.ts +46 -0
- package/dist/core/update/release.d.ts.map +1 -0
- package/dist/core/update/release.js +119 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +21 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +23 -5
- package/dist/modes/tui/tui-mode.d.ts.map +1 -1
- package/dist/modes/tui/tui-mode.js +16 -0
- package/dist/modes/tui/tui-seam.d.ts +5 -0
- package/dist/modes/tui/tui-seam.d.ts.map +1 -1
- package/dist/protocol/mapping.d.ts +14 -0
- package/dist/protocol/mapping.d.ts.map +1 -1
- package/dist/protocol/mapping.js +68 -1
- package/package.json +11 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-event.d.ts","sourceRoot":"","sources":["../../../src/core/runtime/agent-event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEvD,0DAA0D;AAC1D,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"agent-event.d.ts","sourceRoot":"","sources":["../../../src/core/runtime/agent-event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEvD,0DAA0D;AAC1D,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,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AC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,GACD;IACE,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,OAAO,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB,GACD;IAAE,IAAI,EAAE,yBAAyB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACnE;IACE,+DAA+D;IAC/D,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,YAAY,CAAC;CACrB,CAAC;AAEN,MAAM,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-loop-run.d.ts","sourceRoot":"","sources":["../../../src/core/runtime/agent-loop-run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAE1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-loop-run.d.ts","sourceRoot":"","sources":["../../../src/core/runtime/agent-loop-run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAE1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACr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IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC,CAwNvF;AAED,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,OAAO,EAAE,CAAC,CA0BpB;AAGD,YAAY,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { debugLog } from "@chengchenccc/agent-contract";
|
|
2
|
+
import { normalizeToolPresentation, presentationActivity, safeToolSummary, } from "../tools/presentation.js";
|
|
2
3
|
import { matchStreamRule, safeParseJson } from "./agent-loop-utils.js";
|
|
4
|
+
import { approvalTimeoutMs, withApprovalDeadline } from "./approval.js";
|
|
3
5
|
import { latestCompaction } from "./compaction.js";
|
|
4
6
|
import { retryStream } from "./retry.js";
|
|
5
7
|
/** Coalesce consecutive same-kind stream deltas into one TurnBlock.
|
|
@@ -122,13 +124,33 @@ export async function executeTools(ctx, calls) {
|
|
|
122
124
|
async function runOne(call) {
|
|
123
125
|
const tool = toolMap.get(call.name);
|
|
124
126
|
debugLog("oma", `tool_start runId=${state.debugRunId} name=${call.name} callId=${call.id}`);
|
|
125
|
-
|
|
127
|
+
const startEvent = {
|
|
126
128
|
type: "tool_execution_start",
|
|
127
129
|
toolName: call.name,
|
|
128
|
-
|
|
130
|
+
// Stays inside oma (transcript/TUI); never crosses the RPC boundary.
|
|
129
131
|
input: call.input,
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
+
callId: call.id,
|
|
133
|
+
};
|
|
134
|
+
// The activity line is what leaves the process: the tool picks what is
|
|
135
|
+
// meaningful about its input, safeToolSummary makes it safe to display.
|
|
136
|
+
// The structured presentation rides alongside; surfaces prefer it.
|
|
137
|
+
const described = tool?.describeStart?.(call.input);
|
|
138
|
+
if (described !== undefined) {
|
|
139
|
+
const fallback = `正在调用 ${call.name}`;
|
|
140
|
+
const presentation = normalizeToolPresentation(described, fallback);
|
|
141
|
+
if (presentation) {
|
|
142
|
+
startEvent.presentation = presentation;
|
|
143
|
+
}
|
|
144
|
+
startEvent.activity =
|
|
145
|
+
typeof described === "string"
|
|
146
|
+
? safeToolSummary(described, fallback)
|
|
147
|
+
: presentation
|
|
148
|
+
? presentationActivity(presentation)
|
|
149
|
+
: fallback;
|
|
150
|
+
}
|
|
151
|
+
if (tool?.timeoutMs !== undefined)
|
|
152
|
+
startEvent.timeoutMs = tool.timeoutMs;
|
|
153
|
+
await emit(startEvent);
|
|
132
154
|
let result;
|
|
133
155
|
let isError = false;
|
|
134
156
|
let terminate = false;
|
|
@@ -208,13 +230,13 @@ export async function executeTools(ctx, calls) {
|
|
|
208
230
|
},
|
|
209
231
|
...(opts.approvalHandler
|
|
210
232
|
? {
|
|
211
|
-
request: (req) => opts.approvalHandler({
|
|
233
|
+
request: (req) => withApprovalDeadline(opts.approvalHandler({
|
|
212
234
|
callId: call.id,
|
|
213
235
|
toolName: call.name,
|
|
214
236
|
input,
|
|
215
237
|
source: "tool",
|
|
216
238
|
...(req.reason ? { reason: req.reason } : {}),
|
|
217
|
-
}),
|
|
239
|
+
}), approvalTimeoutMs()),
|
|
218
240
|
}
|
|
219
241
|
: {}),
|
|
220
242
|
...(opts.askHandler ? { ask: opts.askHandler } : {}),
|
|
@@ -239,12 +261,25 @@ export async function executeTools(ctx, calls) {
|
|
|
239
261
|
isError = true;
|
|
240
262
|
}
|
|
241
263
|
debugLog("oma", `tool_end runId=${state.debugRunId} name=${call.name} callId=${call.id} error=${isError}`);
|
|
242
|
-
|
|
264
|
+
const endEvent = {
|
|
243
265
|
type: "tool_execution_end",
|
|
244
266
|
toolName: call.name,
|
|
245
267
|
callId: call.id,
|
|
246
268
|
result: (result ?? {}),
|
|
247
|
-
}
|
|
269
|
+
};
|
|
270
|
+
// Result-side summary: the tool decides what about its result is safe and
|
|
271
|
+
// useful to show ("命中 6 处,涉及 3 个文件"); the raw result stays inside.
|
|
272
|
+
const describedResult = tool?.describeResult?.(call.input, result);
|
|
273
|
+
if (describedResult !== undefined) {
|
|
274
|
+
const fallback = call.name;
|
|
275
|
+
const presentation = normalizeToolPresentation(describedResult, fallback);
|
|
276
|
+
if (presentation) {
|
|
277
|
+
endEvent.presentation = isError
|
|
278
|
+
? { ...presentation, errorSummary: presentation.errorSummary ?? presentation.title }
|
|
279
|
+
: presentation;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
await emit(endEvent);
|
|
248
283
|
// afterTool: observe (emit event) or patch (override result fields).
|
|
249
284
|
for (const p of opts.plugins) {
|
|
250
285
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-loop-runner.d.ts","sourceRoot":"","sources":["../../../src/core/runtime/agent-loop-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAY,MAAM,8BAA8B,CAAC;AAIlF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAMrD,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EAGpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAQ1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKzD,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,eAAe,GAAG,IAAI,CAAC;IACnC,EAAE,EAAE,aAAa,CAAC;IAClB,UAAU,EAAE,mBAAmB,EAAE,CAAC;IAClC,cAAc,EAAE,OAAO,C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UAAU,EAAE,eAAe,GAAG,IAAI,CAAC;IACnC,EAAE,EAAE,aAAa,CAAC;IAClB,UAAU,EAAE,mBAAmB,EAAE,CAAC;IAClC,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,iBAAiB,CAAC;IACxB,IAAI,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,OAAO,EAAE,CAAC,OAAO,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3E,KAAK,EAAE,gBAAgB,CAAC;IACxB,UAAU,EAAE,cAAc,CAAC;IAC3B,OAAO,EAAE,MAAM,eAAe,CAAC;IAC/B,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,SAAS,EAAE,SAAS,UAAU,EAAE,CAAC;IACjC,OAAO,EAAE,iBAAiB,CAAC;CAC5B;AA8fD;;;;;;;;GAQG;AACH,wBAAsB,OAAO,CAC3B,GAAG,EAAE,iBAAiB,EACtB,WAAW,EAAE,eAAe,EAC5B,IAAI,EAAE,QAAQ,GAAG,WAAW,GAC3B,OAAO,CAAC,aAAa,CAAC,CAuFxB"}
|
|
@@ -8,6 +8,9 @@ import { buildLoopInput } from "./loop-input.js";
|
|
|
8
8
|
import { renderLoopMeta } from "./prompt.js";
|
|
9
9
|
import { buildTitleContext, generateTitleAndSummary } from "./title.js";
|
|
10
10
|
import { pruneOldToolResults } from "./tool-pruning.js";
|
|
11
|
+
/** Default liveness cadence: often enough that a silence watchdog notices
|
|
12
|
+
* within a minute, rare enough to be free (heartbeats are transient). */
|
|
13
|
+
const DEFAULT_HEARTBEAT_MS = 15_000;
|
|
11
14
|
/** Start the loop: bind runtime, resolve tools, persist the prompt, and
|
|
12
15
|
* return the system prompt + first branch messages. */
|
|
13
16
|
async function prepareLoopStart(ctx, codingInput, mode) {
|
|
@@ -457,6 +460,20 @@ async function runModelTurnLoop(ctx, stepState) {
|
|
|
457
460
|
export async function runLoop(ctx, codingInput, mode) {
|
|
458
461
|
const { opts, emit, state, mutable } = ctx;
|
|
459
462
|
let runError;
|
|
463
|
+
// Liveness: the parent cannot tell a working-but-quiet child from a stuck
|
|
464
|
+
// one, so the loop proves it is alive. Without this a run whose child stops
|
|
465
|
+
// reporting ends only at the 30-minute wall clock (live, 2026-09-25); with
|
|
466
|
+
// it the parent's silence watchdog can settle in a minute.
|
|
467
|
+
const heartbeatMs = opts.heartbeatIntervalMs ?? DEFAULT_HEARTBEAT_MS;
|
|
468
|
+
const heartbeat = heartbeatMs > 0
|
|
469
|
+
? setInterval(() => {
|
|
470
|
+
void Promise.resolve(emit({ type: "heartbeat" })).catch(() => {
|
|
471
|
+
/* liveness is best-effort */
|
|
472
|
+
});
|
|
473
|
+
}, heartbeatMs)
|
|
474
|
+
: null;
|
|
475
|
+
if (heartbeat && typeof heartbeat.unref === "function")
|
|
476
|
+
heartbeat.unref();
|
|
460
477
|
try {
|
|
461
478
|
const { systemPrompt, messages: initialMessages } = await prepareLoopStart(ctx, codingInput, mode);
|
|
462
479
|
const stepState = {
|
|
@@ -517,6 +534,8 @@ export async function runLoop(ctx, codingInput, mode) {
|
|
|
517
534
|
return { status: finalStatus, usage: state.runUsage, error: runError };
|
|
518
535
|
}
|
|
519
536
|
finally {
|
|
537
|
+
if (heartbeat)
|
|
538
|
+
clearInterval(heartbeat);
|
|
520
539
|
mutable.active = false;
|
|
521
540
|
mutable.controller = null;
|
|
522
541
|
mutable.steerQueue.length = 0;
|
|
@@ -33,6 +33,8 @@ export interface OmaSessionOptions {
|
|
|
33
33
|
readonly store: SessionStore;
|
|
34
34
|
readonly plugins: readonly Plugin[];
|
|
35
35
|
readonly maxSteps: number;
|
|
36
|
+
/** Liveness heartbeat cadence (ms). 0 disables it; tests shorten it. */
|
|
37
|
+
readonly heartbeatIntervalMs?: number;
|
|
36
38
|
readonly maxForceContinues: number;
|
|
37
39
|
/** The model call for one turn. */
|
|
38
40
|
readonly modelStream: (messages: readonly Message[], signal?: AbortSignal,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-loop-types.d.ts","sourceRoot":"","sources":["../../../src/core/runtime/agent-loop-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,KAAK,EACN,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,0EAA0E;AAC1E,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED;;;0CAG0C;AAC1C,MAAM,MAAM,iBAAiB,GAAG,CAC9B,QAAQ,EAAE,SAAS,OAAO,EAAE,EAC5B,MAAM,CAAC,EAAE,WAAW,KACjB,OAAO,CAAC,MAAM,CAAC,CAAC;AAErB;;;qDAGqD;AACrD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AAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5F,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,SAAS,SAAS,EAAE,CAAC;IACvC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,SAAS,eAAe,EAAE,CAAC;IAC/C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B;sEACkE;IAClE,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAC3B;6DACyD;IACzD,QAAQ,CAAC,aAAa,CAAC,EAAE,UAAU,CAAC;CACrC"}
|
|
@@ -19,7 +19,13 @@ export interface ApprovalDecision {
|
|
|
19
19
|
readonly reason?: string;
|
|
20
20
|
}
|
|
21
21
|
export type ApprovalHandler = (req: ApprovalRequest) => Promise<ApprovalDecision>;
|
|
22
|
-
|
|
22
|
+
/** How long an approval may wait for a human before it fails closed.
|
|
23
|
+
* HITL over a chat surface means hours — the person may read the card the
|
|
24
|
+
* next morning — so the default is a day (user decision 2026-09-25, after
|
|
25
|
+
* two minutes routinely denied requests nobody had seen yet). Interactive
|
|
26
|
+
* surfaces that cannot wait still fail closed on their own (print/json use
|
|
27
|
+
* denyAllApprovals). `OMA_APPROVAL_TIMEOUT_MS` overrides; 0 = wait. */
|
|
28
|
+
export declare const DEFAULT_APPROVAL_TIMEOUT_MS: number;
|
|
23
29
|
export declare function approvalTimeoutMs(): number;
|
|
24
30
|
/** Resolve with a deadline; a silent human fails closed (deny). 0 = wait. */
|
|
25
31
|
export declare function withApprovalDeadline(p: Promise<ApprovalDecision>, timeoutMs: number): Promise<ApprovalDecision>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../../../src/core/runtime/approval.ts"],"names":[],"mappings":"AAAA;;+BAE+B;AAE/B,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB;iEAC6D;IAC7D,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,GAAG,YAAY,CAAC;IACtD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;sDAEkD;IAClD,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAAC;IACpC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAElF,eAAO,MAAM,2BAA2B,
|
|
1
|
+
{"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../../../src/core/runtime/approval.ts"],"names":[],"mappings":"AAAA;;+BAE+B;AAE/B,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB;iEAC6D;IAC7D,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,GAAG,YAAY,CAAC;IACtD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;sDAEkD;IAClD,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAAC;IACpC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAElF;;;;;wEAKwE;AACxE,eAAO,MAAM,2BAA2B,QAAmB,CAAC;AAE5D,wBAAgB,iBAAiB,IAAI,MAAM,CAI1C;AAED,6EAA6E;AAC7E,wBAAgB,oBAAoB,CAClC,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,EAC5B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,gBAAgB,CAAC,CAW3B;AAED,wEAAwE;AACxE,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAKhF"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
/** HITL approval (spec: 2026-08-26-plugin-trust-model-design.md): one handler
|
|
2
2
|
* type, three resolution pipelines (tui overlay / print+json fail-closed /
|
|
3
3
|
* rpc wire with deadline). */
|
|
4
|
-
|
|
4
|
+
/** How long an approval may wait for a human before it fails closed.
|
|
5
|
+
* HITL over a chat surface means hours — the person may read the card the
|
|
6
|
+
* next morning — so the default is a day (user decision 2026-09-25, after
|
|
7
|
+
* two minutes routinely denied requests nobody had seen yet). Interactive
|
|
8
|
+
* surfaces that cannot wait still fail closed on their own (print/json use
|
|
9
|
+
* denyAllApprovals). `OMA_APPROVAL_TIMEOUT_MS` overrides; 0 = wait. */
|
|
10
|
+
export const DEFAULT_APPROVAL_TIMEOUT_MS = 24 * 60 * 60_000;
|
|
5
11
|
export function approvalTimeoutMs() {
|
|
6
12
|
const raw = process.env.OMA_APPROVAL_TIMEOUT_MS;
|
|
7
13
|
const n = raw === undefined ? DEFAULT_APPROVAL_TIMEOUT_MS : Number(raw);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AskQuestionInput, AskQuestionResult } from "@chengchenccc/agent-contract";
|
|
1
|
+
import type { AskQuestionInput, AskQuestionResult, ToolPresentation } from "@chengchenccc/agent-contract";
|
|
2
2
|
import type { Message } from "@chengchenccc/message";
|
|
3
3
|
import type { OmaLoopEvent } from "./agent-event.js";
|
|
4
4
|
import type { ApprovalDecision } from "./approval.js";
|
|
@@ -10,6 +10,15 @@ export interface PluginTool {
|
|
|
10
10
|
/** "serial" (default) = must run alone; "concurrent" = read-only, safe to
|
|
11
11
|
* run in parallel with other concurrent tools in the same turn. */
|
|
12
12
|
readonly executionMode?: "serial" | "concurrent";
|
|
13
|
+
/** What this call is DOING, in one short user-visible line. Native tools
|
|
14
|
+
* declare it on the `@chengchenccc/message` Tool contract (see
|
|
15
|
+
* `Tool.describeStart`); the loop reads it off the runtime's PluginTool
|
|
16
|
+
* shape, so it is declared here too. The text crosses the process boundary
|
|
17
|
+
* to every surface — never return raw args. A plain string is the
|
|
18
|
+
* shorthand (title only); the structured form adds detail/icon. */
|
|
19
|
+
describeStart?(input: unknown): ToolPresentation | string | undefined;
|
|
20
|
+
/** What the call produced, summarized safely (never the raw result). */
|
|
21
|
+
describeResult?(input: unknown, result: unknown): ToolPresentation | string | undefined;
|
|
13
22
|
/** Wall-clock timeout for this tool in ms (0 = disabled). Shown in the
|
|
14
23
|
* TUI tool card and surfaced on tool_execution_start for live display. */
|
|
15
24
|
readonly timeoutMs?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/core/runtime/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/core/runtime/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC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AQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,aAAa,GAAG,OAAO,CAAC;IAEjF;+DAC2D;IAC3D,UAAU,CAAC,CAAC,MAAM,EAAE,MAAM,IAAI,EAAE,EAAE,EAAE,aAAa,GAAG,IAAI,CAAC;IACzD;;wDAEoD;IACpD,SAAS,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,aAAa,GAAG,IAAI,CAAC;CACtD;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,MAAM,IAAI,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IACvC,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,mBAAmB,EAAE,CAAC;CAChD;AAED;;;;;;wBAMwB;AACxB,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAkBhE;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAK7D;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,UAAU,EAAE,CAErE"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type AgentRunSnapshot, type ProjectedHistoryItem } from "@chengchenccc/agent-contract";
|
|
2
2
|
import { type ModelRuntime, type ModelRuntimeEntry } from "@chengchenccc/ai";
|
|
3
|
+
import type { Tool } from "@chengchenccc/message";
|
|
3
4
|
import { type ContextBudget, type ContextSummarizer, type OmaSession, type Plugin, type PluginTool, type SessionStore } from "../index.js";
|
|
4
5
|
import type { PluginMcpConfig } from "../plugins/plugin-resolve.js";
|
|
5
6
|
import { type RuntimeKnobs } from "../settings/project-settings.js";
|
|
@@ -75,6 +76,19 @@ export interface RunRuntime {
|
|
|
75
76
|
* Run loops: register built-in providers from the process env. The fake
|
|
76
77
|
* deterministic provider is available for tests. */
|
|
77
78
|
export declare function registerBuiltinProviders(runtime: ModelRuntime, env?: Readonly<Record<string, string | undefined>>): void;
|
|
79
|
+
/** Adapt a tools-common `Tool` (sync-or-async, `{content}` result) to the
|
|
80
|
+
* runtime's PluginTool (always-async record result). Pure structural
|
|
81
|
+
* variance — the await normalizes the sync voice, the spread preserves the
|
|
82
|
+
* result object. Single adaptation point for every native tool.
|
|
83
|
+
*
|
|
84
|
+
* Fields are assigned unconditionally: PluginTool's optionals are not
|
|
85
|
+
* `exactOptionalPropertyTypes`-strict, and an undefined key is dropped by
|
|
86
|
+
* JSON.stringify on the way to the model.
|
|
87
|
+
*
|
|
88
|
+
* Exported so a test pins the adaptation: an optional field silently dropped
|
|
89
|
+
* here (describeStart, executionMode) disables a feature with every
|
|
90
|
+
* typecheck still green. */
|
|
91
|
+
export declare function toPluginTool(t: Tool): PluginTool;
|
|
78
92
|
/** Build the complete Runtime assembly for exactly ONE Run. The Run's
|
|
79
93
|
* in-memory SessionStore is created here (never shared with other Runs);
|
|
80
94
|
* the model is resolved per run from the AgentRunSnapshot. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-runtime.d.ts","sourceRoot":"","sources":["../../../src/core/runtime/run-runtime.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,gBAAgB,EAIrB,KAAK,oBAAoB,EAC1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,iBAAiB,EAAqB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"run-runtime.d.ts","sourceRoot":"","sources":["../../../src/core/runtime/run-runtime.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,gBAAgB,EAIrB,KAAK,oBAAoB,EAC1B,MAAM,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AAU,CAAC,CAkblF;AAED,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -159,13 +159,22 @@ async function nextBounded(iter, combined, timeoutSignal) {
|
|
|
159
159
|
/** Adapt a tools-common `Tool` (sync-or-async, `{content}` result) to the
|
|
160
160
|
* runtime's PluginTool (always-async record result). Pure structural
|
|
161
161
|
* variance — the await normalizes the sync voice, the spread preserves the
|
|
162
|
-
* result object. Single adaptation point for every native tool.
|
|
163
|
-
|
|
162
|
+
* result object. Single adaptation point for every native tool.
|
|
163
|
+
*
|
|
164
|
+
* Fields are assigned unconditionally: PluginTool's optionals are not
|
|
165
|
+
* `exactOptionalPropertyTypes`-strict, and an undefined key is dropped by
|
|
166
|
+
* JSON.stringify on the way to the model.
|
|
167
|
+
*
|
|
168
|
+
* Exported so a test pins the adaptation: an optional field silently dropped
|
|
169
|
+
* here (describeStart, executionMode) disables a feature with every
|
|
170
|
+
* typecheck still green. */
|
|
171
|
+
export function toPluginTool(t) {
|
|
164
172
|
return {
|
|
165
173
|
name: t.name,
|
|
166
174
|
description: t.description,
|
|
167
|
-
|
|
168
|
-
|
|
175
|
+
inputSchema: t.inputSchema,
|
|
176
|
+
executionMode: t.executionMode,
|
|
177
|
+
describeStart: t.describeStart,
|
|
169
178
|
async execute(args, signal, options) {
|
|
170
179
|
const result = await t.execute(args, signal, options);
|
|
171
180
|
return { ...result };
|
|
@@ -274,6 +283,23 @@ async function buildNativeToolStage(deps, ctx) {
|
|
|
274
283
|
mountedToolNames: new Set(mounted.tools.map((t) => t.name)),
|
|
275
284
|
};
|
|
276
285
|
}
|
|
286
|
+
/** Is a tool with this LEAF name among the mounted tools?
|
|
287
|
+
*
|
|
288
|
+
* Mounted tools carry their canonical `mcp__<server>__<tool>` name
|
|
289
|
+
* (mcp-mount.ts), so `mountedToolNames.has("todo_write")` was never true for
|
|
290
|
+
* an injected MCP todo: the "the specific injection wins over the built-in
|
|
291
|
+
* default" rule never fired, and BOTH tools were advertised. The agent then
|
|
292
|
+
* used the native one — whose file store is workspace-global, so one
|
|
293
|
+
* conversation's task list showed up inside another's run. Same trap as the
|
|
294
|
+
* wire filters that had to learn the leaf name; match the leaf, not the
|
|
295
|
+
* whole canonical name. */
|
|
296
|
+
function mountedProvidesLeaf(stage, leaf) {
|
|
297
|
+
for (const name of stage.mountedToolNames) {
|
|
298
|
+
if ((name.split("__").pop() ?? name) === leaf)
|
|
299
|
+
return true;
|
|
300
|
+
}
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
277
303
|
/** Model plumbing stage: everything bound to the RUN's model — display
|
|
278
304
|
* identity, the compaction summarizer (same provider/credentials, no
|
|
279
305
|
* catalog-first surprises), the context budget from the run model's
|
|
@@ -340,7 +366,7 @@ function buildModelPlumbing(deps, ctx) {
|
|
|
340
366
|
* per unique action. The factory also serves every workflow subagent —
|
|
341
367
|
* same policy, own intent texts. Absent permissionMode = ungated. */
|
|
342
368
|
function createRunPermissionGates(deps, ctx) {
|
|
343
|
-
const { knobs, store, streamModel, pluginCodeToolNames, approvalDeadlineMs } = ctx;
|
|
369
|
+
const { knobs, store, streamModel, pluginCodeToolNames, approvalDeadlineMs, bashSandboxed } = ctx;
|
|
344
370
|
// Native-tool permission gate (ADR 0020): "deny" blocks outright; "ask"
|
|
345
371
|
// routes high-risk tools through the SAME approvalHandler as plugin code
|
|
346
372
|
// tools (one pipeline). "auto" (CC auto-mode alignment, 2026-09) routes
|
|
@@ -439,14 +465,18 @@ function createRunPermissionGates(deps, ctx) {
|
|
|
439
465
|
};
|
|
440
466
|
}
|
|
441
467
|
escalatedActions.add(actionKey);
|
|
442
|
-
const
|
|
468
|
+
const escalation = {
|
|
443
469
|
// Same key discipline as the ask gate: the card must be resolvable.
|
|
444
470
|
callId: callId || `cls-${randomUUID().slice(0, 8)}`,
|
|
445
471
|
toolName,
|
|
446
472
|
input,
|
|
447
473
|
reason: `classifier: ${verdict.reason}`,
|
|
448
474
|
source: "classifier",
|
|
449
|
-
}
|
|
475
|
+
};
|
|
476
|
+
// Same truthful signal as the ask gate (BashSandbox design P4).
|
|
477
|
+
if (toolName === "bash")
|
|
478
|
+
escalation.sandboxed = bashSandboxed;
|
|
479
|
+
const human = await withApprovalDeadline(deps.approvalHandler(escalation), approvalDeadlineMs);
|
|
450
480
|
if (human.decision === "deny") {
|
|
451
481
|
return {
|
|
452
482
|
block: true,
|
|
@@ -517,10 +547,11 @@ function createRunPermissionGates(deps, ctx) {
|
|
|
517
547
|
input,
|
|
518
548
|
source: "permission",
|
|
519
549
|
};
|
|
520
|
-
// BashSandbox design P4:
|
|
521
|
-
//
|
|
550
|
+
// BashSandbox design P4: report the Run's REAL sandbox state so the
|
|
551
|
+
// human card can distinguish "runs inside bwrap/Seatbelt" from the
|
|
552
|
+
// unsandboxed fallback. A signal, not an authorization basis.
|
|
522
553
|
if (toolName === "bash")
|
|
523
|
-
approvalInput.sandboxed =
|
|
554
|
+
approvalInput.sandboxed = bashSandboxed;
|
|
524
555
|
let verdict;
|
|
525
556
|
try {
|
|
526
557
|
verdict = await withApprovalDeadline(deps.approvalHandler(approvalInput), approvalDeadlineMs);
|
|
@@ -830,7 +861,9 @@ export async function assembleRunRuntime(deps) {
|
|
|
830
861
|
// Native ask_question (oh-my-pi style HITL): same conflict rule as todo —
|
|
831
862
|
// the backend can inject its own MCP ask_question (product surfaces); the
|
|
832
863
|
// injected one wins, standalone workspaces get the native tool.
|
|
833
|
-
|
|
864
|
+
// Native ask_question (oh-my-pi style HITL): same conflict rule as todo —
|
|
865
|
+
// the injected product tool wins over the built-in default.
|
|
866
|
+
const hasInjectedAsk = mountedProvidesLeaf(toolStage, "ask_question");
|
|
834
867
|
const askAllowed = deps.toolFilter ? toolFilterAllows(deps.toolFilter, "ask_question") : true;
|
|
835
868
|
if (!hasInjectedAsk && askAllowed) {
|
|
836
869
|
plugins.push({
|
|
@@ -843,7 +876,7 @@ export async function assembleRunRuntime(deps) {
|
|
|
843
876
|
// RPC workspaces — the specific injection wins over the built-in default;
|
|
844
877
|
// standalone workspaces get the native one). One rule replaces the old
|
|
845
878
|
// per-mode enableNativeTodo flag.
|
|
846
|
-
const hasInjectedTodo = toolStage
|
|
879
|
+
const hasInjectedTodo = mountedProvidesLeaf(toolStage, "todo_write");
|
|
847
880
|
const todoAllowed = deps.toolFilter ? toolFilterAllows(deps.toolFilter, "todo_write") : true;
|
|
848
881
|
// Explicit durable-lesson capture + managed-skill CRUD (omp learn/manage_skill).
|
|
849
882
|
// STANDALONE-ONLY (localMemory, set by print/json/tui via shared.ts): the
|
|
@@ -949,6 +982,7 @@ export async function assembleRunRuntime(deps) {
|
|
|
949
982
|
streamModel,
|
|
950
983
|
pluginCodeToolNames,
|
|
951
984
|
approvalDeadlineMs,
|
|
985
|
+
bashSandboxed: bashSandbox !== undefined,
|
|
952
986
|
});
|
|
953
987
|
// --tools filter also governs the subagent table: a `--tools read` Run must
|
|
954
988
|
// not hand its children bash/write. Applied here (the executor receives the
|
|
@@ -87,14 +87,27 @@ function resolveApiKey(pid, primaryEnv, inlineApiKey, env) {
|
|
|
87
87
|
return env.ANTHROPIC_AUTH_TOKEN;
|
|
88
88
|
return undefined;
|
|
89
89
|
}
|
|
90
|
-
/** Resolve baseUrl with env override (ANTHROPIC_BASE_URL for proxy setups).
|
|
90
|
+
/** Resolve baseUrl with env override (ANTHROPIC_BASE_URL for proxy setups).
|
|
91
|
+
*
|
|
92
|
+
* The descriptor's path is used AS IS (trailing slashes trimmed), matching
|
|
93
|
+
* how the reference implementation composes `${baseUrl}/chat/completions`.
|
|
94
|
+
* There used to be a step appending `/v1` unless the URL already ended with
|
|
95
|
+
* it — which held for the five providers that happen to end in `/v1` and
|
|
96
|
+
* broke the one that does not (Z.AI's coding plan lives at
|
|
97
|
+
* `/coding/paas/v4`, so every request 404'd). A warning replaces the guess:
|
|
98
|
+
* a base URL with no version segment is more likely a mistake than a
|
|
99
|
+
* provider that really serves unversioned paths. */
|
|
91
100
|
function resolveBaseUrl(pid, specBaseUrl, env) {
|
|
92
101
|
// ponytail: anthropic-specific override, delete when ProviderSpec gets
|
|
93
102
|
// a generic baseUrlEnv field.
|
|
94
103
|
if (pid === "anthropic" && env.ANTHROPIC_BASE_URL)
|
|
95
104
|
return env.ANTHROPIC_BASE_URL;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
105
|
+
const url = specBaseUrl.trim().replace(/\/+$/, "");
|
|
106
|
+
const lastSegment = url.split("/").pop() ?? "";
|
|
107
|
+
if (!/^v\d+$/.test(lastSegment)) {
|
|
108
|
+
console.warn(`[oma] provider "${pid}" baseUrl has no version segment (${url}); ` +
|
|
109
|
+
`requests will go to ${url}/chat/completions — there is no /v1 auto-append any more, ` +
|
|
110
|
+
"so write the complete path in models.yml.");
|
|
111
|
+
}
|
|
99
112
|
return url;
|
|
100
113
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../../src/core/tools/bash.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,KAAK,oBAAoB,EAAmB,MAAM,6BAA6B,CAAC;AAEzF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../../src/core/tools/bash.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,KAAK,oBAAoB,EAAmB,MAAM,6BAA6B,CAAC;AAEzF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAcrD;;uBAEuB;AACvB,eAAO,MAAM,mBAAmB,SAAU,CAAC;AAoC3C,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB;0EACsE;IACtE,UAAU,CAAC,EAAE,CACX,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC3B,MAAM,CAAC,EAAE,WAAW,KACjB,OAAO,CAAC,aAAa,CAAC,CAAC;IAC5B;iFAC6E;IAC7E,QAAQ,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAC;QAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACjE,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,oBAAoB,CAAC;CACjC,GAAG,IAAI,CAkSP"}
|
package/dist/core/tools/bash.js
CHANGED
|
@@ -2,6 +2,7 @@ import { childEnv } from "@chengchenccc/agent-contract";
|
|
|
2
2
|
import { defaultRegistry } from "../coordination/registry.js";
|
|
3
3
|
import { ptyWrap, withPtyEnv } from "./bash-pty.js";
|
|
4
4
|
import { NullBashSandbox } from "./bash-sandbox.js";
|
|
5
|
+
import { readStringField } from "./presentation.js";
|
|
5
6
|
import { WorkspaceSandbox } from "./workspace-sandbox.js";
|
|
6
7
|
let nextJobSeq = 1;
|
|
7
8
|
const descriptionParam = {
|
|
@@ -133,6 +134,15 @@ export function createBashTool(opts) {
|
|
|
133
134
|
}
|
|
134
135
|
return {
|
|
135
136
|
name: "bash",
|
|
137
|
+
// The command's first line is the most useful thing a remote surface can
|
|
138
|
+
// show; safeToolSummary flattens it to one line, redacts credentials and
|
|
139
|
+
// truncates, so this never leaks a key or a multi-line script.
|
|
140
|
+
describeStart: (input) => {
|
|
141
|
+
const command = readStringField(input, "command");
|
|
142
|
+
return command
|
|
143
|
+
? { title: "运行命令", detail: command, icon: "command", visibility: "expandable" }
|
|
144
|
+
: { title: "运行命令", icon: "command", visibility: "compact" };
|
|
145
|
+
},
|
|
136
146
|
description: "Execute a bash shell command. Returns exit code, stdout, and stderr. Default timeout 30s, max 600s. " +
|
|
137
147
|
"Supports background execution (async): returns a job id immediately; collect with the hub tool " +
|
|
138
148
|
"(output/wait/stop). Also supports pseudo-terminal mode (pty) for commands that need a real TTY.",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eval.d.ts","sourceRoot":"","sources":["../../../src/core/tools/eval.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,KAAK,oBAAoB,EAAmB,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"eval.d.ts","sourceRoot":"","sources":["../../../src/core/tools/eval.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,KAAK,oBAAoB,EAAmB,MAAM,6BAA6B,CAAC;AAWzF;;;;+EAI+E;AAC/E;;mBAEmB;AACnB,eAAO,MAAM,mBAAmB,SAAU,CAAC;AAE3C,wBAAgB,cAAc,CAAC,IAAI,EAAE;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,oBAAoB,CAAC;CACjC,GAAG,IAAI,CA6JP"}
|
package/dist/core/tools/eval.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { runInSandbox } from "@chengchenccc/sandbox";
|
|
2
2
|
import { defaultRegistry } from "../coordination/registry.js";
|
|
3
|
+
import { readStringField } from "./presentation.js";
|
|
3
4
|
const descriptionParam = {
|
|
4
5
|
type: "string",
|
|
5
6
|
description: "Must be the first parameter. A short human-readable summary explaining what this code evaluates.",
|
|
@@ -20,6 +21,12 @@ export function createEvalTool(opts) {
|
|
|
20
21
|
const defaultTimeoutMs = opts.timeoutMs ?? 30_000;
|
|
21
22
|
return {
|
|
22
23
|
name: "eval",
|
|
24
|
+
// Same exposure profile as bash: the code is the activity. The helper
|
|
25
|
+
// flattens multi-line scripts and redacts credentials.
|
|
26
|
+
describeStart: (input) => {
|
|
27
|
+
const code = readStringField(input, "code");
|
|
28
|
+
return code ? `正在运行脚本:${code}` : "正在运行脚本";
|
|
29
|
+
},
|
|
23
30
|
description: "Evaluate a TypeScript/JavaScript snippet in an isolated sandbox process. The code must `export default async (ctx) => result` — ctx is the provided input object and result must be JSON-serializable. Use for computations, data shaping, and quick experiments instead of bash one-liners. " +
|
|
24
31
|
"Supports background execution (async); collect with the hub tool (output/wait).",
|
|
25
32
|
inputSchema: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-tools.d.ts","sourceRoot":"","sources":["../../../src/core/tools/file-tools.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"file-tools.d.ts","sourceRoot":"","sources":["../../../src/core/tools/file-tools.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAalD;;;;;;;;;;4CAU4C;AAC5C,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,SAAS,CAAC;AAyG9C;;;;qDAIqD;AACrD,MAAM,WAAW,aAAa;IAC5B,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAC;CAClB;AA6BD,+CAA+C;AAC/C,wBAAgB,cAAc,CAAC,IAAI,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,aAAa,CAAA;CAAE,GAAG,IAAI,CAsFrF;AAID,gDAAgD;AAChD,wBAAgB,eAAe,CAAC,IAAI,EAAE;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B,GAAG,IAAI,CAgEP;AAID,gDAAgD;AAChD,wBAAgB,cAAc,CAAC,IAAI,EAAE;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B,GAAG,IAAI,CA+GP"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, realpathSync, statSync, writeFileSync, } from "node:fs";
|
|
2
2
|
import { extname, relative, resolve, sep } from "node:path";
|
|
3
3
|
import { computeFileFingerprint, fingerprintFile, fingerprintFooter, MISSING_FINGERPRINT_HINT, STALE_FINGERPRINT_HINT, } from "./file-fingerprint.js";
|
|
4
|
+
import { readStringField } from "./presentation.js";
|
|
4
5
|
import { WorkspaceSandbox } from "./workspace-sandbox.js";
|
|
5
6
|
/** The fingerprint a later call must echo, or a refusal. `undefined` when the
|
|
6
7
|
* path has no current content — a new file has nothing to protect. */
|
|
@@ -125,6 +126,12 @@ export function createReadTool(opts) {
|
|
|
125
126
|
const freshness = opts.freshness ?? "off";
|
|
126
127
|
return {
|
|
127
128
|
name: "read",
|
|
129
|
+
describeStart: (input) => {
|
|
130
|
+
const path = readStringField(input, "path");
|
|
131
|
+
return path
|
|
132
|
+
? { title: "读取文件", detail: path, icon: "read", visibility: "compact" }
|
|
133
|
+
: { title: "读取文件", icon: "read", visibility: "compact" };
|
|
134
|
+
},
|
|
128
135
|
description: "Read a file from the workspace. Returns file contents with line numbers (line\\tcontent). " +
|
|
129
136
|
"For images, returns a placeholder with file size. Output capped at 256KB; use offset/limit for large files." +
|
|
130
137
|
(freshness === "require"
|
|
@@ -208,11 +215,18 @@ export function createWriteTool(opts) {
|
|
|
208
215
|
const freshness = opts.freshness ?? "off";
|
|
209
216
|
return {
|
|
210
217
|
name: "write",
|
|
218
|
+
describeStart: (input) => {
|
|
219
|
+
const path = readStringField(input, "path");
|
|
220
|
+
return path
|
|
221
|
+
? { title: "写入文件", detail: path, icon: "edit", visibility: "compact" }
|
|
222
|
+
: { title: "写入文件", icon: "edit", visibility: "compact" };
|
|
223
|
+
},
|
|
211
224
|
description: "Write content to a file in the workspace. Creates parent directories if needed. Overwrites if file exists." +
|
|
212
225
|
(freshness === "require"
|
|
213
226
|
? " Overwriting an existing file requires the fingerprint from a prior read of it."
|
|
214
227
|
: ""),
|
|
215
228
|
inputSchema: {
|
|
229
|
+
type: "object",
|
|
216
230
|
properties: buildFileToolProperties({
|
|
217
231
|
description: descriptionParam,
|
|
218
232
|
path: {
|
|
@@ -267,6 +281,12 @@ export function createEditTool(opts) {
|
|
|
267
281
|
const freshness = opts.freshness ?? "off";
|
|
268
282
|
return {
|
|
269
283
|
name: "edit",
|
|
284
|
+
describeStart: (input) => {
|
|
285
|
+
const path = readStringField(input, "path");
|
|
286
|
+
return path
|
|
287
|
+
? { title: "修改文件", detail: path, icon: "edit", visibility: "expandable" }
|
|
288
|
+
: { title: "修改文件", icon: "edit", visibility: "compact" };
|
|
289
|
+
},
|
|
270
290
|
description: "Perform exact string replacement in a file. old_string must match exactly and be unique " +
|
|
271
291
|
"unless replace_all is set. Use for surgical edits; prefer write for full replacement." +
|
|
272
292
|
(freshness === "require" ? " Requires the fingerprint from a prior read of the file." : ""),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../../../src/core/tools/glob.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../../../src/core/tools/glob.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAUlD,wBAAgB,cAAc,CAAC,IAAI,EAAE;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAiEpE"}
|
package/dist/core/tools/glob.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readStringField } from "./presentation.js";
|
|
1
2
|
import { WorkspaceSandbox } from "./workspace-sandbox.js";
|
|
2
3
|
const descriptionParam = {
|
|
3
4
|
type: "string",
|
|
@@ -7,6 +8,10 @@ export function createGlobTool(opts) {
|
|
|
7
8
|
const sandbox = new WorkspaceSandbox(opts.workspaceRoot);
|
|
8
9
|
return {
|
|
9
10
|
name: "glob",
|
|
11
|
+
describeStart: (input) => {
|
|
12
|
+
const pattern = readStringField(input, "pattern");
|
|
13
|
+
return pattern ? `正在查找:${pattern}` : "正在查找文件";
|
|
14
|
+
},
|
|
10
15
|
description: "Find files matching a glob pattern. Returns newline-separated paths. Results are capped at 500.",
|
|
11
16
|
inputSchema: {
|
|
12
17
|
type: "object",
|