@reticlehq/core 3.7.0 → 3.8.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 (108) hide show
  1. package/dist/activation-entry.d.ts +9 -0
  2. package/dist/activation-entry.js +9 -0
  3. package/dist/artifacts/drive-script.d.ts +64 -64
  4. package/dist/artifacts/flow-constants.d.ts +15 -0
  5. package/dist/artifacts/flow-constants.js +15 -0
  6. package/dist/artifacts/flow-expect-flat.d.ts +8 -8
  7. package/dist/artifacts/flow-results.d.ts +11 -0
  8. package/dist/artifacts/flow-types.d.ts +164 -118
  9. package/dist/artifacts/flow-types.js +12 -0
  10. package/dist/artifacts/harness-credits.d.ts +6 -3
  11. package/dist/artifacts/harness-credits.js +9 -6
  12. package/dist/artifacts/harness-map.d.ts +6 -6
  13. package/dist/artifacts/impact.d.ts +77 -80
  14. package/dist/artifacts/impact.js +34 -17
  15. package/dist/artifacts/journal.d.ts +25 -6
  16. package/dist/artifacts/journal.js +13 -0
  17. package/dist/artifacts/prompt-context.d.ts +12 -0
  18. package/dist/artifacts/prompt-context.js +14 -3
  19. package/dist/graph/app-graph.d.ts +137 -0
  20. package/dist/graph/app-graph.js +498 -0
  21. package/dist/hooks/hook-events.d.ts +22 -22
  22. package/dist/hud-entry.js +1 -1
  23. package/dist/identity/checkout.d.ts +41 -0
  24. package/dist/identity/checkout.js +118 -0
  25. package/dist/identity/state-dir.d.ts +23 -0
  26. package/dist/identity/state-dir.js +43 -0
  27. package/dist/index.d.ts +10 -0
  28. package/dist/index.js +10 -0
  29. package/dist/onboarding.d.ts +22 -1
  30. package/dist/onboarding.js +19 -0
  31. package/dist/registry/dev-server-registry.d.ts +2 -2
  32. package/dist/schema/event-message.json +3 -1
  33. package/dist/schema/event-payloads.json +116 -1
  34. package/dist/schema/event-type.json +3 -1
  35. package/dist/schema/hello-message.json +21 -0
  36. package/dist/schema/reticle-event.json +3 -1
  37. package/dist/schema/reticle-message.json +24 -1
  38. package/dist/telemetry-bug.d.ts +6 -6
  39. package/dist/telemetry-entry.d.ts +1 -1
  40. package/dist/telemetry-entry.js +1 -1
  41. package/dist/telemetry-feedback.d.ts +14 -0
  42. package/dist/telemetry-feedback.js +19 -0
  43. package/dist/telemetry-refusal.d.ts +2 -2
  44. package/dist/telemetry-session.d.ts +23 -8
  45. package/dist/telemetry-session.js +15 -4
  46. package/dist/telemetry-signals.d.ts +227 -9
  47. package/dist/telemetry-signals.js +88 -1
  48. package/dist/telemetry.d.ts +379 -72
  49. package/dist/telemetry.js +71 -5
  50. package/dist/verdict/check-sentence.d.ts +34 -0
  51. package/dist/verdict/check-sentence.js +228 -0
  52. package/dist/verdict/consequence.d.ts +15 -0
  53. package/dist/verdict/consequence.js +11 -0
  54. package/dist/verdict/findings.d.ts +10 -0
  55. package/dist/verdict/findings.js +13 -0
  56. package/dist/verdict/instrumentation-coverage.d.ts +3 -34
  57. package/dist/verdict/instrumentation-coverage.js +14 -58
  58. package/dist/verdict/instrumentation-gap.d.ts +79 -0
  59. package/dist/verdict/instrumentation-gap.js +64 -0
  60. package/dist/verdict/predicate-tree.d.ts +2 -0
  61. package/dist/verdict/predicate-tree.js +16 -0
  62. package/dist/verdict/predicate.d.ts +2 -1
  63. package/dist/verdict/predicate.js +103 -12
  64. package/dist/verdict/property-assertion.d.ts +2 -2
  65. package/dist/verdict/run-report.d.ts +166 -0
  66. package/dist/verdict/run-report.js +53 -0
  67. package/dist/verdict/security.d.ts +36 -2
  68. package/dist/verdict/security.js +94 -14
  69. package/dist/verdict/verification-run.d.ts +95 -38
  70. package/dist/verdict/verification-run.js +33 -2
  71. package/dist/verdict/verify-progress.d.ts +6 -6
  72. package/dist/wire/constants/constants.d.ts +56 -141
  73. package/dist/wire/constants/constants.js +64 -144
  74. package/dist/wire/constants/discovery.d.ts +4 -4
  75. package/dist/wire/constants/discovery.js +4 -4
  76. package/dist/wire/constants/event-types.d.ts +35 -1
  77. package/dist/wire/constants/event-types.js +33 -1
  78. package/dist/wire/constants/hud-controls.js +0 -2
  79. package/dist/wire/constants/hud-use.d.ts +4 -0
  80. package/dist/wire/constants/hud-use.js +4 -0
  81. package/dist/wire/constants/mcp-wire.d.ts +16 -0
  82. package/dist/wire/constants/mcp-wire.js +16 -0
  83. package/dist/wire/constants/response-body-reason.d.ts +19 -0
  84. package/dist/wire/constants/response-body-reason.js +18 -0
  85. package/dist/wire/constants/reticle-env.d.ts +138 -0
  86. package/dist/wire/constants/reticle-env.js +138 -0
  87. package/dist/wire/constants/session-constants.d.ts +11 -0
  88. package/dist/wire/constants/session-constants.js +11 -0
  89. package/dist/wire/event-payloads.d.ts +150 -36
  90. package/dist/wire/event-payloads.js +83 -16
  91. package/dist/wire/messages.d.ts +102 -36
  92. package/dist/wire/messages.js +16 -0
  93. package/dist/wire/narrow.d.ts +6 -0
  94. package/dist/wire/narrow.js +26 -0
  95. package/dist/wire/next-step.d.ts +90 -0
  96. package/dist/wire/next-step.js +37 -0
  97. package/dist/wire/platform-link.d.ts +7 -0
  98. package/dist/wire/platform-link.js +12 -6
  99. package/dist/wire/production/activation-ticket.d.ts +64 -0
  100. package/dist/wire/production/activation-ticket.js +148 -0
  101. package/dist/wire/production/hello-mode.d.ts +35 -0
  102. package/dist/wire/production/hello-mode.js +32 -0
  103. package/dist/wire/production/production-policy.d.ts +138 -0
  104. package/dist/wire/production/production-policy.js +133 -0
  105. package/dist/wire/tool-names.d.ts +2 -0
  106. package/dist/wire/tool-names.js +2 -0
  107. package/dist/wire/types.d.ts +73 -48
  108. package/package.json +5 -1
