@overdeck/contracts 0.73.1 → 0.74.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/dist/index.cjs CHANGED
@@ -82,6 +82,19 @@ function indexPanesByAgentKey(panes) {
82
82
  }
83
83
  return byKey;
84
84
  }
85
+ /**
86
+ * Session presence a pane's own state implies (PAN-5011). Herdr `done` is a
87
+ * finished turn with the harness pane still alive, never an exit, so it maps
88
+ * to `idle`, not `ended`; only `exited` (no pane left) ends a session.
89
+ */
90
+ function presenceForPaneState(state) {
91
+ switch (state) {
92
+ case "working":
93
+ case "blocked": return "active";
94
+ case "exited": return "ended";
95
+ default: return "idle";
96
+ }
97
+ }
85
98
  //#endregion
86
99
  //#region src/derived-issue-state.ts
87
100
  /**
@@ -580,7 +593,8 @@ const AgentSnapshot = effect.Schema.Struct({
580
593
  })),
581
594
  resolution: effect.Schema.optional(AgentResolution),
582
595
  resolutionCount: effect.Schema.optional(effect.Schema.Number),
583
- turnEndAssessment: effect.Schema.optional(TurnEndAssessment)
596
+ turnEndAssessment: effect.Schema.optional(TurnEndAssessment),
597
+ deftExternalEscalations: effect.Schema.optional(effect.Schema.Number)
584
598
  });
585
599
  /** PAN-3151: A recorded cycle in the review convergence tracking series */
586
600
  const TurnDiffFileChange = effect.Schema.Struct({
@@ -720,12 +734,24 @@ const RestartGateOutcome = effect.Schema.Struct({
720
734
  at: effect.Schema.String
721
735
  });
722
736
  /**
737
+ * The operator restart hold (PAN-5007), set by `pan restart hold` and lifted by
738
+ * `pan restart release` or its `until` time. While it is active every reload,
739
+ * restart and restart-gate approval refuses.
740
+ */
741
+ const RestartHold = effect.Schema.Struct({
742
+ reason: effect.Schema.String,
743
+ who: effect.Schema.String,
744
+ setAt: effect.Schema.String,
745
+ until: effect.Schema.optional(effect.Schema.String)
746
+ });
747
+ /**
723
748
  * The operator-facing view of the restart gate — identical to the body of
724
749
  * `GET /api/restart-gate`, so the banner and the CLI read the same shape.
725
750
  *
726
751
  * `idle` no live requests; `pending` requests are waiting for approval;
727
752
  * `approved` the operator approved an epoch that nobody has claimed yet;
728
753
  * `claimed` one requester holds the exclusive right to perform the restart.
754
+ * `restartHold` is present while an operator restart hold is active.
729
755
  */
730
756
  const RestartGateSnapshot = effect.Schema.Struct({
731
757
  status: effect.Schema.Literals([
@@ -735,7 +761,8 @@ const RestartGateSnapshot = effect.Schema.Struct({
735
761
  "claimed"
736
762
  ]),
737
763
  pending: effect.Schema.Array(RestartGateRequest),
738
- lastOutcome: effect.Schema.optional(RestartGateOutcome)
764
+ lastOutcome: effect.Schema.optional(RestartGateOutcome),
765
+ restartHold: effect.Schema.optional(RestartHold)
739
766
  });
740
767
  const DashboardSnapshot = effect.Schema.Struct({
741
768
  sequence: SequenceNumber,
@@ -1841,7 +1868,8 @@ const AgentEnrichmentChangedEvent = effect.Schema.Struct({
1841
1868
  })),
1842
1869
  resolution: effect.Schema.optional(AgentResolution),
1843
1870
  resolutionCount: effect.Schema.optional(effect.Schema.Number),
1844
- turnEndAssessment: effect.Schema.optional(TurnEndAssessment)
1871
+ turnEndAssessment: effect.Schema.optional(TurnEndAssessment),
1872
+ deftExternalEscalations: effect.Schema.optional(effect.Schema.Number)
1845
1873
  })
1846
1874
  });
1847
1875
  /** New — agent created in database */
@@ -4255,7 +4283,8 @@ function applyEvent(state, event) {
4255
4283
  pendingProposedPlan: event.payload.pendingProposedPlan,
4256
4284
  resolution: event.payload.resolution,
4257
4285
  resolutionCount: event.payload.resolutionCount,
4258
- turnEndAssessment: event.payload.turnEndAssessment
4286
+ turnEndAssessment: event.payload.turnEndAssessment,
4287
+ deftExternalEscalations: event.payload.deftExternalEscalations
4259
4288
  }
4260
4289
  }
4261
4290
  };
@@ -4394,6 +4423,7 @@ function applyEvent(state, event) {
4394
4423
  delete base["pendingAskUserQuestion"];
4395
4424
  delete base["pendingProposedPlan"];
4396
4425
  delete base["turnEndAssessment"];
4426
+ delete base["deftExternalEscalations"];
4397
4427
  }
4398
4428
  return base;
4399
4429
  })();
@@ -4591,7 +4621,8 @@ function applyEvent(state, event) {
4591
4621
  restartGate: {
4592
4622
  status: event.payload.status,
4593
4623
  pending: event.payload.pending,
4594
- ...event.payload.lastOutcome === void 0 ? {} : { lastOutcome: event.payload.lastOutcome }
4624
+ ...event.payload.lastOutcome === void 0 ? {} : { lastOutcome: event.payload.lastOutcome },
4625
+ ...event.payload.restartHold === void 0 ? {} : { restartHold: event.payload.restartHold }
4595
4626
  }
4596
4627
  };
