strands-darwin 0.0.36 → 0.0.39
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 +19 -4
- package/README.zh-CN.md +14 -4
- package/dist/patches/{@strands-agents+sdk+1.16.0.patch → @strands-agents+sdk+1.18.0.patch} +320 -9
- package/dist/src/agent/compact.js +1 -1
- package/dist/src/agent/permission-rules.js +1 -1
- package/dist/src/agent/permission-rules.js.map +1 -1
- package/dist/src/agent/permission.d.ts +4 -1
- package/dist/src/agent/permission.js +21 -4
- package/dist/src/agent/permission.js.map +1 -1
- package/dist/src/agent/runtime.d.ts +23 -12
- package/dist/src/agent/runtime.js +72 -16
- package/dist/src/agent/runtime.js.map +1 -1
- package/dist/src/agent/session-lease.d.ts +31 -0
- package/dist/src/agent/session-lease.js +42 -0
- package/dist/src/agent/session-lease.js.map +1 -0
- package/dist/src/agent/session.d.ts +2 -47
- package/dist/src/agent/session.js +3 -50
- package/dist/src/agent/session.js.map +1 -1
- package/dist/src/agent/system-prompt.d.ts +1 -1
- package/dist/src/agent/system-prompt.js +12 -0
- package/dist/src/agent/system-prompt.js.map +1 -1
- package/dist/src/agent/task-terminal-delivery.d.ts +25 -2
- package/dist/src/agent/task-terminal-delivery.js +80 -7
- package/dist/src/agent/task-terminal-delivery.js.map +1 -1
- package/dist/src/cli-list-agents.d.ts +1 -0
- package/dist/src/cli-list-agents.js +12 -0
- package/dist/src/cli-list-agents.js.map +1 -0
- package/dist/src/cli-usage.d.ts +1 -1
- package/dist/src/cli-usage.js +5 -0
- package/dist/src/cli-usage.js.map +1 -1
- package/dist/src/cli.js +9 -1
- package/dist/src/cli.js.map +1 -1
- package/dist/src/collaboration/command.d.ts +5 -0
- package/dist/src/collaboration/command.js +72 -0
- package/dist/src/collaboration/command.js.map +1 -0
- package/dist/src/collaboration/grammar.d.ts +3 -0
- package/dist/src/collaboration/grammar.js +8 -0
- package/dist/src/collaboration/grammar.js.map +1 -0
- package/dist/src/collaboration/local.d.ts +61 -0
- package/dist/src/collaboration/local.js +407 -0
- package/dist/src/collaboration/local.js.map +1 -0
- package/dist/src/collaboration/protocol.d.ts +66 -0
- package/dist/src/collaboration/protocol.js +28 -0
- package/dist/src/collaboration/protocol.js.map +1 -0
- package/dist/src/collaboration/storage.d.ts +36 -0
- package/dist/src/collaboration/storage.js +241 -0
- package/dist/src/collaboration/storage.js.map +1 -0
- package/dist/src/collaboration/tools.d.ts +5 -0
- package/dist/src/collaboration/tools.js +11 -0
- package/dist/src/collaboration/tools.js.map +1 -0
- 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/review-command.d.ts +8 -3
- package/dist/src/commands/review-command.js +17 -3
- package/dist/src/commands/review-command.js.map +1 -1
- package/dist/src/dev-repl.js +8 -1
- package/dist/src/dev-repl.js.map +1 -1
- package/dist/src/headless-protocol.d.ts +6 -2
- package/dist/src/headless-protocol.js +32 -8
- package/dist/src/headless-protocol.js.map +1 -1
- package/dist/src/headless-runner.js +45 -1
- package/dist/src/headless-runner.js.map +1 -1
- package/dist/src/headless.d.ts +2 -1
- package/dist/src/headless.js +5 -5
- package/dist/src/headless.js.map +1 -1
- package/dist/src/list-agents.d.ts +21 -0
- package/dist/src/list-agents.js +219 -0
- package/dist/src/list-agents.js.map +1 -0
- package/dist/src/npm-package/patch-package-format.d.ts +5 -5
- package/dist/src/npm-package/patch-package-format.js +4 -4
- package/dist/src/paths.d.ts +5 -0
- package/dist/src/paths.js +14 -2
- package/dist/src/paths.js.map +1 -1
- package/dist/src/sdk-patch-preflight.js +1 -1
- package/dist/src/skills/builtin/developer/SKILL.md +2 -0
- package/dist/src/skills/builtin/self-reflection/references/reflection-template.md +2 -1
- package/dist/src/tools/background-bash.d.ts +7 -1
- package/dist/src/tools/background-bash.js +10 -8
- package/dist/src/tools/background-bash.js.map +1 -1
- package/dist/src/trajectory/record.d.ts +56 -3
- package/dist/src/trajectory/record.js +35 -0
- package/dist/src/trajectory/record.js.map +1 -1
- package/dist/src/trajectory/replay.d.ts +12 -1
- package/dist/src/trajectory/replay.js +44 -2
- package/dist/src/trajectory/replay.js.map +1 -1
- package/dist/src/trajectory/rewind-history.js +1 -1
- package/dist/src/trajectory/rewind-history.js.map +1 -1
- package/dist/src/trajectory/writer.d.ts +17 -3
- package/dist/src/trajectory/writer.js +42 -0
- package/dist/src/trajectory/writer.js.map +1 -1
- package/dist/src/tui/App.js +83 -1
- package/dist/src/tui/App.js.map +1 -1
- package/dist/src/tui/InputBox.d.ts +1 -1
- package/dist/src/tui/InputBox.js +3 -2
- package/dist/src/tui/InputBox.js.map +1 -1
- package/dist/src/tui/help-format.d.ts +2 -2
- package/dist/src/tui/help-format.js +4 -3
- package/dist/src/tui/help-format.js.map +1 -1
- package/dist/src/tui/prompt-editor.js +19 -9
- package/dist/src/tui/prompt-editor.js.map +1 -1
- package/package.json +3 -3
|
@@ -56,9 +56,21 @@ you could read yourself.
|
|
|
56
56
|
whole-document tool-call payload can exceed what the provider stream completes.
|
|
57
57
|
4. Verify your work by running something: the project's typecheck, its tests, or a command that
|
|
58
58
|
exercises the change. If verification is impossible, say so instead of implying success.
|
|
59
|
+
When a reply reports material numbers, compute sums and other summaries with an available
|
|
60
|
+
local tool rather than mentally, and reconcile the components against the authoritative total,
|
|
61
|
+
units and time window. Keep requested apart from executed quantities and observed apart from
|
|
62
|
+
estimated or counterfactual values; state missing evidence or an unexplained residual instead
|
|
63
|
+
of claiming the figures reconcile.
|
|
59
64
|
5. After a tool fails twice with the same cause, state a materially new evidence-backed hypothesis
|
|
60
65
|
before retrying. Three equivalent failures are the limit: stop, report the blocker and collected
|
|
61
66
|
artifacts, and ask the user before continuing in a new turn.
|
|
67
|
+
Code you write to run unattended with side effects needs the same bounds: after a bounded
|
|
68
|
+
number of identical deterministic rejections, pause that action with its reason stated until
|
|
69
|
+
inputs or observed state change; retry transient limits a bounded number of times with backoff,
|
|
70
|
+
honouring any server-directed delay; when a state-changing request's outcome is ambiguous (a
|
|
71
|
+
timeout, say), reconcile the actual state or use an idempotency key before replaying it. When
|
|
72
|
+
feasible, check such a script against representative offline response sequences before an
|
|
73
|
+
unattended launch.
|
|
62
74
|
6. Do not add dependencies, delete data, or rewrite git history unless asked.
|
|
63
75
|
7. Batch independent reads: when several tool calls have no dependency between them — searches,
|
|
64
76
|
file views, status checks — issue them together in one assistant message instead of one call
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../../src/agent/system-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,gDAAgD;AAChD,MAAM,CAAC,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAEzD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG
|
|
1
|
+
{"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../../src/agent/system-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,gDAAgD;AAChD,MAAM,CAAC,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAEzD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8EA2EyC,CAAC;AAE/E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG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AI,GACR,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAE,KAA2B,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAC9F,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,SAAS,CAAC;AACjD,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -15,12 +15,25 @@
|
|
|
15
15
|
* (`endTurn`) commits them, because a cancelled turn's tool result may never have
|
|
16
16
|
* been reasoned about. `observe` cannot throw — observer discipline: a ledger
|
|
17
17
|
* failure costs a possible duplicate wake, never a turn.
|
|
18
|
+
*
|
|
19
|
+
* SRF-036: the SDK `ContextOffloader` replaces an oversized result at default hook
|
|
20
|
+
* order with an `[Offloaded: …]` text preview, so the stream carries only the
|
|
21
|
+
* preview. {@link TerminalDeliveryLedger.install} therefore registers one
|
|
22
|
+
* `HookOrder.SDK_FIRST` `AfterToolCallEvent` hook that reads the *original* result
|
|
23
|
+
* and keeps its terminal ids as candidates keyed by `toolUseId`; `observe` resolves
|
|
24
|
+
* them against the result the stream actually carries. Unchanged, it counts exactly
|
|
25
|
+
* as before. Replaced, a candidate id counts only when the model-visible
|
|
26
|
+
* replacement text contains that exact id, so snapshots cut off by the preview stay
|
|
27
|
+
* undelivered. The preview is only searched for the literal id, never parsed for
|
|
28
|
+
* state: the state comes from the original.
|
|
18
29
|
*/
|
|
19
|
-
import
|
|
30
|
+
import { AfterToolCallEvent } from '@strands-agents/sdk';
|
|
31
|
+
import type { Agent, AgentStreamEvent } from '@strands-agents/sdk';
|
|
20
32
|
/**
|
|
21
33
|
* Task ids whose terminal state a successful `bash` result carried to the model.
|
|
22
34
|
* Recognizes the manager's own shapes only — `wait` (`status.state`), `status`/`stop`
|
|
23
|
-
* (a snapshot) and `list` (snapshots
|
|
35
|
+
* (a snapshot) and `list` (snapshots: a bare array, or the SDK's `{ $value: [...] }`
|
|
36
|
+
* envelope the real tool path produces) — by the result, never by the input, because
|
|
24
37
|
* some SDK after-events omit the original input. Foreground `execute` results and
|
|
25
38
|
* `output` results carry no state and contribute nothing.
|
|
26
39
|
*/
|
|
@@ -31,6 +44,16 @@ export declare function terminalTaskIdsInToolResult(toolName: string, result: {
|
|
|
31
44
|
export declare class TerminalDeliveryLedger {
|
|
32
45
|
private readonly delivered;
|
|
33
46
|
private pending;
|
|
47
|
+
/** Pre-replacement terminal ids per `toolUseId`, resolved by `observe`, dropped by `closeTurn`. */
|
|
48
|
+
private candidates;
|
|
49
|
+
/**
|
|
50
|
+
* Registers the pre-offload hook on the parent Agent: `SDK_FIRST`, so it runs
|
|
51
|
+
* before the `ContextOffloader`'s default-order hook can replace the result.
|
|
52
|
+
* It only reads; it never changes the event.
|
|
53
|
+
*/
|
|
54
|
+
install(agent: Pick<Agent, 'addHook'>): void;
|
|
55
|
+
/** Records the original result's terminal ids for `observe`. Synchronous, non-throwing. */
|
|
56
|
+
candidate(event: AfterToolCallEvent): void;
|
|
34
57
|
/** Observes one stream event of the current turn. Synchronous, non-throwing. */
|
|
35
58
|
observe(event: AgentStreamEvent): void;
|
|
36
59
|
/**
|
|
@@ -15,7 +15,19 @@
|
|
|
15
15
|
* (`endTurn`) commits them, because a cancelled turn's tool result may never have
|
|
16
16
|
* been reasoned about. `observe` cannot throw — observer discipline: a ledger
|
|
17
17
|
* failure costs a possible duplicate wake, never a turn.
|
|
18
|
+
*
|
|
19
|
+
* SRF-036: the SDK `ContextOffloader` replaces an oversized result at default hook
|
|
20
|
+
* order with an `[Offloaded: …]` text preview, so the stream carries only the
|
|
21
|
+
* preview. {@link TerminalDeliveryLedger.install} therefore registers one
|
|
22
|
+
* `HookOrder.SDK_FIRST` `AfterToolCallEvent` hook that reads the *original* result
|
|
23
|
+
* and keeps its terminal ids as candidates keyed by `toolUseId`; `observe` resolves
|
|
24
|
+
* them against the result the stream actually carries. Unchanged, it counts exactly
|
|
25
|
+
* as before. Replaced, a candidate id counts only when the model-visible
|
|
26
|
+
* replacement text contains that exact id, so snapshots cut off by the preview stay
|
|
27
|
+
* undelivered. The preview is only searched for the literal id, never parsed for
|
|
28
|
+
* state: the state comes from the original.
|
|
18
29
|
*/
|
|
30
|
+
import { AfterToolCallEvent, HookOrder } from '@strands-agents/sdk';
|
|
19
31
|
const TERMINAL_STATES = new Set(['succeeded', 'failed', 'stopped']);
|
|
20
32
|
const TASK_ID = /^bg-[0-9a-f-]{36}$/;
|
|
21
33
|
function isRecord(value) {
|
|
@@ -47,10 +59,29 @@ function resultPayload(content) {
|
|
|
47
59
|
}
|
|
48
60
|
return undefined;
|
|
49
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* The array inside the SDK's ordinary-array envelope, or undefined. The SDK's
|
|
64
|
+
* `FunctionTool` cannot hand a plain array to Bedrock as JSON content, so it returns
|
|
65
|
+
* one as `new JsonBlock({ json: { $value: array } })` — which is how `list`'s
|
|
66
|
+
* `manager.list()` reaches the model (SRF-033). Exactly that shape is unwrapped, one
|
|
67
|
+
* level: an object whose only own key is `$value`, holding an array. Extra keys, a
|
|
68
|
+
* non-array `$value` and envelopes nested inside the array are not the SDK's shape
|
|
69
|
+
* and are not unwrapped.
|
|
70
|
+
*/
|
|
71
|
+
function sdkArrayEnvelope(payload) {
|
|
72
|
+
if (!isRecord(payload))
|
|
73
|
+
return undefined;
|
|
74
|
+
const keys = Object.keys(payload);
|
|
75
|
+
if (keys.length !== 1 || keys[0] !== '$value')
|
|
76
|
+
return undefined;
|
|
77
|
+
const value = payload.$value;
|
|
78
|
+
return Array.isArray(value) ? value : undefined;
|
|
79
|
+
}
|
|
50
80
|
/**
|
|
51
81
|
* Task ids whose terminal state a successful `bash` result carried to the model.
|
|
52
82
|
* Recognizes the manager's own shapes only — `wait` (`status.state`), `status`/`stop`
|
|
53
|
-
* (a snapshot) and `list` (snapshots
|
|
83
|
+
* (a snapshot) and `list` (snapshots: a bare array, or the SDK's `{ $value: [...] }`
|
|
84
|
+
* envelope the real tool path produces) — by the result, never by the input, because
|
|
54
85
|
* some SDK after-events omit the original input. Foreground `execute` results and
|
|
55
86
|
* `output` results carry no state and contribute nothing.
|
|
56
87
|
*/
|
|
@@ -58,8 +89,9 @@ export function terminalTaskIdsInToolResult(toolName, result) {
|
|
|
58
89
|
if (toolName !== 'bash' || result.status !== 'success')
|
|
59
90
|
return [];
|
|
60
91
|
const payload = resultPayload(result.content);
|
|
61
|
-
|
|
62
|
-
|
|
92
|
+
const listed = Array.isArray(payload) ? payload : sdkArrayEnvelope(payload);
|
|
93
|
+
if (listed !== undefined) {
|
|
94
|
+
return listed.map(terminalSnapshotId).filter((id) => id !== undefined);
|
|
63
95
|
}
|
|
64
96
|
if (!isRecord(payload))
|
|
65
97
|
return [];
|
|
@@ -75,23 +107,63 @@ export function terminalTaskIdsInToolResult(toolName, result) {
|
|
|
75
107
|
}
|
|
76
108
|
return [];
|
|
77
109
|
}
|
|
110
|
+
/** Whether any text block of a model-visible result contains `id` verbatim. */
|
|
111
|
+
function textContains(content, id) {
|
|
112
|
+
return content.some((block) => isRecord(block) && block.type === 'textBlock' && typeof block.text === 'string' && block.text.includes(id));
|
|
113
|
+
}
|
|
78
114
|
export class TerminalDeliveryLedger {
|
|
79
115
|
delivered = new Set();
|
|
80
116
|
pending = new Set();
|
|
117
|
+
/** Pre-replacement terminal ids per `toolUseId`, resolved by `observe`, dropped by `closeTurn`. */
|
|
118
|
+
candidates = new Map();
|
|
119
|
+
/**
|
|
120
|
+
* Registers the pre-offload hook on the parent Agent: `SDK_FIRST`, so it runs
|
|
121
|
+
* before the `ContextOffloader`'s default-order hook can replace the result.
|
|
122
|
+
* It only reads; it never changes the event.
|
|
123
|
+
*/
|
|
124
|
+
install(agent) {
|
|
125
|
+
agent.addHook(AfterToolCallEvent, (event) => this.candidate(event), { order: HookOrder.SDK_FIRST });
|
|
126
|
+
}
|
|
127
|
+
/** Records the original result's terminal ids for `observe`. Synchronous, non-throwing. */
|
|
128
|
+
candidate(event) {
|
|
129
|
+
try {
|
|
130
|
+
const { toolUse, result } = event;
|
|
131
|
+
if (typeof toolUse?.name !== 'string' || typeof toolUse.toolUseId !== 'string')
|
|
132
|
+
return;
|
|
133
|
+
if (!isRecord(result) || !Array.isArray(result.content))
|
|
134
|
+
return;
|
|
135
|
+
const ids = terminalTaskIdsInToolResult(toolUse.name, { status: String(result.status), content: result.content });
|
|
136
|
+
if (ids.length > 0)
|
|
137
|
+
this.candidates.set(toolUse.toolUseId, { result, ids });
|
|
138
|
+
else
|
|
139
|
+
this.candidates.delete(toolUse.toolUseId);
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
// Observer discipline: a lost candidate costs a possible duplicate wake, never a turn.
|
|
143
|
+
}
|
|
144
|
+
}
|
|
81
145
|
/** Observes one stream event of the current turn. Synchronous, non-throwing. */
|
|
82
146
|
observe(event) {
|
|
83
147
|
try {
|
|
84
148
|
if (event.type !== 'afterToolCallEvent')
|
|
85
149
|
return;
|
|
86
150
|
const { toolUse, result } = event;
|
|
151
|
+
const candidate = typeof toolUse?.toolUseId === 'string' ? this.candidates.get(toolUse.toolUseId) : undefined;
|
|
152
|
+
if (candidate !== undefined)
|
|
153
|
+
this.candidates.delete(toolUse?.toolUseId);
|
|
87
154
|
if (typeof toolUse?.name !== 'string' || !isRecord(result) || !Array.isArray(result.content))
|
|
88
155
|
return;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
content: result.content,
|
|
92
|
-
})) {
|
|
156
|
+
const status = String(result.status);
|
|
157
|
+
for (const id of terminalTaskIdsInToolResult(toolUse.name, { status, content: result.content })) {
|
|
93
158
|
this.pending.add(id);
|
|
94
159
|
}
|
|
160
|
+
// A replaced result (the offloader's preview): the original's ids count only
|
|
161
|
+
// where the model-visible text still names them exactly.
|
|
162
|
+
if (candidate !== undefined && candidate.result !== result && status === 'success') {
|
|
163
|
+
for (const id of candidate.ids)
|
|
164
|
+
if (textContains(result.content, id))
|
|
165
|
+
this.pending.add(id);
|
|
166
|
+
}
|
|
95
167
|
}
|
|
96
168
|
catch {
|
|
97
169
|
// Observer discipline: never a second reason a turn dies.
|
|
@@ -106,6 +178,7 @@ export class TerminalDeliveryLedger {
|
|
|
106
178
|
for (const id of this.pending)
|
|
107
179
|
this.delivered.add(id);
|
|
108
180
|
this.pending = new Set();
|
|
181
|
+
this.candidates = new Map();
|
|
109
182
|
}
|
|
110
183
|
/** True once a completed turn carried this task's terminal state to the model. */
|
|
111
184
|
has(taskId) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-terminal-delivery.js","sourceRoot":"","sources":["../../../src/agent/task-terminal-delivery.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"task-terminal-delivery.js","sourceRoot":"","sources":["../../../src/agent/task-terminal-delivery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGpE,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AACzF,MAAM,OAAO,GAAG,oBAAoB,CAAC;AAErC,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,kGAAkG;AAClG,SAAS,kBAAkB,CAAC,KAAc;IACxC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACvC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IAChC,IAAI,OAAO,MAAM,KAAK,QAAQ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AE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC7F,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,0DAA0D;QAC5D,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,SAAS,CAAC,SAAkB;QAC1B,IAAI,SAAS;YAAE,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,OAAO;gBAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACrE,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;IAC9B,CAAC;IAED,kFAAkF;IAClF,GAAG,CAAC,MAAc;QAChB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runListAgentsCli(projectRoot: string, args: readonly string[]): Promise<void>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Local observer route: no runtime, config, provider or SDK imports. */
|
|
2
|
+
import { formatLocalAgents, readLocalAgents } from './list-agents.js';
|
|
3
|
+
import { usageErrorText } from './cli-usage.js';
|
|
4
|
+
export async function runListAgentsCli(projectRoot, args) {
|
|
5
|
+
if (args.length > 0) {
|
|
6
|
+
process.stderr.write(usageErrorText('list-agents takes no arguments. Usage: darwin list-agents'));
|
|
7
|
+
process.exitCode = 2;
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
process.stdout.write(`${formatLocalAgents(await readLocalAgents(projectRoot))}\n`);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=cli-list-agents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-list-agents.js","sourceRoot":"","sources":["../../src/cli-list-agents.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,WAAmB,EAAE,IAAuB;IACjF,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,2DAA2D,CAAC,CAAC,CAAC;QAClG,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,iBAAiB,CAAC,MAAM,eAAe,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC;AACrF,CAAC"}
|
package/dist/src/cli-usage.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const HELP_FLAGS: readonly ['--help', '-h'];
|
|
2
2
|
export declare const VERSION_FLAGS: readonly ['--version', '-V'];
|
|
3
3
|
/** The complete grammar, exactly as `darwin --help` prints it (trailing newline included). */
|
|
4
|
-
export declare const CLI_USAGE = "Usage: darwin [--resume [<id>]|--session <id>] [--permission-mode <default|auto|plan|yolo>] [--yolo]\n darwin -p <message> [--output-format text|json|stream-json]\n [--continue|--resume [<id>]|--session <id>] [permission flags]\n [--max-model-calls <n>] [--context-offload] [--compact-before]\n darwin sessions\n darwin permissions test <rule>\n darwin import --from claude-code [--apply]\n darwin doctor\n darwin cloud-memory [status|preferences|list|inspect|pending|preview] \u2026\n darwin trajectory <list|search|replay|fork> \u2026\n darwin --help | -h\n darwin --version | -V\n\n--context-offload force-enables the default-on offloader for this process; it never persists.\nPrint-only flags: --output-format, --max-model-calls, --context-offload, --compact-before, --continue.\nWith -p, piped (non-TTY) stdin is read to EOF and appended to <message> as one delimited block (256 KiB cap).\n";
|
|
4
|
+
export declare const CLI_USAGE = "Usage: darwin [--resume [<id>]|--session <id>] [--permission-mode <default|auto|plan|yolo>] [--yolo]\n darwin -p <message> [--output-format text|json|stream-json]\n [--continue|--resume [<id>]|--session <id>] [permission flags]\n [--max-model-calls <n>] [--context-offload] [--compact-before]\n darwin sessions\n darwin list-agents\n darwin collaborate [status|list|pending|relations|on|off]\n darwin collaborate send <endpoint-uuid> <literal text>\n darwin collaborate confirm <pending-id> --persist\n darwin collaborate revoke <pair-id>\n darwin permissions test <rule>\n darwin import --from claude-code [--apply]\n darwin doctor\n darwin cloud-memory [status|preferences|list|inspect|pending|preview] \u2026\n darwin trajectory <list|search|replay|fork> \u2026\n darwin --help | -h\n darwin --version | -V\n\n--context-offload force-enables the default-on offloader for this process; it never persists.\nPrint-only flags: --output-format, --max-model-calls, --context-offload, --compact-before, --continue.\nWith -p, piped (non-TTY) stdin is read to EOF and appended to <message> as one delimited block (256 KiB cap).\n";
|
|
5
5
|
/** The one hint every usage error appends after its `error:` line. */
|
|
6
6
|
export declare const CLI_HELP_HINT = "Run `darwin --help` for usage.";
|
|
7
7
|
/**
|
package/dist/src/cli-usage.js
CHANGED
|
@@ -19,6 +19,11 @@ export const CLI_USAGE = `Usage: darwin [--resume [<id>]|--session <id>] [--perm
|
|
|
19
19
|
[--continue|--resume [<id>]|--session <id>] [permission flags]
|
|
20
20
|
[--max-model-calls <n>] [--context-offload] [--compact-before]
|
|
21
21
|
darwin sessions
|
|
22
|
+
darwin list-agents
|
|
23
|
+
darwin collaborate [status|list|pending|relations|on|off]
|
|
24
|
+
darwin collaborate send <endpoint-uuid> <literal text>
|
|
25
|
+
darwin collaborate confirm <pending-id> --persist
|
|
26
|
+
darwin collaborate revoke <pair-id>
|
|
22
27
|
darwin permissions test <rule>
|
|
23
28
|
darwin import --from claude-code [--apply]
|
|
24
29
|
darwin doctor
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-usage.js","sourceRoot":"","sources":["../../src/cli-usage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,cAAc,EA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C;IAC3F,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/src/cli.js
CHANGED
|
@@ -26,7 +26,15 @@ else {
|
|
|
26
26
|
const args = process.argv.slice(2);
|
|
27
27
|
if (args[0] === '--')
|
|
28
28
|
args.shift();
|
|
29
|
-
if (args[0] === '
|
|
29
|
+
if (args[0] === 'collaborate') {
|
|
30
|
+
const { runCollaborationCli } = await import('./collaboration/command.js');
|
|
31
|
+
await runCollaborationCli(process.cwd(), args.slice(1));
|
|
32
|
+
}
|
|
33
|
+
else if (args[0] === 'list-agents') {
|
|
34
|
+
const { runListAgentsCli } = await import('./cli-list-agents.js');
|
|
35
|
+
await runListAgentsCli(process.cwd(), args.slice(1));
|
|
36
|
+
}
|
|
37
|
+
else if (args[0] === 'import') {
|
|
30
38
|
const { runImportCli } = await import('./cli-import.js');
|
|
31
39
|
await runImportCli(process.cwd(), args.slice(1));
|
|
32
40
|
}
|
package/dist/src/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,6BAA6B,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE5F,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;AACpC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;IAC1B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC9B,OAAO,CAAC,QAAQ,GAAG,6BAA6B,CAAC;AACnD,CAAC;KAAM,CAAC;IACN,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI;QAAE,IAAI,CAAC,KAAK,EAAE,CAAC;IACnC,IAAI,IAAI,CAAC,CAA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ation, expansion or model-granted trust. */
|
|
4
|
+
export declare function collaborationCommand(local: LocalCollaboration, text: string): Promise<string>;
|
|
5
|
+
export declare function runCollaborationCli(root: string, args: readonly string[]): Promise<void>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { discoverPeers, LocalCollaboration } from './local.js';
|
|
3
|
+
import { idSchema, policyCommand } from './storage.js';
|
|
4
|
+
import { COLLABORATE_USAGE } from './grammar.js';
|
|
5
|
+
export { COLLABORATE_USAGE } from './grammar.js';
|
|
6
|
+
/** Pure preflight shared by CLI and TUI: no policy, registration or probe on bad grammar. */
|
|
7
|
+
function validateCommand(args) {
|
|
8
|
+
const [verb, id, flag] = args;
|
|
9
|
+
if (args.length === 1 && ['status', 'list', 'pending', 'relations', 'on', 'off'].includes(verb))
|
|
10
|
+
return;
|
|
11
|
+
if (verb === 'confirm' && args.length === 3 && flag === '--persist' && idSchema.safeParse(id).success)
|
|
12
|
+
return;
|
|
13
|
+
if (verb === 'revoke' && args.length === 2 && /^[a-f0-9]{64}$/.test(id ?? ''))
|
|
14
|
+
return;
|
|
15
|
+
if (verb === 'send' && args.length >= 3 && idSchema.safeParse(id).success) {
|
|
16
|
+
const bytes = Buffer.byteLength(args.slice(2).join(' '));
|
|
17
|
+
if (bytes > 0 && bytes <= 4096)
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
throw new Error(COLLABORATE_USAGE);
|
|
21
|
+
}
|
|
22
|
+
/** Literal user-only command. No invocation, expansion or model-granted trust. */
|
|
23
|
+
export async function collaborationCommand(local, text) {
|
|
24
|
+
const command = text.trim();
|
|
25
|
+
const send = /^send\s+(\S+)\s+([\s\S]+)$/.exec(text.trimStart());
|
|
26
|
+
validateCommand(send ? ['send', send[1], send[2]] : (command || 'status').split(/\s+/));
|
|
27
|
+
if (send) {
|
|
28
|
+
local.beginHumanTurn();
|
|
29
|
+
return local.send(send[1], send[2]);
|
|
30
|
+
}
|
|
31
|
+
if (command === 'list')
|
|
32
|
+
return JSON.stringify(await discoverPeers(), null, 2);
|
|
33
|
+
const result = await policyCommand((command || 'status').split(/\s+/));
|
|
34
|
+
if (command === 'off')
|
|
35
|
+
local.close('collaboration off');
|
|
36
|
+
if (command === 'on') {
|
|
37
|
+
local.close('new endpoint requested');
|
|
38
|
+
await local.start();
|
|
39
|
+
}
|
|
40
|
+
return `${result}\nThis endpoint: ${JSON.stringify(local.address ?? null)}; queued: ${local.pending}\n${COLLABORATE_USAGE}`;
|
|
41
|
+
}
|
|
42
|
+
export async function runCollaborationCli(root, args) {
|
|
43
|
+
try {
|
|
44
|
+
// CLI registration exists only for an explicit send. Read projections do not
|
|
45
|
+
// create policy; first startup/on initializes it with no cross-project grants.
|
|
46
|
+
validateCommand(args.length ? args : ['status']);
|
|
47
|
+
if (args[0] === 'list') {
|
|
48
|
+
console.log(JSON.stringify(await discoverPeers(), null, 2));
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (args[0] !== 'send') {
|
|
52
|
+
console.log(await policyCommand(args.length ? args : ['status']));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const local = new LocalCollaboration(root, `cli-${randomUUID()}`);
|
|
56
|
+
await local.start();
|
|
57
|
+
// argv already separates the target from literal text; do not reparse it as
|
|
58
|
+
// TUI command whitespace and lose leading spaces/newlines in a quoted body.
|
|
59
|
+
try {
|
|
60
|
+
local.beginHumanTurn();
|
|
61
|
+
console.log(await local.send(args[1], args.slice(2).join(' ')));
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
local.close('CLI send finished');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
console.error(`collaborate: ${error instanceof Error ? error.message : 'local operation failed'}`);
|
|
69
|
+
process.exitCode = 1;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,gBAAgB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB,EAAE,CAAC,CAAC;QACnG,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Pure canonical user grammar; safe to import from bounded local help. */
|
|
2
|
+
export declare const COLLABORATION_GRAMMAR: readonly ['/collaborate [status|list|pending|relations|on|off]', '/collaborate send <endpoint-uuid> <literal text>', '/collaborate confirm <pending-id> --persist; /collaborate revoke <pair-id>'];
|
|
3
|
+
export declare const COLLABORATE_USAGE: string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Pure canonical user grammar; safe to import from bounded local help. */
|
|
2
|
+
export const COLLABORATION_GRAMMAR = [
|
|
3
|
+
'/collaborate [status|list|pending|relations|on|off]',
|
|
4
|
+
'/collaborate send <endpoint-uuid> <literal text>',
|
|
5
|
+
'/collaborate confirm <pending-id> --persist; /collaborate revoke <pair-id>',
|
|
6
|
+
];
|
|
7
|
+
export const COLLABORATE_USAGE = COLLABORATION_GRAMMAR.join('; ');
|
|
8
|
+
//# sourceMappingURL=grammar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grammar.js","sourceRoot":"","sources":["../../../src/collaboration/grammar.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,qDAAqD;IACrD,kDAAkD;IAClD,4EAA4E;CACpE,CAAC;AACX,MAAM,CAAC,MAAM,iBAAiB,GAAG,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type PeerAddress, type PeerInput, type PeerTransport } from './protocol.js';
|
|
2
|
+
export declare function socketPath(id: string): string;
|
|
3
|
+
/** Bounded metadata-only endpoint projection, separate from immutable lease discovery. */
|
|
4
|
+
export declare function discoverPeers(): Promise<{
|
|
5
|
+
endpoints: PeerAddress[];
|
|
6
|
+
omitted: number;
|
|
7
|
+
uninspected: number;
|
|
8
|
+
scanLimited: boolean;
|
|
9
|
+
scope: string;
|
|
10
|
+
}>;
|
|
11
|
+
/** One parent session, never a daemon or SDK loop. Only drivers drain the inbox. */
|
|
12
|
+
export declare class LocalCollaboration implements PeerTransport {
|
|
13
|
+
private readonly projectRoot;
|
|
14
|
+
readonly session: string;
|
|
15
|
+
private readonly readOnly;
|
|
16
|
+
private server;
|
|
17
|
+
private registration;
|
|
18
|
+
private sockets;
|
|
19
|
+
private inbox;
|
|
20
|
+
private listeners;
|
|
21
|
+
private notices;
|
|
22
|
+
private seen;
|
|
23
|
+
private chainCounts;
|
|
24
|
+
private cause?;
|
|
25
|
+
private outgoing;
|
|
26
|
+
private peerTurn;
|
|
27
|
+
private lastPeerId?;
|
|
28
|
+
private denied;
|
|
29
|
+
private admitted;
|
|
30
|
+
private window;
|
|
31
|
+
private accepting;
|
|
32
|
+
private stopped;
|
|
33
|
+
private generation;
|
|
34
|
+
private canonicalRoot;
|
|
35
|
+
constructor(projectRoot: string, session: string, readOnly?: () => boolean);
|
|
36
|
+
get project(): string;
|
|
37
|
+
get address(): PeerAddress | undefined;
|
|
38
|
+
get pending(): number;
|
|
39
|
+
get active(): boolean;
|
|
40
|
+
subscribe(listener: () => void): () => void;
|
|
41
|
+
takeNotices(): string[];
|
|
42
|
+
private changed;
|
|
43
|
+
private notice;
|
|
44
|
+
start(): Promise<void>;
|
|
45
|
+
/** Headless closes admission before draining a finite snapshot; not an idle daemon. */
|
|
46
|
+
stopAdmission(): void;
|
|
47
|
+
close(reason: string): void;
|
|
48
|
+
private receive;
|
|
49
|
+
private respond;
|
|
50
|
+
private fresh;
|
|
51
|
+
private admit;
|
|
52
|
+
/** Only a driver at idle takes input. Runtime rechecks it immediately before invocation. */
|
|
53
|
+
take(): PeerInput | undefined;
|
|
54
|
+
validateDelivery(input: PeerInput): void;
|
|
55
|
+
beginHumanTurn(): void;
|
|
56
|
+
beginPeerTurn(input: PeerInput): void;
|
|
57
|
+
permissionDenied(): void;
|
|
58
|
+
get fromPeer(): boolean;
|
|
59
|
+
get peerReadOnly(): boolean;
|
|
60
|
+
send(target: string, text: string): Promise<string>;
|
|
61
|
+
}
|