@songsid/agend 2.4.0-beta.12 → 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 (226) hide show
  1. package/dist/agent-endpoint.js +28 -6
  2. package/dist/agent-endpoint.js.map +1 -1
  3. package/dist/auth-api.js +5 -0
  4. package/dist/auth-api.js.map +1 -1
  5. package/dist/backend/claude-code.d.ts +9 -0
  6. package/dist/backend/claude-code.js +60 -4
  7. package/dist/backend/claude-code.js.map +1 -1
  8. package/dist/backend/codex.js +11 -0
  9. package/dist/backend/codex.js.map +1 -1
  10. package/dist/backend/grok.js +11 -0
  11. package/dist/backend/grok.js.map +1 -1
  12. package/dist/backend/types.d.ts +4 -1
  13. package/dist/backend/types.js.map +1 -1
  14. package/dist/backend-availability.d.ts +1 -16
  15. package/dist/backend-availability.js +2 -91
  16. package/dist/backend-availability.js.map +1 -1
  17. package/dist/backend-version-static.d.ts +15 -0
  18. package/dist/backend-version-static.js +95 -0
  19. package/dist/backend-version-static.js.map +1 -0
  20. package/dist/build-provenance.json +1 -1
  21. package/dist/channel/adapters/telegram.js +3 -1
  22. package/dist/channel/adapters/telegram.js.map +1 -1
  23. package/dist/channel/mcp-server.js +18 -1
  24. package/dist/channel/mcp-server.js.map +1 -1
  25. package/dist/channel/tool-router.d.ts +4 -0
  26. package/dist/channel/tool-router.js +43 -19
  27. package/dist/channel/tool-router.js.map +1 -1
  28. package/dist/classic-channel-manager.d.ts +3 -0
  29. package/dist/classic-channel-manager.js +18 -0
  30. package/dist/classic-channel-manager.js.map +1 -1
  31. package/dist/classic-cli-guard.d.ts +66 -0
  32. package/dist/classic-cli-guard.js +209 -0
  33. package/dist/classic-cli-guard.js.map +1 -0
  34. package/dist/cli-audited.js +7 -5
  35. package/dist/cli-audited.js.map +1 -1
  36. package/dist/config-validator.js +3 -0
  37. package/dist/config-validator.js.map +1 -1
  38. package/dist/contact-auth-api.d.ts +16 -0
  39. package/dist/contact-auth-api.js +78 -0
  40. package/dist/contact-auth-api.js.map +1 -0
  41. package/dist/contact-auth-files.d.ts +6 -0
  42. package/dist/contact-auth-files.js +29 -0
  43. package/dist/contact-auth-files.js.map +1 -0
  44. package/dist/contact-auth-policy.d.ts +75 -0
  45. package/dist/contact-auth-policy.js +23 -0
  46. package/dist/contact-auth-policy.js.map +1 -0
  47. package/dist/contact-auth-service.d.ts +32 -0
  48. package/dist/contact-auth-service.js +99 -0
  49. package/dist/contact-auth-service.js.map +1 -0
  50. package/dist/contact-auth-store.d.ts +75 -0
  51. package/dist/contact-auth-store.js +295 -0
  52. package/dist/contact-auth-store.js.map +1 -0
  53. package/dist/contact-auth-types.d.ts +170 -0
  54. package/dist/contact-auth-types.js +7 -0
  55. package/dist/contact-auth-types.js.map +1 -0
  56. package/dist/daemon.d.ts +16 -1
  57. package/dist/daemon.js +127 -11
  58. package/dist/daemon.js.map +1 -1
  59. package/dist/delivery-outbox.d.ts +6 -0
  60. package/dist/delivery-outbox.js +19 -0
  61. package/dist/delivery-outbox.js.map +1 -1
  62. package/dist/dispatcher-liveness.js +2 -2
  63. package/dist/dispatcher-liveness.js.map +1 -1
  64. package/dist/fleet-manager.d.ts +45 -0
  65. package/dist/fleet-manager.js +450 -23
  66. package/dist/fleet-manager.js.map +1 -1
  67. package/dist/general-knowledge/skills/concepts/SKILL.md +18 -0
  68. package/dist/general-knowledge/skills/credential-profiles/SKILL.md +12 -0
  69. package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +28 -0
  70. package/dist/general-knowledge/skills/hub/SKILL.md +6 -0
  71. package/dist/hub/audit/index.d.ts +3 -1
  72. package/dist/hub/audit/index.js +35 -3
  73. package/dist/hub/audit/index.js.map +1 -1
  74. package/dist/hub/catalog.d.ts +8 -0
  75. package/dist/hub/catalog.js +39 -4
  76. package/dist/hub/catalog.js.map +1 -1
  77. package/dist/hub/compose/server.d.ts +2 -0
  78. package/dist/hub/compose/server.js +11 -1
  79. package/dist/hub/compose/server.js.map +1 -1
  80. package/dist/hub/directory/directory.js +5 -2
  81. package/dist/hub/directory/directory.js.map +1 -1
  82. package/dist/hub/directory/types.d.ts +5 -1
  83. package/dist/hub/directory/types.js.map +1 -1
  84. package/dist/hub/group-policy/resources.d.ts +1 -1
  85. package/dist/hub/http/compose.d.ts +2 -0
  86. package/dist/hub/http/compose.js +123 -6
  87. package/dist/hub/http/compose.js.map +1 -1
  88. package/dist/hub/http/deps.d.ts +2 -0
  89. package/dist/hub/http/schema.js +6 -1
  90. package/dist/hub/http/schema.js.map +1 -1
  91. package/dist/hub/invitations.js +15 -7
  92. package/dist/hub/invitations.js.map +1 -1
  93. package/dist/hub/roles/cutover-inventory.d.ts +3 -0
  94. package/dist/hub/roles/cutover-inventory.js +20 -4
  95. package/dist/hub/roles/cutover-inventory.js.map +1 -1
  96. package/dist/hub/roles/cutover-marker.d.ts +18 -2
  97. package/dist/hub/roles/cutover-marker.js +6 -2
  98. package/dist/hub/roles/cutover-marker.js.map +1 -1
  99. package/dist/hub/room-agent-discovery-model.d.ts +29 -0
  100. package/dist/hub/room-agent-discovery-model.js +33 -0
  101. package/dist/hub/room-agent-discovery-model.js.map +1 -0
  102. package/dist/hub/room-agent-discovery.d.ts +14 -0
  103. package/dist/hub/room-agent-discovery.js +65 -0
  104. package/dist/hub/room-agent-discovery.js.map +1 -0
  105. package/dist/hub/room-agent-requests.d.ts +71 -0
  106. package/dist/hub/room-agent-requests.js +377 -0
  107. package/dist/hub/room-agent-requests.js.map +1 -0
  108. package/dist/hub/rooms/directory.d.ts +13 -0
  109. package/dist/hub/rooms/directory.js +12 -3
  110. package/dist/hub/rooms/directory.js.map +1 -1
  111. package/dist/hub/rooms/schema.d.ts +5 -0
  112. package/dist/hub/rooms/schema.js +9 -0
  113. package/dist/hub/rooms/schema.js.map +1 -1
  114. package/dist/hub/rooms/service.d.ts +43 -19
  115. package/dist/hub/rooms/service.js +67 -11
  116. package/dist/hub/rooms/service.js.map +1 -1
  117. package/dist/hub/rooms/types.d.ts +1 -1
  118. package/dist/instance-lifecycle.d.ts +6 -1
  119. package/dist/instance-lifecycle.js +11 -4
  120. package/dist/instance-lifecycle.js.map +1 -1
  121. package/dist/locale.js +34 -4
  122. package/dist/locale.js.map +1 -1
  123. package/dist/needs-you-hub.d.ts +1 -0
  124. package/dist/needs-you-hub.js +6 -0
  125. package/dist/needs-you-hub.js.map +1 -1
  126. package/dist/needs-you.d.ts +14 -2
  127. package/dist/needs-you.js +4 -0
  128. package/dist/needs-you.js.map +1 -1
  129. package/dist/office-share-page.js +1 -1
  130. package/dist/office-share-page.js.map +1 -1
  131. package/dist/outbound-handlers.d.ts +9 -0
  132. package/dist/outbound-handlers.js +48 -10
  133. package/dist/outbound-handlers.js.map +1 -1
  134. package/dist/pause-marker.d.ts +1 -1
  135. package/dist/pause-marker.js +1 -1
  136. package/dist/pause-marker.js.map +1 -1
  137. package/dist/public-web-gateway.d.ts +20 -0
  138. package/dist/public-web-gateway.js +61 -4
  139. package/dist/public-web-gateway.js.map +1 -1
  140. package/dist/runtime-cli-install.js +7 -7
  141. package/dist/runtime-cli-install.js.map +1 -1
  142. package/dist/topic-commands.d.ts +1 -1
  143. package/dist/topic-commands.js +4 -6
  144. package/dist/topic-commands.js.map +1 -1
  145. package/dist/ui/accounts-keepalive.js +2 -1
  146. package/dist/ui/accounts-view.js +2 -1
  147. package/dist/ui/agent-details-settings.js +7 -5
  148. package/dist/ui/contact-auth-client.js +48 -0
  149. package/dist/ui/contact-auth-strings.js +164 -0
  150. package/dist/ui/contact-authorizations.js +125 -0
  151. package/dist/ui/contact-needs.js +84 -0
  152. package/dist/ui/contact-permissions.js +193 -0
  153. package/dist/ui/contact-ticket-badge.js +54 -0
  154. package/dist/ui/fleet-canvas.js +3 -1
  155. package/dist/ui/fleet-office-skin.js +4 -3
  156. package/dist/ui/fleet-route.js +44 -6
  157. package/dist/ui/fleet-task-view.js +2 -1
  158. package/dist/ui/host-install.js +5 -2
  159. package/dist/ui/hub-ai-apps.js +2 -1
  160. package/dist/ui/hub-chat-strings.js +2 -1
  161. package/dist/ui/hub-client.js +30 -7
  162. package/dist/ui/hub-grant-picker.js +2 -1
  163. package/dist/ui/hub-group-strings.js +2 -1
  164. package/dist/ui/hub-invitations.js +5 -1
  165. package/dist/ui/hub-my-agents.js +2 -1
  166. package/dist/ui/hub-owner-strings.js +2 -1
  167. package/dist/ui/hub-personal-agent.js +2 -1
  168. package/dist/ui/hub-quota.js +2 -1
  169. package/dist/ui/hub-roles-strings.js +2 -1
  170. package/dist/ui/hub-room-new-strings.js +2 -1
  171. package/dist/ui/hub-room-new.js +10 -3
  172. package/dist/ui/hub-room-owner-requests-strings.js +114 -0
  173. package/dist/ui/hub-room-owner-requests.js +264 -0
  174. package/dist/ui/hub-room-pins.js +43 -0
  175. package/dist/ui/hub-room-settings.js +11 -2
  176. package/dist/ui/hub-room-source.js +2 -1
  177. package/dist/ui/hub-room-strings.js +3 -0
  178. package/dist/ui/hub-room-thread.js +47 -5
  179. package/dist/ui/hub-strings.js +2 -1
  180. package/dist/ui/hub-teams.js +2 -1
  181. package/dist/ui/model-picker.js +3 -2
  182. package/dist/ui/panel-chat.js +8 -2
  183. package/dist/ui/panel-details.js +2 -0
  184. package/dist/ui/panel-fleet.js +3 -2
  185. package/dist/ui/panel-hub.js +14 -4
  186. package/dist/ui/panel-needs.js +8 -3
  187. package/dist/ui/panel-runtimes.js +2 -1
  188. package/dist/ui/panel-settings.js +3 -0
  189. package/dist/ui/reply-file-preview.js +2 -1
  190. package/dist/ui/settings-access-overview.js +2 -1
  191. package/dist/ui/settings-connector.js +2 -1
  192. package/dist/ui/shared/agent-sheet.js +2 -1
  193. package/dist/ui/shared/app-i18n.js +2 -2
  194. package/dist/ui/shared/app-route.js +1 -1
  195. package/dist/ui/shared/app-shell.js +35 -9
  196. package/dist/ui/shared/app-stream.js +3 -1
  197. package/dist/ui/shared/app.css +42 -0
  198. package/dist/ui/shared/asset-url.d.ts +2 -0
  199. package/dist/ui/shared/asset-url.js +20 -0
  200. package/dist/ui/shared/chat-quote.js +26 -2
  201. package/dist/ui/shared/chat-table-select.js +175 -0
  202. package/dist/ui/shared/chat-thread.js +6 -2
  203. package/dist/ui/shared/hub-rooms-u2.css +22 -0
  204. package/dist/ui/shared/image-annotate.js +2 -1
  205. package/dist/ui/shared/text-undo.js +17 -3
  206. package/dist/ui/shared/ui-states.js +3 -2
  207. package/dist/ui/shared/view-history.js +2 -1
  208. package/dist/ui/subagent-row.js +3 -2
  209. package/dist/ui/usage-pool.js +2 -1
  210. package/dist/ui/workspace-panel.js +2 -1
  211. package/dist/wake-coordinator.js +3 -2
  212. package/dist/wake-coordinator.js.map +1 -1
  213. package/dist/web-api.d.ts +9 -0
  214. package/dist/web-api.js +56 -4
  215. package/dist/web-api.js.map +1 -1
  216. package/dist/web-chat-history.d.ts +5 -0
  217. package/dist/web-chat-history.js +26 -0
  218. package/dist/web-chat-history.js.map +1 -1
  219. package/dist/web-host-install.d.ts +1 -1
  220. package/dist/web-reply-files.d.ts +1 -0
  221. package/dist/web-reply-files.js +2 -0
  222. package/dist/web-reply-files.js.map +1 -1
  223. package/dist/web-shell-routes.d.ts +1 -1
  224. package/dist/web-shell-routes.js +2 -1
  225. package/dist/web-shell-routes.js.map +1 -1
  226. 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";
