minimal-agent 0.18.20 → 0.18.22
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/README.md +16 -3
- package/package.json +1 -1
- package/plugins/cron-runner/README.md +23 -0
- package/plugins/cron-runner/commands/cron.md +7 -1
- package/plugins/cron-runner/plugin.js +9 -2
- package/plugins/cron-runner/plugin.ts +10 -2
- package/plugins/cron-runner/src/commands.js +112 -25
- package/plugins/cron-runner/src/commands.ts +154 -33
- package/plugins/cron-runner/src/contract.js +70 -0
- package/plugins/cron-runner/src/contract.ts +70 -0
- package/plugins/cron-runner/src/requests.js +22 -13
- package/plugins/cron-runner/src/requests.ts +34 -14
- package/plugins/cron-runner/src/runs.js +63 -10
- package/plugins/cron-runner/src/runs.ts +107 -15
- package/plugins/cron-runner/src/scheduler.js +188 -76
- package/plugins/cron-runner/src/scheduler.ts +277 -94
- package/plugins/cron-runner/src/schema.js +52 -17
- package/plugins/cron-runner/src/schema.ts +73 -22
- package/plugins/cron-runner/src/service.js +29 -8
- package/plugins/cron-runner/src/service.ts +71 -18
- package/plugins/cron-runner/src/store.js +92 -30
- package/plugins/cron-runner/src/store.ts +156 -53
- package/plugins/cron-runner/src/transaction.js +24 -0
- package/plugins/cron-runner/src/transaction.ts +36 -0
- package/plugins/cron-runner/src/types.ts +30 -4
- package/plugins/cron-runner/test/lifecycle.test.ts +419 -0
- package/plugins/cron-runner/test/plugin-integration.test.ts +3 -2
- package/plugins/cron-runner/test/reliability.test.ts +2 -2
- package/plugins/cron-runner/test/store-and-scheduler.test.ts +9 -7
- package/plugins/workflow-runner/plugin.js +1 -0
- package/plugins/workflow-runner/plugin.ts +1 -0
- package/plugins/workflow-runner/src/index.js +1 -0
- package/plugins/workflow-runner/src/index.ts +2 -0
- package/plugins/workflow-runner/src/runner.js +6 -1
- package/plugins/workflow-runner/src/runner.ts +5 -1
- package/plugins/workflow-runner/src/types.ts +1 -0
- package/plugins/workflow-runner/test/api.test.ts +1 -0
- package/plugins/workflow-runner/test/apiCapabilities.test.ts +4 -0
- package/plugins/workflow-runner/test/apiConcurrencyGate.test.ts +1 -0
- package/plugins/workflow-runner/test/childWorkflow.test.ts +19 -0
- package/plugins/workflow-runner/test/embeddedExecution.test.ts +23 -3
- package/src/advisor/README.md +17 -6
- package/src/advisor/advisorNudge.js +23 -3
- package/src/advisor/advisorNudge.ts +20 -3
- package/src/advisor/deliveryReview.js +9 -2
- package/src/advisor/deliveryReview.ts +10 -2
- package/src/cli/args.js +1 -0
- package/src/cli/args.ts +1 -0
- package/src/cli/headlessTurn.js +143 -0
- package/src/cli/headlessTurn.ts +187 -0
- package/src/cli/lifecycle.js +52 -0
- package/src/cli/lifecycle.ts +59 -0
- package/src/cli/print.js +91 -240
- package/src/cli/print.ts +99 -301
- package/src/cli/quickModelSetup.js +3 -0
- package/src/cli/quickModelSetup.tsx +3 -0
- package/src/cli/streamJson.js +244 -334
- package/src/cli/streamJson.ts +248 -416
- package/src/cli/wizards/contextAdvisorWizard.js +0 -7
- package/src/cli/wizards/contextAdvisorWizard.tsx +0 -11
- package/src/cli/wizards/providerPresets.js +25 -14
- package/src/cli/wizards/providerPresets.ts +25 -14
- package/src/cli/wizards/providerWizard.js +29 -11
- package/src/cli/wizards/providerWizard.tsx +29 -11
- package/src/config/configDefaults.js +2 -2
- package/src/config/configDefaults.ts +2 -2
- package/src/config/configDiagnostics.js +7 -3
- package/src/config/configDiagnostics.ts +6 -3
- package/src/config/configFile.ts +1 -1
- package/src/context/compact.js +40 -10
- package/src/context/compact.ts +51 -12
- package/src/context/compactResources.js +39 -0
- package/src/context/compactResources.ts +35 -0
- package/src/context/manualCompact.js +20 -0
- package/src/context/manualCompact.ts +28 -0
- package/src/llm/client.js +4 -0
- package/src/llm/client.ts +4 -0
- package/src/llm/messageProvenance.js +1 -1
- package/src/llm/messageProvenance.ts +1 -1
- package/src/loop/README.md +4 -2
- package/src/loop/deliveryIntent.js +3 -2
- package/src/loop/deliveryIntent.ts +4 -2
- package/src/loop/messages.js +1 -0
- package/src/loop/messages.ts +1 -0
- package/src/loop/options.ts +2 -0
- package/src/loop.js +10 -2
- package/src/loop.ts +9 -2
- package/src/main.js +40 -45
- package/src/main.tsx +33 -52
- package/src/plugin-sdk.js +1 -1
- package/src/plugin-sdk.ts +1 -1
- package/src/plugins/artifactDelivery.js +76 -0
- package/src/plugins/artifactDelivery.ts +76 -0
- package/src/plugins/pluginApi.ts +4 -0
- package/src/plugins/pluginRunner.js +2 -0
- package/src/plugins/pluginRunner.ts +3 -0
- package/src/prompts/delegation.js +2 -2
- package/src/prompts/delegation.ts +2 -2
- package/src/prompts/policyRegistry.js +7 -5
- package/src/prompts/policyRegistry.ts +7 -5
- package/src/prompts/promptAssembly.js +2 -2
- package/src/prompts/promptAssembly.ts +2 -2
- package/src/runtime/requestIntent.js +86 -0
- package/src/runtime/requestIntent.ts +66 -0
- package/src/runtime/systemEvents.js +10 -1
- package/src/runtime/systemEvents.ts +9 -1
- package/src/session/commandTranscript.js +76 -0
- package/src/session/commandTranscript.ts +77 -0
- package/src/session/executionOutcome.js +25 -0
- package/src/session/executionOutcome.ts +34 -0
- package/src/session/runAgentTurn.js +8 -1
- package/src/session/runAgentTurn.ts +10 -1
- package/src/session/runTurn.js +40 -15
- package/src/session/runTurn.ts +38 -12
- package/src/session/sessionState.js +7 -2
- package/src/session/sessionState.ts +7 -2
- package/src/team/onlineToolContract.js +1 -0
- package/src/team/onlineToolContract.ts +1 -0
- package/src/tools/advisor/advisor.js +73 -30
- package/src/tools/advisor/advisor.ts +73 -33
- package/src/tools/advisor/advisorCoordination.js +44 -0
- package/src/tools/advisor/advisorCoordination.ts +45 -0
- package/src/tools/advisor/advisorDescription.js +1 -1
- package/src/tools/advisor/advisorDescription.ts +1 -1
- package/src/tools/agent/README.md +2 -0
- package/src/tools/agent/agent.js +7 -3
- package/src/tools/agent/agent.ts +7 -3
- package/src/tools/agent/agentHandoff.js +2 -1
- package/src/tools/agent/agentHandoff.ts +2 -1
- package/src/tools/agent/agentTaskService.js +26 -5
- package/src/tools/agent/agentTaskService.ts +25 -5
- package/src/tools/agent/agentTypes.js +2 -2
- package/src/tools/agent/agentTypes.ts +2 -2
- package/src/tools/agent/baselineAttach.js +14 -7
- package/src/tools/agent/baselineAttach.ts +14 -7
- package/src/tools/applypatch/applyPatch.js +39 -13
- package/src/tools/applypatch/applyPatch.ts +35 -15
- package/src/tools/bash/bash.js +3 -0
- package/src/tools/bash/bash.ts +3 -0
- package/src/tools/capabilities.js +1 -0
- package/src/tools/capabilities.ts +1 -0
- package/src/tools/download/download.js +147 -11
- package/src/tools/download/download.ts +193 -17
- package/src/tools/edit/edit.js +4 -4
- package/src/tools/edit/edit.ts +4 -4
- package/src/tools/edit/multi-edit.js +2 -2
- package/src/tools/edit/multi-edit.ts +2 -2
- package/src/tools/index.js +2 -0
- package/src/tools/index.ts +2 -0
- package/src/tools/powershell/powershell.js +2 -0
- package/src/tools/powershell/powershell.ts +2 -0
- package/src/tools/schedule/schedule.js +184 -0
- package/src/tools/schedule/schedule.ts +214 -0
- package/src/tools/shared/fileUtils.js +16 -6
- package/src/tools/shared/fileUtils.ts +15 -6
- package/src/tools/tasks/backgroundTaskService.js +108 -12
- package/src/tools/tasks/backgroundTaskService.ts +106 -14
- package/src/tools/tasks/taskOutput.js +15 -5
- package/src/tools/tasks/taskOutput.ts +13 -5
- package/src/tools/tasks/taskStop.js +2 -2
- package/src/tools/tasks/taskStop.ts +2 -2
- package/src/tools/toolPromptGuides.js +4 -3
- package/src/tools/toolPromptGuides.ts +4 -3
- package/src/tools/webfetch/webfetch.js +1 -1
- package/src/tools/webfetch/webfetch.ts +1 -1
- package/src/types.ts +6 -0
- package/src/ui/App.js +3 -1
- package/src/ui/App.tsx +2 -0
- package/src/ui/InputBox.js +2 -2
- package/src/ui/InputBox.tsx +2 -2
- package/src/ui/LiveArea.js +6 -1
- package/src/ui/LiveArea.tsx +6 -1
- package/src/ui/MessageList.js +2 -0
- package/src/ui/MessageList.tsx +2 -0
- package/src/ui/README.md +8 -2
- package/src/ui/activityPresentation.js +23 -3
- package/src/ui/activityPresentation.ts +22 -3
- package/src/ui/backgroundWake.js +20 -4
- package/src/ui/backgroundWake.ts +19 -4
- package/src/ui/commandTranscript.js +2 -69
- package/src/ui/commandTranscript.ts +2 -71
- package/src/ui/hooks/useBackgroundAgents.js +33 -0
- package/src/ui/hooks/useBackgroundAgents.ts +36 -0
- package/src/ui/hooks/useChat.js +46 -25
- package/src/ui/hooks/useChat.ts +36 -23
- package/src/web/protocol.ts +5 -2
- package/src/cli/wizards/advisorWizard.js +0 -152
- package/src/cli/wizards/advisorWizard.tsx +0 -203
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ============================================================
|
|
3
|
-
* src/cli/wizards/advisorWizard.tsx —— 顾问模型子向导
|
|
4
|
-
* ------------------------------------------------------------
|
|
5
|
-
* v4 模型列表 schema 下,顾问不再自带一整套独立凭据——默认从已配置的模型列表
|
|
6
|
-
* 选一个复用。但顾问常常需要一个跟基座完全不同的 provider(对比不同模型的
|
|
7
|
-
* 第二意见才有意义),而 CLI 的「配置基座模型」向导只管理基座这一个槽位、
|
|
8
|
-
* 没有别的入口能新增模型——所以这里的模型选择字段里多一项「+ 新建模型」,
|
|
9
|
-
* 选它会先走一小段收集新模型字段的表单,新建成功后再回落到常规的顾问行为
|
|
10
|
-
* 字段(启用/调用模式/预算/超时/敏感共享)。三阶段状态机,全部落盘只发生在
|
|
11
|
-
* 最后一步提交时(ESC 在任何阶段取消都不留半成品模型)。
|
|
12
|
-
* ============================================================
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import React, { useState } from 'react';
|
|
16
|
-
|
|
17
|
-
import type { ModelConfig } from '../../config/configFile.js';
|
|
18
|
-
import { configService } from '../../config/configService.js';
|
|
19
|
-
import { DEFAULT_ADVISOR_CONFIG } from '../../config/configDefaults.js';
|
|
20
|
-
import { CONFIG_LIMITS, normalizeLimited } from '../../config/numericLimits.js';
|
|
21
|
-
import { FieldForm, type FieldValues } from './fieldForm.js';
|
|
22
|
-
|
|
23
|
-
type ResolvedAdvisor = Awaited<ReturnType<typeof configService.advisor>>;
|
|
24
|
-
|
|
25
|
-
interface Props {
|
|
26
|
-
existing?: ResolvedAdvisor | null;
|
|
27
|
-
/** 已配置的模型列表(供选择顾问引用哪一个,或对照展示);由 configMenu.tsx 一并拉取传入。 */
|
|
28
|
-
models: ModelConfig[];
|
|
29
|
-
onDone: () => void;
|
|
30
|
-
onCancel: () => void;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const NEW_MODEL_OPTION = '+ 新建模型(作为顾问专用,可与基座用不同 provider)';
|
|
34
|
-
|
|
35
|
-
function parsePositiveInt(value: unknown, fallback: number): number {
|
|
36
|
-
const parsed = Number.parseInt(String(value ?? ''), 10);
|
|
37
|
-
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
interface NewModelDraft {
|
|
41
|
-
baseURL: string;
|
|
42
|
-
apiKey: string;
|
|
43
|
-
model: string;
|
|
44
|
-
contextWindow: number;
|
|
45
|
-
supportsVision: boolean;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
type Phase = 'model-choice' | 'new-model' | 'advisor-fields';
|
|
49
|
-
|
|
50
|
-
export function AdvisorWizard({ existing, models, onDone, onCancel }: Props): JSX.Element {
|
|
51
|
-
const enabledModels = models.filter((m) => m.enabled);
|
|
52
|
-
const labelFor = (m: ModelConfig, index: number) => `${index + 1}. ${m.displayName || m.model}`;
|
|
53
|
-
const existingOptions = enabledModels.map(labelFor);
|
|
54
|
-
const labelToId = new Map(enabledModels.map((m, i) => [labelFor(m, i), m.id]));
|
|
55
|
-
const currentLabel = (() => {
|
|
56
|
-
const index = enabledModels.findIndex((m) => m.id === existing?.modelId);
|
|
57
|
-
return index >= 0 ? labelFor(enabledModels[index]!, index) : undefined;
|
|
58
|
-
})();
|
|
59
|
-
|
|
60
|
-
const [phase, setPhase] = useState<Phase>('model-choice');
|
|
61
|
-
const [chosenModelId, setChosenModelId] = useState<string | null>(null);
|
|
62
|
-
const [newModelDraft, setNewModelDraft] = useState<NewModelDraft | null>(null);
|
|
63
|
-
|
|
64
|
-
if (phase === 'model-choice') {
|
|
65
|
-
return (
|
|
66
|
-
<FieldForm
|
|
67
|
-
title="配置顾问模型(Advisor 工具)"
|
|
68
|
-
fields={[
|
|
69
|
-
{
|
|
70
|
-
key: 'modelLabel',
|
|
71
|
-
label: '使用哪个模型',
|
|
72
|
-
type: 'select',
|
|
73
|
-
options: [...existingOptions, NEW_MODEL_OPTION],
|
|
74
|
-
default: currentLabel ?? (existingOptions[0] ?? NEW_MODEL_OPTION),
|
|
75
|
-
hint: enabledModels.length === 0
|
|
76
|
-
? '还没有已配置的模型,只能新建'
|
|
77
|
-
: '可以直接复用基座模型,也可以新建一个专属 provider',
|
|
78
|
-
},
|
|
79
|
-
]}
|
|
80
|
-
onSubmit={async (values) => {
|
|
81
|
-
const label = String(values.modelLabel ?? '');
|
|
82
|
-
if (label === NEW_MODEL_OPTION) {
|
|
83
|
-
setPhase('new-model');
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
const id = labelToId.get(label);
|
|
87
|
-
if (!id) throw new Error('请选择一个模型');
|
|
88
|
-
setChosenModelId(id);
|
|
89
|
-
setPhase('advisor-fields');
|
|
90
|
-
}}
|
|
91
|
-
onCancel={onCancel}
|
|
92
|
-
/>
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (phase === 'new-model') {
|
|
97
|
-
return (
|
|
98
|
-
<FieldForm
|
|
99
|
-
title="新建顾问专用模型(固定 OpenAI 兼容格式;Anthropic 格式请用 Desktop 添加)"
|
|
100
|
-
fields={[
|
|
101
|
-
{ key: 'baseURL', label: 'API 完整端点地址(含 /chat/completions 后缀)', type: 'text', default: '' },
|
|
102
|
-
{ key: 'apiKey', label: 'API Key', type: 'password', default: '' },
|
|
103
|
-
{ key: 'model', label: 'Model', type: 'text', default: '' },
|
|
104
|
-
{ key: 'contextWindow', label: 'Context Window(token 数)', type: 'text', default: '1000000', optional: true },
|
|
105
|
-
]}
|
|
106
|
-
onSubmit={async (values: FieldValues) => {
|
|
107
|
-
const baseURL = String(values.baseURL ?? '').trim();
|
|
108
|
-
const apiKey = String(values.apiKey ?? '').trim();
|
|
109
|
-
const model = String(values.model ?? '').trim();
|
|
110
|
-
if (!baseURL || !apiKey || !model) throw new Error('Base URL / API Key / Model 均不能为空');
|
|
111
|
-
setNewModelDraft({
|
|
112
|
-
baseURL,
|
|
113
|
-
apiKey,
|
|
114
|
-
model,
|
|
115
|
-
contextWindow: parsePositiveInt(values.contextWindow, 1_000_000),
|
|
116
|
-
supportsVision: true,
|
|
117
|
-
});
|
|
118
|
-
setPhase('advisor-fields');
|
|
119
|
-
}}
|
|
120
|
-
onCancel={onCancel}
|
|
121
|
-
/>
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// phase === 'advisor-fields'
|
|
126
|
-
return (
|
|
127
|
-
<FieldForm
|
|
128
|
-
title="配置顾问模型 · 行为设置"
|
|
129
|
-
fields={[
|
|
130
|
-
{ key: 'enabled', label: '是否启用', type: 'boolean', default: existing?.enabled ?? true },
|
|
131
|
-
{
|
|
132
|
-
key: 'mode',
|
|
133
|
-
label: '调用模式',
|
|
134
|
-
type: 'select',
|
|
135
|
-
options: ['auto', 'manual'],
|
|
136
|
-
default: existing?.mode ?? 'auto',
|
|
137
|
-
hint: 'auto=主循环自主判断时机调用 · manual=仅 /advisor ask 手动触发',
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
key: 'enforcement',
|
|
141
|
-
label: '补问方式',
|
|
142
|
-
type: 'select',
|
|
143
|
-
options: ['remind', 'followup'],
|
|
144
|
-
default: existing?.enforcement ?? 'remind',
|
|
145
|
-
hint: 'remind=只提醒 · followup=实质回答未复核时再发一次请求,让模型自己补问顾问(弱基座模型用)',
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
key: 'timeoutSeconds',
|
|
149
|
-
label: '最长等待(秒)',
|
|
150
|
-
type: 'text',
|
|
151
|
-
default: String(Math.round((existing?.timeoutMs ?? DEFAULT_ADVISOR_CONFIG.timeoutMs) / 1000)),
|
|
152
|
-
optional: true,
|
|
153
|
-
},
|
|
154
|
-
]}
|
|
155
|
-
onSubmit={async (values) => {
|
|
156
|
-
// 只在这最后一步才真正落盘——ESC 在任何前置阶段取消都不留半成品模型。
|
|
157
|
-
// newModelDraft 在 add 成功后立即清空 + 把新 id 记入 chosenModelId:若紧接着
|
|
158
|
-
// 的顾问 patch 失败,FieldForm 在同一 phase 内回到第 1 项重试会重新调这个
|
|
159
|
-
// onSubmit,若不清空 newModelDraft 会重新执行一次 add,产生重复模型。
|
|
160
|
-
let modelId = chosenModelId;
|
|
161
|
-
if (!modelId && newModelDraft) {
|
|
162
|
-
const beforeIds = new Set(models.map((m) => m.id));
|
|
163
|
-
const saved = await configService.savePatch({
|
|
164
|
-
models: [{
|
|
165
|
-
op: 'add',
|
|
166
|
-
model: {
|
|
167
|
-
apiFormat: 'openai',
|
|
168
|
-
baseURL: newModelDraft.baseURL,
|
|
169
|
-
apiKey: newModelDraft.apiKey,
|
|
170
|
-
model: newModelDraft.model,
|
|
171
|
-
contextWindow: newModelDraft.contextWindow,
|
|
172
|
-
supportsVision: newModelDraft.supportsVision,
|
|
173
|
-
promptCache: { mode: 'auto' },
|
|
174
|
-
enabled: true,
|
|
175
|
-
},
|
|
176
|
-
}],
|
|
177
|
-
});
|
|
178
|
-
modelId = saved.config?.models.find((m) => !beforeIds.has(m.id))?.id ?? null;
|
|
179
|
-
if (modelId) {
|
|
180
|
-
setChosenModelId(modelId);
|
|
181
|
-
setNewModelDraft(null);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
if (!modelId) throw new Error('未能确定要使用的模型');
|
|
185
|
-
await configService.savePatch({
|
|
186
|
-
advisor: {
|
|
187
|
-
enabled: values.enabled as boolean,
|
|
188
|
-
mode: values.mode === 'manual' ? 'manual' : 'auto',
|
|
189
|
-
enforcement: values.enforcement === 'followup' ? 'followup' : 'remind',
|
|
190
|
-
modelId,
|
|
191
|
-
timeoutMs: normalizeLimited(
|
|
192
|
-
parsePositiveInt(values.timeoutSeconds, DEFAULT_ADVISOR_CONFIG.timeoutMs / 1000) * 1000,
|
|
193
|
-
CONFIG_LIMITS.advisorTimeoutMs,
|
|
194
|
-
DEFAULT_ADVISOR_CONFIG.timeoutMs,
|
|
195
|
-
),
|
|
196
|
-
},
|
|
197
|
-
});
|
|
198
|
-
onDone();
|
|
199
|
-
}}
|
|
200
|
-
onCancel={onCancel}
|
|
201
|
-
/>
|
|
202
|
-
);
|
|
203
|
-
}
|