@phnx-labs/agents-cli 1.22.115 → 1.22.116

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 (88) hide show
  1. package/CHANGELOG.md +149 -14
  2. package/README.md +1 -1
  3. package/dist/commands/browser.js +11 -0
  4. package/dist/commands/exec.js +212 -141
  5. package/dist/commands/feed.js +65 -14
  6. package/dist/commands/sessions-picker.d.ts +11 -0
  7. package/dist/commands/sessions-picker.js +88 -7
  8. package/dist/commands/sessions.d.ts +21 -2
  9. package/dist/commands/sessions.js +157 -3
  10. package/dist/commands/setup-secrets.d.ts +2 -2
  11. package/dist/commands/setup-term.d.ts +24 -0
  12. package/dist/commands/setup-term.js +70 -0
  13. package/dist/commands/setup.d.ts +1 -1
  14. package/dist/commands/setup.js +12 -4
  15. package/dist/commands/ssh.js +1 -69
  16. package/dist/lib/accounting/rotate.d.ts +63 -1
  17. package/dist/lib/accounting/rotate.js +56 -0
  18. package/dist/lib/accounts/add.js +2 -2
  19. package/dist/lib/accounts/slots.js +32 -2
  20. package/dist/lib/answer-router.d.ts +11 -2
  21. package/dist/lib/answer-router.js +26 -2
  22. package/dist/lib/auth-mint.d.ts +5 -4
  23. package/dist/lib/auth-mint.js +4 -3
  24. package/dist/lib/browser/drivers/arc.d.ts +1 -1
  25. package/dist/lib/browser/service.d.ts +10 -0
  26. package/dist/lib/browser/service.js +208 -36
  27. package/dist/lib/browser/types.d.ts +18 -0
  28. package/dist/lib/config-keys.d.ts +1 -1
  29. package/dist/lib/config-keys.js +5 -0
  30. package/dist/lib/device-config.js +61 -0
  31. package/dist/lib/devices/doctor-findings.js +2 -6
  32. package/dist/lib/feed/answer.d.ts +153 -4
  33. package/dist/lib/feed/answer.js +716 -105
  34. package/dist/lib/feed/feed.d.ts +61 -1
  35. package/dist/lib/feed/feed.js +226 -14
  36. package/dist/lib/feed/hub-server.d.ts +58 -3
  37. package/dist/lib/feed/hub-server.js +306 -54
  38. package/dist/lib/feed/pr-status.d.ts +8 -0
  39. package/dist/lib/feed/pr-status.js +9 -1
  40. package/dist/lib/feed-outcome.d.ts +1 -1
  41. package/dist/lib/feed-outcome.js +9 -2
  42. package/dist/lib/feed-policy.js +9 -3
  43. package/dist/lib/fleet/auth-sync.d.ts +2 -55
  44. package/dist/lib/fleet/auth-sync.js +2 -89
  45. package/dist/lib/harness-auth-capabilities.js +7 -2
  46. package/dist/lib/hosts/dispatch.d.ts +20 -1
  47. package/dist/lib/hosts/dispatch.js +52 -30
  48. package/dist/lib/hosts/remote-cmd.d.ts +21 -0
  49. package/dist/lib/hosts/remote-cmd.js +26 -2
  50. package/dist/lib/mailbox.d.ts +12 -0
  51. package/dist/lib/mailbox.js +16 -2
  52. package/dist/lib/menubar/snapshot.d.ts +51 -0
  53. package/dist/lib/menubar/snapshot.js +42 -3
  54. package/dist/lib/open-url.js +2 -2
  55. package/dist/lib/projects.d.ts +23 -0
  56. package/dist/lib/projects.js +78 -0
  57. package/dist/lib/secrets-cli.d.ts +3 -3
  58. package/dist/lib/secrets-cli.js +1 -1
  59. package/dist/lib/session/active.d.ts +1 -0
  60. package/dist/lib/session/active.js +8 -0
  61. package/dist/lib/session/db.d.ts +67 -3
  62. package/dist/lib/session/db.js +381 -126
  63. package/dist/lib/session/prompt.d.ts +23 -7
  64. package/dist/lib/session/prompt.js +46 -8
  65. package/dist/lib/session/remote/remote-list.d.ts +20 -0
  66. package/dist/lib/session/remote/remote-list.js +22 -6
  67. package/dist/lib/session/remote/watch.d.ts +12 -0
  68. package/dist/lib/session/remote/watch.js +9 -0
  69. package/dist/lib/session/remote-preview-cache.d.ts +29 -0
  70. package/dist/lib/session/remote-preview-cache.js +373 -0
  71. package/dist/lib/session/tail.d.ts +50 -0
  72. package/dist/lib/session/tail.js +219 -0
  73. package/dist/lib/setup-tool-install.js +2 -1
  74. package/dist/lib/setup-tool-status.d.ts +1 -1
  75. package/dist/lib/setup-tool-status.js +6 -1
  76. package/dist/lib/signin-badge.d.ts +19 -4
  77. package/dist/lib/signin-badge.js +29 -11
  78. package/dist/lib/term-driver.d.ts +24 -0
  79. package/dist/lib/term-driver.js +36 -0
  80. package/dist/lib/terminal/index.d.ts +1 -1
  81. package/dist/lib/terminal/index.js +1 -1
  82. package/dist/lib/terminal/inject.d.ts +38 -0
  83. package/dist/lib/terminal/inject.js +55 -9
  84. package/dist/lib/terminal/transport.d.ts +15 -5
  85. package/dist/lib/terminal/transport.js +61 -11
  86. package/package.json +1 -1
  87. package/dist/lib/fleet/remote-login.d.ts +0 -170
  88. package/dist/lib/fleet/remote-login.js +0 -568
