@songsid/agend 2.4.0-beta.13 → 2.4.0-beta.14

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 (172) hide show
  1. package/dist/agent-endpoint.js +28 -6
  2. package/dist/agent-endpoint.js.map +1 -1
  3. package/dist/backend/claude-code.d.ts +9 -0
  4. package/dist/backend/claude-code.js +60 -4
  5. package/dist/backend/claude-code.js.map +1 -1
  6. package/dist/backend/grok.js +11 -0
  7. package/dist/backend/grok.js.map +1 -1
  8. package/dist/backend/types.d.ts +3 -0
  9. package/dist/backend/types.js.map +1 -1
  10. package/dist/backend-availability.d.ts +1 -16
  11. package/dist/backend-availability.js +2 -91
  12. package/dist/backend-availability.js.map +1 -1
  13. package/dist/backend-version-static.d.ts +15 -0
  14. package/dist/backend-version-static.js +95 -0
  15. package/dist/backend-version-static.js.map +1 -0
  16. package/dist/build-provenance.json +1 -1
  17. package/dist/channel/adapters/telegram.js +3 -1
  18. package/dist/channel/adapters/telegram.js.map +1 -1
  19. package/dist/channel/mcp-server.js +18 -1
  20. package/dist/channel/mcp-server.js.map +1 -1
  21. package/dist/channel/tool-router.d.ts +4 -0
  22. package/dist/channel/tool-router.js +43 -19
  23. package/dist/channel/tool-router.js.map +1 -1
  24. package/dist/classic-channel-manager.d.ts +3 -0
  25. package/dist/classic-channel-manager.js +18 -0
  26. package/dist/classic-channel-manager.js.map +1 -1
  27. package/dist/classic-cli-guard.d.ts +66 -0
  28. package/dist/classic-cli-guard.js +209 -0
  29. package/dist/classic-cli-guard.js.map +1 -0
  30. package/dist/cli-audited.js +7 -5
  31. package/dist/cli-audited.js.map +1 -1
  32. package/dist/config-validator.js +3 -0
  33. package/dist/config-validator.js.map +1 -1
  34. package/dist/contact-auth-api.d.ts +16 -0
  35. package/dist/contact-auth-api.js +78 -0
  36. package/dist/contact-auth-api.js.map +1 -0
  37. package/dist/contact-auth-files.d.ts +6 -0
  38. package/dist/contact-auth-files.js +29 -0
  39. package/dist/contact-auth-files.js.map +1 -0
  40. package/dist/contact-auth-policy.d.ts +75 -0
  41. package/dist/contact-auth-policy.js +23 -0
  42. package/dist/contact-auth-policy.js.map +1 -0
  43. package/dist/contact-auth-service.d.ts +32 -0
  44. package/dist/contact-auth-service.js +99 -0
  45. package/dist/contact-auth-service.js.map +1 -0
  46. package/dist/contact-auth-store.d.ts +75 -0
  47. package/dist/contact-auth-store.js +295 -0
  48. package/dist/contact-auth-store.js.map +1 -0
  49. package/dist/contact-auth-types.d.ts +170 -0
  50. package/dist/contact-auth-types.js +7 -0
  51. package/dist/contact-auth-types.js.map +1 -0
  52. package/dist/daemon.d.ts +8 -0
  53. package/dist/daemon.js +93 -4
  54. package/dist/daemon.js.map +1 -1
  55. package/dist/delivery-outbox.d.ts +6 -0
  56. package/dist/delivery-outbox.js +19 -0
  57. package/dist/delivery-outbox.js.map +1 -1
  58. package/dist/fleet-manager.d.ts +40 -0
  59. package/dist/fleet-manager.js +429 -22
  60. package/dist/fleet-manager.js.map +1 -1
  61. package/dist/general-knowledge/skills/concepts/SKILL.md +18 -0
  62. package/dist/general-knowledge/skills/credential-profiles/SKILL.md +5 -0
  63. package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +28 -0
  64. package/dist/general-knowledge/skills/hub/SKILL.md +6 -0
  65. package/dist/hub/audit/index.d.ts +3 -1
  66. package/dist/hub/audit/index.js +35 -3
  67. package/dist/hub/audit/index.js.map +1 -1
  68. package/dist/hub/catalog.d.ts +8 -0
  69. package/dist/hub/catalog.js +39 -4
  70. package/dist/hub/catalog.js.map +1 -1
  71. package/dist/hub/compose/server.d.ts +2 -0
  72. package/dist/hub/compose/server.js +11 -1
  73. package/dist/hub/compose/server.js.map +1 -1
  74. package/dist/hub/directory/directory.js +5 -2
  75. package/dist/hub/directory/directory.js.map +1 -1
  76. package/dist/hub/directory/types.d.ts +5 -1
  77. package/dist/hub/directory/types.js.map +1 -1
  78. package/dist/hub/group-policy/resources.d.ts +1 -1
  79. package/dist/hub/http/compose.d.ts +2 -0
  80. package/dist/hub/http/compose.js +123 -6
  81. package/dist/hub/http/compose.js.map +1 -1
  82. package/dist/hub/http/deps.d.ts +2 -0
  83. package/dist/hub/http/schema.js +6 -1
  84. package/dist/hub/http/schema.js.map +1 -1
  85. package/dist/hub/invitations.js +15 -7
  86. package/dist/hub/invitations.js.map +1 -1
  87. package/dist/hub/roles/cutover-inventory.d.ts +3 -0
  88. package/dist/hub/roles/cutover-inventory.js +20 -4
  89. package/dist/hub/roles/cutover-inventory.js.map +1 -1
  90. package/dist/hub/roles/cutover-marker.d.ts +18 -2
  91. package/dist/hub/roles/cutover-marker.js +6 -2
  92. package/dist/hub/roles/cutover-marker.js.map +1 -1
  93. package/dist/hub/room-agent-discovery-model.d.ts +29 -0
  94. package/dist/hub/room-agent-discovery-model.js +33 -0
  95. package/dist/hub/room-agent-discovery-model.js.map +1 -0
  96. package/dist/hub/room-agent-discovery.d.ts +14 -0
  97. package/dist/hub/room-agent-discovery.js +65 -0
  98. package/dist/hub/room-agent-discovery.js.map +1 -0
  99. package/dist/hub/room-agent-requests.d.ts +71 -0
  100. package/dist/hub/room-agent-requests.js +377 -0
  101. package/dist/hub/room-agent-requests.js.map +1 -0
  102. package/dist/hub/rooms/directory.d.ts +13 -0
  103. package/dist/hub/rooms/directory.js +12 -3
  104. package/dist/hub/rooms/directory.js.map +1 -1
  105. package/dist/hub/rooms/schema.d.ts +5 -0
  106. package/dist/hub/rooms/schema.js +9 -0
  107. package/dist/hub/rooms/schema.js.map +1 -1
  108. package/dist/hub/rooms/service.d.ts +43 -19
  109. package/dist/hub/rooms/service.js +67 -11
  110. package/dist/hub/rooms/service.js.map +1 -1
  111. package/dist/hub/rooms/types.d.ts +1 -1
  112. package/dist/instance-lifecycle.d.ts +3 -1
  113. package/dist/instance-lifecycle.js +4 -1
  114. package/dist/instance-lifecycle.js.map +1 -1
  115. package/dist/locale.js +28 -4
  116. package/dist/locale.js.map +1 -1
  117. package/dist/needs-you-hub.d.ts +1 -0
  118. package/dist/needs-you-hub.js +6 -0
  119. package/dist/needs-you-hub.js.map +1 -1
  120. package/dist/needs-you.d.ts +10 -2
  121. package/dist/needs-you.js.map +1 -1
  122. package/dist/outbound-handlers.d.ts +9 -0
  123. package/dist/outbound-handlers.js +46 -10
  124. package/dist/outbound-handlers.js.map +1 -1
  125. package/dist/runtime-cli-install.js +7 -7
  126. package/dist/runtime-cli-install.js.map +1 -1
  127. package/dist/topic-commands.d.ts +1 -1
  128. package/dist/topic-commands.js +4 -6
  129. package/dist/topic-commands.js.map +1 -1
  130. package/dist/ui/agent-details-settings.js +7 -5
  131. package/dist/ui/contact-auth-client.js +48 -0
  132. package/dist/ui/contact-auth-strings.js +164 -0
  133. package/dist/ui/contact-authorizations.js +125 -0
  134. package/dist/ui/contact-needs.js +84 -0
  135. package/dist/ui/contact-permissions.js +193 -0
  136. package/dist/ui/contact-ticket-badge.js +54 -0
  137. package/dist/ui/hub-client.js +30 -7
  138. package/dist/ui/hub-invitations.js +5 -1
  139. package/dist/ui/hub-room-new.js +10 -3
  140. package/dist/ui/hub-room-owner-requests-strings.js +114 -0
  141. package/dist/ui/hub-room-owner-requests.js +264 -0
  142. package/dist/ui/hub-room-pins.js +43 -0
  143. package/dist/ui/hub-room-settings.js +11 -2
  144. package/dist/ui/hub-room-strings.js +3 -0
  145. package/dist/ui/hub-room-thread.js +47 -5
  146. package/dist/ui/panel-chat.js +2 -0
  147. package/dist/ui/panel-details.js +2 -0
  148. package/dist/ui/panel-fleet.js +3 -2
  149. package/dist/ui/panel-hub.js +7 -1
  150. package/dist/ui/panel-needs.js +5 -1
  151. package/dist/ui/panel-settings.js +3 -0
  152. package/dist/ui/shared/app-route.js +1 -1
  153. package/dist/ui/shared/app-shell.js +2 -0
  154. package/dist/ui/shared/app-stream.js +3 -1
  155. package/dist/ui/shared/app.css +31 -0
  156. package/dist/ui/shared/chat-quote.js +26 -2
  157. package/dist/ui/shared/chat-thread.js +6 -2
  158. package/dist/ui/shared/hub-rooms-u2.css +22 -0
  159. package/dist/ui/shared/text-undo.js +17 -3
  160. package/dist/web-api.d.ts +9 -0
  161. package/dist/web-api.js +55 -3
  162. package/dist/web-api.js.map +1 -1
  163. package/dist/web-chat-history.d.ts +5 -0
  164. package/dist/web-chat-history.js +26 -0
  165. package/dist/web-chat-history.js.map +1 -1
  166. package/dist/web-reply-files.d.ts +1 -0
  167. package/dist/web-reply-files.js +2 -0
  168. package/dist/web-reply-files.js.map +1 -1
  169. package/dist/web-shell-routes.d.ts +1 -1
  170. package/dist/web-shell-routes.js +2 -1
  171. package/dist/web-shell-routes.js.map +1 -1
  172. package/package.json +1 -1
