newmark-agent 0.3.5 → 0.3.7
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/Flow/Electron-Debug-Release.Flow.json +43 -43
- package/Flow/Flow.md +8 -8
- package/Flow/UI-Feature-Integration.Flow.json +96 -96
- package/dist/conversation-utility-host.bundle.cjs +154 -11
- package/dist/core/agent.d.ts +2 -0
- package/dist/core/agent.js +126 -2
- package/dist/core/agentKernelRunner.js +4 -0
- package/dist/core/automationWake.js +37 -37
- package/dist/core/subagent.d.ts +1 -0
- package/dist/core/subagent.js +15 -3
- package/dist/core/toolPolicy.js +2 -0
- package/dist/main.js +60 -60
- package/dist/tools/index.js +13 -6
- package/dist/tools/nativeTools.js +2 -0
- package/dist/ui/index.html +1 -1
- package/dist/wsl-agent-host.bundle.cjs +154 -11
- package/package.json +1 -1
- package/dist/windows-process-tree-helper.dll +0 -0
package/dist/core/agent.js
CHANGED
|
@@ -3417,6 +3417,130 @@ class Agent {
|
|
|
3417
3417
|
truncatedActivities: Math.max(0, publicEvents.length - activities.length),
|
|
3418
3418
|
});
|
|
3419
3419
|
}
|
|
3420
|
+
async handleContextCompress(args, signal) {
|
|
3421
|
+
let input = {};
|
|
3422
|
+
try {
|
|
3423
|
+
input = JSON.parse(args || '{}');
|
|
3424
|
+
}
|
|
3425
|
+
catch { }
|
|
3426
|
+
if (this.history.length <= 1)
|
|
3427
|
+
return { ok: false, output: '[context_compress] No context to compress.', error: 'No context to compress.' };
|
|
3428
|
+
const previousKeepLast = this.config.getNum('context', 'keep_recent_messages');
|
|
3429
|
+
const keepRecent = Math.max(2, Math.min(60, Math.floor(Number(input.keep_recent) || previousKeepLast || 10)));
|
|
3430
|
+
const force = Boolean(input.force);
|
|
3431
|
+
try {
|
|
3432
|
+
this.config.set('context', 'keep_recent_messages', keepRecent);
|
|
3433
|
+
const msgs = this.history.map(message => ({ ...message }));
|
|
3434
|
+
const provider = this.engineModel();
|
|
3435
|
+
await this.maybeCompress(msgs, provider, signal, this.activeModelName(), force);
|
|
3436
|
+
if (this.history.length <= 1)
|
|
3437
|
+
return { ok: false, output: '[context_compress] Compression skipped: context unchanged.', error: 'Compression skipped.' };
|
|
3438
|
+
return {
|
|
3439
|
+
ok: true,
|
|
3440
|
+
output: JSON.stringify({
|
|
3441
|
+
ok: true,
|
|
3442
|
+
compressed: true,
|
|
3443
|
+
at: this.lastCompression?.at,
|
|
3444
|
+
originalMessages: this.lastCompression?.originalMessages,
|
|
3445
|
+
compressedMessages: this.lastCompression?.compressedMessages,
|
|
3446
|
+
originalChars: this.lastCompression?.originalChars,
|
|
3447
|
+
compressedChars: this.lastCompression?.compressedChars,
|
|
3448
|
+
estimatedTokens: this.lastCompression?.compressedTokens,
|
|
3449
|
+
summary: this.lastCompression?.summary?.slice(0, 2000),
|
|
3450
|
+
model: this.lastCompression?.model,
|
|
3451
|
+
fallback: this.lastCompression?.fallback,
|
|
3452
|
+
displayHistory: { untouched: true, messageCount: this.chatMessages.length },
|
|
3453
|
+
}, null, 2),
|
|
3454
|
+
metadata: { kind: 'context-compress' },
|
|
3455
|
+
};
|
|
3456
|
+
}
|
|
3457
|
+
finally {
|
|
3458
|
+
this.config.set('context', 'keep_recent_messages', previousKeepLast);
|
|
3459
|
+
}
|
|
3460
|
+
}
|
|
3461
|
+
handleContextHistoryManage(args) {
|
|
3462
|
+
let input = {};
|
|
3463
|
+
try {
|
|
3464
|
+
input = JSON.parse(args || '{}');
|
|
3465
|
+
}
|
|
3466
|
+
catch { }
|
|
3467
|
+
const action = String(input.action || '').trim();
|
|
3468
|
+
if (!action)
|
|
3469
|
+
return { ok: false, output: '[context_history_manage] action is required (list|remove|summarize).', error: 'action is required.' };
|
|
3470
|
+
if (action === 'list') {
|
|
3471
|
+
const limit = Math.max(5, Math.min(400, Math.floor(Number(input.limit || 200))));
|
|
3472
|
+
const entries = this.history.slice(0, limit).map((message, index) => ({
|
|
3473
|
+
position: index,
|
|
3474
|
+
role: String(message.role || ''),
|
|
3475
|
+
name: String(message.name || ''),
|
|
3476
|
+
chars: typeof message.content === 'string' ? message.content.length : JSON.stringify(message.content || '').length,
|
|
3477
|
+
preview: this.compressionHistoryContent(message.content || '').slice(0, 160),
|
|
3478
|
+
}));
|
|
3479
|
+
return {
|
|
3480
|
+
ok: true,
|
|
3481
|
+
output: JSON.stringify({
|
|
3482
|
+
ok: true,
|
|
3483
|
+
action: 'list',
|
|
3484
|
+
entryCount: this.history.length,
|
|
3485
|
+
listed: entries.length,
|
|
3486
|
+
entries,
|
|
3487
|
+
displayHistory: { untouched: true, messageCount: this.chatMessages.length },
|
|
3488
|
+
}, null, 2),
|
|
3489
|
+
metadata: { kind: 'context-history-list' },
|
|
3490
|
+
};
|
|
3491
|
+
}
|
|
3492
|
+
if (action === 'remove') {
|
|
3493
|
+
const position = Math.floor(Number(input.position));
|
|
3494
|
+
if (!Number.isFinite(position) || position < 0 || position >= this.history.length) {
|
|
3495
|
+
return { ok: false, output: `[context_history_manage] remove position ${position} out of range (0..${this.history.length - 1}).`, error: 'remove position out of range.' };
|
|
3496
|
+
}
|
|
3497
|
+
const removed = this.history.splice(position, 1)[0];
|
|
3498
|
+
this.saveWorkspaceConversationState(true);
|
|
3499
|
+
return {
|
|
3500
|
+
ok: true,
|
|
3501
|
+
output: JSON.stringify({
|
|
3502
|
+
ok: true,
|
|
3503
|
+
action: 'remove',
|
|
3504
|
+
removedPosition: position,
|
|
3505
|
+
removedRole: String(removed?.role || ''),
|
|
3506
|
+
remaining: this.history.length,
|
|
3507
|
+
displayHistory: { untouched: true, messageCount: this.chatMessages.length },
|
|
3508
|
+
}, null, 2),
|
|
3509
|
+
metadata: { kind: 'context-history-remove' },
|
|
3510
|
+
};
|
|
3511
|
+
}
|
|
3512
|
+
if (action === 'summarize') {
|
|
3513
|
+
const from = Math.max(0, Math.floor(Number(input.position || 0)));
|
|
3514
|
+
const toRaw = Math.floor(Number(input.to ?? input.position));
|
|
3515
|
+
const to = Number.isFinite(toRaw) ? Math.min(this.history.length - 1, Math.max(from, toRaw)) : from;
|
|
3516
|
+
if (from >= this.history.length)
|
|
3517
|
+
return { ok: false, output: `[context_history_manage] summarize position ${from} out of range (0..${this.history.length - 1}).`, error: 'summarize position out of range.' };
|
|
3518
|
+
if (to - from < 1)
|
|
3519
|
+
return { ok: false, output: '[context_history_manage] summarize requires at least two entries in range.', error: 'summarize requires a range of at least two entries.' };
|
|
3520
|
+
const segment = this.history.slice(from, to + 1);
|
|
3521
|
+
const chars = segment.reduce((sum, message) => sum + (typeof message.content === 'string' ? message.content.length : JSON.stringify(message.content || '').length), 0);
|
|
3522
|
+
const summary = this.localCompressionSummary(`Workspace: ${this.workspace.current?.path || this.rootPath}\nMode: ${this.modeName()}`, segment.map((message, i) => `#${i + 1} [${String(message.role || 'unknown')}${message.name ? ` ${String(message.name)}` : ''}]\n${this.compressionHistoryContent(message.content || '')}`).join('\n\n').slice(0, 20000), segment.length, chars);
|
|
3523
|
+
const replacement = { role: 'system', content: `[Context History Summary]\n${summary}` };
|
|
3524
|
+
this.history.splice(from, to - from + 1, replacement);
|
|
3525
|
+
this.saveWorkspaceConversationState(true);
|
|
3526
|
+
return {
|
|
3527
|
+
ok: true,
|
|
3528
|
+
output: JSON.stringify({
|
|
3529
|
+
ok: true,
|
|
3530
|
+
action: 'summarize',
|
|
3531
|
+
foldedFrom: from,
|
|
3532
|
+
foldedTo: to,
|
|
3533
|
+
foldedEntries: to - from + 1,
|
|
3534
|
+
foldedChars: chars,
|
|
3535
|
+
remaining: this.history.length,
|
|
3536
|
+
summary: summary.slice(0, 2000),
|
|
3537
|
+
displayHistory: { untouched: true, messageCount: this.chatMessages.length },
|
|
3538
|
+
}, null, 2),
|
|
3539
|
+
metadata: { kind: 'context-history-summarize' },
|
|
3540
|
+
};
|
|
3541
|
+
}
|
|
3542
|
+
return { ok: false, output: `[context_history_manage] Unknown action: ${action}`, error: `Unknown action: ${action}` };
|
|
3543
|
+
}
|
|
3420
3544
|
recordContextCompressionStep() {
|
|
3421
3545
|
const runId = this.currentWorkRunId();
|
|
3422
3546
|
if (!runId)
|
|
@@ -5496,7 +5620,7 @@ class Agent {
|
|
|
5496
5620
|
if (!sa)
|
|
5497
5621
|
return { ok: false, output: `[Subagent] Not found: ${name}`, error: `Not found: ${name}` };
|
|
5498
5622
|
const transcript = sa.messages.map(m => `[${m.role}] ${m.content}`).join('\n');
|
|
5499
|
-
return this.subagents.toToolResult(sa.id, `get.subagent("${sa.name}")\nStatus: ${sa.status}\nModel: ${sa.model}\nMode: ${sa.agentMode}\n\nResult:\n${sa.result || ''}\n\nConversation:\n${transcript}`, true);
|
|
5623
|
+
return this.subagents.toToolResult(sa.id, `get.subagent("${sa.name}", id="${sa.id}")\nStatus: ${sa.status}\nModel: ${sa.model}\nMode: ${sa.agentMode}\n\nResult:\n${sa.result || ''}\n\nConversation:\n${transcript}`, true);
|
|
5500
5624
|
}
|
|
5501
5625
|
catch {
|
|
5502
5626
|
return { ok: false, output: '[Subagent] Invalid result arguments.', error: 'Invalid result arguments.' };
|
|
@@ -6393,7 +6517,7 @@ class Agent {
|
|
|
6393
6517
|
return;
|
|
6394
6518
|
const total = msgs.reduce((sum, m) => sum + (typeof m.content === 'string' ? m.content.length : JSON.stringify(m.content || '').length), 0);
|
|
6395
6519
|
const budget = this.compressionBudget(msgs);
|
|
6396
|
-
if (budget.estimatedTokens < budget.triggerTokens)
|
|
6520
|
+
if (budget.estimatedTokens < budget.triggerTokens && !force)
|
|
6397
6521
|
return;
|
|
6398
6522
|
if (!force && this.lastCompression && String(msgs[0]?.content || '').includes(this.lastCompression.summary)) {
|
|
6399
6523
|
const baselineChars = Math.max(0, Number(this.lastCompression.compressedChars || 0));
|
|
@@ -1470,6 +1470,10 @@ async function executeNewmarkTool(agent, name, args, inputSchema, signal) {
|
|
|
1470
1470
|
return agent.handleLinkedPlanTool(args);
|
|
1471
1471
|
if (name === 'build_history_query')
|
|
1472
1472
|
return agent.handleBuildHistoryQuery(args);
|
|
1473
|
+
if (name === 'context_compress')
|
|
1474
|
+
return (await agent.handleContextCompress(args, signal)).output;
|
|
1475
|
+
if (name === 'context_history_manage')
|
|
1476
|
+
return agent.handleContextHistoryManage(args).output;
|
|
1473
1477
|
if (name === 'question') {
|
|
1474
1478
|
if (agent.config.getStr('agent', 'option_feedback') === 'fully_autonomous')
|
|
1475
1479
|
return '[question] Disabled by fully_autonomous option feedback.';
|
|
@@ -109,43 +109,43 @@ class AutomationWakeScheduler {
|
|
|
109
109
|
const startBoundary = toTaskSchedulerLocal(nextRunAt);
|
|
110
110
|
const command = xmlEscape(this.exePath);
|
|
111
111
|
const args = xmlEscape(`--root "${this.rootPath}" --automation-wake`);
|
|
112
|
-
const xml = `<?xml version="1.0" encoding="UTF-16"?>
|
|
113
|
-
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
|
|
114
|
-
<RegistrationInfo>
|
|
115
|
-
<Description>Wake Newmark Agent to run due automations.</Description>
|
|
116
|
-
<URI>\\${xmlEscape(taskName)}</URI>
|
|
117
|
-
</RegistrationInfo>
|
|
118
|
-
<Triggers>
|
|
119
|
-
<TimeTrigger>
|
|
120
|
-
<StartBoundary>${xmlEscape(startBoundary)}</StartBoundary>
|
|
121
|
-
<Enabled>true</Enabled>
|
|
122
|
-
</TimeTrigger>
|
|
123
|
-
</Triggers>
|
|
124
|
-
<Principals>
|
|
125
|
-
<Principal id="Author">
|
|
126
|
-
<UserId>${xmlEscape(os.userInfo().username)}</UserId>
|
|
127
|
-
<LogonType>InteractiveToken</LogonType>
|
|
128
|
-
<RunLevel>LeastPrivilege</RunLevel>
|
|
129
|
-
</Principal>
|
|
130
|
-
</Principals>
|
|
131
|
-
<Settings>
|
|
132
|
-
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
|
|
133
|
-
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
|
|
134
|
-
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
|
|
135
|
-
<AllowHardTerminate>true</AllowHardTerminate>
|
|
136
|
-
<StartWhenAvailable>true</StartWhenAvailable>
|
|
137
|
-
<WakeToRun>true</WakeToRun>
|
|
138
|
-
<Enabled>true</Enabled>
|
|
139
|
-
<Hidden>false</Hidden>
|
|
140
|
-
<ExecutionTimeLimit>PT2H</ExecutionTimeLimit>
|
|
141
|
-
</Settings>
|
|
142
|
-
<Actions Context="Author">
|
|
143
|
-
<Exec>
|
|
144
|
-
<Command>${command}</Command>
|
|
145
|
-
<Arguments>${args}</Arguments>
|
|
146
|
-
<WorkingDirectory>${xmlEscape(this.rootPath)}</WorkingDirectory>
|
|
147
|
-
</Exec>
|
|
148
|
-
</Actions>
|
|
112
|
+
const xml = `<?xml version="1.0" encoding="UTF-16"?>
|
|
113
|
+
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
|
|
114
|
+
<RegistrationInfo>
|
|
115
|
+
<Description>Wake Newmark Agent to run due automations.</Description>
|
|
116
|
+
<URI>\\${xmlEscape(taskName)}</URI>
|
|
117
|
+
</RegistrationInfo>
|
|
118
|
+
<Triggers>
|
|
119
|
+
<TimeTrigger>
|
|
120
|
+
<StartBoundary>${xmlEscape(startBoundary)}</StartBoundary>
|
|
121
|
+
<Enabled>true</Enabled>
|
|
122
|
+
</TimeTrigger>
|
|
123
|
+
</Triggers>
|
|
124
|
+
<Principals>
|
|
125
|
+
<Principal id="Author">
|
|
126
|
+
<UserId>${xmlEscape(os.userInfo().username)}</UserId>
|
|
127
|
+
<LogonType>InteractiveToken</LogonType>
|
|
128
|
+
<RunLevel>LeastPrivilege</RunLevel>
|
|
129
|
+
</Principal>
|
|
130
|
+
</Principals>
|
|
131
|
+
<Settings>
|
|
132
|
+
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
|
|
133
|
+
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
|
|
134
|
+
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
|
|
135
|
+
<AllowHardTerminate>true</AllowHardTerminate>
|
|
136
|
+
<StartWhenAvailable>true</StartWhenAvailable>
|
|
137
|
+
<WakeToRun>true</WakeToRun>
|
|
138
|
+
<Enabled>true</Enabled>
|
|
139
|
+
<Hidden>false</Hidden>
|
|
140
|
+
<ExecutionTimeLimit>PT2H</ExecutionTimeLimit>
|
|
141
|
+
</Settings>
|
|
142
|
+
<Actions Context="Author">
|
|
143
|
+
<Exec>
|
|
144
|
+
<Command>${command}</Command>
|
|
145
|
+
<Arguments>${args}</Arguments>
|
|
146
|
+
<WorkingDirectory>${xmlEscape(this.rootPath)}</WorkingDirectory>
|
|
147
|
+
</Exec>
|
|
148
|
+
</Actions>
|
|
149
149
|
</Task>`;
|
|
150
150
|
fs.writeFileSync(xmlPath, Buffer.from(`\ufeff${xml}`, 'utf16le'));
|
|
151
151
|
return xmlPath;
|
package/dist/core/subagent.d.ts
CHANGED
package/dist/core/subagent.js
CHANGED
|
@@ -119,6 +119,10 @@ class SubagentManager {
|
|
|
119
119
|
const id = (0, crypto_1.randomUUID)();
|
|
120
120
|
const shortId = id.replace(/-/g, '').slice(0, 8);
|
|
121
121
|
const slug = natureSlug(name);
|
|
122
|
+
// The Agent-facing name is the caller's stable, human-readable label and is
|
|
123
|
+
// deliberately decoupled from the identity. The UUID and its short form are
|
|
124
|
+
// the only identity-bearing fields; the UI renders the short-id-qualified
|
|
125
|
+
// display name while Agent tool interactions accept both name and id.
|
|
122
126
|
const displayName = `${slug}-${shortId}`;
|
|
123
127
|
const qualifiedName = `${displayName}--${id}`;
|
|
124
128
|
const stamp = now();
|
|
@@ -128,7 +132,7 @@ class SubagentManager {
|
|
|
128
132
|
natureSlug: slug,
|
|
129
133
|
displayName,
|
|
130
134
|
qualifiedName,
|
|
131
|
-
name:
|
|
135
|
+
name: slug,
|
|
132
136
|
conversationId: this.conversationId,
|
|
133
137
|
createdByAgentId,
|
|
134
138
|
prompt,
|
|
@@ -139,7 +143,7 @@ class SubagentManager {
|
|
|
139
143
|
flowName: flowName || undefined,
|
|
140
144
|
flowPc: Math.max(0, Math.floor(Number(flowPc) || 0)),
|
|
141
145
|
status: 'queued',
|
|
142
|
-
messages: [{ role: 'system', content: `Peer agent '${
|
|
146
|
+
messages: [{ role: 'system', content: `Peer agent '${slug}' (${id}): ${prompt}` }, { role: 'user', content: prompt, hidden_user_input: true }],
|
|
143
147
|
result: null,
|
|
144
148
|
createdAt: stamp,
|
|
145
149
|
updatedAt: stamp,
|
|
@@ -152,7 +156,14 @@ class SubagentManager {
|
|
|
152
156
|
return id;
|
|
153
157
|
}
|
|
154
158
|
get(id) {
|
|
155
|
-
|
|
159
|
+
if (this.subs.has(id))
|
|
160
|
+
return this.subs.get(id);
|
|
161
|
+
const exact = [...this.subs.values()].find(item => item.id === id || item.qualifiedName === id);
|
|
162
|
+
if (exact)
|
|
163
|
+
return exact;
|
|
164
|
+
// name is now caller-supplied and not identity-bearing, so it is a
|
|
165
|
+
// convenience lookup only; the id/shortId/displayName paths stay exact.
|
|
166
|
+
return [...this.subs.values()].find(item => item.name === id || item.displayName === id || item.shortId === id || item.natureSlug === natureSlug(id));
|
|
156
167
|
}
|
|
157
168
|
send(id, prompt) {
|
|
158
169
|
const target = this.get(id);
|
|
@@ -321,6 +332,7 @@ class SubagentManager {
|
|
|
321
332
|
natureSlug: record.natureSlug,
|
|
322
333
|
displayName: record.displayName,
|
|
323
334
|
qualifiedName: record.qualifiedName,
|
|
335
|
+
name: record.name,
|
|
324
336
|
createdByAgentId: record.createdByAgentId,
|
|
325
337
|
status: record.status,
|
|
326
338
|
active: record.status !== 'closed',
|
package/dist/core/toolPolicy.js
CHANGED
package/dist/main.js
CHANGED
|
@@ -491,34 +491,34 @@ function firstRunInit(root) {
|
|
|
491
491
|
// Flow.md
|
|
492
492
|
const fm = path.join(root, 'Flow', 'Flow.md');
|
|
493
493
|
if (!fs.existsSync(fm)) {
|
|
494
|
-
fs.writeFileSync(fm, `# Newmark Flow Format Guide
|
|
495
|
-
|
|
496
|
-
A Flow workflow is saved as \`name.Flow.json\` in the Flow/ folder.
|
|
497
|
-
|
|
498
|
-
## File Format
|
|
499
|
-
\`\`\`json
|
|
500
|
-
{
|
|
501
|
-
"name": "my-workflow",
|
|
502
|
-
"components": [
|
|
503
|
-
{"id": 0, "type": "dialog", "mode": "build", "prompt": "Implement a web server"},
|
|
504
|
-
{"id": 1, "type": "dialog", "mode": "plan", "prompt": "Review: {#prompt#}"},
|
|
505
|
-
{"id": 2, "type": "logic", "prompt": "Is the review complete?", "goto_true": 0, "goto_false": 3},
|
|
506
|
-
{"id": 3, "type": "dialog", "mode": "build", "prompt": "Apply fixes from review"}
|
|
507
|
-
]
|
|
508
|
-
}
|
|
509
|
-
\`\`\`
|
|
510
|
-
|
|
511
|
-
## Component Types
|
|
512
|
-
### dialog
|
|
513
|
-
- id: Sequential index, type: "dialog", mode: "build"/"plan"/"goal"
|
|
514
|
-
- prompt: Base prompt. Use \`{#prompt#}\` as placeholder for user input.
|
|
515
|
-
|
|
516
|
-
### logic
|
|
517
|
-
- id: Sequential index, type: "logic", prompt: Question for the agent to evaluate
|
|
518
|
-
- goto_true/goto_false: Component ID to jump to
|
|
519
|
-
|
|
520
|
-
## Execution
|
|
521
|
-
Components execute in order 0 -> 1 -> 2 -> ..., unless a logic component redirects.
|
|
494
|
+
fs.writeFileSync(fm, `# Newmark Flow Format Guide
|
|
495
|
+
|
|
496
|
+
A Flow workflow is saved as \`name.Flow.json\` in the Flow/ folder.
|
|
497
|
+
|
|
498
|
+
## File Format
|
|
499
|
+
\`\`\`json
|
|
500
|
+
{
|
|
501
|
+
"name": "my-workflow",
|
|
502
|
+
"components": [
|
|
503
|
+
{"id": 0, "type": "dialog", "mode": "build", "prompt": "Implement a web server"},
|
|
504
|
+
{"id": 1, "type": "dialog", "mode": "plan", "prompt": "Review: {#prompt#}"},
|
|
505
|
+
{"id": 2, "type": "logic", "prompt": "Is the review complete?", "goto_true": 0, "goto_false": 3},
|
|
506
|
+
{"id": 3, "type": "dialog", "mode": "build", "prompt": "Apply fixes from review"}
|
|
507
|
+
]
|
|
508
|
+
}
|
|
509
|
+
\`\`\`
|
|
510
|
+
|
|
511
|
+
## Component Types
|
|
512
|
+
### dialog
|
|
513
|
+
- id: Sequential index, type: "dialog", mode: "build"/"plan"/"goal"
|
|
514
|
+
- prompt: Base prompt. Use \`{#prompt#}\` as placeholder for user input.
|
|
515
|
+
|
|
516
|
+
### logic
|
|
517
|
+
- id: Sequential index, type: "logic", prompt: Question for the agent to evaluate
|
|
518
|
+
- goto_true/goto_false: Component ID to jump to
|
|
519
|
+
|
|
520
|
+
## Execution
|
|
521
|
+
Components execute in order 0 -> 1 -> 2 -> ..., unless a logic component redirects.
|
|
522
522
|
`, 'utf-8');
|
|
523
523
|
}
|
|
524
524
|
// Local.json, External.json, State.json
|
|
@@ -843,14 +843,14 @@ async function executeInBrowser(contents, script) {
|
|
|
843
843
|
return await contents.executeJavaScript(script, true);
|
|
844
844
|
}
|
|
845
845
|
function browserSnapshotScript(maxChars) {
|
|
846
|
-
return `(() => {
|
|
847
|
-
const clone = document.body ? document.body.cloneNode(true) : null;
|
|
848
|
-
if (clone) clone.querySelectorAll('script,style,noscript,svg,canvas').forEach((node) => node.remove());
|
|
849
|
-
const text = (clone ? clone.innerText : document.documentElement.innerText || '')
|
|
850
|
-
.replace(/\\s+/g, ' ')
|
|
851
|
-
.trim()
|
|
852
|
-
.slice(0, ${Math.max(500, Math.min(maxChars, 50000))});
|
|
853
|
-
return { url: location.href, title: document.title || '', text };
|
|
846
|
+
return `(() => {
|
|
847
|
+
const clone = document.body ? document.body.cloneNode(true) : null;
|
|
848
|
+
if (clone) clone.querySelectorAll('script,style,noscript,svg,canvas').forEach((node) => node.remove());
|
|
849
|
+
const text = (clone ? clone.innerText : document.documentElement.innerText || '')
|
|
850
|
+
.replace(/\\s+/g, ' ')
|
|
851
|
+
.trim()
|
|
852
|
+
.slice(0, ${Math.max(500, Math.min(maxChars, 50000))});
|
|
853
|
+
return { url: location.href, title: document.title || '', text };
|
|
854
854
|
})()`;
|
|
855
855
|
}
|
|
856
856
|
async function runBrowserControl(request) {
|
|
@@ -881,33 +881,33 @@ async function runBrowserControl(request) {
|
|
|
881
881
|
return { ok: true, action, source: 'webview-cdp', ...snap };
|
|
882
882
|
}
|
|
883
883
|
if (action === 'click') {
|
|
884
|
-
const data = await executeInBrowser(contents, `(() => {
|
|
885
|
-
const el = document.querySelector(${JSON.stringify(request.selector || '')});
|
|
886
|
-
if (!el) return { clicked: false, error: 'selector not found' };
|
|
887
|
-
el.scrollIntoView({ block: 'center', inline: 'center' });
|
|
888
|
-
el.dispatchEvent(new MouseEvent('mouseover', { bubbles: true }));
|
|
889
|
-
el.dispatchEvent(new MouseEvent('mousedown', { bubbles: true }));
|
|
890
|
-
el.dispatchEvent(new MouseEvent('mouseup', { bubbles: true }));
|
|
891
|
-
el.click();
|
|
892
|
-
return { clicked: true, tag: el.tagName, text: (el.innerText || el.value || '').slice(0, 200) };
|
|
884
|
+
const data = await executeInBrowser(contents, `(() => {
|
|
885
|
+
const el = document.querySelector(${JSON.stringify(request.selector || '')});
|
|
886
|
+
if (!el) return { clicked: false, error: 'selector not found' };
|
|
887
|
+
el.scrollIntoView({ block: 'center', inline: 'center' });
|
|
888
|
+
el.dispatchEvent(new MouseEvent('mouseover', { bubbles: true }));
|
|
889
|
+
el.dispatchEvent(new MouseEvent('mousedown', { bubbles: true }));
|
|
890
|
+
el.dispatchEvent(new MouseEvent('mouseup', { bubbles: true }));
|
|
891
|
+
el.click();
|
|
892
|
+
return { clicked: true, tag: el.tagName, text: (el.innerText || el.value || '').slice(0, 200) };
|
|
893
893
|
})()`);
|
|
894
894
|
return { ok: true, action, source: 'webview-cdp', url: contents.getURL(), data };
|
|
895
895
|
}
|
|
896
896
|
if (action === 'type') {
|
|
897
|
-
const data = await executeInBrowser(contents, `(() => {
|
|
898
|
-
const el = document.querySelector(${JSON.stringify(request.selector || '')});
|
|
899
|
-
if (!el) return { typed: false, error: 'selector not found' };
|
|
900
|
-
el.scrollIntoView({ block: 'center', inline: 'center' });
|
|
901
|
-
el.focus();
|
|
902
|
-
if ('value' in el) {
|
|
903
|
-
el.value = ${JSON.stringify(request.text || '')};
|
|
904
|
-
el.dispatchEvent(new Event('input', { bubbles: true }));
|
|
905
|
-
el.dispatchEvent(new Event('change', { bubbles: true }));
|
|
906
|
-
} else {
|
|
907
|
-
el.textContent = ${JSON.stringify(request.text || '')};
|
|
908
|
-
el.dispatchEvent(new InputEvent('input', { bubbles: true, data: ${JSON.stringify(request.text || '')} }));
|
|
909
|
-
}
|
|
910
|
-
return { typed: true, tag: el.tagName };
|
|
897
|
+
const data = await executeInBrowser(contents, `(() => {
|
|
898
|
+
const el = document.querySelector(${JSON.stringify(request.selector || '')});
|
|
899
|
+
if (!el) return { typed: false, error: 'selector not found' };
|
|
900
|
+
el.scrollIntoView({ block: 'center', inline: 'center' });
|
|
901
|
+
el.focus();
|
|
902
|
+
if ('value' in el) {
|
|
903
|
+
el.value = ${JSON.stringify(request.text || '')};
|
|
904
|
+
el.dispatchEvent(new Event('input', { bubbles: true }));
|
|
905
|
+
el.dispatchEvent(new Event('change', { bubbles: true }));
|
|
906
|
+
} else {
|
|
907
|
+
el.textContent = ${JSON.stringify(request.text || '')};
|
|
908
|
+
el.dispatchEvent(new InputEvent('input', { bubbles: true, data: ${JSON.stringify(request.text || '')} }));
|
|
909
|
+
}
|
|
910
|
+
return { typed: true, tag: el.tagName };
|
|
911
911
|
})()`);
|
|
912
912
|
return { ok: true, action, source: 'webview-cdp', url: contents.getURL(), data };
|
|
913
913
|
}
|
|
@@ -966,7 +966,7 @@ function viewerDocument(request) {
|
|
|
966
966
|
const image = request?.type === 'image' && /^data:image\/(?:png|jpeg);base64,[A-Za-z0-9+/]+={0,2}$/i.test(String(request?.dataUrl || ''))
|
|
967
967
|
? `<img src="${viewerEscape(request.dataUrl)}" alt="${title}">`
|
|
968
968
|
: '<div class="empty">Image unavailable</div>';
|
|
969
|
-
return `<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'"><title>${title}</title><style>
|
|
969
|
+
return `<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'"><title>${title}</title><style>
|
|
970
970
|
:root{color-scheme:dark}*{box-sizing:border-box}html,body{margin:0;width:100%;height:100%;overflow:hidden;background:#090d16;color:#dce8f7;font:12px system-ui,sans-serif}main{height:100%;display:grid;grid-template-rows:auto 1fr;padding:14px;gap:10px}header{font-weight:650;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#a8bdd4}section{min-height:0;display:flex;align-items:center;justify-content:center;border:1px solid #233044;border-radius:10px;background:#0d1420}img{display:block;max-width:100%;max-height:100%;object-fit:contain}svg{width:100%;height:100%}.edges line{stroke:#30435b;stroke-width:1;opacity:.62}text{fill:#9fb2c7;font-size:9px}.empty{color:#6f8196}</style></head><body><main><header>${title}</header><section>${image}</section></main></body></html>`;
|
|
971
971
|
}
|
|
972
972
|
async function createViewerWindow(request) {
|
package/dist/tools/index.js
CHANGED
|
@@ -365,14 +365,21 @@ class ToolExecutor {
|
|
|
365
365
|
remote_root: { type: 'string' },
|
|
366
366
|
remote_path: { type: 'string' },
|
|
367
367
|
}, ['action']),
|
|
368
|
-
t('task', 'Create a same-conversation peer agent and return immediately. The peer has a
|
|
369
|
-
t('subagent_list', 'List flat same-conversation peer agents, optionally filtered by status.', { status: { type: 'string', enum: ['idle', 'queued', 'working', 'completed', 'error', 'closed'] } }, []),
|
|
370
|
-
t('subagent_read', 'Read one same-conversation peer status, queue/mailbox summary, latest bounded feedback, and result. Available for running, queued, completed, error, and closed peers.', { id: { type: 'string' }, name: { type: 'string' }, max_chars: { type: 'number', description: 'Bounded result size from 2000 to 32000 characters.' } }, []),
|
|
371
|
-
t('subagent_send', 'Persist a mailbox message to a same-conversation peer agent.', { id: { type: 'string' }, name: { type: 'string' }, message: { type: 'string' }, prompt: { type: 'string', description: 'Legacy alias for message.' }, kind: { type: 'string', enum: ['directive', 'question', 'result', 'handoff'] }, reply_to: { type: 'string' }, correlation_id: { type: 'string' } }, []),
|
|
372
|
-
t('subagent_result', 'Return the persisted transcript, mailbox summary, status, and latest result for a peer agent.', { id: { type: 'string' }, name: { type: 'string' } }, []),
|
|
373
|
-
t('subagent_close', 'Close a same-conversation peer. Root can close any peer; a peer can close only itself.', { id: { type: 'string' }, name: { type: 'string' } }, []),
|
|
368
|
+
t('task', 'Create a same-conversation peer agent and return immediately. The peer has a stable human-readable name, a short id, and a canonical UUID-qualified identity. The peer name is decoupled from its id: pass name for readable references and id for exact targeting. Pass model to select an exact configured model deployment (deployment:providerId:modelId or an unambiguous provider/model name). When model is omitted, the peer inherits the parent Agent\'s currently resolved model deployment. Plan mode peers are forced to Plan.', { nature: { type: 'string' }, name: { type: 'string', description: 'Legacy alias for nature.' }, prompt: { type: 'string' }, preset: { type: 'string' }, agent: { type: 'string' }, model: { type: 'string', description: 'Optional exact model deployment. Omit to inherit the parent Agent resolved model.' }, mode: { type: 'string' }, input_mode: { type: 'string' }, flow: { type: 'string' } }, ['prompt']),
|
|
369
|
+
t('subagent_list', 'List flat same-conversation peer agents, optionally filtered by status. Each entry exposes both the stable name and the exact id; use the id for any subsequent targeting.', { status: { type: 'string', enum: ['idle', 'queued', 'working', 'completed', 'error', 'closed'] } }, []),
|
|
370
|
+
t('subagent_read', 'Read one same-conversation peer status, queue/mailbox summary, latest bounded feedback, and result. Available for running, queued, completed, error, and closed peers. Pass the exact id returned by subagent_list, or a name for convenience lookup.', { id: { type: 'string', description: 'Exact peer id from subagent_list.' }, name: { type: 'string', description: 'Convenience peer name; ambiguous names resolve to the first match.' }, max_chars: { type: 'number', description: 'Bounded result size from 2000 to 32000 characters.' } }, []),
|
|
371
|
+
t('subagent_send', 'Persist a mailbox message to a same-conversation peer agent. Target by exact id (preferred) or name.', { id: { type: 'string', description: 'Exact peer id from subagent_list.' }, name: { type: 'string', description: 'Convenience peer name.' }, message: { type: 'string' }, prompt: { type: 'string', description: 'Legacy alias for message.' }, kind: { type: 'string', enum: ['directive', 'question', 'result', 'handoff'] }, reply_to: { type: 'string' }, correlation_id: { type: 'string' } }, []),
|
|
372
|
+
t('subagent_result', 'Return the persisted transcript, mailbox summary, status, and latest result for a peer agent. Target by exact id (preferred) or name.', { id: { type: 'string', description: 'Exact peer id from subagent_list.' }, name: { type: 'string', description: 'Convenience peer name.' } }, []),
|
|
373
|
+
t('subagent_close', 'Close a same-conversation peer. Root can close any peer; a peer can close only itself. Target by exact id (preferred) or name.', { id: { type: 'string', description: 'Exact peer id from subagent_list.' }, name: { type: 'string', description: 'Convenience peer name.' } }, []),
|
|
374
374
|
t('linked_plan', 'Read or update the current conversation linked Markdown plan. Update requires the current expected_revision.', { action: { type: 'string', enum: ['get', 'update'] }, markdown: { type: 'string' }, expected_revision: { type: 'number' } }, ['action']),
|
|
375
375
|
t('build_history_query', 'Read the concrete public work details of one historical Build Block. The prompt already exposes user input, final summary, and completion status; call this read-only tool only when the user asks what specifically happened. Select by newest-to-oldest history_index, or by run_id returned from an earlier query.', { history_index: { type: 'number', minimum: 1, description: '1-based historical Build Block index from the request ledger; 1 is the newest previous task.' }, run_id: { type: 'string', description: 'Exact run id returned by an earlier build_history_query result.' }, max_events: { type: 'number', minimum: 1, maximum: 200, description: 'Maximum trailing public work events; defaults to 80.' } }, []),
|
|
376
|
+
t('context_compress', 'Actively compress the LLM context history for this conversation. This collapses older history entries into a concise summary while preserving the recent tail, which reduces context tokens and cost. IMPORTANT: it affects only the LLM context (what the model sees); the displayed conversation history shown to the user is never altered. Call this when the conversation is long, token pressure is high, or you judge that older turns are no longer needed in full. Idempotent and safe: repeated calls produce incremental summaries.', { keep_recent: { type: 'number', minimum: 2, maximum: 60, description: 'Recent message count to keep uncompressed at the tail. Defaults to the configured keep_recent_messages.' }, force: { type: 'boolean', description: 'Compress even if the context is not yet over the automatic threshold. Defaults to false.' } }, []),
|
|
377
|
+
t('context_history_manage', 'Manage the LLM context history for this conversation without affecting the displayed conversation history. This is the active context-management surface. Actions: list returns a bounded index of context entries (position, role, name, length, first-line preview); remove deletes the entry at a given position; summarize replaces a contiguous range of context entries with a concise local summary entry. The displayed conversation history (what the user sees) is never modified by any action.', {
|
|
378
|
+
action: { type: 'string', enum: ['list', 'remove', 'summarize'], description: 'list: index context entries. remove: delete the entry at position. summarize: fold entries [from, to] into one summary entry.' },
|
|
379
|
+
position: { type: 'number', minimum: 0, description: '0-based context entry index for remove, or the start of the range for summarize.' },
|
|
380
|
+
to: { type: 'number', minimum: 0, description: '0-based inclusive end of the range for summarize. Defaults to position.' },
|
|
381
|
+
limit: { type: 'number', minimum: 5, maximum: 400, description: 'Maximum context entries to list; defaults to 200.' },
|
|
382
|
+
}, ['action']),
|
|
376
383
|
t('question', 'Ask user a multiple-choice question', { questions: { type: 'array' } }, ['questions']),
|
|
377
384
|
t('skill_download', 'Download a skill', { name: { type: 'string' }, source: { type: 'string' } }, ['name', 'source']),
|
|
378
385
|
t('skill', 'Search enabled skill metadata or load one exact skill body on demand. Use query when unsure, then name to load the selected skill.', { query: { type: 'string', maxLength: 200 }, name: { type: 'string', maxLength: 200 } }, []),
|
|
@@ -40,6 +40,8 @@ exports.NATIVE_TOOL_CATALOG = [
|
|
|
40
40
|
{ name: 'subagent_close', label: 'Subagent close', description: 'Close a same-conversation peer agent.', category: 'agent', defaultEnabled: true, protected: true, availability: 'mode-scoped' },
|
|
41
41
|
{ name: 'linked_plan', label: 'Linked plan', description: 'Read or conservatively update the conversation-linked Markdown plan.', category: 'agent', defaultEnabled: true, protected: true, availability: 'mode-scoped' },
|
|
42
42
|
{ name: 'build_history_query', label: 'Build history query', description: 'Read concrete public work details for one historical Build Block.', category: 'agent', defaultEnabled: true, protected: true, availability: 'mode-scoped' },
|
|
43
|
+
{ name: 'context_compress', label: 'Context compress', description: 'Actively compress the LLM context history, leaving the displayed conversation history unchanged.', category: 'agent', defaultEnabled: true, protected: true, availability: 'mode-scoped' },
|
|
44
|
+
{ name: 'context_history_manage', label: 'Context history manage', description: 'List, remove, or summarize entries in the LLM context history without touching the displayed conversation history.', category: 'agent', defaultEnabled: true, protected: true, availability: 'mode-scoped' },
|
|
43
45
|
{ name: 'question', label: 'Ask question', description: 'Ask the user for structured option feedback.', category: 'agent', defaultEnabled: true, protected: true, availability: 'mode-scoped' },
|
|
44
46
|
{ name: 'skill_download', label: 'Skill download', description: 'Download and install a skill.', category: 'agent', defaultEnabled: true },
|
|
45
47
|
{ name: 'skill', label: 'Skill', description: 'Search enabled skill metadata or load one skill body on demand.', category: 'agent', defaultEnabled: true, protected: true, availability: 'mode-scoped' },
|
package/dist/ui/index.html
CHANGED
|
@@ -9112,7 +9112,7 @@ function workToolActivity(event) {
|
|
|
9112
9112
|
if (name === 'task' || name.indexOf('subagent_') === 0) return { key: 'subagents', type: 'tool_subagent' };
|
|
9113
9113
|
if (name === 'skill' || name === 'skill_load' || name === 'skill_read' || name === 'skill_download') return { key: 'skills', type: 'tool_skill' };
|
|
9114
9114
|
if (name === 'mcp' || name.indexOf('mcp__') === 0 || /^mcp[:._-]/.test(name) || /[:._-]mcp[:._-]/.test(name)) return { key: 'mcp', type: 'tool_mcp' };
|
|
9115
|
-
if (name === 'context_compression') return { key: 'context_compression', type: 'tool_context_compression' };
|
|
9115
|
+
if (name === 'context_compression' || name === 'context_compress' || name === 'context_history_manage') return { key: 'context_compression', type: 'tool_context_compression' };
|
|
9116
9116
|
if (name === 'memory_lab_update' || name === 'memory_lab_reindex') return { key: 'memory_lab', type: 'tool_memory_lab' };
|
|
9117
9117
|
if (name === 'image_inspect' || name === 'computer_use') return { key: 'images', type: 'tool_images' };
|
|
9118
9118
|
if (name === 'write' || name === 'edit') return { key: 'files', type: 'tool_files' };
|