@@ -1,14 +1,133 @@
1
1
  import { type ActiveSession } from '../session/active.js';
2
2
  import { type MessageReceipt } from './feed.js';
3
+ /**
4
+ * Total budget for one answer. Sits below the AGI Menu's 30s abandon so the
5
+ * operator always gets a typed verdict instead of a timeout.
6
+ */
7
+ export declare const ANSWER_DEADLINE_MS = 20000;
8
+ /** Slice of the budget the optional PR-review enrichment may spend. */
9
+ export declare const PR_ENRICHMENT_BUDGET_MS = 4000;
10
+ /** Budget for the forwarded leg — the remote repeats the local work under its own deadline. */
11
+ export declare const REMOTE_ANSWER_TIMEOUT_MS = 25000;
12
+ /**
13
+ * A claim older than this with no receipt was stranded by a kill, not left in
14
+ * flight: it exceeds a full local deadline plus the remote leg, so no live
15
+ * delivery can still be running behind it.
16
+ */
17
+ export declare const STRANDED_CLAIM_MS = 60000;
18
+ /**
19
+ * How long to watch a `resume` child before giving up on a verdict. A resume
20
+ * runs the agent's whole next turn — minutes — so waiting for exit would blow the
21
+ * operator deadline on every headless answer. Only a clean early exit is booked;
22
+ * a non-zero exit or a still-running child is unknown, because neither proves
23
+ * the agent did or did not accept the prompt.
24
+ */
25
+ export declare const RESUME_SETTLE_MS = 2000;
26
+ /**
27
+ * How long a caller that LOST the claim waits for the holder's receipt before
28
+ * reporting unknown. The holder is mid-delivery — a double-clicked answer is the
29
+ * common case — so a short wait turns "I can't tell" into the real receipt,
30
+ * without ever delivering a second copy.
31
+ */
32
+ export declare const HOLDER_RECEIPT_WAIT_MS = 400;
33
+ /** Why an answer could not be delivered — the discriminant the operator UI branches on. */
34
+ export type AnswerFailureCode = 'malformed_key' | 'no_session' | 'stale' | 'unverified' | 'unauthorized' | 'unknown_choice' | 'empty_answer' | 'refused' | 'rail_failed' | 'timeout' | 'remote_failed';
35
+ /** A CONFIRMED failure: nothing reached a rail, the claim is released, retry is safe. */
36
+ export declare class AnswerError extends Error {
37
+ readonly code: AnswerFailureCode;
38
+ constructor(message: string, code: AnswerFailureCode);
39
+ }
40
+ /**
41
+ * An UNCONFIRMED outcome: something may have been delivered. The claim is kept
42
+ * so a retry cannot double-send, and the operator is offered a delivery check
43
+ * rather than a resend.
44
+ */
45
+ export declare class AnswerUnknownError extends Error {
46
+ constructor(message: string);
47
+ }
48
+ /**
49
+ * delivered — this call handed the answer to a rail.
50
+ * already_answered — another claim owns it; the reported evidence is that claim's.
51
+ * unknown — something may have landed; do NOT resend, check delivery.
52
+ * failed — confirmed: nothing was delivered.
53
+ */
54
+ export type AnswerStatus = 'delivered' | 'already_answered' | 'unknown' | 'failed';
55
+ /**
56
+ * receipt — a real {@link MessageReceipt} exists on the block.
57
+ * unconfirmed — no receipt evidence either way. The card must NOT be cleared.
58
+ * failed — confirmed failure, including a `dropped`/`expired` receipt.
59
+ */
60
+ export type AnswerDelivery = 'receipt' | 'unconfirmed' | 'failed';
61
+ export interface FeedAnswerResult {
62
+ status: AnswerStatus;
63
+ /** How much the CLI can actually vouch for. */
64
+ delivery: AnswerDelivery;
65
+ /** The block's real receipt. Absent means no rail ever reported one. */
66
+ receipt?: MessageReceipt;
67
+ /**
68
+ * The AGENT's own evidence that it received the answer — a `consumed` or
69
+ * `continued` receipt. A `queued` receipt is delivery, never resolution, so it
70
+ * leaves this false. Removal of the item from the feed resolves the card on
71
+ * its own; this flag only ever adds evidence, it never withholds it.
72
+ */
73
+ resolved: boolean;
74
+ /** Human explanation for a failure, an unknown, or an unconfirmed delivery. */
75
+ reason?: string;
76
+ /** Set when `status` is `failed`. */
77
+ code?: AnswerFailureCode;
78
+ attentionKey: string;
79
+ blockId?: string;
80
+ /** The device that owns the item — the exact target a delivery check re-queries. */
81
+ host?: string;
82
+ /**
83
+ * Stable identity of the delivery attempt (the claim timestamp). A delivery
84
+ * check correlates its read-only answer with the attempt it is checking, so
85
+ * "still unconfirmed" is distinguishable from "a newer attempt replaced it".
86
+ */
87
+ attempt?: string;
88
+ }
3
89
  interface VerifiedOperator {
4
90
  id?: string;
5
91
  verified: boolean;
6
92
  label?: string;
7
93
  }
