@claudexor/schema 3.4.1 → 3.5.0

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 (42) hide show
  1. package/dist/budget.d.ts +3 -0
  2. package/dist/budget.d.ts.map +1 -1
  3. package/dist/budget.js +4 -0
  4. package/dist/budget.js.map +1 -1
  5. package/dist/credential-profile-snapshot.d.ts +32 -14
  6. package/dist/credential-profile-snapshot.d.ts.map +1 -1
  7. package/dist/credential-store.d.ts +13 -0
  8. package/dist/credential-store.d.ts.map +1 -0
  9. package/dist/credential-store.js +15 -0
  10. package/dist/credential-store.js.map +1 -0
  11. package/dist/harness.d.ts +12 -5
  12. package/dist/harness.d.ts.map +1 -1
  13. package/dist/index.d.ts +2 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +2 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/quota.d.ts +75 -14
  18. package/dist/quota.d.ts.map +1 -1
  19. package/dist/quota.js +28 -2
  20. package/dist/quota.js.map +1 -1
  21. package/dist/setup-login-input.js +1 -1
  22. package/dist/setup-login-input.js.map +1 -1
  23. package/dist/setup-login.d.ts +446 -0
  24. package/dist/setup-login.d.ts.map +1 -0
  25. package/dist/setup-login.js +161 -0
  26. package/dist/setup-login.js.map +1 -0
  27. package/dist/setup.d.ts +130 -491
  28. package/dist/setup.d.ts.map +1 -1
  29. package/dist/setup.js +8 -138
  30. package/dist/setup.js.map +1 -1
  31. package/generated/BudgetObservation.schema.json +4 -0
  32. package/generated/ControlCredentialProfilesQueryResponse.schema.json +6 -2
  33. package/generated/ControlCredentialProfilesSnapshotResponse.schema.json +6 -2
  34. package/generated/ControlQuotaResponse.schema.json +6 -2
  35. package/generated/ControlSetupJob.schema.json +6 -1
  36. package/generated/ControlSetupJobCreateRequest.schema.json +2 -1
  37. package/generated/ControlSetupJobEvent.schema.json +6 -1
  38. package/generated/ControlSetupJobListFilter.schema.json +2 -1
  39. package/generated/ControlSetupJobListResponse.schema.json +6 -1
  40. package/generated/ControlSetupJobSnapshot.schema.json +6 -1
  41. package/generated/HarnessEvent.schema.json +5 -1
  42. package/package.json +2 -2
