@usenaive-sdk/cli 0.15.1 → 1.0.1

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 (281) hide show
  1. package/README.md +43 -402
  2. package/dist/index.js +51796 -502
  3. package/package.json +22 -18
  4. package/dist/client.d.ts +0 -108
  5. package/dist/client.js +0 -458
  6. package/dist/client.js.map +0 -1
  7. package/dist/commands/account-kits.d.ts +0 -2
  8. package/dist/commands/account-kits.js +0 -71
  9. package/dist/commands/account-kits.js.map +0 -1
  10. package/dist/commands/aeo.d.ts +0 -2
  11. package/dist/commands/aeo.js +0 -451
  12. package/dist/commands/aeo.js.map +0 -1
  13. package/dist/commands/agent-profiles.d.ts +0 -11
  14. package/dist/commands/agent-profiles.js +0 -120
  15. package/dist/commands/agent-profiles.js.map +0 -1
  16. package/dist/commands/agents.d.ts +0 -2
  17. package/dist/commands/agents.js +0 -916
  18. package/dist/commands/agents.js.map +0 -1
  19. package/dist/commands/app-data.d.ts +0 -2
  20. package/dist/commands/app-data.js +0 -445
  21. package/dist/commands/app-data.js.map +0 -1
  22. package/dist/commands/approvals.d.ts +0 -2
  23. package/dist/commands/approvals.js +0 -242
  24. package/dist/commands/approvals.js.map +0 -1
  25. package/dist/commands/apps.d.ts +0 -9
  26. package/dist/commands/apps.js +0 -844
  27. package/dist/commands/apps.js.map +0 -1
  28. package/dist/commands/audio.d.ts +0 -9
  29. package/dist/commands/audio.js +0 -391
  30. package/dist/commands/audio.js.map +0 -1
  31. package/dist/commands/auth.d.ts +0 -31
  32. package/dist/commands/auth.js +0 -428
  33. package/dist/commands/auth.js.map +0 -1
  34. package/dist/commands/billing.d.ts +0 -2
  35. package/dist/commands/billing.js +0 -250
  36. package/dist/commands/billing.js.map +0 -1
  37. package/dist/commands/brain.d.ts +0 -2
  38. package/dist/commands/brain.js +0 -1300
  39. package/dist/commands/brain.js.map +0 -1
  40. package/dist/commands/browser.d.ts +0 -2
  41. package/dist/commands/browser.js +0 -378
  42. package/dist/commands/browser.js.map +0 -1
  43. package/dist/commands/business.d.ts +0 -2
  44. package/dist/commands/business.js +0 -566
  45. package/dist/commands/business.js.map +0 -1
  46. package/dist/commands/cards.d.ts +0 -2
  47. package/dist/commands/cards.js +0 -419
  48. package/dist/commands/cards.js.map +0 -1
  49. package/dist/commands/ceo.d.ts +0 -2
  50. package/dist/commands/ceo.js +0 -369
  51. package/dist/commands/ceo.js.map +0 -1
  52. package/dist/commands/clone.d.ts +0 -2
  53. package/dist/commands/clone.js +0 -203
  54. package/dist/commands/clone.js.map +0 -1
  55. package/dist/commands/companies.d.ts +0 -10
  56. package/dist/commands/companies.js +0 -283
  57. package/dist/commands/companies.js.map +0 -1
  58. package/dist/commands/company-data.d.ts +0 -2
  59. package/dist/commands/company-data.js +0 -168
  60. package/dist/commands/company-data.js.map +0 -1
  61. package/dist/commands/compute.d.ts +0 -2
  62. package/dist/commands/compute.js +0 -498
  63. package/dist/commands/compute.js.map +0 -1
  64. package/dist/commands/config.d.ts +0 -2
  65. package/dist/commands/config.js +0 -36
  66. package/dist/commands/config.js.map +0 -1
  67. package/dist/commands/connections.d.ts +0 -8
  68. package/dist/commands/connections.js +0 -137
  69. package/dist/commands/connections.js.map +0 -1
  70. package/dist/commands/cron-jobs.d.ts +0 -2
  71. package/dist/commands/cron-jobs.js +0 -245
  72. package/dist/commands/cron-jobs.js.map +0 -1
  73. package/dist/commands/domains.d.ts +0 -2
  74. package/dist/commands/domains.js +0 -474
  75. package/dist/commands/domains.js.map +0 -1
  76. package/dist/commands/ecommerce.d.ts +0 -2
  77. package/dist/commands/ecommerce.js +0 -277
  78. package/dist/commands/ecommerce.js.map +0 -1
  79. package/dist/commands/email.d.ts +0 -2
  80. package/dist/commands/email.js +0 -336
  81. package/dist/commands/email.js.map +0 -1
  82. package/dist/commands/employees.d.ts +0 -2
  83. package/dist/commands/employees.js +0 -190
  84. package/dist/commands/employees.js.map +0 -1
  85. package/dist/commands/env.d.ts +0 -7
  86. package/dist/commands/env.js +0 -112
  87. package/dist/commands/env.js.map +0 -1
  88. package/dist/commands/formation.d.ts +0 -2
  89. package/dist/commands/formation.js +0 -273
  90. package/dist/commands/formation.js.map +0 -1
  91. package/dist/commands/identity.d.ts +0 -2
  92. package/dist/commands/identity.js +0 -110
  93. package/dist/commands/identity.js.map +0 -1
  94. package/dist/commands/images.d.ts +0 -2
  95. package/dist/commands/images.js +0 -371
  96. package/dist/commands/images.js.map +0 -1
  97. package/dist/commands/init.d.ts +0 -5
  98. package/dist/commands/init.js +0 -43
  99. package/dist/commands/init.js.map +0 -1
  100. package/dist/commands/jobs.d.ts +0 -2
  101. package/dist/commands/jobs.js +0 -144
  102. package/dist/commands/jobs.js.map +0 -1
  103. package/dist/commands/keys.d.ts +0 -2
  104. package/dist/commands/keys.js +0 -156
  105. package/dist/commands/keys.js.map +0 -1
  106. package/dist/commands/legacy-auth.d.ts +0 -27
  107. package/dist/commands/legacy-auth.js +0 -64
  108. package/dist/commands/legacy-auth.js.map +0 -1
  109. package/dist/commands/llm.d.ts +0 -2
  110. package/dist/commands/llm.js +0 -125
  111. package/dist/commands/llm.js.map +0 -1
  112. package/dist/commands/login.d.ts +0 -2
  113. package/dist/commands/login.js +0 -65
  114. package/dist/commands/login.js.map +0 -1
  115. package/dist/commands/logout.d.ts +0 -7
  116. package/dist/commands/logout.js +0 -55
  117. package/dist/commands/logout.js.map +0 -1
  118. package/dist/commands/logs.d.ts +0 -2
  119. package/dist/commands/logs.js +0 -42
  120. package/dist/commands/logs.js.map +0 -1
  121. package/dist/commands/loops.d.ts +0 -2
  122. package/dist/commands/loops.js +0 -260
  123. package/dist/commands/loops.js.map +0 -1
  124. package/dist/commands/media.d.ts +0 -2
  125. package/dist/commands/media.js +0 -183
  126. package/dist/commands/media.js.map +0 -1
  127. package/dist/commands/memory.d.ts +0 -2
  128. package/dist/commands/memory.js +0 -151
  129. package/dist/commands/memory.js.map +0 -1
  130. package/dist/commands/mobile.d.ts +0 -4
  131. package/dist/commands/mobile.js +0 -382
  132. package/dist/commands/mobile.js.map +0 -1
  133. package/dist/commands/module.d.ts +0 -8
  134. package/dist/commands/module.js +0 -48
  135. package/dist/commands/module.js.map +0 -1
  136. package/dist/commands/objectives.d.ts +0 -2
  137. package/dist/commands/objectives.js +0 -243
  138. package/dist/commands/objectives.js.map +0 -1
  139. package/dist/commands/payments.d.ts +0 -2
  140. package/dist/commands/payments.js +0 -131
  141. package/dist/commands/payments.js.map +0 -1
  142. package/dist/commands/people.d.ts +0 -2
  143. package/dist/commands/people.js +0 -197
  144. package/dist/commands/people.js.map +0 -1
  145. package/dist/commands/phone.d.ts +0 -2
  146. package/dist/commands/phone.js +0 -289
  147. package/dist/commands/phone.js.map +0 -1
  148. package/dist/commands/projects.d.ts +0 -13
  149. package/dist/commands/projects.js +0 -220
  150. package/dist/commands/projects.js.map +0 -1
  151. package/dist/commands/queue.d.ts +0 -2
  152. package/dist/commands/queue.js +0 -121
  153. package/dist/commands/queue.js.map +0 -1
  154. package/dist/commands/register.d.ts +0 -2
  155. package/dist/commands/register.js +0 -88
  156. package/dist/commands/register.js.map +0 -1
  157. package/dist/commands/report.d.ts +0 -17
  158. package/dist/commands/report.js +0 -109
  159. package/dist/commands/report.js.map +0 -1
  160. package/dist/commands/sandbox.d.ts +0 -2
  161. package/dist/commands/sandbox.js +0 -558
  162. package/dist/commands/sandbox.js.map +0 -1
  163. package/dist/commands/search.d.ts +0 -2
  164. package/dist/commands/search.js +0 -223
  165. package/dist/commands/search.js.map +0 -1
  166. package/dist/commands/seo.d.ts +0 -2
  167. package/dist/commands/seo.js +0 -528
  168. package/dist/commands/seo.js.map +0 -1
  169. package/dist/commands/sessions.d.ts +0 -6
  170. package/dist/commands/sessions.js +0 -109
  171. package/dist/commands/sessions.js.map +0 -1
  172. package/dist/commands/social-data.d.ts +0 -2
  173. package/dist/commands/social-data.js +0 -245
  174. package/dist/commands/social-data.js.map +0 -1
  175. package/dist/commands/social.d.ts +0 -2
  176. package/dist/commands/social.js +0 -407
  177. package/dist/commands/social.js.map +0 -1
  178. package/dist/commands/status.d.ts +0 -2
  179. package/dist/commands/status.js +0 -79
  180. package/dist/commands/status.js.map +0 -1
  181. package/dist/commands/support.d.ts +0 -2
  182. package/dist/commands/support.js +0 -134
  183. package/dist/commands/support.js.map +0 -1
  184. package/dist/commands/tasks.d.ts +0 -2
  185. package/dist/commands/tasks.js +0 -409
  186. package/dist/commands/tasks.js.map +0 -1
  187. package/dist/commands/teams.d.ts +0 -69
  188. package/dist/commands/teams.js +0 -503
  189. package/dist/commands/teams.js.map +0 -1
  190. package/dist/commands/trading.d.ts +0 -2
  191. package/dist/commands/trading.js +0 -333
  192. package/dist/commands/trading.js.map +0 -1
  193. package/dist/commands/up.d.ts +0 -551
  194. package/dist/commands/up.js +0 -1149
  195. package/dist/commands/up.js.map +0 -1
  196. package/dist/commands/usage.d.ts +0 -2
  197. package/dist/commands/usage.js +0 -73
  198. package/dist/commands/usage.js.map +0 -1
  199. package/dist/commands/use.d.ts +0 -12
  200. package/dist/commands/use.js +0 -96
  201. package/dist/commands/use.js.map +0 -1
  202. package/dist/commands/users.d.ts +0 -10
  203. package/dist/commands/users.js +0 -82
  204. package/dist/commands/users.js.map +0 -1
  205. package/dist/commands/vault.d.ts +0 -2
  206. package/dist/commands/vault.js +0 -101
  207. package/dist/commands/vault.js.map +0 -1
  208. package/dist/commands/verification.d.ts +0 -2
  209. package/dist/commands/verification.js +0 -152
  210. package/dist/commands/verification.js.map +0 -1
  211. package/dist/commands/verify-email.d.ts +0 -19
  212. package/dist/commands/verify-email.js +0 -130
  213. package/dist/commands/verify-email.js.map +0 -1
  214. package/dist/commands/video.d.ts +0 -2
  215. package/dist/commands/video.js +0 -417
  216. package/dist/commands/video.js.map +0 -1
  217. package/dist/commands/voice.d.ts +0 -2
  218. package/dist/commands/voice.js +0 -516
  219. package/dist/commands/voice.js.map +0 -1
  220. package/dist/commands/wallet.d.ts +0 -2
  221. package/dist/commands/wallet.js +0 -244
  222. package/dist/commands/wallet.js.map +0 -1
  223. package/dist/commands/webhooks.d.ts +0 -13
  224. package/dist/commands/webhooks.js +0 -119
  225. package/dist/commands/webhooks.js.map +0 -1
  226. package/dist/commands/whoami.d.ts +0 -2
  227. package/dist/commands/whoami.js +0 -53
  228. package/dist/commands/whoami.js.map +0 -1
  229. package/dist/config.d.ts +0 -42
  230. package/dist/config.js +0 -83
  231. package/dist/config.js.map +0 -1
  232. package/dist/index.d.ts +0 -3
  233. package/dist/index.js.map +0 -1
  234. package/dist/lib/brain-select.d.ts +0 -193
  235. package/dist/lib/brain-select.js +0 -403
  236. package/dist/lib/brain-select.js.map +0 -1
  237. package/dist/lib/cli-validation.d.ts +0 -12
  238. package/dist/lib/cli-validation.js +0 -46
  239. package/dist/lib/cli-validation.js.map +0 -1
  240. package/dist/lib/config-errors.d.ts +0 -4
  241. package/dist/lib/config-errors.js +0 -13
  242. package/dist/lib/config-errors.js.map +0 -1
  243. package/dist/lib/deprecation.d.ts +0 -158
  244. package/dist/lib/deprecation.js +0 -140
  245. package/dist/lib/deprecation.js.map +0 -1
  246. package/dist/lib/duration.d.ts +0 -8
  247. package/dist/lib/duration.js +0 -11
  248. package/dist/lib/duration.js.map +0 -1
  249. package/dist/lib/http-response.d.ts +0 -11
  250. package/dist/lib/http-response.js +0 -96
  251. package/dist/lib/http-response.js.map +0 -1
  252. package/dist/lib/llm-paywall.d.ts +0 -82
  253. package/dist/lib/llm-paywall.js +0 -231
  254. package/dist/lib/llm-paywall.js.map +0 -1
  255. package/dist/lib/pricing.d.ts +0 -132
  256. package/dist/lib/pricing.js +0 -148
  257. package/dist/lib/pricing.js.map +0 -1
  258. package/dist/lib/starter-config.d.ts +0 -13
  259. package/dist/lib/starter-config.js +0 -71
  260. package/dist/lib/starter-config.js.map +0 -1
  261. package/dist/lib/stream-frames.d.ts +0 -114
  262. package/dist/lib/stream-frames.js +0 -169
  263. package/dist/lib/stream-frames.js.map +0 -1
  264. package/dist/lib/teams-catalog.d.ts +0 -141
  265. package/dist/lib/teams-catalog.js +0 -841
  266. package/dist/lib/teams-catalog.js.map +0 -1
  267. package/dist/lib/unknown-command.d.ts +0 -71
  268. package/dist/lib/unknown-command.js +0 -132
  269. package/dist/lib/unknown-command.js.map +0 -1
  270. package/dist/lib/version-check.d.ts +0 -26
  271. package/dist/lib/version-check.js +0 -21
  272. package/dist/lib/version-check.js.map +0 -1
  273. package/dist/output.d.ts +0 -246
  274. package/dist/output.js +0 -539
  275. package/dist/output.js.map +0 -1
  276. package/dist/prompt.d.ts +0 -17
  277. package/dist/prompt.js +0 -70
  278. package/dist/prompt.js.map +0 -1
  279. package/dist/version.d.ts +0 -2
  280. package/dist/version.js +0 -14
  281. package/dist/version.js.map +0 -1