@@ -0,0 +1,170 @@
1
+ /** M-3339 wire contract. All identities and origins are resolved by the server. */
2
+ export interface ContactPerson {
3
+ platform: "discord" | "telegram" | "host";
4
+ adapterId: string;
5
+ userId: string;
6
+ label: string;
7
+ }
8
+ export type ContactVerb = "send_to_instance" | "delegate_task" | "request_information" | "broadcast" | "report_result";
9
+ export type ContactTicketState = "pending" | "approved" | "delivered" | "declined" | "expired" | "unknown";
10
+ export interface ContactGuardStatus {
11
+ state: "ready" | "restart-required" | "not-covered" | "failed";
12
+ backend: string;
13
+ version?: string;
14
+ wouldDisable?: string[];
15
+ impactComplete?: boolean;
16
+ reason?: string;
17
+ }
18
+ export interface ContactRoomTool {
19
+ /** Exact backend tool identity; no wildcard or command-fragment matching. */
20
+ name: string;
21
+ kind: "public-read" | "mcp";
22
+ usesOwnerAccount: boolean;
23
+ /** Server label, never a credential value. */
24
+ accountWarning?: string;
25
+ }
26
+ export interface ContactRoomTools {
27
+ /** Public WebSearch/WebFetch or the verified backend equivalents stay available. */
28
+ publicRead: boolean;
29
+ allowedMcpTools: ContactRoomTool[];
30
+ /** Current tools that would stop if this legacy room switched. */
31
+ wouldDisable: string[];
32
+ }
33
+ export interface ContactOrigin {
34
+ /** Unknown and mixed origins never acquire admin authority from message text. */
35
+ kind: "human" | "unknown" | "mixed";
36
+ people: ContactPerson[];
37
+ receiptIds: string[];
38
+ /** Server-owned instance hops, oldest first; no authority is conveyed by labels. */
39
+ chain: string[];
40
+ }
41
+ export interface ContactGrant {
42
+ id: string;
43
+ person: ContactPerson;
44
+ source: string;
45
+ target: string;
46
+ sourceGeneration?: string;
47
+ targetGeneration?: string;
48
+ verbs: ContactVerb[];
49
+ expiresAt: string;
50
+ /** null means reusable until expiry, otherwise a remaining dispatch count. */
51
+ remainingUses: number | null;
52
+ createdBy: ContactPerson;
53
+ createdAt: string;
54
+ }
55
+ export interface ContactTicket {
56
+ id: string;
57
+ revision: number;
58
+ scope: "peer.dispatch";
59
+ state: ContactTicketState;
60
+ source: string;
61
+ target: string;
62
+ sourceGeneration: string;
63
+ targetGeneration: string;
64
+ verb: ContactVerb;
65
+ origin: ContactOrigin;
66
+ /** Visible only to an authorized approver or the source room's authorized admin. */
67
+ message: string;
68
+ requestHash: string;
69
+ correlationId: string;
70
+ resultRecipient: string;
71
+ createdAt: string;
72
+ expiresAt: string;
73
+ decidedAt?: string;
74
+ decidedBy?: ContactPerson;
75
+ grantId?: string;
76
+ grantIds?: string[];
77
+ deliveryId?: string;
78
+ /** Contact delivery, never a claim that the target completed its task. */
79
+ reason?: string;
80
+ canDecide: boolean;
81
+ }
82
+ export interface ContactHistoryRow {
83
+ id: string;
84
+ at: string;
85
+ actor: ContactPerson;
86
+ action: "policy" | "approve" | "decline" | "grant-add" | "grant-remove" | "grant-use";
87
+ ticketId?: string;
88
+ summary: string;
89
+ source?: string;
90
+ target?: string;
91
+ generation?: string;
92
+ policyChange?: {
93
+ approvers?: {
94
+ before: ContactPerson[] | null;
95
+ after: ContactPerson[] | null;
96
+ };
97
+ grants?: {
98
+ before: ContactGrant[];
99
+ after: ContactGrant[];
100
+ };
101
+ roomTools?: {
102
+ before: ContactRoomTools;
103
+ after: ContactRoomTools;
104
+ };
105
+ modeRequested?: "legacy" | "restricted";
106
+ };
107
+ }
108
+ export interface ContactPermissions {
109
+ instance: string;
110
+ revision: number;
111
+ classicRoom: boolean;
112
+ mode: "legacy" | "restricted";
113
+ approvers: ContactPerson[];
114
+ /** Slice 1: only the target adapter's Fleet admins (or verified host operator). */
115
+ eligibleApprovers: ContactPerson[];
116
+ /** True when approvers are inherited from the target's owning adapter. */
117
+ inheritedApprovers: boolean;
118
+ nativeGuard: ContactGuardStatus;
119
+ roomTools: ContactRoomTools;
120
+ canManage: boolean;
121
+ canSetMode: boolean;
122
+ suggestRestricted: boolean;
123
+ grants: ContactGrant[];
124
+ history: ContactHistoryRow[];
125
+ originRestriction?: {
126
+ active: true;
127
+ reason: "earlier-non-admin" | "unknown-origin";
128
+ resetSupported: false;
129
+ };
130
+ }
131
+ export interface ContactPermissionsWrite {
132
+ revision: number;
133
+ mode?: "legacy" | "restricted";
134
+ approvers?: ContactPerson[];
135
+ roomTools?: Pick<ContactRoomTools, "publicRead" | "allowedMcpTools">;
136
+ /** Replaces the contact table, with an explicit optimistic revision check. */
137
+ grants?: Array<Pick<ContactGrant, "id" | "person" | "source" | "target" | "verbs" | "expiresAt" | "remainingUses">>;
138
+ }
139
+ export interface ContactTicketPage {
140
+ items: ContactTicket[];
141
+ nextCursor: string | null;
142
+ }
143
+ export interface ContactTicketDecision {
144
+ revision: number;
145
+ decision: "approve-once" | "decline";
146
+ /** Separate, explicit opt-in; never inferred from clicking Approve once. */
147
+ grant?: {
148
+ expiresAt: string;
149
+ remainingUses: number | null;
150
+ };
151
+ }
152
+ export interface ContactHeldResult {
153
+ sent: false;
154
+ held: true;
155
+ authorization_id: string;
156
+ authorization_state: ContactTicketState;
157
+ message: string;
158
+ }
159
+ export interface ContactBadge {
160
+ id: string;
161
+ state: ContactTicketState;
162
+ }
163
+ /** SSE `contact-auth`: clients refresh their scoped list and affected detail. */
164
+ export interface ContactAuthEvent {
165
+ instance: string;
166
+ ticketId?: string;
167
+ revision: number;
168
+ }
169
+ /** AgEnD tool ceiling, separate from room-configured public-read and MCP tools. */
170
+ export declare const CLASSIC_RESTRICTED_TOOLS: readonly string[];
@@ -0,0 +1,7 @@
1
+ /** AgEnD tool ceiling, separate from room-configured public-read and MCP tools. */
2
+ export const CLASSIC_RESTRICTED_TOOLS = Object.freeze([
3
+ "reply", "react", "edit_message", "download_attachment", "close_poll",
4
+ "list_instances", "describe_instance", "list_teams", "delivery_status",
5
+ "send_to_instance", "delegate_task", "request_information", "broadcast", "report_result",
6
+ ]);
7
+ //# sourceMappingURL=contact-auth-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contact-auth-types.js","sourceRoot":"","sources":["../src/contact-auth-types.ts"],"names":[],"mappings":"AAgJA,mFAAmF;AACnF,MAAM,CAAC,MAAM,wBAAwB,GAAsB,MAAM,CAAC,MAAM,CAAC;IACvE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,YAAY;IACrE,gBAAgB,EAAE,mBAAmB,EAAE,YAAY,EAAE,iBAAiB;IACtE,kBAAkB,EAAE,eAAe,EAAE,qBAAqB,EAAE,WAAW,EAAE,eAAe;CACzF,CAAC,CAAC"}
package/dist/daemon.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { type ClassicRestrictionInput } from "./classic-cli-guard.js";
2
+ import { type ContactGuardStatus } from "./contact-auth-types.js";
1
3
  import { type ModelObservation } from "./claude-model-observation.js";