@@ -791,6 +793,8 @@ export declare class Daemon extends EventEmitter {
791
793
  * instance is still auth-broken and must not resume raising alarms.
792
794
  */
793
795
  private authFailureUnresolved;
796
+ /** A process-local login failure cannot be repaired by a valid auth file or idle chrome. */
797
+ private staleAuth;
794
798
  /** One login-screen auth report per spawn — the screen persists across polls. */
795
799
  private loginScreenReported;
796
800
  /** #2795: the auth pattern match the token-free check is still to judge; it arms nothing until confirmAuthFailure(). */
@@ -1081,6 +1085,10 @@ export declare class Daemon extends EventEmitter {
1081
1085
  /** Stop buffering and deliver, in order, every `pty_error` raised while the lifecycle was starting us. */
1082
1086
  releaseStartupIncidents(): void;
1083
1087
  emit(event: string | symbol, ...args: unknown[]): boolean;
1088
+ /** Attention remains active for General/busy agents too, until a new launch takes ownership. */
1089
+ staleAuthIssue(): {
1090
+ since: number;
1091
+ } | null;
1084
1092
  /**
1085
1093
  * Undo an auth suspicion once the backend's token-free probe has said the credentials are fine. Since #2795 a pane
1086
1094
  * pattern match arms nothing before that probe (its pending match is just dropped); what is left to undo is a
@@ -1128,6 +1136,12 @@ export declare class Daemon extends EventEmitter {
1128
1136
  acceptNativeFleetMessage(message: Record<string, unknown>): boolean;
1129
1137
  private broadcastFleetMessage;
1130
1138
  private fleetTransportAvailable;
1139
+ private classicRestriction;
1140
+ private classicRestrictionFailed;
1141
+ private classicRestrictionNeedsRestart;
1142
+ setClassicRestriction(input: ClassicRestrictionInput): void;
1143
+ private assertClassicRestrictionLaunch;
1144
+ classicNativeGuard(): ContactGuardStatus;
1131
1145
  /** Internal lifecycle injection, before start. Native paths and provider files stay on their runner. */
1132
1146
  setNativePaneLifecycle(native: NativePaneLifecycle): void;
1133
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,
@@ -2365,6 +2379,7 @@ export declare class Daemon extends EventEmitter {
2365
2379
  /** Observe the Kiro paste outside paneWriteLock; a long agent turn must not block dialog handling. */
2366
2380
  private observeKiroSubmission;
2367
2381
  /**
2382
+ * A stale process login refuses delivery before any write; durable attempts stay retryable.
2368
2383
  * While the CLI is parked on a fatal startup screen (see fatalStartupBlocked),
2369
2384
  * no pane write may happen: paste+Enter into the corrupt-config modal would
2370
2385
  * confirm "Exit and fix manually" and exit the CLI. The message is failed (❌)
@@ -2372,7 +2387,7 @@ export declare class Daemon extends EventEmitter {
2372
2387
  * what to fix, and holding would only build a queue that floods the pane the
2373
2388
  * moment the flag clears.
2374
2389
  */
2375
- private refuseFatalStartupDelivery;
2390
+ private refuseBlockedDelivery;
2376
2391
  /**
2377
2392
  * A raw `%output` silence check is authoritative for ordinary TUIs. It is not
2378
2393
  * for a backend such as agy whose status-line hook periodically redraws an
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";
@@ -1568,6 +1570,8 @@ export class Daemon extends EventEmitter {
1568
1570
  * instance is still auth-broken and must not resume raising alarms.
1569
1571
  */
1570
1572
  authFailureUnresolved = false;
1573
+ /** A process-local login failure cannot be repaired by a valid auth file or idle chrome. */
1574
+ staleAuth = null;
1571
1575
  /** One login-screen auth report per spawn — the screen persists across polls. */
1572
1576
  loginScreenReported = false;
1573
1577
  /** #2795: the auth pattern match the token-free check is still to judge; it arms nothing until confirmAuthFailure(). */
@@ -1861,7 +1865,7 @@ export class Daemon extends EventEmitter {
1861
1865
  if (!["codex", "grok"].includes(this.backend?.binaryName ?? ""))
1862
1866
  return [];
1863
1867
  const patterns = this.backend?.getErrorPatterns?.() ?? [];
1864
- return this.backend?.binaryName === "codex" ? patterns.filter(ep => Daemon.isCodexUsageLimitPause(ep)) : patterns.filter(ep => ep.type === "quota");
1868
+ return this.backend?.binaryName === "codex" ? patterns.filter(ep => Daemon.isCodexUsageLimitPause(ep) || ep.type === "stale_auth") : patterns.filter(ep => ep.type === "quota");
1865
1869
  }
1866
1870
  async prepareQuotaReplayHistory(reuseWindow) {
1867
1871
  this.quotaReplay = null;
@@ -1885,7 +1889,20 @@ export class Daemon extends EventEmitter {
1885
1889
  if (!current())
1886
1890
  return;
1887
1891
  const patterns = this.paneQuotaPatterns();
1888
- 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()];
1889
1906
  this.quotaReplay = { messages, current: () => true, spawn, fence, attempt };
1890
1907
  }
1891
1908
  }
@@ -1901,7 +1918,13 @@ export class Daemon extends EventEmitter {
1901
1918
  this.quotaReplay = null;
1902
1919
  if (history.spawn !== this.spawnGeneration || history.fence !== this.launchFenceEpoch || history.attempt !== this.launchAttempt || !history.current())
1903
1920
  return;
1904
- 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) {
1905
1928
  const count = Math.min(Daemon.countOccurrences(ep.pattern, pane), quotaHistoryCount(pane, ep.pattern, history.messages));
1906
1929
  if (!count)
1907
1930
  continue;
@@ -1923,7 +1946,7 @@ export class Daemon extends EventEmitter {
1923
1946
  this.quotaInput = history.marker && history.occurrences === 0 ? { history, reported: new Map() } : null;
1924
1947
  }
1925
1948
  quotaOccurrencesAfterInput(pane, ep) {
1926
- if (!(this.backend?.binaryName === "codex" && Daemon.isCodexUsageLimitPause(ep)
1949
+ if (!(this.backend?.binaryName === "codex" && (Daemon.isCodexUsageLimitPause(ep) || ep.type === "stale_auth")
1927
1950
  || this.backend?.binaryName === "grok" && ep.type === "quota"))
1928
1951
  return null;
1929
1952
  const input = this.quotaInput, history = input?.history;
@@ -2087,6 +2110,10 @@ export class Daemon extends EventEmitter {
2087
2110
  }
2088
2111
  return super.emit(event, ...args);
2089
2112
  }
2113
+ /** Attention remains active for General/busy agents too, until a new launch takes ownership. */
2114
+ staleAuthIssue() {
2115
+ return this.staleAuth?.generation === this.spawnGeneration ? { since: this.staleAuth.since } : null;
2116
+ }
2090
2117
  /**
2091
2118
  * Undo an auth suspicion once the backend's token-free probe has said the credentials are fine. Since #2795 a pane
2092
2119
  * pattern match arms nothing before that probe (its pending match is just dropped); what is left to undo is a
@@ -2095,6 +2122,8 @@ export class Daemon extends EventEmitter {
2095
2122
  * is still live and stays.
2096
2123
  */
2097
2124
  clearSuspectedAuthFailure() {
2125
+ if (this.staleAuthIssue())
2126
+ return false;
2098
2127
  this.unverifiedAuthMatch = null;
2099
2128
  if (!this.authFailureUnresolved && !this.loginScreenReported)
2100
2129
  return false;
@@ -2212,6 +2241,63 @@ export class Daemon extends EventEmitter {
2212
2241
  fleetTransportAvailable() {
2213
2242
  return this.nativePaneLifecycle ? !!this.nativeFleetBridge?.current() && !this.runtimeMonitorsFrozen : !!this.ipcServer;
2214
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
+ }
2215
2301
  /** Internal lifecycle injection, before start. Native paths and provider files stay on their runner. */
2216
2302
  setNativePaneLifecycle(native) {
2217
2303
  if (this.tmux || this.ipcServer || this.nativePaneLifecycle)
@@ -2970,6 +3056,8 @@ export class Daemon extends EventEmitter {
2970
3056
  const oomStop = readSessionOomStop(this.instanceDir);
2971
3057
  if (oomStop.blocked)
2972
3058
  return sessionOomStopHint(oomStop);
3059
+ if (this.staleAuthIssue())
3060
+ return t("inst.codex_stale_auth");
2973
3061
  if (this.pauseWakeState !== "active")
2974
3062
  return t("delivery.hold_state", this.pauseWakeState);
2975
3063
  if (this.inputBlockedDialogKey !== null)
@@ -4714,6 +4802,8 @@ export class Daemon extends EventEmitter {
4714
4802
  }
4715
4803
  /** Evaluate one pane snapshot. Kept synchronous so state-machine edges are unit-testable. */
4716
4804
  evaluateErrorPatterns(pane, patterns, readyPattern, now = Date.now(), busyPattern = null) {
4805
+ if (this.staleAuthIssue())
4806
+ return; // Ready chrome and recovery deadlines cannot repair this process.
4717
4807
  // Count occurrences across the WHOLE pane (not just text after the last
4718
4808
  // ready prompt). One shared counter (the static below): arm requires
4719
4809
  // count > baseline, so a drifted clone here would silently gate nudges.
@@ -4824,7 +4914,7 @@ export class Daemon extends EventEmitter {
4824
4914
  // composer to establish its baseline; later appended occurrences remain eligible.
4825
4915
  if ((ep.type === "rate_limit" && ep.action === "nudge_continue") || ep.historyUntilLiveComposer) {
4826
4916
  const baseline = this.nudgeBaselines?.get(key);
4827
- if (baseline === undefined || count <= baseline) {
4917
+ if ((baseline === undefined || count <= baseline) && !(ep.type === "stale_auth" && newQuotaAfterInput)) {
4828
4918
  if (baseline !== undefined)
4829
4919
  this.lastErrorCount.set(key, count);
4830
4920
  continue;
@@ -4922,6 +5012,10 @@ export class Daemon extends EventEmitter {
4922
5012
  });
4923
5013
  return;
4924
5014
  }
5015
+ if (ep.type === "stale_auth") {
5016
+ this.staleAuth = { generation: this.spawnGeneration, since: now };
5017
+ this.authFailureUnresolved = true;
5018
+ }
4925
5019
  // #2795: auth text on the pane proves nothing about the credentials (22 of 22 such matches on the main host were
4926
5020
  // conversation text). It arms nothing here; it only asks the lifecycle's token-free check, and a failing check
4927
5021
  // arms the auth state through confirmAuthFailure().
@@ -6464,7 +6558,8 @@ export class Daemon extends EventEmitter {
6464
6558
  // auth pause — otherwise the instance would pause again the moment it idles.
6465
6559
  this.pausePending = false;
6466
6560
  this.pauseReconfirmAuth = false;
6467
- this.authFailureUnresolved = false;
6561
+ if (!this.staleAuthIssue())
6562
+ this.authFailureUnresolved = false;
6468
6563
  this.unverifiedAuthMatch = null;
6469
6564
  this.loginScreenReported = false;
6470
6565
  this.fatalStartupReported = false;
@@ -8985,7 +9080,7 @@ export class Daemon extends EventEmitter {
8985
9080
  const settleFence = this.launchFenceEpoch;
8986
9081
  if (cancelled())
8987
9082
  return false;
8988
- if (this.refuseFatalStartupDelivery(verdict, status))
9083
+ if (this.refuseBlockedDelivery(verdict, status))
8989
9084
  return false;
8990
9085
  let windowId = this.getWindowId();
8991
9086
  const supportsQueuedInput = this.backend?.supportsQueuedInput?.() === true;
@@ -9110,7 +9205,7 @@ export class Daemon extends EventEmitter {
9110
9205
  // delivery from the top, where the settle wait runs again outside it.
9111
9206
  if (!settledClean || settleGeneration !== this.spawnGeneration || this.spawning)
9112
9207
  return "spawn-started";
9113
- if (this.refuseFatalStartupDelivery(verdict, status))
9208
+ if (this.refuseBlockedDelivery(verdict, status))
9114
9209
  return false;
9115
9210
  // A passive startup phase may paint after the outer readiness probe.
9116
9211
  // It clears without input, so waiting under the pane lock cannot starve
@@ -9144,6 +9239,7 @@ export class Daemon extends EventEmitter {
9144
9239
  // same process, a pause/stop/respawn is not (launchFenceEpoch moves even
9145
9240
  // when a failed pause resumes the monitors).
9146
9241
  const writeCurrent = () => !cancelled()
9242
+ && !this.staleAuthIssue()
9147
9243
  && !this.deliveryWritesStopping
9148
9244
  && !this.runtimeMonitorsFrozen
9149
9245
  && !this.spawning
@@ -10378,6 +10474,10 @@ export class Daemon extends EventEmitter {
10378
10474
  * pane proves nothing. The silence gate comes first and costs no capture.
10379
10475
  */
10380
10476
  async paneReadinessForDelivery(windowId) {
10477
+ if (this.staleAuthIssue()) {
10478
+ this.resetFooterFallback();
10479
+ return "dialog";
10480
+ }
10381
10481
  // Each early return below is the pane seen outside the footer-fallback
10382
10482
  // candidate state, and never reaches deliveryInputReadyPane: reset here.
10383
10483
  if (!this.isPaneIdleForDelivery(windowId)) {
@@ -10902,6 +11002,7 @@ export class Daemon extends EventEmitter {
10902
11002
  }
10903
11003
  }
10904
11004
  /**
11005
+ * A stale process login refuses delivery before any write; durable attempts stay retryable.
10905
11006
  * While the CLI is parked on a fatal startup screen (see fatalStartupBlocked),
10906
11007
  * no pane write may happen: paste+Enter into the corrupt-config modal would
10907
11008
  * confirm "Exit and fix manually" and exit the CLI. The message is failed (❌)
@@ -10909,7 +11010,11 @@ export class Daemon extends EventEmitter {
10909
11010
  * what to fix, and holding would only build a queue that floods the pane the
10910
11011
  * moment the flag clears.
10911
11012
  */
10912
- refuseFatalStartupDelivery(verdict, status) {
11013
+ refuseBlockedDelivery(verdict, status) {
11014
+ if (this.staleAuthIssue()) {
11015
+ this.failDelivery(verdict, status, "pre-write", "stale-auth");
11016
+ return true;
11017
+ }
10913
11018
  if (!this.fatalStartupBlocked && !this.modelMinimumBlocked)
10914
11019
  return false;
10915
11020
  this.logger.error("Delivery refused — CLI startup or model-version repair is held");
@@ -13340,6 +13445,8 @@ export class Daemon extends EventEmitter {
13340
13445
  ? resolveToolSet(this.config, this.name, "general")
13341
13446
  : resolveToolSet(this.config, this.name);
13342
13447
  mcpEnv.AGEND_TOOL_SET = toolSet;
13448
+ if (this.classicRestriction)
13449
+ mcpEnv.AGEND_CLASSIC_ALLOWED_TOOLS = JSON.stringify(this.classicRestriction.allowedAgendTools);
13343
13450
  // The dashboard features the person switched off: out of the tool menu from this start (the fleet refuses them
13344
13451
  // at once, whatever the menu still shows).
13345
13452
  const dashboardOff = dashboardFeaturesOff(dashboardAccessOf(this.config));
@@ -13407,6 +13514,7 @@ export class Daemon extends EventEmitter {
13407
13514
  const backendName = this.config.backend ?? "claude-code";
13408
13515
  const backendOptions = this.config.backend_options?.[backendName];
13409
13516
  return {
13517
+ ...(this.classicRestriction ? { classicRestriction: this.classicRestriction } : {}),
13410
13518
  workingDirectory: this.config.working_directory,
13411
13519
  instanceDir: this.instanceDir,
13412
13520
  instanceName: this.name,
@@ -14784,12 +14892,19 @@ export class Daemon extends EventEmitter {
14784
14892
  if (this.nativePaneLifecycle)
14785
14893
  throw Error("Native relaunch requires its owned exit and a new lifecycle reservation");
14786
14894
  let expectedAttempt = this.launchAttempt;
14787
- const admit = () => { this.startupAdmission?.(); if (repairAdmission && !repairAdmission(expectedAttempt))
14788
- 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
+ };
14789
14902
  this.assertSessionOomAdmission();
14790
14903
  admit();
14791
14904
  const launchFence = this.launchFenceEpoch;
14792
14905
  const backendConfig = this.buildBackendConfig();
14906
+ if (this.classicRestrictionFailed)
14907
+ throw Error("Restricted room policy is unavailable");
14793
14908
  // A compatibility refusal is not a failed resume: no configuration, pin, history or pane may change.
14794
14909
  if (this.backend?.assertLaunchSupported) {
14795
14910
  this.backend.assertLaunchSupported(backendConfig);
@@ -14819,6 +14934,7 @@ export class Daemon extends EventEmitter {
14819
14934
  if (launchFence !== this.launchFenceEpoch)
14820
14935
  throw new Error("Launch cancelled: the instance was stopped or paused while the launch was being prepared");
14821
14936
  this.backend.writeConfig(backendConfig);
14937
+ this.classicRestrictionNeedsRestart = false;
14822
14938
  if (freshInboundInstructions)
14823
14939
  this.installCompactInboundInstructions();
14824
14940
  else {