strands-darwin 0.0.43 → 0.0.45
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 +4 -1
- package/README.zh-CN.md +4 -1
- package/dist/patches/ink+7.1.1.patch +15 -0
- package/dist/src/agent/context-breakdown.d.ts +26 -3
- package/dist/src/agent/context-breakdown.js +27 -1
- package/dist/src/agent/context-breakdown.js.map +1 -1
- package/dist/src/agent/goal-check.d.ts +35 -0
- package/dist/src/agent/goal-check.js +132 -0
- package/dist/src/agent/goal-check.js.map +1 -0
- package/dist/src/agent/model-retry.d.ts +6 -1
- package/dist/src/agent/model-retry.js +45 -9
- package/dist/src/agent/model-retry.js.map +1 -1
- package/dist/src/agent/permission-rules.d.ts +31 -13
- package/dist/src/agent/permission-rules.js +180 -20
- package/dist/src/agent/permission-rules.js.map +1 -1
- package/dist/src/agent/permission.d.ts +0 -6
- package/dist/src/agent/permission.js +4 -3
- package/dist/src/agent/permission.js.map +1 -1
- package/dist/src/agent/runtime.d.ts +9 -0
- package/dist/src/agent/runtime.js +39 -3
- package/dist/src/agent/runtime.js.map +1 -1
- package/dist/src/agent/safety-classifier.d.ts +3 -1
- package/dist/src/agent/safety-classifier.js +0 -0
- package/dist/src/agent/safety-classifier.js.map +1 -1
- package/dist/src/agent/working-context.d.ts +16 -0
- package/dist/src/agent/working-context.js +20 -0
- package/dist/src/agent/working-context.js.map +1 -1
- package/dist/src/cli-main.js +36 -1
- package/dist/src/cli-main.js.map +1 -1
- package/dist/src/cli-mcp.d.ts +12 -0
- package/dist/src/cli-mcp.js +111 -0
- package/dist/src/cli-mcp.js.map +1 -0
- package/dist/src/cli-usage.d.ts +1 -1
- package/dist/src/cli-usage.js +2 -0
- package/dist/src/cli-usage.js.map +1 -1
- package/dist/src/cli.js +4 -0
- package/dist/src/cli.js.map +1 -1
- package/dist/src/collaboration/command.js +1 -1
- package/dist/src/collaboration/command.js.map +1 -1
- package/dist/src/collaboration/hub-command.d.ts +7 -0
- package/dist/src/collaboration/hub-command.js +23 -0
- package/dist/src/collaboration/hub-command.js.map +1 -1
- package/dist/src/collaboration/local.d.ts +137 -6
- package/dist/src/collaboration/local.js +76 -19
- package/dist/src/collaboration/local.js.map +1 -1
- package/dist/src/collaboration/tools.js +1 -1
- package/dist/src/collaboration/tools.js.map +1 -1
- package/dist/src/commands/custom-commands.d.ts +1 -1
- package/dist/src/commands/custom-commands.js +3 -1
- package/dist/src/commands/custom-commands.js.map +1 -1
- package/dist/src/commands/goal-command.d.ts +26 -0
- package/dist/src/commands/goal-command.js +32 -0
- package/dist/src/commands/goal-command.js.map +1 -0
- package/dist/src/config.d.ts +15 -6
- package/dist/src/config.js +3 -0
- package/dist/src/config.js.map +1 -1
- package/dist/src/mcp/oauth-login.d.ts +37 -0
- package/dist/src/mcp/oauth-login.js +263 -0
- package/dist/src/mcp/oauth-login.js.map +1 -0
- package/dist/src/mcp/oauth-net.d.ts +50 -0
- package/dist/src/mcp/oauth-net.js +321 -0
- package/dist/src/mcp/oauth-net.js.map +1 -0
- package/dist/src/mcp/oauth-provider.d.ts +89 -0
- package/dist/src/mcp/oauth-provider.js +398 -0
- package/dist/src/mcp/oauth-provider.js.map +1 -0
- package/dist/src/mcp/oauth-store.d.ts +49 -0
- package/dist/src/mcp/oauth-store.js +176 -0
- package/dist/src/mcp/oauth-store.js.map +1 -0
- package/dist/src/mcp/registry.d.ts +6 -0
- package/dist/src/mcp/registry.js +83 -4
- package/dist/src/mcp/registry.js.map +1 -1
- package/dist/src/tools/shell-env.d.ts +27 -1
- package/dist/src/tools/shell-env.js +34 -5
- package/dist/src/tools/shell-env.js.map +1 -1
- package/dist/src/tui/App.d.ts +4 -1
- package/dist/src/tui/App.js +209 -10
- package/dist/src/tui/App.js.map +1 -1
- package/dist/src/tui/InputBox.d.ts +1 -1
- package/dist/src/tui/InputBox.js +1 -1
- package/dist/src/tui/context-format.d.ts +7 -3
- package/dist/src/tui/context-format.js +28 -3
- package/dist/src/tui/context-format.js.map +1 -1
- package/dist/src/tui/goal.d.ts +123 -0
- package/dist/src/tui/goal.js +187 -0
- package/dist/src/tui/goal.js.map +1 -0
- package/dist/src/tui/help-format.d.ts +1 -1
- package/dist/src/tui/help-format.js +1 -1
- package/dist/src/tui/mcp-format.js +5 -1
- package/dist/src/tui/mcp-format.js.map +1 -1
- package/dist/src/tui/prompt-editor.d.ts +4 -3
- package/dist/src/tui/prompt-editor.js +8 -3
- package/dist/src/tui/prompt-editor.js.map +1 -1
- package/dist/src/update-check.d.ts +45 -0
- package/dist/src/update-check.js +184 -0
- package/dist/src/update-check.js.map +1 -0
- package/dist/src/version.d.ts +6 -0
- package/dist/src/version.js +13 -5
- package/dist/src/version.js.map +1 -1
- package/package.json +1 -1
package/dist/src/tui/App.js
CHANGED
|
@@ -57,7 +57,7 @@ import { PermissionRulePreview, ruleReviewClaim, ruleReviewLayout } from './perm
|
|
|
57
57
|
import { welcomeLayout } from './WelcomeHeader.js';
|
|
58
58
|
import { ActiveToolCalls } from './ToolCallPanel.js';
|
|
59
59
|
import { QueuedMessages } from './QueuedMessages.js';
|
|
60
|
-
import { backspaceAtCursor, deleteAtCursor, deleteWordAfter, deleteWordBefore, insertAtCursor, killToRowEdge, layoutEditor, moveHorizontal, moveToRowEdge, moveVertical, moveWordHorizontal, popUndo, pushUndo, updateLastCut, LAST_CUT_OVERFLOW_NOTICE, } from './prompt-editor.js';
|
|
60
|
+
import { backspaceAtCursor, deleteAtCursor, deleteWordAfter, deleteWordBefore, insertAtCursor, killToRowEdge, layoutEditor, moveHorizontal, moveToDraftEdge, moveToRowEdge, moveVertical, moveWordHorizontal, popUndo, pushUndo, updateLastCut, LAST_CUT_OVERFLOW_NOTICE, } from './prompt-editor.js';
|
|
61
61
|
import { NO_WORKSPACE_PATHS, applyPathCompletion, scanWorkspacePaths, workspacePathsNote, } from './path-completion.js';
|
|
62
62
|
import { promptCompletionState, visiblePromptCompletions, } from './prompt-completion.js';
|
|
63
63
|
import { openPromptRecall, promptRecallIndicator, stepPromptRecall, } from './prompt-recall.js';
|
|
@@ -67,6 +67,9 @@ import { TANGENT_COMMAND_USAGE, armTangent, captureReturnPoint, discardedPromptC
|
|
|
67
67
|
import { clipboardImageFact, readClipboardImage } from './clipboard-image.js';
|
|
68
68
|
import { DRAFT_STASH_DROP_NOTICE, stashHint, toggleDraftStash } from './draft-stash.js';
|
|
69
69
|
import { delegationWakeEntries, hasQueuedImage, isTaskWake, partitionQueue, queuedCountHint, refusesToQueue, takeBackDraft, } from './prompt-queue.js';
|
|
70
|
+
import { GOAL_CONDITION_MAX_CODE_POINTS, parseGoalCommand } from '../commands/goal-command.js';
|
|
71
|
+
import { boundedReason } from '../agent/goal-check.js';
|
|
72
|
+
import { GOAL_SET_NOTICE, composeGoalEvidence, goalAction, goalAfterCheck, goalAfterTurn, goalBeforeTurn, goalContinuationPrompt, goalContinued, goalLiveSuffix, goalStatusText, newGoal, } from './goal.js';
|
|
70
73
|
import { composeShellReport, parseShellCommand, projectShellOutput, runShellCommand, } from './shell-command.js';
|
|
71
74
|
import { formatTaskCompletion, formatTasksReport, runningTasksHeader } from './task-format.js';
|
|
72
75
|
import { TASK_WAKE_TAIL_LINES, formatTaskNotification, formatTaskWakeUndelivered, taskNotificationFields, } from './task-wake.js';
|
|
@@ -299,6 +302,24 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
299
302
|
queuedRef.current = next;
|
|
300
303
|
setQueuedState(next);
|
|
301
304
|
}, []);
|
|
305
|
+
/**
|
|
306
|
+
* The `/goal` loop's state (SER-108), with the same immediate-mirror ref the queue has:
|
|
307
|
+
* effects and the turn tail must read one generation. Live-session state only — never
|
|
308
|
+
* persisted, dropped by `/clear`.
|
|
309
|
+
*/
|
|
310
|
+
const [goal, setGoalState] = useState(undefined);
|
|
311
|
+
const goalRef = useRef(undefined);
|
|
312
|
+
const setGoal = useCallback((next) => {
|
|
313
|
+
goalRef.current = next;
|
|
314
|
+
setGoalState(next);
|
|
315
|
+
}, []);
|
|
316
|
+
/** Set while the goal's own continuation is being submitted; read once at the turn's start. */
|
|
317
|
+
const goalTurnPending = useRef(false);
|
|
318
|
+
/** The in-flight condition check's controller; Ctrl+C aborts only this, never the agent. */
|
|
319
|
+
const goalCheckAbort = useRef(undefined);
|
|
320
|
+
/** What the current turn showed the driver: the bounded record the check reads. */
|
|
321
|
+
const goalAnswers = useRef([]);
|
|
322
|
+
const goalTools = useRef([]);
|
|
302
323
|
/** True from a user Ctrl+C (or a turn failure) until the busy state it aborted ends. */
|
|
303
324
|
const turnAborted = useRef(false);
|
|
304
325
|
/** Latch: one queue entry in flight through submit(); see the drain effect. */
|
|
@@ -598,7 +619,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
598
619
|
: undefined;
|
|
599
620
|
const busyRetryWait = busyElapsedMs === undefined ? undefined : liveRetryWait(runtime);
|
|
600
621
|
const queuedCounts = partitionQueue(queued);
|
|
601
|
-
const statusHint = hintForStatus(effectiveStatus, busyElapsedMs === undefined ? undefined : busySuffix(busyElapsedMs, liveSpend(runtime), busyRetryWait), queuedCounts.user.length, queuedCounts.wakes.length);
|
|
622
|
+
const statusHint = hintForStatus(effectiveStatus, busyElapsedMs === undefined ? undefined : busySuffix(busyElapsedMs, liveSpend(runtime), busyRetryWait), queuedCounts.user.length, queuedCounts.wakes.length, goalLiveSuffix(goal));
|
|
602
623
|
const streamingHint = statusHint === undefined ? undefined : stashHint(statusHint, draftStash !== undefined, columns);
|
|
603
624
|
const activeToolClaims = state.activeTools.map((tool) => ({
|
|
604
625
|
detailRows: toolDetailsVisible(tool.name, state.toolDetailsExpanded)
|
|
@@ -864,15 +885,47 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
864
885
|
}
|
|
865
886
|
return true;
|
|
866
887
|
}, [dispatch, setAttachedImage, setEditor, setQueued]);
|
|
888
|
+
/** Applies a `/goal` transition: the new state, then its one transcript notice. */
|
|
889
|
+
const applyGoalTransition = useCallback((transition) => {
|
|
890
|
+
setGoal(transition.goal);
|
|
891
|
+
if (transition.notice !== undefined) {
|
|
892
|
+
dispatch({
|
|
893
|
+
type: 'notice',
|
|
894
|
+
text: transition.notice.text,
|
|
895
|
+
...(transition.notice.severity === undefined ? {} : { severity: transition.notice.severity }),
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
}, [dispatch, setGoal]);
|
|
867
899
|
const runTurn = useCallback(async (text, userInput = text, image, origin) => {
|
|
868
900
|
turnStartedAt.current = Date.now();
|
|
869
901
|
turnAborted.current = false;
|
|
902
|
+
// Who started this turn, decided once at its start (SER-108): the goal's own
|
|
903
|
+
// continuation, the session itself (task/delegation wake, peer), or the user.
|
|
904
|
+
const goalKind = origin !== undefined ? 'session' : goalTurnPending.current ? 'goal' : 'user';
|
|
905
|
+
goalTurnPending.current = false;
|
|
906
|
+
goalAnswers.current = [];
|
|
907
|
+
goalTools.current = [];
|
|
908
|
+
if (goalRef.current !== undefined)
|
|
909
|
+
setGoal(goalBeforeTurn(goalRef.current, goalKind));
|
|
870
910
|
let lifecycleOutcome = 'success';
|
|
871
911
|
setStatus('streaming');
|
|
872
912
|
try {
|
|
873
913
|
await runWithStreamResumption(text, async (turnInput) => {
|
|
874
914
|
let answerTailLive = false;
|
|
875
915
|
for await (const event of runtime.send(turnInput, userInput, turnInput === text ? image : undefined, origin)) {
|
|
916
|
+
// The bounded record a `/goal` check may read: observed, never re-read.
|
|
917
|
+
if (goalRef.current !== undefined) {
|
|
918
|
+
if (event.type === 'contentBlockEvent' && event.contentBlock.type === 'textBlock') {
|
|
919
|
+
goalAnswers.current.push(event.contentBlock.text);
|
|
920
|
+
if (goalAnswers.current.length > 64)
|
|
921
|
+
goalAnswers.current.shift();
|
|
922
|
+
}
|
|
923
|
+
else if (event.type === 'afterToolCallEvent') {
|
|
924
|
+
goalTools.current.push({ name: event.toolUse.name, status: event.result.status });
|
|
925
|
+
if (goalTools.current.length > 200)
|
|
926
|
+
goalTools.current.shift();
|
|
927
|
+
}
|
|
928
|
+
}
|
|
876
929
|
if (event.type === 'modelStreamUpdateEvent' &&
|
|
877
930
|
event.event.type === 'modelContentBlockDeltaEvent' &&
|
|
878
931
|
event.event.delta.type === 'textDelta' &&
|
|
@@ -1040,8 +1093,16 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1040
1093
|
for (const problem of runtime.takeHookProblems()) {
|
|
1041
1094
|
dispatch({ type: 'notice', text: `hook: ${problem}`, severity: 'warn' });
|
|
1042
1095
|
}
|
|
1096
|
+
// The `/goal` loop's turn tail (SER-108), last on purpose: every notice this turn
|
|
1097
|
+
// owes has been written before the goal may owe a check. Completed turns owe one
|
|
1098
|
+
// check at the next idle moment; a cancelled or failed one owes nothing, and
|
|
1099
|
+
// cancelled or failed goal-owned work clears the goal.
|
|
1100
|
+
const goalNow = goalRef.current;
|
|
1101
|
+
if (goalNow !== undefined) {
|
|
1102
|
+
applyGoalTransition(goalAfterTurn(goalNow, goalKind, !failed ? 'completed' : lifecycleOutcome === 'cancelled' ? 'cancelled' : 'failed'));
|
|
1103
|
+
}
|
|
1043
1104
|
return !failed;
|
|
1044
|
-
}, [prepareAnswerClose, returnQueuedToEditor, runtime, setTangent, waitUntilRenderFlush]);
|
|
1105
|
+
}, [applyGoalTransition, prepareAnswerClose, returnQueuedToEditor, runtime, setGoal, setTangent, waitUntilRenderFlush]);
|
|
1045
1106
|
const submit = useCallback(async (raw, queuedEntry) => {
|
|
1046
1107
|
const text = raw.trim();
|
|
1047
1108
|
if (clearing.current) {
|
|
@@ -1151,6 +1212,52 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1151
1212
|
applyModeCommand(runtime, text, dispatch);
|
|
1152
1213
|
return;
|
|
1153
1214
|
}
|
|
1215
|
+
// `/goal` (SER-108), before the busy check for the reason `/mode` is: mid-loop is
|
|
1216
|
+
// exactly when a goal needs replacing or switching off, and none of it sends
|
|
1217
|
+
// anything. Setting a goal spends nothing — the first check runs after the next
|
|
1218
|
+
// completed turn. `/goal off` never interrupts running work (Ctrl+C does that); it
|
|
1219
|
+
// withdraws the check in flight, if any, and stops every later continuation.
|
|
1220
|
+
const goalCommand = parseGoalCommand(text);
|
|
1221
|
+
if (goalCommand !== undefined) {
|
|
1222
|
+
setEditor({ text: '', cursor: { offset: 0, affinity: 'downstream' } });
|
|
1223
|
+
setSelectedCompletion(0);
|
|
1224
|
+
dispatch({ type: 'userInput', text });
|
|
1225
|
+
if (goalCommand.kind === 'status') {
|
|
1226
|
+
dispatch({ type: 'notice', text: goalStatusText(goalRef.current) });
|
|
1227
|
+
}
|
|
1228
|
+
else if (goalCommand.kind === 'too-long') {
|
|
1229
|
+
dispatch({
|
|
1230
|
+
type: 'notice',
|
|
1231
|
+
text: `goal condition is ${goalCommand.length} code points; the limit is ${GOAL_CONDITION_MAX_CODE_POINTS} — goal unchanged`,
|
|
1232
|
+
severity: 'warn',
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
else if (goalCommand.kind === 'off') {
|
|
1236
|
+
if (goalRef.current === undefined) {
|
|
1237
|
+
dispatch({ type: 'notice', text: 'no goal to clear' });
|
|
1238
|
+
}
|
|
1239
|
+
else {
|
|
1240
|
+
const checkInFlight = goalCheckAbort.current;
|
|
1241
|
+
checkInFlight?.abort();
|
|
1242
|
+
setGoal(undefined);
|
|
1243
|
+
dispatch({
|
|
1244
|
+
type: 'notice',
|
|
1245
|
+
text: checkInFlight !== undefined
|
|
1246
|
+
? 'goal cleared — the check in flight was cancelled'
|
|
1247
|
+
: status !== 'idle'
|
|
1248
|
+
? 'goal cleared — the running work is not interrupted (ctrl+c cancels it)'
|
|
1249
|
+
: 'goal cleared',
|
|
1250
|
+
});
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
else {
|
|
1254
|
+
const replaced = goalRef.current !== undefined;
|
|
1255
|
+
goalCheckAbort.current?.abort();
|
|
1256
|
+
setGoal(newGoal(goalCommand.condition));
|
|
1257
|
+
dispatch({ type: 'notice', text: GOAL_SET_NOTICE(goalCommand.condition, replaced) });
|
|
1258
|
+
}
|
|
1259
|
+
return;
|
|
1260
|
+
}
|
|
1154
1261
|
// Before the busy check for the same reason as /mode: revocation only ever
|
|
1155
1262
|
// *narrows* what runs silently, and mid-turn is exactly when a rule that
|
|
1156
1263
|
// turned out too broad needs pulling — the gate stops honouring it before
|
|
@@ -1734,6 +1841,11 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1734
1841
|
setQueued([]);
|
|
1735
1842
|
clipboardReadGeneration.current += 1;
|
|
1736
1843
|
setAttachedImage(undefined);
|
|
1844
|
+
// The goal (SER-108) was about the conversation just set aside; it dies with it.
|
|
1845
|
+
// `/clear` is idle-only, so no check is in flight; a continuation owed is dropped.
|
|
1846
|
+
const droppedGoal = goalRef.current;
|
|
1847
|
+
setGoal(undefined);
|
|
1848
|
+
goalTurnPending.current = false;
|
|
1737
1849
|
// Mirrored to the *successor's* diagnostics log: the memoized `dispatch` still
|
|
1738
1850
|
// points at the predecessor's, which this switch has just closed.
|
|
1739
1851
|
withNoticeDiagnostics(recordAction, next.diagnostics)({
|
|
@@ -1741,6 +1853,12 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1741
1853
|
text: `cleared — new session ${next.info.sessionId}. Previous session ${previousSessionId} is saved and ` +
|
|
1742
1854
|
`resumable (darwin --session ${previousSessionId}); background jobs and MCP servers keep running.`,
|
|
1743
1855
|
});
|
|
1856
|
+
if (droppedGoal !== undefined) {
|
|
1857
|
+
withNoticeDiagnostics(recordAction, next.diagnostics)({
|
|
1858
|
+
type: 'notice',
|
|
1859
|
+
text: `goal dropped with the cleared conversation: ${droppedGoal.condition}`,
|
|
1860
|
+
});
|
|
1861
|
+
}
|
|
1744
1862
|
// The tangent bookmarked a conversation this session no longer holds
|
|
1745
1863
|
// (SER-083): it ends with one notice, and no rewind is performed for it.
|
|
1746
1864
|
if (tangentRef.current !== undefined) {
|
|
@@ -1877,7 +1995,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1877
1995
|
severity: 'warn',
|
|
1878
1996
|
});
|
|
1879
1997
|
}
|
|
1880
|
-
}, [adoptBranchSuccessor, dispatch, exit, openRewindChooser, recordAction, returnQueuedToEditor, runtime, runTurn, setAttachedImage, setDraftStash, setEditor, setQueued, setTangent, startNewSession, startRewind, status, writeToTerminal]);
|
|
1998
|
+
}, [adoptBranchSuccessor, dispatch, exit, openRewindChooser, recordAction, returnQueuedToEditor, runtime, runTurn, setAttachedImage, setDraftStash, setEditor, setGoal, setQueued, setTangent, startNewSession, startRewind, status, writeToTerminal]);
|
|
1881
1999
|
// The drain (SER-027): when the session is idle and nothing owns the keyboard,
|
|
1882
2000
|
// the oldest queued entry goes back through the ordinary submit path — its own
|
|
1883
2001
|
// turn for a prompt, its own run for a `!`, its own `userInput` recorded at
|
|
@@ -1950,6 +2068,77 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1950
2068
|
dispatch({ type: 'notice', severity: 'warn', text: `peer message ${peer.envelope.id} failed/cancelled; not re-sent` });
|
|
1951
2069
|
}).finally(() => { draining.current = false; setDrainCycle(cycle => cycle + 1); });
|
|
1952
2070
|
}, [peerCycle, drainCycle, pendingPermission, queued, runtime, runTurn, status, dispatch]);
|
|
2071
|
+
// The `/goal` loop (SER-108): the lowest-priority owner of an idle session. It is asked
|
|
2072
|
+
// in the same commits as the two effects above and declared after them, so anything
|
|
2073
|
+
// they take — a queued prompt, `!`, task/delegation wake, peer message — sets the
|
|
2074
|
+
// shared `draining` latch first and the goal simply waits for the next idle moment.
|
|
2075
|
+
// `goalAction` is the whole gate (idle, no permission decision, no `/clear`, empty queue,
|
|
2076
|
+
// empty peer inbox); a pending permission prompt therefore holds both the check and the
|
|
2077
|
+
// continuation exactly as it holds the queue.
|
|
2078
|
+
//
|
|
2079
|
+
// `check`: one bounded model call outside the agent loop, with the session held busy so
|
|
2080
|
+
// submissions queue behind it and Ctrl+C reaches it (`goalCheckAbort`). `continue`:
|
|
2081
|
+
// exactly one prompt through the ordinary `submit()`, as a drained entry — it never
|
|
2082
|
+
// touches the draft or an attached image, and it counts against the cap at dispatch.
|
|
2083
|
+
useEffect(() => {
|
|
2084
|
+
const current = goalRef.current;
|
|
2085
|
+
const action = goalAction(current, {
|
|
2086
|
+
idle: status === 'idle',
|
|
2087
|
+
permissionPending: pendingPermission !== undefined,
|
|
2088
|
+
clearing: clearing.current,
|
|
2089
|
+
draining: draining.current,
|
|
2090
|
+
queued: queuedRef.current.length,
|
|
2091
|
+
peerPending: runtime.collaboration?.pending ?? 0,
|
|
2092
|
+
});
|
|
2093
|
+
if (current === undefined || action === 'none')
|
|
2094
|
+
return;
|
|
2095
|
+
draining.current = true;
|
|
2096
|
+
if (action === 'continue') {
|
|
2097
|
+
const prompt = goalContinuationPrompt(current.condition, current.note ?? '(no note)');
|
|
2098
|
+
setGoal(goalContinued(current));
|
|
2099
|
+
goalTurnPending.current = true;
|
|
2100
|
+
void submit(prompt, { text: prompt }).finally(() => {
|
|
2101
|
+
goalTurnPending.current = false;
|
|
2102
|
+
draining.current = false;
|
|
2103
|
+
setDrainCycle((cycle) => cycle + 1);
|
|
2104
|
+
});
|
|
2105
|
+
return;
|
|
2106
|
+
}
|
|
2107
|
+
const checking = { ...current, phase: 'checking' };
|
|
2108
|
+
setGoal(checking);
|
|
2109
|
+
const controller = new AbortController();
|
|
2110
|
+
goalCheckAbort.current = controller;
|
|
2111
|
+
turnAborted.current = false;
|
|
2112
|
+
turnStartedAt.current = Date.now();
|
|
2113
|
+
setStatus('streaming');
|
|
2114
|
+
void (async () => {
|
|
2115
|
+
let result;
|
|
2116
|
+
try {
|
|
2117
|
+
const verdict = await runtime.checkGoal(current.condition, composeGoalEvidence(goalAnswers.current, goalTools.current), controller.signal);
|
|
2118
|
+
result = { kind: 'verdict', ...verdict };
|
|
2119
|
+
}
|
|
2120
|
+
catch (error) {
|
|
2121
|
+
result = controller.signal.aborted
|
|
2122
|
+
? { kind: 'cancelled' }
|
|
2123
|
+
: { kind: 'error', message: boundedReason(error instanceof Error ? error.message : String(error)) };
|
|
2124
|
+
}
|
|
2125
|
+
goalCheckAbort.current = undefined;
|
|
2126
|
+
turnStartedAt.current = undefined;
|
|
2127
|
+
setStatus('idle');
|
|
2128
|
+
// A goal replaced or switched off while the check ran already said so; its result
|
|
2129
|
+
// belongs to nothing now and is dropped. A user Ctrl+C left the state as it was.
|
|
2130
|
+
if (goalRef.current === checking)
|
|
2131
|
+
applyGoalTransition(goalAfterCheck(checking, result));
|
|
2132
|
+
// A cancelled check never silently sends the queue (SER-027), like a cancelled turn.
|
|
2133
|
+
if (turnAborted.current) {
|
|
2134
|
+
turnAborted.current = false;
|
|
2135
|
+
returnQueuedToEditor(true);
|
|
2136
|
+
}
|
|
2137
|
+
})().finally(() => {
|
|
2138
|
+
draining.current = false;
|
|
2139
|
+
setDrainCycle((cycle) => cycle + 1);
|
|
2140
|
+
});
|
|
2141
|
+
}, [applyGoalTransition, drainCycle, goal, peerCycle, pendingPermission, queued, returnQueuedToEditor, runtime, setGoal, status, submit]);
|
|
1953
2142
|
/**
|
|
1954
2143
|
* Answers the pending confirmation and, when the user picked an "always allow"
|
|
1955
2144
|
* option, remembers the rule.
|
|
@@ -2291,6 +2480,14 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
2291
2480
|
// be able to ask for approval. The abort mark is what keeps the queue from
|
|
2292
2481
|
// being silently sent when the cancelled turn winds down (SER-027).
|
|
2293
2482
|
turnAborted.current = true;
|
|
2483
|
+
// The goal's condition check (SER-108) is a busy state with no agent turn behind it:
|
|
2484
|
+
// Ctrl+C aborts exactly that call. The runtime's cancel would also close the peer
|
|
2485
|
+
// inbox for a turn that does not exist.
|
|
2486
|
+
if (goalCheckAbort.current !== undefined) {
|
|
2487
|
+
goalCheckAbort.current.abort();
|
|
2488
|
+
dispatch({ type: 'notice', text: 'interrupted — press ctrl+c again to exit' });
|
|
2489
|
+
return;
|
|
2490
|
+
}
|
|
2294
2491
|
permissions.denyPending();
|
|
2295
2492
|
runtime.cancel();
|
|
2296
2493
|
dispatch({ type: 'notice', text: 'interrupted — press ctrl+c again to exit' });
|
|
@@ -2641,7 +2838,9 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
2641
2838
|
if (key.home || key.end) {
|
|
2642
2839
|
setEditor((current) => ({
|
|
2643
2840
|
...current,
|
|
2644
|
-
cursor:
|
|
2841
|
+
cursor: key.ctrl
|
|
2842
|
+
? moveToDraftEdge(current.text, key.home ? 'start' : 'end')
|
|
2843
|
+
: moveToRowEdge(layoutEditor(current.text, columns, current.cursor), key.home ? 'start' : 'end'),
|
|
2645
2844
|
}));
|
|
2646
2845
|
preferredColumn.current = undefined;
|
|
2647
2846
|
return;
|
|
@@ -2713,17 +2912,17 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
2713
2912
|
setSelectedCompletion(0);
|
|
2714
2913
|
endRecall();
|
|
2715
2914
|
});
|
|
2716
|
-
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(
|
|
2915
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(MessageList, { history: state.history, ...(state.staticEpoch === 0 ? { welcome: initialWelcome } : {}), liveText: state.liveText, liveCodeOpen: fenceOpenAfter(state.committedAnswer), columns: columns, maxLiveRows: grants.live, staticEpoch: state.staticEpoch }), _jsx(Box, { ref: headerRef, flexDirection: "column", children: _jsx(Header, { runtime: runtime, status: effectiveStatus, frame: frame, tangent: tangent, goal: goal, runningTaskCount: runningTaskCount, draftStashed: statusHint === undefined && draftStash !== undefined }) }), _jsxs(Box, { ref: chromeRef, flexDirection: "column", children: [state.thinking && effectiveStatus === 'streaming' && (_jsx(Text, { dimColor: true, wrap: "truncate-end", children: `thinking…${busyElapsedMs === undefined ? '' : busySuffix(busyElapsedMs, undefined, busyRetryWait)}` })), _jsx(ActiveToolCalls, { tools: state.activeTools, frame: frame, toolDetailsExpanded: state.toolDetailsExpanded, columns: columns, maxRows: grants.tools }), _jsx(PlanChecklist, { plan: state.livePlan, maxRows: grants.plan }), _jsx(QueuedMessages, { entries: queued, maxRows: grants.queued }), activeRuleReview !== undefined ? _jsx(PermissionRulePreview, { review: activeRuleReview }) : pendingPermission !== undefined ? (_jsx(PermissionPrompt, { request: pendingPermission, waiting: permissions.waiting, columns: columns, maxRows: grants.prompt })) : (_jsx(InputBox, { layout: layout, completions: completions, completionKind: completionKind, completionNote: completionNote, selectedCompletion: selectedCompletion, editable: effectiveStatus !== 'compacting', offset: { top: chrome.top, left: chrome.left }, maxRows: grants.prompt, hint: streamingHint, attachment: attachedImage === undefined ? undefined : clipboardImageFact(attachedImage), recallIndicator: recallIndicator, historySearch: historySearchProjection, rewindSearch: rewindSearchProjection }))] })] }));
|
|
2717
2916
|
}
|
|
2718
2917
|
/** The hint row under the draft, or nothing when the session is idle. */
|
|
2719
|
-
function hintForStatus(status, busyReadout, queuedCount = 0, queuedWakeCount = 0) {
|
|
2918
|
+
function hintForStatus(status, busyReadout, queuedCount = 0, queuedWakeCount = 0, goalSuffix = '') {
|
|
2720
2919
|
if (status === 'streaming') {
|
|
2721
2920
|
// The live readout rides directly behind `working…`, ahead of the static command
|
|
2722
2921
|
// hints: the row is one truncated <Text>, so on a narrow terminal the tail is what
|
|
2723
2922
|
// goes missing, and the tail should be the part that never changes. The queue
|
|
2724
2923
|
// count (SER-027) rides with it: even a listing cut to nothing stays counted here,
|
|
2725
2924
|
// typed entries and background-task wakes (SER-069) each under their own word.
|
|
2726
|
-
return `working…${busyReadout ?? ''}${queuedCountHint(queuedCount, queuedWakeCount)} /tasks lists jobs · /agents lists dispatches · /usage reports tokens · ctrl+c cancels this turn`;
|
|
2925
|
+
return `working…${busyReadout ?? ''}${goalSuffix}${queuedCountHint(queuedCount, queuedWakeCount)} /tasks lists jobs · /agents lists dispatches · /usage reports tokens · ctrl+c cancels this turn`;
|
|
2727
2926
|
}
|
|
2728
2927
|
// Elapsed lives on the command's own panel row, so this row can stay static.
|
|
2729
2928
|
if (status === 'shell')
|
|
@@ -2762,7 +2961,7 @@ function lastRetryOutcome(runtime) {
|
|
|
2762
2961
|
return undefined;
|
|
2763
2962
|
}
|
|
2764
2963
|
}
|
|
2765
|
-
export function Header({ runtime, status = 'idle', frame = 0, tangent, runningTaskCount = 0, draftStashed = false, }) {
|
|
2964
|
+
export function Header({ runtime, status = 'idle', frame = 0, tangent, goal, runningTaskCount = 0, draftStashed = false, }) {
|
|
2766
2965
|
const { columns } = useWindowSize();
|
|
2767
2966
|
const info = runtime.info;
|
|
2768
2967
|
const instructions = info.projectInstructions;
|
|
@@ -2771,7 +2970,7 @@ export function Header({ runtime, status = 'idle', frame = 0, tangent, runningTa
|
|
|
2771
2970
|
// place the effective mode is stated, and it must not gain a second one.
|
|
2772
2971
|
const mode = runtime.permissionMode;
|
|
2773
2972
|
const stateLabel = status === 'streaming' ? 'working' : headerStatus(status);
|
|
2774
|
-
const tangentSuffix = tangentHeaderSuffix(tangent);
|
|
2973
|
+
const tangentSuffix = tangentHeaderSuffix(tangent) + goalLiveSuffix(goal);
|
|
2775
2974
|
const activity = runningTasksHeader(runningTaskCount, columns - `◆ DARWIN · ${stateLabel}${tangentSuffix}`.length, frame);
|
|
2776
2975
|
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Text, { wrap: "truncate-end", children: [_jsxs(Text, { color: visualColor.identity, bold: true, children: [visualMarker.identity, " DARWIN"] }), _jsxs(Text, { dimColor: true, children: [' · ', status === 'streaming' ? _jsx(WorkingStatus, { frame: frame }) : headerStatus(status), tangentSuffix] }), _jsx(Text, { color: visualColor.active, children: activity.label }), _jsx(Text, { dimColor: true, children: activity.hint })] }), _jsxs(Text, { dimColor: true, children: [runtime.config.provider, "/", runtime.config.model, " \u00B7 session ", info.sessionId, info.resumed ? ' (resumed)' : '', formatPromptCache(runtime.promptCache), formatThinking(runtime.thinking)] }), mode === 'yolo' ? (_jsxs(Text, { color: visualColor.warning, children: ["mode: ", describeMode(mode, runtime.allowRuleCount, runtime.denyRuleCount)] })) : mode === 'plan' ? (_jsxs(Text, { color: visualColor.warning, children: ["mode: ", describeMode(mode, runtime.allowRuleCount, runtime.denyRuleCount)] })) : (_jsxs(Text, { dimColor: true, children: ["mode: ", describeMode(mode, runtime.allowRuleCount, runtime.denyRuleCount)] })), instructions !== undefined &&
|
|
2777
2976
|
(instructions.truncated ? (_jsx(Text, { color: visualColor.warning, children: formatInstructionsLoadedRow(instructions) })) : (_jsx(Text, { dimColor: true, children: formatInstructionsLoadedRow(instructions) }))), info.projectInstructionsProblem !== undefined && (_jsx(Text, { color: visualColor.warning, children: formatInstructionsProblemRow(info.projectInstructionsProblemFile ?? AGENTS_FILENAME, info.projectInstructionsProblem) })), info.systemPromptSource === 'config' && (_jsxs(Text, { dimColor: true, children: ["system prompt: overridden by ", DARWIN_DIRNAME, "/", CONFIG_FILENAME] })), info.systemPromptSource === 'file' && (_jsxs(Text, { dimColor: true, children: ["system prompt: ", DARWIN_DIRNAME, "/", SYSTEM_PROMPT_FILENAME] })), info.systemPromptProblem !== undefined && (_jsxs(Text, { color: visualColor.warning, children: ["system prompt: using the default \u2014 ", info.systemPromptProblem] })), info.workingContextProblem !== undefined && (_jsxs(Text, { color: visualColor.warning, children: ["working context: no directory listing \u2014 ", info.workingContextProblem] })), info.promptCache.problem !== undefined && (_jsxs(Text, { color: visualColor.warning, children: ["prompt cache: off \u2014 ", info.promptCache.problem] })), runtime.thinking.problem !== undefined && (_jsxs(Text, { color: visualColor.warning, children: ["thinking: ", runtime.thinking.problem] })), hasCapabilities(info) && (_jsxs(Text, { dimColor: true, children: ["loaded: ", formatCapabilities(info), " \u00B7 type / for commands"] })), info.mcpIgnoredConfigPath !== undefined && (_jsxs(Text, { color: visualColor.warning, children: ["mcp: using ", DARWIN_DIRNAME, "/", MCP_CONFIG_FILENAME, " \u2014 ", info.mcpIgnoredConfigPath, " ignored"] })), info.hookShadowNotices.map((notice) => (_jsxs(Text, { color: visualColor.warning, wrap: "truncate-end", children: ["hooks: ", notice.layer, " ", notice.directory, " shadows ", notice.shadowed.join(', ')] }, notice.directory))), info.skillProblems.map((problem) => (_jsxs(Text, { color: visualColor.warning, children: ["skill skipped: ", problem.directory, " \u2014 ", problem.reason] }, problem.directory))), info.commandProblems.map((problem) => (_jsxs(Text, { color: visualColor.warning, children: ["command skipped: ", problem.file, " \u2014 ", problem.reason] }, problem.file))), info.agentProblems.map((problem) => (_jsxs(Text, { color: visualColor.warning, children: ["agent skipped: ", problem.file, " \u2014 ", problem.reason] }, problem.file))), _jsx(Text, { dimColor: true, children: stashHint('/ for actions · @ for paths · ctrl+c cancels · /exit quits', draftStashed, columns) })] }));
|