2
4
  import type { SubagentSource } from "./subagent-service.js";
3
5
  import type { RecoveryLive } from "./working-recovery.js";
@@ -1134,6 +1136,12 @@ export declare class Daemon extends EventEmitter {
1134
1136
  acceptNativeFleetMessage(message: Record<string, unknown>): boolean;
1135
1137
  private broadcastFleetMessage;
1136
1138
  private fleetTransportAvailable;
1139
+ private classicRestriction;
1140
+ private classicRestrictionFailed;
1141
+ private classicRestrictionNeedsRestart;
1142
+ setClassicRestriction(input: ClassicRestrictionInput): void;
1143
+ private assertClassicRestrictionLaunch;
1144
+ classicNativeGuard(): ContactGuardStatus;
1137
1145
  /** Internal lifecycle injection, before start. Native paths and provider files stay on their runner. */
1138
1146
  setNativePaneLifecycle(native: NativePaneLifecycle): void;
1139
1147
  constructor(name: string, config: InstanceConfig, instanceDir: string, topicMode?: boolean, backend?: CliBackend | undefined, controlClient?: PaneObservation | undefined, rootLogger?: Logger, runtimeIdentity?: FleetInstructionsParams["runtimeIdentity"], spawnGate?: SpawnGate | undefined, stormWindow?: StormWindow | undefined,
package/dist/daemon.js CHANGED
@@ -2,6 +2,8 @@ import { HUB_REPORT_TARGET } from "./hub-report-target.js";
2
2
  import { RoomConversationGeneration, roomContextInputMarker } from "./hub-room-conversation.js";
3
3
  import { checkpointGrokDelivery } from "./grok-delivery-proof.js";
4
4
  import { nativePaneToolRefusal } from "./native-pane-tools.js";
5
+ import { classicGuardInventory, classicPlanDigest, invalidateClassicGuard } from "./classic-cli-guard.js";
6
+ import { CLASSIC_RESTRICTED_TOOLS } from "./contact-auth-types.js";
5
7
  import { generalByName } from "./general-instance.js";
6
8
  import { ClaudeModelObserver, normalizeClaudeModel } from "./claude-model-observation.js";
7
9
  import { codexMetadataHomes } from "./backend/codex-metadata.js";
@@ -1887,7 +1889,20 @@ export class Daemon extends EventEmitter {
1887
1889
  if (!current())
1888
1890
  return;
1889
1891
  const patterns = this.paneQuotaPatterns();
1890
- const messages = oldPane.split(/\r?\n/).filter(row => patterns.some(ep => ep.pattern.test(row)));
1892
+ // A quota frame can span several wrapped rows. Keep the complete rows
1893
+ // each actual match covered, rather than testing the rows independently.
1894
+ // Exact spans dedupe overlapping rules without collapsing repeated hits.
1895
+ const spans = new Map();
1896
+ for (const ep of patterns) {
1897
+ const flags = ep.pattern.flags.includes("g") ? ep.pattern.flags : ep.pattern.flags + "g";
1898
+ for (const match of oldPane.matchAll(new RegExp(ep.pattern.source, flags))) {
1899
+ const start = oldPane.lastIndexOf("\n", match.index) + 1;
1900
+ const newline = oldPane.indexOf("\n", match.index + match[0].length);
1901
+ const end = newline < 0 ? oldPane.length : newline;
1902
+ spans.set(`${start}:${end}`, oldPane.slice(start, end));
1903
+ }
1904
+ }
1905
+ const messages = [...spans.values()];
1891
1906
  this.quotaReplay = { messages, current: () => true, spawn, fence, attempt };
1892
1907
  }
1893
1908
  }
@@ -1903,7 +1918,13 @@ export class Daemon extends EventEmitter {
1903
1918
  this.quotaReplay = null;
1904
1919
  if (history.spawn !== this.spawnGeneration || history.fence !== this.launchFenceEpoch || history.attempt !== this.launchAttempt || !history.current())
1905
1920
  return;
1906
- for (const ep of this.paneQuotaPatterns()) {
1921
+ const patterns = this.paneQuotaPatterns();
1922
+ // Grok's old quota frame can also contain a 401. That same proven frame
1923
+ // must not arm the auth gate after its quota was absorbed as history.
1924
+ if (this.backend?.binaryName === "grok") {
1925
+ patterns.push(...(this.backend.getErrorPatterns?.() ?? []).filter(ep => ep.type === "auth_error"));
1926
+ }
1927
+ for (const ep of patterns) {
1907
1928
  const count = Math.min(Daemon.countOccurrences(ep.pattern, pane), quotaHistoryCount(pane, ep.pattern, history.messages));
1908
1929
  if (!count)
1909
1930
  continue;
@@ -2220,6 +2241,63 @@ export class Daemon extends EventEmitter {
2220
2241
  fleetTransportAvailable() {
2221
2242
  return this.nativePaneLifecycle ? !!this.nativeFleetBridge?.current() && !this.runtimeMonitorsFrozen : !!this.ipcServer;
2222
2243
  }
2244
+ classicRestriction;
2245
+ classicRestrictionFailed = false;
2246
+ classicRestrictionNeedsRestart = false;
2247
+ setClassicRestriction(input) {
2248
+ if (this.runtimeIdentity?.kind !== "classic") {
2249
+ if (input?.mode === "legacy")
2250
+ return; // The optional adapter also sees existing/default-kind starts.
2251
+ throw Error("Classic restriction requires a Classic room");
2252
+ }
2253
+ try {
2254
+ if (!input || !["legacy", "restricted"].includes(input.mode))
2255
+ throw Error("invalid-policy");
2256
+ const next = input.mode === "restricted" ? { roomKey: this.name, policyRevision: input.policyRevision ?? 0,
2257
+ publicRead: input.roomTools.publicRead, allowedMcpTools: structuredClone(input.roomTools.allowedMcpTools),
2258
+ allowedAgendTools: [...CLASSIC_RESTRICTED_TOOLS] } : undefined;
2259
+ // A1's revision also changes for contact grants and approvers. Validate it,
2260
+ // but preserve the frozen launch when the native tool policy is unchanged.
2261
+ if (next)
2262
+ classicPlanDigest(next);
2263
+ const before = this.classicRestriction ? classicPlanDigest({ ...this.classicRestriction, policyRevision: 0 }) : null;
2264
+ const after = next ? classicPlanDigest({ ...next, policyRevision: 0 }) : null;
2265
+ if (before !== after) {
2266
+ invalidateClassicGuard(this.instanceDir);
2267
+ if (this.classicRestriction && !next && this.processStatus === "running")
2268
+ this.classicRestrictionNeedsRestart = true;
2269
+ this.classicRestriction = next;
2270
+ }
2271
+ this.classicRestrictionFailed = false;
2272
+ }
2273
+ catch {
2274
+ this.classicRestrictionFailed = true;
2275
+ try {
2276
+ invalidateClassicGuard(this.instanceDir);
2277
+ }
2278
+ catch { /* failed remains visible and refuses the next launch */ }
2279
+ }
2280
+ }
2281
+ assertClassicRestrictionLaunch(expected) {
2282
+ const current = this.classicRestriction ? classicPlanDigest(this.classicRestriction) : null;
2283
+ if (this.classicRestrictionFailed || current !== expected)
2284
+ throw Error("Restricted room policy changed while CLI launch was being prepared");
2285
+ }
2286
+ classicNativeGuard() {
2287
+ const backend = this.config.backend ?? this.backend?.binaryName ?? "unknown";
2288
+ if (this.classicRestrictionFailed)
2289
+ return classicGuardInventory({ state: "failed", backend, reason: "guard-unavailable" });
2290
+ if (!this.classicRestriction)
2291
+ return classicGuardInventory(this.classicRestrictionNeedsRestart
2292
+ ? { state: "restart-required", backend, reason: "stale-policy" }
2293
+ : { state: "not-covered", backend, reason: "legacy-mode" });
2294
+ if (this.nativePaneLifecycle)
2295
+ return classicGuardInventory({ state: "not-covered", backend, reason: "unsupported-platform" });
2296
+ const status = this.backend?.classicNativeGuard?.(this.classicRestriction)
2297
+ ?? { state: "not-covered", backend, reason: "unsupported-backend" };
2298
+ return classicGuardInventory(status.state === "ready" && this.processStatus !== "running"
2299
+ ? { state: "restart-required", backend, reason: "not-running" } : status);
2300
+ }
2223
2301
  /** Internal lifecycle injection, before start. Native paths and provider files stay on their runner. */
2224
2302
  setNativePaneLifecycle(native) {
2225
2303
  if (this.tmux || this.ipcServer || this.nativePaneLifecycle)
@@ -13367,6 +13445,8 @@ export class Daemon extends EventEmitter {
13367
13445
  ? resolveToolSet(this.config, this.name, "general")
13368
13446
  : resolveToolSet(this.config, this.name);
13369
13447
  mcpEnv.AGEND_TOOL_SET = toolSet;
13448
+ if (this.classicRestriction)
13449
+ mcpEnv.AGEND_CLASSIC_ALLOWED_TOOLS = JSON.stringify(this.classicRestriction.allowedAgendTools);
13370
13450
  // The dashboard features the person switched off: out of the tool menu from this start (the fleet refuses them
13371
13451
  // at once, whatever the menu still shows).
13372
13452
  const dashboardOff = dashboardFeaturesOff(dashboardAccessOf(this.config));
@@ -13434,6 +13514,7 @@ export class Daemon extends EventEmitter {
13434
13514
  const backendName = this.config.backend ?? "claude-code";
13435
13515
  const backendOptions = this.config.backend_options?.[backendName];
13436
13516
  return {
13517
+ ...(this.classicRestriction ? { classicRestriction: this.classicRestriction } : {}),
13437
13518
  workingDirectory: this.config.working_directory,
13438
13519
  instanceDir: this.instanceDir,
13439
13520
  instanceName: this.name,
@@ -14811,12 +14892,19 @@ export class Daemon extends EventEmitter {
14811
14892
  if (this.nativePaneLifecycle)
14812
14893
  throw Error("Native relaunch requires its owned exit and a new lifecycle reservation");
14813
14894
  let expectedAttempt = this.launchAttempt;
14814
- const admit = () => { this.startupAdmission?.(); if (repairAdmission && !repairAdmission(expectedAttempt))
14815
- throw new Error("CLI repair superseded by another launch, pause or stop"); };
14895
+ const restrictionStamp = this.classicRestriction ? classicPlanDigest(this.classicRestriction) : null;
14896
+ const admit = () => {
14897
+ this.startupAdmission?.();
14898
+ this.assertClassicRestrictionLaunch(restrictionStamp);
14899
+ if (repairAdmission && !repairAdmission(expectedAttempt))
14900
+ throw new Error("CLI repair superseded by another launch, pause or stop");
14901
+ };
14816
14902
  this.assertSessionOomAdmission();
14817
14903
  admit();
14818
14904
  const launchFence = this.launchFenceEpoch;
14819
14905
  const backendConfig = this.buildBackendConfig();
14906
+ if (this.classicRestrictionFailed)
14907
+ throw Error("Restricted room policy is unavailable");
14820
14908
  // A compatibility refusal is not a failed resume: no configuration, pin, history or pane may change.
14821
14909
  if (this.backend?.assertLaunchSupported) {
14822
14910
  this.backend.assertLaunchSupported(backendConfig);
@@ -14846,6 +14934,7 @@ export class Daemon extends EventEmitter {
14846
14934
  if (launchFence !== this.launchFenceEpoch)
14847
14935
  throw new Error("Launch cancelled: the instance was stopped or paused while the launch was being prepared");
14848
14936
  this.backend.writeConfig(backendConfig);
14937
+ this.classicRestrictionNeedsRestart = false;
14849
14938
  if (freshInboundInstructions)
14850
14939
  this.installCompactInboundInstructions();
14851
14940
  else {