@@ -19,10 +19,10 @@ export declare const HumanControlDataSchema: z.ZodObject<{
19
19
  }>;
20
20
  text: z.ZodOptional<z.ZodString>;
21
21
  }, "strip", z.ZodTypeAny, {
22
- kind: "message" | "harness" | "pause" | "resume" | "end" | "replay" | "sync" | "signin" | "harness-run" | "harness-stop" | "harness-link";
22
+ kind: "pause" | "message" | "harness" | "resume" | "end" | "replay" | "sync" | "signin" | "harness-run" | "harness-stop" | "harness-link";
23
23
  text?: string | undefined;
24
24
  }, {
25
- kind: "message" | "harness" | "pause" | "resume" | "end" | "replay" | "sync" | "signin" | "harness-run" | "harness-stop" | "harness-link";
25
+ kind: "pause" | "message" | "harness" | "resume" | "end" | "replay" | "sync" | "signin" | "harness-run" | "harness-stop" | "harness-link";
26
26
  text?: string | undefined;
27
27
  }>;
28
28
  export type HumanControlData = z.infer<typeof HumanControlDataSchema>;
@@ -180,6 +180,8 @@ export declare const ReticleEventSchema: z.ZodObject<{
180
180
  readonly HUMAN_MARK: "human.mark";
181
181
  readonly DOWNLOAD: "download";
182
182
  readonly HUD_USED: "hud.used";
183
+ readonly MEDIA_STATE: "media.state";
184
+ readonly CANVAS_DIGEST: "canvas.digest";
183
185
  }>;
184
186
  sessionId: z.ZodString;
185
187
  /** Stable element reference this event concerns, when applicable (e.g. "e7"). */