@@ -1,114 +0,0 @@
1
- /**
2
- * `naive teams watch` — the pure half (06 §1.6).
3
- *
4
- * Everything here is a function of its input, so the framing, the resume
5
- * position, the redaction and the termination rule are tests rather than
6
- * behaviour you have to run a server to observe.
7
- *
8
- * THE OUTPUT IS NDJSON, ONE OBJECT PER LINE — not a JSON array. A stream has no
9
- * closing bracket, so an array can only be completed by a client that already
10
- * knows the stream ended, which is the one thing a consumer of a live stream
11
- * does not know.
12
- *
13
- * TERMINATION IS `{"type":"stream.end"}` WITH A REASON, NEVER `[DONE]`. That
14
- * token belongs to the OpenAI-compatible lane; reusing it here would make one
15
- * word mean two protocols.
16
- */
17
- /**
18
- * Secrets that must never reach a transcript.
19
- *
20
- * `nv_sk_…` is the platform api key — the same shape `output.ts` already guards
21
- * in `next_steps`. `vt_<company>_<hex>` is the per-team runtime credential, which
22
- * `output.ts` has never seen because nothing else prints one. A transcript prints
23
- * TOOL ARGUMENTS, so it is the one surface where either can arrive inside an
24
- * arbitrary payload rather than in a field with a known name.
25
- */
26
- export declare const SECRET_PATTERNS: readonly RegExp[];
27
- /**
28
- * Redact a decoded frame in place-free fashion.
29
- *
30
- * `showArgs` is false by default and the frame's `args` are replaced by whatever
31
- * `args_digest` the server sent. That is the honest default: a digest still lets
32
- * a reader correlate two frames, and it cannot leak a value nobody audited.
33
- * `commands/teams.ts` additionally refuses `--show-args` outside an interactive
34
- * terminal, so a pipe or a CI job cannot turn it on.
35
- */
36
- export declare function redactFrame(frame: unknown, opts: {
37
- showArgs: boolean;
38
- }): unknown;
39
- export interface SseEvent {
40
- /** The `id:` field, which is what a resume sends back as `Last-Event-ID`. */
41
- readonly id?: string;
42
- /** The concatenated `data:` lines. */
43
- readonly data: string;
44
- }
45
- /**
46
- * Split a buffer into complete SSE events, returning the unconsumed tail.
47
- *
48
- * The tail matters: a chunk boundary lands mid-event far more often than test
49
- * fixtures suggest, and a parser that discards a partial event drops exactly the
50
- * frames that arrive under load.
51
- */
52
- export declare function parseSse(buffer: string): {
53
- events: SseEvent[];
54
- rest: string;
55
- };
56
- /** The terminal states that are NOT success. `unverified` is the reason exit 3
57
- * exists at all: a CI script reading exit 0 as "the work is done" would count an
58
- * unattested task as a pass. */
59
- export declare const NON_SUCCESS_TERMINAL: readonly ["unverified", "failed", "blocked"];
60
- export type StreamEndReason = "run_terminal" | "client_closed" | "timeout" | "fence_closed";
61
- /**
62
- * The exit code for a finished stream. `--fail-on-terminal` is opt-in because
63
- * changing the exit code of an existing command is a wire break; without it a
64
- * watch always exits 0 and the caller reads `status` itself.
65
- */
66
- export declare function watchExitCode(finalStatus: string | undefined, failOnTerminal: boolean): 0 | 3;
67
- /**
68
- * One board card, in the three fields this gate is allowed to read.
69
- *
70
- * Deliberately structural and deliberately narrow: `extractCards` hands over
71
- * whatever the wire said, and a gate that reads more of a card than it needs is
72
- * a gate that breaks when an unrelated field is renamed.
73
- */
74
- export type GateCard = {
75
- status?: string;
76
- /** `durableCard`: naive adjudicated and the verdict never reached the runtime. */
77
- verdict_delivery_failed?: unknown;
78
- /** `durableCard`: naive granted a terminal the runtime does not hold. */
79
- boards_disagree?: unknown;
80
- };
81
- /**
82
- * Is this card's verification state anything other than SETTLED AND AGREED?
83
- *
84
- * 🔴 A CARD THE TWO BOARDS DISAGREE ABOUT IS NOT A VERIFIED CARD, and this gate
85
- * used to say it was. It read one field -- `status === "unverified"` -- and the
86
- * durable lane has two more that mean the verification did not conclude:
87
- *
88
- * - `verdict_delivery_failed`. naive REJECTED the card and the verdict did not
89
- * reach the runtime, so the runtime still holds its own terminal. The board
90
- * row carries the failure and says, in its own `meaning` field, that "the two
91
- * boards disagree about it".
92
- * - `boards_disagree`. naive granted a terminal the runtime does not hold, with
93
- * no delivery to fail -- an accept is written on naive's own row and is never
94
- * delivered, so this is the ONLY signal that case has. Its own text calls it
95
- * "the disagreement that bills for work the runtime says did not finish".
96
- *
97
- * Measured on staging: card A carried `verdict_delivery_failed` and
98
- * `naive teams tasks … --fail-on-unverified` exited 0 on it. A CI job reading
99
- * that exit code as "attested" is the exact failure this flag exists to prevent,
100
- * and the file's own history records it happening once already through a
101
- * different field (see `extractCards`).
102
- *
103
- * PRESENCE, not shape. Both fields are objects the server composes and neither is
104
- * ever emitted as a negative -- `durableCard` omits them entirely for a card with
105
- * nothing to report -- so asking whether one is there is the whole test, and it
106
- * cannot go stale when their contents change.
107
- */
108
- export declare function cardIsUnverified(card: GateCard): boolean;
109
- /** The same rule for a single board card, used by `tasks`/`task --fail-on-unverified`. */
110
- export declare function unverifiedExitCode(cards: readonly GateCard[], failOnUnverified: boolean): 0 | 3;
111
- /** The highest `seq` printed so far — the position a reconnect resumes from.
112
- * `sequence >` is strict on the server, so nothing is lost and nothing is
113
- * duplicated. */
114
- export declare function highestSeq(current: number | undefined, frame: unknown): number | undefined;
@@ -1,169 +0,0 @@
1
- /**
2
- * `naive teams watch` — the pure half (06 §1.6).
3
- *
4
- * Everything here is a function of its input, so the framing, the resume
5
- * position, the redaction and the termination rule are tests rather than
6
- * behaviour you have to run a server to observe.
7
- *
8
- * THE OUTPUT IS NDJSON, ONE OBJECT PER LINE — not a JSON array. A stream has no
9
- * closing bracket, so an array can only be completed by a client that already
10
- * knows the stream ended, which is the one thing a consumer of a live stream
11
- * does not know.
12
- *
13
- * TERMINATION IS `{"type":"stream.end"}` WITH A REASON, NEVER `[DONE]`. That
14
- * token belongs to the OpenAI-compatible lane; reusing it here would make one
15
- * word mean two protocols.
16
- */
17
- /**
18
- * Secrets that must never reach a transcript.
19
- *
20
- * `nv_sk_…` is the platform api key — the same shape `output.ts` already guards
21
- * in `next_steps`. `vt_<company>_<hex>` is the per-team runtime credential, which
22
- * `output.ts` has never seen because nothing else prints one. A transcript prints
23
- * TOOL ARGUMENTS, so it is the one surface where either can arrive inside an
24
- * arbitrary payload rather than in a field with a known name.
25
- */
26
- export const SECRET_PATTERNS = [
27
- /nv_sk_[A-Za-z0-9_-]+/g,
28
- /vt_[A-Za-z0-9-]+_[A-Fa-f0-9]{8,}/g,
29
- ];
30
- /** Field names whose VALUE is a secret whatever it looks like. */
31
- const SECRET_FIELDS = new Set(["api_key", "session_token", "token", "credential", "secret"]);
32
- const REDACTED = "[redacted]";
33
- function scrubString(s) {
34
- let out = s;
35
- for (const re of SECRET_PATTERNS)
36
- out = out.replace(new RegExp(re.source, re.flags), REDACTED);
37
- return out;
38
- }
39
- /**
40
- * Redact a decoded frame in place-free fashion.
41
- *
42
- * `showArgs` is false by default and the frame's `args` are replaced by whatever
43
- * `args_digest` the server sent. That is the honest default: a digest still lets
44
- * a reader correlate two frames, and it cannot leak a value nobody audited.
45
- * `commands/teams.ts` additionally refuses `--show-args` outside an interactive
46
- * terminal, so a pipe or a CI job cannot turn it on.
47
- */
48
- export function redactFrame(frame, opts) {
49
- const seen = new WeakSet();
50
- const walk = (v, key) => {
51
- if (typeof v === "string") {
52
- if (key !== undefined && SECRET_FIELDS.has(key))
53
- return REDACTED;
54
- return scrubString(v);
55
- }
56
- if (Array.isArray(v))
57
- return v.map((e) => walk(e));
58
- if (typeof v === "object" && v !== null) {
59
- if (seen.has(v))
60
- return "[circular]";
61
- seen.add(v);
62
- const out = {};
63
- for (const [k, val] of Object.entries(v)) {
64
- if (k === "args" && !opts.showArgs) {
65
- out.args = REDACTED;
66
- continue;
67
- }
68
- out[k] = walk(val, k);
69
- }
70
- return out;
71
- }
72
- return v;
73
- };
74
- return walk(frame);
75
- }
76
- /**
77
- * Split a buffer into complete SSE events, returning the unconsumed tail.
78
- *
79
- * The tail matters: a chunk boundary lands mid-event far more often than test
80
- * fixtures suggest, and a parser that discards a partial event drops exactly the
81
- * frames that arrive under load.
82
- */
83
- export function parseSse(buffer) {
84
- const events = [];
85
- // An event ends at a blank line. \r\n is legal per the spec and some proxies
86
- // rewrite line endings, so both are accepted.
87
- const parts = buffer.split(/\r?\n\r?\n/);
88
- const rest = parts.pop() ?? "";
89
- for (const block of parts) {
90
- let id;
91
- const data = [];
92
- for (const line of block.split(/\r?\n/)) {
93
- if (line.startsWith(":"))
94
- continue; // a comment / keep-alive
95
- const colon = line.indexOf(":");
96
- const field = colon === -1 ? line : line.slice(0, colon);
97
- const value = colon === -1 ? "" : line.slice(colon + 1).replace(/^ /, "");
98
- if (field === "data")
99
- data.push(value);
100
- else if (field === "id")
101
- id = value;
102
- }
103
- if (data.length > 0)
104
- events.push({ ...(id !== undefined && { id }), data: data.join("\n") });
105
- }
106
- return { events, rest };
107
- }
108
- /** The terminal states that are NOT success. `unverified` is the reason exit 3
109
- * exists at all: a CI script reading exit 0 as "the work is done" would count an
110
- * unattested task as a pass. */
111
- export const NON_SUCCESS_TERMINAL = ["unverified", "failed", "blocked"];
112
- /**
113
- * The exit code for a finished stream. `--fail-on-terminal` is opt-in because
114
- * changing the exit code of an existing command is a wire break; without it a
115
- * watch always exits 0 and the caller reads `status` itself.
116
- */
117
- export function watchExitCode(finalStatus, failOnTerminal) {
118
- if (!failOnTerminal || finalStatus === undefined)
119
- return 0;
120
- return NON_SUCCESS_TERMINAL.includes(finalStatus) ? 3 : 0;
121
- }
122
- /**
123
- * Is this card's verification state anything other than SETTLED AND AGREED?
124
- *
125
- * 🔴 A CARD THE TWO BOARDS DISAGREE ABOUT IS NOT A VERIFIED CARD, and this gate
126
- * used to say it was. It read one field -- `status === "unverified"` -- and the
127
- * durable lane has two more that mean the verification did not conclude:
128
- *
129
- * - `verdict_delivery_failed`. naive REJECTED the card and the verdict did not
130
- * reach the runtime, so the runtime still holds its own terminal. The board
131
- * row carries the failure and says, in its own `meaning` field, that "the two
132
- * boards disagree about it".
133
- * - `boards_disagree`. naive granted a terminal the runtime does not hold, with
134
- * no delivery to fail -- an accept is written on naive's own row and is never
135
- * delivered, so this is the ONLY signal that case has. Its own text calls it
136
- * "the disagreement that bills for work the runtime says did not finish".
137
- *
138
- * Measured on staging: card A carried `verdict_delivery_failed` and
139
- * `naive teams tasks … --fail-on-unverified` exited 0 on it. A CI job reading
140
- * that exit code as "attested" is the exact failure this flag exists to prevent,
141
- * and the file's own history records it happening once already through a
142
- * different field (see `extractCards`).
143
- *
144
- * PRESENCE, not shape. Both fields are objects the server composes and neither is
145
- * ever emitted as a negative -- `durableCard` omits them entirely for a card with
146
- * nothing to report -- so asking whether one is there is the whole test, and it
147
- * cannot go stale when their contents change.
148
- */
149
- export function cardIsUnverified(card) {
150
- return (card.status === "unverified" ||
151
- card.verdict_delivery_failed != null ||
152
- card.boards_disagree != null);
153
- }
154
- /** The same rule for a single board card, used by `tasks`/`task --fail-on-unverified`. */
155
- export function unverifiedExitCode(cards, failOnUnverified) {
156
- if (!failOnUnverified)
157
- return 0;
158
- return cards.some(cardIsUnverified) ? 3 : 0;
159
- }
160
- /** The highest `seq` printed so far — the position a reconnect resumes from.
161
- * `sequence >` is strict on the server, so nothing is lost and nothing is
162
- * duplicated. */
163
- export function highestSeq(current, frame) {
164
- const seq = frame?.seq;
165
- if (typeof seq !== "number" || !Number.isFinite(seq))
166
- return current;
167
- return current === undefined || seq > current ? seq : current;
168
- }
169
- //# sourceMappingURL=stream-frames.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream-frames.js","sourceRoot":"","sources":["../../src/lib/stream-frames.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;G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J,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,kBAAkB,CAAC,KAA0B,EAAE,gBAAyB;IACtF,IAAI,CAAC,gBAAgB;QAAE,OAAO,CAAC,CAAC;IAChC,OAAO,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED;;kBAEkB;AAClB,MAAM,UAAU,UAAU,CAAC,OAA2B,EAAE,KAAc;IACpE,MAAM,GAAG,GAAI,KAAkC,EAAE,GAAG,CAAC;IACrD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC;IACrE,OAAO,OAAO,KAAK,SAAS,IAAI,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC;AAChE,CAAC"}
@@ -1,141 +0,0 @@
1
- /**
2
- * THE ONE DECLARATION SITE for the `naive teams` surface (06 §1.4).
3
- *
4
- * Two design notes shipped two `teams` command sets and neither was a superset of
5
- * the other. Two hand-written lists is exactly the drift a one-declaration rule
6
- * exists to catch, so both are deleted and the union is declared once, here, as
7
- * DATA. `commands/teams.ts` builds the commander tree by walking this array; it
8
- * writes no subcommand of its own. A row added here is a working command, and a
9
- * command that is not a row here does not exist.
10
- *
11
- * ── WHY THIS IS A .ts FILE IN THIS PACKAGE AND NOT A GENERATED ARTIFACT ─────
12
- *
13
- * 06 §1.4 puts the declaration in `@usenaive/agent-contract/capabilities` and has
14
- * a generator emit `packages/cli/src/generated/teams-commands.ts` from it, so the
15
- * CLI subcommand, the MCP tool, the REST path and the openapi operation are all
16
- * one statement. MEASURED: there is no `packages/agent-contract` directory in
17
- * this tree and no generator to run, and this task owns `packages/cli` only. A
18
- * hand-written file that IMITATES a generated one — committed under `generated/`,
19
- * with nothing that regenerates it — is worse than an honest source file: the
20
- * next person edits it and their edit is silently the truth.
21
- *
22
- * So this is the honest intermediate: ONE declaration, inside the package that
23
- * consumes it, shaped so a future generator emits exactly this array. The fields
24
- * a generator would need and the CLI does not (`action`, `rest`, `mcp`,
25
- * `because`, `fenced`, `write`) are carried anyway, so the day the contract
26
- * package exists this file is deleted rather than reconciled.
27
- *
28
- * ── WHY IT MUST BE ONE LIST AND NOT 28 `.command()` CALLS ───────────────────
29
- *
30
- * `src/index.ts` calls `findUnknownSubcommand` BEFORE `parseAsync` and hard-fails
31
- * on an unrecognised subcommand even with `--help` appended. A subcommand list
32
- * that can drift from the thing that answers it therefore makes VALID commands
33
- * fail with `cli_outdated`, rather than degrading. One array, walked once, cannot
34
- * drift from itself.
35
- */
36
- /** Where a flag's value goes on the wire. `client` never leaves the process. */
37
- export type FlagIn = "query" | "body" | "path" | "client";
38
- export interface FlagSpec {
39
- /** Commander syntax, verbatim: `--status <status>` or `--follow`. */
40
- readonly flag: string;
41
- /** The key commander puts on the options object. */
42
- readonly key: string;
43
- readonly describe: string;
44
- readonly in: FlagIn;
45
- /** Wire field name. Defaults to `key`. */
46
- readonly field?: string;
47
- /** `requiredOption` rather than `option` — see `--because` below. */
48
- readonly required?: boolean;
49
- /** Parse the value as an integer before sending it. */
50
- readonly int?: boolean;
51
- /**
52
- * A boolean flag that SELECTS a value for a shared wire field instead of
53
- * sending its own name as a field.
54
- *
55
- * `--allow` is not a field this API has. The field is `decision` and `--allow`
56
- * is one of its two values (`POST …/approvals/:id/decide` throws
57
- * `invalid_input: decision must be "approve" or "deny"` on anything else). The
58
- * first spelling of this catalog declared `--allow` and `--deny` as ordinary
59
- * body flags, so the CLI sent `{"allow":true,"because":"…"}` and the one
60
- * mounted write on the whole `/v1/teams` surface could not be invoked at all.
61
- *
62
- * A flag declaring `value` MUST also declare `field`; flags sharing a `field`
63
- * form a mutually exclusive group, and `selectorGroups()` derives that group
64
- * rather than listing it, so a third value cannot be added without joining the
65
- * exclusion.
66
- */
67
- readonly value?: string;
68
- }
69
- export interface ArgSpec {
70
- /** Commander syntax, verbatim: `<team>` or `[channel]`. */
71
- readonly arg: string;
72
- /** The bare name, for path substitution and body keys. */
73
- readonly name: string;
74
- readonly describe: string;
75
- readonly in: "path" | "body";
76
- /** Wire field name. Defaults to `name`. */
77
- readonly field?: string;
78
- }
79
- export interface TeamOp {
80
- /** The subcommand name under `naive teams`. */
81
- readonly cli: string;
82
- readonly describe: string;
83
- /** The governance ActionId this op is evaluated as. */
84
- readonly action: string;
85
- readonly method: "GET" | "POST" | "DELETE";
86
- /** `{name}` placeholders are filled from `{team}`, `{tenant}` and path args. */
87
- readonly path: string;
88
- /** Does this op need `--tenant`? True for all 28 except `list` (R-4). */
89
- readonly tenant: boolean;
90
- /** Does it pass through the write fence? Printed in `--help`, not enforced here. */
91
- readonly fenced: boolean;
92
- readonly write: boolean;
93
- /** The MCP tool name, or `false` with a mandatory `because`. */
94
- readonly mcp: string | false;
95
- readonly because?: string;
96
- readonly args: readonly ArgSpec[];
97
- readonly flags: readonly FlagSpec[];
98
- /** Reads a stream rather than a JSON body. Exactly one op does. */
99
- readonly streams?: true;
100
- }
101
- export declare const TEAM_OPS: readonly TeamOp[];
102
- export declare class TeamOpError extends Error {
103
- }
104
- /** Every `{placeholder}` this op's path expects. */
105
- export declare function pathPlaceholders(op: TeamOp): string[];
106
- /**
107
- * Fill the path. Every value is `encodeURIComponent`'d — a team name or a card id
108
- * that contains a slash must not be able to reach a different route, and an
109
- * absent value is an error rather than the literal string "undefined" in a URL.
110
- */
111
- export declare function buildPath(op: TeamOp, values: Readonly<Record<string, string | undefined>>): string;
112
- /** The query string, including its leading `?`, or `""`. */
113
- export declare function buildQuery(op: TeamOp, opts: Readonly<Record<string, unknown>>): string;
114
- /**
115
- * The request body: positional args declared `in: "body"`, then flags declared
116
- * `in: "body"`. A GET has no body at all — a GET that carries one is a request
117
- * some proxy will strip and some server will ignore, which is a silent wrong
118
- * answer rather than an error.
119
- */
120
- export declare function buildBody(op: TeamOp, args: Readonly<Record<string, unknown>>, opts: Readonly<Record<string, unknown>>): Record<string, unknown> | undefined;
121
- /**
122
- * The mutually exclusive selector groups on this op, keyed by the wire field
123
- * they share. DERIVED from the flags rather than listed, so a third member added
124
- * to a group joins the exclusion without anyone remembering to widen a list.
125
- */
126
- export declare function selectorGroups(op: TeamOp): Map<string, FlagSpec[]>;
127
- /**
128
- * Refuse an ambiguous or absent decision BEFORE the request leaves the process.
129
- *
130
- * A selector group is a CHOICE: exactly one member must be given. Neither branch
131
- * can be left to the server. `--allow --deny` would otherwise resolve by flag
132
- * order in this file — an approval decided by declaration order — and giving
133
- * neither would send a body with no `decision`, which `settle` (whose openapi
134
- * marks nothing required) would accept as a well-formed request that settles an
135
- * effect no particular way.
136
- */
137
- export declare function assertSelectors(op: TeamOp, opts: Readonly<Record<string, unknown>>): void;
138
- /** `failOnTerminal` -> `fail_on_terminal`. Flags are camelCase in commander and
139
- * snake_case on this API's wire; converting in one place keeps the two apart. */
140
- export declare function snake(key: string): string;
141
- export declare function findOp(cli: string): TeamOp | undefined;