@@ -0,0 +1,446 @@
1
+ /**
2
+ * The internal, file-backed protocol between claudexord and the DETACHED
3
+ * native-login runner: the sealed manifest the runner executes, the transient
4
+ * device-code/URL disclosure it publishes, its observable state, the permit
5
+ * that authorizes the spawn, and its durable result. Split out of setup.ts so
6
+ * the control-plane setup DTOs and the runner wire contract each stay one
7
+ * readable file.
8
+ */
9
+ import { z } from "zod/v3";
10
+ /** Internal, file-backed protocol between claudexord and the detached native-login runner. */
11
+ export declare const SetupLoginProtocolVersion: z.ZodLiteral<2>;
12
+ export declare const SetupLoginManifest: z.ZodEffects<z.ZodObject<{
13
+ version: z.ZodLiteral<2>;
14
+ jobId: z.ZodString;
15
+ executionId: z.ZodString;
16
+ harness: z.ZodEnum<["codex", "claude", "cursor", "agy"]>;
17
+ jobDir: z.ZodString;
18
+ binary: z.ZodString;
19
+ args: z.ZodArray<z.ZodString, "many">;
20
+ cwd: z.ZodString;
21
+ /** Scoped config dir for an INV-135 profile login (claude CLAUDE_CONFIG_DIR /
22
+ * codex CODEX_HOME). OPTIONAL, not defaulted: absent on default-store jobs so
23
+ * pre-existing manifests keep their sealed digest across a daemon upgrade. */
24
+ profileConfigDir: z.ZodOptional<z.ZodString>;
25
+ /** How the runner performs the login: "terminal" (codex browser_redirect
26
+ * fallback only), "device_code" (codex app-server), "url_disclosure"
27
+ * (daemon-hosted, URL captured into the sidecar — cursor), or
28
+ * "url_disclosure_with_input" (same + one-shot stdin input — claude).
29
+ * OPTIONAL/undefaulted so pre-upgrade manifests keep their digest. */
30
+ loginMode: z.ZodOptional<z.ZodEnum<["terminal", "device_code", "url_disclosure", "url_disclosure_with_input"]>>;
31
+ /** Which app-server auth flow the device_code runner requests. Present only
32
+ * with loginMode "device_code". */
33
+ appServerFlow: z.ZodOptional<z.ZodEnum<["chatgptDeviceCode", "chatgpt"]>>;
34
+ /** Sidecar the runner writes its transient disclosure to; read by the
35
+ * daemon for the snapshot overlay, never journaled. device_code manifests
36
+ * REQUIRE it; terminal manifests MAY carry it (the runner then captures the
37
+ * vendor login's OAuth URL into it as an `oauth_url` disclosure). Optional
38
+ * so pre-upgrade sealed manifests keep their digest. */
39
+ deviceCodePath: z.ZodOptional<z.ZodString>;
40
+ /** One-shot input sidecar (url_disclosure_with_input only): transient,
41
+ * never journaled, delivered to the vendor CLI's stdin by the runner. */
42
+ inputPath: z.ZodOptional<z.ZodString>;
43
+ /** Whether the vendor reads its pasted code only from a REAL terminal
44
+ * (agy answers a plain pipe with "authentication required"); the runner
45
+ * then interposes a tty. Absent = a pipe, as every prior manifest. */
46
+ ptyStdin: z.ZodOptional<z.ZodBoolean>;
47
+ statePath: z.ZodString;
48
+ resultPath: z.ZodString;
49
+ permitPath: z.ZodString;
50
+ permitDeadlineAt: z.ZodString;
51
+ permitWaitMs: z.ZodOptional<z.ZodNumber>;
52
+ executable: z.ZodObject<{
53
+ realpath: z.ZodString;
54
+ sha256: z.ZodString;
55
+ size: z.ZodNumber;
56
+ mode: z.ZodNumber;
57
+ device: z.ZodString;
58
+ inode: z.ZodString;
59
+ }, "strict", z.ZodTypeAny, {
60
+ realpath: string;
61
+ sha256: string;
62
+ size: number;
63
+ mode: number;
64
+ device: string;
65
+ inode: string;
66
+ }, {
67
+ realpath: string;
68
+ sha256: string;
69
+ size: number;
70
+ mode: number;
71
+ device: string;
72
+ inode: string;
73
+ }>;
74
+ commandDigest: z.ZodString;
75
+ manifestDigest: z.ZodString;
76
+ }, "strict", z.ZodTypeAny, {
77
+ version: 2;
78
+ jobId: string;
79
+ executionId: string;
80
+ harness: "agy" | "claude" | "codex" | "cursor";
81
+ jobDir: string;
82
+ binary: string;
83
+ args: string[];
84
+ cwd: string;
85
+ profileConfigDir?: string | undefined;
86
+ loginMode?: "device_code" | "terminal" | "url_disclosure" | "url_disclosure_with_input" | undefined;
87
+ appServerFlow?: "chatgpt" | "chatgptDeviceCode" | undefined;
88
+ deviceCodePath?: string | undefined;
89
+ inputPath?: string | undefined;
90
+ ptyStdin?: boolean | undefined;
91
+ statePath: string;
92
+ resultPath: string;
93
+ permitPath: string;
94
+ permitDeadlineAt: string;
95
+ permitWaitMs?: number | undefined;
96
+ executable: {
97
+ realpath: string;
98
+ sha256: string;
99
+ size: number;
100
+ mode: number;
101
+ device: string;
102
+ inode: string;
103
+ };
104
+ commandDigest: string;
105
+ manifestDigest: string;
106
+ }, {
107
+ version: 2;
108
+ jobId: string;
109
+ executionId: string;
110
+ harness: "agy" | "claude" | "codex" | "cursor";
111
+ jobDir: string;
112
+ binary: string;
113
+ args: string[];
114
+ cwd: string;
115
+ profileConfigDir?: string | undefined;
116
+ loginMode?: "device_code" | "terminal" | "url_disclosure" | "url_disclosure_with_input" | undefined;
117
+ appServerFlow?: "chatgpt" | "chatgptDeviceCode" | undefined;
118
+ deviceCodePath?: string | undefined;
119
+ inputPath?: string | undefined;
120
+ ptyStdin?: boolean | undefined;
121
+ statePath: string;
122
+ resultPath: string;
123
+ permitPath: string;
124
+ permitDeadlineAt: string;
125
+ permitWaitMs?: number | undefined;
126
+ executable: {
127
+ realpath: string;
128
+ sha256: string;
129
+ size: number;
130
+ mode: number;
131
+ device: string;
132
+ inode: string;
133
+ };
134
+ commandDigest: string;
135
+ manifestDigest: string;
136
+ }>, {
137
+ version: 2;
138
+ jobId: string;
139
+ executionId: string;
140
+ harness: "agy" | "claude" | "codex" | "cursor";
141
+ jobDir: string;
142
+ binary: string;
143
+ args: string[];
144
+ cwd: string;
145
+ profileConfigDir?: string | undefined;
146
+ loginMode?: "device_code" | "terminal" | "url_disclosure" | "url_disclosure_with_input" | undefined;
147
+ appServerFlow?: "chatgpt" | "chatgptDeviceCode" | undefined;
148
+ deviceCodePath?: string | undefined;
149
+ inputPath?: string | undefined;
150
+ ptyStdin?: boolean | undefined;
151
+ statePath: string;
152
+ resultPath: string;
153
+ permitPath: string;
154
+ permitDeadlineAt: string;
155
+ permitWaitMs?: number | undefined;
156
+ executable: {
157
+ realpath: string;
158
+ sha256: string;
159
+ size: number;
160
+ mode: number;
161
+ device: string;
162
+ inode: string;
163
+ };
164
+ commandDigest: string;
165
+ manifestDigest: string;
166
+ }, {
167
+ version: 2;
168
+ jobId: string;
169
+ executionId: string;
170
+ harness: "agy" | "claude" | "codex" | "cursor";
171
+ jobDir: string;
172
+ binary: string;
173
+ args: string[];
174
+ cwd: string;
175
+ profileConfigDir?: string | undefined;
176
+ loginMode?: "device_code" | "terminal" | "url_disclosure" | "url_disclosure_with_input" | undefined;
177
+ appServerFlow?: "chatgpt" | "chatgptDeviceCode" | undefined;
178
+ deviceCodePath?: string | undefined;
179
+ inputPath?: string | undefined;
180
+ ptyStdin?: boolean | undefined;
181
+ statePath: string;
182
+ resultPath: string;
183
+ permitPath: string;
184
+ permitDeadlineAt: string;
185
+ permitWaitMs?: number | undefined;
186
+ executable: {
187
+ realpath: string;
188
+ sha256: string;
189
+ size: number;
190
+ mode: number;
191
+ device: string;
192
+ inode: string;
193
+ };
194
+ commandDigest: string;
195
+ manifestDigest: string;
196
+ }>;
197
+ export type SetupLoginManifest = z.infer<typeof SetupLoginManifest>;
198
+ /**
199
+ * TRANSIENT device-code sidecar the device_code runner writes after
200
+ * `account/login/start` succeeds. Bound to the job + execution like the state
201
+ * sidecar. The daemon reads it to overlay {@link SetupDeviceCodeDisclosure} on
202
+ * snapshots/SSE; its `userCode` is NEVER journaled, logged, or copied into the
203
+ * durable result receipt (INV-062 / D-17).
204
+ */
205
+ export declare const SetupLoginDeviceCode: z.ZodObject<{
206
+ version: z.ZodLiteral<2>;
207
+ jobId: z.ZodString;
208
+ executionId: z.ZodString;
209
+ flow: z.ZodEnum<["chatgptDeviceCode", "chatgpt", "oauth_url", "oauth_url_input"]>;
210
+ verificationUrl: z.ZodString;
211
+ userCode: z.ZodString;
212
+ disclosedAt: z.ZodString;
213
+ }, "strict", z.ZodTypeAny, {
214
+ version: 2;
215
+ jobId: string;
216
+ executionId: string;
217
+ flow: "chatgpt" | "chatgptDeviceCode" | "oauth_url" | "oauth_url_input";
218
+ verificationUrl: string;
219
+ userCode: string;
220
+ disclosedAt: string;
221
+ }, {
222
+ version: 2;
223
+ jobId: string;
224
+ executionId: string;
225
+ flow: "chatgpt" | "chatgptDeviceCode" | "oauth_url" | "oauth_url_input";
226
+ verificationUrl: string;
227
+ userCode: string;
228
+ disclosedAt: string;
229
+ }>;
230
+ export type SetupLoginDeviceCode = z.infer<typeof SetupLoginDeviceCode>;
231
+ export declare const SetupLoginRunnerState: z.ZodObject<{
232
+ version: z.ZodLiteral<2>;
233
+ jobId: z.ZodString;
234
+ executionId: z.ZodString;
235
+ processGroup: z.ZodEffects<z.ZodObject<{
236
+ schemaVersion: z.ZodLiteral<1>;
237
+ pgid: z.ZodNumber;
238
+ leader: z.ZodObject<{
239
+ status: z.ZodLiteral<"known">;
240
+ pid: z.ZodNumber;
241
+ platform: z.ZodEnum<["linux", "darwin", "win32"]>;
242
+ source: z.ZodEnum<["procfs_stat", "proc_pidinfo", "win32_process_times"]>;
243
+ startToken: z.ZodString;
244
+ processGroupId: z.ZodNumber;
245
+ }, "strict", z.ZodTypeAny, {
246
+ status: "known";
247
+ pid: number;
248
+ platform: "darwin" | "linux" | "win32";
249
+ source: "proc_pidinfo" | "procfs_stat" | "win32_process_times";
250
+ startToken: string;
251
+ processGroupId: number;
252
+ }, {
253
+ status: "known";
254
+ pid: number;
255
+ platform: "darwin" | "linux" | "win32";
256
+ source: "proc_pidinfo" | "procfs_stat" | "win32_process_times";
257
+ startToken: string;
258
+ processGroupId: number;
259
+ }>;
260
+ }, "strict", z.ZodTypeAny, {
261
+ schemaVersion: 1;
262
+ pgid: number;
263
+ leader: {
264
+ status: "known";
265
+ pid: number;
266
+ platform: "darwin" | "linux" | "win32";
267
+ source: "proc_pidinfo" | "procfs_stat" | "win32_process_times";
268
+ startToken: string;
269
+ processGroupId: number;
270
+ };
271
+ }, {
272
+ schemaVersion: 1;
273
+ pgid: number;
274
+ leader: {
275
+ status: "known";
276
+ pid: number;
277
+ platform: "darwin" | "linux" | "win32";
278
+ source: "proc_pidinfo" | "procfs_stat" | "win32_process_times";
279
+ startToken: string;
280
+ processGroupId: number;
281
+ };
282
+ }>, {
283
+ schemaVersion: 1;
284
+ pgid: number;
285
+ leader: {
286
+ status: "known";
287
+ pid: number;
288
+ platform: "darwin" | "linux" | "win32";
289
+ source: "proc_pidinfo" | "procfs_stat" | "win32_process_times";
290
+ startToken: string;
291
+ processGroupId: number;
292
+ };
293
+ }, {
294
+ schemaVersion: 1;
295
+ pgid: number;
296
+ leader: {
297
+ status: "known";
298
+ pid: number;
299
+ platform: "darwin" | "linux" | "win32";
300
+ source: "proc_pidinfo" | "procfs_stat" | "win32_process_times";
301
+ startToken: string;
302
+ processGroupId: number;
303
+ };
304
+ }>;
305
+ stage: z.ZodEnum<["awaiting_permit", "running"]>;
306
+ observedAt: z.ZodString;
307
+ commandDigest: z.ZodString;
308
+ manifestDigest: z.ZodString;
309
+ }, "strict", z.ZodTypeAny, {
310
+ version: 2;
311
+ jobId: string;
312
+ executionId: string;
313
+ processGroup: {
314
+ schemaVersion: 1;
315
+ pgid: number;
316
+ leader: {
317
+ status: "known";
318
+ pid: number;
319
+ platform: "darwin" | "linux" | "win32";
320
+ source: "proc_pidinfo" | "procfs_stat" | "win32_process_times";
321
+ startToken: string;
322
+ processGroupId: number;
323
+ };
324
+ };
325
+ stage: "awaiting_permit" | "running";
326
+ observedAt: string;
327
+ commandDigest: string;
328
+ manifestDigest: string;
329
+ }, {
330
+ version: 2;
331
+ jobId: string;
332
+ executionId: string;
333
+ processGroup: {
334
+ schemaVersion: 1;
335
+ pgid: number;
336
+ leader: {
337
+ status: "known";
338
+ pid: number;
339
+ platform: "darwin" | "linux" | "win32";
340
+ source: "proc_pidinfo" | "procfs_stat" | "win32_process_times";
341
+ startToken: string;
342
+ processGroupId: number;
343
+ };
344
+ };
345
+ stage: "awaiting_permit" | "running";
346
+ observedAt: string;
347
+ commandDigest: string;
348
+ manifestDigest: string;
349
+ }>;
350
+ export type SetupLoginRunnerState = z.infer<typeof SetupLoginRunnerState>;
351
+ export declare const SetupLoginPermit: z.ZodObject<{
352
+ version: z.ZodLiteral<2>;
353
+ jobId: z.ZodString;
354
+ executionId: z.ZodString;
355
+ issuedAt: z.ZodString;
356
+ commandDigest: z.ZodString;
357
+ manifestDigest: z.ZodString;
358
+ }, "strict", z.ZodTypeAny, {
359
+ version: 2;
360
+ jobId: string;
361
+ executionId: string;
362
+ issuedAt: string;
363
+ commandDigest: string;
364
+ manifestDigest: string;
365
+ }, {
366
+ version: 2;
367
+ jobId: string;
368
+ executionId: string;
369
+ issuedAt: string;
370
+ commandDigest: string;
371
+ manifestDigest: string;
372
+ }>;
373
+ export type SetupLoginPermit = z.infer<typeof SetupLoginPermit>;
374
+ export declare const SetupLoginRunnerResult: z.ZodEffects<z.ZodObject<{
375
+ executionId: z.ZodString;
376
+ commandDigest: z.ZodString;
377
+ manifestDigest: z.ZodString;
378
+ permitIssuedAt: z.ZodNullable<z.ZodString>;
379
+ commandStarted: z.ZodBoolean;
380
+ exitCode: z.ZodNullable<z.ZodNumber>;
381
+ signal: z.ZodNullable<z.ZodString>;
382
+ errorCode: z.ZodOptional<z.ZodEnum<["permit_timeout", "spawn_failed", "device_auth_unsupported"]>>;
383
+ finishedAt: z.ZodString;
384
+ version: z.ZodLiteral<2>;
385
+ jobId: z.ZodString;
386
+ /** Bounded, ANSI-stripped tail of the vendor command's captured output —
387
+ * diagnostic evidence for classifying a failed login (e.g. the device-code
388
+ * toggle being disabled). RESULT-FILE ONLY: the durable control receipt
389
+ * deliberately does not carry it (the ≤600-char slice in the failure
390
+ * message is the only journal/API exposure). Only tee'd flows (codex). */
391
+ outputTail: z.ZodOptional<z.ZodString>;
392
+ }, "strict", z.ZodTypeAny, {
393
+ executionId: string;
394
+ commandDigest: string;
395
+ manifestDigest: string;
396
+ permitIssuedAt: string | null;
397
+ commandStarted: boolean;
398
+ exitCode: number | null;
399
+ signal: string | null;
400
+ errorCode?: "device_auth_unsupported" | "permit_timeout" | "spawn_failed" | undefined;
401
+ finishedAt: string;
402
+ version: 2;
403
+ jobId: string;
404
+ outputTail?: string | undefined;
405
+ }, {
406
+ executionId: string;
407
+ commandDigest: string;
408
+ manifestDigest: string;
409
+ permitIssuedAt: string | null;
410
+ commandStarted: boolean;
411
+ exitCode: number | null;
412
+ signal: string | null;
413
+ errorCode?: "device_auth_unsupported" | "permit_timeout" | "spawn_failed" | undefined;
414
+ finishedAt: string;
415
+ version: 2;
416
+ jobId: string;
417
+ outputTail?: string | undefined;
418
+ }>, {
419
+ executionId: string;
420
+ commandDigest: string;
421
+ manifestDigest: string;
422
+ permitIssuedAt: string | null;
423
+ commandStarted: boolean;
424
+ exitCode: number | null;
425
+ signal: string | null;
426
+ errorCode?: "device_auth_unsupported" | "permit_timeout" | "spawn_failed" | undefined;
427
+ finishedAt: string;
428
+ version: 2;
429
+ jobId: string;
430
+ outputTail?: string | undefined;
431
+ }, {
432
+ executionId: string;
433
+ commandDigest: string;
434
+ manifestDigest: string;
435
+ permitIssuedAt: string | null;
436
+ commandStarted: boolean;
437
+ exitCode: number | null;
438
+ signal: string | null;
439
+ errorCode?: "device_auth_unsupported" | "permit_timeout" | "spawn_failed" | undefined;
440
+ finishedAt: string;
441
+ version: 2;
442
+ jobId: string;
443
+ outputTail?: string | undefined;
444
+ }>;
445
+ export type SetupLoginRunnerResult = z.infer<typeof SetupLoginRunnerResult>;
446
+ //# sourceMappingURL=setup-login.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-login.d.ts","sourceRoot":"","sources":["../src/setup-login.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAe3B,8FAA8F;AAC9F,eAAO,MAAM,yBAAyB,iBAAe,CAAC;AAEtD,eAAO,MAAM,kBAAkB;;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backed protocol between claudexord and the DETACHED
3
+ * native-login runner: the sealed manifest the runner executes, the transient
4
+ * device-code/URL disclosure it publishes, its observable state, the permit
5
+ * that authorizes the spawn, and its durable result. Split out of setup.ts so
6
+ * the control-plane setup DTOs and the runner wire contract each stay one
7
+ * readable file.
8
+ */
9
+ import { z } from "zod/v3";
10
+ import { harnessHasDefaultCredentialStore } from "./credential-store.js";
11
+ import * as SetupLoginProtocol from "./setup-login-protocol.js";
12
+ import { ControlHarnessSetupHarness, SetupAppServerLoginFlow, SetupExecutableEvidence, SetupLoginDisclosureFlow, SetupNativeCommandReceipt, SetupNativeCommandReceiptShape, SetupProcessGroupHandle, SetupTimestamp, Sha256Hex, } from "./setup.js";
13
+ /** Internal, file-backed protocol between claudexord and the detached native-login runner. */
14
+ export const SetupLoginProtocolVersion = z.literal(2);
15
+ export const SetupLoginManifest = z
16
+ .object({
17
+ version: SetupLoginProtocolVersion,
18
+ jobId: SetupLoginProtocol.SetupLoginJobId,
19
+ executionId: SetupLoginProtocol.SetupLoginExecutionId,
20
+ harness: ControlHarnessSetupHarness,
21
+ jobDir: SetupLoginProtocol.SetupLoginAbsolutePath,
22
+ binary: SetupLoginProtocol.SetupLoginAbsolutePath,
23
+ args: z.array(z.string()),
24
+ cwd: SetupLoginProtocol.SetupLoginAbsolutePath,
25
+ /** Scoped config dir for an INV-135 profile login (claude CLAUDE_CONFIG_DIR /
26
+ * codex CODEX_HOME). OPTIONAL, not defaulted: absent on default-store jobs so
27
+ * pre-existing manifests keep their sealed digest across a daemon upgrade. */
28
+ profileConfigDir: SetupLoginProtocol.SetupLoginAbsolutePath.optional(),
29
+ /** How the runner performs the login: "terminal" (codex browser_redirect
30
+ * fallback only), "device_code" (codex app-server), "url_disclosure"
31
+ * (daemon-hosted, URL captured into the sidecar — cursor), or
32
+ * "url_disclosure_with_input" (same + one-shot stdin input — claude).
33
+ * OPTIONAL/undefaulted so pre-upgrade manifests keep their digest. */
34
+ loginMode: z
35
+ .enum(["terminal", "device_code", "url_disclosure", "url_disclosure_with_input"])
36
+ .optional(),
37
+ /** Which app-server auth flow the device_code runner requests. Present only
38
+ * with loginMode "device_code". */
39
+ appServerFlow: SetupAppServerLoginFlow.optional(),
40
+ /** Sidecar the runner writes its transient disclosure to; read by the
41
+ * daemon for the snapshot overlay, never journaled. device_code manifests
42
+ * REQUIRE it; terminal manifests MAY carry it (the runner then captures the
43
+ * vendor login's OAuth URL into it as an `oauth_url` disclosure). Optional
44
+ * so pre-upgrade sealed manifests keep their digest. */
45
+ deviceCodePath: SetupLoginProtocol.SetupLoginAbsolutePath.optional(),
46
+ /** One-shot input sidecar (url_disclosure_with_input only): transient,
47
+ * never journaled, delivered to the vendor CLI's stdin by the runner. */
48
+ inputPath: SetupLoginProtocol.SetupLoginAbsolutePath.optional(),
49
+ /** Whether the vendor reads its pasted code only from a REAL terminal
50
+ * (agy answers a plain pipe with "authentication required"); the runner
51
+ * then interposes a tty. Absent = a pipe, as every prior manifest. */
52
+ ptyStdin: z.boolean().optional(),
53
+ statePath: SetupLoginProtocol.SetupLoginAbsolutePath,
54
+ resultPath: SetupLoginProtocol.SetupLoginAbsolutePath,
55
+ permitPath: SetupLoginProtocol.SetupLoginAbsolutePath,
56
+ permitDeadlineAt: SetupTimestamp,
57
+ permitWaitMs: SetupLoginProtocol.SetupClientPtyPermitWaitMs,
58
+ executable: SetupExecutableEvidence,
59
+ commandDigest: Sha256Hex,
60
+ manifestDigest: Sha256Hex,
61
+ })
62
+ .strict()
63
+ .superRefine((value, context) => {
64
+ const deny = (path, message) => context.addIssue({ code: z.ZodIssueCode.custom, path, message });
65
+ const deviceCode = value.loginMode === "device_code";
66
+ const urlDisclosure = value.loginMode === "url_disclosure" || value.loginMode === "url_disclosure_with_input";
67
+ if (deviceCode && value.harness !== "codex")
68
+ deny(["loginMode"], "device_code login mode exists only for the codex app-server");
69
+ if (deviceCode && (!value.appServerFlow || !value.deviceCodePath))
70
+ deny(["appServerFlow"], "device_code manifests require appServerFlow and deviceCodePath");
71
+ // deviceCodePath is legal on terminal manifests too (the runner captures
72
+ // the vendor login's OAuth URL into it); only the app-server flow selector
73
+ // stays device_code-exclusive.
74
+ if (!deviceCode && value.appServerFlow)
75
+ deny(["appServerFlow"], "appServerFlow requires loginMode device_code");
76
+ if (urlDisclosure && !value.deviceCodePath)
77
+ deny(["deviceCodePath"], "url_disclosure manifests require the disclosure sidecar path");
78
+ if ((value.loginMode === "url_disclosure_with_input") !== (value.inputPath !== undefined))
79
+ deny(["inputPath"], "inputPath rides url_disclosure_with_input manifests, exactly");
80
+ // A tty exists only to deliver the pasted code; claiming it elsewhere
81
+ // would wrap a login that never reads stdin.
82
+ // A harness with no default credential store has nowhere to sign in
83
+ // EXCEPT a named profile, so a manifest without one is malformed rather
84
+ // than merely unlucky — the runner would otherwise fail opaquely and the
85
+ // reason (INV-135 / owner decision Л-4) would never reach the user.
86
+ if (!harnessHasDefaultCredentialStore(value.harness) && !value.profileConfigDir)
87
+ deny(["profileConfigDir"], `${value.harness} has no default credential store: its login manifest must target a named profile HOME`);
88
+ if (value.ptyStdin && value.loginMode !== "url_disclosure_with_input")
89
+ deny(["ptyStdin"], "ptyStdin exists only for url_disclosure_with_input manifests");
90
+ });
91
+ /**
92
+ * TRANSIENT device-code sidecar the device_code runner writes after
93
+ * `account/login/start` succeeds. Bound to the job + execution like the state
94
+ * sidecar. The daemon reads it to overlay {@link SetupDeviceCodeDisclosure} on
95
+ * snapshots/SSE; its `userCode` is NEVER journaled, logged, or copied into the
96
+ * durable result receipt (INV-062 / D-17).
97
+ */
98
+ export const SetupLoginDeviceCode = z
99
+ .object({
100
+ version: SetupLoginProtocolVersion,
101
+ jobId: SetupLoginProtocol.SetupLoginJobId,
102
+ executionId: SetupLoginProtocol.SetupLoginExecutionId,
103
+ flow: SetupLoginDisclosureFlow,
104
+ verificationUrl: z.string().url(),
105
+ userCode: z.string(),
106
+ disclosedAt: SetupTimestamp,
107
+ })
108
+ .strict();
109
+ export const SetupLoginRunnerState = z
110
+ .object({
111
+ version: SetupLoginProtocolVersion,
112
+ jobId: SetupLoginProtocol.SetupLoginJobId,
113
+ executionId: SetupLoginProtocol.SetupLoginExecutionId,
114
+ processGroup: SetupProcessGroupHandle,
115
+ stage: z.enum(["awaiting_permit", "running"]),
116
+ observedAt: SetupTimestamp,
117
+ commandDigest: Sha256Hex,
118
+ manifestDigest: Sha256Hex,
119
+ })
120
+ .strict();
121
+ export const SetupLoginPermit = z
122
+ .object({
123
+ version: SetupLoginProtocolVersion,
124
+ jobId: SetupLoginProtocol.SetupLoginJobId,
125
+ executionId: SetupLoginProtocol.SetupLoginExecutionId,
126
+ issuedAt: SetupTimestamp,
127
+ commandDigest: Sha256Hex,
128
+ manifestDigest: Sha256Hex,
129
+ })
130
+ .strict();
131
+ export const SetupLoginRunnerResult = z
132
+ .object({
133
+ version: SetupLoginProtocolVersion,
134
+ jobId: SetupLoginProtocol.SetupLoginJobId,
135
+ ...SetupNativeCommandReceiptShape,
136
+ /** Bounded, ANSI-stripped tail of the vendor command's captured output —
137
+ * diagnostic evidence for classifying a failed login (e.g. the device-code
138
+ * toggle being disabled). RESULT-FILE ONLY: the durable control receipt
139
+ * deliberately does not carry it (the ≤600-char slice in the failure
140
+ * message is the only journal/API exposure). Only tee'd flows (codex). */
141
+ outputTail: z.string().max(4000).optional(),
142
+ })
143
+ .strict()
144
+ .superRefine((value, context) => {
145
+ const parsed = SetupNativeCommandReceipt.safeParse({
146
+ executionId: value.executionId,
147
+ commandDigest: value.commandDigest,
148
+ manifestDigest: value.manifestDigest,
149
+ permitIssuedAt: value.permitIssuedAt,
150
+ commandStarted: value.commandStarted,
151
+ exitCode: value.exitCode,
152
+ signal: value.signal,
153
+ ...(value.errorCode ? { errorCode: value.errorCode } : {}),
154
+ finishedAt: value.finishedAt,
155
+ });
156
+ if (!parsed.success) {
157
+ for (const issue of parsed.error.issues)
158
+ context.addIssue(issue);
159
+ }
160
+ });
161
+ //# sourceMappingURL=setup-login.js.map
@@ -0,0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