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.
Files changed (188) hide show
  1. package/README.md +16 -3
  2. package/package.json +1 -1
  3. package/plugins/cron-runner/README.md +23 -0
  4. package/plugins/cron-runner/commands/cron.md +7 -1
  5. package/plugins/cron-runner/plugin.js +9 -2
  6. package/plugins/cron-runner/plugin.ts +10 -2
  7. package/plugins/cron-runner/src/commands.js +112 -25
  8. package/plugins/cron-runner/src/commands.ts +154 -33
  9. package/plugins/cron-runner/src/contract.js +70 -0
  10. package/plugins/cron-runner/src/contract.ts +70 -0
  11. package/plugins/cron-runner/src/requests.js +22 -13
  12. package/plugins/cron-runner/src/requests.ts +34 -14
  13. package/plugins/cron-runner/src/runs.js +63 -10
  14. package/plugins/cron-runner/src/runs.ts +107 -15
  15. package/plugins/cron-runner/src/scheduler.js +188 -76
  16. package/plugins/cron-runner/src/scheduler.ts +277 -94
  17. package/plugins/cron-runner/src/schema.js +52 -17
  18. package/plugins/cron-runner/src/schema.ts +73 -22
  19. package/plugins/cron-runner/src/service.js +29 -8
  20. package/plugins/cron-runner/src/service.ts +71 -18
  21. package/plugins/cron-runner/src/store.js +92 -30
  22. package/plugins/cron-runner/src/store.ts +156 -53
  23. package/plugins/cron-runner/src/transaction.js +24 -0
  24. package/plugins/cron-runner/src/transaction.ts +36 -0
  25. package/plugins/cron-runner/src/types.ts +30 -4
  26. package/plugins/cron-runner/test/lifecycle.test.ts +419 -0
  27. package/plugins/cron-runner/test/plugin-integration.test.ts +3 -2
  28. package/plugins/cron-runner/test/reliability.test.ts +2 -2
  29. package/plugins/cron-runner/test/store-and-scheduler.test.ts +9 -7
  30. package/plugins/workflow-runner/plugin.js +1 -0
  31. package/plugins/workflow-runner/plugin.ts +1 -0
  32. package/plugins/workflow-runner/src/index.js +1 -0
  33. package/plugins/workflow-runner/src/index.ts +2 -0
  34. package/plugins/workflow-runner/src/runner.js +6 -1
  35. package/plugins/workflow-runner/src/runner.ts +5 -1
  36. package/plugins/workflow-runner/src/types.ts +1 -0
  37. package/plugins/workflow-runner/test/api.test.ts +1 -0
  38. package/plugins/workflow-runner/test/apiCapabilities.test.ts +4 -0
  39. package/plugins/workflow-runner/test/apiConcurrencyGate.test.ts +1 -0
  40. package/plugins/workflow-runner/test/childWorkflow.test.ts +19 -0
  41. package/plugins/workflow-runner/test/embeddedExecution.test.ts +23 -3
  42. package/src/advisor/README.md +17 -6
  43. package/src/advisor/advisorNudge.js +23 -3
  44. package/src/advisor/advisorNudge.ts +20 -3
  45. package/src/advisor/deliveryReview.js +9 -2
  46. package/src/advisor/deliveryReview.ts +10 -2
  47. package/src/cli/args.js +1 -0
  48. package/src/cli/args.ts +1 -0
  49. package/src/cli/headlessTurn.js +143 -0
  50. package/src/cli/headlessTurn.ts +187 -0
  51. package/src/cli/lifecycle.js +52 -0
  52. package/src/cli/lifecycle.ts +59 -0
  53. package/src/cli/print.js +91 -240
  54. package/src/cli/print.ts +99 -301
  55. package/src/cli/quickModelSetup.js +3 -0
  56. package/src/cli/quickModelSetup.tsx +3 -0
  57. package/src/cli/streamJson.js +244 -334
  58. package/src/cli/streamJson.ts +248 -416
  59. package/src/cli/wizards/contextAdvisorWizard.js +0 -7
  60. package/src/cli/wizards/contextAdvisorWizard.tsx +0 -11
  61. package/src/cli/wizards/providerPresets.js +25 -14
  62. package/src/cli/wizards/providerPresets.ts +25 -14
  63. package/src/cli/wizards/providerWizard.js +29 -11
  64. package/src/cli/wizards/providerWizard.tsx +29 -11
  65. package/src/config/configDefaults.js +2 -2
  66. package/src/config/configDefaults.ts +2 -2
  67. package/src/config/configDiagnostics.js +7 -3
  68. package/src/config/configDiagnostics.ts +6 -3
  69. package/src/config/configFile.ts +1 -1
  70. package/src/context/compact.js +40 -10
  71. package/src/context/compact.ts +51 -12
  72. package/src/context/compactResources.js +39 -0
  73. package/src/context/compactResources.ts +35 -0
  74. package/src/context/manualCompact.js +20 -0
  75. package/src/context/manualCompact.ts +28 -0
  76. package/src/llm/client.js +4 -0
  77. package/src/llm/client.ts +4 -0
  78. package/src/llm/messageProvenance.js +1 -1
  79. package/src/llm/messageProvenance.ts +1 -1
  80. package/src/loop/README.md +4 -2
  81. package/src/loop/deliveryIntent.js +3 -2
  82. package/src/loop/deliveryIntent.ts +4 -2
  83. package/src/loop/messages.js +1 -0
  84. package/src/loop/messages.ts +1 -0
  85. package/src/loop/options.ts +2 -0
  86. package/src/loop.js +10 -2
  87. package/src/loop.ts +9 -2
  88. package/src/main.js +40 -45
  89. package/src/main.tsx +33 -52
  90. package/src/plugin-sdk.js +1 -1
  91. package/src/plugin-sdk.ts +1 -1
  92. package/src/plugins/artifactDelivery.js +76 -0
  93. package/src/plugins/artifactDelivery.ts +76 -0
  94. package/src/plugins/pluginApi.ts +4 -0
  95. package/src/plugins/pluginRunner.js +2 -0
  96. package/src/plugins/pluginRunner.ts +3 -0
  97. package/src/prompts/delegation.js +2 -2
  98. package/src/prompts/delegation.ts +2 -2
  99. package/src/prompts/policyRegistry.js +7 -5
  100. package/src/prompts/policyRegistry.ts +7 -5
  101. package/src/prompts/promptAssembly.js +2 -2
  102. package/src/prompts/promptAssembly.ts +2 -2
  103. package/src/runtime/requestIntent.js +86 -0
  104. package/src/runtime/requestIntent.ts +66 -0
  105. package/src/runtime/systemEvents.js +10 -1
  106. package/src/runtime/systemEvents.ts +9 -1
  107. package/src/session/commandTranscript.js +76 -0
  108. package/src/session/commandTranscript.ts +77 -0
  109. package/src/session/executionOutcome.js +25 -0
  110. package/src/session/executionOutcome.ts +34 -0
  111. package/src/session/runAgentTurn.js +8 -1
  112. package/src/session/runAgentTurn.ts +10 -1
  113. package/src/session/runTurn.js +40 -15
  114. package/src/session/runTurn.ts +38 -12
  115. package/src/session/sessionState.js +7 -2
  116. package/src/session/sessionState.ts +7 -2
  117. package/src/team/onlineToolContract.js +1 -0
  118. package/src/team/onlineToolContract.ts +1 -0
  119. package/src/tools/advisor/advisor.js +73 -30
  120. package/src/tools/advisor/advisor.ts +73 -33
  121. package/src/tools/advisor/advisorCoordination.js +44 -0
  122. package/src/tools/advisor/advisorCoordination.ts +45 -0
  123. package/src/tools/advisor/advisorDescription.js +1 -1
  124. package/src/tools/advisor/advisorDescription.ts +1 -1
  125. package/src/tools/agent/README.md +2 -0
  126. package/src/tools/agent/agent.js +7 -3
  127. package/src/tools/agent/agent.ts +7 -3
  128. package/src/tools/agent/agentHandoff.js +2 -1
  129. package/src/tools/agent/agentHandoff.ts +2 -1
  130. package/src/tools/agent/agentTaskService.js +26 -5
  131. package/src/tools/agent/agentTaskService.ts +25 -5
  132. package/src/tools/agent/agentTypes.js +2 -2
  133. package/src/tools/agent/agentTypes.ts +2 -2
  134. package/src/tools/agent/baselineAttach.js +14 -7
  135. package/src/tools/agent/baselineAttach.ts +14 -7
  136. package/src/tools/applypatch/applyPatch.js +39 -13
  137. package/src/tools/applypatch/applyPatch.ts +35 -15
  138. package/src/tools/bash/bash.js +3 -0
  139. package/src/tools/bash/bash.ts +3 -0
  140. package/src/tools/capabilities.js +1 -0
  141. package/src/tools/capabilities.ts +1 -0
  142. package/src/tools/download/download.js +147 -11
  143. package/src/tools/download/download.ts +193 -17
  144. package/src/tools/edit/edit.js +4 -4
  145. package/src/tools/edit/edit.ts +4 -4
  146. package/src/tools/edit/multi-edit.js +2 -2
  147. package/src/tools/edit/multi-edit.ts +2 -2
  148. package/src/tools/index.js +2 -0
  149. package/src/tools/index.ts +2 -0
  150. package/src/tools/powershell/powershell.js +2 -0
  151. package/src/tools/powershell/powershell.ts +2 -0
  152. package/src/tools/schedule/schedule.js +184 -0
  153. package/src/tools/schedule/schedule.ts +214 -0
  154. package/src/tools/shared/fileUtils.js +16 -6
  155. package/src/tools/shared/fileUtils.ts +15 -6
  156. package/src/tools/tasks/backgroundTaskService.js +108 -12
  157. package/src/tools/tasks/backgroundTaskService.ts +106 -14
  158. package/src/tools/tasks/taskOutput.js +15 -5
  159. package/src/tools/tasks/taskOutput.ts +13 -5
  160. package/src/tools/tasks/taskStop.js +2 -2
  161. package/src/tools/tasks/taskStop.ts +2 -2
  162. package/src/tools/toolPromptGuides.js +4 -3
  163. package/src/tools/toolPromptGuides.ts +4 -3
  164. package/src/tools/webfetch/webfetch.js +1 -1
  165. package/src/tools/webfetch/webfetch.ts +1 -1
  166. package/src/types.ts +6 -0
  167. package/src/ui/App.js +3 -1
  168. package/src/ui/App.tsx +2 -0
  169. package/src/ui/InputBox.js +2 -2
  170. package/src/ui/InputBox.tsx +2 -2
  171. package/src/ui/LiveArea.js +6 -1
  172. package/src/ui/LiveArea.tsx +6 -1
  173. package/src/ui/MessageList.js +2 -0
  174. package/src/ui/MessageList.tsx +2 -0
  175. package/src/ui/README.md +8 -2
  176. package/src/ui/activityPresentation.js +23 -3
  177. package/src/ui/activityPresentation.ts +22 -3
  178. package/src/ui/backgroundWake.js +20 -4
  179. package/src/ui/backgroundWake.ts +19 -4
  180. package/src/ui/commandTranscript.js +2 -69
  181. package/src/ui/commandTranscript.ts +2 -71
  182. package/src/ui/hooks/useBackgroundAgents.js +33 -0
  183. package/src/ui/hooks/useBackgroundAgents.ts +36 -0
  184. package/src/ui/hooks/useChat.js +46 -25
  185. package/src/ui/hooks/useChat.ts +36 -23
  186. package/src/web/protocol.ts +5 -2
  187. package/src/cli/wizards/advisorWizard.js +0 -152
  188. 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
- }