@agent-watch-ai/edge 0.3.1 → 0.4.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.
- package/CHANGELOG.md +46 -0
- package/README.md +7 -3
- package/SECURITY.md +7 -4
- package/dist/cli/constants/cli.constants.d.ts +2 -0
- package/dist/cli/constants/cli.constants.js +3 -1
- package/dist/cli/doctor.js +13 -2
- package/dist/cli/setup.js +138 -29
- package/dist/cli/toggle.js +5 -1
- package/dist/cli/types/cli.types.d.ts +6 -0
- package/dist/cli/uninstall.js +1 -1
- package/dist/cli.js +14 -3
- package/dist/config/config-store.d.ts +1 -1
- package/dist/config/config-store.js +1 -1
- package/dist/config/constants/config.constants.d.ts +4 -1
- package/dist/config/constants/config.constants.js +7 -2
- package/dist/config/schemas/config.schema.d.ts +110 -0
- package/dist/config/schemas/config.schema.js +12 -3
- package/dist/credentials/constants/credentials.constants.d.ts +8 -0
- package/dist/credentials/constants/credentials.constants.js +9 -1
- package/dist/credentials/credential-status.js +8 -4
- package/dist/credentials/credentials.d.ts +16 -2
- package/dist/credentials/credentials.js +28 -3
- package/dist/credentials/device-api.d.ts +10 -1
- package/dist/credentials/device-api.js +12 -1
- package/dist/credentials/identity.d.ts +12 -1
- package/dist/credentials/identity.js +12 -1
- package/dist/credentials/migration.d.ts +1 -1
- package/dist/credentials/migration.js +1 -1
- package/dist/credentials/sign-in.d.ts +14 -1
- package/dist/credentials/sign-in.js +24 -5
- package/dist/credentials/types/credentials.types.d.ts +12 -1
- package/dist/enforcement/decision-client.js +2 -1
- package/dist/enforcement/enforcement.js +7 -5
- package/dist/enforcement/types/enforcement.types.d.ts +2 -2
- package/dist/pipeline/constants/pipeline.constants.d.ts +3 -0
- package/dist/pipeline/constants/pipeline.constants.js +3 -0
- package/dist/pipeline/hook-pipeline.js +56 -7
- package/dist/privacy/product-capture.js +2 -0
- package/dist/providers/codex/codex.otel.d.ts +12 -1
- package/dist/providers/codex/codex.otel.js +61 -11
- package/dist/providers/codex/constants/codex.otel.constants.d.ts +5 -0
- package/dist/providers/codex/constants/codex.otel.constants.js +5 -0
- package/dist/providers/constants/provider.constants.d.ts +8 -0
- package/dist/providers/constants/provider.constants.js +8 -0
- package/dist/providers/cursor/constants/cursor.constants.d.ts +2 -0
- package/dist/providers/cursor/constants/cursor.constants.js +2 -0
- package/dist/providers/cursor/cursor.adapter.js +79 -3
- package/dist/providers/gemini/constants/gemini.otel.constants.d.ts +6 -0
- package/dist/providers/gemini/constants/gemini.otel.constants.js +6 -0
- package/dist/providers/gemini/gemini.otel.d.ts +11 -1
- package/dist/providers/gemini/gemini.otel.js +52 -12
- package/dist/providers/shared/bearer-rewrite.d.ts +19 -0
- package/dist/providers/shared/bearer-rewrite.js +46 -0
- package/dist/providers/shared/constants/tooling.constants.d.ts +6 -0
- package/dist/providers/shared/constants/tooling.constants.js +6 -0
- package/dist/providers/shared/tooling.d.ts +28 -0
- package/dist/providers/shared/tooling.js +52 -1
- package/dist/providers/types/provider.types.d.ts +24 -0
- package/dist/storage/atomic-file.d.ts +14 -0
- package/dist/storage/atomic-file.js +19 -0
- package/dist/storage/constants/storage.constants.d.ts +2 -0
- package/dist/storage/constants/storage.constants.js +2 -0
- package/dist/turns/work-checkout.d.ts +5 -3
- package/dist/turns/work-checkout.js +46 -12
- package/docs/DATA_HANDLING.md +11 -4
- package/docs/ENTERPRISE_DEPLOYMENT.md +19 -4
- package/package.json +1 -1
|
@@ -158,7 +158,10 @@ export declare const RE_TRAILING_SLASHES: RegExp;
|
|
|
158
158
|
export declare const ROUTE_FIELDS: readonly ["eventsUrl", "otlpUrl", "enforcementUrl"];
|
|
159
159
|
/** The fields that hold an identity's credential; a root naming one replaces both. */
|
|
160
160
|
export declare const CREDENTIAL_KEYS: ReadonlySet<string>;
|
|
161
|
-
/**
|
|
161
|
+
/**
|
|
162
|
+
* The device credential reference, removed by uninstall, with the organization
|
|
163
|
+
* it was enrolled in: left behind, it would read as an install waiting for a sign-in.
|
|
164
|
+
*/
|
|
162
165
|
export declare const DEVICE_KEY: ReadonlySet<string>;
|
|
163
166
|
/** One writer of config.json at a time: setup, uninstall and a hook's exchange. */
|
|
164
167
|
export declare const CONFIG_LOCK = "config";
|
|
@@ -116,6 +116,8 @@ export const GLOBAL_ONLY_KEYS = new Set([
|
|
|
116
116
|
// wrong store would leave every hook there with no bearer and every prompt
|
|
117
117
|
// unchecked, a one-line budget-cap bypass.
|
|
118
118
|
'device',
|
|
119
|
+
// Beside no credential it stops every hook: never a repository's to set.
|
|
120
|
+
'organizationId',
|
|
119
121
|
'installationId',
|
|
120
122
|
'developerEmail',
|
|
121
123
|
'developerName',
|
|
@@ -177,8 +179,11 @@ export const RE_TRAILING_SLASHES = /\/+$/;
|
|
|
177
179
|
export const ROUTE_FIELDS = ['eventsUrl', 'otlpUrl', 'enforcementUrl'];
|
|
178
180
|
/** The fields that hold an identity's credential; a root naming one replaces both. */
|
|
179
181
|
export const CREDENTIAL_KEYS = new Set(['token', 'device']);
|
|
180
|
-
/**
|
|
181
|
-
|
|
182
|
+
/**
|
|
183
|
+
* The device credential reference, removed by uninstall, with the organization
|
|
184
|
+
* it was enrolled in: left behind, it would read as an install waiting for a sign-in.
|
|
185
|
+
*/
|
|
186
|
+
export const DEVICE_KEY = new Set(['device', 'organizationId']);
|
|
182
187
|
/** One writer of config.json at a time: setup, uninstall and a hook's exchange. */
|
|
183
188
|
export const CONFIG_LOCK = 'config';
|
|
184
189
|
/** How long setup and uninstall wait for a hook holding the config lock; a hook holds it for one read and one write. */
|
|
@@ -33,6 +33,8 @@ export declare const captureSchema: z.ZodObject<{
|
|
|
33
33
|
sessionTitle: z.ZodDefault<z.ZodBoolean>;
|
|
34
34
|
git: z.ZodDefault<z.ZodBoolean>;
|
|
35
35
|
files: z.ZodDefault<z.ZodBoolean>;
|
|
36
|
+
/** MCP server and tool names in `tools_used`; false folds them into `mcp`. Metadata, not content. */
|
|
37
|
+
mcpNames: z.ZodDefault<z.ZodBoolean>;
|
|
36
38
|
}, "strip", z.ZodTypeAny, {
|
|
37
39
|
promptText: boolean;
|
|
38
40
|
toolInput: boolean;
|
|
@@ -40,6 +42,7 @@ export declare const captureSchema: z.ZodObject<{
|
|
|
40
42
|
sessionTitle: boolean;
|
|
41
43
|
git: boolean;
|
|
42
44
|
files: boolean;
|
|
45
|
+
mcpNames: boolean;
|
|
43
46
|
}, {
|
|
44
47
|
promptText?: boolean | undefined;
|
|
45
48
|
toolInput?: boolean | undefined;
|
|
@@ -47,6 +50,7 @@ export declare const captureSchema: z.ZodObject<{
|
|
|
47
50
|
sessionTitle?: boolean | undefined;
|
|
48
51
|
git?: boolean | undefined;
|
|
49
52
|
files?: boolean | undefined;
|
|
53
|
+
mcpNames?: boolean | undefined;
|
|
50
54
|
}>;
|
|
51
55
|
/** Tuning for the in-hook send and the machine-global offline queue. */
|
|
52
56
|
export declare const deliverySchema: z.ZodObject<{
|
|
@@ -216,14 +220,20 @@ export declare const rootOverrideSchema: z.ZodObject<{
|
|
|
216
220
|
id: z.ZodString;
|
|
217
221
|
store: z.ZodEnum<["macos-keychain", "libsecret", "windows-dpapi", "file"]>;
|
|
218
222
|
endpoint: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
223
|
+
source: z.ZodCatch<z.ZodOptional<z.ZodLiteral<"batch-code">>>;
|
|
224
|
+
codeId: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
219
225
|
}, "strip", z.ZodTypeAny, {
|
|
220
226
|
id: string;
|
|
221
227
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
222
228
|
endpoint?: string | undefined;
|
|
229
|
+
source?: "batch-code" | undefined;
|
|
230
|
+
codeId?: string | undefined;
|
|
223
231
|
}, {
|
|
224
232
|
id: string;
|
|
225
233
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
226
234
|
endpoint?: unknown;
|
|
235
|
+
source?: unknown;
|
|
236
|
+
codeId?: unknown;
|
|
227
237
|
}>>>;
|
|
228
238
|
installationId: z.ZodOptional<z.ZodString>;
|
|
229
239
|
developerEmail: z.ZodOptional<z.ZodString>;
|
|
@@ -237,6 +247,8 @@ export declare const rootOverrideSchema: z.ZodObject<{
|
|
|
237
247
|
id: string;
|
|
238
248
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
239
249
|
endpoint?: string | undefined;
|
|
250
|
+
source?: "batch-code" | undefined;
|
|
251
|
+
codeId?: string | undefined;
|
|
240
252
|
} | undefined;
|
|
241
253
|
installationId?: string | undefined;
|
|
242
254
|
developerEmail?: string | undefined;
|
|
@@ -266,15 +278,26 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
266
278
|
id: z.ZodString;
|
|
267
279
|
store: z.ZodEnum<["macos-keychain", "libsecret", "windows-dpapi", "file"]>;
|
|
268
280
|
endpoint: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
281
|
+
source: z.ZodCatch<z.ZodOptional<z.ZodLiteral<"batch-code">>>;
|
|
282
|
+
codeId: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
269
283
|
}, "strip", z.ZodTypeAny, {
|
|
270
284
|
id: string;
|
|
271
285
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
272
286
|
endpoint?: string | undefined;
|
|
287
|
+
source?: "batch-code" | undefined;
|
|
288
|
+
codeId?: string | undefined;
|
|
273
289
|
}, {
|
|
274
290
|
id: string;
|
|
275
291
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
276
292
|
endpoint?: unknown;
|
|
293
|
+
source?: unknown;
|
|
294
|
+
codeId?: unknown;
|
|
277
295
|
}>>>;
|
|
296
|
+
/**
|
|
297
|
+
* The organization an enrollment URL named. Beside no credential it marks an
|
|
298
|
+
* MDM install whose developer has not signed in yet: it sends nothing.
|
|
299
|
+
*/
|
|
300
|
+
organizationId: z.ZodOptional<z.ZodString>;
|
|
278
301
|
installationId: z.ZodOptional<z.ZodString>;
|
|
279
302
|
/** Developer identity attached to turn summaries; falls back to `git config user.email`. */
|
|
280
303
|
developerEmail: z.ZodOptional<z.ZodString>;
|
|
@@ -297,14 +320,20 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
297
320
|
id: z.ZodString;
|
|
298
321
|
store: z.ZodEnum<["macos-keychain", "libsecret", "windows-dpapi", "file"]>;
|
|
299
322
|
endpoint: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
323
|
+
source: z.ZodCatch<z.ZodOptional<z.ZodLiteral<"batch-code">>>;
|
|
324
|
+
codeId: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
300
325
|
}, "strip", z.ZodTypeAny, {
|
|
301
326
|
id: string;
|
|
302
327
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
303
328
|
endpoint?: string | undefined;
|
|
329
|
+
source?: "batch-code" | undefined;
|
|
330
|
+
codeId?: string | undefined;
|
|
304
331
|
}, {
|
|
305
332
|
id: string;
|
|
306
333
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
307
334
|
endpoint?: unknown;
|
|
335
|
+
source?: unknown;
|
|
336
|
+
codeId?: unknown;
|
|
308
337
|
}>>>;
|
|
309
338
|
installationId: z.ZodOptional<z.ZodString>;
|
|
310
339
|
developerEmail: z.ZodOptional<z.ZodString>;
|
|
@@ -318,6 +347,8 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
318
347
|
id: string;
|
|
319
348
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
320
349
|
endpoint?: string | undefined;
|
|
350
|
+
source?: "batch-code" | undefined;
|
|
351
|
+
codeId?: string | undefined;
|
|
321
352
|
} | undefined;
|
|
322
353
|
installationId?: string | undefined;
|
|
323
354
|
developerEmail?: string | undefined;
|
|
@@ -354,6 +385,8 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
354
385
|
sessionTitle: z.ZodDefault<z.ZodBoolean>;
|
|
355
386
|
git: z.ZodDefault<z.ZodBoolean>;
|
|
356
387
|
files: z.ZodDefault<z.ZodBoolean>;
|
|
388
|
+
/** MCP server and tool names in `tools_used`; false folds them into `mcp`. Metadata, not content. */
|
|
389
|
+
mcpNames: z.ZodDefault<z.ZodBoolean>;
|
|
357
390
|
}, "strip", z.ZodTypeAny, {
|
|
358
391
|
promptText: boolean;
|
|
359
392
|
toolInput: boolean;
|
|
@@ -361,6 +394,7 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
361
394
|
sessionTitle: boolean;
|
|
362
395
|
git: boolean;
|
|
363
396
|
files: boolean;
|
|
397
|
+
mcpNames: boolean;
|
|
364
398
|
}, {
|
|
365
399
|
promptText?: boolean | undefined;
|
|
366
400
|
toolInput?: boolean | undefined;
|
|
@@ -368,6 +402,7 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
368
402
|
sessionTitle?: boolean | undefined;
|
|
369
403
|
git?: boolean | undefined;
|
|
370
404
|
files?: boolean | undefined;
|
|
405
|
+
mcpNames?: boolean | undefined;
|
|
371
406
|
}>>;
|
|
372
407
|
emit: z.ZodDefault<z.ZodObject<{
|
|
373
408
|
/** One flat summary per prompt→response turn, emitted on Stop. */
|
|
@@ -448,15 +483,26 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
448
483
|
id: z.ZodString;
|
|
449
484
|
store: z.ZodEnum<["macos-keychain", "libsecret", "windows-dpapi", "file"]>;
|
|
450
485
|
endpoint: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
486
|
+
source: z.ZodCatch<z.ZodOptional<z.ZodLiteral<"batch-code">>>;
|
|
487
|
+
codeId: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
451
488
|
}, "strip", z.ZodTypeAny, {
|
|
452
489
|
id: string;
|
|
453
490
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
454
491
|
endpoint?: string | undefined;
|
|
492
|
+
source?: "batch-code" | undefined;
|
|
493
|
+
codeId?: string | undefined;
|
|
455
494
|
}, {
|
|
456
495
|
id: string;
|
|
457
496
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
458
497
|
endpoint?: unknown;
|
|
498
|
+
source?: unknown;
|
|
499
|
+
codeId?: unknown;
|
|
459
500
|
}>>>;
|
|
501
|
+
/**
|
|
502
|
+
* The organization an enrollment URL named. Beside no credential it marks an
|
|
503
|
+
* MDM install whose developer has not signed in yet: it sends nothing.
|
|
504
|
+
*/
|
|
505
|
+
organizationId: z.ZodOptional<z.ZodString>;
|
|
460
506
|
installationId: z.ZodOptional<z.ZodString>;
|
|
461
507
|
/** Developer identity attached to turn summaries; falls back to `git config user.email`. */
|
|
462
508
|
developerEmail: z.ZodOptional<z.ZodString>;
|
|
@@ -479,14 +525,20 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
479
525
|
id: z.ZodString;
|
|
480
526
|
store: z.ZodEnum<["macos-keychain", "libsecret", "windows-dpapi", "file"]>;
|
|
481
527
|
endpoint: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
528
|
+
source: z.ZodCatch<z.ZodOptional<z.ZodLiteral<"batch-code">>>;
|
|
529
|
+
codeId: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
482
530
|
}, "strip", z.ZodTypeAny, {
|
|
483
531
|
id: string;
|
|
484
532
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
485
533
|
endpoint?: string | undefined;
|
|
534
|
+
source?: "batch-code" | undefined;
|
|
535
|
+
codeId?: string | undefined;
|
|
486
536
|
}, {
|
|
487
537
|
id: string;
|
|
488
538
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
489
539
|
endpoint?: unknown;
|
|
540
|
+
source?: unknown;
|
|
541
|
+
codeId?: unknown;
|
|
490
542
|
}>>>;
|
|
491
543
|
installationId: z.ZodOptional<z.ZodString>;
|
|
492
544
|
developerEmail: z.ZodOptional<z.ZodString>;
|
|
@@ -500,6 +552,8 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
500
552
|
id: string;
|
|
501
553
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
502
554
|
endpoint?: string | undefined;
|
|
555
|
+
source?: "batch-code" | undefined;
|
|
556
|
+
codeId?: string | undefined;
|
|
503
557
|
} | undefined;
|
|
504
558
|
installationId?: string | undefined;
|
|
505
559
|
developerEmail?: string | undefined;
|
|
@@ -536,6 +590,8 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
536
590
|
sessionTitle: z.ZodDefault<z.ZodBoolean>;
|
|
537
591
|
git: z.ZodDefault<z.ZodBoolean>;
|
|
538
592
|
files: z.ZodDefault<z.ZodBoolean>;
|
|
593
|
+
/** MCP server and tool names in `tools_used`; false folds them into `mcp`. Metadata, not content. */
|
|
594
|
+
mcpNames: z.ZodDefault<z.ZodBoolean>;
|
|
539
595
|
}, "strip", z.ZodTypeAny, {
|
|
540
596
|
promptText: boolean;
|
|
541
597
|
toolInput: boolean;
|
|
@@ -543,6 +599,7 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
543
599
|
sessionTitle: boolean;
|
|
544
600
|
git: boolean;
|
|
545
601
|
files: boolean;
|
|
602
|
+
mcpNames: boolean;
|
|
546
603
|
}, {
|
|
547
604
|
promptText?: boolean | undefined;
|
|
548
605
|
toolInput?: boolean | undefined;
|
|
@@ -550,6 +607,7 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
550
607
|
sessionTitle?: boolean | undefined;
|
|
551
608
|
git?: boolean | undefined;
|
|
552
609
|
files?: boolean | undefined;
|
|
610
|
+
mcpNames?: boolean | undefined;
|
|
553
611
|
}>>;
|
|
554
612
|
emit: z.ZodDefault<z.ZodObject<{
|
|
555
613
|
/** One flat summary per prompt→response turn, emitted on Stop. */
|
|
@@ -630,15 +688,26 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
630
688
|
id: z.ZodString;
|
|
631
689
|
store: z.ZodEnum<["macos-keychain", "libsecret", "windows-dpapi", "file"]>;
|
|
632
690
|
endpoint: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
691
|
+
source: z.ZodCatch<z.ZodOptional<z.ZodLiteral<"batch-code">>>;
|
|
692
|
+
codeId: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
633
693
|
}, "strip", z.ZodTypeAny, {
|
|
634
694
|
id: string;
|
|
635
695
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
636
696
|
endpoint?: string | undefined;
|
|
697
|
+
source?: "batch-code" | undefined;
|
|
698
|
+
codeId?: string | undefined;
|
|
637
699
|
}, {
|
|
638
700
|
id: string;
|
|
639
701
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
640
702
|
endpoint?: unknown;
|
|
703
|
+
source?: unknown;
|
|
704
|
+
codeId?: unknown;
|
|
641
705
|
}>>>;
|
|
706
|
+
/**
|
|
707
|
+
* The organization an enrollment URL named. Beside no credential it marks an
|
|
708
|
+
* MDM install whose developer has not signed in yet: it sends nothing.
|
|
709
|
+
*/
|
|
710
|
+
organizationId: z.ZodOptional<z.ZodString>;
|
|
642
711
|
installationId: z.ZodOptional<z.ZodString>;
|
|
643
712
|
/** Developer identity attached to turn summaries; falls back to `git config user.email`. */
|
|
644
713
|
developerEmail: z.ZodOptional<z.ZodString>;
|
|
@@ -661,14 +730,20 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
661
730
|
id: z.ZodString;
|
|
662
731
|
store: z.ZodEnum<["macos-keychain", "libsecret", "windows-dpapi", "file"]>;
|
|
663
732
|
endpoint: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
733
|
+
source: z.ZodCatch<z.ZodOptional<z.ZodLiteral<"batch-code">>>;
|
|
734
|
+
codeId: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
664
735
|
}, "strip", z.ZodTypeAny, {
|
|
665
736
|
id: string;
|
|
666
737
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
667
738
|
endpoint?: string | undefined;
|
|
739
|
+
source?: "batch-code" | undefined;
|
|
740
|
+
codeId?: string | undefined;
|
|
668
741
|
}, {
|
|
669
742
|
id: string;
|
|
670
743
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
671
744
|
endpoint?: unknown;
|
|
745
|
+
source?: unknown;
|
|
746
|
+
codeId?: unknown;
|
|
672
747
|
}>>>;
|
|
673
748
|
installationId: z.ZodOptional<z.ZodString>;
|
|
674
749
|
developerEmail: z.ZodOptional<z.ZodString>;
|
|
@@ -682,6 +757,8 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
682
757
|
id: string;
|
|
683
758
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
684
759
|
endpoint?: string | undefined;
|
|
760
|
+
source?: "batch-code" | undefined;
|
|
761
|
+
codeId?: string | undefined;
|
|
685
762
|
} | undefined;
|
|
686
763
|
installationId?: string | undefined;
|
|
687
764
|
developerEmail?: string | undefined;
|
|
@@ -718,6 +795,8 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
718
795
|
sessionTitle: z.ZodDefault<z.ZodBoolean>;
|
|
719
796
|
git: z.ZodDefault<z.ZodBoolean>;
|
|
720
797
|
files: z.ZodDefault<z.ZodBoolean>;
|
|
798
|
+
/** MCP server and tool names in `tools_used`; false folds them into `mcp`. Metadata, not content. */
|
|
799
|
+
mcpNames: z.ZodDefault<z.ZodBoolean>;
|
|
721
800
|
}, "strip", z.ZodTypeAny, {
|
|
722
801
|
promptText: boolean;
|
|
723
802
|
toolInput: boolean;
|
|
@@ -725,6 +804,7 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
725
804
|
sessionTitle: boolean;
|
|
726
805
|
git: boolean;
|
|
727
806
|
files: boolean;
|
|
807
|
+
mcpNames: boolean;
|
|
728
808
|
}, {
|
|
729
809
|
promptText?: boolean | undefined;
|
|
730
810
|
toolInput?: boolean | undefined;
|
|
@@ -732,6 +812,7 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
732
812
|
sessionTitle?: boolean | undefined;
|
|
733
813
|
git?: boolean | undefined;
|
|
734
814
|
files?: boolean | undefined;
|
|
815
|
+
mcpNames?: boolean | undefined;
|
|
735
816
|
}>>;
|
|
736
817
|
emit: z.ZodDefault<z.ZodObject<{
|
|
737
818
|
/** One flat summary per prompt→response turn, emitted on Stop. */
|
|
@@ -806,6 +887,7 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
806
887
|
sessionTitle: boolean;
|
|
807
888
|
git: boolean;
|
|
808
889
|
files: boolean;
|
|
890
|
+
mcpNames: boolean;
|
|
809
891
|
};
|
|
810
892
|
otel: {
|
|
811
893
|
logs: boolean;
|
|
@@ -848,6 +930,8 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
848
930
|
id: string;
|
|
849
931
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
850
932
|
endpoint?: string | undefined;
|
|
933
|
+
source?: "batch-code" | undefined;
|
|
934
|
+
codeId?: string | undefined;
|
|
851
935
|
} | undefined;
|
|
852
936
|
installationId?: string | undefined;
|
|
853
937
|
developerEmail?: string | undefined;
|
|
@@ -857,7 +941,10 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
857
941
|
id: string;
|
|
858
942
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
859
943
|
endpoint?: string | undefined;
|
|
944
|
+
source?: "batch-code" | undefined;
|
|
945
|
+
codeId?: string | undefined;
|
|
860
946
|
} | undefined;
|
|
947
|
+
organizationId?: string | undefined;
|
|
861
948
|
installationId?: string | undefined;
|
|
862
949
|
developerEmail?: string | undefined;
|
|
863
950
|
developerName?: string | undefined;
|
|
@@ -875,15 +962,26 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
875
962
|
id: z.ZodString;
|
|
876
963
|
store: z.ZodEnum<["macos-keychain", "libsecret", "windows-dpapi", "file"]>;
|
|
877
964
|
endpoint: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
965
|
+
source: z.ZodCatch<z.ZodOptional<z.ZodLiteral<"batch-code">>>;
|
|
966
|
+
codeId: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
878
967
|
}, "strip", z.ZodTypeAny, {
|
|
879
968
|
id: string;
|
|
880
969
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
881
970
|
endpoint?: string | undefined;
|
|
971
|
+
source?: "batch-code" | undefined;
|
|
972
|
+
codeId?: string | undefined;
|
|
882
973
|
}, {
|
|
883
974
|
id: string;
|
|
884
975
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
885
976
|
endpoint?: unknown;
|
|
977
|
+
source?: unknown;
|
|
978
|
+
codeId?: unknown;
|
|
886
979
|
}>>>;
|
|
980
|
+
/**
|
|
981
|
+
* The organization an enrollment URL named. Beside no credential it marks an
|
|
982
|
+
* MDM install whose developer has not signed in yet: it sends nothing.
|
|
983
|
+
*/
|
|
984
|
+
organizationId: z.ZodOptional<z.ZodString>;
|
|
887
985
|
installationId: z.ZodOptional<z.ZodString>;
|
|
888
986
|
/** Developer identity attached to turn summaries; falls back to `git config user.email`. */
|
|
889
987
|
developerEmail: z.ZodOptional<z.ZodString>;
|
|
@@ -906,14 +1004,20 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
906
1004
|
id: z.ZodString;
|
|
907
1005
|
store: z.ZodEnum<["macos-keychain", "libsecret", "windows-dpapi", "file"]>;
|
|
908
1006
|
endpoint: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
1007
|
+
source: z.ZodCatch<z.ZodOptional<z.ZodLiteral<"batch-code">>>;
|
|
1008
|
+
codeId: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
909
1009
|
}, "strip", z.ZodTypeAny, {
|
|
910
1010
|
id: string;
|
|
911
1011
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
912
1012
|
endpoint?: string | undefined;
|
|
1013
|
+
source?: "batch-code" | undefined;
|
|
1014
|
+
codeId?: string | undefined;
|
|
913
1015
|
}, {
|
|
914
1016
|
id: string;
|
|
915
1017
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
916
1018
|
endpoint?: unknown;
|
|
1019
|
+
source?: unknown;
|
|
1020
|
+
codeId?: unknown;
|
|
917
1021
|
}>>>;
|
|
918
1022
|
installationId: z.ZodOptional<z.ZodString>;
|
|
919
1023
|
developerEmail: z.ZodOptional<z.ZodString>;
|
|
@@ -927,6 +1031,8 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
927
1031
|
id: string;
|
|
928
1032
|
store: "macos-keychain" | "libsecret" | "windows-dpapi" | "file";
|
|
929
1033
|
endpoint?: string | undefined;
|
|
1034
|
+
source?: "batch-code" | undefined;
|
|
1035
|
+
codeId?: string | undefined;
|
|
930
1036
|
} | undefined;
|
|
931
1037
|
installationId?: string | undefined;
|
|
932
1038
|
developerEmail?: string | undefined;
|
|
@@ -963,6 +1069,8 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
963
1069
|
sessionTitle: z.ZodDefault<z.ZodBoolean>;
|
|
964
1070
|
git: z.ZodDefault<z.ZodBoolean>;
|
|
965
1071
|
files: z.ZodDefault<z.ZodBoolean>;
|
|
1072
|
+
/** MCP server and tool names in `tools_used`; false folds them into `mcp`. Metadata, not content. */
|
|
1073
|
+
mcpNames: z.ZodDefault<z.ZodBoolean>;
|
|
966
1074
|
}, "strip", z.ZodTypeAny, {
|
|
967
1075
|
promptText: boolean;
|
|
968
1076
|
toolInput: boolean;
|
|
@@ -970,6 +1078,7 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
970
1078
|
sessionTitle: boolean;
|
|
971
1079
|
git: boolean;
|
|
972
1080
|
files: boolean;
|
|
1081
|
+
mcpNames: boolean;
|
|
973
1082
|
}, {
|
|
974
1083
|
promptText?: boolean | undefined;
|
|
975
1084
|
toolInput?: boolean | undefined;
|
|
@@ -977,6 +1086,7 @@ export declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
977
1086
|
sessionTitle?: boolean | undefined;
|
|
978
1087
|
git?: boolean | undefined;
|
|
979
1088
|
files?: boolean | undefined;
|
|
1089
|
+
mcpNames?: boolean | undefined;
|
|
980
1090
|
}>>;
|
|
981
1091
|
emit: z.ZodDefault<z.ZodObject<{
|
|
982
1092
|
/** One flat summary per prompt→response turn, emitted on Stop. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { asRecord } from '../../core/object.js';
|
|
3
|
-
import { CREDENTIAL_STORE_KINDS, RE_DEVICE_ID } from '../../credentials/constants/credentials.constants.js';
|
|
3
|
+
import { CREDENTIAL_STORE_KINDS, DEVICE_SOURCE_BATCH_CODE, RE_DEVICE_ID } from '../../credentials/constants/credentials.constants.js';
|
|
4
4
|
import { AGENT_WATCH_HOSTS, CUSTOM_ENDPOINT_MESSAGE, CUSTOM_ENDPOINTS_KEY, DELIVERABLE_URL_MESSAGE, DEVICE_URL_FIELDS, ROOTS_KEY, ROOT_URL_FIELDS, URL_FIELDS, LOOPBACK_HOSTS, DEFAULT_DRAIN_BATCH_SIZE, DEFAULT_ENFORCEMENT_CACHE_TTL_MS, DEFAULT_ENFORCEMENT_TIMEOUT_MS, DEFAULT_MAX_ATTEMPTS, DEFAULT_MAX_EVENT_AGE_DAYS, DEFAULT_MAX_QUEUE_EVENTS, DEFAULT_SEND_TIMEOUT_MS } from '../constants/config.constants.js';
|
|
5
5
|
/**
|
|
6
6
|
* The content flags, off.
|
|
@@ -50,7 +50,9 @@ export const captureSchema = z
|
|
|
50
50
|
/** The provider's native session name/title, scrubbed and bounded. A generated title can paraphrase the first prompt; the edge never derives one from the prompt. */
|
|
51
51
|
sessionTitle: z.boolean().default(false),
|
|
52
52
|
git: z.boolean().default(true),
|
|
53
|
-
files: z.boolean().default(true)
|
|
53
|
+
files: z.boolean().default(true),
|
|
54
|
+
/** MCP server and tool names in `tools_used`; false folds them into `mcp`. Metadata, not content. */
|
|
55
|
+
mcpNames: z.boolean().default(true)
|
|
54
56
|
})
|
|
55
57
|
.strip();
|
|
56
58
|
/** Tuning for the in-hook send and the machine-global offline queue. */
|
|
@@ -384,7 +386,9 @@ const deviceCredential = z
|
|
|
384
386
|
.object({
|
|
385
387
|
id: z.string().regex(RE_DEVICE_ID),
|
|
386
388
|
store: z.enum(CREDENTIAL_STORE_KINDS),
|
|
387
|
-
endpoint: z.string().optional().catch(undefined)
|
|
389
|
+
endpoint: z.string().optional().catch(undefined),
|
|
390
|
+
source: z.literal(DEVICE_SOURCE_BATCH_CODE).optional().catch(undefined),
|
|
391
|
+
codeId: z.string().optional().catch(undefined)
|
|
388
392
|
})
|
|
389
393
|
.strip()
|
|
390
394
|
.optional()
|
|
@@ -429,6 +433,11 @@ export const configSchema = z
|
|
|
429
433
|
/** The install key, until it is exchanged for `device` (AWT-356). */
|
|
430
434
|
token: z.string().optional(),
|
|
431
435
|
device: deviceCredential,
|
|
436
|
+
/**
|
|
437
|
+
* The organization an enrollment URL named. Beside no credential it marks an
|
|
438
|
+
* MDM install whose developer has not signed in yet: it sends nothing.
|
|
439
|
+
*/
|
|
440
|
+
organizationId: z.string().optional(),
|
|
432
441
|
installationId: z.string().optional(),
|
|
433
442
|
/** Developer identity attached to turn summaries; falls back to `git config user.email`. */
|
|
434
443
|
developerEmail: z.string().optional(),
|
|
@@ -53,6 +53,10 @@ export declare const TOKEN_PATH = "/v1/devices/token";
|
|
|
53
53
|
/** AWT-275 browser sign-in (RFC 8628): start a session, then poll it with the device code in the body. */
|
|
54
54
|
export declare const ENROLLMENT_SESSION_PATH = "/v1/devices/enrollment-sessions";
|
|
55
55
|
export declare const ENROLLMENT_SESSION_TOKEN_PATH = "/v1/devices/enrollment-sessions/token";
|
|
56
|
+
/** AWT-275 unattended enrollment: an admin-issued, single-use code in the body. */
|
|
57
|
+
export declare const ENROLL_CODE_PATH = "/v1/devices/enroll-code";
|
|
58
|
+
/** Recorded on a device enrolled with an admin-issued code, so `status` can say so (core `DeviceCredentialSource.BatchCode`). */
|
|
59
|
+
export declare const DEVICE_SOURCE_BATCH_CODE = "batch-code";
|
|
56
60
|
/** The RFC 8628 answers of a poll that are not failures: keep waiting. */
|
|
57
61
|
export declare const POLL_PENDING = "authorization_pending";
|
|
58
62
|
export declare const POLL_SLOW_DOWN = "slow_down";
|
|
@@ -66,6 +70,8 @@ export declare const REVOKE_PATH = "/v1/devices/revoke";
|
|
|
66
70
|
export declare const REFUSAL_TOKEN_EXPIRED = "token_expired";
|
|
67
71
|
export declare const REFUSAL_DEVICE_REVOKED = "device_revoked";
|
|
68
72
|
export declare const REFUSAL_INSTALL_KEY_RETIRED = "install_key_retired";
|
|
73
|
+
/** The one answer to any code that cannot be redeemed: unknown, used, expired or revoked alike. */
|
|
74
|
+
export declare const REFUSAL_ENROLLMENT_CODE_INVALID = "enrollment_code_invalid";
|
|
69
75
|
/** The one refusal any run may answer with a new enrollment: the secret only aged out, nobody revoked it. */
|
|
70
76
|
export declare const REFUSAL_SECRET_EXPIRED = "device_secret_expired";
|
|
71
77
|
/**
|
|
@@ -109,3 +115,5 @@ export declare const ENROLL_RETRY_MS = 3600000;
|
|
|
109
115
|
* the gateway already approved.
|
|
110
116
|
*/
|
|
111
117
|
export declare const RE_PLAIN_EMAIL: RegExp;
|
|
118
|
+
/** What an MDM install that has not signed in yet tells its developer, wherever it speaks. */
|
|
119
|
+
export declare const NOT_SIGNED_IN = "AgentWatch is set up for your organization but not signed in: run `agentwatch setup` to sign in. Nothing is recorded until then";
|
|
@@ -54,6 +54,10 @@ export const TOKEN_PATH = '/v1/devices/token';
|
|
|
54
54
|
/** AWT-275 browser sign-in (RFC 8628): start a session, then poll it with the device code in the body. */
|
|
55
55
|
export const ENROLLMENT_SESSION_PATH = '/v1/devices/enrollment-sessions';
|
|
56
56
|
export const ENROLLMENT_SESSION_TOKEN_PATH = '/v1/devices/enrollment-sessions/token';
|
|
57
|
+
/** AWT-275 unattended enrollment: an admin-issued, single-use code in the body. */
|
|
58
|
+
export const ENROLL_CODE_PATH = '/v1/devices/enroll-code';
|
|
59
|
+
/** Recorded on a device enrolled with an admin-issued code, so `status` can say so (core `DeviceCredentialSource.BatchCode`). */
|
|
60
|
+
export const DEVICE_SOURCE_BATCH_CODE = 'batch-code';
|
|
57
61
|
/** The RFC 8628 answers of a poll that are not failures: keep waiting. */
|
|
58
62
|
export const POLL_PENDING = 'authorization_pending';
|
|
59
63
|
export const POLL_SLOW_DOWN = 'slow_down';
|
|
@@ -67,6 +71,8 @@ export const REVOKE_PATH = '/v1/devices/revoke';
|
|
|
67
71
|
export const REFUSAL_TOKEN_EXPIRED = 'token_expired';
|
|
68
72
|
export const REFUSAL_DEVICE_REVOKED = 'device_revoked';
|
|
69
73
|
export const REFUSAL_INSTALL_KEY_RETIRED = 'install_key_retired';
|
|
74
|
+
/** The one answer to any code that cannot be redeemed: unknown, used, expired or revoked alike. */
|
|
75
|
+
export const REFUSAL_ENROLLMENT_CODE_INVALID = 'enrollment_code_invalid';
|
|
70
76
|
/** The one refusal any run may answer with a new enrollment: the secret only aged out, nobody revoked it. */
|
|
71
77
|
export const REFUSAL_SECRET_EXPIRED = 'device_secret_expired';
|
|
72
78
|
/**
|
|
@@ -77,7 +83,7 @@ export const REFUSAL_SECRET_EXPIRED = 'device_secret_expired';
|
|
|
77
83
|
*/
|
|
78
84
|
export const DEVICE_REFUSALS = new Set([REFUSAL_DEVICE_REVOKED, 'device_unknown', REFUSAL_SECRET_EXPIRED]);
|
|
79
85
|
/** Every reason the edge acts on, from any route. */
|
|
80
|
-
export const KNOWN_REFUSALS = new Set([REFUSAL_TOKEN_EXPIRED, REFUSAL_INSTALL_KEY_RETIRED, ...DEVICE_REFUSALS]);
|
|
86
|
+
export const KNOWN_REFUSALS = new Set([REFUSAL_TOKEN_EXPIRED, REFUSAL_INSTALL_KEY_RETIRED, REFUSAL_ENROLLMENT_CODE_INVALID, ...DEVICE_REFUSALS]);
|
|
81
87
|
/**
|
|
82
88
|
* The share of the hook's delivery budget credential work may spend: a
|
|
83
89
|
* keychain read, a refresh or an exchange together. The send gets the rest, so
|
|
@@ -110,3 +116,5 @@ export const ENROLL_RETRY_MS = 3_600_000;
|
|
|
110
116
|
* the gateway already approved.
|
|
111
117
|
*/
|
|
112
118
|
export const RE_PLAIN_EMAIL = /^[^\s@\p{Cc}\p{Cf}]{1,64}@[^\s@\p{Cc}\p{Cf}]{1,189}$/u;
|
|
119
|
+
/** What an MDM install that has not signed in yet tells its developer, wherever it speaks. */
|
|
120
|
+
export const NOT_SIGNED_IN = 'AgentWatch is set up for your organization but not signed in: run `agentwatch setup` to sign in. Nothing is recorded until then';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { isUninstalled } from '../storage/uninstalled.js';
|
|
3
3
|
import { identityPaths } from '../transport/queue-partition.js';
|
|
4
|
-
import { CREDENTIALS_DIR_NAME } from './constants/credentials.constants.js';
|
|
4
|
+
import { CREDENTIALS_DIR_NAME, DEVICE_SOURCE_BATCH_CODE, NOT_SIGNED_IN } from './constants/credentials.constants.js';
|
|
5
5
|
import { readDeviceState } from './device-state.js';
|
|
6
|
-
import { deviceFor, identityOf } from './identity.js';
|
|
6
|
+
import { awaitingSignIn, deviceFor, identityOf } from './identity.js';
|
|
7
7
|
import { storeLabel } from './secret-store.js';
|
|
8
8
|
/**
|
|
9
9
|
* One line on this identity's credential, for `status` and `doctor`: where the
|
|
@@ -18,6 +18,8 @@ import { storeLabel } from './secret-store.js';
|
|
|
18
18
|
export async function describeCredential(paths, config, scope) {
|
|
19
19
|
if (await isUninstalled(paths, scope))
|
|
20
20
|
return { level: 'warn', detail: 'uninstalled — run `agentwatch setup` to enroll this machine again' };
|
|
21
|
+
if (awaitingSignIn(config))
|
|
22
|
+
return { level: 'warn', detail: NOT_SIGNED_IN };
|
|
21
23
|
const device = deviceFor(config);
|
|
22
24
|
if (!device && config.token)
|
|
23
25
|
return { level: 'warn', detail: 'install key, not yet exchanged for a device credential; the next run retries' };
|
|
@@ -27,8 +29,10 @@ export async function describeCredential(paths, config, scope) {
|
|
|
27
29
|
if (refusal) {
|
|
28
30
|
return { level: 'fail', detail: `device credential refused by the backend (${refusal.reason}) since ${refusal.since}; events are queued — enroll again with \`agentwatch setup --token <install key>\`` };
|
|
29
31
|
}
|
|
32
|
+
// SPEC R4: an admin-assigned identity is marked as such wherever it shows.
|
|
33
|
+
const how = device.source === DEVICE_SOURCE_BATCH_CODE ? ', enrolled with an admin-issued code' : '';
|
|
30
34
|
if (device.store === 'file') {
|
|
31
|
-
return { level: 'warn', detail: `device credential in ${storeLabel('file')}: ${path.join(paths.configDir, CREDENTIALS_DIR_NAME)}` };
|
|
35
|
+
return { level: 'warn', detail: `device credential in ${storeLabel('file')}: ${path.join(paths.configDir, CREDENTIALS_DIR_NAME)}${how}` };
|
|
32
36
|
}
|
|
33
|
-
return { level: 'ok', detail: `device credential in ${storeLabel(device.store)}` };
|
|
37
|
+
return { level: 'ok', detail: `device credential in ${storeLabel(device.store)}${how}` };
|
|
34
38
|
}
|
|
@@ -4,8 +4,8 @@ import type { CredentialContext, DeviceCredentialRef, DeviceForgetResult } from
|
|
|
4
4
|
* The bearer to send for this config, doing the network work it needs.
|
|
5
5
|
*
|
|
6
6
|
* A config whose device is listed sends that device's access token, refreshed
|
|
7
|
-
* when due, and never its install key (which stays in the
|
|
8
|
-
*
|
|
7
|
+
* when due, and never its install key (which stays in the config to enroll
|
|
8
|
+
* again after the secret expires). An install key with no device yet is offered for exchange
|
|
9
9
|
* first and presented itself only while that fails. A device the gateway
|
|
10
10
|
* refused is enrolled again when `migrateInstallKey` allows it, and its install
|
|
11
11
|
* key is never sent in its place. Undefined means "nothing to send with": the
|
|
@@ -32,6 +32,20 @@ export declare function resolveBearer(ctx: CredentialContext, config: AgentWatch
|
|
|
32
32
|
* @returns The bearer, or undefined (never a throw).
|
|
33
33
|
*/
|
|
34
34
|
export declare function cachedBearer(ctx: CredentialContext, config: AgentWatchConfig): Promise<string | undefined>;
|
|
35
|
+
/**
|
|
36
|
+
* The bearer an agent's own config file may hold (Codex, Gemini, AWT-357):
|
|
37
|
+
* the device access token, refreshed when due. Never the device secret. The
|
|
38
|
+
* install key while there is no access token: no device yet (its exchange
|
|
39
|
+
* is failing), or a device whose refresh is in cooldown or offline. Writing
|
|
40
|
+
* no header would get every export refused, and the hook only swaps an
|
|
41
|
+
* existing bearer. The hook replaces the key once a device token exists. For
|
|
42
|
+
* setup and `on`, which may refresh; the hook rewrites from the cache.
|
|
43
|
+
*
|
|
44
|
+
* @param ctx - Paths, clock, timeout and keychain runner.
|
|
45
|
+
* @param config - The machine config: those files are machine-wide.
|
|
46
|
+
* @returns The access token, the install key, or undefined (never a throw).
|
|
47
|
+
*/
|
|
48
|
+
export declare function nativeExporterBearer(ctx: CredentialContext, config: AgentWatchConfig): Promise<string | undefined>;
|
|
35
49
|
/**
|
|
36
50
|
* Remove a device secret and its cached token, unless the config still names
|
|
37
51
|
* that device anywhere: a root may share it with the machine, or with the
|
|
@@ -19,8 +19,8 @@ import { cachedAccessToken, currentAccessToken } from './token-refresher.js';
|
|
|
19
19
|
* The bearer to send for this config, doing the network work it needs.
|
|
20
20
|
*
|
|
21
21
|
* A config whose device is listed sends that device's access token, refreshed
|
|
22
|
-
* when due, and never its install key (which stays in the
|
|
23
|
-
*
|
|
22
|
+
* when due, and never its install key (which stays in the config to enroll
|
|
23
|
+
* again after the secret expires). An install key with no device yet is offered for exchange
|
|
24
24
|
* first and presented itself only while that fails. A device the gateway
|
|
25
25
|
* refused is enrolled again when `migrateInstallKey` allows it, and its install
|
|
26
26
|
* key is never sent in its place. Undefined means "nothing to send with": the
|
|
@@ -79,6 +79,30 @@ export async function cachedBearer(ctx, config) {
|
|
|
79
79
|
return undefined;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* The bearer an agent's own config file may hold (Codex, Gemini, AWT-357):
|
|
84
|
+
* the device access token, refreshed when due. Never the device secret. The
|
|
85
|
+
* install key while there is no access token: no device yet (its exchange
|
|
86
|
+
* is failing), or a device whose refresh is in cooldown or offline. Writing
|
|
87
|
+
* no header would get every export refused, and the hook only swaps an
|
|
88
|
+
* existing bearer. The hook replaces the key once a device token exists. For
|
|
89
|
+
* setup and `on`, which may refresh; the hook rewrites from the cache.
|
|
90
|
+
*
|
|
91
|
+
* @param ctx - Paths, clock, timeout and keychain runner.
|
|
92
|
+
* @param config - The machine config: those files are machine-wide.
|
|
93
|
+
* @returns The access token, the install key, or undefined (never a throw).
|
|
94
|
+
*/
|
|
95
|
+
export async function nativeExporterBearer(ctx, config) {
|
|
96
|
+
try {
|
|
97
|
+
if (await isUninstalled(ctx.paths))
|
|
98
|
+
return undefined;
|
|
99
|
+
return (deviceFor(config) ? await currentAccessToken(ctx, config) : undefined) ?? config.token;
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
debugLog('credentials: resolving the native exporter bearer failed:', error);
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
82
106
|
/**
|
|
83
107
|
* Remove a device secret and its cached token, unless the config still names
|
|
84
108
|
* that device anywhere: a root may share it with the machine, or with the
|
|
@@ -148,7 +172,8 @@ export async function forgetDeviceCredentials(ctx) {
|
|
|
148
172
|
written = await updateConfig(ctx.paths, (loaded) => {
|
|
149
173
|
invalid = loaded.state === 'invalid';
|
|
150
174
|
held = loaded.state === 'ok' ? heldDevices(loaded.config) : new Map();
|
|
151
|
-
|
|
175
|
+
// A deferred install holds no device, only the organization it waits to sign in to.
|
|
176
|
+
if (held.size === 0 && (loaded.state !== 'ok' || loaded.config.organizationId === undefined))
|
|
152
177
|
return undefined;
|
|
153
178
|
const roots = loaded.config.roots ? Object.fromEntries(Object.entries(loaded.config.roots).map(([key, root]) => [key, omitKeys(root, DEVICE_KEY)])) : undefined;
|
|
154
179
|
return { ...omitKeys(loaded.config, DEVICE_KEY), ...(roots ? { roots } : {}) };
|