@songsid/agend 2.4.0-beta.13 → 2.4.0-beta.15
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/agent-endpoint.js +28 -6
- package/dist/agent-endpoint.js.map +1 -1
- package/dist/auth-api.js +1 -0
- package/dist/auth-api.js.map +1 -1
- package/dist/backend/claude-code.d.ts +9 -0
- package/dist/backend/claude-code.js +60 -4
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/grok.js +11 -0
- package/dist/backend/grok.js.map +1 -1
- package/dist/backend/types.d.ts +3 -0
- package/dist/backend/types.js.map +1 -1
- package/dist/backend-availability.d.ts +1 -16
- package/dist/backend-availability.js +2 -91
- package/dist/backend-availability.js.map +1 -1
- package/dist/backend-version-static.d.ts +15 -0
- package/dist/backend-version-static.js +95 -0
- package/dist/backend-version-static.js.map +1 -0
- package/dist/build-provenance.json +1 -1
- package/dist/channel/adapters/telegram.js +3 -1
- package/dist/channel/adapters/telegram.js.map +1 -1
- package/dist/channel/mcp-server.js +18 -1
- package/dist/channel/mcp-server.js.map +1 -1
- package/dist/channel/tool-router.d.ts +4 -0
- package/dist/channel/tool-router.js +43 -19
- package/dist/channel/tool-router.js.map +1 -1
- package/dist/classic-channel-manager.d.ts +3 -0
- package/dist/classic-channel-manager.js +18 -0
- package/dist/classic-channel-manager.js.map +1 -1
- package/dist/classic-cli-guard.d.ts +66 -0
- package/dist/classic-cli-guard.js +209 -0
- package/dist/classic-cli-guard.js.map +1 -0
- package/dist/cli-audited.js +7 -5
- package/dist/cli-audited.js.map +1 -1
- package/dist/config-validator.js +3 -0
- package/dist/config-validator.js.map +1 -1
- package/dist/contact-auth-api.d.ts +17 -0
- package/dist/contact-auth-api.js +88 -0
- package/dist/contact-auth-api.js.map +1 -0
- package/dist/contact-auth-files.d.ts +6 -0
- package/dist/contact-auth-files.js +29 -0
- package/dist/contact-auth-files.js.map +1 -0
- package/dist/contact-auth-policy.d.ts +80 -0
- package/dist/contact-auth-policy.js +25 -0
- package/dist/contact-auth-policy.js.map +1 -0
- package/dist/contact-auth-service.d.ts +32 -0
- package/dist/contact-auth-service.js +99 -0
- package/dist/contact-auth-service.js.map +1 -0
- package/dist/contact-auth-store.d.ts +86 -0
- package/dist/contact-auth-store.js +357 -0
- package/dist/contact-auth-store.js.map +1 -0
- package/dist/contact-auth-types.d.ts +196 -0
- package/dist/contact-auth-types.js +7 -0
- package/dist/contact-auth-types.js.map +1 -0
- package/dist/daemon.d.ts +8 -0
- package/dist/daemon.js +93 -4
- package/dist/daemon.js.map +1 -1
- package/dist/delivery-outbox.d.ts +6 -0
- package/dist/delivery-outbox.js +19 -0
- package/dist/delivery-outbox.js.map +1 -1
- package/dist/fleet-manager.d.ts +48 -0
- package/dist/fleet-manager.js +484 -22
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/concepts/SKILL.md +18 -0
- package/dist/general-knowledge/skills/credential-profiles/SKILL.md +5 -0
- package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +38 -0
- package/dist/general-knowledge/skills/hub/SKILL.md +6 -0
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +5 -0
- package/dist/hub/audit/index.d.ts +3 -1
- package/dist/hub/audit/index.js +35 -3
- package/dist/hub/audit/index.js.map +1 -1
- package/dist/hub/catalog.d.ts +8 -0
- package/dist/hub/catalog.js +39 -4
- package/dist/hub/catalog.js.map +1 -1
- package/dist/hub/compose/server.d.ts +2 -0
- package/dist/hub/compose/server.js +11 -1
- package/dist/hub/compose/server.js.map +1 -1
- package/dist/hub/directory/directory.js +5 -2
- package/dist/hub/directory/directory.js.map +1 -1
- package/dist/hub/directory/types.d.ts +5 -1
- package/dist/hub/directory/types.js.map +1 -1
- package/dist/hub/group-policy/resources.d.ts +1 -1
- package/dist/hub/http/compose.d.ts +2 -0
- package/dist/hub/http/compose.js +123 -6
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/http/deps.d.ts +2 -0
- package/dist/hub/http/schema.js +6 -1
- package/dist/hub/http/schema.js.map +1 -1
- package/dist/hub/invitations.js +15 -7
- package/dist/hub/invitations.js.map +1 -1
- package/dist/hub/roles/cutover-inventory.d.ts +3 -0
- package/dist/hub/roles/cutover-inventory.js +20 -4
- package/dist/hub/roles/cutover-inventory.js.map +1 -1
- package/dist/hub/roles/cutover-marker.d.ts +18 -2
- package/dist/hub/roles/cutover-marker.js +6 -2
- package/dist/hub/roles/cutover-marker.js.map +1 -1
- package/dist/hub/room-agent-discovery-model.d.ts +29 -0
- package/dist/hub/room-agent-discovery-model.js +33 -0
- package/dist/hub/room-agent-discovery-model.js.map +1 -0
- package/dist/hub/room-agent-discovery.d.ts +14 -0
- package/dist/hub/room-agent-discovery.js +65 -0
- package/dist/hub/room-agent-discovery.js.map +1 -0
- package/dist/hub/room-agent-requests.d.ts +71 -0
- package/dist/hub/room-agent-requests.js +377 -0
- package/dist/hub/room-agent-requests.js.map +1 -0
- package/dist/hub/rooms/directory.d.ts +13 -0
- package/dist/hub/rooms/directory.js +12 -3
- package/dist/hub/rooms/directory.js.map +1 -1
- package/dist/hub/rooms/schema.d.ts +5 -0
- package/dist/hub/rooms/schema.js +9 -0
- package/dist/hub/rooms/schema.js.map +1 -1
- package/dist/hub/rooms/service.d.ts +43 -19
- package/dist/hub/rooms/service.js +67 -11
- package/dist/hub/rooms/service.js.map +1 -1
- package/dist/hub/rooms/types.d.ts +1 -1
- package/dist/instance-lifecycle.d.ts +3 -1
- package/dist/instance-lifecycle.js +4 -1
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/locale.js +34 -4
- package/dist/locale.js.map +1 -1
- package/dist/needs-you-hub.d.ts +1 -0
- package/dist/needs-you-hub.js +9 -0
- package/dist/needs-you-hub.js.map +1 -1
- package/dist/needs-you.d.ts +12 -2
- package/dist/needs-you.js.map +1 -1
- package/dist/outbound-handlers.d.ts +9 -0
- package/dist/outbound-handlers.js +46 -10
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/runtime-cli-install.js +7 -7
- package/dist/runtime-cli-install.js.map +1 -1
- package/dist/topic-commands.d.ts +1 -1
- package/dist/topic-commands.js +4 -6
- package/dist/topic-commands.js.map +1 -1
- package/dist/ui/agent-details-settings.js +7 -5
- package/dist/ui/contact-auth-client.js +50 -0
- package/dist/ui/contact-auth-strings.js +195 -0
- package/dist/ui/contact-authorizations.js +125 -0
- package/dist/ui/contact-needs.js +100 -0
- package/dist/ui/contact-permissions.js +238 -0
- package/dist/ui/contact-ticket-badge.js +54 -0
- package/dist/ui/contact-tool-groups.js +39 -0
- package/dist/ui/hub-client.js +30 -7
- package/dist/ui/hub-invitations.js +5 -1
- package/dist/ui/hub-room-new.js +10 -3
- package/dist/ui/hub-room-owner-requests-strings.js +114 -0
- package/dist/ui/hub-room-owner-requests.js +264 -0
- package/dist/ui/hub-room-pins.js +43 -0
- package/dist/ui/hub-room-settings.js +11 -2
- package/dist/ui/hub-room-strings.js +3 -0
- package/dist/ui/hub-room-thread.js +47 -5
- package/dist/ui/panel-chat.js +2 -0
- package/dist/ui/panel-details.js +2 -0
- package/dist/ui/panel-fleet.js +3 -2
- package/dist/ui/panel-hub.js +7 -1
- package/dist/ui/panel-needs.js +11 -4
- package/dist/ui/panel-settings.js +3 -0
- package/dist/ui/settings-appearance.js +6 -1
- package/dist/ui/settings-registry.js +1 -1
- package/dist/ui/shared/app-i18n.js +4 -0
- package/dist/ui/shared/app-route.js +1 -1
- package/dist/ui/shared/app-shell.js +18 -7
- package/dist/ui/shared/app-stream.js +3 -1
- package/dist/ui/shared/app.css +86 -0
- package/dist/ui/shared/chat-quote.js +26 -2
- package/dist/ui/shared/chat-thread.js +6 -2
- package/dist/ui/shared/hub-rooms-u2.css +22 -0
- package/dist/ui/shared/text-undo.js +17 -3
- package/dist/ui/shared/theme-picker.js +46 -0
- package/dist/ui/shared/theme.js +36 -3
- package/dist/ui/shared/tokens.css +273 -0
- package/dist/ui/shared/ui-confirm.js +5 -2
- package/dist/web-api.d.ts +10 -0
- package/dist/web-api.js +55 -3
- package/dist/web-api.js.map +1 -1
- package/dist/web-chat-history.d.ts +5 -0
- package/dist/web-chat-history.js +26 -0
- package/dist/web-chat-history.js.map +1 -1
- package/dist/web-reply-files.d.ts +1 -0
- package/dist/web-reply-files.js +2 -0
- package/dist/web-reply-files.js.map +1 -1
- package/dist/web-shell-routes.d.ts +1 -1
- package/dist/web-shell-routes.js +2 -1
- package/dist/web-shell-routes.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,196 @@
|
|
|
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" | "origin-clear";
|
|
87
|
+
ticketId?: string;
|
|
88
|
+
summary: string;
|
|
89
|
+
source?: string;
|
|
90
|
+
target?: string;
|
|
91
|
+
generation?: string;
|
|
92
|
+
originChange?: {
|
|
93
|
+
before: ContactOriginImage;
|
|
94
|
+
after: ContactOriginImage;
|
|
95
|
+
};
|
|
96
|
+
policyChange?: {
|
|
97
|
+
approvers?: {
|
|
98
|
+
before: ContactPerson[] | null;
|
|
99
|
+
after: ContactPerson[] | null;
|
|
100
|
+
};
|
|
101
|
+
grants?: {
|
|
102
|
+
before: ContactGrant[];
|
|
103
|
+
after: ContactGrant[];
|
|
104
|
+
};
|
|
105
|
+
roomTools?: {
|
|
106
|
+
before: ContactRoomTools;
|
|
107
|
+
after: ContactRoomTools;
|
|
108
|
+
};
|
|
109
|
+
modeRequested?: "legacy" | "restricted";
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
export type ContactOriginImage = Pick<ContactOrigin, "kind" | "people" | "chain"> & {
|
|
113
|
+
receiptCount: number;
|
|
114
|
+
};
|
|
115
|
+
export interface ContactOriginClear {
|
|
116
|
+
revision: number;
|
|
117
|
+
originRevision: number;
|
|
118
|
+
generation: string;
|
|
119
|
+
}
|
|
120
|
+
export interface ContactOriginState {
|
|
121
|
+
kind: ContactOrigin["kind"] | "none";
|
|
122
|
+
people: ContactPerson[];
|
|
123
|
+
chain: string[];
|
|
124
|
+
receiptCount: number;
|
|
125
|
+
revision: number;
|
|
126
|
+
generation: string;
|
|
127
|
+
canClear: boolean;
|
|
128
|
+
lastCleared?: {
|
|
129
|
+
actor: ContactPerson;
|
|
130
|
+
at: string;
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
export interface ContactPermissions {
|
|
134
|
+
instance: string;
|
|
135
|
+
revision: number;
|
|
136
|
+
classicRoom: boolean;
|
|
137
|
+
mode: "legacy" | "restricted";
|
|
138
|
+
approvers: ContactPerson[];
|
|
139
|
+
/** Slice 1: only the target adapter's Fleet admins (or verified host operator). */
|
|
140
|
+
eligibleApprovers: ContactPerson[];
|
|
141
|
+
/** True when approvers are inherited from the target's owning adapter. */
|
|
142
|
+
inheritedApprovers: boolean;
|
|
143
|
+
nativeGuard: ContactGuardStatus;
|
|
144
|
+
roomTools: ContactRoomTools;
|
|
145
|
+
canManage: boolean;
|
|
146
|
+
canSetMode: boolean;
|
|
147
|
+
suggestRestricted: boolean;
|
|
148
|
+
grants: ContactGrant[];
|
|
149
|
+
history: ContactHistoryRow[];
|
|
150
|
+
originState?: ContactOriginState;
|
|
151
|
+
originRestriction?: {
|
|
152
|
+
active: true;
|
|
153
|
+
reason: "earlier-non-admin" | "unknown-origin";
|
|
154
|
+
resetSupported: false;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
export interface ContactPermissionsWrite {
|
|
158
|
+
revision: number;
|
|
159
|
+
mode?: "legacy" | "restricted";
|
|
160
|
+
approvers?: ContactPerson[];
|
|
161
|
+
roomTools?: Pick<ContactRoomTools, "publicRead" | "allowedMcpTools">;
|
|
162
|
+
/** Replaces the contact table, with an explicit optimistic revision check. */
|
|
163
|
+
grants?: Array<Pick<ContactGrant, "id" | "person" | "source" | "target" | "verbs" | "expiresAt" | "remainingUses">>;
|
|
164
|
+
}
|
|
165
|
+
export interface ContactTicketPage {
|
|
166
|
+
items: ContactTicket[];
|
|
167
|
+
nextCursor: string | null;
|
|
168
|
+
}
|
|
169
|
+
export interface ContactTicketDecision {
|
|
170
|
+
revision: number;
|
|
171
|
+
decision: "approve-once" | "decline";
|
|
172
|
+
/** Separate, explicit opt-in; never inferred from clicking Approve once. */
|
|
173
|
+
grant?: {
|
|
174
|
+
expiresAt: string;
|
|
175
|
+
remainingUses: number | null;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
export interface ContactHeldResult {
|
|
179
|
+
sent: false;
|
|
180
|
+
held: true;
|
|
181
|
+
authorization_id: string;
|
|
182
|
+
authorization_state: ContactTicketState;
|
|
183
|
+
message: string;
|
|
184
|
+
}
|
|
185
|
+
export interface ContactBadge {
|
|
186
|
+
id: string;
|
|
187
|
+
state: ContactTicketState;
|
|
188
|
+
}
|
|
189
|
+
/** SSE `contact-auth`: clients refresh their scoped list and affected detail. */
|
|
190
|
+
export interface ContactAuthEvent {
|
|
191
|
+
instance: string;
|
|
192
|
+
ticketId?: string;
|
|
193
|
+
revision: number;
|
|
194
|
+
}
|
|
195
|
+
/** AgEnD tool ceiling, separate from room-configured public-read and MCP tools. */
|
|
196
|
+
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":"AA8JA,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
|
-
|
|
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
|
-
|
|
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
|
|
14815
|
-
|
|
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 {
|