agent-embassy 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/CONTRIBUTING.md +51 -47
- package/README.md +26 -9
- package/README.zh-CN.md +22 -9
- package/SECURITY.md +48 -35
- package/dist/src/gateway/acp-client.d.ts +12 -19
- package/dist/src/gateway/acp-client.js +90 -65
- package/dist/src/gateway/acp-client.js.map +1 -1
- package/dist/src/gateway/acp-provider.d.ts +11 -10
- package/dist/src/gateway/acp-provider.js +165 -53
- package/dist/src/gateway/acp-provider.js.map +1 -1
- package/dist/src/gateway/claude-helper-client.d.ts +2 -43
- package/dist/src/gateway/claude-helper-client.js +1 -211
- package/dist/src/gateway/claude-helper-client.js.map +1 -1
- package/dist/src/gateway/claude-helper-protocol.d.ts +16 -74
- package/dist/src/gateway/claude-helper-protocol.js +99 -378
- package/dist/src/gateway/claude-helper-protocol.js.map +1 -1
- package/dist/src/gateway/claude-helper-supervisor.d.ts +56 -44
- package/dist/src/gateway/claude-helper-supervisor.js +265 -456
- package/dist/src/gateway/claude-helper-supervisor.js.map +1 -1
- package/dist/src/gateway/claude-helper.js +184 -210
- package/dist/src/gateway/claude-helper.js.map +1 -1
- package/dist/src/gateway/claude-peer.d.ts +20 -87
- package/dist/src/gateway/claude-peer.js +310 -1009
- package/dist/src/gateway/claude-peer.js.map +1 -1
- package/dist/src/gateway/claude-runtime.d.ts +13 -15
- package/dist/src/gateway/claude-runtime.js +14 -168
- package/dist/src/gateway/claude-runtime.js.map +1 -1
- package/dist/src/gateway/cli-copy.en.d.ts +2 -2
- package/dist/src/gateway/cli-copy.en.js +4 -2
- package/dist/src/gateway/cli-copy.en.js.map +1 -1
- package/dist/src/gateway/cli-copy.zh-CN.d.ts +2 -2
- package/dist/src/gateway/cli-copy.zh-CN.js +4 -2
- package/dist/src/gateway/cli-copy.zh-CN.js.map +1 -1
- package/dist/src/gateway/cli.d.ts +7 -2
- package/dist/src/gateway/cli.js +277 -575
- package/dist/src/gateway/cli.js.map +1 -1
- package/dist/src/gateway/codex-app-server.d.ts +5 -227
- package/dist/src/gateway/codex-app-server.js +18 -1463
- package/dist/src/gateway/codex-app-server.js.map +1 -1
- package/dist/src/gateway/codex-doctor.d.ts +36 -0
- package/dist/src/gateway/codex-doctor.js +127 -0
- package/dist/src/gateway/codex-doctor.js.map +1 -0
- package/dist/src/gateway/codex-local-transport.d.ts +6 -6
- package/dist/src/gateway/codex-local-transport.js +13 -10
- package/dist/src/gateway/codex-local-transport.js.map +1 -1
- package/dist/src/gateway/codex-stateless-transport.d.ts +114 -0
- package/dist/src/gateway/codex-stateless-transport.js +1108 -0
- package/dist/src/gateway/codex-stateless-transport.js.map +1 -0
- package/dist/src/gateway/config.d.ts +2 -9
- package/dist/src/gateway/config.js +62 -100
- package/dist/src/gateway/config.js.map +1 -1
- package/dist/src/gateway/control.d.ts +36 -90
- package/dist/src/gateway/control.js +465 -1123
- package/dist/src/gateway/control.js.map +1 -1
- package/dist/src/gateway/dashboard-copy.d.ts +1 -1
- package/dist/src/gateway/dashboard-copy.en.d.ts +8 -26
- package/dist/src/gateway/dashboard-copy.en.js +19 -37
- package/dist/src/gateway/dashboard-copy.en.js.map +1 -1
- package/dist/src/gateway/dashboard-copy.js +8 -26
- package/dist/src/gateway/dashboard-copy.js.map +1 -1
- package/dist/src/gateway/dashboard-copy.zh-CN.d.ts +8 -26
- package/dist/src/gateway/dashboard-copy.zh-CN.js +19 -37
- package/dist/src/gateway/dashboard-copy.zh-CN.js.map +1 -1
- package/dist/src/gateway/dashboard-model.d.ts +8 -22
- package/dist/src/gateway/dashboard-model.js +44 -130
- package/dist/src/gateway/dashboard-model.js.map +1 -1
- package/dist/src/gateway/dashboard.d.ts +0 -6
- package/dist/src/gateway/dashboard.js +3 -7
- package/dist/src/gateway/dashboard.js.map +1 -1
- package/dist/src/gateway/live-dashboard-app/app.js +20 -34
- package/dist/src/gateway/live-dashboard-command.js +2 -2
- package/dist/src/gateway/live-dashboard-command.js.map +1 -1
- package/dist/src/gateway/live-dashboard-http.d.ts +1 -1
- package/dist/src/gateway/live-dashboard-http.js +2 -2
- package/dist/src/gateway/live-dashboard-http.js.map +1 -1
- package/dist/src/gateway/progress-watch-machine.d.ts +1 -37
- package/dist/src/gateway/progress-watch-machine.js +4 -15
- package/dist/src/gateway/progress-watch-machine.js.map +1 -1
- package/dist/src/gateway/providers.d.ts +58 -191
- package/dist/src/gateway/providers.js +637 -2434
- package/dist/src/gateway/providers.js.map +1 -1
- package/dist/src/gateway/server.d.ts +16 -25
- package/dist/src/gateway/server.js +165 -240
- package/dist/src/gateway/server.js.map +1 -1
- package/dist/src/gateway/service.d.ts +149 -427
- package/dist/src/gateway/service.js +1639 -5662
- package/dist/src/gateway/service.js.map +1 -1
- package/dist/src/gateway/state-v2-to-v3.d.ts +23 -0
- package/dist/src/gateway/state-v2-to-v3.js +994 -0
- package/dist/src/gateway/state-v2-to-v3.js.map +1 -0
- package/dist/src/gateway/store.d.ts +54 -309
- package/dist/src/gateway/store.js +1560 -3510
- package/dist/src/gateway/store.js.map +1 -1
- package/dist/src/gateway/types.d.ts +181 -225
- package/dist/src/gateway/types.js +115 -251
- package/dist/src/gateway/types.js.map +1 -1
- package/docs/CONFIGURATION.md +22 -9
- package/docs/CONFIGURATION.zh-CN.md +21 -9
- package/docs/DASHBOARD.md +10 -10
- package/docs/DASHBOARD.zh-CN.md +3 -3
- package/docs/DELIVERY.md +4 -4
- package/docs/DELIVERY.zh-CN.md +4 -4
- package/docs/GATEWAY-ARCHITECTURE.md +158 -187
- package/package.json +1 -1
- package/skills/embassy-peer/SKILL.md +28 -22
- package/dist/src/gateway/codex-registration-generation.d.ts +0 -5
- package/dist/src/gateway/codex-registration-generation.js +0 -19
- package/dist/src/gateway/codex-registration-generation.js.map +0 -1
- package/dist/src/gateway/codex-registration-succession.d.ts +0 -209
- package/dist/src/gateway/codex-registration-succession.js +0 -588
- package/dist/src/gateway/codex-registration-succession.js.map +0 -1
- package/dist/src/gateway/compatibility.d.ts +0 -22
- package/dist/src/gateway/compatibility.js +0 -23
- package/dist/src/gateway/compatibility.js.map +0 -1
- package/dist/src/gateway/delivery-machine.d.ts +0 -235
- package/dist/src/gateway/delivery-machine.js +0 -540
- package/dist/src/gateway/delivery-machine.js.map +0 -1
|
@@ -1,29 +1,17 @@
|
|
|
1
1
|
import type { GatewayConfig } from "./config.js";
|
|
2
2
|
import { type GatewayControlHandlers, type GatewaySnapshotObservation } from "./control.js";
|
|
3
3
|
import { publishGatewayDashboard } from "./dashboard.js";
|
|
4
|
+
import type { CodexDoctorResult } from "./codex-doctor.js";
|
|
4
5
|
import { GatewayStore } from "./store.js";
|
|
5
|
-
import { type
|
|
6
|
-
export type GatewayAdapterRouteState =
|
|
7
|
-
export type GatewayAdapterRouteObservationState = GatewayAdapterRouteState | "
|
|
8
|
-
export type GatewayAdapterDiscovery = {
|
|
9
|
-
/** Canonical public alias. The service never lowercases or truncates it. */
|
|
6
|
+
import { type GatewayPreparedWriteEvidence, type GatewayProvider, type GatewayPublicSnapshot, type LogicalRouteBinding } from "./types.js";
|
|
7
|
+
export type GatewayAdapterRouteState = "idle" | "busy" | "awaiting_approval";
|
|
8
|
+
export type GatewayAdapterRouteObservationState = GatewayAdapterRouteState | "unobserved";
|
|
9
|
+
export type GatewayAdapterDiscovery = Readonly<{
|
|
10
10
|
alias: string;
|
|
11
|
-
/** Stable provider identity; for Claude this is its native session UUID. */
|
|
12
11
|
routeHandle: string;
|
|
13
12
|
kind: "interactive";
|
|
14
13
|
state: GatewayAdapterRouteState;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* One bounded discovery pass. `complete` is false when the provider stopped
|
|
18
|
-
* before it could inspect the full registry; such a pass may be displayed but
|
|
19
|
-
* cannot authorize selection restoration.
|
|
20
|
-
*/
|
|
21
|
-
export type GatewayAdapterDiscoverySnapshot = {
|
|
22
|
-
peers: readonly GatewayAdapterDiscovery[];
|
|
23
|
-
complete: boolean;
|
|
24
|
-
/** Bounded registry-shape evidence; never carries record contents or paths. */
|
|
25
|
-
registry?: GatewayAdapterRegistryObservation;
|
|
26
|
-
};
|
|
14
|
+
}>;
|
|
27
15
|
export type GatewayAdapterRegistryObservation = Readonly<{
|
|
28
16
|
entriesScanned: number;
|
|
29
17
|
parseableRecords: number;
|
|
@@ -32,223 +20,129 @@ export type GatewayAdapterRegistryObservation = Readonly<{
|
|
|
32
20
|
count: number;
|
|
33
21
|
}>[];
|
|
34
22
|
}>;
|
|
35
|
-
export type
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
23
|
+
export type GatewayAdapterDiscoverySnapshot = Readonly<{
|
|
24
|
+
peers: readonly GatewayAdapterDiscovery[];
|
|
25
|
+
complete: boolean;
|
|
26
|
+
registry?: GatewayAdapterRegistryObservation;
|
|
27
|
+
}>;
|
|
28
|
+
export type GatewayAdapterRouteObservation = Readonly<{
|
|
29
|
+
route: LogicalRouteBinding;
|
|
30
|
+
state: GatewayAdapterRouteObservationState;
|
|
31
|
+
observedAt: string;
|
|
39
32
|
safeErrorCode?: string;
|
|
40
|
-
/** Transient, bounded by the adapter. Never copied into normalized state. */
|
|
41
|
-
replyText?: string;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* One provider-wide Codex endpoint transition. Native thread and generation
|
|
45
|
-
* identifiers stay inside this controller boundary and are never projected.
|
|
46
|
-
*/
|
|
47
|
-
export type GatewayAdapterEndpointRefresh = Readonly<{
|
|
48
|
-
previous: PrivateEndpointIdentity;
|
|
49
|
-
current: PrivateEndpointIdentity;
|
|
50
|
-
routes: readonly Readonly<{
|
|
51
|
-
routeHandle: string;
|
|
52
|
-
state: GatewayAdapterRouteState;
|
|
53
|
-
}>[];
|
|
54
33
|
}>;
|
|
55
|
-
export type
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
/** A callback user frame has no conversation ID; correlation is service-owned. */
|
|
65
|
-
onClaudeReply: (event: {
|
|
66
|
-
endpoint: PrivateEndpointIdentity & {
|
|
67
|
-
routeHandle: string;
|
|
68
|
-
};
|
|
34
|
+
export type GatewayAdapterNativeEndpoint = Readonly<{
|
|
35
|
+
provider: GatewayProvider;
|
|
36
|
+
hostId: string;
|
|
37
|
+
routeHandle: string;
|
|
38
|
+
}>;
|
|
39
|
+
export type GatewayAdapterCallbacks = Readonly<{
|
|
40
|
+
onRouteState: (event: GatewayAdapterRouteObservation) => void;
|
|
41
|
+
onClaudeReply: (event: Readonly<{
|
|
42
|
+
endpoint: GatewayAdapterNativeEndpoint;
|
|
69
43
|
text: string;
|
|
70
|
-
}) => void;
|
|
71
|
-
onClaudeMessage?: (event: {
|
|
72
|
-
endpoint:
|
|
73
|
-
routeHandle: string;
|
|
74
|
-
};
|
|
44
|
+
}>) => void;
|
|
45
|
+
onClaudeMessage?: (event: Readonly<{
|
|
46
|
+
endpoint: GatewayAdapterNativeEndpoint;
|
|
75
47
|
sourceAlias: string;
|
|
76
48
|
targetAlias: string;
|
|
77
49
|
text: string;
|
|
78
50
|
receiptHandle?: string;
|
|
79
|
-
}) => void;
|
|
80
|
-
|
|
81
|
-
onProtocolNotice?: (event: {
|
|
51
|
+
}>) => void;
|
|
52
|
+
onProtocolNotice?: (event: Readonly<{
|
|
82
53
|
code: string;
|
|
83
|
-
}) => void;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
};
|
|
87
|
-
export type GatewayAdapterStart = {
|
|
54
|
+
}>) => void;
|
|
55
|
+
}>;
|
|
56
|
+
export type GatewayAdapterStart = Readonly<{
|
|
88
57
|
health: "healthy" | "degraded";
|
|
89
58
|
safeErrorCode?: string;
|
|
90
|
-
/** One config-declared, Embassy-owned route observed without spawning. */
|
|
91
59
|
ownedRoute?: Readonly<{
|
|
92
60
|
alias: string;
|
|
93
61
|
routeHandle: string;
|
|
94
62
|
state: GatewayAdapterRouteState;
|
|
95
63
|
}>;
|
|
96
|
-
}
|
|
97
|
-
export type GatewayAdapterDispatchResult = {
|
|
98
|
-
state: "pending";
|
|
99
|
-
}
|
|
100
|
-
/** Provider accepted the turn, but its final result/reply remains pending. */
|
|
101
|
-
| {
|
|
102
|
-
state: "accepted";
|
|
103
|
-
} | {
|
|
64
|
+
}>;
|
|
65
|
+
export type GatewayAdapterDispatchResult = Readonly<{
|
|
104
66
|
state: "deferred";
|
|
105
67
|
safeErrorCode?: string;
|
|
106
|
-
} | {
|
|
107
|
-
state: "delivered" | "unconfirmed" | "failed" | "ambiguous" | "cancelled";
|
|
68
|
+
}> | Readonly<{
|
|
69
|
+
state: "delivered" | "unconfirmed" | "failed" | "ambiguous" | "expired" | "cancelled";
|
|
108
70
|
safeErrorCode?: string;
|
|
109
71
|
replyText?: string;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
* carried beside the raw body so the provider can frame it exactly once at
|
|
114
|
-
* its semantic write boundary. They must not be projected or persisted.
|
|
115
|
-
*/
|
|
116
|
-
export type GatewayAdapterDispatchInput = {
|
|
72
|
+
}>;
|
|
73
|
+
export type GatewayAdapterDispatchInput = Readonly<{
|
|
74
|
+
attemptId: string;
|
|
117
75
|
sourceAlias: string;
|
|
118
76
|
sourceProvider: GatewayProvider;
|
|
119
77
|
targetAlias: string;
|
|
120
78
|
conversationId: string;
|
|
121
|
-
binding:
|
|
79
|
+
binding: LogicalRouteBinding;
|
|
122
80
|
authorization: "selected_route" | "native_reply";
|
|
123
81
|
messageId: string;
|
|
124
82
|
text: string;
|
|
125
83
|
expectsReply: boolean;
|
|
126
84
|
deadlineAt: string;
|
|
127
85
|
steer?: true;
|
|
128
|
-
/** Broker-derived display metadata; never grants or persists authority. */
|
|
129
86
|
progressWatchActive?: true;
|
|
130
|
-
/** Older accepted rows observed when this exact STEER left the queue. */
|
|
131
87
|
queuedAhead?: number;
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
88
|
+
authorizeWrite: (evidence: GatewayPreparedWriteEvidence & Readonly<{
|
|
89
|
+
attemptId: string;
|
|
90
|
+
}>) => Promise<boolean>;
|
|
91
|
+
onAccepted: (evidence: Readonly<{
|
|
92
|
+
attemptId: string;
|
|
93
|
+
}>) => Promise<void>;
|
|
94
|
+
}>;
|
|
138
95
|
export interface GatewayProviderAdapter {
|
|
139
|
-
readonly identity:
|
|
96
|
+
readonly identity: Readonly<{
|
|
97
|
+
provider: GatewayProvider;
|
|
98
|
+
hostId: string;
|
|
99
|
+
}>;
|
|
140
100
|
readonly protocol: string;
|
|
141
101
|
readonly protocolVersion: string;
|
|
142
|
-
/** Latest already-read Claude registry evidence; this accessor performs no I/O. */
|
|
143
102
|
latestRegistryObservation?(): GatewayAdapterRegistryObservation | undefined;
|
|
144
|
-
/** Releases the provider's exact current-generation activation latch. */
|
|
145
|
-
activateEndpointGeneration(endpointGeneration: string): void;
|
|
146
|
-
/** Releases one selector claim after controller-side activation fails. */
|
|
147
|
-
releaseEndpointRefreshSelectorClaim?(endpointGeneration: string): void;
|
|
148
|
-
/** Re-publishes pending transition evidence on one observed recovery edge. */
|
|
149
|
-
rearmEndpointRefreshActivation?(endpointGeneration: string): void;
|
|
150
103
|
initialize(callbacks: GatewayAdapterCallbacks): Promise<GatewayAdapterStart>;
|
|
104
|
+
observeLogicalRoute?(input: Readonly<{
|
|
105
|
+
alias: string;
|
|
106
|
+
routeHandle: string;
|
|
107
|
+
registrationId: string;
|
|
108
|
+
}>): void;
|
|
109
|
+
forgetLogicalRoute?(registrationId: string): void;
|
|
151
110
|
discoverClaudePeers?(): Promise<GatewayAdapterDiscoverySnapshot>;
|
|
152
|
-
selectRoute(input: {
|
|
111
|
+
selectRoute?(input: Readonly<{
|
|
153
112
|
alias: string;
|
|
154
113
|
routeHandle: string;
|
|
155
|
-
}): Promise<{
|
|
114
|
+
}>): Promise<{
|
|
156
115
|
routeHandle: string;
|
|
157
116
|
state: GatewayAdapterRouteState;
|
|
158
|
-
endpointRefresh?: GatewayAdapterEndpointRefresh;
|
|
159
117
|
}>;
|
|
160
|
-
/** Claude-only workspace guard. Codex registration has no workspace gate. */
|
|
161
118
|
assertWorkspaceDisjoint?(routeHandle: string, stateRoot: string): Promise<void>;
|
|
162
|
-
/** Converts a UDS connect-back capability to an exact already-observed handle. */
|
|
163
119
|
resolveReplyAddress?(address: string): Promise<{
|
|
164
120
|
routeHandle: string;
|
|
165
121
|
}>;
|
|
166
|
-
advertiseNativeSourcePeer?(input: {
|
|
122
|
+
advertiseNativeSourcePeer?(input: Readonly<{
|
|
167
123
|
alias: string;
|
|
168
124
|
sourceProvider: GatewayProvider;
|
|
169
125
|
cwd: string;
|
|
170
|
-
}): Promise<void>;
|
|
126
|
+
}>): Promise<void>;
|
|
171
127
|
unadvertiseNativeSourcePeer?(alias: string): Promise<void>;
|
|
172
128
|
updateNativeSourcePeerStatus?(alias: string, status: "idle" | "busy" | "waiting"): Promise<void>;
|
|
173
129
|
updateNativeInboundStatus?(receiptHandle: string, status: "held" | "delivered" | "denied" | "expired", diagnosticCode?: string): Promise<void>;
|
|
174
|
-
notifyNativeInboundProgress?(receiptHandle: string, progress: {
|
|
130
|
+
notifyNativeInboundProgress?(receiptHandle: string, progress: Readonly<{
|
|
175
131
|
kind: "stall";
|
|
176
|
-
reason: "ROUTE_BUSY" | "ROUTE_UNAVAILABLE" | "
|
|
132
|
+
reason: "ROUTE_BUSY" | "ROUTE_UNAVAILABLE" | "AWAITING_EXTERNAL_APPROVAL";
|
|
177
133
|
queuedForMs: number;
|
|
178
|
-
}): Promise<void>;
|
|
179
|
-
releaseNativeInboundReceipt?(receiptHandle: string):
|
|
180
|
-
/** Fence new native ingress while keeping receipt writes available. */
|
|
181
|
-
quiesceNativeInbound?(): Promise<void>;
|
|
182
|
-
/** Claude-only exact listener-generation succession controls. */
|
|
183
|
-
currentNativeCodexPeerGeneration?(alias: string): string;
|
|
184
|
-
prepareNativeCodexPeerGeneration?(input: {
|
|
185
|
-
alias: string;
|
|
186
|
-
cwd: string;
|
|
187
|
-
generation: string;
|
|
188
|
-
currentGeneration?: string;
|
|
189
|
-
}): Promise<void>;
|
|
190
|
-
quiesceNativeCodexPeerGeneration?(generation: string): Promise<void>;
|
|
191
|
-
observeNativeCodexSuccessionBarrier?(generation: string): Readonly<{
|
|
192
|
-
generation: string;
|
|
193
|
-
activeGenerationMatched: boolean;
|
|
194
|
-
ingressQuiesced: boolean;
|
|
195
|
-
monitorFrozen: boolean;
|
|
196
|
-
discoveryInFlight: boolean;
|
|
197
|
-
pendingOutboundReceipts: number;
|
|
198
|
-
pendingInboundReceipts: number;
|
|
199
|
-
rejectedInboundSettlements: number;
|
|
200
|
-
clean: boolean;
|
|
201
|
-
}> | Promise<Readonly<{
|
|
202
|
-
generation: string;
|
|
203
|
-
activeGenerationMatched: boolean;
|
|
204
|
-
ingressQuiesced: boolean;
|
|
205
|
-
monitorFrozen: boolean;
|
|
206
|
-
discoveryInFlight: boolean;
|
|
207
|
-
pendingOutboundReceipts: number;
|
|
208
|
-
pendingInboundReceipts: number;
|
|
209
|
-
rejectedInboundSettlements: number;
|
|
210
|
-
clean: boolean;
|
|
211
|
-
}>>;
|
|
212
|
-
publishPreparedNativeCodexPeer?(input: {
|
|
213
|
-
currentGeneration: string;
|
|
214
|
-
preparedGeneration: string;
|
|
215
|
-
}): Promise<"published" | "not_published" | "unknown">;
|
|
216
|
-
activatePreparedNativeCodexPeerGeneration?(generation: string): void | Promise<void>;
|
|
217
|
-
cleanupPreparedNativeCodexPeerGeneration?(generation: string): Promise<void>;
|
|
218
|
-
resumeNativeCodexPeerGeneration?(generation: string): void | Promise<void>;
|
|
219
|
-
rollbackPreparedNativeCodexPeerGeneration?(input: {
|
|
220
|
-
preparedGeneration: string;
|
|
221
|
-
resumeGeneration: string;
|
|
222
|
-
}): Promise<void>;
|
|
223
|
-
retireNativeCodexPeerGeneration?(input: {
|
|
224
|
-
retiredGeneration: string;
|
|
225
|
-
protectedActiveGeneration: string;
|
|
226
|
-
}): Promise<void>;
|
|
227
|
-
purgeNativeCodexPeerGenerationReplyCapabilities?(generation: string): number | Promise<number>;
|
|
228
|
-
/** Codex-only private provider-work barrier for one exact task route. */
|
|
229
|
-
observeRouteSuccessionBarrier?(routeHandle: string): Readonly<{
|
|
230
|
-
routePresent: boolean;
|
|
231
|
-
connection: string;
|
|
232
|
-
routeStatus: string;
|
|
233
|
-
queueDepth: number;
|
|
234
|
-
hasActiveTurn: boolean;
|
|
235
|
-
requestInFlight: boolean;
|
|
236
|
-
routeCreationInFlight: boolean;
|
|
237
|
-
routeReleaseInFlight: boolean;
|
|
238
|
-
pendingReplyCorrelations: number;
|
|
239
|
-
pendingCallbacks: number;
|
|
240
|
-
clean: boolean;
|
|
241
|
-
}>;
|
|
134
|
+
}>): Promise<void>;
|
|
135
|
+
releaseNativeInboundReceipt?(receiptHandle: string): Promise<boolean>;
|
|
242
136
|
dispatch(input: GatewayAdapterDispatchInput): Promise<GatewayAdapterDispatchResult>;
|
|
243
137
|
releaseRoute?(routeHandle: string): Promise<void>;
|
|
244
138
|
close(): Promise<void>;
|
|
245
139
|
}
|
|
246
140
|
type GatewayServiceTimer = ReturnType<typeof setTimeout>;
|
|
247
|
-
type GatewayServiceTimers = {
|
|
141
|
+
type GatewayServiceTimers = Readonly<{
|
|
248
142
|
setTimeout: (callback: () => void, delayMs: number) => GatewayServiceTimer;
|
|
249
143
|
clearTimeout: (timer: GatewayServiceTimer) => void;
|
|
250
|
-
}
|
|
251
|
-
export type GatewayServiceOptions = {
|
|
144
|
+
}>;
|
|
145
|
+
export type GatewayServiceOptions = Readonly<{
|
|
252
146
|
config: GatewayConfig;
|
|
253
147
|
adapters?: readonly GatewayProviderAdapter[];
|
|
254
148
|
store?: GatewayStore;
|
|
@@ -256,9 +150,8 @@ export type GatewayServiceOptions = {
|
|
|
256
150
|
now?: () => Date;
|
|
257
151
|
nativePeerCwd?: string;
|
|
258
152
|
timers?: GatewayServiceTimers;
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
};
|
|
153
|
+
codexDoctor?: () => Promise<CodexDoctorResult>;
|
|
154
|
+
}>;
|
|
262
155
|
export declare class GatewayService {
|
|
263
156
|
readonly config: GatewayConfig;
|
|
264
157
|
readonly store: GatewayStore;
|
|
@@ -267,281 +160,110 @@ export declare class GatewayService {
|
|
|
267
160
|
private readonly now;
|
|
268
161
|
private readonly timers;
|
|
269
162
|
private readonly nativePeerCwd;
|
|
270
|
-
private readonly
|
|
271
|
-
private readonly
|
|
272
|
-
private readonly
|
|
273
|
-
private readonly routeStates;
|
|
274
|
-
private readonly bindingAliases;
|
|
163
|
+
private readonly codexDoctor;
|
|
164
|
+
private readonly connectors;
|
|
165
|
+
private readonly routeObservations;
|
|
275
166
|
private readonly candidates;
|
|
276
|
-
private availablePeers;
|
|
277
|
-
private readonly registryEvidenceByConnector;
|
|
278
|
-
private readonly registryAdaptersWithParseableRecords;
|
|
279
167
|
private readonly conversations;
|
|
280
168
|
private readonly messageContexts;
|
|
281
|
-
private readonly
|
|
282
|
-
private readonly
|
|
283
|
-
private readonly
|
|
284
|
-
private readonly dispatchRunnerTargets;
|
|
285
|
-
private readonly heldRedispatchTimers;
|
|
169
|
+
private readonly activeAttempts;
|
|
170
|
+
private readonly reserveOperations;
|
|
171
|
+
private readonly inboundOperations;
|
|
286
172
|
private readonly pendingClaudeReplies;
|
|
287
|
-
private readonly
|
|
288
|
-
private readonly
|
|
173
|
+
private readonly nativeReceipts;
|
|
174
|
+
private readonly progressWatches;
|
|
175
|
+
private readonly progressWatchEvents;
|
|
176
|
+
private readonly dispatchRunners;
|
|
177
|
+
private readonly steerRunners;
|
|
178
|
+
private readonly startingTargets;
|
|
289
179
|
private readonly runtimeAlerts;
|
|
290
|
-
private readonly activityEvents;
|
|
291
|
-
private activitySequence;
|
|
292
|
-
private readonly detachedReceiptWrites;
|
|
293
|
-
private readonly nativeIngressByConversation;
|
|
294
|
-
private readonly callbackQueue;
|
|
295
|
-
/**
|
|
296
|
-
* Endpoint replacement is authority-bearing lifecycle evidence, not an
|
|
297
|
-
* ordinary refreshable observation. Keep one coalesced slot outside the
|
|
298
|
-
* bounded callback queue so delivery evidence can never displace it (or be
|
|
299
|
-
* displaced by it).
|
|
300
|
-
*/
|
|
301
|
-
private endpointRefreshCallback;
|
|
302
|
-
private activeEndpointRefreshCallback;
|
|
303
|
-
private endpointRefreshRetryRequested;
|
|
304
|
-
private endpointRefreshConflictBoundary;
|
|
305
|
-
private activeEndpointRefreshCallbackKey;
|
|
306
|
-
private endpointRefreshCallbackPoisoned;
|
|
307
|
-
private endpointRefreshConflictPending;
|
|
308
|
-
/** Last successfully activated transition per allowed Codex host. */
|
|
309
|
-
private readonly activatedEndpointRefreshes;
|
|
310
|
-
/** Durable reanchors awaiting their exact native-listener activation. */
|
|
311
|
-
private readonly durablyAppliedEndpointRefreshes;
|
|
312
|
-
/** Selector transitions staged until their exact registration owns a helper. */
|
|
313
|
-
private readonly pendingSelectorEndpointActivations;
|
|
314
|
-
/** Process-local dedupe for automatic public activity rows across retries. */
|
|
315
|
-
private readonly endpointRefreshActivityKeys;
|
|
316
|
-
private callbackWorker;
|
|
317
|
-
private callbackScheduled;
|
|
318
|
-
private readonly callbackCapacity;
|
|
319
|
-
private readonly deliveryCallbackReserve;
|
|
320
|
-
private readonly deliveryTokenCapacity;
|
|
321
|
-
private lifecycleTimer;
|
|
322
|
-
private nextDashboardRefreshAt;
|
|
323
|
-
private nextProgressWatchAt;
|
|
324
180
|
private control;
|
|
325
|
-
|
|
181
|
+
private wakeTimer;
|
|
182
|
+
private nextDiscoveryAt;
|
|
183
|
+
private nextDoctorAt;
|
|
184
|
+
private codexDoctorResult;
|
|
326
185
|
private revision;
|
|
327
|
-
/**
|
|
328
|
-
* Process-local semantic public-snapshot clock. The first observation
|
|
329
|
-
* establishes revision zero; a new GatewayService process resets it.
|
|
330
|
-
*/
|
|
331
186
|
private snapshotRevision;
|
|
332
187
|
private snapshotFingerprint;
|
|
333
188
|
private running;
|
|
334
189
|
private closing;
|
|
335
190
|
private closeInFlight;
|
|
336
|
-
private acceptingCallbacks;
|
|
337
|
-
private dashboardHealthy;
|
|
338
|
-
/** Route-scoped fences; unrelated Codex registrations remain dispatchable. */
|
|
339
|
-
private readonly codexSuccessionDispatchFrozen;
|
|
340
|
-
private readonly codexSuccessionPoisoned;
|
|
341
|
-
/**
|
|
342
|
-
* Exact stale authority whose process-owned native advertisement was already
|
|
343
|
-
* removed, but whose durable orphan deletion did not commit. Keep dispatch
|
|
344
|
-
* frozen and permit only the same exact cleanup transaction to retry.
|
|
345
|
-
*/
|
|
346
|
-
private readonly codexOrphanCleanupPending;
|
|
347
|
-
private codexSuccessionState;
|
|
348
|
-
private pendingCodexSuccessionRecovery;
|
|
349
|
-
/**
|
|
350
|
-
* Exact active identity. It changes only through the journaled succession
|
|
351
|
-
* machine; ordinary unregister/register cannot repurpose one listener.
|
|
352
|
-
*/
|
|
353
|
-
private readonly codexRegistrationLocks;
|
|
354
191
|
constructor(options: GatewayServiceOptions);
|
|
355
192
|
start(signal?: AbortSignal): Promise<void>;
|
|
356
193
|
close(): Promise<void>;
|
|
357
194
|
private closeOnce;
|
|
358
195
|
handlers(): GatewayControlHandlers;
|
|
359
196
|
snapshot(): Promise<GatewayPublicSnapshot>;
|
|
360
|
-
private captureRegistryObservation;
|
|
361
|
-
private connectorsWithRegistry;
|
|
362
197
|
observeSnapshot(): Promise<GatewaySnapshotObservation>;
|
|
363
|
-
private
|
|
364
|
-
private
|
|
365
|
-
private
|
|
366
|
-
private
|
|
367
|
-
private
|
|
368
|
-
private
|
|
369
|
-
private
|
|
370
|
-
private
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
* admitted while it is reduced remain queued for the ordinary worker, and
|
|
377
|
-
* the dedicated endpoint-transition slot is never consumed recursively.
|
|
378
|
-
*/
|
|
379
|
-
private drainSelectorCallbackSnapshotLocked;
|
|
380
|
-
private failClosedEndpointRefreshConflict;
|
|
381
|
-
private requireEndpointRefreshUnconflicted;
|
|
382
|
-
private isTerminalAdapterDelivery;
|
|
383
|
-
/**
|
|
384
|
-
* Delivery evidence observed strictly before the deadline must reach the
|
|
385
|
-
* reducer before its deadline event, even when callback scheduling is late.
|
|
386
|
-
* Evidence observed at/after the cutoff cannot reopen the terminal machine.
|
|
387
|
-
*/
|
|
388
|
-
private drainPreDeadlineDeliveryCallbacksLocked;
|
|
389
|
-
/**
|
|
390
|
-
* A provider may synchronously emit a terminal callback before its dispatch
|
|
391
|
-
* promise resolves to `pending`. Consume those already-retained callbacks
|
|
392
|
-
* before interpreting `pending` as successful provider acceptance, otherwise
|
|
393
|
-
* the sender can observe a false delivered result that wins the terminal
|
|
394
|
-
* race against the queued failure.
|
|
395
|
-
*/
|
|
396
|
-
private drainDeliveryCallbacksForMessageLocked;
|
|
397
|
-
private adapter;
|
|
398
|
-
private assertClaudeWorkspaceDisjoint;
|
|
399
|
-
private contextTargetBinding;
|
|
400
|
-
private recoverCodexSuccessionAfterRestartLocked;
|
|
401
|
-
/**
|
|
402
|
-
* Rebuild process-owned route and listener authority for retained Codex
|
|
403
|
-
* registrations during staged startup. The provider's selectRoute performs
|
|
404
|
-
* the exact loaded/list + history-free resume proof; durable state advances
|
|
405
|
-
* only after the new native advertisement and status are live.
|
|
406
|
-
*/
|
|
407
|
-
private reactivateRetainedCodexRoutesAfterRestartLocked;
|
|
408
|
-
private completePendingCodexSuccessionRecoveryLocked;
|
|
409
|
-
private assertPendingCodexSuccessionRecoveryMatch;
|
|
410
|
-
private requireCurrentNativeCodexGeneration;
|
|
411
|
-
private nextCodexSuccessionGeneration;
|
|
412
|
-
private successionStoreIdentity;
|
|
413
|
-
private sameSuccessionStoreIdentity;
|
|
414
|
-
private reconcilePreparedCodexSuccessionAfterUnknownCommit;
|
|
415
|
-
private requireSuccessionMethod;
|
|
416
|
-
private succeedCodexRegistration;
|
|
417
|
-
private driveCodexSuccessionLocked;
|
|
418
|
-
private recoverCodexSuccessionLocked;
|
|
419
|
-
private successionNewRegistration;
|
|
420
|
-
private codexSuccessionFailurePhase;
|
|
421
|
-
private executeCodexSuccessionEffectLocked;
|
|
422
|
-
private successionOldRegistration;
|
|
423
|
-
private quiesceAndDrainPoisonedSuccessionLocked;
|
|
424
|
-
private codexRouteSuccessionQuiet;
|
|
425
|
-
private conversationTouchesAliases;
|
|
426
|
-
private successionServiceStateClean;
|
|
427
|
-
private purgeSuccessionTransientState;
|
|
428
|
-
private codexSuccessionPoisonBarrierCleanLocked;
|
|
429
|
-
private codexSuccessionBarrierCleanLocked;
|
|
430
|
-
private rescheduleIdleRoutesLocked;
|
|
431
|
-
private codexSuccessionIsStable;
|
|
432
|
-
private requireUnchangedStaleCodexOrphan;
|
|
433
|
-
private nativeCodexOrphanBarrierClean;
|
|
434
|
-
private endpointCallbacksQuiet;
|
|
198
|
+
private health;
|
|
199
|
+
private installOwnedRoute;
|
|
200
|
+
private observeLoadedRoutes;
|
|
201
|
+
private observeRoute;
|
|
202
|
+
private forgetRoute;
|
|
203
|
+
private adapterFor;
|
|
204
|
+
private claudeAdapter;
|
|
205
|
+
private advertise;
|
|
206
|
+
private unadvertise;
|
|
207
|
+
private reconcileAdvertisement;
|
|
208
|
+
private reconcileUnadvertisement;
|
|
209
|
+
private removeOwnedRoute;
|
|
210
|
+
private recordActivity;
|
|
435
211
|
private registerCodex;
|
|
436
|
-
private lockCodexRegistration;
|
|
437
|
-
private rollbackCodexRegistration;
|
|
438
212
|
private unregisterCodex;
|
|
439
|
-
private
|
|
440
|
-
private removeStaleCodexRegistration;
|
|
441
|
-
private discoveryPublicFingerprint;
|
|
442
|
-
private refreshClaudeDiscovery;
|
|
443
|
-
private renameClaudeRoute;
|
|
444
|
-
private claudeCandidate;
|
|
445
|
-
private activatePersistedClaudeCandidate;
|
|
446
|
-
private selectClaudeCandidate;
|
|
447
|
-
private replaceClaudeSelectionCandidate;
|
|
448
|
-
private resolveSelectedClaudeDestination;
|
|
449
|
-
private inferCodexAlias;
|
|
450
|
-
private assertPairThreadAttestation;
|
|
451
|
-
private pairRoutes;
|
|
452
|
-
private unpairRoutes;
|
|
453
|
-
private assertLiveConsentEndpoints;
|
|
454
|
-
private removeConsentEdge;
|
|
213
|
+
private removeCodexRegistration;
|
|
455
214
|
private selectClaude;
|
|
456
|
-
private selectAndPairClaude;
|
|
457
|
-
private rollbackFreshClaudeSelection;
|
|
458
215
|
private unselectClaude;
|
|
459
|
-
private
|
|
460
|
-
private
|
|
461
|
-
private
|
|
462
|
-
private
|
|
463
|
-
private
|
|
464
|
-
private
|
|
465
|
-
private
|
|
466
|
-
private
|
|
467
|
-
private
|
|
468
|
-
private
|
|
469
|
-
private
|
|
470
|
-
private settlementDeliveryState;
|
|
471
|
-
private pruneDeliveryTrackers;
|
|
472
|
-
private addRuntimeAlert;
|
|
473
|
-
private releaseNativeReceiptLocked;
|
|
474
|
-
/**
|
|
475
|
-
* Native `held` is progress, not terminal delivery or approval. Emit it
|
|
476
|
-
* only after this exact message is known to be waiting, or after its prompt
|
|
477
|
-
* dispatch threshold elapses. A clean pre-write may retry; an ambiguous
|
|
478
|
-
* write is never replayed, and neither path consumes the terminal receipt.
|
|
479
|
-
*/
|
|
480
|
-
private publishNativeHeldLocked;
|
|
481
|
-
private nativeReceiptNotificationFor;
|
|
482
|
-
private sendNativeReceiptLocked;
|
|
483
|
-
private deliveryCorrelation;
|
|
484
|
-
private eventTime;
|
|
485
|
-
private normalizeDeliverySafeCode;
|
|
486
|
-
private planRouteInFlightSettlementsLocked;
|
|
487
|
-
private planRoutesInFlightSettlementsLocked;
|
|
488
|
-
private planConsentEdgeInFlightSettlementsLocked;
|
|
489
|
-
private purgeConsentEdgeCapabilitiesLocked;
|
|
490
|
-
private settleDeliveryStoreLocked;
|
|
491
|
-
private publishStallNoticeLocked;
|
|
492
|
-
private applyDeliveryEffectsLocked;
|
|
493
|
-
private advanceDeliveryLocked;
|
|
494
|
-
private applyTerminalSettlementLocked;
|
|
495
|
-
private takeMessageContextLocked;
|
|
496
|
-
/**
|
|
497
|
-
* Codex App Server acceptance is a terminal delivery boundary for the
|
|
498
|
-
* original message body, but not for its later model reply. Settle the
|
|
499
|
-
* durable ledger/body now and retain only bounded in-memory reply
|
|
500
|
-
* correlation until completion or the original deadline.
|
|
501
|
-
*/
|
|
502
|
-
private acceptProviderDeliveryLocked;
|
|
503
|
-
private stallReasonFor;
|
|
504
|
-
private refreshNextProgressWatchWakeLocked;
|
|
505
|
-
private processProgressWatchesLocked;
|
|
506
|
-
private processLifecycleLocked;
|
|
507
|
-
private scheduleLifecycleWakeLocked;
|
|
216
|
+
private pair;
|
|
217
|
+
private unpair;
|
|
218
|
+
private resolvePairEndpoints;
|
|
219
|
+
private assertThread;
|
|
220
|
+
private sendToClaude;
|
|
221
|
+
private sendToCodex;
|
|
222
|
+
private reply;
|
|
223
|
+
private assertReplyCaller;
|
|
224
|
+
private enqueueConversation;
|
|
225
|
+
private rememberConversation;
|
|
226
|
+
private conversationIsActive;
|
|
508
227
|
private deliveryStatus;
|
|
509
|
-
private
|
|
510
|
-
private
|
|
511
|
-
private
|
|
512
|
-
private
|
|
513
|
-
private
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
* without recreating route authority or accepting a new unsolicited send.
|
|
520
|
-
*/
|
|
521
|
-
private enqueueObservedClaudeReplyAfterRouteTeardownLocked;
|
|
522
|
-
private pruneTransient;
|
|
523
|
-
private awaitDispatchWithNativeHeldLocked;
|
|
524
|
-
private restoreQueuedMessageContextLocked;
|
|
525
|
-
private dispatchOne;
|
|
526
|
-
private scheduleDispatch;
|
|
527
|
-
private scheduleHeldRedispatch;
|
|
528
|
-
private onDelivery;
|
|
529
|
-
private finishDelivery;
|
|
530
|
-
private finishDeliveredReplyLocked;
|
|
531
|
-
private finishProviderTurnContinuationLocked;
|
|
532
|
-
private onClaudeReply;
|
|
533
|
-
private onClaudeMessage;
|
|
534
|
-
private releasePendingClaude;
|
|
535
|
-
private onCodexEndpointRefresh;
|
|
536
|
-
private applyCodexEndpointRefresh;
|
|
228
|
+
private messageUpdatedAt;
|
|
229
|
+
private kick;
|
|
230
|
+
private kickExact;
|
|
231
|
+
private kickSteer;
|
|
232
|
+
private startRunner;
|
|
233
|
+
private runTarget;
|
|
234
|
+
private settleAttemptForShutdown;
|
|
235
|
+
private resolvePrewrite;
|
|
236
|
+
private applyDispatchResult;
|
|
237
|
+
private callbacksFor;
|
|
537
238
|
private onRouteState;
|
|
538
|
-
private
|
|
539
|
-
private
|
|
540
|
-
private
|
|
541
|
-
private
|
|
542
|
-
private
|
|
543
|
-
private
|
|
544
|
-
private
|
|
239
|
+
private onClaudeMessage;
|
|
240
|
+
private onClaudeReply;
|
|
241
|
+
private enqueueCorrelatedReply;
|
|
242
|
+
private enqueueNativeConversationReply;
|
|
243
|
+
private installPendingClaudeReply;
|
|
244
|
+
private pruneExpiredPendingClaudeReplies;
|
|
245
|
+
private retirePendingClaudeReply;
|
|
246
|
+
private activatePendingClaudeReply;
|
|
247
|
+
private deliverPendingClaudeReply;
|
|
248
|
+
private updateProgressWatch;
|
|
249
|
+
private restoreProgressWatch;
|
|
250
|
+
private untrack;
|
|
251
|
+
private settleWatchesForAlias;
|
|
252
|
+
private settleProgressWatch;
|
|
253
|
+
private recordProgressWatchEvent;
|
|
254
|
+
private processProgressWatches;
|
|
255
|
+
private finishSettlements;
|
|
256
|
+
private finishSettlement;
|
|
257
|
+
private scheduleTargetRetry;
|
|
258
|
+
private scheduleWake;
|
|
259
|
+
private onWake;
|
|
260
|
+
private refreshClaudeDiscovery;
|
|
261
|
+
private refreshCodexDoctor;
|
|
262
|
+
private assertWritable;
|
|
263
|
+
private resolveClaudeSelector;
|
|
264
|
+
private resolveSelectedClaudeRoute;
|
|
265
|
+
private routeObservationStillCurrent;
|
|
545
266
|
private publish;
|
|
267
|
+
private alert;
|
|
546
268
|
}
|
|
547
269
|
export {};
|