@axiom-lattice/gateway 4.1.0 → 4.1.2
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/{a2a-standard-VYQCHMBV.mjs → a2a-standard-G3J5ZHQ7.mjs} +15 -15
- package/dist/a2a-standard-G3J5ZHQ7.mjs.map +1 -0
- package/dist/index.d.mts +435 -71
- package/dist/index.d.ts +435 -71
- package/dist/index.js +10280 -3005
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9063 -1733
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/dist/a2a-standard-VYQCHMBV.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,50 +1,40 @@
|
|
|
1
1
|
import * as http from 'http';
|
|
2
|
+
import { ProjectRoomMessage, ProjectBotMembership, ProjectMembership, TaskItem, ChannelAdapter, InboundMessage, Binding, BindingRegistry, ChannelInstallationStore, DispatchResult, ProjectRoomEventScope, ProjectRoomBusinessEventDraft, ProjectRoomScopedBusinessEvent, ProjectRoomBusinessEvent, ProjectRoomEventSubscription, ProjectRoomRealtimeActor, ProjectRoomSseWritable, TaskStore, ProjectRoomStore, ProjectBotMembershipStore, ThreadStore, ProjectRoom, Thread, LoggerType, PinoFileOptions } from '@axiom-lattice/protocols';
|
|
3
|
+
import { TrustedAgentMessageDispatcher, TrustedMessageOptions, TaskLifecycleListener, TaskLifecycleService } from '@axiom-lattice/core';
|
|
2
4
|
import * as fastify from 'fastify';
|
|
3
|
-
import { ChannelAdapter, InboundMessage, Binding, BindingRegistry, ChannelInstallationStore, DispatchResult, LoggerType, PinoFileOptions } from '@axiom-lattice/protocols';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
declare const defaultSwaggerUiConfig: {
|
|
40
|
-
routePrefix: string;
|
|
41
|
-
uiConfig: {
|
|
42
|
-
docExpansion: "full";
|
|
43
|
-
deepLinking: boolean;
|
|
44
|
-
};
|
|
45
|
-
staticCSP: boolean;
|
|
46
|
-
transformStaticCSP: (header: string) => string;
|
|
47
|
-
};
|
|
6
|
+
/** Public publisher surface for committed Project Room business facts. */
|
|
7
|
+
interface ProjectRoomRealtimePublisher {
|
|
8
|
+
/** Publishes a newly committed room message. */
|
|
9
|
+
messageCreated(message: ProjectRoomMessage): void;
|
|
10
|
+
/** Publishes a committed bot roster mutation. */
|
|
11
|
+
rosterChanged(input: {
|
|
12
|
+
tenantId: string;
|
|
13
|
+
roomId: string;
|
|
14
|
+
membership: ProjectBotMembership;
|
|
15
|
+
change: "added" | "updated" | "paused" | "resumed" | "removed";
|
|
16
|
+
sourceKey: string;
|
|
17
|
+
}): void;
|
|
18
|
+
/** Publishes a committed human membership mutation. */
|
|
19
|
+
membershipChanged(input: {
|
|
20
|
+
tenantId: string;
|
|
21
|
+
roomId: string;
|
|
22
|
+
membership: ProjectMembership;
|
|
23
|
+
change: "added" | "role_changed" | "removed";
|
|
24
|
+
sourceKey: string;
|
|
25
|
+
}): void;
|
|
26
|
+
/** Publishes a committed Project Task fact using the caller's event key. */
|
|
27
|
+
taskChanged(input: {
|
|
28
|
+
tenantId: string;
|
|
29
|
+
roomId: string;
|
|
30
|
+
projectId: string;
|
|
31
|
+
taskId: string;
|
|
32
|
+
status: TaskItem["status"];
|
|
33
|
+
ownerMembershipId: string;
|
|
34
|
+
updatedAt: string;
|
|
35
|
+
sourceKey: string;
|
|
36
|
+
}): void;
|
|
37
|
+
}
|
|
48
38
|
|
|
49
39
|
declare class ChannelAdapterRegistry {
|
|
50
40
|
private adapters;
|
|
@@ -62,6 +52,13 @@ interface MessageContext {
|
|
|
62
52
|
}
|
|
63
53
|
type MessageMiddleware = (ctx: MessageContext, next: () => Promise<void>) => Promise<void>;
|
|
64
54
|
|
|
55
|
+
/** Non-serializable host capability required to enter internal Room routing. */
|
|
56
|
+
declare const INTERNAL_ROOM_DISPATCH: unique symbol;
|
|
57
|
+
/** Host-derived Room presence thread identity carried only under the symbol capability. */
|
|
58
|
+
interface InternalRoomDispatchAuthority {
|
|
59
|
+
expectedRoomThreadId: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
65
62
|
/**
|
|
66
63
|
* Configuration for {@link MessageRouter}.
|
|
67
64
|
*
|
|
@@ -75,6 +72,12 @@ interface MessageRouterConfig {
|
|
|
75
72
|
bindingRegistry: BindingRegistry;
|
|
76
73
|
adapterRegistry: ChannelAdapterRegistry;
|
|
77
74
|
installationStore: ChannelInstallationStore;
|
|
75
|
+
trustedDispatcher?: TrustedAgentMessageDispatcher;
|
|
76
|
+
}
|
|
77
|
+
/** Host-trusted options for internal orchestration only. Public routes must not provide these. */
|
|
78
|
+
interface InternalMessageDispatchOptions {
|
|
79
|
+
trustedMessageOptions?: TrustedMessageOptions;
|
|
80
|
+
[INTERNAL_ROOM_DISPATCH]?: InternalRoomDispatchAuthority;
|
|
78
81
|
}
|
|
79
82
|
/**
|
|
80
83
|
* Core message router for external channel integration.
|
|
@@ -86,21 +89,10 @@ interface MessageRouterConfig {
|
|
|
86
89
|
*
|
|
87
90
|
* ## Reply flow
|
|
88
91
|
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* 2. Multiple concurrent dispatches on the same thread increment a counter;
|
|
94
|
-
* only the first registers the `EventEmitter.once` listener.
|
|
95
|
-
* 3. When `reply:ready` fires, the callback extracts the last AI message from
|
|
96
|
-
* the LangGraph state and sends it via `ChannelAdapter.sendReply`.
|
|
97
|
-
* 4. The counter is decremented; the subscription is only removed when the
|
|
98
|
-
* counter reaches 0.
|
|
99
|
-
* 5. Stale subscriptions are cleaned up after a 1-hour timeout.
|
|
100
|
-
*
|
|
101
|
-
* The `replyTarget` is carried through by injecting `_replyTarget` into
|
|
102
|
-
* `custom_run_config` on {@link Agent.addMessage}, and retrieved from the
|
|
103
|
-
* `reply:ready` event payload.
|
|
92
|
+
* Each inbound input gets a unique ID before enqueue and an independent
|
|
93
|
+
* `reply:ready` subscription. Events are filtered by that ID, so concurrent
|
|
94
|
+
* inputs on one thread can complete in either order without cross-delivery.
|
|
95
|
+
* Subscriptions are removed on a matching event, enqueue failure, or timeout.
|
|
104
96
|
*
|
|
105
97
|
* @see {@link ChannelAdapter.sendReply}
|
|
106
98
|
* @see {@link InboundMessage.replyTarget}
|
|
@@ -110,13 +102,8 @@ declare class MessageRouter {
|
|
|
110
102
|
private bindingRegistry;
|
|
111
103
|
private adapterRegistry;
|
|
112
104
|
private installationStore;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
* `subscribeOnce` registrations and ensure proper cleanup.
|
|
116
|
-
*
|
|
117
|
-
* Key format: `{threadId}:{adapterChannel}:reply`
|
|
118
|
-
*/
|
|
119
|
-
private _replySubs;
|
|
105
|
+
private trustedDispatcher?;
|
|
106
|
+
private replySubscriptions;
|
|
120
107
|
constructor(config: MessageRouterConfig);
|
|
121
108
|
/**
|
|
122
109
|
* Register an additional middleware at the end of the chain.
|
|
@@ -124,6 +111,15 @@ declare class MessageRouter {
|
|
|
124
111
|
* @param middleware - A {@link MessageMiddleware} function
|
|
125
112
|
*/
|
|
126
113
|
use(middleware: MessageMiddleware): void;
|
|
114
|
+
/**
|
|
115
|
+
* Releases every pending reply subscription owned by this router.
|
|
116
|
+
*
|
|
117
|
+
* Safe to call repeatedly during Gateway shutdown. Each subscription removes its exact Agent
|
|
118
|
+
* callback and timeout; in-flight Agent execution is not aborted.
|
|
119
|
+
*
|
|
120
|
+
* @returns Nothing.
|
|
121
|
+
*/
|
|
122
|
+
dispose(): void;
|
|
127
123
|
/**
|
|
128
124
|
* Dispatch an inbound channel message to the bound agent.
|
|
129
125
|
*
|
|
@@ -137,10 +133,381 @@ declare class MessageRouter {
|
|
|
137
133
|
* @param message - Normalized inbound message from a channel adapter
|
|
138
134
|
* @returns {@link DispatchResult} with success status, bindingId, and threadId
|
|
139
135
|
*/
|
|
140
|
-
dispatch(message: InboundMessage): Promise<DispatchResult>;
|
|
136
|
+
dispatch(message: InboundMessage, options?: InternalMessageDispatchOptions): Promise<DispatchResult>;
|
|
137
|
+
private dispatchInternal;
|
|
141
138
|
private runMiddlewares;
|
|
142
139
|
}
|
|
143
140
|
|
|
141
|
+
type Listener = (event: ProjectRoomBusinessEvent) => void | Promise<void>;
|
|
142
|
+
/** Construction options for the bounded process-local Project Room event broker. */
|
|
143
|
+
interface ProjectRoomEventBrokerOptions {
|
|
144
|
+
epoch?: string;
|
|
145
|
+
now?: () => number;
|
|
146
|
+
maxEventsPerRoom?: number;
|
|
147
|
+
maxEventAgeMs?: number;
|
|
148
|
+
maxRooms?: number;
|
|
149
|
+
maxGlobalEvents?: number;
|
|
150
|
+
maxGlobalBytes?: number;
|
|
151
|
+
initialSequence?: number;
|
|
152
|
+
log?: {
|
|
153
|
+
warn(message: string, context: Record<string, unknown>): void;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Process-local, bounded Project Room replay and detached notification broker.
|
|
158
|
+
*
|
|
159
|
+
* Retention is intentionally ephemeral. Public operations perform maintenance;
|
|
160
|
+
* no room owns a timer or other background resource.
|
|
161
|
+
*/
|
|
162
|
+
declare class ProjectRoomEventBroker {
|
|
163
|
+
readonly epoch: string;
|
|
164
|
+
private readonly now;
|
|
165
|
+
private readonly maxEventsPerRoom;
|
|
166
|
+
private readonly maxEventAgeMs;
|
|
167
|
+
private readonly maxRooms;
|
|
168
|
+
private readonly maxGlobalEvents;
|
|
169
|
+
private readonly maxGlobalBytes;
|
|
170
|
+
private readonly log;
|
|
171
|
+
private readonly rooms;
|
|
172
|
+
private readonly sequenceScopes;
|
|
173
|
+
private sequence;
|
|
174
|
+
private eventCount;
|
|
175
|
+
private byteCount;
|
|
176
|
+
private subscriberCount;
|
|
177
|
+
private usageClock;
|
|
178
|
+
private closed;
|
|
179
|
+
constructor(options?: ProjectRoomEventBrokerOptions);
|
|
180
|
+
/** Number of currently registered subscriptions across all rooms. */
|
|
181
|
+
get activeSubscriberCount(): number;
|
|
182
|
+
/** Exact UTF-8 byte count of all retained serialized scoped events. */
|
|
183
|
+
get retainedBytes(): number;
|
|
184
|
+
/** Atomically stores an immutable event before queueing detached listener callbacks. */
|
|
185
|
+
publish(scope: ProjectRoomEventScope, draft: ProjectRoomBusinessEventDraft): ProjectRoomScopedBusinessEvent;
|
|
186
|
+
/** Atomically resolves replay and registers a distinct subscription for live events. */
|
|
187
|
+
subscribe(scope: ProjectRoomEventScope, afterEventId: string | undefined, listener: Listener): ProjectRoomEventSubscription;
|
|
188
|
+
/** Clears retained state, marks every subscription closed, and permanently closes the broker. */
|
|
189
|
+
close(): void;
|
|
190
|
+
private unsubscribe;
|
|
191
|
+
private queueCallback;
|
|
192
|
+
private planMaintenance;
|
|
193
|
+
private planRoomCapacity;
|
|
194
|
+
private planGlobalCapacity;
|
|
195
|
+
private inactiveRoomsByLru;
|
|
196
|
+
private inactiveRoomsForRoomEviction;
|
|
197
|
+
private remainingRoomCount;
|
|
198
|
+
private remainingEvents;
|
|
199
|
+
private planEventRemoval;
|
|
200
|
+
private planRoomRemoval;
|
|
201
|
+
private applyPlan;
|
|
202
|
+
private resolveCursor;
|
|
203
|
+
private currentTime;
|
|
204
|
+
private assertOpen;
|
|
205
|
+
private createRoom;
|
|
206
|
+
private touch;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** Dependencies for a Project Room realtime connection. */
|
|
210
|
+
interface ProjectRoomRealtimeServiceDependencies {
|
|
211
|
+
broker: ProjectRoomEventBroker;
|
|
212
|
+
requireReadAccess: (actor: ProjectRoomRealtimeActor, signal: AbortSignal) => Promise<void>;
|
|
213
|
+
log: {
|
|
214
|
+
warn(message: string, context: Record<string, unknown>): void;
|
|
215
|
+
};
|
|
216
|
+
now?: () => number;
|
|
217
|
+
authRecheckMs?: number;
|
|
218
|
+
heartbeatMs?: number;
|
|
219
|
+
maxTimerDelay?: number;
|
|
220
|
+
maxConnectionsPerUserProject?: number;
|
|
221
|
+
}
|
|
222
|
+
/** Orchestrates authenticated, resumable, bounded Project Room SSE connections. */
|
|
223
|
+
declare class ProjectRoomRealtimeService {
|
|
224
|
+
private readonly deps;
|
|
225
|
+
private readonly connections;
|
|
226
|
+
private readonly now;
|
|
227
|
+
private readonly authRecheckMs;
|
|
228
|
+
private readonly heartbeatMs;
|
|
229
|
+
private closed;
|
|
230
|
+
private readonly activeConnections;
|
|
231
|
+
/** Creates a service using one process-local broker and read-only authorizer. */
|
|
232
|
+
constructor(deps: ProjectRoomRealtimeServiceDependencies);
|
|
233
|
+
/** Returns whether the actor's tenant/user/project stream quota has capacity. */
|
|
234
|
+
canConnect(actor: ProjectRoomRealtimeActor): boolean;
|
|
235
|
+
/** Starts a connection; authorization is assumed to have been performed by the route. */
|
|
236
|
+
connect(input: {
|
|
237
|
+
actor: ProjectRoomRealtimeActor;
|
|
238
|
+
roomId: string;
|
|
239
|
+
lastEventId?: string;
|
|
240
|
+
raw: ProjectRoomSseWritable;
|
|
241
|
+
}): void;
|
|
242
|
+
/** Closes every connection and prevents new connections. */
|
|
243
|
+
close(): void;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Publishes the sole realtime task invalidation for committed Project lifecycle notifications.
|
|
248
|
+
*
|
|
249
|
+
* Notifications are admitted synchronously into bounded, scope-keyed FIFO queues. Store work is
|
|
250
|
+
* detached from the Core lifecycle notifier and all failures are warning-only.
|
|
251
|
+
*/
|
|
252
|
+
declare class ProjectRoomTaskEventSubscriber {
|
|
253
|
+
private readonly deps;
|
|
254
|
+
private readonly queues;
|
|
255
|
+
private pendingCount;
|
|
256
|
+
private accepting;
|
|
257
|
+
private closed;
|
|
258
|
+
private readonly maxPending;
|
|
259
|
+
private readonly accepted;
|
|
260
|
+
/** Creates a bounded Project task lifecycle observer. */
|
|
261
|
+
constructor(deps: {
|
|
262
|
+
tasks: Pick<TaskStore, "getById">;
|
|
263
|
+
rooms: Pick<ProjectRoomStore, "getMainRoom">;
|
|
264
|
+
memberships: Pick<ProjectBotMembershipStore, "findByAssistant">;
|
|
265
|
+
realtime: Pick<ProjectRoomRealtimePublisher, "taskChanged">;
|
|
266
|
+
log: {
|
|
267
|
+
warn(message: string, context: Record<string, unknown>): void;
|
|
268
|
+
};
|
|
269
|
+
maxPending?: number;
|
|
270
|
+
});
|
|
271
|
+
/** Admits one notification without awaiting any store operation. */
|
|
272
|
+
handle(value: unknown): Promise<void>;
|
|
273
|
+
/** Closes admission without interrupting accepted work. */
|
|
274
|
+
closeAdmission(): void;
|
|
275
|
+
/** Drains accepted work, closing permanently if the bound expires. */
|
|
276
|
+
drain(timeoutMs?: number): Promise<void>;
|
|
277
|
+
/** Closes admission and drains accepted work. */
|
|
278
|
+
dispose(): Promise<void>;
|
|
279
|
+
private processQueue;
|
|
280
|
+
private publish;
|
|
281
|
+
private parse;
|
|
282
|
+
private warn;
|
|
283
|
+
private overflow;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/** App-owned Project Room realtime resources and lifecycle subscription. */
|
|
287
|
+
declare class ProjectRoomRealtimeRuntime {
|
|
288
|
+
private readonly deps;
|
|
289
|
+
readonly broker: ProjectRoomEventBroker;
|
|
290
|
+
readonly publisher: ProjectRoomRealtimePublisher;
|
|
291
|
+
readonly service: ProjectRoomRealtimeService;
|
|
292
|
+
private readonly accepted;
|
|
293
|
+
private readonly unsubscribe;
|
|
294
|
+
private readonly shutdownTimeoutMs;
|
|
295
|
+
private closing?;
|
|
296
|
+
constructor(deps: {
|
|
297
|
+
broker: ProjectRoomEventBroker;
|
|
298
|
+
publisher: ProjectRoomRealtimePublisher;
|
|
299
|
+
service: ProjectRoomRealtimeService;
|
|
300
|
+
subscriber: Pick<ProjectRoomTaskEventSubscriber, "handle" | "closeAdmission" | "drain">;
|
|
301
|
+
subscribe(listener: TaskLifecycleListener): () => void;
|
|
302
|
+
log: {
|
|
303
|
+
warn(message: string, context: Record<string, unknown>): void;
|
|
304
|
+
};
|
|
305
|
+
shutdownTimeoutMs?: number;
|
|
306
|
+
});
|
|
307
|
+
/** Stops admission, drains accepted work, and closes transport resources exactly once. */
|
|
308
|
+
close(): Promise<void>;
|
|
309
|
+
private dispose;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** Identifies one tenant-scoped Project task machine. */
|
|
313
|
+
interface ProjectTaskMachineScope {
|
|
314
|
+
tenantId: string;
|
|
315
|
+
assistantId: string;
|
|
316
|
+
projectId: string;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Serializes Project task machine operations by tenant, Assistant, and Project.
|
|
320
|
+
*
|
|
321
|
+
* This mutex is process-local: callers must share one instance, and deployments
|
|
322
|
+
* with multiple Gateway processes need an external lease for cross-process
|
|
323
|
+
* exclusion. Acquisition is FIFO and intentionally non-reentrant; an operation
|
|
324
|
+
* must not await another acquisition of its own machine key. When an operation
|
|
325
|
+
* also needs the Project mutation mutex, it must acquire this machine mutex first.
|
|
326
|
+
*/
|
|
327
|
+
declare class ProjectTaskExecutionMutex {
|
|
328
|
+
private readonly queues;
|
|
329
|
+
private readonly active;
|
|
330
|
+
/**
|
|
331
|
+
* Runs an operation after all earlier operations for the same machine finish.
|
|
332
|
+
* A queued operation can be cancelled with `signal`; cancellation never aborts
|
|
333
|
+
* an operation that has already acquired the machine.
|
|
334
|
+
*/
|
|
335
|
+
runExclusive<T>(scope: ProjectTaskMachineScope, operation: () => Promise<T>, signal?: AbortSignal): Promise<T>;
|
|
336
|
+
/** Returns the number of operations waiting behind the current holder. */
|
|
337
|
+
pending(scope: ProjectTaskMachineScope): number;
|
|
338
|
+
private acquire;
|
|
339
|
+
private release;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/** Input required to resolve a canonical Project Task execution Thread. */
|
|
343
|
+
interface EnsureProjectTaskThreadInput {
|
|
344
|
+
task: TaskItem;
|
|
345
|
+
room: ProjectRoom;
|
|
346
|
+
membership: ProjectBotMembership;
|
|
347
|
+
mode: "current_owner" | "reassignment";
|
|
348
|
+
}
|
|
349
|
+
/** Result of resolving or creating a canonical Project Task execution Thread. */
|
|
350
|
+
interface EnsuredProjectTaskThread {
|
|
351
|
+
thread: Thread;
|
|
352
|
+
created: boolean;
|
|
353
|
+
/** True when a later task CAS loser can identify this newly created retained Thread as an orphan candidate. */
|
|
354
|
+
orphanCandidate: boolean;
|
|
355
|
+
}
|
|
356
|
+
/** Dependencies needed to resolve Project Task Threads. */
|
|
357
|
+
interface ProjectTaskThreadServiceDependencies {
|
|
358
|
+
threads: Pick<ThreadStore, "getThreadById" | "createThread">;
|
|
359
|
+
idFactory: () => string;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Resolves an exact current-owner Thread or creates a new target-owned reassignment Thread.
|
|
363
|
+
*
|
|
364
|
+
* Generated IDs are read before creation because Thread stores may implement creation as an
|
|
365
|
+
* upsert. Every create is read back and validated; newly created Threads are intentionally retained.
|
|
366
|
+
*/
|
|
367
|
+
declare class ProjectTaskThreadService {
|
|
368
|
+
private readonly deps;
|
|
369
|
+
/** @param deps Thread persistence and unique-ID generation dependencies. */
|
|
370
|
+
constructor(deps: ProjectTaskThreadServiceDependencies);
|
|
371
|
+
/**
|
|
372
|
+
* Ensures a canonical Task execution Thread for the requested ownership mode.
|
|
373
|
+
*
|
|
374
|
+
* @param input Exact Task, room, membership, and ownership mode.
|
|
375
|
+
* @returns The validated canonical Thread and creation/orphan disposition.
|
|
376
|
+
*/
|
|
377
|
+
ensure(input: EnsureProjectTaskThreadInput): Promise<EnsuredProjectTaskThread>;
|
|
378
|
+
private assertScope;
|
|
379
|
+
private assertThread;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/** Aggregate result of one bounded deterministic startup reconciliation. */
|
|
383
|
+
interface ProjectTaskReconciliationResult {
|
|
384
|
+
inspected: number;
|
|
385
|
+
taskTruncated: boolean;
|
|
386
|
+
projectEnumerationTruncated: boolean;
|
|
387
|
+
projectionTruncated: boolean;
|
|
388
|
+
projectionWarnings: number;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/** Bounds applied while starting and stopping the process-owned Project Task runtime. */
|
|
392
|
+
interface ProjectTaskRuntimeLifecycleOptions {
|
|
393
|
+
/** Soft admission deadline that aborts new reconciliation work while initiated work drains. */
|
|
394
|
+
deadlineMs?: number;
|
|
395
|
+
}
|
|
396
|
+
/** Process-owned Project Task observer, recovery, and execution lifecycle. */
|
|
397
|
+
interface ProjectTaskRuntimeDisposal {
|
|
398
|
+
/** Whether every initiated operation drained before the bounded shutdown deadline. */
|
|
399
|
+
readonly drained: boolean;
|
|
400
|
+
/** Actual completion of every initiated operation, including work beyond the shutdown deadline. */
|
|
401
|
+
readonly drainPromise: Promise<void>;
|
|
402
|
+
}
|
|
403
|
+
/** Process-owned Project Task observer, recovery, and execution lifecycle. */
|
|
404
|
+
interface ProjectTaskRuntime {
|
|
405
|
+
/** Shared process-local execution mutex used by HTTP reassignment and observer work. */
|
|
406
|
+
readonly mutex: ProjectTaskExecutionMutex;
|
|
407
|
+
/** Shared canonical Task Thread service. */
|
|
408
|
+
readonly threads: ProjectTaskThreadService;
|
|
409
|
+
/** Shared canonical Task lifecycle service. */
|
|
410
|
+
readonly lifecycle: TaskLifecycleService;
|
|
411
|
+
/** Starts or joins one bounded startup reconciliation. */
|
|
412
|
+
prepareReconciliation(options?: ProjectTaskRuntimeLifecycleOptions): Promise<ProjectTaskReconciliationResult>;
|
|
413
|
+
/** Aborts runtime work and returns bounded status plus the actual drain promise. */
|
|
414
|
+
dispose(): Promise<ProjectTaskRuntimeDisposal>;
|
|
415
|
+
}
|
|
416
|
+
/** Reference-counted handle to one process-owned Project Task runtime. */
|
|
417
|
+
interface ProjectTaskRuntimeLease {
|
|
418
|
+
/** Shared runtime instance. */
|
|
419
|
+
readonly runtime: ProjectTaskRuntime;
|
|
420
|
+
/** Starts or joins the registry's single startup reconciliation. */
|
|
421
|
+
prepare(options?: ProjectTaskRuntimeLifecycleOptions): Promise<ProjectTaskReconciliationResult>;
|
|
422
|
+
/** Releases this handle; the final release disposes the runtime. */
|
|
423
|
+
release(): Promise<void>;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Channel infrastructure shared by inbound routing and internal room binding provisioning.
|
|
428
|
+
*
|
|
429
|
+
* @remarks All fields must reference the objects created by gateway startup; room provisioning
|
|
430
|
+
* must not construct a second registry or installation store.
|
|
431
|
+
*/
|
|
432
|
+
interface ChannelDependencies {
|
|
433
|
+
/** Message router used by channel ingress. */
|
|
434
|
+
router: MessageRouter;
|
|
435
|
+
/** Adapter registry used by channel ingress and installation lifecycle management. */
|
|
436
|
+
adapterRegistry: ChannelAdapterRegistry;
|
|
437
|
+
/** Tenant-scoped installation persistence used by routing and room provisioning. */
|
|
438
|
+
installationStore: ChannelInstallationStore;
|
|
439
|
+
/** Tenant-scoped binding persistence shared by routing and room provisioning. */
|
|
440
|
+
bindingRegistry: BindingRegistry;
|
|
441
|
+
/** Shared process-local Project Room realtime publisher. */
|
|
442
|
+
realtime?: ProjectRoomRealtimePublisher;
|
|
443
|
+
/** Structured warning sink for safe post-commit realtime callback failures. */
|
|
444
|
+
warn?: (message: string, context: Record<string, unknown>) => void;
|
|
445
|
+
}
|
|
446
|
+
/** Options controlling optional route-owned runtime composition. */
|
|
447
|
+
interface LatticeRouteOptions {
|
|
448
|
+
/** Enables Project Task execution, notification observation, and startup recovery. */
|
|
449
|
+
projectTaskEnabled: boolean;
|
|
450
|
+
/** Structured warning sink used by background observation and projection repair. */
|
|
451
|
+
projectTaskLog: {
|
|
452
|
+
warn: (message: string, context: Record<string, unknown>) => void;
|
|
453
|
+
};
|
|
454
|
+
/** Optional app-owned runtime created before channel and route composition. */
|
|
455
|
+
projectRoomRealtimeRuntime: ProjectRoomRealtimeRuntime;
|
|
456
|
+
}
|
|
457
|
+
/** Optional runtime resources returned while registering the always-available HTTP routes. */
|
|
458
|
+
interface LatticeRouteResult {
|
|
459
|
+
/** Present only when execution is enabled and every runtime dependency is available. */
|
|
460
|
+
projectTaskRuntime?: ProjectTaskRuntimeLease;
|
|
461
|
+
/** Stable missing capability or incompatible-runtime reason. */
|
|
462
|
+
projectTaskUnavailableReason?: string;
|
|
463
|
+
/** Present only in exact single-Gateway realtime mode. */
|
|
464
|
+
projectRoomRealtimeRuntime?: ProjectRoomRealtimeRuntime;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
declare const defaultSwaggerConfig: {
|
|
468
|
+
openapi: {
|
|
469
|
+
openapi: string;
|
|
470
|
+
info: {
|
|
471
|
+
title: string;
|
|
472
|
+
description: string;
|
|
473
|
+
version: string;
|
|
474
|
+
contact: {
|
|
475
|
+
name: string;
|
|
476
|
+
email: string;
|
|
477
|
+
};
|
|
478
|
+
};
|
|
479
|
+
servers: {
|
|
480
|
+
url: string;
|
|
481
|
+
description: string;
|
|
482
|
+
}[];
|
|
483
|
+
components: {
|
|
484
|
+
securitySchemes: {
|
|
485
|
+
bearerAuth: {
|
|
486
|
+
type: "http";
|
|
487
|
+
scheme: "bearer";
|
|
488
|
+
bearerFormat: string;
|
|
489
|
+
};
|
|
490
|
+
};
|
|
491
|
+
};
|
|
492
|
+
security: {
|
|
493
|
+
bearerAuth: never[];
|
|
494
|
+
}[];
|
|
495
|
+
tags: {
|
|
496
|
+
name: string;
|
|
497
|
+
description: string;
|
|
498
|
+
}[];
|
|
499
|
+
};
|
|
500
|
+
};
|
|
501
|
+
declare const defaultSwaggerUiConfig: {
|
|
502
|
+
routePrefix: string;
|
|
503
|
+
uiConfig: {
|
|
504
|
+
docExpansion: "full";
|
|
505
|
+
deepLinking: boolean;
|
|
506
|
+
};
|
|
507
|
+
staticCSP: boolean;
|
|
508
|
+
transformStaticCSP: (header: string) => string;
|
|
509
|
+
};
|
|
510
|
+
|
|
144
511
|
type QueueServiceType = "memory" | "redis";
|
|
145
512
|
|
|
146
513
|
interface AgentTaskRequest {
|
|
@@ -223,10 +590,7 @@ interface LatticeGatewayConfig {
|
|
|
223
590
|
declare const LatticeGateway: {
|
|
224
591
|
startAsHttpEndpoint: (config?: LatticeGatewayConfig) => Promise<void>;
|
|
225
592
|
configureSwagger: (app: fastify.FastifyInstance, customSwaggerConfig?: Partial<typeof defaultSwaggerConfig>, customSwaggerUiConfig?: Partial<typeof defaultSwaggerUiConfig>) => Promise<void>;
|
|
226
|
-
registerLatticeRoutes: (app: fastify.FastifyInstance, channelDeps?:
|
|
227
|
-
router: MessageRouter;
|
|
228
|
-
installationStore: ChannelInstallationStore;
|
|
229
|
-
}) => void;
|
|
593
|
+
registerLatticeRoutes: (app: fastify.FastifyInstance, channelDeps?: ChannelDependencies, options?: Partial<LatticeRouteOptions>) => LatticeRouteResult;
|
|
230
594
|
app: fastify.FastifyInstance<http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>, http.IncomingMessage, http.ServerResponse<http.IncomingMessage>, fastify.FastifyBaseLogger, fastify.FastifyTypeProviderDefault> & PromiseLike<fastify.FastifyInstance<http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>, http.IncomingMessage, http.ServerResponse<http.IncomingMessage>, fastify.FastifyBaseLogger, fastify.FastifyTypeProviderDefault>> & {
|
|
231
595
|
__linterBrands: "SafePromiseLike";
|
|
232
596
|
};
|