4597
4628
  case "github_quota.changed": return {
@@ -6207,7 +6238,8 @@ const HARNESS_CAPABILITY_KEYS = [
6207
6238
  "correlatesBySessionId",
6208
6239
  "answersQuestionByMessage",
6209
6240
  "askAnswerDelivery",
6210
- "runsOnFlyMachine"
6241
+ "runsOnFlyMachine",
6242
+ "overdeckMcp"
6211
6243
  ];
6212
6244
  const CLAUDE_CODE_CAPABILITIES = {
6213
6245
  contextChannel: "append-system-prompt-file",
@@ -6230,7 +6262,8 @@ const CLAUDE_CODE_CAPABILITIES = {
6230
6262
  correlatesBySessionId: false,
6231
6263
  answersQuestionByMessage: true,
6232
6264
  askAnswerDelivery: "message",
6233
- runsOnFlyMachine: true
6265
+ runsOnFlyMachine: true,
6266
+ overdeckMcp: true
6234
6267
  };
6235
6268
  const OHMYPI_CAPABILITIES = {
6236
6269
  contextChannel: "append-system-prompt",
@@ -6253,7 +6286,8 @@ const OHMYPI_CAPABILITIES = {
6253
6286
  correlatesBySessionId: true,
6254
6287
  answersQuestionByMessage: false,
6255
6288
  askAnswerDelivery: "pi-ask-modal",
6256
- runsOnFlyMachine: false
6289
+ runsOnFlyMachine: false,
6290
+ overdeckMcp: false
6257
6291
  };
6258
6292
  const CODEX_CAPABILITIES = {
6259
6293
  contextChannel: "developer_instructions",
@@ -6275,8 +6309,9 @@ const CODEX_CAPABILITIES = {
6275
6309
  workspaceResolution: "agent-dir",
6276
6310
  correlatesBySessionId: true,
6277
6311
  answersQuestionByMessage: false,
6278
- askAnswerDelivery: "message",
6279
- runsOnFlyMachine: true
6312
+ askAnswerDelivery: "codex-approval",
6313
+ runsOnFlyMachine: true,
6314
+ overdeckMcp: true
6280
6315
  };
6281
6316
  const ACP_CAPABILITIES = {
6282
6317
  contextChannel: "acp-initial-context",
@@ -6299,7 +6334,8 @@ const ACP_CAPABILITIES = {
6299
6334
  correlatesBySessionId: true,
6300
6335
  answersQuestionByMessage: false,
6301
6336
  askAnswerDelivery: "message",
6302
- runsOnFlyMachine: false
6337
+ runsOnFlyMachine: false,
6338
+ overdeckMcp: true
6303
6339
  };
6304
6340
  const KIMI_CODE_CAPABILITIES = {
6305
6341
  contextChannel: "initial-message-envelope",
@@ -6322,7 +6358,8 @@ const KIMI_CODE_CAPABILITIES = {
6322
6358
  correlatesBySessionId: true,
6323
6359
  answersQuestionByMessage: false,
6324
6360
  askAnswerDelivery: "message",
6325
- runsOnFlyMachine: false
6361
+ runsOnFlyMachine: false,
6362
+ overdeckMcp: false
6326
6363
  };
6327
6364
  const OPENCODE_CAPABILITIES = {
6328
6365
  contextChannel: "acp-initial-context",
@@ -6345,7 +6382,8 @@ const OPENCODE_CAPABILITIES = {
6345
6382
  correlatesBySessionId: true,
6346
6383
  answersQuestionByMessage: false,
6347
6384
  askAnswerDelivery: "message",
6348
- runsOnFlyMachine: false
6385
+ runsOnFlyMachine: false,
6386
+ overdeckMcp: true
6349
6387
  };
6350
6388
  const MUSE_CAPABILITIES = {
6351
6389
  contextChannel: "append-system-prompt-file",
@@ -6368,7 +6406,8 @@ const MUSE_CAPABILITIES = {
6368
6406
  correlatesBySessionId: true,
6369
6407
  answersQuestionByMessage: false,
6370
6408
  askAnswerDelivery: "message",
6371
- runsOnFlyMachine: false
6409
+ runsOnFlyMachine: false,
6410
+ overdeckMcp: false
6372
6411
  };
6373
6412
  const PRIME_AGENT_CAPABILITIES = {
6374
6413
  contextChannel: "prime-agent-append-system-prompt",
@@ -6391,7 +6430,8 @@ const PRIME_AGENT_CAPABILITIES = {
6391
6430
  correlatesBySessionId: true,
6392
6431
  answersQuestionByMessage: false,
6393
6432
  askAnswerDelivery: "message",
6394
- runsOnFlyMachine: false
6433
+ runsOnFlyMachine: false,
6434
+ overdeckMcp: false
6395
6435
  };
6396
6436
  //#endregion
6397
6437
  //#region src/harness-behavior.ts
@@ -6754,7 +6794,14 @@ const TELEMETRY_EVENT_NAMES = [
6754
6794
  "pipeline_stage_changed",
6755
6795
  "github_quota_sample",
6756
6796
  "github_rate_limited",
6757
- "instance_heartbeat"
6797
+ "instance_heartbeat",
6798
+ "machine_link_started",
6799
+ "machine_link_approved",
6800
+ "machine_link_failed",
6801
+ "phone_paired",
6802
+ "phone_removed",
6803
+ "anywhere_channel_opened",
6804
+ "relay_usage_sampled"
6758
6805
  ];
6759
6806
  const TELEMETRY_CLI_VERBS = [
6760
6807
  "abort",
@@ -6827,6 +6874,27 @@ const TELEMETRY_PROPERTY_DOMAINS = {
6827
6874
  ],
6828
6875
  auto_merge_variant: ["segmented", "badge"],
6829
6876
  boolean: [false, true],
6877
+ channel_error_class: [
6878
+ "none",
6879
+ "unreachable",
6880
+ "identity_refused",
6881
+ "unknown_peer",
6882
+ "unsupported",
6883
+ "no_relay_plan",
6884
+ "descriptor_failed",
6885
+ "wrong_machine",
6886
+ "heartbeat_failed",
6887
+ "revoked"
6888
+ ],
6889
+ channel_route: [
6890
+ "lan",
6891
+ "tailnet",
6892
+ "ssh",
6893
+ "public",
6894
+ "direct",
6895
+ "relay",
6896
+ "stored"
6897
+ ],
6830
6898
  cli_verb: TELEMETRY_CLI_VERBS,
6831
6899
  close_out_variant: ["card", "inspector"],
6832
6900
  count_bucket: [
@@ -6900,6 +6968,27 @@ const TELEMETRY_PROPERTY_DOMAINS = {
6900
6968
  "muse",
6901
6969
  "prime-agent"
6902
6970
  ],
6971
+ link_failure_reason: [
6972
+ "bad_pairing_url",
6973
+ "unreachable",
6974
+ "pairing_refused",
6975
+ "unsupported",
6976
+ "identity_mismatch",
6977
+ "exchange_failed",
6978
+ "grant_refused",
6979
+ "offline",
6980
+ "approval_refused",
6981
+ "approval_failed",
6982
+ "other"
6983
+ ],
6984
+ link_method: [
6985
+ "pairing_code",
6986
+ "ssh",
6987
+ "fly",
6988
+ "directory_approval",
6989
+ "other"
6990
+ ],
6991
+ link_side: ["requester", "approver"],
6903
6992
  merge_kind: ["pipeline"],
6904
6993
  model_family: [
6905
6994
  "claude",
@@ -6911,6 +7000,7 @@ const TELEMETRY_PROPERTY_DOMAINS = {
6911
7000
  "mimo",
6912
7001
  "other"
6913
7002
  ],
7003
+ phone_removed_by: ["operator", "phone"],
6914
7004
  pipeline_stage: [
6915
7005
  "work_done",
6916
7006
  "review_passed",
@@ -6941,7 +7031,14 @@ const TELEMETRY_PROPERTY_DOMAINS = {
6941
7031
  "2500+",
6942
7032
  "unknown"
6943
7033
  ],
6944
- rate_limit_kind: ["primary", "secondary"]
7034
+ rate_limit_kind: ["primary", "secondary"],
7035
+ relay_bytes_bucket: [
7036
+ "under_1mb",
7037
+ "1mb-9mb",
7038
+ "10mb-99mb",
7039
+ "100mb-999mb",
7040
+ "1gb+"
7041
+ ]
6945
7042
  };
6946
7043
  const TELEMETRY_EVENT_CATALOG = {
6947
7044
  dashboard_tab_viewed: { tab: "dashboard_tab" },
@@ -7022,7 +7119,25 @@ const TELEMETRY_EVENT_CATALOG = {
7022
7119
  project_count: "count_bucket",
7023
7120
  active_agent_count: "count_bucket",
7024
7121
  dashboard_running: "boolean"
7025
- }
7122
+ },
7123
+ machine_link_started: { method: "link_method" },
7124
+ machine_link_approved: {
7125
+ method: "link_method",
7126
+ side: "link_side"
7127
+ },
7128
+ machine_link_failed: {
7129
+ method: "link_method",
7130
+ side: "link_side",
7131
+ reason: "link_failure_reason"
7132
+ },
7133
+ phone_paired: { replaced_previous: "boolean" },
7134
+ phone_removed: { by: "phone_removed_by" },
7135
+ anywhere_channel_opened: {
7136
+ route: "channel_route",
7137
+ ok: "boolean",
7138
+ error_class: "channel_error_class"
7139
+ },
7140
+ relay_usage_sampled: { bytes: "relay_bytes_bucket" }
7026
7141
  };
7027
7142
  /** PAN-4264: GitHub quota points as a coarse bucket (raw counts are never sent). */
7028
7143
  function bucketQuotaPoints(points) {
@@ -7044,6 +7159,14 @@ function bucketQuotaRemaining(remaining) {
7044
7159
  if (remaining < 2500) return "1000-2499";
7045
7160
  return "2500+";
7046
7161
  }
7162
+ /** PAN-5016: relayed bytes as a coarse bucket (raw byte counts are never sent). */
7163
+ function bucketRelayBytes(bytes) {
7164
+ if (!(bytes >= 1e6)) return "under_1mb";
7165
+ if (bytes < 1e7) return "1mb-9mb";
7166
+ if (bytes < 1e8) return "10mb-99mb";
7167
+ if (bytes < 1e9) return "100mb-999mb";
7168
+ return "1gb+";
7169
+ }
7047
7170
  //#endregion
7048
7171
  //#region src/composer-commands.generated.ts
7049
7172
  const COMPOSER_COMMAND_MANIFEST = [
@@ -7553,7 +7676,7 @@ const COMPOSER_COMMAND_MANIFEST = [
7553
7676
  "status"
7554
7677
  ],
7555
7678
  "display": "/pan skills pack sageox status",
7556
- "description": "Show, per project, the sageox pack state and the upload state",
7679
+ "description": "Show, per project, the sageox pack state, the upload state and the link state",
7557
7680
  "args": [],
7558
7681
  "options": [{
7559
7682
  "flags": "--project <key>",
@@ -7593,6 +7716,51 @@ const COMPOSER_COMMAND_MANIFEST = [
7593
7716
  "aliases": [],
7594
7717
  "category": "Core"
7595
7718
  },
7719
+ {
7720
+ "id": "pan-skills-pack-sageox-link",
7721
+ "path": [
7722
+ "skills",
7723
+ "pack",
7724
+ "sageox",
7725
+ "link"
7726
+ ],
7727
+ "display": "/pan skills pack sageox link",
7728
+ "description": "Run ox init in a throwaway worktree and store the project's SageOx link files (changes no checkout)",
7729
+ "args": [],
7730
+ "options": [{
7731
+ "flags": "--project <key>",
7732
+ "description": "Project key",
7733
+ "required": true,
7734
+ "valueHint": "key"
7735
+ }, {
7736
+ "flags": "--team <team>",
7737
+ "description": "SageOx team (name, slug or id) passed to ox init",
7738
+ "required": true,
7739
+ "valueHint": "team"
7740
+ }],
7741
+ "aliases": [],
7742
+ "category": "Core"
7743
+ },
7744
+ {
7745
+ "id": "pan-skills-pack-sageox-commit",
7746
+ "path": [
7747
+ "skills",
7748
+ "pack",
7749
+ "sageox",
7750
+ "commit"
7751
+ ],
7752
+ "display": "/pan skills pack sageox commit",
7753
+ "description": "Open one PR that adds the project's stored SageOx link files as .sageox/, then record sageox_binding: committed",
7754
+ "args": [],
7755
+ "options": [{
7756
+ "flags": "--project <key>",
7757
+ "description": "Project key",
7758
+ "required": true,
7759
+ "valueHint": "key"
7760
+ }],
7761
+ "aliases": [],
7762
+ "category": "Core"
7763
+ },
7596
7764
  {
7597
7765
  "id": "pan-skills-deft",
7598
7766
  "path": ["skills", "deft"],
@@ -8437,7 +8605,251 @@ const COMPOSER_COMMAND_MANIFEST = [
8437
8605
  "id": "pan-mcp-serve",
8438
8606
  "path": ["mcp", "serve"],
8439
8607
  "display": "/pan mcp serve",
8440
- "description": "Serve Overdeck as an MCP server over stdio (token from OVERDECK_MCP_TOKEN; see configuration/mcp.mdx)",
8608
+ "description": "Serve Overdeck as an MCP server over stdio (token from OVERDECK_MCP_TOKEN or OVERDECK_MCP_TOKEN_FILE; see configuration/mcp.mdx)",
8609
+ "args": [],
8610
+ "options": [],
8611
+ "aliases": [],
8612
+ "category": "CLI"
8613
+ },
8614
+ {
8615
+ "id": "pan-mcp-oauth",
8616
+ "path": ["mcp", "oauth"],
8617
+ "display": "/pan mcp oauth",
8618
+ "description": "Manage OAuth sign-ins to /mcp (see configuration/mcp.mdx)",
8619
+ "args": [],
8620
+ "options": [],
8621
+ "aliases": [],
8622
+ "category": "CLI"
8623
+ },
8624
+ {
8625
+ "id": "pan-mcp-oauth-issue",
8626
+ "path": [
8627
+ "mcp",
8628
+ "oauth",
8629
+ "issue"
8630
+ ],
8631
+ "display": "/pan mcp oauth issue",
8632
+ "description": "Create a sign-in for a client that cannot open a browser; prints its tokens once",
8633
+ "args": [],
8634
+ "options": [{
8635
+ "flags": "--name <name>",
8636
+ "description": "Name shown in the sign-in list",
8637
+ "required": true,
8638
+ "valueHint": "name"
8639
+ }, {
8640
+ "flags": "--level <level>",
8641
+ "description": "Access level: read, message, operate or approve",
8642
+ "required": true,
8643
+ "valueHint": "level"
8644
+ }],
8645
+ "aliases": [],
8646
+ "category": "CLI"
8647
+ },
8648
+ {
8649
+ "id": "pan-mcp-oauth-list",
8650
+ "path": [
8651
+ "mcp",
8652
+ "oauth",
8653
+ "list"
8654
+ ],
8655
+ "display": "/pan mcp oauth list",
8656
+ "description": "List active OAuth sign-ins",
8657
+ "args": [],
8658
+ "options": [],
8659
+ "aliases": [],
8660
+ "category": "CLI"
8661
+ },
8662
+ {
8663
+ "id": "pan-mcp-oauth-revoke",
8664
+ "path": [
8665
+ "mcp",
8666
+ "oauth",
8667
+ "revoke"
8668
+ ],
8669
+ "display": "/pan mcp oauth revoke",
8670
+ "description": "End one OAuth sign-in",
8671
+ "args": [{
8672
+ "name": "familyId",
8673
+ "required": true,
8674
+ "variadic": false
8675
+ }],
8676
+ "options": [],
8677
+ "aliases": [],
8678
+ "category": "CLI"
8679
+ },
8680
+ {
8681
+ "id": "pan-mcp-oauth-pending",
8682
+ "path": [
8683
+ "mcp",
8684
+ "oauth",
8685
+ "pending"
8686
+ ],
8687
+ "display": "/pan mcp oauth pending",
8688
+ "description": "List sign-ins waiting for your approval",
8689
+ "args": [],
8690
+ "options": [],
8691
+ "aliases": [],
8692
+ "category": "CLI"
8693
+ },
8694
+ {
8695
+ "id": "pan-mcp-oauth-approve",
8696
+ "path": [
8697
+ "mcp",
8698
+ "oauth",
8699
+ "approve"
8700
+ ],
8701
+ "display": "/pan mcp oauth approve",
8702
+ "description": "Approve the waiting sign-in that shows this approval code",
8703
+ "args": [{
8704
+ "name": "code",
8705
+ "required": true,
8706
+ "variadic": false
8707
+ }],
8708
+ "options": [{
8709
+ "flags": "--level <level>",
8710
+ "description": "Access level: read, message, operate or approve",
8711
+ "required": true,
8712
+ "valueHint": "level"
8713
+ }],
8714
+ "aliases": [],
8715
+ "category": "CLI"
8716
+ },
8717
+ {
8718
+ "id": "pan-mcp-oauth-deny",
8719
+ "path": [
8720
+ "mcp",
8721
+ "oauth",
8722
+ "deny"
8723
+ ],
8724
+ "display": "/pan mcp oauth deny",
8725
+ "description": "Deny the waiting sign-in that shows this approval code",
8726
+ "args": [{
8727
+ "name": "code",
8728
+ "required": true,
8729
+ "variadic": false
8730
+ }],
8731
+ "options": [],
8732
+ "aliases": [],
8733
+ "category": "CLI"
8734
+ },
8735
+ {
8736
+ "id": "pan-mcp-connector",
8737
+ "path": ["mcp", "connector"],
8738
+ "display": "/pan mcp connector",
8739
+ "description": "Run an Overdeck connector for a self-hosted bot (see configuration/mcp.mdx)",
8740
+ "args": [],
8741
+ "options": [],
8742
+ "aliases": [],
8743
+ "category": "CLI"
8744
+ },
8745
+ {
8746
+ "id": "pan-mcp-connector-login",
8747
+ "path": [
8748
+ "mcp",
8749
+ "connector",
8750
+ "login"
8751
+ ],
8752
+ "display": "/pan mcp connector login",
8753
+ "description": "Sign this connector in to overdeck.ai with the device flow",
8754
+ "args": [],
8755
+ "options": [{
8756
+ "flags": "--account-url <url>",
8757
+ "description": "overdeck.ai account service URL",
8758
+ "required": true,
8759
+ "valueHint": "url"
8760
+ }, {
8761
+ "flags": "--directory-url <url>",
8762
+ "description": "overdeck.ai directory URL",
8763
+ "required": true,
8764
+ "valueHint": "url"
8765
+ }],
8766
+ "aliases": [],
8767
+ "category": "CLI"
8768
+ },
8769
+ {
8770
+ "id": "pan-mcp-connector-pair",
8771
+ "path": [
8772
+ "mcp",
8773
+ "connector",
8774
+ "pair"
8775
+ ],
8776
+ "display": "/pan mcp connector pair",
8777
+ "description": "Pair with one Overdeck machine using the string from Connect a bot",
8778
+ "args": [{
8779
+ "name": "pairingString",
8780
+ "required": true,
8781
+ "variadic": false
8782
+ }],
8783
+ "options": [{
8784
+ "flags": "--label <name>",
8785
+ "description": "name this connector shows on the machine (default: host name)",
8786
+ "required": true,
8787
+ "valueHint": "name"
8788
+ }],
8789
+ "aliases": [],
8790
+ "category": "CLI"
8791
+ },
8792
+ {
8793
+ "id": "pan-mcp-connector-serve",
8794
+ "path": [
8795
+ "mcp",
8796
+ "connector",
8797
+ "serve"
8798
+ ],
8799
+ "display": "/pan mcp connector serve",
8800
+ "description": "Serve the Overdeck MCP tools on 127.0.0.1 (or stdio) for the paired machine",
8801
+ "args": [],
8802
+ "options": [
8803
+ {
8804
+ "flags": "--port <port>",
8805
+ "description": "loopback port for http://127.0.0.1:<port>/mcp (default 7466)",
8806
+ "required": true,
8807
+ "valueHint": "port"
8808
+ },
8809
+ {
8810
+ "flags": "--stdio",
8811
+ "description": "serve one MCP session on stdin and stdout instead",
8812
+ "required": false,
8813
+ "valueHint": null
8814
+ },
8815
+ {
8816
+ "flags": "--label <name>",
8817
+ "description": "name this connector shows in the overdeck.ai directory (default: host name)",
8818
+ "required": true,
8819
+ "valueHint": "name"
8820
+ }
8821
+ ],
8822
+ "aliases": [],
8823
+ "category": "CLI"
8824
+ },
8825
+ {
8826
+ "id": "pan-mcp-connector-status",
8827
+ "path": [
8828
+ "mcp",
8829
+ "connector",
8830
+ "status"
8831
+ ],
8832
+ "display": "/pan mcp connector status",
8833
+ "description": "Show the signed-in account, the paired machine, its scopes and the live route",
8834
+ "args": [],
8835
+ "options": [{
8836
+ "flags": "--port <port>",
8837
+ "description": "port of the running serve (default 7466)",
8838
+ "required": true,
8839
+ "valueHint": "port"
8840
+ }],
8841
+ "aliases": [],
8842
+ "category": "CLI"
8843
+ },
8844
+ {
8845
+ "id": "pan-mcp-connector-logout",
8846
+ "path": [
8847
+ "mcp",
8848
+ "connector",
8849
+ "logout"
8850
+ ],
8851
+ "display": "/pan mcp connector logout",
8852
+ "description": "Remove this connector from its machine and overdeck.ai, then delete its files",
8441
8853
  "args": [],
8442
8854
  "options": [],
8443
8855
  "aliases": [],
@@ -11277,6 +11689,44 @@ const COMPOSER_COMMAND_MANIFEST = [
11277
11689
  "aliases": [],
11278
11690
  "category": "CLI"
11279
11691
  },
11692
+ {
11693
+ "id": "pan-share",
11694
+ "path": ["share"],
11695
+ "display": "/pan share",
11696
+ "description": "Share a conversation by link: print the join link and join code (Shared Sessions)",
11697
+ "args": [{
11698
+ "name": "conversation",
11699
+ "required": true,
11700
+ "variadic": false
11701
+ }],
11702
+ "options": [{
11703
+ "flags": "--json",
11704
+ "description": "Print the share as JSON",
11705
+ "required": false,
11706
+ "valueHint": null
11707
+ }],
11708
+ "aliases": [],
11709
+ "category": "CLI"
11710
+ },
11711
+ {
11712
+ "id": "pan-join",
11713
+ "path": ["join"],
11714
+ "display": "/pan join",
11715
+ "description": "Join a shared conversation from a link or join code: signs in, starts Overdeck if needed, opens the lobby",
11716
+ "args": [{
11717
+ "name": "link-or-code",
11718
+ "required": true,
11719
+ "variadic": false
11720
+ }],
11721
+ "options": [{
11722
+ "flags": "--no-open",
11723
+ "description": "Print the shared-conversation URL instead of opening a browser",
11724
+ "required": false,
11725
+ "valueHint": null
11726
+ }],
11727
+ "aliases": [],
11728
+ "category": "CLI"
11729
+ },
11280
11730
  {
11281
11731
  "id": "pan-test",
11282
11732
  "path": ["test"],
@@ -11781,6 +12231,12 @@ const COMPOSER_COMMAND_MANIFEST = [
11781
12231
  "required": true,
11782
12232
  "valueHint": "n"
11783
12233
  },
12234
+ {
12235
+ "flags": "--facts",
12236
+ "description": "With --json: also return matching curated facts from this checkout, the operator and the machine store, scope the search to the current project, and print one line { facts, observations }",
12237
+ "required": false,
12238
+ "valueHint": null
12239
+ },
11784
12240
  {
11785
12241
  "flags": "--json",
11786
12242
  "description": "Output JSON",
@@ -16484,6 +16940,45 @@ const COMPOSER_COMMAND_MANIFEST = [
16484
16940
  "aliases": [],
16485
16941
  "category": "Core"
16486
16942
  },
16943
+ {
16944
+ "id": "pan-restart-hold",
16945
+ "path": ["restart", "hold"],
16946
+ "display": "/pan restart hold",
16947
+ "description": "Hold every dashboard restart and reload until `pan restart release` (or --until expires)",
16948
+ "args": [],
16949
+ "options": [
16950
+ {
16951
+ "flags": "--reason <text>",
16952
+ "description": "Why restarts are held; every refused command prints it",
16953
+ "required": true,
16954
+ "valueHint": "text"
16955
+ },
16956
+ {
16957
+ "flags": "--until <when>",
16958
+ "description": "Lift the hold on its own: a duration (90m, 2h, 1d) or an ISO time",
16959
+ "required": true,
16960
+ "valueHint": "when"
16961
+ },
16962
+ {
16963
+ "flags": "--status",
16964
+ "description": "Show the current hold instead of setting one",
16965
+ "required": false,
16966
+ "valueHint": null
16967
+ }
16968
+ ],
16969
+ "aliases": [],
16970
+ "category": "Core"
16971
+ },
16972
+ {
16973
+ "id": "pan-restart-release",
16974
+ "path": ["restart", "release"],
16975
+ "display": "/pan restart release",
16976
+ "description": "Release the restart hold so `pan reload` and `pan restart` run again",
16977
+ "args": [],
16978
+ "options": [],
16979
+ "aliases": [],
16980
+ "category": "Core"
16981
+ },
16487
16982
  {
16488
16983
  "id": "pan-project",
16489
16984
  "path": ["project"],
@@ -17947,7 +18442,7 @@ const MachinePlacementMode = effect.Schema.Literals(["auto", "on-request"]);
17947
18442
  /** PAN-4651 FR-6: `CPU 3% · 41 GB · 2 agents` (unknown parts `n/a`); null without a sample. */
17948
18443
  function formatMachineLoad(load) {
17949
18444
  if (!load) return null;
17950
- return `CPU ${load.cpuPsiSomeAvg10 === null ? "n/a" : `${Math.round(load.cpuPsiSomeAvg10)}%`} · ${load.memAvailableBytes === null ? "n/a" : `${Math.floor(load.memAvailableBytes / 2 ** 30)}`} GB · ${load.workingAgents} agents`;
18445
+ return `CPU ${load.cpuPsiSomeAvg10 === null ? "n/a" : `${Math.round(load.cpuPsiSomeAvg10)}%`} · ${load.memAvailableBytes === null ? "n/a" : `${Math.floor(load.memAvailableBytes / 2 ** 30)}`} GB · ${load.workingAgents} ${load.workingAgents === 1 ? "agent" : "agents"}`;
17951
18446
  }
17952
18447
  /** PAN-4651 FR-7: `tags: docker, linux · reserved`; null when there is neither. */
17953
18448
  function formatMachineProfile(tags, placement) {
@@ -18046,7 +18541,11 @@ const MachinesResponse = effect.Schema.Struct({
18046
18541
  /** PAN-4651: this machine's own load sample, tags and placement mode. */
18047
18542
  load: effect.Schema.optional(effect.Schema.NullOr(LoadSample)),
18048
18543
  tags: effect.Schema.optional(effect.Schema.Array(effect.Schema.String)),
18049
- placement: effect.Schema.optional(MachinePlacementMode)
18544
+ placement: effect.Schema.optional(MachinePlacementMode),
18545
+ /** PAN-4905: config.toml `[remote] enabled`; the Add a Fly machine dialog reads it before the click. */
18546
+ remoteEnabled: effect.Schema.optional(effect.Schema.Boolean),
18547
+ /** PAN-4905: config.toml as a display path (`~/.overdeck/config.toml`). */
18548
+ remoteConfigFile: effect.Schema.optional(effect.Schema.String)
18050
18549
  }),
18051
18550
  links: effect.Schema.Array(MachineLinkView),
18052
18551
  inbound: effect.Schema.Array(InboundMachineView)
@@ -18095,7 +18594,11 @@ const EnvironmentCapabilities = effect.Schema.Struct({
18095
18594
  /** `/ws/*` upgrades require a credential (PAN-1166). */
18096
18595
  terminalAuth: effect.Schema.Boolean,
18097
18596
  /** Secure machine links are accepted (PAN-4645). Absent on older servers ⇒ `unsupported`. */
18098
- machineLinks: effect.Schema.optional(effect.Schema.Boolean)
18597
+ machineLinks: effect.Schema.optional(effect.Schema.Boolean),
18598
+ /** The phone app can pair and use this machine (PAN-4835). Absent on older servers ⇒ unsupported. */
18599
+ phoneApp: effect.Schema.optional(effect.Schema.Boolean),
18600
+ /** An Overdeck connector can pair with this machine (PAN-4927 W-CONN1). Absent on older servers ⇒ unsupported. */
18601
+ connector: effect.Schema.optional(effect.Schema.Boolean)
18099
18602
  });
18100
18603
  const EnvironmentDescriptor = effect.Schema.Struct({
18101
18604
  descriptorVersion: effect.Schema.Literal(1),
@@ -18163,6 +18666,8 @@ const INBOX_HOLD_MS = 864e5;
18163
18666
  const APPROVAL_TTL_MS = 6e5;
18164
18667
  /** Phones (directory clients) one account may register (PAN-4823 D-2, NFR-3). Clients never count as machines. */
18165
18668
  const CLIENT_LIMIT = 5;
18669
+ /** PAN-4927 D-18: connectors are counted apart from phones. */
18670
+ const CONNECTOR_LIMIT = 10;
18166
18671
  /** Pushes the directory forwards per account per minute (PAN-4823 D-9). */
18167
18672
  const PUSH_RATE_PER_MINUTE = 30;
18168
18673
  /**
@@ -18175,10 +18680,19 @@ const PUSH_SEALED_MAX_CHARS = 3072;
18175
18680
  * grows by 4/3, so 2,256 bytes seal to exactly `PUSH_SEALED_MAX_CHARS` characters.
18176
18681
  */
18177
18682
  const PUSH_PLAINTEXT_MAX_BYTES = 2256;
18683
+ /** Live Activity (PAN-4839, OD-1): the most either count may be. */
18684
+ const ACTIVITY_COUNT_MAX = 9999;
18685
+ /** A machine's report counts toward a phone's card this long; also the APNs `stale-date` offset. */
18686
+ const ACTIVITY_STALE_MS = 6e5;
18687
+ /** The directory re-pushes unchanged counts at most this often, so the stale date moves ahead. */
18688
+ const ACTIVITY_REFRESH_MS = 24e4;
18689
+ /** Live Activity pushes per account per minute, counted apart from alert pushes (NFR-1). */
18690
+ const ACTIVITY_PUSH_RATE_PER_MINUTE = 60;
18178
18691
  const FREE_MACHINE_LIMIT_MESSAGE = "The free account includes 3 machines";
18179
18692
  const NO_DIRECT_PATH_MESSAGE = "No direct path; install Tailscale or use the relay plan";
18180
18693
  const RELAY_CAP_MESSAGE = "Relay allowance used; install Tailscale or add 50 GB";
18181
18694
  const CLIENT_LIMIT_MESSAGE = "This account already has 5 phones. Remove one in the app or on a machine.";
18695
+ const CONNECTOR_LIMIT_MESSAGE = "This account already has 10 Overdeck connectors. Remove one in Settings → Anywhere → Bots.";
18182
18696
  /** WebSocket close codes the directory uses. */
18183
18697
  const CONNECT_CLOSE_CODES = {
18184
18698
  unauthorized: 4001,
@@ -18188,7 +18702,7 @@ const CONNECT_CLOSE_CODES = {
18188
18702
  /** Replaced by a newer socket for the same machine. */
18189
18703
  replaced: 4011,
18190
18704
  forgotten: 4012,
18191
- /** A sixth phone on one account (PAN-4823 D-2). */
18705
+ /** A sixth phone or an eleventh connector on one account (PAN-4823 D-2, PAN-4927 D-18). */
18192
18706
  clientLimit: 4013
18193
18707
  };
18194
18708
  //#endregion
@@ -18279,6 +18793,120 @@ const DirectoryResponse = effect.Schema.Struct({
18279
18793
  relay: effect.Schema.NullOr(RelayStatusView)
18280
18794
  });
18281
18795
  //#endregion
18796
+ //#region src/phone-pairing.ts
18797
+ /** The phone app's bundle id and private-use URI scheme (RFC 8252 §7.1). */
18798
+ const PHONE_APP_SCHEME = "ai.overdeck.app";
18799
+ const PHONE_PAIR_LINK_VERSION = 1;
18800
+ /** Everything before the fragment. Single slash after the colon. */
18801
+ const PHONE_PAIR_LINK_PREFIX = `${PHONE_APP_SCHEME}:/pair#`;
18802
+ const PHONE_PAIR_ENVIRONMENT_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
18803
+ const PHONE_PAIR_MACHINE_KEY_RE = /^[0-9a-f]{64}$/;
18804
+ const PHONE_PAIR_CODE_RE = /^odp_[0-9a-f]{64}$/;
18805
+ /** `ai.overdeck.app:/pair#v=1&e=<environmentId>&k=<machineKeyHex>&c=<code>`; throws on a malformed input. */
18806
+ function buildPhonePairLink(input) {
18807
+ if (!PHONE_PAIR_ENVIRONMENT_ID_RE.test(input.environmentId)) throw new Error("environmentId must be a lowercase UUID v4");
18808
+ if (!PHONE_PAIR_MACHINE_KEY_RE.test(input.machineKeyHex)) throw new Error("machineKeyHex must be 64 lowercase hex characters");
18809
+ if (!PHONE_PAIR_CODE_RE.test(input.code)) throw new Error("code must be an odp_ pairing code");
18810
+ return `${PHONE_PAIR_LINK_PREFIX}v=1&e=${input.environmentId}&k=${input.machineKeyHex}&c=${input.code}`;
18811
+ }
18812
+ /** The inverse of `buildPhonePairLink`: the link's fields, or null unless every part is well formed. Surrounding whitespace is ignored. */
18813
+ function parsePhonePairLink(text) {
18814
+ const link = text.trim();
18815
+ if (!link.startsWith(PHONE_PAIR_LINK_PREFIX)) return null;
18816
+ const params = new URLSearchParams(link.slice(PHONE_PAIR_LINK_PREFIX.length));
18817
+ const environmentId = params.get("e");
18818
+ const machineKeyHex = params.get("k");
18819
+ const code = params.get("c");
18820
+ if (params.get("v") !== String(1)) return null;
18821
+ if (environmentId === null || !PHONE_PAIR_ENVIRONMENT_ID_RE.test(environmentId)) return null;
18822
+ if (machineKeyHex === null || !PHONE_PAIR_MACHINE_KEY_RE.test(machineKeyHex)) return null;
18823
+ if (code === null || !PHONE_PAIR_CODE_RE.test(code)) return null;
18824
+ return {
18825
+ environmentId,
18826
+ machineKeyHex,
18827
+ code
18828
+ };
18829
+ }
18830
+ //#endregion
18831
+ //#region src/phone-notifications.ts
18832
+ const PHONE_NOTIFICATION_CATEGORIES = [
18833
+ "question",
18834
+ "plan",
18835
+ "permission",
18836
+ "finished",
18837
+ "failed",
18838
+ "stopped"
18839
+ ];
18840
+ const DEFAULT_PHONE_NOTIFICATION_PREFERENCES = {
18841
+ v: 1,
18842
+ pause: null,
18843
+ muted: []
18844
+ };
18845
+ function isPlainObject$1(value) {
18846
+ return typeof value === "object" && value !== null && !Array.isArray(value);
18847
+ }
18848
+ function parsePause(value) {
18849
+ if (value === null) return null;
18850
+ if (!isPlainObject$1(value)) return void 0;
18851
+ const until = value.until;
18852
+ if (until === null) return { until: null };
18853
+ if (typeof until !== "string" || Number.isNaN(Date.parse(until))) return void 0;
18854
+ return { until };
18855
+ }
18856
+ /** Null for anything that is not a v1 prefs object; drops unknown/duplicate `muted` entries; never throws. */
18857
+ function parsePhoneNotificationPreferences(value) {
18858
+ if (!isPlainObject$1(value)) return null;
18859
+ if (value.v !== 1) return null;
18860
+ const pause = parsePause(value.pause);
18861
+ if (pause === void 0) return null;
18862
+ const rawMuted = value.muted;
18863
+ if (!Array.isArray(rawMuted)) return null;
18864
+ return {
18865
+ v: 1,
18866
+ pause,
18867
+ muted: PHONE_NOTIFICATION_CATEGORIES.filter((category) => rawMuted.includes(category))
18868
+ };
18869
+ }
18870
+ /** Whether a notification of `category` may go to a phone with `prefs` at `nowMs` (D-3). */
18871
+ function notificationAllowed(prefs, category, nowMs) {
18872
+ if (prefs === null) return true;
18873
+ if (category === "test") return true;
18874
+ if (prefs.pause !== null && (prefs.pause.until === null || Date.parse(prefs.pause.until) > nowMs)) return false;
18875
+ if (category === "summary") return true;
18876
+ return !prefs.muted.includes(category);
18877
+ }
18878
+ //#endregion
18879
+ //#region src/connector-pairing.ts
18880
+ const CONNECTOR_PAIR_SCHEME = "overdeck-connector";
18881
+ const CONNECTOR_PAIR_LINK_VERSION = 1;
18882
+ /** Everything before the fragment. Single slash after the colon. */
18883
+ const CONNECTOR_PAIR_LINK_PREFIX = `${CONNECTOR_PAIR_SCHEME}:/pair#`;
18884
+ /** `overdeck-connector:/pair#v=1&e=<environmentId>&k=<machineKeyHex>&c=<code>`; throws on a malformed input. */
18885
+ function buildConnectorPairLink(input) {
18886
+ if (!PHONE_PAIR_ENVIRONMENT_ID_RE.test(input.environmentId)) throw new Error("environmentId must be a lowercase UUID v4");
18887
+ if (!PHONE_PAIR_MACHINE_KEY_RE.test(input.machineKeyHex)) throw new Error("machineKeyHex must be 64 lowercase hex characters");
18888
+ if (!PHONE_PAIR_CODE_RE.test(input.code)) throw new Error("code must be an odp_ pairing code");
18889
+ return `${CONNECTOR_PAIR_LINK_PREFIX}v=1&e=${input.environmentId}&k=${input.machineKeyHex}&c=${input.code}`;
18890
+ }
18891
+ /** The inverse of `buildConnectorPairLink`: the string's fields, or null unless every part is well formed. Surrounding whitespace is ignored. */
18892
+ function parseConnectorPairLink(text) {
18893
+ const link = text.trim();
18894
+ if (!link.startsWith(CONNECTOR_PAIR_LINK_PREFIX)) return null;
18895
+ const params = new URLSearchParams(link.slice(CONNECTOR_PAIR_LINK_PREFIX.length));
18896
+ const environmentId = params.get("e");
18897
+ const machineKeyHex = params.get("k");
18898
+ const code = params.get("c");
18899
+ if (params.get("v") !== String(1)) return null;
18900
+ if (environmentId === null || !PHONE_PAIR_ENVIRONMENT_ID_RE.test(environmentId)) return null;
18901
+ if (machineKeyHex === null || !PHONE_PAIR_MACHINE_KEY_RE.test(machineKeyHex)) return null;
18902
+ if (code === null || !PHONE_PAIR_CODE_RE.test(code)) return null;
18903
+ return {
18904
+ environmentId,
18905
+ machineKeyHex,
18906
+ code
18907
+ };
18908
+ }
18909
+ //#endregion
18282
18910
  //#region src/fleet-versions.ts
18283
18911
  const FleetInstallMode = effect.Schema.Literals([
18284
18912
  "npm-global",
@@ -18363,6 +18991,269 @@ const MachineVersionsReportSchema = effect.Schema.Struct({
18363
18991
  job: effect.Schema.NullOr(FleetUpdateJobSchema)
18364
18992
  });
18365
18993
  //#endregion
18994
+ //#region src/sharing-wire.ts
18995
+ const SHARED_WIRE_VERSION = 1;
18996
+ const SHARED_SCOPE_KINDS = ["conversation"];
18997
+ const SHARED_CHANNELS = [
18998
+ "control",
18999
+ "conversation",
19000
+ "drafts",
19001
+ "terminal",
19002
+ "presence"
19003
+ ];
19004
+ /** The longest data-channel message: 32,768 UTF-16 code units, at most 96 KiB of UTF-8. Longer envelopes are fragmented. */
19005
+ const SHARE_MAX_MESSAGE_CHARS = 32768;
19006
+ /** The longest encoded envelope ever sent or reassembled. */
19007
+ const SHARE_MAX_ENVELOPE_CHARS = 32 * 1024 * 1024;
19008
+ /** The longest envelope a host reassembles from a viewer on `control` or `drafts` (NFR-3). */
19009
+ const SHARE_MAX_INBOUND_ENVELOPE_CHARS = 65536;
19010
+ /** The longest shared prompt or draft, in UTF-16 code units (D-11). */
19011
+ const SHARED_PROMPT_MAX_CHARS = 8e3;
19012
+ /**
19013
+ * The longest single message a fragment can be: JSON escaping can turn each of a slice's
19014
+ * SHARE_MAX_MESSAGE_CHARS code units into six (`\u0000`), plus the chunk header.
19015
+ */
19016
+ const MAX_FRAGMENT_MESSAGE_CHARS = SHARE_MAX_MESSAGE_CHARS * 6 + 256;
19017
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
19018
+ const isPositiveInteger = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0;
19019
+ const isNonNegativeInteger = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
19020
+ /** Copies only the allow-listed fields. Never spreads the input and never sets `author`. */
19021
+ function toSharedMessage(message) {
19022
+ const shared = {
19023
+ id: message.id,
19024
+ role: message.role,
19025
+ text: message.text,
19026
+ createdAt: message.createdAt
19027
+ };
19028
+ if (typeof message.turnId === "string") shared.turnId = message.turnId;
19029
+ if (typeof message.completedAt === "string") shared.completedAt = message.completedAt;
19030
+ if (typeof message.streaming === "boolean") shared.streaming = message.streaming;
19031
+ if (typeof message.sequence === "number" && Number.isFinite(message.sequence)) shared.sequence = message.sequence;
19032
+ return shared;
19033
+ }
19034
+ /**
19035
+ * `null` when a shared prompt may be delivered; the refusal reason otherwise (D-9). A leading `/`, `!`
19036
+ * or `#` would reach a composer command, a shell command or a memory note, so it is refused.
19037
+ */
19038
+ function sharedPromptRefusal(text) {
19039
+ const trimmed = text.trim();
19040
+ if (trimmed.length === 0) return "invalid_prompt";
19041
+ if (text.length > 8e3) return "too_long";
19042
+ const first = trimmed[0];
19043
+ return first === "/" || first === "!" || first === "#" ? "invalid_prompt" : null;
19044
+ }
19045
+ /** A host → viewer DraftPayload rebuilt from its known keys, or `null` when `value` is not one. */
19046
+ function readDraftPayload(value) {
19047
+ if (!isRecord(value)) return null;
19048
+ const { authorGithubId, authorLogin, text, updatedAt } = value;
19049
+ if (!isPositiveInteger(authorGithubId)) return null;
19050
+ if (typeof authorLogin !== "string") return null;
19051
+ if (typeof text !== "string" || text.length > 8e3) return null;
19052
+ if (typeof updatedAt !== "number" || !Number.isFinite(updatedAt)) return null;
19053
+ return {
19054
+ authorGithubId,
19055
+ authorLogin,
19056
+ text,
19057
+ updatedAt
19058
+ };
19059
+ }
19060
+ /** A new envelope with exactly the six envelope keys, or `null` when `value` is not one. */
19061
+ function decodeEnvelope(value) {
19062
+ if (!isRecord(value)) return null;
19063
+ const { v, ch, streamId, seq, t } = value;
19064
+ if (!isPositiveInteger(v)) return null;
19065
+ if (typeof ch !== "string" || !SHARED_CHANNELS.includes(ch)) return null;
19066
+ if (typeof streamId !== "string" || streamId.length === 0) return null;
19067
+ if (!isPositiveInteger(seq)) return null;
19068
+ if (typeof t !== "number" || !Number.isFinite(t)) return null;
19069
+ if (!Object.prototype.hasOwnProperty.call(value, "payload")) return null;
19070
+ return {
19071
+ v,
19072
+ ch,
19073
+ streamId,
19074
+ seq,
19075
+ t,
19076
+ payload: value.payload
19077
+ };
19078
+ }
19079
+ /**
19080
+ * Encodes one envelope as the data-channel messages to send in order: one message, or `count`
19081
+ * fragments when the encoded envelope is longer than SHARE_MAX_MESSAGE_CHARS. Slicing can split a
19082
+ * UTF-16 surrogate pair across fragments; the reader joins the slices before parsing, so the pair is
19083
+ * whole again. Throws RangeError when the encoded envelope is longer than SHARE_MAX_ENVELOPE_CHARS.
19084
+ */
19085
+ function encodeSharedMessage(envelope, chunkId) {
19086
+ const text = JSON.stringify(envelope);
19087
+ if (text.length > 33554432) throw new RangeError("shared envelope too large");
19088
+ if (text.length <= 32768) return [text];
19089
+ const count = Math.ceil(text.length / SHARE_MAX_MESSAGE_CHARS);
19090
+ const parts = [];
19091
+ for (let index = 0; index < count; index++) {
19092
+ const data = text.slice(index * SHARE_MAX_MESSAGE_CHARS, (index + 1) * SHARE_MAX_MESSAGE_CHARS);
19093
+ parts.push(JSON.stringify({
19094
+ v: 1,
19095
+ chunk: {
19096
+ id: chunkId,
19097
+ index,
19098
+ count
19099
+ },
19100
+ data
19101
+ }));
19102
+ }
19103
+ return parts;
19104
+ }
19105
+ /**
19106
+ * Reads one channel's messages in arrival order and reassembles fragmented envelopes. One reader per
19107
+ * channel. `maxEnvelopeChars` caps what one envelope may grow to; a host reading a viewer passes
19108
+ * SHARE_MAX_INBOUND_ENVELOPE_CHARS so one viewer cannot make it buffer megabytes.
19109
+ */
19110
+ var SharedChannelReader = class {
19111
+ partial = null;
19112
+ constructor(maxEnvelopeChars = SHARE_MAX_ENVELOPE_CHARS) {
19113
+ this.maxEnvelopeChars = maxEnvelopeChars;
19114
+ }
19115
+ read(text) {
19116
+ if (text.length > Math.max(this.maxEnvelopeChars, MAX_FRAGMENT_MESSAGE_CHARS)) return {
19117
+ kind: "invalid",
19118
+ reason: "too_large"
19119
+ };
19120
+ let value;
19121
+ try {
19122
+ value = JSON.parse(text);
19123
+ } catch {
19124
+ return {
19125
+ kind: "invalid",
19126
+ reason: "not_json"
19127
+ };
19128
+ }
19129
+ if (isRecord(value) && Object.prototype.hasOwnProperty.call(value, "chunk")) return this.readFragment(value);
19130
+ if (text.length > this.maxEnvelopeChars) return {
19131
+ kind: "invalid",
19132
+ reason: "too_large"
19133
+ };
19134
+ return decoded(value);
19135
+ }
19136
+ readFragment(value) {
19137
+ const { chunk, data } = value;
19138
+ if (!isRecord(chunk) || typeof data !== "string") return {
19139
+ kind: "invalid",
19140
+ reason: "not_envelope"
19141
+ };
19142
+ const { id, index, count } = chunk;
19143
+ if (typeof id !== "number" || !Number.isFinite(id) || !isNonNegativeInteger(index) || !isNonNegativeInteger(count) || index >= count) return {
19144
+ kind: "invalid",
19145
+ reason: "not_envelope"
19146
+ };
19147
+ if (count * 32768 > this.maxEnvelopeChars + 32768 || data.length > 32768) {
19148
+ this.partial = null;
19149
+ return {
19150
+ kind: "invalid",
19151
+ reason: "too_large"
19152
+ };
19153
+ }
19154
+ const partial = this.partial;
19155
+ if (partial === null) {
19156
+ if (index !== 0) return {
19157
+ kind: "invalid",
19158
+ reason: "chunk_out_of_order"
19159
+ };
19160
+ this.partial = {
19161
+ id,
19162
+ count,
19163
+ parts: [data]
19164
+ };
19165
+ } else {
19166
+ if (id !== partial.id || count !== partial.count || index !== partial.parts.length) {
19167
+ this.partial = null;
19168
+ return {
19169
+ kind: "invalid",
19170
+ reason: "chunk_out_of_order"
19171
+ };
19172
+ }
19173
+ partial.parts.push(data);
19174
+ }
19175
+ const current = this.partial;
19176
+ if (current === null || current.parts.length < current.count) return { kind: "pending" };
19177
+ this.partial = null;
19178
+ const text = current.parts.join("");
19179
+ if (text.length > this.maxEnvelopeChars) return {
19180
+ kind: "invalid",
19181
+ reason: "too_large"
19182
+ };
19183
+ let joined;
19184
+ try {
19185
+ joined = JSON.parse(text);
19186
+ } catch {
19187
+ return {
19188
+ kind: "invalid",
19189
+ reason: "not_json"
19190
+ };
19191
+ }
19192
+ return decoded(joined);
19193
+ }
19194
+ };
19195
+ function decoded(value) {
19196
+ const envelope = decodeEnvelope(value);
19197
+ return envelope === null ? {
19198
+ kind: "invalid",
19199
+ reason: "not_envelope"
19200
+ } : {
19201
+ kind: "envelope",
19202
+ envelope
19203
+ };
19204
+ }
19205
+ /** Detects `seq` gaps per channel and stream. A gap is reported once; tracking resumes after it. */
19206
+ var SeqTracker = class {
19207
+ expected = /* @__PURE__ */ new Map();
19208
+ observe(ch, streamId, seq) {
19209
+ const key = `${ch}\n${streamId}`;
19210
+ const expected = this.expected.get(key) ?? 1;
19211
+ this.expected.set(key, seq + 1);
19212
+ return seq === expected ? { ok: true } : {
19213
+ ok: false,
19214
+ expected,
19215
+ got: seq
19216
+ };
19217
+ }
19218
+ };
19219
+ /** Agrees on `min(local.v, remote.v)` when the remote hello is well formed and both sides support the shared scope. */
19220
+ function negotiateHello(local, remote) {
19221
+ if (!isRecord(remote)) return {
19222
+ ok: false,
19223
+ code: "invalid_hello"
19224
+ };
19225
+ const { v, scopeKinds, scope } = remote;
19226
+ if (!isPositiveInteger(v)) return {
19227
+ ok: false,
19228
+ code: "invalid_hello"
19229
+ };
19230
+ if (!Array.isArray(scopeKinds) || !scopeKinds.every((kind) => typeof kind === "string")) return {
19231
+ ok: false,
19232
+ code: "invalid_hello"
19233
+ };
19234
+ if (!isRecord(scope) || typeof scope.kind !== "string" || typeof scope.conversationId !== "string") return {
19235
+ ok: false,
19236
+ code: "invalid_hello"
19237
+ };
19238
+ const agreed = Math.min(local.v, v);
19239
+ if (agreed < 1) return {
19240
+ ok: false,
19241
+ code: "version_unsupported"
19242
+ };
19243
+ if (!scopeKinds.includes(local.scope.kind) || !local.scopeKinds.includes(scope.kind)) return {
19244
+ ok: false,
19245
+ code: "scope_kind_unsupported"
19246
+ };
19247
+ if (scope.kind !== local.scope.kind || scope.conversationId !== local.scope.conversationId) return {
19248
+ ok: false,
19249
+ code: "invalid_hello"
19250
+ };
19251
+ return {
19252
+ ok: true,
19253
+ v: agreed
19254
+ };
19255
+ }
19256
+ //#endregion
18366
19257
  //#region src/color-theme.ts
18367
19258
  const TERMINAL_PALETTE_KEYS = [
18368
19259
  "background",
@@ -18682,6 +19573,10 @@ function presetToCron(preset) {
18682
19573
  //#endregion
18683
19574
  exports.ACP_BEHAVIOR = ACP_BEHAVIOR;
18684
19575
  exports.ACP_CAPABILITIES = ACP_CAPABILITIES;
19576
+ exports.ACTIVITY_COUNT_MAX = ACTIVITY_COUNT_MAX;
19577
+ exports.ACTIVITY_PUSH_RATE_PER_MINUTE = ACTIVITY_PUSH_RATE_PER_MINUTE;
19578
+ exports.ACTIVITY_REFRESH_MS = ACTIVITY_REFRESH_MS;
19579
+ exports.ACTIVITY_STALE_MS = ACTIVITY_STALE_MS;
18685
19580
  exports.AGENT_ROLES = AGENT_ROLES;
18686
19581
  exports.APPROVAL_TTL_MS = APPROVAL_TTL_MS;
18687
19582
  exports.Activity = Activity;
@@ -18764,6 +19659,11 @@ exports.COMPANION_TERMINAL_OPEN_BODY_KEYS = COMPANION_TERMINAL_OPEN_BODY_KEYS;
18764
19659
  exports.COMPOSER_COMMAND_INSERT_OVERRIDES = COMPOSER_COMMAND_INSERT_OVERRIDES;
18765
19660
  exports.COMPOSER_COMMAND_MANIFEST = COMPOSER_COMMAND_MANIFEST;
18766
19661
  exports.COMPOSER_COMMAND_VARIANTS = COMPOSER_COMMAND_VARIANTS;
19662
+ exports.CONNECTOR_LIMIT = CONNECTOR_LIMIT;
19663
+ exports.CONNECTOR_LIMIT_MESSAGE = CONNECTOR_LIMIT_MESSAGE;
19664
+ exports.CONNECTOR_PAIR_LINK_PREFIX = CONNECTOR_PAIR_LINK_PREFIX;
19665
+ exports.CONNECTOR_PAIR_LINK_VERSION = CONNECTOR_PAIR_LINK_VERSION;
19666
+ exports.CONNECTOR_PAIR_SCHEME = CONNECTOR_PAIR_SCHEME;
18767
19667
  exports.CONNECT_CLOSE_CODES = CONNECT_CLOSE_CODES;
18768
19668
  exports.CONNECT_PROTOCOL_VERSION = CONNECT_PROTOCOL_VERSION;
18769
19669
  exports.CONTEXT_LAYER_KINDS = CONTEXT_LAYER_KINDS;
@@ -18815,6 +19715,7 @@ exports.CostEventRecordedEvent = CostEventRecordedEvent;
18815
19715
  exports.DEFAULT_EFFORT = DEFAULT_EFFORT;
18816
19716
  exports.DEFAULT_MAX_MEMORY_OBSERVATIONS_PER_ISSUE = DEFAULT_MAX_MEMORY_OBSERVATIONS_PER_ISSUE;
18817
19717
  exports.DEFAULT_MAX_TURN_DIFF_SUMMARIES_PER_AGENT = DEFAULT_MAX_TURN_DIFF_SUMMARIES_PER_AGENT;
19718
+ exports.DEFAULT_PHONE_NOTIFICATION_PREFERENCES = DEFAULT_PHONE_NOTIFICATION_PREFERENCES;
18818
19719
  exports.DashboardLifecycleCompletedEvent = DashboardLifecycleCompletedEvent;
18819
19720
  exports.DashboardLifecycleFailedEvent = DashboardLifecycleFailedEvent;
18820
19721
  exports.DashboardLifecycleStartedEvent = DashboardLifecycleStartedEvent;
@@ -19027,6 +19928,13 @@ exports.OrderBookLane = OrderBookLane;
19027
19928
  exports.OrderBookPosture = OrderBookPosture;
19028
19929
  exports.OrderBookSettings = OrderBookSettings;
19029
19930
  exports.OrderBookStatus = OrderBookStatus;
19931
+ exports.PHONE_APP_SCHEME = PHONE_APP_SCHEME;
19932
+ exports.PHONE_NOTIFICATION_CATEGORIES = PHONE_NOTIFICATION_CATEGORIES;
19933
+ exports.PHONE_PAIR_CODE_RE = PHONE_PAIR_CODE_RE;
19934
+ exports.PHONE_PAIR_ENVIRONMENT_ID_RE = PHONE_PAIR_ENVIRONMENT_ID_RE;
19935
+ exports.PHONE_PAIR_LINK_PREFIX = PHONE_PAIR_LINK_PREFIX;
19936
+ exports.PHONE_PAIR_LINK_VERSION = PHONE_PAIR_LINK_VERSION;
19937
+ exports.PHONE_PAIR_MACHINE_KEY_RE = PHONE_PAIR_MACHINE_KEY_RE;
19030
19938
  exports.PIPELINE_MEMBERSHIP_LOADING_CODE = PIPELINE_MEMBERSHIP_LOADING_CODE;
19031
19939
  exports.PRIME_AGENT_BEHAVIOR = PRIME_AGENT_BEHAVIOR;
19032
19940
  exports.PRIME_AGENT_CAPABILITIES = PRIME_AGENT_CAPABILITIES;
@@ -19100,6 +20008,7 @@ exports.RestartGateKind = RestartGateKind;
19100
20008
  exports.RestartGateOutcome = RestartGateOutcome;
19101
20009
  exports.RestartGateRequest = RestartGateRequest;
19102
20010
  exports.RestartGateSnapshot = RestartGateSnapshot;
20011
+ exports.RestartHold = RestartHold;
19103
20012
  exports.ReviewApprovedEvent = ReviewApprovedEvent;
19104
20013
  exports.ReviewCoordinatorDiedEvent = ReviewCoordinatorDiedEvent;
19105
20014
  exports.ReviewCoordinatorStartedEvent = ReviewCoordinatorStartedEvent;
@@ -19115,6 +20024,13 @@ exports.Role = Role;
19115
20024
  exports.RouteKind = RouteKind;
19116
20025
  exports.RouteSource = RouteSource;
19117
20026
  exports.SCHEDULE_PRESET_DAYS = SCHEDULE_PRESET_DAYS;
20027
+ exports.SHARED_CHANNELS = SHARED_CHANNELS;
20028
+ exports.SHARED_PROMPT_MAX_CHARS = SHARED_PROMPT_MAX_CHARS;
20029
+ exports.SHARED_SCOPE_KINDS = SHARED_SCOPE_KINDS;
20030
+ exports.SHARED_WIRE_VERSION = SHARED_WIRE_VERSION;
20031
+ exports.SHARE_MAX_ENVELOPE_CHARS = SHARE_MAX_ENVELOPE_CHARS;
20032
+ exports.SHARE_MAX_INBOUND_ENVELOPE_CHARS = SHARE_MAX_INBOUND_ENVELOPE_CHARS;
20033
+ exports.SHARE_MAX_MESSAGE_CHARS = SHARE_MAX_MESSAGE_CHARS;
19118
20034
  exports.SINGLETON_AGENT_IDS = SINGLETON_AGENT_IDS;
19119
20035
  exports.SSH_HELPER_PROTOCOL = SSH_HELPER_PROTOCOL;
19120
20036
  exports.SSH_MACHINE_ERROR_CODES = SSH_MACHINE_ERROR_CODES;
@@ -19132,6 +20048,7 @@ exports.ScopedRef = ScopedRef;
19132
20048
  exports.ScopedTerminalRef = ScopedTerminalRef;
19133
20049
  exports.SearchConversationsRpc = SearchConversationsRpc;
19134
20050
  exports.SendTerminalInputRpc = SendTerminalInputRpc;
20051
+ exports.SeqTracker = SeqTracker;
19135
20052
  exports.SequenceNumber = SequenceNumber;
19136
20053
  exports.ServiceHealthSnapshot = ServiceHealthSnapshot;
19137
20054
  exports.ServiceHealthStatus = ServiceHealthStatus;
@@ -19143,6 +20060,7 @@ exports.SessionsFeedFacetsSnapshot = SessionsFeedFacetsSnapshot;
19143
20060
  exports.SessionsFeedRowSnapshot = SessionsFeedRowSnapshot;
19144
20061
  exports.SessionsFeedSource = SessionsFeedSource;
19145
20062
  exports.ShadowInferenceUpdateEvent = ShadowInferenceUpdateEvent;
20063
+ exports.SharedChannelReader = SharedChannelReader;
19146
20064
  exports.ShellOpenInBrowserRpc = ShellOpenInBrowserRpc;
19147
20065
  exports.ShellOpenInEditorRpc = ShellOpenInEditorRpc;
19148
20066
  exports.SpecialistCompletedEvent = SpecialistCompletedEvent;
@@ -19215,6 +20133,9 @@ exports.applyEvents = applyEvents;
19215
20133
  exports.applyIssueDelta = applyIssueDelta;
19216
20134
  exports.bucketQuotaPoints = bucketQuotaPoints;
19217
20135
  exports.bucketQuotaRemaining = bucketQuotaRemaining;
20136
+ exports.bucketRelayBytes = bucketRelayBytes;
20137
+ exports.buildConnectorPairLink = buildConnectorPairLink;
20138
+ exports.buildPhonePairLink = buildPhonePairLink;
19218
20139
  exports.builtinFor = builtinFor;
19219
20140
  exports.canonicalPullRequestUrl = canonicalPullRequestUrl;
19220
20141
  exports.companionTerminalKindFor = companionTerminalKindFor;
@@ -19223,12 +20144,14 @@ exports.compareFleetBinaries = compareFleetBinaries;
19223
20144
  exports.compareIssueIds = compareIssueIds;
19224
20145
  exports.compareTimelineKeys = compareTimelineKeys;
19225
20146
  exports.createIssueDelta = createIssueDelta;
20147
+ exports.decodeEnvelope = decodeEnvelope;
19226
20148
  exports.decodeFlywheelDerivedStatus = decodeFlywheelDerivedStatus;
19227
20149
  exports.decodeFlywheelStats = decodeFlywheelStats;
19228
20150
  exports.decodeTimelineCursor = decodeTimelineCursor;
19229
20151
  exports.deriveProjectCi = deriveProjectCi;
19230
20152
  exports.effectiveTerminalPalette = effectiveTerminalPalette;
19231
20153
  exports.encodeFlywheelStats = encodeFlywheelStats;
20154
+ exports.encodeSharedMessage = encodeSharedMessage;
19232
20155
  exports.encodeTimelineCursor = encodeTimelineCursor;
19233
20156
  exports.formatMachineLoad = formatMachineLoad;
19234
20157
  exports.formatMachineProfile = formatMachineProfile;
@@ -19253,26 +20176,35 @@ exports.isTerminalBackendName = isTerminalBackendName;
19253
20176
  exports.isTerminalTurnDiffSummaryStatus = isTerminalTurnDiffSummaryStatus;
19254
20177
  exports.laneActivityOf = laneActivityOf;
19255
20178
  exports.linkedConversationName = linkedConversationName;
20179
+ exports.negotiateHello = negotiateHello;
19256
20180
  exports.normalizeChannelReplyPayload = normalizeChannelReplyPayload;
19257
20181
  exports.normalizeColorTheme = normalizeColorTheme;
19258
20182
  exports.normalizeHarnessName = normalizeHarnessName;
20183
+ exports.notificationAllowed = notificationAllowed;
19259
20184
  exports.omitTurnDiffSummariesForAgent = omitTurnDiffSummariesForAgent;
19260
20185
  exports.overdeckInstallCommand = overdeckInstallCommand;
19261
20186
  exports.paneAgentKey = paneAgentKey;
20187
+ exports.parseConnectorPairLink = parseConnectorPairLink;
19262
20188
  exports.parseLinkedConversationName = parseLinkedConversationName;
20189
+ exports.parsePhoneNotificationPreferences = parsePhoneNotificationPreferences;
20190
+ exports.parsePhonePairLink = parsePhonePairLink;
19263
20191
  exports.parsePullRequestRef = parsePullRequestRef;
19264
20192
  exports.parseTrackerIssueUrl = parseTrackerIssueUrl;
20193
+ exports.presenceForPaneState = presenceForPaneState;
19265
20194
  exports.presetToCron = presetToCron;
19266
20195
  exports.projectLegacySystemHealthSummary = projectLegacySystemHealthSummary;
20196
+ exports.readDraftPayload = readDraftPayload;
19267
20197
  exports.readableForeground = readableForeground;
19268
20198
  exports.repoFromRemoteUrl = repoFromRemoteUrl;
19269
20199
  exports.resolveEffectivePullRequest = resolveEffectivePullRequest;
19270
20200
  exports.resolveTrackerIssueId = resolveTrackerIssueId;
20201
+ exports.sharedPromptRefusal = sharedPromptRefusal;
19271
20202
  exports.slugifyThemeId = slugifyThemeId;
19272
20203
  exports.syncSnapshot = syncSnapshot;
19273
20204
  exports.timelineKeyOfMessage = timelineKeyOfMessage;
19274
20205
  exports.timelineKeyOfWork = timelineKeyOfWork;
19275
20206
  exports.toOpaqueHex = toOpaqueHex;
20207
+ exports.toSharedMessage = toSharedMessage;
19276
20208
  exports.trimMemoryObservations = trimMemoryObservations;
19277
20209
  exports.trimTurnDiffSummaries = trimTurnDiffSummaries;
19278
20210
  exports.withPaneLivenessAlias = withPaneLivenessAlias;