@xiangyixie/dsh-superagent 0.14.4 → 0.14.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/CHANGELOG.md +43 -0
- package/README.en.md +1754 -1878
- package/README.md +1161 -1220
- package/README.zh.md +1173 -1232
- package/docs/images/approval-card.png +0 -0
- package/docs/images/console-summary.png +0 -0
- package/docs/images/console-task-lines.png +0 -0
- package/docs/images/sidebar-entry.png +0 -0
- package/lib/console.js +12 -2
- package/lib/doctor.js +1 -0
- package/lib/index.js +211 -220
- package/package.json +3 -2
package/lib/index.js
CHANGED
|
@@ -1255,16 +1255,19 @@ export function apply(ctx, config) {
|
|
|
1255
1255
|
// `superagent_start` next to the host's `subagent` tool can hand-orchestrate
|
|
1256
1256
|
// the work with the latter — three children, three report fragments, and no
|
|
1257
1257
|
// run, no plan, no merged report, and nothing in the run list to look at.
|
|
1258
|
-
// This nudge is the only thing that states the policy, so it is injected
|
|
1259
|
-
//
|
|
1258
|
+
// This nudge is the only thing that states the policy, so it is injected once
|
|
1259
|
+
// per session, at the first step of a top-level session: repeating it every
|
|
1260
|
+
// turn would put another copy in the history each time.
|
|
1260
1261
|
const GUIDANCE_SOURCE = { kind: 'superagent-guidance', form: 'notice', summary: '多步目标先起 run' }
|
|
1261
1262
|
const GUIDANCE_TEXT = [
|
|
1262
|
-
'
|
|
1263
|
-
'
|
|
1264
|
-
'
|
|
1265
|
-
'
|
|
1266
|
-
'只有单一动作(一次查找、一次编辑、一条命令、一段短文本)才直接做,不必起 run。',
|
|
1263
|
+
'多步目标(两个及以上可独立交付物,或含“先 A 后 B”的前置依赖)先用 superagent_start(mode="planned") 起 run,',
|
|
1264
|
+
'之后用 superagent_followup 续、superagent_status 读报告;不要用内置 subagent 自己编排,那样没有计划与合并报告。',
|
|
1265
|
+
'直接调用,先不要确认工具是否存在;只有返回不存在时才退回 subagent。单一动作直接做,不必起 run。',
|
|
1266
|
+
'长期目标、定时、跨 run 记忆、模板、审计、实时插话:先调 superagent_help 展开这些工具。',
|
|
1267
1267
|
].join('')
|
|
1268
|
+
// Session ids that already carry the notice in their history. Bounded so a
|
|
1269
|
+
// long-lived host cannot accumulate them without limit.
|
|
1270
|
+
const guidedSessions = new Set()
|
|
1268
1271
|
if (typeof ctx.on === 'function') {
|
|
1269
1272
|
ctx.on('agent/pre-step', async ({ agent, step }, next) => {
|
|
1270
1273
|
const decision = await next()
|
|
@@ -1273,6 +1276,12 @@ export function apply(ctx, config) {
|
|
|
1273
1276
|
if (!header) return decision
|
|
1274
1277
|
if ((header.delegationDepth ?? 0) > 0 || header.origin === 'subagent') return decision
|
|
1275
1278
|
if (decision.messages.some(message => message?.source?.kind === GUIDANCE_SOURCE.kind)) return decision
|
|
1279
|
+
const sessionId = sessionKey(agent)
|
|
1280
|
+
if (sessionId && guidedSessions.has(sessionId)) return decision
|
|
1281
|
+
if (sessionId) {
|
|
1282
|
+
if (guidedSessions.size >= 2000) guidedSessions.clear()
|
|
1283
|
+
guidedSessions.add(sessionId)
|
|
1284
|
+
}
|
|
1276
1285
|
const guidance = {
|
|
1277
1286
|
id: randomUUID(),
|
|
1278
1287
|
role: 'user',
|
|
@@ -1283,6 +1292,20 @@ export function apply(ctx, config) {
|
|
|
1283
1292
|
})
|
|
1284
1293
|
}
|
|
1285
1294
|
|
|
1295
|
+
// Every declaration is paid for on every request, so the capabilities most
|
|
1296
|
+
// sessions never touch are registered with a per-session activation
|
|
1297
|
+
// condition (see EXTRA_TOOLS): `superagent_help` names them and turns them on.
|
|
1298
|
+
const expandedSessions = new Set()
|
|
1299
|
+
const sessionKey = agent => {
|
|
1300
|
+
const header = agent?.session?.header
|
|
1301
|
+
return agent?.id ?? header?.id ?? header?.sessionId
|
|
1302
|
+
}
|
|
1303
|
+
const isExpanded = agent => Boolean(expandedSessions.has(sessionKey(agent)))
|
|
1304
|
+
// The host's contract is `tools.register(definition, { when })`: `when` is
|
|
1305
|
+
// evaluated for every step, and false keeps the tool out of that step's
|
|
1306
|
+
// declarations and dispatch.
|
|
1307
|
+
const EXTRA_TOOLS = { when: context => isExpanded(context?.agent) }
|
|
1308
|
+
|
|
1286
1309
|
// Runtime control is opt-in. With `runtime.enabled` false nothing below is
|
|
1287
1310
|
// registered, which is why a profile that never asked for browser or desktop
|
|
1288
1311
|
// access sees exactly the same tool list as before this layer existed.
|
|
@@ -2005,61 +2028,43 @@ export function apply(ctx, config) {
|
|
|
2005
2028
|
ctx.tools.register(defineTool({
|
|
2006
2029
|
name: 'superagent_start',
|
|
2007
2030
|
description:
|
|
2008
|
-
'Start
|
|
2009
|
-
+ '
|
|
2010
|
-
+ '
|
|
2011
|
-
+ '
|
|
2012
|
-
+ 'or aggregator, and its reply is the report verbatim — use it for one lookup, one edit, one query, or '
|
|
2013
|
-
+ 'one short piece of writing, not for a goal with parts that can be worked in parallel. '
|
|
2014
|
-
+ 'Prefer this over the built-in subagent tool whenever the goal has several deliverables or a '
|
|
2015
|
-
+ 'declared prerequisite step: only a run keeps the plan, the parallel timing, and one merged report. '
|
|
2016
|
-
+ 'The call returns immediately with a run id; poll it with superagent_status. Runs are persisted, '
|
|
2017
|
-
+ 'so they survive a host restart and can be resumed or cancelled.',
|
|
2031
|
+
'Start an autonomous run: a planner splits the goal into subtasks, independent ones run in parallel, and their '
|
|
2032
|
+
+ 'reports merge into one. Use it instead of the host subagent tool for goals with several deliverables or an '
|
|
2033
|
+
+ 'ordered prerequisite. Returns a run id; poll with superagent_status or pass wait_seconds. '
|
|
2034
|
+
+ 'mode "direct" runs one worker with no plan or merge.',
|
|
2018
2035
|
properties: {
|
|
2019
|
-
goal: { type: 'string', description: 'The complete goal
|
|
2036
|
+
goal: { type: 'string', description: 'The complete goal; be specific about the expected outcome.' },
|
|
2020
2037
|
mode: {
|
|
2021
2038
|
type: 'string',
|
|
2022
2039
|
enum: ['planned', 'direct'],
|
|
2023
|
-
description: 'planned (default):
|
|
2024
|
-
+ 'goal, with no planning or aggregation, and its reply is returned unchanged. Choose direct only when the '
|
|
2025
|
-
+ 'task is one self-contained pass that gains nothing from splitting.',
|
|
2040
|
+
description: 'planned (default): plan, parallel workers, merged report. direct: one worker, reply as-is.',
|
|
2026
2041
|
},
|
|
2027
2042
|
queue: {
|
|
2028
2043
|
type: 'boolean',
|
|
2029
|
-
description: '
|
|
2030
|
-
+ `status "queued" with its position, starts automatically when another run finishes, and gives up after `
|
|
2031
|
-
+ `queueTimeoutMinutes (default ${DEFAULTS.queueTimeoutMinutes}). Off by default; at most maxQueuedRuns `
|
|
2032
|
-
+ `(default ${DEFAULTS.maxQueuedRuns}) may wait.`,
|
|
2044
|
+
description: 'Wait for a free slot when the concurrency cap is reached, instead of failing.',
|
|
2033
2045
|
},
|
|
2034
2046
|
goal_mode: {
|
|
2035
2047
|
type: 'boolean',
|
|
2036
|
-
description: '
|
|
2037
|
-
+ 'acceptance step checks the acceptance conditions, and a failed round starts another one with what is '
|
|
2038
|
-
+ 'missing instead of repeating the same work. It stops when the goal is met, when max_rounds, '
|
|
2039
|
-
+ 'max_wall_clock_minutes or the budget is reached, or when consecutive rounds stop making progress. Off by '
|
|
2040
|
-
+ 'default, so a start without this flag behaves exactly as before.',
|
|
2048
|
+
description: 'Check acceptance conditions and start another round with what is missing until they hold.',
|
|
2041
2049
|
},
|
|
2042
2050
|
acceptance: {
|
|
2043
2051
|
type: 'array',
|
|
2044
|
-
description: '
|
|
2045
|
-
+ 'check is {"type":"command","command":"npm test"} (real exit code) or {"type":"file","path":"dist/app.js"} '
|
|
2046
|
-
+ '(existence); the plugin runs it, so the verdict is not the model\'s opinion. A condition without a check '
|
|
2047
|
-
+ 'is judged by an independent acceptance model, and status names the source of every verdict.',
|
|
2052
|
+
description: 'Required with goal_mode: conditions that decide whether the goal is met.',
|
|
2048
2053
|
items: {
|
|
2049
2054
|
type: 'object',
|
|
2050
2055
|
properties: {
|
|
2051
|
-
id: { type: 'string', description: 'Short id used in reports
|
|
2052
|
-
text: { type: 'string', description: 'What must hold
|
|
2056
|
+
id: { type: 'string', description: 'Short id used in reports.' },
|
|
2057
|
+
text: { type: 'string', description: 'What must hold.' },
|
|
2053
2058
|
check: {
|
|
2054
2059
|
type: 'object',
|
|
2055
|
-
description: 'Machine
|
|
2060
|
+
description: 'Machine check; omit to let an independent model judge it.',
|
|
2056
2061
|
properties: {
|
|
2057
2062
|
type: { type: 'string', enum: ['command', 'file'] },
|
|
2058
|
-
command: { type: 'string', description: 'Shell command
|
|
2059
|
-
cwd: { type: 'string', description: '
|
|
2063
|
+
command: { type: 'string', description: 'Shell command; exit code is the verdict.' },
|
|
2064
|
+
cwd: { type: 'string', description: 'Working directory, relative to the goal workspace.' },
|
|
2060
2065
|
timeout_seconds: { type: 'number', description: 'Command timeout (default 120, max 900).' },
|
|
2061
|
-
path: { type: 'string', description: 'File path
|
|
2062
|
-
must_exist: { type: 'boolean', description: '
|
|
2066
|
+
path: { type: 'string', description: 'File path, relative to the goal workspace.' },
|
|
2067
|
+
must_exist: { type: 'boolean', description: 'true (default) requires the file, false its absence.' },
|
|
2063
2068
|
},
|
|
2064
2069
|
required: ['type'],
|
|
2065
2070
|
},
|
|
@@ -2067,38 +2072,32 @@ export function apply(ctx, config) {
|
|
|
2067
2072
|
required: ['text'],
|
|
2068
2073
|
},
|
|
2069
2074
|
},
|
|
2070
|
-
max_rounds: { type: 'number', description: 'Goal mode: rounds
|
|
2071
|
-
max_wall_clock_minutes: {
|
|
2072
|
-
type: 'number',
|
|
2073
|
-
description: 'Goal mode: wall-clock budget for the rounds (default 60; a resume restarts it).',
|
|
2074
|
-
},
|
|
2075
|
+
max_rounds: { type: 'number', description: 'Goal mode: rounds before stopping (default 5, max 20).' },
|
|
2076
|
+
max_wall_clock_minutes: { type: 'number', description: 'Goal mode: wall-clock budget (default 60).' },
|
|
2075
2077
|
no_progress_rounds: {
|
|
2076
2078
|
type: 'number',
|
|
2077
|
-
description: 'Goal mode:
|
|
2078
|
-
+ 'the acceptance has a machine check, a round that changed no file stops immediately instead.',
|
|
2079
|
+
description: 'Goal mode: identical failing rounds before stopping (default 2).',
|
|
2079
2080
|
},
|
|
2080
2081
|
budget: {
|
|
2081
2082
|
type: 'object',
|
|
2082
|
-
description: 'Goal mode budget,
|
|
2083
|
+
description: 'Goal mode budget, inside the operator cap.',
|
|
2083
2084
|
properties: {
|
|
2084
2085
|
max_model_calls: { type: 'number' },
|
|
2085
2086
|
max_tokens: { type: 'number' },
|
|
2086
2087
|
},
|
|
2087
2088
|
},
|
|
2088
|
-
max_subtasks: { type: 'number', description: `
|
|
2089
|
-
max_parallel: { type: 'number', description: `Subtasks
|
|
2089
|
+
max_subtasks: { type: 'number', description: `Planned subtasks cap (default ${DEFAULTS.maxSubtasks}, max 16).` },
|
|
2090
|
+
max_parallel: { type: 'number', description: `Subtasks at once (default ${DEFAULTS.maxParallel}, max 8).` },
|
|
2090
2091
|
deadline_minutes: { type: 'number', description: `Wall-clock budget in minutes (default ${DEFAULTS.deadlineMinutes}).` },
|
|
2091
2092
|
allow_duplicate: {
|
|
2092
2093
|
type: 'boolean',
|
|
2093
|
-
description: 'Start a second run for the same goal
|
|
2094
|
-
+ 'By default the active run id is returned instead, so a retry cannot double the spend.',
|
|
2094
|
+
description: 'Start a second run for the same goal; default returns the active run id instead.',
|
|
2095
2095
|
},
|
|
2096
2096
|
approve_policy: {
|
|
2097
2097
|
type: 'boolean',
|
|
2098
|
-
description: 'Release a start
|
|
2099
|
-
+ 'recorded in the audit trail. It cannot override a policy that denies the start.',
|
|
2098
|
+
description: 'Release a start the permission policy holds for confirmation; it cannot override a deny.',
|
|
2100
2099
|
},
|
|
2101
|
-
wait_seconds: { type: 'number', description: 'Block up to this
|
|
2100
|
+
wait_seconds: { type: 'number', description: 'Block up to this long for a terminal status (default 0).' },
|
|
2102
2101
|
},
|
|
2103
2102
|
required: ['goal'],
|
|
2104
2103
|
async execute(args = {}, exec) {
|
|
@@ -2155,40 +2154,33 @@ export function apply(ctx, config) {
|
|
|
2155
2154
|
ctx.tools.register(defineTool({
|
|
2156
2155
|
name: 'superagent_goal',
|
|
2157
2156
|
description:
|
|
2158
|
-
'Run a long-term goal as
|
|
2159
|
-
+ '
|
|
2160
|
-
+ '
|
|
2161
|
-
+ 'persisted, so after a host restart it resumes the interrupted phase instead of starting over. A phase that '
|
|
2162
|
-
+ 'keeps failing, or a goal that stops making progress, opens a decision that a person answers with action '
|
|
2163
|
-
+ '"answer" — no goal-level question is guessed by the model. Per-phase and whole-goal model budgets are hard '
|
|
2164
|
-
+ 'stops. Use superagent_status/superagent_cancel on the phase run ids it reports. Prefer this over '
|
|
2165
|
-
+ 'superagent_start when the work has milestones that must happen in order over a long horizon.',
|
|
2157
|
+
'Run a long-term goal as ordered phases: each phase is its own run with planner and parallel workers, and later '
|
|
2158
|
+
+ 'phases receive earlier reports. A phase that keeps failing opens a decision a person answers with action '
|
|
2159
|
+
+ '"answer". Use it over superagent_start when milestones must happen in order over a long horizon.',
|
|
2166
2160
|
properties: {
|
|
2167
2161
|
action: {
|
|
2168
2162
|
type: 'string',
|
|
2169
2163
|
enum: ['create', 'status', 'list', 'answer', 'resume', 'pause', 'cancel'],
|
|
2170
|
-
description: 'create
|
|
2164
|
+
description: 'create, read one, list, answer an open decision, resume/pause/cancel.',
|
|
2171
2165
|
},
|
|
2172
|
-
goal_id: { type: 'string', description: '
|
|
2166
|
+
goal_id: { type: 'string', description: 'From action=create; required except for create/list.' },
|
|
2173
2167
|
goal: {
|
|
2174
2168
|
type: 'string',
|
|
2175
|
-
description: 'create: the complete long-term outcome
|
|
2169
|
+
description: 'create: the complete long-term outcome, concrete about the finished state.',
|
|
2176
2170
|
},
|
|
2177
2171
|
phases: {
|
|
2178
2172
|
type: 'array',
|
|
2179
|
-
description: 'create:
|
|
2180
|
-
+ '{id?, title, objective, depends_on?, acceptance?, max_rounds?, max_wall_clock_minutes?, deliverables?}. '
|
|
2181
|
-
+ 'acceptance uses the same {text, check?} shape as superagent_start; at least one condition per phase.',
|
|
2173
|
+
description: 'create: explicit phases; omit to let the phase planner split the goal.',
|
|
2182
2174
|
items: {
|
|
2183
2175
|
type: 'object',
|
|
2184
2176
|
properties: {
|
|
2185
|
-
id: { type: 'string', description: 'Short id, e.g. "p1";
|
|
2177
|
+
id: { type: 'string', description: 'Short id, e.g. "p1"; referenced by depends_on.' },
|
|
2186
2178
|
title: { type: 'string', description: 'Short name shown in the phase table.' },
|
|
2187
|
-
objective: { type: 'string', description: 'What this phase must produce
|
|
2179
|
+
objective: { type: 'string', description: 'What this phase must produce.' },
|
|
2188
2180
|
depends_on: {
|
|
2189
2181
|
type: 'array',
|
|
2190
2182
|
items: { type: 'string' },
|
|
2191
|
-
description: 'Phase ids that must complete
|
|
2183
|
+
description: 'Phase ids that must complete first; omit for independent phases.',
|
|
2192
2184
|
},
|
|
2193
2185
|
acceptance: {
|
|
2194
2186
|
type: 'array',
|
|
@@ -2213,25 +2205,24 @@ export function apply(ctx, config) {
|
|
|
2213
2205
|
required: ['text'],
|
|
2214
2206
|
},
|
|
2215
2207
|
},
|
|
2216
|
-
max_rounds: { type: 'number', description: '
|
|
2217
|
-
max_wall_clock_minutes: { type: 'number', description: 'Wall-clock cap
|
|
2218
|
-
deliverables: { type: 'array', items: { type: 'string' }, description: '
|
|
2208
|
+
max_rounds: { type: 'number', description: 'Retries before the phase stops (default 3).' },
|
|
2209
|
+
max_wall_clock_minutes: { type: 'number', description: 'Wall-clock cap (default 120).' },
|
|
2210
|
+
deliverables: { type: 'array', items: { type: 'string' }, description: 'Paths to report.' },
|
|
2219
2211
|
},
|
|
2220
2212
|
required: ['objective'],
|
|
2221
2213
|
},
|
|
2222
2214
|
},
|
|
2223
|
-
cwd: { type: 'string', description: 'Workspace every phase and
|
|
2224
|
-
max_parallel_phases: { type: 'number', description: 'Phases
|
|
2215
|
+
cwd: { type: 'string', description: 'Workspace for every phase and machine check (default cwd).' },
|
|
2216
|
+
max_parallel_phases: { type: 'number', description: 'Phases in flight at once (default 2, max 8).' },
|
|
2225
2217
|
max_attempts_per_phase: {
|
|
2226
2218
|
type: 'number',
|
|
2227
|
-
description: 'Attempts per phase before
|
|
2228
|
-
+ 'failure signature; an identical no-change failure stops earlier.',
|
|
2219
|
+
description: 'Attempts per phase before asking a person (default 2).',
|
|
2229
2220
|
},
|
|
2230
|
-
max_rounds_per_phase: { type: 'number', description: 'Default goal-mode rounds
|
|
2231
|
-
no_progress_rounds: { type: 'number', description: '
|
|
2221
|
+
max_rounds_per_phase: { type: 'number', description: 'Default goal-mode rounds per phase (default 3).' },
|
|
2222
|
+
no_progress_rounds: { type: 'number', description: 'Identical failing rounds before a phase stops (default 2).' },
|
|
2232
2223
|
phase_budget: {
|
|
2233
2224
|
type: 'object',
|
|
2234
|
-
description: 'Per-phase
|
|
2225
|
+
description: 'Per-phase hard cap, inside what remains of the goal budget.',
|
|
2235
2226
|
properties: {
|
|
2236
2227
|
max_model_calls: { type: 'number' },
|
|
2237
2228
|
max_tokens: { type: 'number' },
|
|
@@ -2239,30 +2230,29 @@ export function apply(ctx, config) {
|
|
|
2239
2230
|
},
|
|
2240
2231
|
budget: {
|
|
2241
2232
|
type: 'object',
|
|
2242
|
-
description: 'Whole-goal hard cap
|
|
2233
|
+
description: 'Whole-goal hard cap; reaching it stops the goal.',
|
|
2243
2234
|
properties: {
|
|
2244
2235
|
max_model_calls: { type: 'number' },
|
|
2245
2236
|
max_tokens: { type: 'number' },
|
|
2246
2237
|
},
|
|
2247
2238
|
},
|
|
2248
|
-
max_wall_clock_minutes: { type: 'number', description: 'Whole-goal wall-clock cap
|
|
2239
|
+
max_wall_clock_minutes: { type: 'number', description: 'Whole-goal wall-clock cap (default 1440).' },
|
|
2249
2240
|
stall_after_minutes: {
|
|
2250
2241
|
type: 'number',
|
|
2251
2242
|
description: 'No completed phase for this long opens a stall decision (default 180).',
|
|
2252
2243
|
},
|
|
2253
2244
|
auto_resume: {
|
|
2254
2245
|
type: 'boolean',
|
|
2255
|
-
description: 'Continue
|
|
2246
|
+
description: 'Continue after a host restart (default true); false leaves it paused.',
|
|
2256
2247
|
},
|
|
2257
|
-
decision_id: { type: 'string', description: 'answer:
|
|
2248
|
+
decision_id: { type: 'string', description: 'answer: id shown in action=status.' },
|
|
2258
2249
|
answer: {
|
|
2259
2250
|
type: 'string',
|
|
2260
|
-
description: 'answer:
|
|
2261
|
-
+ 'to dependents; stop ends the goal; continue resets a stall; answer (worker question) needs note.',
|
|
2251
|
+
description: 'answer: retry, skip, stop, continue, or answer (worker question, needs note).',
|
|
2262
2252
|
},
|
|
2263
2253
|
note: {
|
|
2264
2254
|
type: 'string',
|
|
2265
|
-
description: 'answer:
|
|
2255
|
+
description: 'answer: new instruction for retry, or the text for a worker question.',
|
|
2266
2256
|
},
|
|
2267
2257
|
limit: { type: 'number', description: 'list: maximum rows (default 20).' },
|
|
2268
2258
|
},
|
|
@@ -2356,7 +2346,7 @@ export function apply(ctx, config) {
|
|
|
2356
2346
|
return describeError(error)
|
|
2357
2347
|
}
|
|
2358
2348
|
},
|
|
2359
|
-
}))
|
|
2349
|
+
}), EXTRA_TOOLS)
|
|
2360
2350
|
|
|
2361
2351
|
// Files on disk can be newer than the code this host loaded: a package update
|
|
2362
2352
|
// only takes effect after DSH restarts. Surface the mismatch instead of
|
|
@@ -2377,11 +2367,11 @@ export function apply(ctx, config) {
|
|
|
2377
2367
|
ctx.tools.register(defineTool({
|
|
2378
2368
|
name: 'superagent_status',
|
|
2379
2369
|
description:
|
|
2380
|
-
'Read one
|
|
2381
|
-
+ '
|
|
2370
|
+
'Read one run: status, subtask outcomes, measured token usage, and the final report. wait_seconds blocks for a '
|
|
2371
|
+
+ 'terminal state.',
|
|
2382
2372
|
properties: {
|
|
2383
2373
|
run_id: { type: 'string', description: 'Run id returned by superagent_start.' },
|
|
2384
|
-
wait_seconds: { type: 'number', description: 'Block up to this
|
|
2374
|
+
wait_seconds: { type: 'number', description: 'Block up to this long for a terminal state (default 0).' },
|
|
2385
2375
|
},
|
|
2386
2376
|
required: ['run_id'],
|
|
2387
2377
|
async execute(args = {}) {
|
|
@@ -2399,9 +2389,9 @@ export function apply(ctx, config) {
|
|
|
2399
2389
|
|
|
2400
2390
|
ctx.tools.register(defineTool({
|
|
2401
2391
|
name: 'superagent_list',
|
|
2402
|
-
description: 'List recorded
|
|
2392
|
+
description: 'List recorded runs, newest first, with status and progress.',
|
|
2403
2393
|
properties: {
|
|
2404
|
-
limit: { type: 'number', description: 'Maximum rows
|
|
2394
|
+
limit: { type: 'number', description: 'Maximum rows (default 20).' },
|
|
2405
2395
|
},
|
|
2406
2396
|
async execute(args = {}) {
|
|
2407
2397
|
try {
|
|
@@ -2434,11 +2424,40 @@ export function apply(ctx, config) {
|
|
|
2434
2424
|
},
|
|
2435
2425
|
}))
|
|
2436
2426
|
|
|
2427
|
+
// Every declaration is paid for on every request, so the capabilities most
|
|
2428
|
+
// sessions never touch are registered behind a per-session activation
|
|
2429
|
+
// condition: `superagent_help` names them and turns them on for that session.
|
|
2430
|
+
ctx.tools.register(defineTool({
|
|
2431
|
+
name: 'superagent_help',
|
|
2432
|
+
description:
|
|
2433
|
+
'Show the extra superagent tools and when each applies: long-term goals, cron schedules, live steering, '
|
|
2434
|
+
+ 'cross-run memory, workflow templates, audit export. Call this before using any of them.',
|
|
2435
|
+
properties: {},
|
|
2436
|
+
async execute(_args, exec) {
|
|
2437
|
+
const check = requireAgent(exec)
|
|
2438
|
+
if (check.error) return check.error
|
|
2439
|
+
const id = sessionKey(check.agent)
|
|
2440
|
+
if (id) {
|
|
2441
|
+
if (expandedSessions.size >= 2000) expandedSessions.clear()
|
|
2442
|
+
expandedSessions.add(id)
|
|
2443
|
+
}
|
|
2444
|
+
return [
|
|
2445
|
+
'已展开,下一步起可用(参数见各自 schema):',
|
|
2446
|
+
'- superagent_goal: 长期目标按阶段推进,多里程碑或必须按序时用;action=create/status/list/answer/resume/pause/cancel',
|
|
2447
|
+
'- superagent_schedule: 定时或按间隔自动起 run;action=create/list/pause/resume/delete/run-now',
|
|
2448
|
+
'- superagent_inject: 给正在跑的 worker 立刻发指令;不着急就用 superagent_followup',
|
|
2449
|
+
'- superagent_memory: 跨 run 笔记;action=list/search/set/forget,layer="user" 读写用户级事实',
|
|
2450
|
+
'- superagent_template: 工作流模板;action=list/show/expand/save/delete,expand 出 goal 再 start',
|
|
2451
|
+
'- superagent_audit: 查询或导出审计流水(tool.call、path.write、blocked、审批等)',
|
|
2452
|
+
'不确定就先 action=list 或 superagent_status 看现状。',
|
|
2453
|
+
].join('\n')
|
|
2454
|
+
},
|
|
2455
|
+
}))
|
|
2456
|
+
|
|
2437
2457
|
ctx.tools.register(defineTool({
|
|
2438
2458
|
name: 'superagent_cancel',
|
|
2439
2459
|
description:
|
|
2440
|
-
'Cancel a
|
|
2441
|
-
+ 'so the partial work stays inspectable.',
|
|
2460
|
+
'Cancel a run: stops its subtasks and marks it cancelled; the state file stays inspectable.',
|
|
2442
2461
|
properties: {
|
|
2443
2462
|
run_id: { type: 'string', description: 'Run id to cancel.' },
|
|
2444
2463
|
},
|
|
@@ -2466,20 +2485,18 @@ export function apply(ctx, config) {
|
|
|
2466
2485
|
ctx.tools.register(defineTool({
|
|
2467
2486
|
name: 'superagent_resume',
|
|
2468
2487
|
description:
|
|
2469
|
-
'Resume
|
|
2470
|
-
+ '
|
|
2471
|
-
+ 'holds an answer that never reached a prompt, so its aggregation can apply the decision.',
|
|
2488
|
+
'Resume an interrupted, timed-out, or failed run: completed subtasks are kept, pending and failed ones run '
|
|
2489
|
+
+ 'again.',
|
|
2472
2490
|
properties: {
|
|
2473
2491
|
run_id: { type: 'string', description: 'Run id to resume.' },
|
|
2474
|
-
wait_seconds: { type: 'number', description: 'Block up to this
|
|
2492
|
+
wait_seconds: { type: 'number', description: 'Block up to this long for a terminal state (default 0).' },
|
|
2475
2493
|
force: {
|
|
2476
2494
|
type: 'boolean',
|
|
2477
|
-
description: '
|
|
2495
|
+
description: 'Ignored; kept so older callers still validate.',
|
|
2478
2496
|
},
|
|
2479
2497
|
approve_policy: {
|
|
2480
2498
|
type: 'boolean',
|
|
2481
|
-
description: 'Release a resume
|
|
2482
|
-
+ 'recorded in the audit trail. It cannot override a policy that denies the resume.',
|
|
2499
|
+
description: 'Release a resume the permission policy holds for confirmation.',
|
|
2483
2500
|
},
|
|
2484
2501
|
},
|
|
2485
2502
|
required: ['run_id'],
|
|
@@ -2513,11 +2530,8 @@ export function apply(ctx, config) {
|
|
|
2513
2530
|
ctx.tools.register(defineTool({
|
|
2514
2531
|
name: 'superagent_followup',
|
|
2515
2532
|
description:
|
|
2516
|
-
'Add an instruction to a run that is already executing
|
|
2517
|
-
+ '
|
|
2518
|
-
+ 'instruction is queued on the run and carried by the next prompt built for it — the next worker spawn or the '
|
|
2519
|
-
+ 'aggregation, whichever comes first. Subtasks that are already running or finished keep their results. The '
|
|
2520
|
-
+ 'reply states exactly which boundary it will reach.',
|
|
2533
|
+
'Add an instruction to a run that is already executing instead of starting a second one. It is queued and '
|
|
2534
|
+
+ 'carried by the next prompt built for the run; children already running are not interrupted.',
|
|
2521
2535
|
properties: {
|
|
2522
2536
|
run_id: { type: 'string', description: 'Run id returned by superagent_start.' },
|
|
2523
2537
|
message: { type: 'string', description: 'The instruction or constraint to add.' },
|
|
@@ -2550,23 +2564,18 @@ export function apply(ctx, config) {
|
|
|
2550
2564
|
ctx.tools.register(defineTool({
|
|
2551
2565
|
name: 'superagent_inject',
|
|
2552
2566
|
description:
|
|
2553
|
-
'Deliver an instruction into the workers
|
|
2554
|
-
+ '
|
|
2555
|
-
+ 'model request: it never interrupts a model call already in flight, and it arrives only after the current step '
|
|
2556
|
-
+ '(the model response plus its tool batch) finishes. A live child that had already decided to stop runs one more '
|
|
2557
|
-
+ 'turn to read it. The reply reports the measured delay from acceptance to the child\'s next request; a message '
|
|
2558
|
-
+ 'the child never claimed is reported as missed, never as delivered. Use superagent_followup when no worker is '
|
|
2559
|
-
+ 'running or the instruction can wait for the next prompt.',
|
|
2567
|
+
'Deliver an instruction into the workers running right now: it becomes part of each child\'s next model request, '
|
|
2568
|
+
+ 'at its next step boundary. Use superagent_followup when no worker is running.',
|
|
2560
2569
|
properties: {
|
|
2561
2570
|
run_id: { type: 'string', description: 'Run id returned by superagent_start.' },
|
|
2562
|
-
message: { type: 'string', description: 'The instruction
|
|
2571
|
+
message: { type: 'string', description: 'The instruction the running workers should read next.' },
|
|
2563
2572
|
subtask_index: {
|
|
2564
2573
|
type: 'number',
|
|
2565
|
-
description: '
|
|
2574
|
+
description: 'One worker, by its index from superagent_status; omit to reach every running worker.',
|
|
2566
2575
|
},
|
|
2567
2576
|
wait_seconds: {
|
|
2568
2577
|
type: 'number',
|
|
2569
|
-
description: 'Block up to this
|
|
2578
|
+
description: 'Block up to this long for the children to claim it, so the delay can be measured (default 0).',
|
|
2570
2579
|
},
|
|
2571
2580
|
},
|
|
2572
2581
|
required: ['run_id', 'message'],
|
|
@@ -2588,24 +2597,21 @@ export function apply(ctx, config) {
|
|
|
2588
2597
|
return describeError(error)
|
|
2589
2598
|
}
|
|
2590
2599
|
},
|
|
2591
|
-
}))
|
|
2600
|
+
}), EXTRA_TOOLS)
|
|
2592
2601
|
|
|
2593
2602
|
ctx.tools.register(defineTool({
|
|
2594
2603
|
name: 'superagent_answer',
|
|
2595
2604
|
description:
|
|
2596
|
-
'Answer
|
|
2597
|
-
+ '
|
|
2598
|
-
+ 'is reopened and only its aggregation runs again, now with the answer. The answer is matched to one specific '
|
|
2599
|
-
+ 'question: an unknown, already answered, or expired question is refused instead of being attached to whatever '
|
|
2600
|
-
+ 'is open.',
|
|
2605
|
+
'Answer the question a run asked (the qN item in superagent_status), so that run continues instead of a new one '
|
|
2606
|
+
+ 'starting. An active run applies it at its next boundary; a finished run is reopened for aggregation.',
|
|
2601
2607
|
properties: {
|
|
2602
2608
|
run_id: { type: 'string', description: 'Run id returned by superagent_start.' },
|
|
2603
2609
|
attention_id: {
|
|
2604
2610
|
type: 'string',
|
|
2605
|
-
description: 'Question id from superagent_status, e.g. q1
|
|
2611
|
+
description: 'Question id from superagent_status, e.g. q1; required when several are open.',
|
|
2606
2612
|
},
|
|
2607
|
-
answer: { type: 'string', description: 'The decision
|
|
2608
|
-
wait_seconds: { type: 'number', description: 'Block up to this
|
|
2613
|
+
answer: { type: 'string', description: 'The decision; a listed option or free text.' },
|
|
2614
|
+
wait_seconds: { type: 'number', description: 'Block up to this long for the run to settle (default 0).' },
|
|
2609
2615
|
},
|
|
2610
2616
|
required: ['run_id', 'answer'],
|
|
2611
2617
|
async execute(args = {}, exec) {
|
|
@@ -2641,60 +2647,57 @@ export function apply(ctx, config) {
|
|
|
2641
2647
|
ctx.tools.register(defineTool({
|
|
2642
2648
|
name: 'superagent_memory',
|
|
2643
2649
|
description:
|
|
2644
|
-
'Read or correct the cross-run notebook: short notes
|
|
2645
|
-
+ '
|
|
2646
|
-
+ 'With layer="user" (when the user-level profile is enabled) the same actions address durable facts, '
|
|
2647
|
-
+ 'preferences, and decisions with their rationale; forgetting there deletes instead of retracting.',
|
|
2650
|
+
'Read or correct the cross-run notebook: short notes earlier runs left for the next one, or (layer="user") '
|
|
2651
|
+
+ 'durable facts, preferences, and decisions.',
|
|
2648
2652
|
properties: {
|
|
2649
2653
|
action: {
|
|
2650
2654
|
type: 'string',
|
|
2651
2655
|
enum: ['list', 'search', 'set', 'forget'],
|
|
2652
|
-
description: 'List notes, search
|
|
2656
|
+
description: 'List notes, search by keyword or tag, set one, or forget one.',
|
|
2653
2657
|
},
|
|
2654
2658
|
layer: {
|
|
2655
2659
|
type: 'string',
|
|
2656
2660
|
enum: ['run', 'user'],
|
|
2657
|
-
description: 'run (default)
|
|
2661
|
+
description: 'run (default): task notebook. user: cross-task profile.',
|
|
2658
2662
|
},
|
|
2659
2663
|
category: {
|
|
2660
2664
|
type: 'string',
|
|
2661
2665
|
enum: [...USER_MEMORY_CATEGORIES],
|
|
2662
2666
|
description: 'User layer only: fact, preference, or decision.',
|
|
2663
2667
|
},
|
|
2664
|
-
key: { type: 'string', description: 'Short topic key
|
|
2668
|
+
key: { type: 'string', description: 'Short topic key; a new note with the same key replaces it.' },
|
|
2665
2669
|
kind: { type: 'string', enum: [...MEMORY_KINDS], description: 'decision, pitfall, next, dispatch, or note.' },
|
|
2666
|
-
text: { type: 'string', description: 'The durable fact to record
|
|
2667
|
-
choice: { type: 'string', description: 'User decision
|
|
2668
|
-
rejected: { type: 'string', description: 'User decision
|
|
2669
|
-
reason: { type: 'string', description: 'User decision
|
|
2670
|
-
rollback: { type: 'string', description: 'User decision
|
|
2670
|
+
text: { type: 'string', description: 'The durable fact to record.' },
|
|
2671
|
+
choice: { type: 'string', description: 'User decision: what was chosen.' },
|
|
2672
|
+
rejected: { type: 'string', description: 'User decision: the alternative given up.' },
|
|
2673
|
+
reason: { type: 'string', description: 'User decision: why.' },
|
|
2674
|
+
rollback: { type: 'string', description: 'User decision: how to undo it.' },
|
|
2671
2675
|
query: {
|
|
2672
2676
|
type: 'string',
|
|
2673
|
-
description: '
|
|
2677
|
+
description: 'Search: keywords to rank notes by.',
|
|
2674
2678
|
},
|
|
2675
2679
|
tags: {
|
|
2676
2680
|
type: 'array',
|
|
2677
2681
|
items: { type: 'string' },
|
|
2678
|
-
description: '
|
|
2682
|
+
description: 'Match exactly (search) or attach (set).',
|
|
2679
2683
|
},
|
|
2680
2684
|
scope: {
|
|
2681
2685
|
type: 'string',
|
|
2682
|
-
description: 'Notebook scope: "rules"
|
|
2683
|
-
+ 'or the run scope (default) that earlier runs write to.',
|
|
2686
|
+
description: 'Notebook scope: "rules", "profile", or the run scope (default).',
|
|
2684
2687
|
},
|
|
2685
2688
|
run_id: {
|
|
2686
2689
|
type: 'string',
|
|
2687
|
-
description: 'User layer forget
|
|
2690
|
+
description: 'User layer forget: delete every record from this run.',
|
|
2688
2691
|
},
|
|
2689
2692
|
before: {
|
|
2690
2693
|
type: 'string',
|
|
2691
|
-
description: 'User layer forget
|
|
2694
|
+
description: 'User layer forget: delete records at or before this date.',
|
|
2692
2695
|
},
|
|
2693
2696
|
after: {
|
|
2694
2697
|
type: 'string',
|
|
2695
|
-
description: 'User layer forget
|
|
2698
|
+
description: 'User layer forget: delete records at or after this date.',
|
|
2696
2699
|
},
|
|
2697
|
-
limit: { type: 'number', description: 'Maximum notes
|
|
2700
|
+
limit: { type: 'number', description: 'Maximum notes (default 20).' },
|
|
2698
2701
|
},
|
|
2699
2702
|
required: ['action'],
|
|
2700
2703
|
async execute(args = {}, exec) {
|
|
@@ -2852,7 +2855,7 @@ export function apply(ctx, config) {
|
|
|
2852
2855
|
return describeError(error)
|
|
2853
2856
|
}
|
|
2854
2857
|
},
|
|
2855
|
-
}))
|
|
2858
|
+
}), EXTRA_TOOLS)
|
|
2856
2859
|
|
|
2857
2860
|
/**
|
|
2858
2861
|
* A template failure already names the concrete problem (which parameters
|
|
@@ -2876,28 +2879,24 @@ export function apply(ctx, config) {
|
|
|
2876
2879
|
ctx.tools.register(defineTool({
|
|
2877
2880
|
name: 'superagent_template',
|
|
2878
2881
|
description:
|
|
2879
|
-
'List, show, expand, save, or delete a workflow template: a fixed goal skeleton with required parameters
|
|
2880
|
-
+ '
|
|
2881
|
-
+ 'superagent_start plans exactly like a goal typed by the user. A template cannot set limits, budgets, a '
|
|
2882
|
-
+ 'mode, or an override, so using one never widens what a run may do.',
|
|
2882
|
+
'List, show, expand, save, or delete a workflow template: a fixed goal skeleton with required parameters. '
|
|
2883
|
+
+ 'expand returns one goal string for superagent_start; a template never sets limits, budgets, or overrides.',
|
|
2883
2884
|
properties: {
|
|
2884
2885
|
action: {
|
|
2885
2886
|
type: 'string',
|
|
2886
2887
|
enum: ['list', 'show', 'expand', 'save', 'delete'],
|
|
2887
|
-
description: 'List
|
|
2888
|
+
description: 'List, show one, expand into a goal, save a custom one, or delete a custom one.',
|
|
2888
2889
|
},
|
|
2889
|
-
id: { type: 'string', description: 'Template id from action="list"
|
|
2890
|
+
id: { type: 'string', description: 'Template id from action="list"; built-in ids are read-only.' },
|
|
2890
2891
|
params: {
|
|
2891
2892
|
type: 'object',
|
|
2892
|
-
description: '
|
|
2893
|
-
+ 'empty value is refused with its name instead of being given a default.',
|
|
2893
|
+
description: 'expand: a value for every declared parameter; missing ones are refused, not defaulted.',
|
|
2894
2894
|
additionalProperties: { type: 'string' },
|
|
2895
2895
|
},
|
|
2896
2896
|
template: {
|
|
2897
2897
|
type: 'object',
|
|
2898
|
-
description: '
|
|
2899
|
-
+ '
|
|
2900
|
-
+ 'refused so a template cannot carry limits or overrides.',
|
|
2898
|
+
description: 'save: id, title, whenToUse, whenNotToUse, variables [{name, description}], '
|
|
2899
|
+
+ 'skeleton with {{name}} placeholders.',
|
|
2901
2900
|
},
|
|
2902
2901
|
limit: { type: 'number', description: 'Maximum templates to list (default 50).' },
|
|
2903
2902
|
},
|
|
@@ -2959,80 +2958,66 @@ export function apply(ctx, config) {
|
|
|
2959
2958
|
return describeError(error)
|
|
2960
2959
|
}
|
|
2961
2960
|
},
|
|
2962
|
-
}))
|
|
2961
|
+
}), EXTRA_TOOLS)
|
|
2963
2962
|
|
|
2964
2963
|
ctx.tools.register(defineTool({
|
|
2965
2964
|
name: 'superagent_schedule',
|
|
2966
2965
|
description:
|
|
2967
|
-
'Create and manage scheduled runs
|
|
2968
|
-
+ '
|
|
2969
|
-
+ '
|
|
2970
|
-
+ '
|
|
2971
|
-
+ 'Missed windows are not replayed: the default miss policy "latest" runs only the newest due window and marks '
|
|
2972
|
-
+ 'the rest missed with a reason; "none" skips due windows while the host is down. '
|
|
2973
|
-
+ 'A plan never overlaps itself: if its previous run is still active, that window is recorded as '
|
|
2974
|
-
+ '"skipped: previous run still active". Scheduled runs share the concurrency quota with manual runs, and by '
|
|
2975
|
-
+ 'default one slot stays reserved for manual starts. Notifications are limited to achieved, first failure, '
|
|
2976
|
-
+ 'budget stop, and a needed decision; a plan that fails 3 times in a row pauses and says so once. '
|
|
2977
|
-
+ 'Cron support is zero-dependency: 5 fields, *, */n, ranges, lists, month/weekday names, 0 or 7 for Sunday. '
|
|
2978
|
-
+ 'Seconds, @macros, L, W, # and ? are refused when the plan is created, with the field number. '
|
|
2979
|
-
+ 'Nothing runs until a plan is created; an install with no plans behaves exactly as before.',
|
|
2966
|
+
'Create and manage scheduled runs that start on a cron expression or fixed interval without anyone calling '
|
|
2967
|
+
+ 'superagent_start. Actions: create, list, pause, resume, delete, run-now. Plans survive restarts, never overlap '
|
|
2968
|
+
+ 'themselves, and pause after 3 consecutive failures. Cron is 5 fields (*, */n, ranges, lists, names, 0/7 '
|
|
2969
|
+
+ 'Sunday); seconds and macros are refused.',
|
|
2980
2970
|
properties: {
|
|
2981
2971
|
action: {
|
|
2982
2972
|
type: 'string',
|
|
2983
2973
|
enum: ['create', 'list', 'pause', 'resume', 'delete', 'run-now'],
|
|
2984
|
-
description: 'create
|
|
2985
|
-
+ 'next planned window.',
|
|
2974
|
+
description: 'create, list, pause/resume, delete, or start one run now without moving the next window.',
|
|
2986
2975
|
},
|
|
2987
|
-
id: { type: 'string', description: 'Schedule id (sch-...)
|
|
2988
|
-
name: { type: 'string', description: '
|
|
2976
|
+
id: { type: 'string', description: 'Schedule id (sch-...); required for pause, resume, delete, run-now.' },
|
|
2977
|
+
name: { type: 'string', description: 'create: short name used in list and notifications.' },
|
|
2989
2978
|
goal: {
|
|
2990
2979
|
type: 'string',
|
|
2991
|
-
description: '
|
|
2980
|
+
description: 'create: the complete goal the scheduled run starts. Give goal or template_id, not both.',
|
|
2992
2981
|
},
|
|
2993
2982
|
template_id: {
|
|
2994
2983
|
type: 'string',
|
|
2995
|
-
description: '
|
|
2996
|
-
+ 'goal is the expanded text, so a later template edit does not change the plan.',
|
|
2984
|
+
description: 'create: expand this template into the goal at create time.',
|
|
2997
2985
|
},
|
|
2998
2986
|
params: {
|
|
2999
2987
|
type: 'object',
|
|
3000
|
-
description: '
|
|
2988
|
+
description: 'create with template_id: values for the placeholders.',
|
|
3001
2989
|
additionalProperties: { type: 'string' },
|
|
3002
2990
|
},
|
|
3003
2991
|
cron: {
|
|
3004
2992
|
type: 'string',
|
|
3005
|
-
description: '
|
|
3006
|
-
+ '
|
|
2993
|
+
description: 'create: 5-field cron (minute hour day month weekday) in timezone, e.g. "0 9 * * MON-FRI". '
|
|
2994
|
+
+ 'Give cron or every_minutes, not both.',
|
|
3007
2995
|
},
|
|
3008
2996
|
every_minutes: {
|
|
3009
2997
|
type: 'number',
|
|
3010
|
-
description: '
|
|
3011
|
-
+ 'later runs are one interval after the previous planned window.',
|
|
2998
|
+
description: 'create: fixed interval instead of cron; first run one interval from now.',
|
|
3012
2999
|
},
|
|
3013
3000
|
timezone: {
|
|
3014
3001
|
type: 'string',
|
|
3015
|
-
description: '
|
|
3016
|
-
+ 'clock is not used as an implicit zone.',
|
|
3002
|
+
description: 'create: IANA zone the cron is written in (default UTC), e.g. "Asia/Shanghai".',
|
|
3017
3003
|
},
|
|
3018
3004
|
miss_policy: {
|
|
3019
3005
|
type: 'string',
|
|
3020
3006
|
enum: ['latest', 'none'],
|
|
3021
|
-
description: '
|
|
3022
|
-
+ 'the others missed; none skips all due windows and advances to the next one.',
|
|
3007
|
+
description: 'create: after downtime, latest (default) runs the newest missed window; none skips them.',
|
|
3023
3008
|
},
|
|
3024
3009
|
mode: {
|
|
3025
3010
|
type: 'string',
|
|
3026
3011
|
enum: ['planned', 'direct'],
|
|
3027
|
-
description: '
|
|
3012
|
+
description: 'create: run mode per execution, as in superagent_start.',
|
|
3028
3013
|
},
|
|
3029
3014
|
goal_mode: {
|
|
3030
3015
|
type: 'boolean',
|
|
3031
|
-
description: '
|
|
3016
|
+
description: 'create: run each execution in goal mode with acceptance checking.',
|
|
3032
3017
|
},
|
|
3033
3018
|
acceptance: {
|
|
3034
3019
|
type: 'array',
|
|
3035
|
-
description: '
|
|
3020
|
+
description: 'create with goal_mode: conditions, same shape as superagent_start.',
|
|
3036
3021
|
items: {
|
|
3037
3022
|
type: 'object',
|
|
3038
3023
|
properties: {
|
|
@@ -3054,14 +3039,13 @@ export function apply(ctx, config) {
|
|
|
3054
3039
|
required: ['text'],
|
|
3055
3040
|
},
|
|
3056
3041
|
},
|
|
3057
|
-
max_rounds: { type: 'number', description: '
|
|
3058
|
-
max_wall_clock_minutes: { type: 'number', description: '
|
|
3059
|
-
no_progress_rounds: { type: 'number', description: '
|
|
3042
|
+
max_rounds: { type: 'number', description: 'create with goal_mode: rounds per execution (default 5, max 20).' },
|
|
3043
|
+
max_wall_clock_minutes: { type: 'number', description: 'create with goal_mode: wall-clock budget per execution.' },
|
|
3044
|
+
no_progress_rounds: { type: 'number', description: 'create with goal_mode: no-progress rounds before stopping.' },
|
|
3060
3045
|
budget: {
|
|
3061
3046
|
type: 'object',
|
|
3062
|
-
description: '
|
|
3063
|
-
+ 'max_total_model_calls, max_total_tokens
|
|
3064
|
-
+ 'total pauses the plan and records the reason.',
|
|
3047
|
+
description: 'create: per-execution caps (max_model_calls, max_tokens) and whole-plan caps '
|
|
3048
|
+
+ '(max_total_model_calls, max_total_tokens, max_total_runs).',
|
|
3065
3049
|
properties: {
|
|
3066
3050
|
max_model_calls: { type: 'number' },
|
|
3067
3051
|
max_tokens: { type: 'number' },
|
|
@@ -3072,15 +3056,11 @@ export function apply(ctx, config) {
|
|
|
3072
3056
|
},
|
|
3073
3057
|
human_priority: {
|
|
3074
3058
|
type: 'boolean',
|
|
3075
|
-
description: '
|
|
3076
|
-
+ 'manual superagent_start at the same moment still finds room.',
|
|
3059
|
+
description: 'create: when true (default), a scheduled run cannot take the last slot a manual start needs.',
|
|
3077
3060
|
},
|
|
3078
3061
|
session_id: {
|
|
3079
3062
|
type: 'string',
|
|
3080
|
-
description: '
|
|
3081
|
-
+ 'the calling session. After a host restart the plugin asks the Host Session API to reopen that session, '
|
|
3082
|
-
+ 'and creates a replacement if it was deleted, so a plan does not depend on the original process staying '
|
|
3083
|
-
+ 'alive. On a host without that API the plan is marked at create time as requiring a resident session.',
|
|
3063
|
+
description: 'create: session that owns the runs and receives notifications (default: this session).',
|
|
3084
3064
|
},
|
|
3085
3065
|
},
|
|
3086
3066
|
required: ['action'],
|
|
@@ -3166,7 +3146,7 @@ export function apply(ctx, config) {
|
|
|
3166
3146
|
return describeError(error)
|
|
3167
3147
|
}
|
|
3168
3148
|
},
|
|
3169
|
-
}))
|
|
3149
|
+
}), EXTRA_TOOLS)
|
|
3170
3150
|
|
|
3171
3151
|
// The embedding surface is opt-in: mounting the plugin must not open a port
|
|
3172
3152
|
// unasked. When it is on, every request goes through the same orchestrator as
|
|
@@ -3175,22 +3155,21 @@ export function apply(ctx, config) {
|
|
|
3175
3155
|
ctx.tools.register(defineTool({
|
|
3176
3156
|
name: 'superagent_audit',
|
|
3177
3157
|
description:
|
|
3178
|
-
'Query the append-only audit trail (tool calls, path writes, commands, blocks, approvals,
|
|
3179
|
-
+ '
|
|
3180
|
-
+ 'JSONL or CSV file.',
|
|
3158
|
+
'Query the append-only audit trail (tool calls, path writes, commands, blocks, approvals, decisions, run '
|
|
3159
|
+
+ 'lifecycle) for one run or a time window, or export the matching events as JSONL or CSV.',
|
|
3181
3160
|
properties: {
|
|
3182
3161
|
run_id: { type: 'string', description: 'Only events for this run id.' },
|
|
3183
3162
|
subtask_id: { type: 'string', description: 'Only events for one subtask, e.g. "subtask-2" or "aggregator".' },
|
|
3184
3163
|
kind: { type: 'string', description: 'Event kind, e.g. tool.call, path.write, command.exec, blocked, approved, attention.' },
|
|
3185
|
-
decision: { type: 'string', description: '
|
|
3186
|
-
result: { type: 'string', description: '
|
|
3187
|
-
target: { type: 'string', description: 'Substring of the path, command, or question
|
|
3188
|
-
since: { type: 'string', description: 'ISO timestamp; events
|
|
3189
|
-
until: { type: 'string', description: 'ISO timestamp; events
|
|
3190
|
-
limit: { type: 'number', description: 'Maximum events
|
|
3164
|
+
decision: { type: 'string', description: 'allow, confirm, or deny.' },
|
|
3165
|
+
result: { type: 'string', description: 'e.g. ok, blocked, pending, approved, failed.' },
|
|
3166
|
+
target: { type: 'string', description: 'Substring of the path, command, or question.' },
|
|
3167
|
+
since: { type: 'string', description: 'ISO timestamp; earlier events are skipped.' },
|
|
3168
|
+
until: { type: 'string', description: 'ISO timestamp; later events are skipped.' },
|
|
3169
|
+
limit: { type: 'number', description: 'Maximum events read or rows printed (default 8 for summary, all for export).' },
|
|
3191
3170
|
order: { type: 'string', description: 'asc (oldest first, default) or desc.' },
|
|
3192
|
-
format: { type: 'string', description: 'summary (default), jsonl, or csv
|
|
3193
|
-
out_path: { type: 'string', description: 'File
|
|
3171
|
+
format: { type: 'string', description: 'summary (default), jsonl, or csv; the last two write a file and return its path.' },
|
|
3172
|
+
out_path: { type: 'string', description: 'File for jsonl/csv; defaults to <stateDir>/audit/audit-export-<time>.<ext>.' },
|
|
3194
3173
|
},
|
|
3195
3174
|
async execute(args = {}) {
|
|
3196
3175
|
try {
|
|
@@ -3226,7 +3205,7 @@ export function apply(ctx, config) {
|
|
|
3226
3205
|
return describeError(error)
|
|
3227
3206
|
}
|
|
3228
3207
|
},
|
|
3229
|
-
}))
|
|
3208
|
+
}), EXTRA_TOOLS)
|
|
3230
3209
|
}
|
|
3231
3210
|
|
|
3232
3211
|
if (cfg.controlPort !== null) {
|
|
@@ -3766,7 +3745,19 @@ export function apply(ctx, config) {
|
|
|
3766
3745
|
// waterfall listener, and a listener that never calls `next()` would win by
|
|
3767
3746
|
// order alone. Answering our own sessions first is what routes this tree's
|
|
3768
3747
|
// ask to this page; every other session still falls through untouched.
|
|
3769
|
-
|
|
3748
|
+
// Cordis exposes the root context under a well-known symbol, not a `root`
|
|
3749
|
+
// property; reading `ctx.root` makes the service resolver throw before the
|
|
3750
|
+
// bridge is even registered. Fall back to this plugin's own context so a
|
|
3751
|
+
// host that hides the symbol still keeps its normal answerer chain.
|
|
3752
|
+
const rootContext = (() => {
|
|
3753
|
+
try {
|
|
3754
|
+
const candidate = ctx[Symbol.for('cordis.root')]
|
|
3755
|
+
return candidate && typeof candidate.on === 'function' ? candidate : ctx
|
|
3756
|
+
} catch {
|
|
3757
|
+
return ctx
|
|
3758
|
+
}
|
|
3759
|
+
})()
|
|
3760
|
+
const approvalCtx = rootContext
|
|
3770
3761
|
const bridgeApproval = (request, next) => {
|
|
3771
3762
|
try {
|
|
3772
3763
|
const session = request?.agent?.session
|