@myagentroam/agent 0.9.136 → 0.9.138
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/host/local-agent-host.d.ts +5 -0
- package/dist/host/local-agent-host.js +2 -1
- package/dist/prompts/index.d.ts +2 -1
- package/dist/prompts/index.js +2 -2
- package/dist/prompts/resources.d.ts +1 -0
- package/dist/prompts/resources.js +8 -2
- package/dist/prompts/workflow.d.ts +1 -1
- package/dist/prompts/workflow.js +7 -2
- package/dist/runtime/context-gc.js +10 -6
- package/dist/runtime/context-projection.js +1 -1
- package/dist/sdk/agent.js +163 -88
- package/dist/sdk/types.d.ts +17 -2
- package/dist/session/context-gc-checkpoint.d.ts +1 -1
- package/dist/session/context-gc-checkpoint.js +11 -5
- package/dist/session/context-gc-replacements.d.ts +2 -0
- package/dist/session/context-gc-replacements.js +18 -0
- package/dist/session/jsonl-store.d.ts +5 -2
- package/dist/session/jsonl-store.js +105 -12
- package/dist/subagent/session-controller.d.ts +2 -0
- package/dist/subagent/session-controller.js +23 -6
- package/dist/tools/callers.d.ts +2 -0
- package/dist/tools/callers.js +7 -1
- package/dist/tools/code-mode/cells.d.ts +20 -0
- package/dist/tools/code-mode/cells.js +250 -0
- package/dist/tools/code-mode/dispatch.d.ts +21 -0
- package/dist/tools/code-mode/dispatch.js +53 -0
- package/dist/tools/code-mode/engine.d.ts +1 -0
- package/dist/tools/code-mode/quickjs-engine.js +4 -0
- package/dist/tools/code-mode/worker.js +1 -0
- package/dist/tools/code-mode.d.ts +15 -4
- package/dist/tools/code-mode.js +83 -17
- package/dist/tools/execution-limits.d.ts +5 -0
- package/dist/tools/execution-limits.js +5 -0
- package/dist/tools/local-registry.d.ts +5 -0
- package/dist/tools/local-registry.js +5 -1
- package/dist/tools/registry.js +2 -1
- package/dist/tools/scheduler.d.ts +2 -0
- package/dist/tools/scheduler.js +11 -0
- package/dist/tools/tool-search.js +12 -6
- package/package.json +1 -1
package/dist/tools/registry.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { applyPatchToolDefinition } from './apply-patch.js';
|
|
2
2
|
import { execToolDefinition } from './exec.js';
|
|
3
|
-
import { codeModeToolDefinition } from './code-mode.js';
|
|
3
|
+
import { codeModeToolDefinition, codeExecWaitToolDefinition } from './code-mode.js';
|
|
4
4
|
import { executeQuestion, questionToolDefinition } from './question.js';
|
|
5
5
|
import { readToolDefinition } from './read.js';
|
|
6
6
|
import { viewImageToolDefinition } from './view-image.js';
|
|
@@ -21,6 +21,7 @@ export const BUILTIN_TOOL_DEFINITIONS = [
|
|
|
21
21
|
viewImageToolDefinition,
|
|
22
22
|
execToolDefinition,
|
|
23
23
|
codeModeToolDefinition,
|
|
24
|
+
codeExecWaitToolDefinition,
|
|
24
25
|
applyPatchToolDefinition,
|
|
25
26
|
questionToolDefinition,
|
|
26
27
|
todoReadToolDefinition,
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ClientToolDefinition } from '../model/contracts.js';
|
|
2
|
+
/** One barrier domain for foreground tools and all retained cells in a Session. */
|
|
3
|
+
export declare function createSessionToolScheduler(): <T>(definition: ClientToolDefinition | undefined, run: () => Promise<T>) => Promise<T>;
|
|
2
4
|
/** Schedules an incremental stream while preserving the same safe/serial barriers as batches. */
|
|
3
5
|
export declare function createToolCallScheduler<TCall extends {
|
|
4
6
|
readonly name: string;
|
package/dist/tools/scheduler.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/** One barrier domain for foreground tools and all retained cells in a Session. */
|
|
2
|
+
export function createSessionToolScheduler() {
|
|
3
|
+
const schedule = createToolCallScheduler([
|
|
4
|
+
{ name: 'safe', parallelSafety: 'safe' },
|
|
5
|
+
{ name: 'serial', parallelSafety: 'serial' }
|
|
6
|
+
], (job) => job.run());
|
|
7
|
+
return (definition, run) => schedule({
|
|
8
|
+
name: definition?.parallelSafety === 'safe' ? 'safe' : 'serial',
|
|
9
|
+
run
|
|
10
|
+
});
|
|
11
|
+
}
|
|
1
12
|
/** Schedules an incremental stream while preserving the same safe/serial barriers as batches. */
|
|
2
13
|
export function createToolCallScheduler(definitions, execute) {
|
|
3
14
|
const safety = new Map(definitions.map((definition) => [definition.name, definition.parallelSafety]));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MarAgentError } from '../error.js';
|
|
2
2
|
import { assertMcpToolCatalog } from '../sdk/mcp-catalog.js';
|
|
3
3
|
import { countModelTokens } from '../runtime/token-budget.js';
|
|
4
|
-
import { projectCodeModeTools } from './code-mode.js';
|
|
4
|
+
import { projectCodeModeSearchResult, projectCodeModeTools } from './code-mode.js';
|
|
5
5
|
export const TOOL_SEARCH_LIMITS = Object.freeze({
|
|
6
6
|
defaultLimit: 5,
|
|
7
7
|
maximumLimit: 20,
|
|
@@ -13,7 +13,7 @@ export const TOOL_SEARCH_LIMITS = Object.freeze({
|
|
|
13
13
|
});
|
|
14
14
|
export const toolSearchToolDefinition = {
|
|
15
15
|
name: 'tool_search',
|
|
16
|
-
description: 'Search deferred MCP metadata and
|
|
16
|
+
description: 'Search deferred MCP metadata and return matching tool definitions for the next model call. Use the full callable name for exact selection, or keywords for BM25 search. Never executes the discovered tools. With Code Mode Only, programmatic tools must be called through code_exec, not directly. Already exposed tools need not be searched again. The selected definitions must fit the exposure budget or the search fails atomically.',
|
|
17
17
|
inputSchema: {
|
|
18
18
|
type: 'object',
|
|
19
19
|
properties: {
|
|
@@ -201,10 +201,16 @@ export class DeferredMcpRegistry {
|
|
|
201
201
|
};
|
|
202
202
|
}
|
|
203
203
|
assertBudget(base, window, system, selection = this.#selected, executionSelection = this.#executionSelected) {
|
|
204
|
-
const
|
|
205
|
-
const
|
|
206
|
-
const
|
|
207
|
-
const
|
|
204
|
+
const resident = this.projectDirect(base);
|
|
205
|
+
const active = this.project(base, selection, new Set(executionSelection));
|
|
206
|
+
const tools = projectCodeModeTools(active, resident);
|
|
207
|
+
const direct = projectCodeModeTools(resident);
|
|
208
|
+
const residentNames = new Set(resident.map((tool) => tool.name));
|
|
209
|
+
const definitions = active.filter((tool) => !residentNames.has(tool.name));
|
|
210
|
+
const searchResult = projectCodeModeSearchResult({ role: 'tool', content: '', toolSearchTools: definitions }, base.some((tool) => tool.name === 'code_exec'));
|
|
211
|
+
// Search-result definitions still consume context even when Only mode hides direct tools.
|
|
212
|
+
const estimated = countModelTokens(searchResult.content || JSON.stringify(searchResult.toolSearchTools));
|
|
213
|
+
const full = Math.max(countModelTokens(JSON.stringify(tools)), countModelTokens(JSON.stringify(direct)) + estimated);
|
|
208
214
|
const maximum = Math.min(TOOL_SEARCH_LIMITS.maximumDefinitionTokens, Math.floor(window * TOOL_SEARCH_LIMITS.definitionWindowFraction));
|
|
209
215
|
if (estimated > maximum ||
|
|
210
216
|
full + countModelTokens(system) + TOOL_SEARCH_LIMITS.minimumContinuationTokens > window)
|