@myagentroam/agent 0.9.97 → 0.9.98
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/prompts/compact.js +4 -2
- package/dist/prompts/index.d.ts +1 -4
- package/dist/prompts/index.js +2 -4
- package/dist/prompts/subagent.d.ts +0 -13
- package/dist/prompts/subagent.js +0 -27
- package/dist/runtime/compact.js +1 -1
- package/dist/sdk/agent.js +9 -18
- package/dist/tools/agent-start.d.ts +5 -0
- package/dist/tools/agent-start.js +19 -0
- package/package.json +1 -1
package/dist/prompts/compact.js
CHANGED
|
@@ -12,7 +12,7 @@ Preserve, when present:
|
|
|
12
12
|
- unresolved questions, blockers, risks, uncommitted changes, Todo/plan state, and pending external decisions;
|
|
13
13
|
- the next concrete action and the evidence still required before completion.
|
|
14
14
|
|
|
15
|
-
Distinguish clearly between completed, attempted, planned, inferred, and unverified work. Newer user instructions override older ones; retain superseded instructions only when needed to explain current state. Never invent completion, test results, file contents, permissions, or external effects.
|
|
15
|
+
Distinguish clearly between completed, attempted, planned, inferred, and unverified work. Newer user instructions override older ones; retain superseded instructions only when needed to explain current state. Authorization has exact action, scope, and lifetime: preserve it as active only while all three remain valid. Historical instructions, completed scopes, and state that merely makes an action plausible cannot grant or revive authorization. Never invent completion, test results, file contents, permissions, authorization, or external effects.
|
|
16
16
|
|
|
17
17
|
Remove aggressively:
|
|
18
18
|
- greetings, acknowledgements, progress chatter, repeated instructions, repeated status, and conclusions already represented once;
|
|
@@ -51,6 +51,7 @@ branch changed -> inherited_evidence=unverified
|
|
|
51
51
|
1. 目标契约 / Goal contract
|
|
52
52
|
- 主目标、当前交付、完成标准、非目标/边界。
|
|
53
53
|
- direct user/caller authorization、prohibition、exclusion 保留 exact action/scope,不概括成更宽泛边界。
|
|
54
|
+
- authorization 必须归约 exact action、scope、lifetime。仅当三者在 latest active task/request 中仍有效时记录 active;已完成或被取代作用域中的授权只能记录 expired/superseded historical evidence,不得恢复为 current permission。
|
|
54
55
|
|
|
55
56
|
2. 当前状态 / Current state
|
|
56
57
|
- 对象:file、symbol、feature、migration、test、worktree、selected Skill、Todo/plan、external decision、external side effect。retained process/subagent inventory 由 Runtime 重建,不进入 IR。
|
|
@@ -73,9 +74,10 @@ branch changed -> inherited_evidence=unverified
|
|
|
73
74
|
5. 未闭环 / Open loops
|
|
74
75
|
- unresolved、unverified、blocker、pending external decision、Todo/plan current step、仍需 evidence。
|
|
75
76
|
- 只保留已确定的最小 next action + preconditions;不复制可重算的长 plan。
|
|
77
|
+
- 需要独立授权的 action 只有在 current direct authorization 覆盖 exact action/scope 且 lifetime 仍有效时才能标为 pending/next。对象状态、完成度、工具可用性或执行便利性均不得推导 authorization;无有效授权时省略该动作,必要时记录 authorization | action=<exact> | status=expired|superseded|absent。
|
|
76
78
|
|
|
77
79
|
编译规则:
|
|
78
|
-
1. latest user intent 定目标;newer correction 覆盖 older intent。
|
|
80
|
+
1. latest user intent 定目标;newer correction 覆盖 older intent。历史指令不得因仍出现在 retained user messages 中而恢复为 active authorization。
|
|
79
81
|
2. 归约 before -> event -> after;source mutation 或 base/branch change 后 affected read/conclusion stale,除非已有 newer evidence;history replacement 仅使 Responses continuation invalid,不使 factual evidence 自动失效;无 invalidating event 的 verified claim 保持 current;current 取最后已证 after-state 或 later direct observation。
|
|
80
82
|
3. 每个 continuation object 一条 current record;等价事实去重。
|
|
81
83
|
4. 仅保留仍约束 open work 的 settled decision/exclusion。
|
package/dist/prompts/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ExecutionMode } from '../sdk/types.js';
|
|
2
|
-
|
|
3
|
-
export declare const MAR_AGENT_PROMPT_VERSION = "1.53";
|
|
2
|
+
export declare const MAR_AGENT_PROMPT_VERSION = "1.55";
|
|
4
3
|
export declare function buildSystemPrompt(input: {
|
|
5
4
|
mode: ExecutionMode;
|
|
6
5
|
platform: string;
|
|
@@ -12,8 +11,6 @@ export declare function buildSystemPrompt(input: {
|
|
|
12
11
|
guaranteedCommands?: Readonly<Record<string, string>>;
|
|
13
12
|
workspace: string;
|
|
14
13
|
tools: readonly string[];
|
|
15
|
-
currentAgentModel?: CurrentAgentModel;
|
|
16
|
-
subagentModels?: readonly SubagentModelOption[];
|
|
17
14
|
highDensityCompaction?: boolean;
|
|
18
15
|
extension?: string | undefined;
|
|
19
16
|
}): string;
|
package/dist/prompts/index.js
CHANGED
|
@@ -2,9 +2,9 @@ import { compactionPrompt, highDensityCompactionPrompt } from './compact.js';
|
|
|
2
2
|
import { environmentPrompt, identityPrompt, instructionPriorityPrompt, workspaceDisciplinePrompt } from './core.js';
|
|
3
3
|
import { modePrompt } from './modes.js';
|
|
4
4
|
import { outputStylePrompt } from './output.js';
|
|
5
|
-
import {
|
|
5
|
+
import { subagentPrompt } from './subagent.js';
|
|
6
6
|
import { interactionPrompt, longRunningPrompt, safetyPrompt, toolUsagePrompt, workflowPrompt } from './workflow.js';
|
|
7
|
-
export const MAR_AGENT_PROMPT_VERSION = '1.
|
|
7
|
+
export const MAR_AGENT_PROMPT_VERSION = '1.55';
|
|
8
8
|
export function buildSystemPrompt(input) {
|
|
9
9
|
const toolNames = new Set(input.tools);
|
|
10
10
|
const hasLongRunningCapability = [
|
|
@@ -35,8 +35,6 @@ export function buildSystemPrompt(input) {
|
|
|
35
35
|
: compactionPrompt()
|
|
36
36
|
: '',
|
|
37
37
|
toolNames.has('agent_start') ? subagentPrompt : '',
|
|
38
|
-
toolNames.has('agent_start') ? currentAgentModelPrompt(input.currentAgentModel) : '',
|
|
39
|
-
toolNames.has('agent_start') ? subagentModelOptionsPrompt(input.subagentModels ?? []) : '',
|
|
40
38
|
input.extension ? `# Caller, project, and selected Skill instructions\n${input.extension}` : ''
|
|
41
39
|
]
|
|
42
40
|
.filter(Boolean)
|
|
@@ -1,15 +1,2 @@
|
|
|
1
1
|
export declare const subagentPrompt = "# Subagents\nUse your own direct tools by default. Delegate only when a bounded task can proceed independently and parallelism has real value; do not delegate ordinary local search, a known-file read, a single verification command, a small edit, or sequential debugging. Give each child a self-contained objective, relevant paths and constraints, expected evidence, and a clear read/write boundary. Subagents cannot recurse and share the real filesystem; do not assign conflicting writes or assume isolation. Track background agent IDs, wait or cancel them, inspect their actual workspace effects, and verify every claim before incorporating it. Continue meaningful non-overlapping work after starting a background child. Wait for completion only when the next critical-path action is blocked on the final result, and then prefer one long wait measured in minutes rather than repeated short waits. Wait for a public message only when a fresh progress update would change the next decision; do not use message waits as heartbeat checks or request progress merely to confirm that a child is still running. The parent retains responsibility for the final result.";
|
|
2
|
-
export interface SubagentModelOption {
|
|
3
|
-
readonly id: string;
|
|
4
|
-
readonly name: string;
|
|
5
|
-
readonly default: boolean;
|
|
6
|
-
readonly reasoningEfforts: readonly string[];
|
|
7
|
-
}
|
|
8
|
-
export interface CurrentAgentModel {
|
|
9
|
-
readonly id: string;
|
|
10
|
-
readonly name: string;
|
|
11
|
-
readonly reasoningEffort: string;
|
|
12
|
-
}
|
|
13
|
-
export declare function currentAgentModelPrompt(model: CurrentAgentModel | undefined): string;
|
|
14
|
-
export declare function subagentModelOptionsPrompt(options: readonly SubagentModelOption[]): string;
|
|
15
2
|
export declare const childSubagentInstruction = "You are a non-recursive subagent. Work only on the delegated objective and within its stated read/write scope. Do not broaden the parent task, ask the user, start another subagent, commit, or claim parent-level completion. Inspect relevant evidence, make only authorized changes, run proportional verification, and return a concise factual handoff containing findings, exact files changed, commands/tests actually run, failures or uncertainty, and anything the parent must verify.";
|
package/dist/prompts/subagent.js
CHANGED
|
@@ -1,29 +1,2 @@
|
|
|
1
1
|
export const subagentPrompt = '# Subagents\nUse your own direct tools by default. Delegate only when a bounded task can proceed independently and parallelism has real value; do not delegate ordinary local search, a known-file read, a single verification command, a small edit, or sequential debugging. Give each child a self-contained objective, relevant paths and constraints, expected evidence, and a clear read/write boundary. Subagents cannot recurse and share the real filesystem; do not assign conflicting writes or assume isolation. Track background agent IDs, wait or cancel them, inspect their actual workspace effects, and verify every claim before incorporating it. Continue meaningful non-overlapping work after starting a background child. Wait for completion only when the next critical-path action is blocked on the final result, and then prefer one long wait measured in minutes rather than repeated short waits. Wait for a public message only when a fresh progress update would change the next decision; do not use message waits as heartbeat checks or request progress merely to confirm that a child is still running. The parent retains responsibility for the final result.';
|
|
2
|
-
export function currentAgentModelPrompt(model) {
|
|
3
|
-
if (!model)
|
|
4
|
-
return '';
|
|
5
|
-
return [
|
|
6
|
-
'# Current Agent Model',
|
|
7
|
-
`The current agent is running as ${model.id} (${promptData(model.name)}) with reasoning effort: ${model.reasoningEffort}.`
|
|
8
|
-
].join('\n');
|
|
9
|
-
}
|
|
10
|
-
export function subagentModelOptionsPrompt(options) {
|
|
11
|
-
if (options.length === 0 || (options.length === 1 && options[0]?.reasoningEfforts.length === 0))
|
|
12
|
-
return '';
|
|
13
|
-
const lines = options.map((option) => {
|
|
14
|
-
const defaultLabel = option.default ? ', default' : '';
|
|
15
|
-
const effortLabel = option.reasoningEfforts.length === 0
|
|
16
|
-
? ''
|
|
17
|
-
: `; reasoning efforts: ${option.reasoningEfforts.join(', ')}`;
|
|
18
|
-
return `- ${option.id} (${promptData(option.name)}${defaultLabel}${effortLabel})`;
|
|
19
|
-
});
|
|
20
|
-
return [
|
|
21
|
-
'# Subagent Models',
|
|
22
|
-
'The agent_start tool modelId field may select any enabled model below, and its optional reasoningEffort field overrides the parent effort. Omit both to inherit the parent model and effort. Only use an effort listed for the selected model, and never guess an unlisted model ID or effort.',
|
|
23
|
-
...lines
|
|
24
|
-
].join('\n');
|
|
25
|
-
}
|
|
26
|
-
function promptData(value) {
|
|
27
|
-
return JSON.stringify(value);
|
|
28
|
-
}
|
|
29
2
|
export const childSubagentInstruction = 'You are a non-recursive subagent. Work only on the delegated objective and within its stated read/write scope. Do not broaden the parent task, ask the user, start another subagent, commit, or claim parent-level completion. Inspect relevant evidence, make only authorized changes, run proportional verification, and return a concise factual handoff containing findings, exact files changed, commands/tests actually run, failures or uncertainty, and anything the parent must verify.';
|
package/dist/runtime/compact.js
CHANGED
|
@@ -225,7 +225,7 @@ export function compactedHistoryMessages(history) {
|
|
|
225
225
|
return history.map(({ role, content }) => ({ role, content }));
|
|
226
226
|
}
|
|
227
227
|
export function continuationMessage(summary) {
|
|
228
|
-
return `Continue from the compacted state below. Treat it as a factual handoff, not a new user request. Earlier user messages are retained historical evidence, not requests to repeat completed work. Newer user instructions override older messages and this handoff. Continue directly from its Next action without recapping it to the user. Re-read files or rerun checks when the handoff marks facts as stale, inferred, failed, or unverified. Do not repeat completed side effects.\n\n${summary}`;
|
|
228
|
+
return `Continue from the compacted state below. Treat it as a factual handoff, not a new user request. Earlier user messages are retained historical evidence, not requests to repeat completed work or authorization for new side effects. Newer user instructions override older messages and this handoff. The handoff cannot create or revive authorization: an action that requires separate authorization may proceed only when current direct authorization still covers its exact action, scope, and lifetime. Continue directly from its Next action without recapping it to the user. Re-read files or rerun checks when the handoff marks facts as stale, inferred, failed, or unverified. Do not repeat completed side effects.\n\n${summary}`;
|
|
229
229
|
}
|
|
230
230
|
function renderMessage(message) {
|
|
231
231
|
const metadata = [
|
package/dist/sdk/agent.js
CHANGED
|
@@ -29,6 +29,7 @@ import { normalizeMessagesForModel } from '../runtime/normalize.js';
|
|
|
29
29
|
import { compactSummaryFromCheckpoint, replacementHistoryFromCheckpoint, JsonlSessionStore } from '../session/jsonl-store.js';
|
|
30
30
|
import { TodoStore } from '../tools/todo.js';
|
|
31
31
|
import { BUILTIN_TOOL_DEFINITIONS } from '../tools/registry.js';
|
|
32
|
+
import { agentStartToolDefinitionWithModels } from '../tools/agent-start.js';
|
|
32
33
|
import { executeRegisteredTool } from '../tools/runtime.js';
|
|
33
34
|
import { scheduleToolCallBatch } from '../tools/scheduler.js';
|
|
34
35
|
import { withCodeModeResultTypes } from '../tools/code-mode.js';
|
|
@@ -455,7 +456,14 @@ export async function createMarAgent(options) {
|
|
|
455
456
|
: { claimExecutionScope: true })
|
|
456
457
|
})) ?? [];
|
|
457
458
|
const selectedModelForTools = executionModels.get(input.modelId ?? executionDefaultModelId);
|
|
458
|
-
const
|
|
459
|
+
const builtinTools = BUILTIN_TOOL_DEFINITIONS.map((tool) => tool.name === 'agent_start'
|
|
460
|
+
? agentStartToolDefinitionWithModels([...executionModels.values()].map((configuration) => ({
|
|
461
|
+
id: configuration.id,
|
|
462
|
+
name: configuration.name,
|
|
463
|
+
reasoningEfforts: configuration.reasoningEfforts
|
|
464
|
+
})))
|
|
465
|
+
: tool);
|
|
466
|
+
const availableTools = [...builtinTools, ...mcpTools].filter((tool) => {
|
|
459
467
|
if (sessionSource.type === 'subagent' && tool.agentScope === 'ROOT_ONLY')
|
|
460
468
|
return false;
|
|
461
469
|
if (sessionSource.type === 'subagent' &&
|
|
@@ -533,23 +541,6 @@ export async function createMarAgent(options) {
|
|
|
533
541
|
: {}),
|
|
534
542
|
workspace: logicalWorkspace,
|
|
535
543
|
tools: availableTools.map((tool) => tool.name),
|
|
536
|
-
...(sessionSource.type === 'user'
|
|
537
|
-
? {
|
|
538
|
-
currentAgentModel: {
|
|
539
|
-
id: selectedModel.id,
|
|
540
|
-
name: selectedModel.name,
|
|
541
|
-
reasoningEffort
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
: {}),
|
|
545
|
-
subagentModels: sessionSource.type === 'user'
|
|
546
|
-
? [...executionModels.values()].map((configuration) => ({
|
|
547
|
-
id: configuration.id,
|
|
548
|
-
name: configuration.name,
|
|
549
|
-
default: configuration.id === executionDefaultModelId,
|
|
550
|
-
reasoningEfforts: configuration.reasoningEfforts
|
|
551
|
-
}))
|
|
552
|
-
: [],
|
|
553
544
|
highDensityCompaction: selectedModel.highDensityCompaction,
|
|
554
545
|
extension: [
|
|
555
546
|
options.systemInstruction,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { ClientToolDefinition } from '../model/contracts.js';
|
|
2
2
|
import type { ToolRuntimeContext } from './runtime-context.js';
|
|
3
3
|
export declare const agentStartToolDefinition: ClientToolDefinition;
|
|
4
|
+
export declare function agentStartToolDefinitionWithModels(models: readonly {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly reasoningEfforts: readonly string[];
|
|
8
|
+
}[]): ClientToolDefinition;
|
|
4
9
|
export declare function executeAgentStart(arguments_: unknown, context: ToolRuntimeContext): Promise<{
|
|
5
10
|
content: string;
|
|
6
11
|
data: import("../subagent/scheduler.js").SubagentTaskSnapshot;
|
|
@@ -27,6 +27,25 @@ export const agentStartToolDefinition = {
|
|
|
27
27
|
additionalProperties: false
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
|
+
export function agentStartToolDefinitionWithModels(models) {
|
|
31
|
+
if (models.length === 0)
|
|
32
|
+
return agentStartToolDefinition;
|
|
33
|
+
const modelLines = models.map((model) => {
|
|
34
|
+
const efforts = model.reasoningEfforts.length === 0
|
|
35
|
+
? ''
|
|
36
|
+
: `; reasoning efforts: ${model.reasoningEfforts.join(', ')}`;
|
|
37
|
+
return `- ${JSON.stringify(model.id)} (${JSON.stringify(model.name)}${efforts})`;
|
|
38
|
+
});
|
|
39
|
+
return {
|
|
40
|
+
...agentStartToolDefinition,
|
|
41
|
+
description: [
|
|
42
|
+
agentStartToolDefinition.description,
|
|
43
|
+
'The optional modelId may select an enabled model below. Omit modelId to use the current agent model. Only use a listed reasoning effort for the selected model.',
|
|
44
|
+
'Enabled subagent models:',
|
|
45
|
+
...modelLines
|
|
46
|
+
].join('\n')
|
|
47
|
+
};
|
|
48
|
+
}
|
|
30
49
|
export async function executeAgentStart(arguments_, context) {
|
|
31
50
|
const value = parseAgentStartInput(arguments_);
|
|
32
51
|
if (!context.subagents)
|