@@ -219,7 +221,7 @@ export declare const ReticleEventSchema: z.ZodObject<{
219
221
  /** Event-type-specific payload. Kept open here; refined per observer at the edges. */
220
222
  data: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
221
223
  }, "strip", z.ZodTypeAny, {
222
- type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "dialog.opened" | "render.commit" | "focus.change" | "field.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download" | "hud.used";
224
+ type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "dialog.opened" | "render.commit" | "focus.change" | "field.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download" | "hud.used" | "media.state" | "canvas.digest";
223
225
  data: Record<string, unknown>;
224
226
  t: number;
225
227
  sessionId: string;
@@ -230,7 +232,7 @@ export declare const ReticleEventSchema: z.ZodObject<{
230
232
  attribution?: "window" | undefined;
231
233
  documentId?: string | undefined;
232
234
  }, {
233
- type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "dialog.opened" | "render.commit" | "focus.change" | "field.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download" | "hud.used";
235
+ type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "dialog.opened" | "render.commit" | "focus.change" | "field.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download" | "hud.used" | "media.state" | "canvas.digest";
234
236
  t: number;
235
237
  sessionId: string;
236
238
  seq?: number | undefined;
@@ -268,6 +270,22 @@ export declare const HelloMessageSchema: z.ZodObject<{
268
270
  adapters: z.ZodArray<z.ZodString, "many">;
269
271
  /** Optional browser/bridge pairing token. Required when the bridge configures one. */
270
272
  token: z.ZodOptional<z.ZodString>;
273
+ /**
274
+ * Where this page runs. ABSENT MEANS `development`: every SDK before this field was a dev build.
275
+ * The bridge accepts `production` only with a session nonce, never with the pairing token.
276
+ */
277
+ env: z.ZodOptional<z.ZodNativeEnum<{
278
+ readonly DEVELOPMENT: "development";
279
+ readonly PRODUCTION: "production";
280
+ }>>;
281
+ /**
282
+ * What a drive may do here: `observe` or `act`. Absent means `act` in development. The bridge
283
+ * refuses a production HELLO without it, and a page can only narrow what its nonce granted.
284
+ */
285
+ scope: z.ZodOptional<z.ZodNativeEnum<{
286
+ readonly OBSERVE: "observe";
287
+ readonly ACT: "act";
288
+ }>>;
271
289
  /**
272
290
  * What kind of surface this is: a browser document, a web page in somebody else's window, a
273
291
  * native view tree, or no rendering surface at all. See platform.ts.
@@ -330,12 +348,12 @@ export declare const HelloMessageSchema: z.ZodObject<{
330
348
  events: z.ZodArray<z.ZodString, "many">;
331
349
  actions: z.ZodArray<z.ZodString, "many">;
332
350
  }, "strip", z.ZodTypeAny, {
333
- events: string[];
334
351
  commands: string[];
352
+ events: string[];
335
353
  actions: string[];
336
354
  }, {
337
- events: string[];
338
355
  commands: string[];
356
+ events: string[];
339
357
  actions: string[];
340
358
  }>>;
341
359
  /** Whether the app has advertised a capability registry (reticle.describe). */
@@ -365,6 +383,14 @@ export declare const HelloMessageSchema: z.ZodObject<{
365
383
  * would suppress the honest gap for every app that simply has no source mapping at all.
366
384
  */
367
385
  sourceMapping: z.ZodOptional<z.ZodBoolean>;
386
+ /**
387
+ * Who put the SDK in this page: `installed` by the app, or `injected` from outside by a hosted
388
+ * verifier. ABSENT means `installed`. See `HelloInstrumentation`.
389
+ */
390
+ instrumentation: z.ZodOptional<z.ZodNativeEnum<{
391
+ readonly INSTALLED: "installed";
392
+ readonly INJECTED: "injected";
393
+ }>>;
368
394
  /**
369
395
  * The version of the SDK in the page, so a version-skewed pair can SAY so.
370
396
  *
@@ -398,46 +424,52 @@ export declare const HelloMessageSchema: z.ZodObject<{
398
424
  }, "strip", z.ZodTypeAny, {
399
425
  kind: "hello";
400
426
  url: string;
401
- adapters: string[];
402
427
  sessionId: string;
403
428
  protocolVersion: number;
404
429
  title: string;
430
+ adapters: string[];
431
+ scope?: "observe" | "act" | undefined;
432
+ env?: "development" | "production" | undefined;
405
433
  projectId?: string | undefined;
434
+ token?: string | undefined;
406
435
  platform?: "native" | "web" | "webview" | "service" | undefined;
407
436
  channels?: ("signal" | "net" | "state" | "route" | "visual" | "ui" | "log" | "storage" | "time")[] | undefined;
408
- token?: string | undefined;
409
437
  commands?: string[] | undefined;
410
438
  contractParts?: {
411
- events: string[];
412
439
  commands: string[];
440
+ events: string[];
413
441
  actions: string[];
414
442
  } | undefined;
415
443
  hasCapabilities?: boolean | undefined;
416
444
  captureBodies?: boolean | undefined;
417
445
  sourceMapping?: boolean | undefined;
446
+ instrumentation?: "installed" | "injected" | undefined;
418
447
  sdkVersion?: string | undefined;
419
448
  contract?: string | undefined;
420
449
  redactKeys?: string[] | undefined;
421
450
  }, {
422
451
  kind: "hello";
423
452
  url: string;
424
- adapters: string[];
425
453
  sessionId: string;
426
454
  protocolVersion: number;
427
455
  title: string;
456
+ adapters: string[];
457
+ scope?: "observe" | "act" | undefined;
458
+ env?: "development" | "production" | undefined;
428
459
  projectId?: string | undefined;
460
+ token?: string | undefined;
429
461
  platform?: "native" | "web" | "webview" | "service" | undefined;
430
462
  channels?: ("signal" | "net" | "state" | "route" | "visual" | "ui" | "log" | "storage" | "time")[] | undefined;
431
- token?: string | undefined;
432
463
  commands?: string[] | undefined;
433
464
  contractParts?: {
434
- events: string[];
435
465
  commands: string[];
466
+ events: string[];
436
467
  actions: string[];
437
468
  } | undefined;
438
469
  hasCapabilities?: boolean | undefined;
439
470
  captureBodies?: boolean | undefined;
440
471
  sourceMapping?: boolean | undefined;
472
+ instrumentation?: "installed" | "injected" | undefined;
441
473
  sdkVersion?: string | undefined;
442
474
  contract?: string | undefined;
443
475
  redactKeys?: string[] | undefined;
@@ -484,8 +516,8 @@ export declare const CommandMessageSchema: z.ZodObject<{
484
516
  allowed: ("invite" | "send" | "share" | "delete" | "pay" | "publish" | "revoke" | "transfer" | "sign out" | "change role" | "create key" | "change state")[];
485
517
  }>>;
486
518
  }, "strip", z.ZodTypeAny, {
487
- kind: "command";
488
519
  name: string;
520
+ kind: "command";
489
521
  id: string;
490
522
  args: Record<string, unknown>;
491
523
  by?: "harness" | undefined;
@@ -494,8 +526,8 @@ export declare const CommandMessageSchema: z.ZodObject<{
494
526
  allowed: ("invite" | "send" | "share" | "delete" | "pay" | "publish" | "revoke" | "transfer" | "sign out" | "change role" | "create key" | "change state")[];
495
527
  } | undefined;
496
528
  }, {
497
- kind: "command";
498
529
  name: string;
530
+ kind: "command";
499
531
  id: string;
500
532
  by?: "harness" | undefined;
501
533
  args?: Record<string, unknown> | undefined;
@@ -513,14 +545,14 @@ export declare const CommandResultSchema: z.ZodObject<{
513
545
  result: z.ZodOptional<z.ZodUnknown>;
514
546
  error: z.ZodOptional<z.ZodString>;
515
547
  }, "strip", z.ZodTypeAny, {
516
- kind: "command_result";
517
548
  ok: boolean;
549
+ kind: "command_result";
518
550
  id: string;
519
551
  error?: string | undefined;
520
552
  result?: unknown;
521
553
  }, {
522
- kind: "command_result";
523
554
  ok: boolean;
555
+ kind: "command_result";
524
556
  id: string;
525
557
  error?: string | undefined;
526
558
  result?: unknown;
@@ -571,6 +603,8 @@ export declare const EventMessageSchema: z.ZodObject<{
571
603
  readonly HUMAN_MARK: "human.mark";
572
604
  readonly DOWNLOAD: "download";
573
605
  readonly HUD_USED: "hud.used";
606
+ readonly MEDIA_STATE: "media.state";
607
+ readonly CANVAS_DIGEST: "canvas.digest";
574
608
  }>;
575
609
  sessionId: z.ZodString;
576
610
  /** Stable element reference this event concerns, when applicable (e.g. "e7"). */
@@ -610,7 +644,7 @@ export declare const EventMessageSchema: z.ZodObject<{
610
644
  /** Event-type-specific payload. Kept open here; refined per observer at the edges. */
611
645
  data: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
612
646
  }, "strip", z.ZodTypeAny, {
613
- type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "dialog.opened" | "render.commit" | "focus.change" | "field.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download" | "hud.used";
647
+ type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "dialog.opened" | "render.commit" | "focus.change" | "field.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download" | "hud.used" | "media.state" | "canvas.digest";
614
648
  data: Record<string, unknown>;
615
649
  t: number;
616
650
  sessionId: string;
@@ -621,7 +655,7 @@ export declare const EventMessageSchema: z.ZodObject<{
621
655
  attribution?: "window" | undefined;
622
656
  documentId?: string | undefined;
623
657
  }, {
624
- type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "dialog.opened" | "render.commit" | "focus.change" | "field.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download" | "hud.used";
658
+ type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "dialog.opened" | "render.commit" | "focus.change" | "field.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download" | "hud.used" | "media.state" | "canvas.digest";
625
659
  t: number;
626
660
  sessionId: string;
627
661
  seq?: number | undefined;
@@ -635,7 +669,7 @@ export declare const EventMessageSchema: z.ZodObject<{
635
669
  }, "strip", z.ZodTypeAny, {
636
670
  kind: "event";
637
671
  event: {
638
- type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "dialog.opened" | "render.commit" | "focus.change" | "field.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download" | "hud.used";
672
+ type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "dialog.opened" | "render.commit" | "focus.change" | "field.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download" | "hud.used" | "media.state" | "canvas.digest";
639
673
  data: Record<string, unknown>;
640
674
  t: number;
641
675
  sessionId: string;
@@ -649,7 +683,7 @@ export declare const EventMessageSchema: z.ZodObject<{
649
683
  }, {
650
684
  kind: "event";
651
685
  event: {
652
- type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "dialog.opened" | "render.commit" | "focus.change" | "field.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download" | "hud.used";
686
+ type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "dialog.opened" | "render.commit" | "focus.change" | "field.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download" | "hud.used" | "media.state" | "canvas.digest";
653
687
  t: number;
654
688
  sessionId: string;
655
689
  seq?: number | undefined;
@@ -687,6 +721,22 @@ export declare const ReticleMessageSchema: z.ZodDiscriminatedUnion<"kind", [z.Zo
687
721
  adapters: z.ZodArray<z.ZodString, "many">;
688
722
  /** Optional browser/bridge pairing token. Required when the bridge configures one. */
689
723
  token: z.ZodOptional<z.ZodString>;
724
+ /**
725
+ * Where this page runs. ABSENT MEANS `development`: every SDK before this field was a dev build.
726
+ * The bridge accepts `production` only with a session nonce, never with the pairing token.
727
+ */
728
+ env: z.ZodOptional<z.ZodNativeEnum<{
729
+ readonly DEVELOPMENT: "development";
730
+ readonly PRODUCTION: "production";
731
+ }>>;
732
+ /**
733
+ * What a drive may do here: `observe` or `act`. Absent means `act` in development. The bridge
734
+ * refuses a production HELLO without it, and a page can only narrow what its nonce granted.
735
+ */
736
+ scope: z.ZodOptional<z.ZodNativeEnum<{
737
+ readonly OBSERVE: "observe";
738
+ readonly ACT: "act";
739
+ }>>;
690
740
  /**
691
741
  * What kind of surface this is: a browser document, a web page in somebody else's window, a
692
742
  * native view tree, or no rendering surface at all. See platform.ts.
@@ -749,12 +799,12 @@ export declare const ReticleMessageSchema: z.ZodDiscriminatedUnion<"kind", [z.Zo
749
799
  events: z.ZodArray<z.ZodString, "many">;
750
800
  actions: z.ZodArray<z.ZodString, "many">;
751
801
  }, "strip", z.ZodTypeAny, {
752
- events: string[];
753
802
  commands: string[];
803
+ events: string[];
754
804
  actions: string[];
755
805
  }, {
756
- events: string[];
757
806
  commands: string[];
807
+ events: string[];
758
808
  actions: string[];
759
809
  }>>;
760
810
  /** Whether the app has advertised a capability registry (reticle.describe). */
@@ -784,6 +834,14 @@ export declare const ReticleMessageSchema: z.ZodDiscriminatedUnion<"kind", [z.Zo
784
834
  * would suppress the honest gap for every app that simply has no source mapping at all.
785
835
  */
786
836
  sourceMapping: z.ZodOptional<z.ZodBoolean>;
837
+ /**
838
+ * Who put the SDK in this page: `installed` by the app, or `injected` from outside by a hosted
839
+ * verifier. ABSENT means `installed`. See `HelloInstrumentation`.
840
+ */
841
+ instrumentation: z.ZodOptional<z.ZodNativeEnum<{
842
+ readonly INSTALLED: "installed";
843
+ readonly INJECTED: "injected";
844
+ }>>;
787
845
  /**
788
846
  * The version of the SDK in the page, so a version-skewed pair can SAY so.
789
847
  *
@@ -817,46 +875,52 @@ export declare const ReticleMessageSchema: z.ZodDiscriminatedUnion<"kind", [z.Zo
817
875
  }, "strip", z.ZodTypeAny, {
818
876
  kind: "hello";
819
877
  url: string;
820
- adapters: string[];
821
878
  sessionId: string;
822
879
  protocolVersion: number;
823
880
  title: string;
881
+ adapters: string[];
882
+ scope?: "observe" | "act" | undefined;
883
+ env?: "development" | "production" | undefined;
824
884
  projectId?: string | undefined;
885
+ token?: string | undefined;
825
886
  platform?: "native" | "web" | "webview" | "service" | undefined;
826
887
  channels?: ("signal" | "net" | "state" | "route" | "visual" | "ui" | "log" | "storage" | "time")[] | undefined;
827
- token?: string | undefined;
828
888
  commands?: string[] | undefined;
829
889
  contractParts?: {
830
- events: string[];
831
890
  commands: string[];
891
+ events: string[];
832
892
  actions: string[];
833
893
  } | undefined;
834
894
  hasCapabilities?: boolean | undefined;
835
895
  captureBodies?: boolean | undefined;
836
896
  sourceMapping?: boolean | undefined;
897
+ instrumentation?: "installed" | "injected" | undefined;
837
898
  sdkVersion?: string | undefined;
838
899
  contract?: string | undefined;
839
900
  redactKeys?: string[] | undefined;
840
901
  }, {
841
902
  kind: "hello";
842
903
  url: string;
843
- adapters: string[];
844
904
  sessionId: string;
845
905
  protocolVersion: number;
846
906
  title: string;
907
+ adapters: string[];
908
+ scope?: "observe" | "act" | undefined;
909
+ env?: "development" | "production" | undefined;
847
910
  projectId?: string | undefined;
911
+ token?: string | undefined;
848
912
  platform?: "native" | "web" | "webview" | "service" | undefined;
849
913
  channels?: ("signal" | "net" | "state" | "route" | "visual" | "ui" | "log" | "storage" | "time")[] | undefined;
850
- token?: string | undefined;
851
914
  commands?: string[] | undefined;
852
915
  contractParts?: {
853
- events: string[];
854
916
  commands: string[];
917
+ events: string[];
855
918
  actions: string[];
856
919
  } | undefined;
857
920
  hasCapabilities?: boolean | undefined;
858
921
  captureBodies?: boolean | undefined;
859
922
  sourceMapping?: boolean | undefined;
923
+ instrumentation?: "installed" | "injected" | undefined;
860
924
  sdkVersion?: string | undefined;
861
925
  contract?: string | undefined;
862
926
  redactKeys?: string[] | undefined;
@@ -895,8 +959,8 @@ export declare const ReticleMessageSchema: z.ZodDiscriminatedUnion<"kind", [z.Zo
895
959
  allowed: ("invite" | "send" | "share" | "delete" | "pay" | "publish" | "revoke" | "transfer" | "sign out" | "change role" | "create key" | "change state")[];
896
960
  }>>;
897
961
  }, "strip", z.ZodTypeAny, {
898
- kind: "command";
899
962
  name: string;
963
+ kind: "command";
900
964
  id: string;
901
965
  args: Record<string, unknown>;
902
966
  by?: "harness" | undefined;
@@ -905,8 +969,8 @@ export declare const ReticleMessageSchema: z.ZodDiscriminatedUnion<"kind", [z.Zo
905
969
  allowed: ("invite" | "send" | "share" | "delete" | "pay" | "publish" | "revoke" | "transfer" | "sign out" | "change role" | "create key" | "change state")[];
906
970
  } | undefined;
907
971
  }, {
908
- kind: "command";
909
972
  name: string;
973
+ kind: "command";
910
974
  id: string;
911
975
  by?: "harness" | undefined;
912
976
  args?: Record<string, unknown> | undefined;
@@ -921,14 +985,14 @@ export declare const ReticleMessageSchema: z.ZodDiscriminatedUnion<"kind", [z.Zo
921
985
  result: z.ZodOptional<z.ZodUnknown>;
922
986
  error: z.ZodOptional<z.ZodString>;
923
987
  }, "strip", z.ZodTypeAny, {
924
- kind: "command_result";
925
988
  ok: boolean;
989
+ kind: "command_result";
926
990
  id: string;
927
991
  error?: string | undefined;
928
992
  result?: unknown;
929
993
  }, {
930
- kind: "command_result";
931
994
  ok: boolean;
995
+ kind: "command_result";
932
996
  id: string;
933
997
  error?: string | undefined;
934
998
  result?: unknown;
@@ -976,6 +1040,8 @@ export declare const ReticleMessageSchema: z.ZodDiscriminatedUnion<"kind", [z.Zo
976
1040
  readonly HUMAN_MARK: "human.mark";
977
1041
  readonly DOWNLOAD: "download";
978
1042
  readonly HUD_USED: "hud.used";
1043
+ readonly MEDIA_STATE: "media.state";
1044
+ readonly CANVAS_DIGEST: "canvas.digest";
979
1045
  }>;
980
1046
  sessionId: z.ZodString;
981
1047
  /** Stable element reference this event concerns, when applicable (e.g. "e7"). */
@@ -1015,7 +1081,7 @@ export declare const ReticleMessageSchema: z.ZodDiscriminatedUnion<"kind", [z.Zo
1015
1081
  /** Event-type-specific payload. Kept open here; refined per observer at the edges. */
1016
1082
  data: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1017
1083
  }, "strip", z.ZodTypeAny, {
1018
- type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "dialog.opened" | "render.commit" | "focus.change" | "field.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download" | "hud.used";
1084
+ type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "dialog.opened" | "render.commit" | "focus.change" | "field.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download" | "hud.used" | "media.state" | "canvas.digest";
1019
1085
  data: Record<string, unknown>;
1020
1086
  t: number;
1021
1087
  sessionId: string;
@@ -1026,7 +1092,7 @@ export declare const ReticleMessageSchema: z.ZodDiscriminatedUnion<"kind", [z.Zo
1026
1092
  attribution?: "window" | undefined;
1027
1093
  documentId?: string | undefined;
1028
1094
  }, {
1029
- type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "dialog.opened" | "render.commit" | "focus.change" | "field.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download" | "hud.used";
1095
+ type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "dialog.opened" | "render.commit" | "focus.change" | "field.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download" | "hud.used" | "media.state" | "canvas.digest";
1030
1096
  t: number;
1031
1097
  sessionId: string;
1032
1098
  seq?: number | undefined;
@@ -1040,7 +1106,7 @@ export declare const ReticleMessageSchema: z.ZodDiscriminatedUnion<"kind", [z.Zo
1040
1106
  }, "strip", z.ZodTypeAny, {
1041
1107
  kind: "event";
1042
1108
  event: {
1043
- type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "dialog.opened" | "render.commit" | "focus.change" | "field.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download" | "hud.used";
1109
+ type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "dialog.opened" | "render.commit" | "focus.change" | "field.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download" | "hud.used" | "media.state" | "canvas.digest";
1044
1110
  data: Record<string, unknown>;
1045
1111
  t: number;
1046
1112
  sessionId: string;
@@ -1054,7 +1120,7 @@ export declare const ReticleMessageSchema: z.ZodDiscriminatedUnion<"kind", [z.Zo
1054
1120
  }, {
1055
1121
  kind: "event";
1056
1122
  event: {
1057
- type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "dialog.opened" | "render.commit" | "focus.change" | "field.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download" | "hud.used";
1123
+ type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "dialog.opened" | "render.commit" | "focus.change" | "field.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download" | "hud.used" | "media.state" | "canvas.digest";
1058
1124
  t: number;
1059
1125
  sessionId: string;
1060
1126
  seq?: number | undefined;
@@ -7,6 +7,7 @@ import { DOCUMENT_ID_LENGTH } from '../identity/document-identity.js';
7
7
  import { NO_EDITS_OBSERVED } from '../identity/edit-epoch.js';
8
8
  import { PlatformProfile } from './platform.js';
9
9
  import { ChannelId } from './channel.js';
10
+ import { HelloEnv, HelloInstrumentation, HelloScope } from './production/hello-mode.js';
10
11
  import { OutwardAction } from '../verdict/security.js';
11
12
  const sessionIdSchema = z.string().min(1).max(TRANSPORT_LIMITS.MAX_SESSION_ID_LENGTH);
12
13
  const refSchema = z.string().max(TRANSPORT_LIMITS.MAX_REF_LENGTH);
@@ -137,6 +138,16 @@ export const HelloMessageSchema = z.object({
137
138
  .max(TRANSPORT_LIMITS.MAX_ADAPTERS),
138
139
  /** Optional browser/bridge pairing token. Required when the bridge configures one. */
139
140
  token: z.string().max(TRANSPORT_LIMITS.MAX_TOKEN_LENGTH).optional(),
141
+ /**
142
+ * Where this page runs. ABSENT MEANS `development`: every SDK before this field was a dev build.
143
+ * The bridge accepts `production` only with a session nonce, never with the pairing token.
144
+ */
145
+ env: z.nativeEnum(HelloEnv).optional(),
146
+ /**
147
+ * What a drive may do here: `observe` or `act`. Absent means `act` in development. The bridge
148
+ * refuses a production HELLO without it, and a page can only narrow what its nonce granted.
149
+ */
150
+ scope: z.nativeEnum(HelloScope).optional(),
140
151
  /**
141
152
  * What kind of surface this is: a browser document, a web page in somebody else's window, a
142
153
  * native view tree, or no rendering surface at all. See platform.ts.
@@ -216,6 +227,11 @@ export const HelloMessageSchema = z.object({
216
227
  * would suppress the honest gap for every app that simply has no source mapping at all.
217
228
  */
218
229
  sourceMapping: z.boolean().optional(),
230
+ /**
231
+ * Who put the SDK in this page: `installed` by the app, or `injected` from outside by a hosted
232
+ * verifier. ABSENT means `installed`. See `HelloInstrumentation`.
233
+ */
234
+ instrumentation: z.nativeEnum(HelloInstrumentation).optional(),
219
235
  /**
220
236
  * The version of the SDK in the page, so a version-skewed pair can SAY so.
221
237
  *
@@ -37,3 +37,9 @@ export declare function asNumber(value: unknown): number | undefined;
37
37
  * move, and a move that also changes behaviour is two changes wearing one message.
38
38
  */
39
39
  export declare function asRecord(value: unknown): Record<string, unknown>;
40
+ /** Whether the value is an object other than `null` or an array; `asRecord` lets arrays through. */
41
+ export declare function isPlainRecord(value: unknown): value is Record<string, unknown>;
42
+ /** The URL's origin, or nothing when it is absent or does not parse. */
43
+ export declare function originOf(url: string | undefined): string | undefined;
44
+ /** The URL's pathname, or nothing when it is absent or does not parse. */
45
+ export declare function pathOf(url: string | undefined): string | undefined;
@@ -43,3 +43,29 @@ export function asNumber(value) {
43
43
  export function asRecord(value) {
44
44
  return 'object' === typeof value && value !== null ? value : {};
45
45
  }
46
+ /** Whether the value is an object other than `null` or an array; `asRecord` lets arrays through. */
47
+ export function isPlainRecord(value) {
48
+ return 'object' === typeof value && value !== null && !Array.isArray(value);
49
+ }
50
+ /** The URL's origin, or nothing when it is absent or does not parse. */
51
+ export function originOf(url) {
52
+ if (url === undefined)
53
+ return undefined;
54
+ try {
55
+ return new URL(url).origin;
56
+ }
57
+ catch {
58
+ return undefined;
59
+ }
60
+ }
61
+ /** The URL's pathname, or nothing when it is absent or does not parse. */
62
+ export function pathOf(url) {
63
+ if (url === undefined)
64
+ return undefined;
65
+ try {
66
+ return new URL(url).pathname;
67
+ }
68
+ catch {
69
+ return undefined;
70
+ }
71
+ }
@@ -0,0 +1,90 @@
1
+ /**
2
+ * What to do next, and who does it, when Reticle refuses something.
3
+ *
4
+ * One file because the daemon, the HUD and the agent each say part of the same answer. When each
5
+ * wrote its own, the Harness refusal said `reticle connect` and the recovery beside it said
6
+ * `npx @reticlehq/server connect`: two spellings of one command, in one answer.
7
+ */
8
+ import { z } from 'zod';
9
+ /** The command that signs a person in and links a project. The docs spell it this way. */
10
+ export declare const CONNECT_COMMAND = "reticle connect";
11
+ /** The refusals that say what to do next as data rather than in a sentence. */
12
+ export declare const RefusalCode: {
13
+ /** The Harness was asked for, and this project is not linked to the platform it runs on. */
14
+ readonly HARNESS_NOT_LINKED: "harness_not_linked";
15
+ };
16
+ export type RefusalCode = (typeof RefusalCode)[keyof typeof RefusalCode];
17
+ /** Who takes a next step: the person (a command to run) or the agent (a tool to call). */
18
+ export declare const NextWho: {
19
+ readonly HUMAN: "human";
20
+ readonly AGENT: "agent";
21
+ };
22
+ export declare const NextStepSchema: z.ZodDiscriminatedUnion<"who", [z.ZodObject<{
23
+ who: z.ZodLiteral<"human">;
24
+ run: z.ZodString;
25
+ }, "strip", z.ZodTypeAny, {
26
+ who: "human";
27
+ run: string;
28
+ }, {
29
+ who: "human";
30
+ run: string;
31
+ }>, z.ZodObject<{
32
+ who: z.ZodLiteral<"agent">;
33
+ tool: z.ZodString;
34
+ }, "strip", z.ZodTypeAny, {
35
+ tool: string;
36
+ who: "agent";
37
+ }, {
38
+ tool: string;
39
+ who: "agent";
40
+ }>]>;
41
+ export type NextStep = z.infer<typeof NextStepSchema>;
42
+ /** A coded refusal, as it rides on a tool's error envelope beside `error`. */
43
+ export declare const CodedRefusalSchema: z.ZodObject<{
44
+ code: z.ZodEnum<["harness_not_linked"]>;
45
+ next: z.ZodArray<z.ZodDiscriminatedUnion<"who", [z.ZodObject<{
46
+ who: z.ZodLiteral<"human">;
47
+ run: z.ZodString;
48
+ }, "strip", z.ZodTypeAny, {
49
+ who: "human";
50
+ run: string;
51
+ }, {
52
+ who: "human";
53
+ run: string;
54
+ }>, z.ZodObject<{
55
+ who: z.ZodLiteral<"agent">;
56
+ tool: z.ZodString;
57
+ }, "strip", z.ZodTypeAny, {
58
+ tool: string;
59
+ who: "agent";
60
+ }, {
61
+ tool: string;
62
+ who: "agent";
63
+ }>]>, "many">;
64
+ }, "strip", z.ZodTypeAny, {
65
+ code: "harness_not_linked";
66
+ next: ({
67
+ who: "human";
68
+ run: string;
69
+ } | {
70
+ tool: string;
71
+ who: "agent";
72
+ })[];
73
+ }, {
74
+ code: "harness_not_linked";
75
+ next: ({
76
+ who: "human";
77
+ run: string;
78
+ } | {
79
+ tool: string;
80
+ who: "agent";
81
+ })[];
82
+ }>;
83
+ export type CodedRefusal = z.infer<typeof CodedRefusalSchema>;
84
+ /** Not linked: the person connects, or the agent drives the journey itself. */
85
+ export declare const HARNESS_NOT_LINKED_NEXT: readonly NextStep[];
86
+ /**
87
+ * The same refusal, for the person on the HUD: one sentence, the command, no tool names. No credit
88
+ * number either: free credit is granted once per person, so the engine cannot know what is left.
89
+ */
90
+ export declare const HARNESS_NOT_LINKED_HUMAN = "Connect your Reticle account to run the Harness: `reticle connect`.";
@@ -0,0 +1,37 @@
1
+ /**
2
+ * What to do next, and who does it, when Reticle refuses something.
3
+ *
4
+ * One file because the daemon, the HUD and the agent each say part of the same answer. When each
5
+ * wrote its own, the Harness refusal said `reticle connect` and the recovery beside it said
6
+ * `npx @reticlehq/server connect`: two spellings of one command, in one answer.
7
+ */
8
+ import { z } from 'zod';
9
+ import { ReticleTool } from './tool-names.js';
10
+ /** The command that signs a person in and links a project. The docs spell it this way. */
11
+ export const CONNECT_COMMAND = 'reticle connect';
12
+ /** The refusals that say what to do next as data rather than in a sentence. */
13
+ export const RefusalCode = {
14
+ /** The Harness was asked for, and this project is not linked to the platform it runs on. */
15
+ HARNESS_NOT_LINKED: 'harness_not_linked',
16
+ };
17
+ /** Who takes a next step: the person (a command to run) or the agent (a tool to call). */
18
+ export const NextWho = { HUMAN: 'human', AGENT: 'agent' };
19
+ export const NextStepSchema = z.discriminatedUnion('who', [
20
+ z.object({ who: z.literal(NextWho.HUMAN), run: z.string() }),
21
+ z.object({ who: z.literal(NextWho.AGENT), tool: z.string() }),
22
+ ]);
23
+ /** A coded refusal, as it rides on a tool's error envelope beside `error`. */
24
+ export const CodedRefusalSchema = z.object({
25
+ code: z.enum([RefusalCode.HARNESS_NOT_LINKED]),
26
+ next: z.array(NextStepSchema),
27
+ });
28
+ /** Not linked: the person connects, or the agent drives the journey itself. */
29
+ export const HARNESS_NOT_LINKED_NEXT = [
30
+ { who: NextWho.HUMAN, run: CONNECT_COMMAND },
31
+ { who: NextWho.AGENT, tool: ReticleTool.ACT_AND_WAIT },
32
+ ];
33
+ /**
34
+ * The same refusal, for the person on the HUD: one sentence, the command, no tool names. No credit
35
+ * number either: free credit is granted once per person, so the engine cannot know what is left.
36
+ */
37
+ export const HARNESS_NOT_LINKED_HUMAN = `Connect your Reticle account to run the Harness: \`${CONNECT_COMMAND}\`.`;