@nordhavnhq/runner 0.103.0 → 0.105.0
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/runtime/up.js +27 -8
- package/dist/tools/console.js +1 -1
- package/dist/tools/http.js +4 -4
- package/dist/version.json +3 -3
- package/node_modules/@nordhavnhq/runner-browser/dist/show.js +1 -1
- package/node_modules/@nordhavnhq/runner-browser/package.json +1 -1
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/batch.d.ts +7 -7
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/batch.js +16 -15
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/calls.d.ts +2 -2
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/calls.js +4 -3
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/loop.d.ts +17 -17
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/loop.js +35 -34
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/phases.d.ts +12 -12
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/phases.js +14 -13
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/pins.d.ts +3 -3
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/pins.js +9 -9
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/tool-names.d.ts +24 -5
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/tool-names.js +36 -9
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/version.d.ts +1 -1
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/version.js +1 -1
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/wire.d.ts +16 -8
- package/node_modules/@nordhavnhq/runner-runtime/dist/contract/wire.js +8 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/index.d.ts +1 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/index.js +1 -0
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/auto-load.d.ts +3 -3
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/auto-load.js +5 -4
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/extract-json.d.ts +1 -1
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/extract-json.js +1 -1
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/handle-chat.js +6 -6
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/handle-task.js +14 -14
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/loop.d.ts +6 -6
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/loop.js +12 -11
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/phased-loop.js +2 -1
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/run-tools.d.ts +1 -1
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/run-tools.js +1 -1
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/scratch-prompt.js +1 -1
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/task-validation.d.ts +2 -2
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/task-validation.js +2 -2
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/unload-toolset.d.ts +5 -5
- package/node_modules/@nordhavnhq/runner-runtime/dist/runtime/unload-toolset.js +18 -17
- package/node_modules/@nordhavnhq/runner-runtime/dist/tools/delegate.d.ts +2 -2
- package/node_modules/@nordhavnhq/runner-runtime/dist/tools/delegate.js +3 -3
- package/node_modules/@nordhavnhq/runner-runtime/dist/tools/index.d.ts +3 -3
- package/node_modules/@nordhavnhq/runner-runtime/dist/tools/mcp.d.ts +1 -1
- package/node_modules/@nordhavnhq/runner-runtime/dist/tools/mcp.js +5 -4
- package/node_modules/@nordhavnhq/runner-runtime/package.json +1 -1
- package/package.json +3 -3
|
@@ -15,7 +15,7 @@ import { createChatRunEnds, endsWithin, SUPERSEDED_RUN_WAIT_MS } from './chat-ru
|
|
|
15
15
|
import { dispatchScratchKey } from '../contract/calls.js';
|
|
16
16
|
import { MAX_LOOP_MS, MAX_TOOL_ROUNDS } from '../constants.js';
|
|
17
17
|
import { TOOL_RESULT_MAX_CHARS } from '../contract/loop.js';
|
|
18
|
-
import { buildUnknownToolError } from '../contract/tool-names.js';
|
|
18
|
+
import { buildUnknownToolError, osTool } from '../contract/tool-names.js';
|
|
19
19
|
import { runAgenticLoop, } from './loop.js';
|
|
20
20
|
/**
|
|
21
21
|
* The one-to-one half of the cutoff notice: the next thing the person types
|
|
@@ -34,7 +34,7 @@ const CONTINUE_HINT = 'Reply "continue" and I\'ll pick up where I left off.';
|
|
|
34
34
|
* notice is appended to IS the agent's own account of where it got to, which is
|
|
35
35
|
* why the notice never replaces a reply, only follows it.
|
|
36
36
|
*/
|
|
37
|
-
const MEETING_CUTOFF_HANDOVER = 'Whatever I was in the middle of is unfinished. This is a room, so there is nothing to reply "continue" to: the next turn is routed and may not come back to me. If the rest still needs doing, put it in a task with `
|
|
37
|
+
const MEETING_CUTOFF_HANDOVER = 'Whatever I was in the middle of is unfinished. This is a room, so there is nothing to reply "continue" to: the next turn is routed and may not come back to me. If the rest still needs doing, put it in a task with `os_create_task` and say here that you did.';
|
|
38
38
|
/** A code session's reply suggestion on its own last line (the studio's shared/utils/reply-suggestion.ts). */
|
|
39
39
|
const REPLY_SUGGESTION_LINE = /(?:^|\n)[ \t]*<reply-suggestion>([^\n]*)<\/reply-suggestion>\s*$/i;
|
|
40
40
|
const REPLY_SUGGESTION_ANY_TAG = /<\/?reply-suggestion\b/i;
|
|
@@ -255,7 +255,7 @@ export function createHandleChat(deps) {
|
|
|
255
255
|
// 1. Tool registry - mutable across rounds within this dispatch.
|
|
256
256
|
// Seeded from the studio's dispatch (bootstrap + anything previously
|
|
257
257
|
// loaded in this conversation). The model expands it mid-loop by
|
|
258
|
-
// calling `
|
|
258
|
+
// calling `os_load_toolset`, which streams new defs back through
|
|
259
259
|
// `ctx.loadTools` (defined below) and into this map. The agentic
|
|
260
260
|
// loop re-reads it at the top of every round, so new tools become
|
|
261
261
|
// callable on the next inference call.
|
|
@@ -434,12 +434,12 @@ export function createHandleChat(deps) {
|
|
|
434
434
|
// 5. Tool-execution adapter - owns local-vs-MCP routing, WS
|
|
435
435
|
// `chat:tool-use` framing, and per-tool stdout logging.
|
|
436
436
|
const executeTool = async (call, toolDef) => {
|
|
437
|
-
// `
|
|
437
|
+
// `os_unload_toolset` carries `mcpPath: null` and is not a local
|
|
438
438
|
// tool: it only mutates this dispatch's registry, which the provider
|
|
439
439
|
// cannot see. Routed BEFORE the auto-load and unknown-tool branches
|
|
440
440
|
// below, which would otherwise reject it for having no path at all.
|
|
441
441
|
// Mirrors the studio-side interception in internal-runtime/adapters.ts.
|
|
442
|
-
if (toolDef && call.name === '
|
|
442
|
+
if (toolDef && call.name === osTool('unload_toolset')) {
|
|
443
443
|
const unloadStart = Date.now();
|
|
444
444
|
sendWsToolUse(socket, msg.conversationId, call.name, 'running', call.arguments);
|
|
445
445
|
emitEvent({
|
|
@@ -734,7 +734,7 @@ export function createHandleChat(deps) {
|
|
|
734
734
|
// made every stop-during-a-tool-call land as "I finished this turn without a
|
|
735
735
|
// message to send", since `cutoffNotice` has no text for a user abort.
|
|
736
736
|
const aborted = loopResult.stopReason === 'aborted';
|
|
737
|
-
// The turn ended on a question (
|
|
737
|
+
// The turn ended on a question (os_ask in a chat). The studio already wrote
|
|
738
738
|
// it into the chat as this agent's message, so there is nothing to add -
|
|
739
739
|
// but `chat:done` still goes out, empty, because that is what completes
|
|
740
740
|
// the queue entry and lets the agent go idle. Mirrors `resolveChatReply`.
|
|
@@ -13,12 +13,12 @@ import { dispatchScratchKey } from '../contract/calls.js';
|
|
|
13
13
|
import { MAX_TASK_TOOL_ROUNDS } from '../constants.js';
|
|
14
14
|
import { extractValidationFromUpdateTaskOutput, formatValidationFeedback, } from './task-validation.js';
|
|
15
15
|
import { pendingActionInReply, pendingActionNudge, deliversTaskWork, isRunEndingTaskStatus, runEndingReply, TOOL_RESULT_MAX_CHARS } from '../contract/loop.js';
|
|
16
|
-
import { buildUnknownToolError } from '../contract/tool-names.js';
|
|
16
|
+
import { buildUnknownToolError, osTool } from '../contract/tool-names.js';
|
|
17
17
|
import { runTaskLoop } from './phased-loop.js';
|
|
18
18
|
import { emitEvent } from './events.js';
|
|
19
19
|
import { backgroundWaitMs, formatBackgroundCommandsNote, formatBackgroundWaitMessage, } from './background-commands.js';
|
|
20
20
|
// Reserved task-memory key holding the agent's pinned-notes working set, so the
|
|
21
|
-
// `
|
|
21
|
+
// `os_pin` facts survive a task interruption / resume (a fresh dispatch of the
|
|
22
22
|
// same task starts a new in-memory loop with empty pins otherwise). Mirrors the
|
|
23
23
|
// studio-side run-task.ts. Persisted via the studio memory endpoint; task-scoped
|
|
24
24
|
// so it is NOT loaded into the `## Memory` prompt block.
|
|
@@ -64,7 +64,7 @@ function persistPinnedNotes(studioUrl, token, taskUid, notes) {
|
|
|
64
64
|
// ─── Result-reply extraction ──────────────────────────────────────────
|
|
65
65
|
/**
|
|
66
66
|
* Pull a human-readable reply out of the resultJson the agent submitted via
|
|
67
|
-
*
|
|
67
|
+
* os_update_task. Used when we short-circuit the loop after a terminal
|
|
68
68
|
* status update - the resultJson IS the deliverable.
|
|
69
69
|
*/
|
|
70
70
|
function extractReplyFromResultJson(resultJson) {
|
|
@@ -151,7 +151,7 @@ export function createHandleTask(deps) {
|
|
|
151
151
|
let finalModel;
|
|
152
152
|
try {
|
|
153
153
|
// Mutable per-dispatch tool registry. Seeded from the studio's bootstrap
|
|
154
|
-
// set; the model expands it mid-loop via `
|
|
154
|
+
// set; the model expands it mid-loop via `os_load_toolset`, which
|
|
155
155
|
// streams new defs back through `ctx.loadTools` (defined below) and into
|
|
156
156
|
// this map. The agentic loop re-reads it at the top of every round.
|
|
157
157
|
const registry = new Map();
|
|
@@ -309,15 +309,15 @@ export function createHandleTask(deps) {
|
|
|
309
309
|
// Tool-execution adapter - owns local-vs-MCP routing, WS
|
|
310
310
|
// `task:tool-use` framing, per-tool stdout logging, event emission, and
|
|
311
311
|
// the schema-validation + terminal-status detection that fires when the
|
|
312
|
-
// agent calls `
|
|
312
|
+
// agent calls `os_update_task` on the current task. Mirrors the
|
|
313
313
|
// OS-side `runInternalTask` decision matrix; keep them aligned.
|
|
314
314
|
const executeTool = async (call, toolDef) => {
|
|
315
|
-
// `
|
|
315
|
+
// `os_unload_toolset` carries `mcpPath: null` and is not a local
|
|
316
316
|
// tool: it only mutates this dispatch's registry, which the provider
|
|
317
317
|
// cannot see. Routed BEFORE the auto-load and unknown-tool branches
|
|
318
318
|
// below, which would otherwise reject it for having no path at all.
|
|
319
319
|
// Mirrors the studio-side interception in internal-runtime/adapters.ts.
|
|
320
|
-
if (toolDef && call.name === '
|
|
320
|
+
if (toolDef && call.name === osTool('unload_toolset')) {
|
|
321
321
|
const unloadStart = Date.now();
|
|
322
322
|
sendWsTaskToolUse(socket, task.queueId, call.name, 'running', call.arguments);
|
|
323
323
|
emitEvent({
|
|
@@ -386,7 +386,7 @@ export function createHandleTask(deps) {
|
|
|
386
386
|
}
|
|
387
387
|
// Note a successful durable persist so the scratch heads-up can stay
|
|
388
388
|
// quiet for runs that clearly moved their output out of scratch.
|
|
389
|
-
if (!isError && (call.name === 'runner_upload_file' || call.name === '
|
|
389
|
+
if (!isError && (call.name === 'runner_upload_file' || call.name === osTool('save_file'))) {
|
|
390
390
|
persistedToStudio = true;
|
|
391
391
|
}
|
|
392
392
|
// Rich first-use fallback: the call errored on a tool we just
|
|
@@ -405,10 +405,10 @@ export function createHandleTask(deps) {
|
|
|
405
405
|
durMs: durationMs,
|
|
406
406
|
...(isError ? { error: result } : {}),
|
|
407
407
|
});
|
|
408
|
-
//
|
|
408
|
+
// os_update_task: validate the structured result and detect
|
|
409
409
|
// terminal status. Only react when the underlying MCP call succeeded
|
|
410
410
|
// - errored calls leave state untouched.
|
|
411
|
-
if (call.name === '
|
|
411
|
+
if (call.name === osTool('update_task') && !isError) {
|
|
412
412
|
const args = call.arguments;
|
|
413
413
|
if (args?.resultJson) {
|
|
414
414
|
const validation = extractValidationFromUpdateTaskOutput(result);
|
|
@@ -446,7 +446,7 @@ export function createHandleTask(deps) {
|
|
|
446
446
|
}
|
|
447
447
|
else if (doneOnInvalidSchema && targetsCurrentTask && validationRetriesLeft === 0) {
|
|
448
448
|
pendingValidationFeedback =
|
|
449
|
-
'Your `done` call was rejected: the structured result has failed schema validation on every retry, and there are no retries remaining. The task will be marked failed. Do not call `
|
|
449
|
+
'Your `done` call was rejected: the structured result has failed schema validation on every retry, and there are no retries remaining. The task will be marked failed. Do not call `os_update_task` again; end your turn.';
|
|
450
450
|
terminalStatusSubmitted = 'failed';
|
|
451
451
|
terminalReplyOverride = `Schema validation failed after all retries - ${(lastValidationErrors ?? []).map(e => `${e.path}: ${e.message}`).join('; ')}`;
|
|
452
452
|
}
|
|
@@ -475,7 +475,7 @@ export function createHandleTask(deps) {
|
|
|
475
475
|
// and would prod the model to overwrite a clean result. Mirrors
|
|
476
476
|
// the same guard in OS-side run-task.ts.
|
|
477
477
|
// - `onAfterRound` flushes pending validation feedback and stops the
|
|
478
|
-
// loop once a terminal `
|
|
478
|
+
// loop once a terminal `os_update_task` has been observed.
|
|
479
479
|
// - `onInferenceInput`/`Output` mirror the verbose `--debug` logs the
|
|
480
480
|
// old inlined loop emitted, only attached when debug is on.
|
|
481
481
|
const drainSteerInstruction = () => {
|
|
@@ -598,7 +598,7 @@ export function createHandleTask(deps) {
|
|
|
598
598
|
initialPinnedNotes,
|
|
599
599
|
onPinnedNotesChanged: notes => persistPinnedNotes(config.studioUrl, agent.token, taskInput?.taskUid, notes),
|
|
600
600
|
// A task has no persisted conversation to archive - handle
|
|
601
|
-
//
|
|
601
|
+
// os_compact by folding the in-memory transcript.
|
|
602
602
|
compactInMemory: true,
|
|
603
603
|
// Notes for whoever picks the task up next: full ones when the run
|
|
604
604
|
// stops before it is done, short ones for the reviewer when it handed
|
|
@@ -713,7 +713,7 @@ export function createHandleTask(deps) {
|
|
|
713
713
|
channel: 'task',
|
|
714
714
|
agentSlug: agent.slug,
|
|
715
715
|
queueUid: task.queueUid,
|
|
716
|
-
message: `${leftInScratch} file(s) left in scratch and nothing was persisted to the studio. Scratch is auto-deleted on a TTL, so this content will be lost - commit deliverables to the project or upload assets with runner_upload_file /
|
|
716
|
+
message: `${leftInScratch} file(s) left in scratch and nothing was persisted to the studio. Scratch is auto-deleted on a TTL, so this content will be lost - commit deliverables to the project or upload assets with runner_upload_file / os_save_file.`,
|
|
717
717
|
});
|
|
718
718
|
}
|
|
719
719
|
}
|
|
@@ -96,7 +96,7 @@ export interface AgenticLoopHooks {
|
|
|
96
96
|
* `{ continueWithUserMessage }` to push the assistant's reply back into
|
|
97
97
|
* the conversation followed by a corrective user message and run another
|
|
98
98
|
* round (task uses this to nudge the agent into calling
|
|
99
|
-
* `
|
|
99
|
+
* `os_update_task` when a structured-result schema is required).
|
|
100
100
|
* Returning `void` ends the loop with `finalReply = result.message`. */
|
|
101
101
|
onEmptyToolCalls?: (round: number, finalReply: string) => Promise<{
|
|
102
102
|
continueWithUserMessage?: string;
|
|
@@ -105,7 +105,7 @@ export interface AgenticLoopHooks {
|
|
|
105
105
|
} | void;
|
|
106
106
|
/** Fired after all tool calls in a round have been executed and their
|
|
107
107
|
* results appended to the conversation. Return `{ stop: true }` to break
|
|
108
|
-
* out of the loop early (task uses this once a terminal `
|
|
108
|
+
* out of the loop early (task uses this once a terminal `os_update_task`
|
|
109
109
|
* call has been seen). `injectUserMessage` queues a user-role message
|
|
110
110
|
* onto the next round (task uses this to surface validation feedback).
|
|
111
111
|
* `overrideFinalReply` replaces the loop's `finalReply` when `stop` is
|
|
@@ -125,7 +125,7 @@ export interface AgenticLoopOpts {
|
|
|
125
125
|
* trim these before passing them in. */
|
|
126
126
|
initialMessages: ModelMessage[];
|
|
127
127
|
/** Mutable per-dispatch tool registry. The loop re-reads it at the top of
|
|
128
|
-
* every round so mid-loop expansion via `
|
|
128
|
+
* every round so mid-loop expansion via `os_load_toolset` is picked up
|
|
129
129
|
* on the next inference call. */
|
|
130
130
|
registry: Map<string, ToolDefPayload>;
|
|
131
131
|
callInference: CallInference;
|
|
@@ -189,13 +189,13 @@ export interface AgenticLoopOpts {
|
|
|
189
189
|
* work started. */
|
|
190
190
|
startedAtMs?: number;
|
|
191
191
|
/** Pinned notes restored from task memory at dispatch (label -> text), so the
|
|
192
|
-
* agent's `
|
|
192
|
+
* agent's `os_pin` working set survives a task interruption / resume.
|
|
193
193
|
* Auto-pinned skills are NOT restored here - they are cheaply re-loaded. */
|
|
194
194
|
initialPinnedNotes?: Array<[string, string]>;
|
|
195
195
|
/** Fired whenever the agent's pinned notes change, so the caller can persist
|
|
196
196
|
* them (the task runner writes them to task-scoped memory). */
|
|
197
197
|
onPinnedNotesChanged?: (notes: Array<[string, string]>) => void;
|
|
198
|
-
/** Handle `
|
|
198
|
+
/** Handle `os_compact` IN-LOOP (a fold of the live in-memory
|
|
199
199
|
* transcript into a summary) instead of routing it to the MCP endpoint.
|
|
200
200
|
* Set by task runs, which have no persisted conversation to archive - their
|
|
201
201
|
* context is this message array, so the tool must fold it here. Chat runs
|
|
@@ -215,7 +215,7 @@ export interface AgenticLoopOpts {
|
|
|
215
215
|
nudgePins?: boolean;
|
|
216
216
|
/** Remind the run (at most `MAX_TODO_NUDGES` times) to update its todo
|
|
217
217
|
* list when it has open items and `TODO_NUDGE_AFTER_CALLS` tool calls
|
|
218
|
-
* went by without `
|
|
218
|
+
* went by without `os_manage_todos`. Off for delegations. */
|
|
219
219
|
nudgeTodos?: boolean;
|
|
220
220
|
hooks?: AgenticLoopHooks;
|
|
221
221
|
}
|
|
@@ -3,6 +3,7 @@ import { COMPACTION_MIN_ROUNDS, COMPACTION_RETRY_ROUNDS, compactionThresholdToke
|
|
|
3
3
|
import { CALL_TOOL, callResultCap, fitCallResult, readableCallResult } from '../contract/calls.js';
|
|
4
4
|
import { byToolName, orderRunTools, trackLoadedTools } from './run-tools.js';
|
|
5
5
|
import { SKILL_PIN_MAX_CHARS, applyPin, clipSkillPin, composeSystemPrompt, pinSlugFromArgs } from '../contract/pins.js';
|
|
6
|
+
import { osTool } from '../contract/tool-names.js';
|
|
6
7
|
import { buildAssistantToolCallsMessage, buildToolResultMessage } from './messages.js';
|
|
7
8
|
export { byToolName };
|
|
8
9
|
export async function runAgenticLoop(opts) {
|
|
@@ -16,7 +17,7 @@ export async function runAgenticLoop(opts) {
|
|
|
16
17
|
...initialMessages,
|
|
17
18
|
];
|
|
18
19
|
// Durable "Task context": skill playbooks the agent loads (auto) and facts
|
|
19
|
-
// it pins with
|
|
20
|
+
// it pins with os_pin, rendered into the system message. It is the one
|
|
20
21
|
// channel that survives a fold into a summary, the fix for agents losing
|
|
21
22
|
// load-bearing knowledge and re-discovering it. Mirrors the studio side in
|
|
22
23
|
// server/utils/internal-runtime/loop.ts.
|
|
@@ -28,7 +29,7 @@ export async function runAgenticLoop(opts) {
|
|
|
28
29
|
// append-only (see the agent contract's "Keeping the context bounded"): a
|
|
29
30
|
// system prompt rewritten mid-run re-caches everything after it and
|
|
30
31
|
// invalidates every thinking block. Until the next fold a pin is in the
|
|
31
|
-
// transcript already, as the
|
|
32
|
+
// transcript already, as the os_pin call itself.
|
|
32
33
|
let systemStale = true;
|
|
33
34
|
// The tools of the last round, so a closing call (the handoff, a fold) asks
|
|
34
35
|
// with the same prefix and is a cache read rather than a re-write.
|
|
@@ -37,7 +38,7 @@ export async function runAgenticLoop(opts) {
|
|
|
37
38
|
const ask = [...initialMessages].reverse().find(m => m.role === 'user') ?? null;
|
|
38
39
|
// What earlier folds replaced, so the working set still names the whole run.
|
|
39
40
|
const folded = [];
|
|
40
|
-
// A fold the agent asked for with
|
|
41
|
+
// A fold the agent asked for with os_compact, run at the next round.
|
|
41
42
|
let compactRequested = false;
|
|
42
43
|
// No fold before this round (set after one that failed).
|
|
43
44
|
let foldBlockedUntilRound = 0;
|
|
@@ -170,7 +171,7 @@ export async function runAgenticLoop(opts) {
|
|
|
170
171
|
* appended: the transcript is never rewritten later. A result the host kept
|
|
171
172
|
* whole (`spillToolOutput`) is cut hard and the note says where the copy
|
|
172
173
|
* is; one with no copy keeps the larger cap (`toolResultCaps`). The
|
|
173
|
-
* answers of `
|
|
174
|
+
* answers of `os_call_agent` have a budget of their own, shared per
|
|
174
175
|
* answer (`fitCallResult`): they are what the call was placed for. */
|
|
175
176
|
const caps = toolResultCaps(limits.toolResultTruncateChars);
|
|
176
177
|
const callCap = callResultCap(limits.toolResultTruncateChars);
|
|
@@ -242,7 +243,7 @@ export async function runAgenticLoop(opts) {
|
|
|
242
243
|
}
|
|
243
244
|
// The safety net, at a round boundary and before anything new is appended
|
|
244
245
|
// this round: once the last call's context passed the threshold (or the
|
|
245
|
-
// agent asked with
|
|
246
|
+
// agent asked with os_compact), fold the whole transcript into a
|
|
246
247
|
// summary. Nothing else ever rewrites the history.
|
|
247
248
|
const overCeiling = (totalUsage.contextTokens ?? 0) >= compactionThresholdTokens(limits.contextWindowTokens);
|
|
248
249
|
if ((overCeiling || compactRequested)
|
|
@@ -436,10 +437,10 @@ export async function runAgenticLoop(opts) {
|
|
|
436
437
|
messages.push(buildToolResultMessage(call.id, call.name, truncatedCallMessage(call.name), { isError: true }));
|
|
437
438
|
continue;
|
|
438
439
|
}
|
|
439
|
-
//
|
|
440
|
+
// os_pin is handled in-loop (no MCP endpoint): it mutates the durable
|
|
440
441
|
// Task-context block re-injected into the system message each round.
|
|
441
442
|
// Intercepted before the repeat-guard so re-pinning is never blocked.
|
|
442
|
-
if (call.name === '
|
|
443
|
+
if (call.name === osTool('pin')) {
|
|
443
444
|
const pinResult = applyPin(call.arguments, pinnedNotes);
|
|
444
445
|
if (!pinResult.startsWith('Error:')) {
|
|
445
446
|
pinnedAny = true;
|
|
@@ -448,14 +449,14 @@ export async function runAgenticLoop(opts) {
|
|
|
448
449
|
messages.push(buildToolResultMessage(call.id, call.name, pinResult, { isError: false }));
|
|
449
450
|
continue;
|
|
450
451
|
}
|
|
451
|
-
//
|
|
452
|
+
// os_compact in a task has no persisted conversation to archive - its
|
|
452
453
|
// context IS this in-memory transcript. It schedules the safety-net fold
|
|
453
454
|
// for the next round boundary (folding here would cut the tool round this
|
|
454
455
|
// call is part of), rather than routing to the MCP endpoint, which would
|
|
455
456
|
// return "requires a conversation context". Placed before the
|
|
456
457
|
// repeat-guard so asking again is never blocked. Chat runs leave
|
|
457
458
|
// compactInMemory false and fall through to the MCP archival path.
|
|
458
|
-
if (compactInMemory && call.name === '
|
|
459
|
+
if (compactInMemory && call.name === osTool('compact')) {
|
|
459
460
|
const compact = scheduleInMemoryCompaction(messages);
|
|
460
461
|
if (compact.scheduled)
|
|
461
462
|
compactRequested = true;
|
|
@@ -500,7 +501,7 @@ export async function runAgenticLoop(opts) {
|
|
|
500
501
|
pinNudged = true;
|
|
501
502
|
capped += PIN_NUDGE_NOTE;
|
|
502
503
|
}
|
|
503
|
-
if (call.name === '
|
|
504
|
+
if (call.name === osTool('manage_todos')) {
|
|
504
505
|
if (!outcome.isError) {
|
|
505
506
|
lastTodos = todosFromArgs(call.arguments) ?? lastTodos;
|
|
506
507
|
callsSinceTodos = 0;
|
|
@@ -523,7 +524,7 @@ export async function runAgenticLoop(opts) {
|
|
|
523
524
|
// Auto-pin loaded skill playbooks: they are load-bearing for the whole
|
|
524
525
|
// task, so the Task-context block carries them through a fold into a
|
|
525
526
|
// summary.
|
|
526
|
-
if (call.name === '
|
|
527
|
+
if (call.name === osTool('get_skill') && !outcome.isError) {
|
|
527
528
|
const slug = pinSlugFromArgs(call.arguments);
|
|
528
529
|
if (slug)
|
|
529
530
|
pinnedSkills.set(slug, clipSkillPin(outcome.result, SKILL_PIN_MAX_CHARS));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { workingSetLedger } from '../contract/loop.js';
|
|
2
2
|
import { runPhasedLoop } from '../contract/phases.js';
|
|
3
|
+
import { osTool } from '../contract/tool-names.js';
|
|
3
4
|
import { runAgenticLoop } from './loop.js';
|
|
4
5
|
/**
|
|
5
6
|
* A task run's loop: the single-model loop, or, when the dispatch carries
|
|
@@ -36,7 +37,7 @@ export async function runTaskLoop(opts, phased) {
|
|
|
36
37
|
runPhase: run => runAgenticLoop(phaseLoopOpts(base, run, phased.inferenceFor(run.slot, run.phase))),
|
|
37
38
|
});
|
|
38
39
|
}
|
|
39
|
-
const LOAD_TOOLSET = '
|
|
40
|
+
const LOAD_TOOLSET = osTool('load_toolset');
|
|
40
41
|
/** The loop options of one phase: the run's own, with the phase's chain, transport, limits and guard. */
|
|
41
42
|
function phaseLoopOpts(base, run, callInference) {
|
|
42
43
|
const hooks = base.hooks ?? {};
|
|
@@ -18,7 +18,7 @@ export declare function byToolName(a: {
|
|
|
18
18
|
export declare function orderRunTools(registry: ReadonlyMap<string, ToolDefPayload>, loadedBy: ReadonlyMap<string, string>): ToolDefinition[];
|
|
19
19
|
/**
|
|
20
20
|
* Wraps `executeTool` so every tool that appears in the registry during a call
|
|
21
|
-
* (an explicit `
|
|
21
|
+
* (an explicit `os_load_toolset`, a first-use auto-load) is recorded with
|
|
22
22
|
* the call's id. `reset()` forgets them, where a new chain starts.
|
|
23
23
|
*/
|
|
24
24
|
export declare function trackLoadedTools<C extends {
|
|
@@ -29,7 +29,7 @@ export function orderRunTools(registry, loadedBy) {
|
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* Wraps `executeTool` so every tool that appears in the registry during a call
|
|
32
|
-
* (an explicit `
|
|
32
|
+
* (an explicit `os_load_toolset`, a first-use auto-load) is recorded with
|
|
33
33
|
* the call's id. `reset()` forgets them, where a new chain starts.
|
|
34
34
|
*/
|
|
35
35
|
export function trackLoadedTools(registry, loadedBy, executeTool) {
|
|
@@ -15,5 +15,5 @@ export function buildScratchPromptNote(scratchRoot, callerScratch) {
|
|
|
15
15
|
|
|
16
16
|
For throwaway or intermediate files (scratch notes, temp scripts, downloaded artifacts you do not need to keep), write under \`${scratchRoot}\` - also exposed to shell commands as \`$NORDHAVN_SCRATCH\`. It sits outside the project checkout and is auto-deleted after 24h, so it never pollutes the repo or shows up in git. Keep everything temporary here.
|
|
17
17
|
|
|
18
|
-
Anything you need to KEEP must not live only in scratch - it is deleted, not saved. Before you finish: commit code/text deliverables into the project checkout, and push assets (images, PDFs, generated files) to the file manager with \`runner_upload_file\` (pass the local path) or \`
|
|
18
|
+
Anything you need to KEEP must not live only in scratch - it is deleted, not saved. Before you finish: commit code/text deliverables into the project checkout, and push assets (images, PDFs, generated files) to the file manager with \`runner_upload_file\` (pass the local path) or \`os_save_file\`. A file that exists only under \`${scratchRoot}\` at the end of your run is lost.${callerNote}`;
|
|
19
19
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Helpers for handling `
|
|
2
|
+
* Helpers for handling `os_update_task` schema-validation outcomes inside
|
|
3
3
|
* the task runner loop.
|
|
4
4
|
*
|
|
5
5
|
* KEEP IN SYNC WITH packages/os/os-shared/utils/task-validation.ts - that file
|
|
@@ -29,7 +29,7 @@ export interface TaskResultValidation {
|
|
|
29
29
|
errors: TaskResultValidationError[];
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
-
* Pull the validation outcome out of the `
|
|
32
|
+
* Pull the validation outcome out of the `os_update_task` tool result.
|
|
33
33
|
* Returns `null` when the result contains no parseable JSON or when the
|
|
34
34
|
* server returned no `validation` block (i.e. the task has no result schema
|
|
35
35
|
* or the agent didn't submit `structured`).
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// MIRROR: studio packages/os/os-shared/utils/task-validation.ts
|
|
2
2
|
import { extractFirstJsonObject } from './extract-json.js';
|
|
3
3
|
/**
|
|
4
|
-
* Pull the validation outcome out of the `
|
|
4
|
+
* Pull the validation outcome out of the `os_update_task` tool result.
|
|
5
5
|
* Returns `null` when the result contains no parseable JSON or when the
|
|
6
6
|
* server returned no `validation` block (i.e. the task has no result schema
|
|
7
7
|
* or the agent didn't submit `structured`).
|
|
@@ -33,5 +33,5 @@ export function formatValidationFeedback(errors, retriesLeft) {
|
|
|
33
33
|
const retryHint = retriesLeft > 0
|
|
34
34
|
? `You have ${retriesLeft} more correction attempt${retriesLeft === 1 ? '' : 's'}.`
|
|
35
35
|
: 'This is your final attempt.';
|
|
36
|
-
return `The structured result you just submitted failed schema validation:\n\n${errorList}\n\nFix ONLY these specific fields and call
|
|
36
|
+
return `The structured result you just submitted failed schema validation:\n\n${errorList}\n\nFix ONLY these specific fields and call os_update_task again with the corrected resultJson. Keep all other fields unchanged. ${retryHint}`;
|
|
37
37
|
}
|
|
@@ -3,8 +3,8 @@ import type { ToolDefPayload, ToolGroupPayload } from '../contract/wire.js';
|
|
|
3
3
|
* Tools the RUNTIME executes itself, with neither an `mcpPath` nor an entry in
|
|
4
4
|
* a frontend's local-tool provider.
|
|
5
5
|
*
|
|
6
|
-
* `
|
|
7
|
-
* block re-injected every round); `
|
|
6
|
+
* `os_pin` is intercepted inside the loop (it mutates the pinned-notes
|
|
7
|
+
* block re-injected every round); `os_unload_toolset` is intercepted in the
|
|
8
8
|
* dispatch handlers (it mutates the per-dispatch registry). Neither can be a
|
|
9
9
|
* `LocalTool`, because both act on state the tool provider cannot see.
|
|
10
10
|
*
|
|
@@ -12,15 +12,15 @@ import type { ToolDefPayload, ToolGroupPayload } from '../contract/wire.js';
|
|
|
12
12
|
* CLI) compares the studio's `mcpPath: null` grants against the provider's
|
|
13
13
|
* executor names and would otherwise report these two as missing forever. A
|
|
14
14
|
* warning with a known false positive in it is a warning people stop reading,
|
|
15
|
-
* which is how the genuinely missing `
|
|
15
|
+
* which is how the genuinely missing `os_unload_toolset` stayed invisible.
|
|
16
16
|
*/
|
|
17
17
|
export declare const RUNTIME_HANDLED_TOOLS: ReadonlySet<string>;
|
|
18
18
|
/**
|
|
19
|
-
* Tools `
|
|
19
|
+
* Tools `os_unload_toolset` refuses to drop.
|
|
20
20
|
*
|
|
21
21
|
* Unloading the loader, the pin store or the delegation tools would leave the
|
|
22
22
|
* agent unable to recover capabilities or coordinate: it could no longer reach
|
|
23
|
-
* `
|
|
23
|
+
* `os_load_toolset` to bring anything back. Kept explicit rather than
|
|
24
24
|
* derived from `bootstrap: true`, so a future bootstrap tool that is genuinely
|
|
25
25
|
* drop-safe can be left out of this set without touching the mechanism.
|
|
26
26
|
*
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { osTool } from '../contract/tool-names.js';
|
|
1
2
|
/**
|
|
2
3
|
* Tools the RUNTIME executes itself, with neither an `mcpPath` nor an entry in
|
|
3
4
|
* a frontend's local-tool provider.
|
|
4
5
|
*
|
|
5
|
-
* `
|
|
6
|
-
* block re-injected every round); `
|
|
6
|
+
* `os_pin` is intercepted inside the loop (it mutates the pinned-notes
|
|
7
|
+
* block re-injected every round); `os_unload_toolset` is intercepted in the
|
|
7
8
|
* dispatch handlers (it mutates the per-dispatch registry). Neither can be a
|
|
8
9
|
* `LocalTool`, because both act on state the tool provider cannot see.
|
|
9
10
|
*
|
|
@@ -11,18 +12,18 @@
|
|
|
11
12
|
* CLI) compares the studio's `mcpPath: null` grants against the provider's
|
|
12
13
|
* executor names and would otherwise report these two as missing forever. A
|
|
13
14
|
* warning with a known false positive in it is a warning people stop reading,
|
|
14
|
-
* which is how the genuinely missing `
|
|
15
|
+
* which is how the genuinely missing `os_unload_toolset` stayed invisible.
|
|
15
16
|
*/
|
|
16
17
|
export const RUNTIME_HANDLED_TOOLS = new Set([
|
|
17
|
-
'
|
|
18
|
-
'
|
|
18
|
+
osTool('pin'),
|
|
19
|
+
osTool('unload_toolset'),
|
|
19
20
|
]);
|
|
20
21
|
/**
|
|
21
|
-
* Tools `
|
|
22
|
+
* Tools `os_unload_toolset` refuses to drop.
|
|
22
23
|
*
|
|
23
24
|
* Unloading the loader, the pin store or the delegation tools would leave the
|
|
24
25
|
* agent unable to recover capabilities or coordinate: it could no longer reach
|
|
25
|
-
* `
|
|
26
|
+
* `os_load_toolset` to bring anything back. Kept explicit rather than
|
|
26
27
|
* derived from `bootstrap: true`, so a future bootstrap tool that is genuinely
|
|
27
28
|
* drop-safe can be left out of this set without touching the mechanism.
|
|
28
29
|
*
|
|
@@ -32,14 +33,14 @@ export const RUNTIME_HANDLED_TOOLS = new Set([
|
|
|
32
33
|
* on where the agent happens to run.
|
|
33
34
|
*/
|
|
34
35
|
export const UNLOAD_PROTECTED = new Set([
|
|
35
|
-
'
|
|
36
|
-
'
|
|
37
|
-
'
|
|
38
|
-
'
|
|
39
|
-
'
|
|
40
|
-
'
|
|
41
|
-
'
|
|
42
|
-
'
|
|
36
|
+
osTool('load_toolset'),
|
|
37
|
+
osTool('unload_toolset'),
|
|
38
|
+
osTool('get_tool_instructions'),
|
|
39
|
+
osTool('set_activity'),
|
|
40
|
+
osTool('compact'),
|
|
41
|
+
osTool('pin'),
|
|
42
|
+
osTool('call_agent'),
|
|
43
|
+
osTool('ping_agent'),
|
|
43
44
|
]);
|
|
44
45
|
/**
|
|
45
46
|
* Drop tool schemas from this dispatch's registry so the next inference round
|
|
@@ -62,7 +63,7 @@ export function applyUnloadToolset(args, registry, groupForToolName) {
|
|
|
62
63
|
: [];
|
|
63
64
|
if (!requestedGroup && requestedNames.length === 0) {
|
|
64
65
|
return {
|
|
65
|
-
result: 'Error:
|
|
66
|
+
result: 'Error: os_unload_toolset requires either "group" or "names" (or both).',
|
|
66
67
|
isError: true,
|
|
67
68
|
};
|
|
68
69
|
}
|
|
@@ -95,7 +96,7 @@ export function applyUnloadToolset(args, registry, groupForToolName) {
|
|
|
95
96
|
}
|
|
96
97
|
else {
|
|
97
98
|
removed.sort();
|
|
98
|
-
lines.push(`Unloaded ${removed.length} tool${removed.length === 1 ? '' : 's'} from ${requestLabel}: ${removed.join(', ')}. Load them again via
|
|
99
|
+
lines.push(`Unloaded ${removed.length} tool${removed.length === 1 ? '' : 's'} from ${requestLabel}: ${removed.join(', ')}. Load them again via os_load_toolset if you need them later.`);
|
|
99
100
|
}
|
|
100
101
|
if (skipped.length > 0) {
|
|
101
102
|
lines.push(`Protected (never unloaded): ${skipped.sort().join(', ')}.`);
|
|
@@ -19,7 +19,7 @@ declare class OnceEmitter {
|
|
|
19
19
|
}
|
|
20
20
|
export declare const delegateEmitter: OnceEmitter;
|
|
21
21
|
/**
|
|
22
|
-
* `
|
|
22
|
+
* `os_call_agent`, runner side. Its face (arguments, limits, clock, result
|
|
23
23
|
* text) is the agent contract's (`contract/calls.ts`), the same code the
|
|
24
24
|
* studio's `executeCallAgent` runs for internal agents; only placing a call
|
|
25
25
|
* (a `delegate:request` frame) is the runner's own.
|
|
@@ -27,7 +27,7 @@ export declare const delegateEmitter: OnceEmitter;
|
|
|
27
27
|
declare function executeCallAgent(params: Record<string, unknown>, context?: ToolContext): Promise<string>;
|
|
28
28
|
export declare const delegateTools: {
|
|
29
29
|
definition: {
|
|
30
|
-
name:
|
|
30
|
+
name: "os_call_agent";
|
|
31
31
|
description: string;
|
|
32
32
|
parameters: {
|
|
33
33
|
type: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CALL_TIERS, DEFAULT_CALL_TIMEOUT_MS, MAX_OPEN_CALLS_PER_RUN, callTimeoutMs, planCalls, renderCallOutcomes } from '../contract/calls.js';
|
|
1
|
+
import { CALL_TIERS, CALL_TOOL, DEFAULT_CALL_TIMEOUT_MS, MAX_OPEN_CALLS_PER_RUN, callTimeoutMs, planCalls, renderCallOutcomes } from '../contract/calls.js';
|
|
2
2
|
import { sendWsDelegateCancel, sendWsDelegateRequest } from '../connection.js';
|
|
3
3
|
import { randomId } from '../platform.js';
|
|
4
4
|
/** The studio owns a call's clock and answers when it runs out. This backstop
|
|
@@ -80,7 +80,7 @@ function placeCall(args, context, timeoutMs, background) {
|
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
|
-
* `
|
|
83
|
+
* `os_call_agent`, runner side. Its face (arguments, limits, clock, result
|
|
84
84
|
* text) is the agent contract's (`contract/calls.ts`), the same code the
|
|
85
85
|
* studio's `executeCallAgent` runs for internal agents; only placing a call
|
|
86
86
|
* (a `delegate:request` frame) is the runner's own.
|
|
@@ -100,7 +100,7 @@ async function executeCallAgent(params, context) {
|
|
|
100
100
|
export const delegateTools = [
|
|
101
101
|
{
|
|
102
102
|
definition: {
|
|
103
|
-
name:
|
|
103
|
+
name: CALL_TOOL,
|
|
104
104
|
description: 'Place a call to another agent (or a working copy of yourself) and wait for the answer, like phoning a colleague. '
|
|
105
105
|
+ 'Pass `{ batch: [...] }` to put several calls out at once, `background: true` to carry on without waiting, '
|
|
106
106
|
+ 'and `tier: "explore"` with your own slug to send a cheap read-only copy to search and summarise.',
|
|
@@ -100,7 +100,7 @@ export interface ToolContext {
|
|
|
100
100
|
touchedFiles?: WeakMap<Record<string, unknown>, readonly string[]>;
|
|
101
101
|
/** Abort signal - tools should bail when it fires. */
|
|
102
102
|
signal?: AbortSignal;
|
|
103
|
-
/** The agent's own cap on a `
|
|
103
|
+
/** The agent's own cap on a `os_call_agent` (agentConfig). */
|
|
104
104
|
delegateTimeoutMs?: number;
|
|
105
105
|
/** When this dispatch's wall-clock budget ends (epoch ms). A call placed
|
|
106
106
|
* from it is never given longer. Absent for a task with no budget. */
|
|
@@ -132,13 +132,13 @@ export interface ToolContext {
|
|
|
132
132
|
* to translate pixel coords to logical screen coords. Opaque to the core;
|
|
133
133
|
* host tools cast it to their own `ScreenMeta`. */
|
|
134
134
|
lastScreenCapture?: unknown;
|
|
135
|
-
/** Sink for `
|
|
135
|
+
/** Sink for `os_load_toolset` results. When the model calls it, the MCP
|
|
136
136
|
* executor parses the studio response and invokes this callback so the core
|
|
137
137
|
* loop merges the new tool defs into its per-dispatch registry - the next
|
|
138
138
|
* inference round registers them with the LLM. */
|
|
139
139
|
loadTools?: (defs: ToolDefPayload[]) => void;
|
|
140
140
|
/** True when the agent holds the tool `name` in this dispatch: in its
|
|
141
|
-
* registry, granted at dispatch or loaded since with `
|
|
141
|
+
* registry, granted at dispatch or loaded since with `os_load_toolset`.
|
|
142
142
|
* Lets a tool point the agent at another one only when it can call it
|
|
143
143
|
* (the runner's sonar hints). Absent outside a dispatch: read as "no". */
|
|
144
144
|
hasTool?: (name: string) => boolean;
|
|
@@ -8,7 +8,7 @@ import type { ToolContext } from './index.js';
|
|
|
8
8
|
* - When `mcpQuery` is true, remaining args are sent as URL query parameters.
|
|
9
9
|
* - When `mcpQuery` is false (default), remaining args are sent as JSON body.
|
|
10
10
|
*
|
|
11
|
-
* Batch dispatch: any
|
|
11
|
+
* Batch dispatch: any os_* tool can be called with `{ batch: [args, ...] }`
|
|
12
12
|
* and fans out into N parallel single-call invocations, returning a
|
|
13
13
|
* stringified `{ results: [{ ok: true, data } | { ok: false, error, statusCode? }, ...] }`.
|
|
14
14
|
* The envelope is the agent contract's `runBatch`, the same code the studio's
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { runBatch } from '../contract/batch.js';
|
|
2
2
|
import { RUN_STOPPED_PREFIX, RUN_STOPPED_STATUSES } from '../contract/loop.js';
|
|
3
|
+
import { osTool } from '../contract/tool-names.js';
|
|
3
4
|
import { networkErrorMessage } from '../inference.js';
|
|
4
5
|
/**
|
|
5
6
|
* Execute an MCP tool by making an HTTP call to the studio's MCP API.
|
|
@@ -9,7 +10,7 @@ import { networkErrorMessage } from '../inference.js';
|
|
|
9
10
|
* - When `mcpQuery` is true, remaining args are sent as URL query parameters.
|
|
10
11
|
* - When `mcpQuery` is false (default), remaining args are sent as JSON body.
|
|
11
12
|
*
|
|
12
|
-
* Batch dispatch: any
|
|
13
|
+
* Batch dispatch: any os_* tool can be called with `{ batch: [args, ...] }`
|
|
13
14
|
* and fans out into N parallel single-call invocations, returning a
|
|
14
15
|
* stringified `{ results: [{ ok: true, data } | { ok: false, error, statusCode? }, ...] }`.
|
|
15
16
|
* The envelope is the agent contract's `runBatch`, the same code the studio's
|
|
@@ -53,7 +54,7 @@ export async function executeMcpTool(toolDef, args, ctx) {
|
|
|
53
54
|
return JSON.stringify(envelope);
|
|
54
55
|
// Backfill `taskUid` from the dispatch context before interpolation runs.
|
|
55
56
|
// The studio prompt promises that taskUid auto-fills for tools targeting the
|
|
56
|
-
// current task (e.g.
|
|
57
|
+
// current task (e.g. os_update_task, os_get_task) - without this, an
|
|
57
58
|
// omitted arg leaves `{taskUid}` empty and the URL collapses to
|
|
58
59
|
// `/api/mcp/tasks/`, which 404s.
|
|
59
60
|
if (ctx.taskUid && args.taskUid === undefined) {
|
|
@@ -125,11 +126,11 @@ export async function executeMcpTool(toolDef, args, ctx) {
|
|
|
125
126
|
if (!res.ok) {
|
|
126
127
|
return `Error: ${method} ${interpolated} returned ${res.status}: ${text.slice(0, 500)}`;
|
|
127
128
|
}
|
|
128
|
-
//
|
|
129
|
+
// os_load_toolset is the one MCP call whose response the runner consumes itself:
|
|
129
130
|
// the studio returns `{ toolDefs[], warnings? }` and the runner merges the defs into
|
|
130
131
|
// its per-dispatch tool registry so subsequent inference rounds can invoke
|
|
131
132
|
// them. The model only ever sees a short human-readable summary.
|
|
132
|
-
if (toolDef.name === '
|
|
133
|
+
if (toolDef.name === osTool('load_toolset')) {
|
|
133
134
|
return handleLoadToolsetResponse(text, args, ctx);
|
|
134
135
|
}
|
|
135
136
|
// If the response is JSON, return the serialized form; otherwise raw text.
|