@miphamai/cli 0.85.17 → 0.85.19
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 +1 -1
- package/package.json +1 -1
- package/src/agent/sub-agent.ts +11 -0
- package/src/agent/types.ts +8 -0
- package/src/agent-view/agent-view-manager.ts +50 -0
- package/src/config/defaults.ts +6 -1
- package/src/core/credential-masker/output-scrub.ts +8 -1
- package/src/core/engine.ts +88 -9
- package/src/core/instructions.ts +97 -2
- package/src/core/permission-rules.ts +52 -4
- package/src/core/permission.ts +6 -2
- package/src/core/session-log.ts +10 -0
- package/src/daemon/channel-message.ts +8 -1
- package/src/daemon/session-worker.ts +17 -2
- package/src/i18n-core/locales/en-US.json +4 -2
- package/src/i18n-core/locales/zh-CN.json +4 -2
- package/src/index.tsx +22 -1
- package/src/mcp/client.ts +20 -1
- package/src/mcp/http-transport.ts +48 -3
- package/src/mcp/instructions.ts +25 -1
- package/src/mcp/protocol.ts +69 -2
- package/src/providers/anthropic.ts +47 -12
- package/src/providers/fetch-utils.ts +72 -4
- package/src/providers/openai-compat.ts +13 -10
- package/src/shared/package-info.ts +2 -2
- package/src/shared/types.ts +12 -0
- package/src/skills/loader.ts +13 -2
- package/src/skills/sanitizer.ts +16 -8
- package/src/tools/agent/agent.ts +24 -0
- package/src/tools/agent/skill.ts +13 -0
- package/src/tools/artifact/artifact.ts +9 -9
- package/src/tools/exec/bash.ts +10 -0
- package/src/tools/file/grep.ts +11 -2
- package/src/tools/file/read.ts +21 -0
- package/src/tools/network/web-fetch.ts +87 -22
- package/src/tools/scheduling/schedule-wakeup.ts +156 -32
- package/src/ui/app.tsx +47 -6
- package/src/ui/chat.tsx +15 -1
- package/src/ui/input.tsx +25 -1
- package/src/workflow/primitives/agent.ts +1 -0
package/src/ui/app.tsx
CHANGED
|
@@ -62,7 +62,8 @@ import { useI18n } from '../i18n-context'
|
|
|
62
62
|
import type { PermissionMode } from '../shared/index.ts'
|
|
63
63
|
import { sanitizeForDisplay } from '../shared/sanitize.ts'
|
|
64
64
|
import { recordLoopTurn, readAutoloopJournal } from '../commands/autoloop-journal.js'
|
|
65
|
-
import { cancelAllSessionTimers } from '../tools/scheduling/schedule-wakeup.js'
|
|
65
|
+
import { cancelAllSessionTimers, resumeWakeups } from '../tools/scheduling/schedule-wakeup.js'
|
|
66
|
+
import type { LostWakeup } from '../tools/scheduling/schedule-wakeup.js'
|
|
66
67
|
import { startCronPoller } from '../core/cron-poller'
|
|
67
68
|
|
|
68
69
|
interface AppProps {
|
|
@@ -224,6 +225,25 @@ function toolDisplayName(name: string): string {
|
|
|
224
225
|
return name
|
|
225
226
|
}
|
|
226
227
|
|
|
228
|
+
/**
|
|
229
|
+
* The turn a `/loop` gets when its wakeup came due while no process was running.
|
|
230
|
+
*
|
|
231
|
+
* Said plainly, and with the decision handed back: the loop was left armed by the
|
|
232
|
+
* model, so only the model can say whether to re-time it or end it. Silence here is
|
|
233
|
+
* what made the loss invisible — the model would keep treating a dead timer as
|
|
234
|
+
* pending work.
|
|
235
|
+
*/
|
|
236
|
+
function missedWakeupNotice(lost: LostWakeup): string {
|
|
237
|
+
return (
|
|
238
|
+
`⏰ Your scheduled wakeup never fired: it was due at ${lost.firesAt} ` +
|
|
239
|
+
`(${lost.reason}), and Mipham Code was not running then — nothing ran on your behalf. ` +
|
|
240
|
+
`The prompt you had queued was:\n"${lost.prompt}"\n\n` +
|
|
241
|
+
`The delay you chose measured from when you chose it, so this is not the iteration you ` +
|
|
242
|
+
`asked for. Decide now: reschedule with ScheduleWakeup (a fresh delaySeconds), or end ` +
|
|
243
|
+
`the loop with ScheduleWakeup {stop: true}.`
|
|
244
|
+
)
|
|
245
|
+
}
|
|
246
|
+
|
|
227
247
|
export function App({
|
|
228
248
|
engine,
|
|
229
249
|
config,
|
|
@@ -834,10 +854,11 @@ export function App({
|
|
|
834
854
|
setActiveTool(null)
|
|
835
855
|
setAgentTick((t) => t + 1)
|
|
836
856
|
}
|
|
837
|
-
//
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
857
|
+
// No checkpoint here. The automatic one is taken in `engine.process`, right
|
|
858
|
+
// after the prompt lands and before the reply does — so the newest
|
|
859
|
+
// checkpoint is the state `/rewind` is supposed to return to. Saving a
|
|
860
|
+
// second time at the end of the turn would put a snapshot *containing* that
|
|
861
|
+
// reply on top, and `/rewind` would restore what is already on screen.
|
|
841
862
|
// Final sync of background agents after the turn completes
|
|
842
863
|
syncBgAgents()
|
|
843
864
|
}
|
|
@@ -901,6 +922,26 @@ export function App({
|
|
|
901
922
|
return () => qe.setOnWakeupEnqueued(null)
|
|
902
923
|
}, [engine])
|
|
903
924
|
|
|
925
|
+
// ── /loop wakeup restore after a restart ──
|
|
926
|
+
// The timer is in memory, so an exit (or an idle daemon worker being recycled at
|
|
927
|
+
// 30 min, against a wakeup that may be 3600s out) used to drop a pending wakeup
|
|
928
|
+
// without a word — the model went on believing a loop iteration was coming.
|
|
929
|
+
// A wakeup still in the future is re-armed from disk here; one that came due
|
|
930
|
+
// while we were gone is handed to the model as the loop turn it is, so IT decides
|
|
931
|
+
// whether to re-time or end it. Declared *after* the subscription above: the
|
|
932
|
+
// enqueue below only mutates the queue, and it is that subscription that turns
|
|
933
|
+
// the mutation into the state bump the idle-drain effect reacts to.
|
|
934
|
+
useEffect(() => {
|
|
935
|
+
if (!('hasPendingWakeup' in engine)) return
|
|
936
|
+
const qe = engine
|
|
937
|
+
// `?? ''` and not a guard: the ToolContext this app builds writes
|
|
938
|
+
// `sessionId: sessionId || ''`, so that is the key a wakeup from here was
|
|
939
|
+
// stored under — looking it up under anything else would miss our own file.
|
|
940
|
+
for (const lost of resumeWakeups({ sessionId: sessionId ?? '' })) {
|
|
941
|
+
qe.enqueueWakeup(missedWakeupNotice(lost), false)
|
|
942
|
+
}
|
|
943
|
+
}, [engine, sessionId])
|
|
944
|
+
|
|
904
945
|
// When a wakeup is enqueued and the engine is idle, drain it now (the running turn's
|
|
905
946
|
// end-drain handles the busy case). `wakeupTick === 0` skips the mount-time run.
|
|
906
947
|
useEffect(() => {
|
|
@@ -1303,7 +1344,7 @@ export function App({
|
|
|
1303
1344
|
) : (
|
|
1304
1345
|
<>
|
|
1305
1346
|
{/* Chat panel */}
|
|
1306
|
-
<ChatPanel messages={messages} focusMode={focusMode} />
|
|
1347
|
+
<ChatPanel messages={messages} focusMode={focusMode} turnActive={isLoading} />
|
|
1307
1348
|
{(() => {
|
|
1308
1349
|
const indicator = formatThinking(
|
|
1309
1350
|
config.showThinking ?? 'off',
|
package/src/ui/chat.tsx
CHANGED
|
@@ -8,6 +8,8 @@ import { homedir } from 'node:os'
|
|
|
8
8
|
interface ChatPanelProps {
|
|
9
9
|
messages: ChatMessage[]
|
|
10
10
|
focusMode?: boolean
|
|
11
|
+
/** A turn is in flight — the moment the focus tip is worth offering. */
|
|
12
|
+
turnActive?: boolean
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
/**
|
|
@@ -119,7 +121,7 @@ const MessageRow = React.memo(
|
|
|
119
121
|
prev.msg.toolMeta?.collapsed === next.msg.toolMeta?.collapsed,
|
|
120
122
|
)
|
|
121
123
|
|
|
122
|
-
export function ChatPanel({ messages, focusMode }: ChatPanelProps) {
|
|
124
|
+
export function ChatPanel({ messages, focusMode, turnActive }: ChatPanelProps) {
|
|
123
125
|
const { t } = useI18n()
|
|
124
126
|
// Memoize display message computation to avoid O(n) compact on every render.
|
|
125
127
|
// During streaming, messages changes on every chunk; without memoization,
|
|
@@ -140,6 +142,18 @@ export function ChatPanel({ messages, focusMode }: ChatPanelProps) {
|
|
|
140
142
|
</Text>
|
|
141
143
|
</Box>
|
|
142
144
|
)}
|
|
145
|
+
{/*
|
|
146
|
+
Offer focus while a turn is running — that is when the transcript grows
|
|
147
|
+
fastest and when someone is most likely to want it — rather than only
|
|
148
|
+
documenting it in the idle banner, where it is read before there is
|
|
149
|
+
anything to focus on. Shown only outside focus mode, and the text names
|
|
150
|
+
the way back so trying it cannot strand anyone.
|
|
151
|
+
*/}
|
|
152
|
+
{turnActive && !focusMode && messages.length > 0 && (
|
|
153
|
+
<Box marginBottom={1}>
|
|
154
|
+
<Text dimColor>{t('ui.chat.try_focus_tip')}</Text>
|
|
155
|
+
</Box>
|
|
156
|
+
)}
|
|
143
157
|
{messages.length === 0 && (
|
|
144
158
|
<Box flexDirection="column">
|
|
145
159
|
<Box marginBottom={1}>
|
package/src/ui/input.tsx
CHANGED
|
@@ -323,6 +323,11 @@ export function InputBar({
|
|
|
323
323
|
// 下面两个 ref 是**浏览游标**、不是历史本体,随卸载重置才是对的。
|
|
324
324
|
const historyIndexRef = useRef(-1) // -1 = not browsing history
|
|
325
325
|
const savedDraftRef = useRef('') // saved user draft before browsing history
|
|
326
|
+
// 被清空的草稿的**可恢复槽**:Escape 清空输入时落这里,下一次 Up(输入为空且未在
|
|
327
|
+
// 翻历史)把它放回去。仅靠 history 不够 —— 半途写了一半的行从没进过 history,
|
|
328
|
+
// 清掉就是没了。与 savedDraftRef 分开:那个槽的语义是「翻历史前的草稿」,会被
|
|
329
|
+
// Down 一路用掉,混用会让 Up 第一下就落到更早的历史条目上。
|
|
330
|
+
const clearedDraftRef = useRef('')
|
|
326
331
|
|
|
327
332
|
// ── Ghost-text 自动补全 ──
|
|
328
333
|
const [suggestion, setSuggestion] = useState<string | null>(null)
|
|
@@ -418,7 +423,9 @@ export function InputBar({
|
|
|
418
423
|
onCancel?.()
|
|
419
424
|
return
|
|
420
425
|
}
|
|
421
|
-
// Idle → clear the draft (the intuitive "cancel")
|
|
426
|
+
// Idle → clear the draft (the intuitive "cancel"), keeping it recoverable:
|
|
427
|
+
// Up from the now-empty input restores it (see the arrow-key branch).
|
|
428
|
+
if (valueRef.current) clearedDraftRef.current = valueRef.current
|
|
422
429
|
setValue('')
|
|
423
430
|
valueRef.current = ''
|
|
424
431
|
clearSuggestion()
|
|
@@ -469,6 +476,23 @@ export function InputBar({
|
|
|
469
476
|
// Ignore if picker is active (command picker handles its own arrows)
|
|
470
477
|
if (value.startsWith('/')) return
|
|
471
478
|
|
|
479
|
+
// A draft Escape cleared is still the user's text, and it is the *only*
|
|
480
|
+
// copy: unlike a sent message or a slash command it never entered history.
|
|
481
|
+
// Bring it back on the first Up from an empty input instead of walking into
|
|
482
|
+
// history, whose first step would land on an older entry and leave this
|
|
483
|
+
// text with nowhere to come back from.
|
|
484
|
+
if (
|
|
485
|
+
key.upArrow &&
|
|
486
|
+
historyIndexRef.current === -1 &&
|
|
487
|
+
valueRef.current === '' &&
|
|
488
|
+
clearedDraftRef.current
|
|
489
|
+
) {
|
|
490
|
+
const restored = clearedDraftRef.current
|
|
491
|
+
clearedDraftRef.current = ''
|
|
492
|
+
setValue(restored)
|
|
493
|
+
return
|
|
494
|
+
}
|
|
495
|
+
|
|
472
496
|
const result = navigateHistory(
|
|
473
497
|
{
|
|
474
498
|
history,
|
|
@@ -118,6 +118,7 @@ export async function workflowAgent(
|
|
|
118
118
|
const textResult = await sub.execute(retryPrompt, opts.label || 'workflow-agent', {
|
|
119
119
|
type: 'general',
|
|
120
120
|
modelOverride: opts.model,
|
|
121
|
+
effort: opts.effort,
|
|
121
122
|
allowedTools: undefined, // use all tools by default
|
|
122
123
|
worktreePath,
|
|
123
124
|
// The prompt is computed by the script, not typed by the user — say so,
|