8
- interface FeedAnswerResult {
9
- status: 'delivered' | 'already_answered';
10
- receipt: MessageReceipt;
94
+ export interface ParsedAttentionKey {
95
+ host: string;
96
+ sessionId: string;
97
+ generation: string;
11
98
  }
99
+ /**
100
+ * Split `<host>/<session>/<generation>` (attention.ts `attentionKey`). Fails
101
+ * loud on a malformed key: the old `slice(0, indexOf('/'))` returned a truncated
102
+ * host for a key with no separator, which then routed the answer at random.
103
+ */
104
+ export declare function parseAttentionKey(key: string): ParsedAttentionKey;
105
+ /**
106
+ * Whether THIS machine owns the item. The exact local/remote choice: the key's
107
+ * host is compared through the same {@link normalizeHost} the machine id is
108
+ * minted with, so `Yosemite-M4.local` and `yosemite-m4` are one machine.
109
+ */
110
+ export declare function answerOwnerIsLocal(host: string, self?: string): boolean;
111
+ /**
112
+ * What a stored receipt proves. The lifecycle vocabulary is fixed by
113
+ * `MessageReceipt`, and each member means exactly one thing here:
114
+ * queued — a rail took the answer. Delivery, never resolution.
115
+ * consumed/continued— the agent itself acknowledged it. This resolves the item.
116
+ * dropped/expired — terminal failure; it is the newest truth for its message
117
+ * (the write rank puts it top precisely so it cannot be
118
+ * regressed), which is exactly why it must not read as success.
119
+ */
120
+ export declare function classifyReceipt(receipt: MessageReceipt): {
121
+ delivery: AnswerDelivery;
122
+ resolved: boolean;
123
+ };
124
+ /**
125
+ * Read-only reconciliation of an attention item's delivery state — what powers
126
+ * "Check delivery" on an unconfirmed answer. It NEVER claims, routes, adopts or
127
+ * resends; it reports the stored claim and the block's real receipt so an
128
+ * operator can tell "still unconfirmed" from "the agent has it".
129
+ */
130
+ export declare function checkAnswerDelivery(attentionKey: string, feedRoot?: string, expectedAttempt?: string): FeedAnswerResult;
12
131
  /** Atomically claim the first answer, then route it over the session's recorded reply rail. */
13
132
  export declare function claimAndRouteAttentionAnswer(input: {
14
133
  attentionKey: string;
@@ -18,13 +137,43 @@ export declare function claimAndRouteAttentionAnswer(input: {
18
137
  feedRoot?: string;
19
138
  mailboxRoot?: string;
20
139
  sessions?: ActiveSession[];
140
+ deadlineMs?: number;
21
141
  }): Promise<FeedAnswerResult>;
22
- /** Forward a fleet attention answer to the device that owns its scope. */
142
+ /**
143
+ * The remote `agents feed answer` argv for a forwarded answer. Exported so the
144
+ * exact tokens that cross the hop are asserted directly.
145
+ */
146
+ export declare function remoteAnswerArgv(input: {
147
+ attentionKey: string;
148
+ choiceId?: string;
149
+ text?: string;
150
+ operatorId?: string;
151
+ check?: boolean;
152
+ attempt?: string;
153
+ }): string[];
154
+ /**
155
+ * Forward a fleet attention answer to the device that owns its scope.
156
+ *
157
+ * Every token is POSIX-quoted with the canonical {@link shellQuote} before the
158
+ * remote login shell parses it, so a multiline answer or one carrying `$`, `"`,
159
+ * `` ` ``, `;` or a newline arrives byte-identical. The transport is the
160
+ * canonical bounded {@link sshExecAsync} — it disables ControlMaster whenever a
161
+ * timeout is set, so the bound actually tears the remote command down instead of
162
+ * orphaning it behind a control socket.
163
+ *
164
+ * A timeout is reported UNKNOWN: the remote may well have delivered before the
165
+ * link was cut, so the operator is offered a delivery check, never an implicit
166
+ * resend. The returned receipt is verified to be about the key that was asked
167
+ * for, so a mismatched or truncated remote reply cannot be trusted as one.
168
+ */
23
169
  export declare function forwardFeedAnswer(input: {
24
170
  host: string;
25
171
  attentionKey: string;
26
172
  choiceId?: string;
27
173
  text?: string;
28
174
  operatorId?: string;
175
+ check?: boolean;
176
+ attempt?: string;
177
+ timeoutMs?: number;
29
178
  }): Promise<FeedAnswerResult>;
30
179
  export {};