@emseepea/server 0.24.0 → 0.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/events-cloud-tasks-transport.d.ts +34 -0
  2. package/dist/events-cloud-tasks-transport.d.ts.map +1 -0
  3. package/dist/events-cloud-tasks-transport.js +232 -0
  4. package/dist/events-cloud-tasks-transport.js.map +1 -0
  5. package/dist/events-google-sdk-lifetime.d.ts +7 -0
  6. package/dist/events-google-sdk-lifetime.d.ts.map +1 -0
  7. package/dist/events-google-sdk-lifetime.js +70 -0
  8. package/dist/events-google-sdk-lifetime.js.map +1 -0
  9. package/dist/events-postgres-delivery-migrations.d.ts +18 -0
  10. package/dist/events-postgres-delivery-migrations.d.ts.map +1 -0
  11. package/dist/events-postgres-delivery-migrations.js +146 -0
  12. package/dist/events-postgres-delivery-migrations.js.map +1 -0
  13. package/dist/events-postgres-delivery-owned.d.ts +16 -0
  14. package/dist/events-postgres-delivery-owned.d.ts.map +1 -0
  15. package/dist/events-postgres-delivery-owned.js +178 -0
  16. package/dist/events-postgres-delivery-owned.js.map +1 -0
  17. package/dist/events-postgres-delivery.d.ts +29 -0
  18. package/dist/events-postgres-delivery.d.ts.map +1 -0
  19. package/dist/events-postgres-delivery.js +299 -0
  20. package/dist/events-postgres-delivery.js.map +1 -0
  21. package/dist/events-postgres-dispatch-migrations.d.ts +19 -0
  22. package/dist/events-postgres-dispatch-migrations.d.ts.map +1 -0
  23. package/dist/events-postgres-dispatch-migrations.js +162 -0
  24. package/dist/events-postgres-dispatch-migrations.js.map +1 -0
  25. package/dist/events-postgres-dispatch.d.ts +39 -0
  26. package/dist/events-postgres-dispatch.d.ts.map +1 -0
  27. package/dist/events-postgres-dispatch.js +270 -0
  28. package/dist/events-postgres-dispatch.js.map +1 -0
  29. package/dist/events-postgres-lifecycle-migrations.d.ts +17 -0
  30. package/dist/events-postgres-lifecycle-migrations.d.ts.map +1 -0
  31. package/dist/events-postgres-lifecycle-migrations.js +125 -0
  32. package/dist/events-postgres-lifecycle-migrations.js.map +1 -0
  33. package/dist/events-postgres-lifecycle.d.ts +13 -0
  34. package/dist/events-postgres-lifecycle.d.ts.map +1 -0
  35. package/dist/events-postgres-lifecycle.js +176 -0
  36. package/dist/events-postgres-lifecycle.js.map +1 -0
  37. package/dist/events-postgres-migrations.d.ts +32 -0
  38. package/dist/events-postgres-migrations.d.ts.map +1 -0
  39. package/dist/events-postgres-migrations.js +329 -0
  40. package/dist/events-postgres-migrations.js.map +1 -0
  41. package/dist/events-postgres-owned.d.ts +16 -0
  42. package/dist/events-postgres-owned.d.ts.map +1 -0
  43. package/dist/events-postgres-owned.js +161 -0
  44. package/dist/events-postgres-owned.js.map +1 -0
  45. package/dist/events-postgres.d.ts +53 -0
  46. package/dist/events-postgres.d.ts.map +1 -0
  47. package/dist/events-postgres.js +289 -0
  48. package/dist/events-postgres.js.map +1 -0
  49. package/dist/index.js +58 -9
  50. package/dist/index.js.map +1 -1
  51. package/package.json +29 -5
@@ -0,0 +1,34 @@
1
+ import type { ExternalMcpEventInvocation } from './events-external.js';
2
+ import type { EventDispatchTransport } from './events-postgres-dispatch.js';
3
+ type Invocation = ExternalMcpEventInvocation;
4
+ export declare class GoogleEventTransportSetupError extends Error {
5
+ readonly code: 'INVALID_CONFIGURATION' | 'UNSUPPORTED_DEPENDENCY_GRAPH' | 'UNSAFE_SDK_LOGGING';
6
+ constructor(code: 'INVALID_CONFIGURATION' | 'UNSUPPORTED_DEPENDENCY_GRAPH' | 'UNSAFE_SDK_LOGGING');
7
+ }
8
+ export interface CloudTasksEventConfiguration {
9
+ readonly namespace: string;
10
+ readonly projectId: string;
11
+ readonly location: string;
12
+ readonly queueId: string;
13
+ readonly workerURL: string;
14
+ readonly audience: string;
15
+ readonly serviceAccountEmail: string;
16
+ readonly serviceAccountUid: string;
17
+ }
18
+ interface Credentials {
19
+ getRequestHeaders(url: string): Promise<Headers>;
20
+ }
21
+ interface Runtime {
22
+ graphSafe(): boolean;
23
+ loggingSafe(): boolean;
24
+ createAuth(projectId: string): {
25
+ getClient(): Promise<Credentials>;
26
+ };
27
+ fetch: typeof globalThis.fetch;
28
+ }
29
+ /** Private preparation seam; no public route or credential/provider override is exported by the package. */
30
+ export declare function createCloudTasksRestTransportRuntime(options: CloudTasksEventConfiguration, runtime?: Runtime): EventDispatchTransport & {
31
+ settle(invocation: Invocation): Promise<boolean>;
32
+ };
33
+ export {};
34
+ //# sourceMappingURL=events-cloud-tasks-transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events-cloud-tasks-transport.d.ts","sourceRoot":"","sources":["../src/events-cloud-tasks-transport.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAI5E,KAAK,UAAU,GAAC,0BAA0B,CAAC;AAG3C,qBAAa,8BAA+B,SAAQ,KAAK;IAC5C,QAAQ,CAAC,IAAI,EAAC,uBAAuB,GAAC,8BAA8B,GAAC,oBAAoB;gBAAhF,IAAI,EAAC,uBAAuB,GAAC,8BAA8B,GAAC,oBAAoB;CACrG;AACD,MAAM,WAAW,4BAA4B;IAC5C,QAAQ,CAAC,SAAS,EAAC,MAAM,CAAC;IAAA,QAAQ,CAAC,SAAS,EAAC,MAAM,CAAC;IAAA,QAAQ,CAAC,QAAQ,EAAC,MAAM,CAAC;IAAA,QAAQ,CAAC,OAAO,EAAC,MAAM,CAAC;IACrG,QAAQ,CAAC,SAAS,EAAC,MAAM,CAAC;IAAA,QAAQ,CAAC,QAAQ,EAAC,MAAM,CAAC;IAAA,QAAQ,CAAC,mBAAmB,EAAC,MAAM,CAAC;IAAA,QAAQ,CAAC,iBAAiB,EAAC,MAAM,CAAC;CACzH;AACD,UAAU,WAAW;IAAE,iBAAiB,CAAC,GAAG,EAAC,MAAM,GAAE,OAAO,CAAC,OAAO,CAAC,CAAA;CAAC;AACtE,UAAU,OAAO;IAChB,SAAS,IAAG,OAAO,CAAC;IAAA,WAAW,IAAG,OAAO,CAAC;IAC1C,UAAU,CAAC,SAAS,EAAC,MAAM,GAAE;QAAC,SAAS,IAAG,OAAO,CAAC,WAAW,CAAC,CAAA;KAAC,CAAC;IAChE,KAAK,EAAC,OAAO,UAAU,CAAC,KAAK,CAAC;CAC9B;AAkCD,4GAA4G;AAC5G,wBAAgB,oCAAoC,CAAC,OAAO,EAAC,4BAA4B,EAAC,OAAO,GAAC,OAAkB,GAAE,sBAAsB,GAAC;IAAC,MAAM,CAAC,UAAU,EAAC,UAAU,GAAE,OAAO,CAAC,OAAO,CAAC,CAAA;CAAC,CAmE5L"}
@@ -0,0 +1,232 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { createRequire } from 'node:module';
3
+ import { realpathSync } from 'node:fs';
4
+ import { TextDecoder } from 'node:util';
5
+ import { GoogleAuth, AuthClient } from 'google-auth-library';
6
+ import { log, placeholder } from 'google-logging-utils';
7
+ import { createGoogleApiLifetime } from './events-google-sdk-lifetime.js';
8
+ const origin = 'https://cloudtasks.googleapis.com';
9
+ const requestLimit = 8192, responseLimit = 16384, bodyLimit = 1024;
10
+ export class GoogleEventTransportSetupError extends Error {
11
+ code;
12
+ constructor(code) {
13
+ super(code);
14
+ this.code = code;
15
+ this.name = 'GoogleEventTransportSetupError';
16
+ }
17
+ }
18
+ const production = {
19
+ graphSafe() {
20
+ try {
21
+ const here = createRequire(import.meta.url), auth = createRequire(here.resolve('google-auth-library'));
22
+ const metadata = createRequire(auth.resolve('gcp-metadata'));
23
+ const expected = realpathSync(here.resolve('google-logging-utils'));
24
+ return expected === realpathSync(auth.resolve('google-logging-utils')) && expected === realpathSync(metadata.resolve('google-logging-utils'));
25
+ }
26
+ catch {
27
+ return false;
28
+ }
29
+ },
30
+ loggingSafe: () => !process.env.DEBUG_AUTH && AuthClient.log === placeholder && log('auth') === placeholder && log('gcp-metadata') === placeholder,
31
+ createAuth: projectId => new GoogleAuth({ projectId, universeDomain: 'googleapis.com', scopes: ['https://www.googleapis.com/auth/cloud-platform'] }),
32
+ fetch: (input, options) => globalThis.fetch(input, options),
33
+ };
34
+ const setup = (code) => { throw new GoogleEventTransportSetupError(code); };
35
+ const hasControl = (value) => { for (const character of value) {
36
+ const code = character.codePointAt(0);
37
+ if (code <= 31 || code === 127)
38
+ return true;
39
+ } return false; };
40
+ const text = (v, max) => typeof v === 'string' && v.length > 0 && Buffer.byteLength(v) <= max &&
41
+ !hasControl(v) && !/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(v);
42
+ const object = (v) => !!v && typeof v === 'object' && !Array.isArray(v) && Object.getPrototypeOf(v) === Object.prototype;
43
+ const keys = (v, allowed) => Object.keys(v).every(k => allowed.includes(k));
44
+ const noKeys = (v) => v === undefined || object(v) && Object.keys(v).length === 0;
45
+ function https(value) {
46
+ if (!text(value, 2048))
47
+ return setup('INVALID_CONFIGURATION');
48
+ try {
49
+ const url = new URL(value);
50
+ if (url.protocol !== 'https:' || url.username || url.password || url.search || url.hash || url.port && url.port !== '443')
51
+ return setup('INVALID_CONFIGURATION');
52
+ return url.href;
53
+ }
54
+ catch {
55
+ return setup('INVALID_CONFIGURATION');
56
+ }
57
+ }
58
+ function configure(value) {
59
+ if (!object(value) || !keys(value, ['namespace', 'projectId', 'location', 'queueId', 'workerURL', 'audience', 'serviceAccountEmail', 'serviceAccountUid']) ||
60
+ !text(value.namespace, 240) || typeof value.projectId !== 'string' || !/^[a-z][a-z0-9-]{4,28}[a-z0-9]$/.test(value.projectId) ||
61
+ typeof value.location !== 'string' || !/^[a-z][a-z0-9-]{0,62}$/.test(value.location) || typeof value.queueId !== 'string' || !/^[A-Za-z0-9_-]{1,100}$/.test(value.queueId) ||
62
+ typeof value.serviceAccountEmail !== 'string' || !/^[-a-z0-9.]{1,64}@[-a-z0-9.]{1,128}\.iam\.gserviceaccount\.com$/.test(value.serviceAccountEmail) ||
63
+ typeof value.serviceAccountUid !== 'string' || !/^[0-9]{1,40}$/.test(value.serviceAccountUid))
64
+ return setup('INVALID_CONFIGURATION');
65
+ const config = Object.freeze({ ...value, workerURL: https(value.workerURL), audience: https(value.audience) });
66
+ const queue = `projects/${config.projectId}/locations/${config.location}/queues/${config.queueId}`;
67
+ return { config, queue, fingerprint: createHash('sha256').update(JSON.stringify([config.namespace, queue, config.workerURL, config.audience, config.serviceAccountEmail, config.serviceAccountUid, 'POST', 1, 28])).digest('hex') };
68
+ }
69
+ /** Private preparation seam; no public route or credential/provider override is exported by the package. */
70
+ export function createCloudTasksRestTransportRuntime(options, runtime = production) {
71
+ const { config, queue, fingerprint } = configure(options), lifetime = createGoogleApiLifetime();
72
+ let disposalFailed = false;
73
+ const endpoint = `${origin}/v2/${queue.split('/').map(encodeURIComponent).join('/')}`;
74
+ const body = (deliveryId) => Buffer.from(JSON.stringify({ deliveryId }));
75
+ function descriptor(deliveryId, taskId) {
76
+ if (!text(deliveryId, 240) || !/^emseepea-[0-9a-f]{64}$/.test(taskId))
77
+ throw new Error('INVALID_TASK_IDENTITY');
78
+ const bytes = body(deliveryId);
79
+ if (bytes.length > bodyLimit)
80
+ throw new Error('TASK_BODY_TOO_LARGE');
81
+ return { name: `${queue}/tasks/${taskId}`, httpRequest: { httpMethod: 'POST', url: config.workerURL, headers: { 'Content-Type': 'application/json' }, body: bytes.toString('base64'),
82
+ oidcToken: { serviceAccountEmail: config.serviceAccountEmail, audience: config.audience } }, dispatchDeadline: '28s' };
83
+ }
84
+ function requestBody(deliveryId, taskId) { const bytes = Buffer.from(JSON.stringify({ task: descriptor(deliveryId, taskId), responseView: 'BASIC' })); if (bytes.length > requestLimit)
85
+ throw new Error('CREATE_REQUEST_TOO_LARGE'); return bytes; }
86
+ // Reject configurations whose worst valid escaped identifier can never meet the request cap.
87
+ try {
88
+ requestBody('\\'.repeat(240), 'emseepea-' + 'f'.repeat(64));
89
+ }
90
+ catch {
91
+ return setup('INVALID_CONFIGURATION');
92
+ }
93
+ const guards = () => { if (!runtime.graphSafe())
94
+ return setup('UNSUPPORTED_DEPENDENCY_GRAPH'); if (!runtime.loggingSafe())
95
+ return setup('UNSAFE_SDK_LOGGING'); };
96
+ guards();
97
+ const auth = runtime.createAuth(config.projectId);
98
+ async function read(response, check) {
99
+ if (!response.body)
100
+ throw new Error('EMPTY_GOOGLE_RESPONSE');
101
+ const reader = response.body.getReader();
102
+ let done = false, total = 0, value, failure;
103
+ const chunks = [];
104
+ try {
105
+ while (true) {
106
+ check();
107
+ const next = await reader.read();
108
+ check();
109
+ if (next.done) {
110
+ done = true;
111
+ break;
112
+ }
113
+ total += next.value.byteLength;
114
+ if (total > responseLimit)
115
+ throw new Error('GOOGLE_RESPONSE_TOO_LARGE');
116
+ chunks.push(next.value);
117
+ }
118
+ value = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(Buffer.concat(chunks, total)));
119
+ }
120
+ catch (error) {
121
+ failure = error;
122
+ }
123
+ if (!done)
124
+ try {
125
+ await reader.cancel();
126
+ }
127
+ catch {
128
+ disposalFailed = true;
129
+ failure = new Error('GOOGLE_STREAM_CLEANUP_FAILED');
130
+ }
131
+ try {
132
+ reader.releaseLock();
133
+ }
134
+ catch {
135
+ disposalFailed = true;
136
+ }
137
+ if (failure)
138
+ throw failure;
139
+ return value;
140
+ }
141
+ async function request(path, method, data, invocation) {
142
+ if (data && data.length > requestLimit)
143
+ return null;
144
+ return lifetime.invoke(invocation, null, async (signal, check) => {
145
+ guards();
146
+ check();
147
+ const credentials = await auth.getClient();
148
+ check();
149
+ guards();
150
+ const supplied = await credentials.getRequestHeaders(origin);
151
+ check();
152
+ guards();
153
+ const authorization = supplied.get('authorization');
154
+ if (typeof authorization !== 'string' || authorization.length > 8192 || !/^Bearer [A-Za-z0-9._~+\x2f-]+=*$/.test(authorization))
155
+ throw new Error('GOOGLE_AUTH_UNAVAILABLE');
156
+ // Do not forward quota-project or arbitrary SDK headers into the configured queue request.
157
+ const headers = { Authorization: authorization };
158
+ if (data)
159
+ headers['Content-Type'] = 'application/json';
160
+ check();
161
+ const response = await runtime.fetch(path, { method, headers, redirect: 'manual', signal, ...(data ? { body: data.toString('utf8') } : {}) });
162
+ if (response.status >= 300 && response.status < 400) {
163
+ if (response.body)
164
+ await response.body.cancel();
165
+ throw new Error('GOOGLE_REDIRECT_REJECTED');
166
+ }
167
+ const value = await read(response, check);
168
+ check();
169
+ return { status: response.status, value };
170
+ });
171
+ }
172
+ function matching(value, deliveryId, taskId) {
173
+ if (!object(value) || !keys(value, ['name', 'httpRequest', 'dispatchDeadline', 'scheduleTime', 'createTime', 'dispatchCount', 'responseCount', 'firstAttempt', 'lastAttempt', 'view']))
174
+ return false;
175
+ const wanted = descriptor(deliveryId, taskId), http = value.httpRequest;
176
+ if (value.name !== wanted.name || value.dispatchDeadline !== '28s' || !object(http) || !keys(http, ['httpMethod', 'url', 'headers', 'body', 'oidcToken']) || http.httpMethod !== 'POST' || http.url !== config.workerURL)
177
+ return false;
178
+ if (!object(http.oidcToken) || !keys(http.oidcToken, ['serviceAccountEmail', 'audience']) || http.oidcToken.serviceAccountEmail !== config.serviceAccountEmail || http.oidcToken.audience !== config.audience)
179
+ return false;
180
+ if (!object(http.headers) || Object.keys(http.headers).length !== 1 || Object.entries(http.headers).some(([name, value]) => name.toLowerCase() !== 'content-type' || value !== 'application/json'))
181
+ return false;
182
+ if (typeof http.body !== 'string' || http.body.length > 1400 || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(http.body))
183
+ return false;
184
+ const decoded = Buffer.from(http.body, 'base64');
185
+ return decoded.length <= bodyLimit && decoded.toString('base64') === http.body && decoded.equals(body(deliveryId));
186
+ }
187
+ return Object.freeze({
188
+ fingerprint,
189
+ async queue(invocation) {
190
+ const response = await request(endpoint, 'GET', undefined, invocation);
191
+ if (!response || response.status !== 200 || !object(response.value))
192
+ return 'unavailable';
193
+ const value = response.value;
194
+ return value.name === queue && value.state === 'RUNNING' && keys(value, ['name', 'state', 'rateLimits', 'retryConfig', 'purgeTime', 'taskTtl', 'tombstoneTtl', 'stackdriverLoggingConfig', 'httpTarget', 'appEngineRoutingOverride']) && noKeys(value.httpTarget) && noKeys(value.appEngineRoutingOverride) ? 'present' : 'unavailable';
195
+ },
196
+ async inspect(task, invocation) {
197
+ const { deliveryId, taskId } = task;
198
+ try {
199
+ descriptor(deliveryId, taskId);
200
+ }
201
+ catch {
202
+ return 'conflict';
203
+ }
204
+ const response = await request(`${endpoint}/tasks/${taskId}?responseView=FULL`, 'GET', undefined, invocation);
205
+ if (!response)
206
+ return 'unavailable';
207
+ if (response.status === 404)
208
+ return 'missing';
209
+ if (response.status !== 200)
210
+ return 'unavailable';
211
+ return matching(response.value, deliveryId, taskId) ? 'matching' : 'conflict';
212
+ },
213
+ async create(task, invocation) {
214
+ const { deliveryId, taskId } = task;
215
+ let bytes;
216
+ try {
217
+ bytes = requestBody(deliveryId, taskId);
218
+ }
219
+ catch {
220
+ return 'unavailable';
221
+ }
222
+ const response = await request(`${endpoint}/tasks`, 'POST', bytes, invocation);
223
+ if (!response || !object(response.value))
224
+ return 'unavailable';
225
+ if (response.status >= 200 && response.status < 300 && response.value.name === `${queue}/tasks/${taskId}`)
226
+ return 'created';
227
+ return response.status === 409 && object(response.value.error) && response.value.error.status === 'ALREADY_EXISTS' ? 'exists' : 'unavailable';
228
+ },
229
+ async settle(invocation) { return await lifetime.settle(invocation) && !disposalFailed; },
230
+ });
231
+ }
232
+ //# sourceMappingURL=events-cloud-tasks-transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events-cloud-tasks-transport.js","sourceRoot":"","sources":["../src/events-cloud-tasks-transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C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AM,CAAC,UAAU,CAAC,IAAE,CAAC,cAAc,CAAC,CAAA,CAAC;KAC/F,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { ExternalMcpEventInvocation } from './events-external.js';
2
+ /** Private ownership of exposed credential/fetch/body promises, never a cancellation guarantee. */
3
+ export declare function createGoogleApiLifetime(): {
4
+ invoke<T>(invocation: ExternalMcpEventInvocation, unavailable: T, work: (signal: AbortSignal, check: () => void) => Promise<T>): Promise<T>;
5
+ settle(invocation: ExternalMcpEventInvocation): Promise<boolean>;
6
+ };
7
+ //# sourceMappingURL=events-google-sdk-lifetime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events-google-sdk-lifetime.d.ts","sourceRoot":"","sources":["../src/events-google-sdk-lifetime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAEvE,mGAAmG;AACnG,wBAAgB,uBAAuB;WAGxB,CAAC,cAAa,0BAA0B,eAAa,CAAC,QAAM,CAAC,MAAM,EAAC,WAAW,EAAC,KAAK,EAAC,MAAI,IAAI,KAAG,OAAO,CAAC,CAAC,CAAC,GAAE,OAAO,CAAC,CAAC,CAAC;uBAgB5G,0BAA0B,GAAE,OAAO,CAAC,OAAO,CAAC;EAYrE"}
@@ -0,0 +1,70 @@
1
+ import { performance } from 'node:perf_hooks';
2
+ /** Private ownership of exposed credential/fetch/body promises, never a cancellation guarantee. */
3
+ export function createGoogleApiLifetime() {
4
+ const pending = new Set();
5
+ let closing = false;
6
+ return {
7
+ async invoke(invocation, unavailable, work) {
8
+ if (!invocation?.signal || !Number.isFinite(invocation.deadlineMs) || closing || invocation.signal.aborted || pending.size >= 2)
9
+ return unavailable;
10
+ const end = performance.now() + Math.min(3000, invocation.deadlineMs - Date.now());
11
+ if (end <= performance.now())
12
+ return unavailable;
13
+ const controller = new AbortController();
14
+ const check = () => { if (closing || controller.signal.aborted || invocation.signal.aborted || performance.now() >= end)
15
+ throw new Error('GOOGLE_OPERATION_UNAVAILABLE'); };
16
+ let timer, stop;
17
+ const actual = Promise.resolve().then(async () => { check(); return work(controller.signal, check); }).catch(() => { controller.abort(); return unavailable; });
18
+ pending.add(actual);
19
+ void actual.then(() => pending.delete(actual));
20
+ try {
21
+ const value = await Promise.race([actual, new Promise(resolve => {
22
+ timer = setTimeout(() => { controller.abort(); resolve(unavailable); }, Math.max(1, end - performance.now()));
23
+ stop = () => { controller.abort(); resolve(unavailable); };
24
+ invocation.signal.addEventListener('abort', stop, { once: true });
25
+ if (invocation.signal.aborted)
26
+ stop();
27
+ })]);
28
+ if (closing || invocation.signal.aborted || performance.now() >= end)
29
+ return unavailable;
30
+ return value;
31
+ }
32
+ finally {
33
+ if (timer)
34
+ clearTimeout(timer);
35
+ if (stop)
36
+ invocation.signal.removeEventListener('abort', stop);
37
+ }
38
+ },
39
+ async settle(invocation) {
40
+ closing = true;
41
+ if (!invocation?.signal || !Number.isFinite(invocation.deadlineMs))
42
+ return false;
43
+ const end = performance.now() + Math.max(0, invocation.deadlineMs - Date.now());
44
+ while (pending.size) {
45
+ if (invocation.signal.aborted || performance.now() >= end)
46
+ return false;
47
+ let timer, stop;
48
+ try {
49
+ const complete = await Promise.race([Promise.allSettled(pending).then(() => true), new Promise(resolve => {
50
+ timer = setTimeout(() => resolve(false), Math.max(1, end - performance.now()));
51
+ stop = () => resolve(false);
52
+ invocation.signal.addEventListener('abort', stop, { once: true });
53
+ if (invocation.signal.aborted)
54
+ stop();
55
+ })]);
56
+ if (!complete)
57
+ return false;
58
+ }
59
+ finally {
60
+ if (timer)
61
+ clearTimeout(timer);
62
+ if (stop)
63
+ invocation.signal.removeEventListener('abort', stop);
64
+ }
65
+ }
66
+ return true;
67
+ },
68
+ };
69
+ }
70
+ //# sourceMappingURL=events-google-sdk-lifetime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events-google-sdk-lifetime.js","sourceRoot":"","sources":["../src/events-google-sdk-lifetime.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M,CAAC,CAAC,CAAC,CAAC,CAAC;oBAAA,IAAG,CAAC,QAAQ;wBAAC,OAAO,KAAK,CAAC;gBAAA,CAAC;wBAAO,CAAC;oBAAA,IAAG,KAAK;wBAAC,YAAY,CAAC,KAAK,CAAC,CAAC;oBAAA,IAAG,IAAI;wBAAC,UAAU,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAC,IAAI,CAAC,CAAC;gBAAA,CAAC;YACnI,CAAC;YACD,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { type OwnedEventPool } from './events-postgres-owned.js';
2
+ import type { ExternalMcpEventInvocation } from './events-external.js';
3
+ export declare class PostgresEventDeliveryMigrationError extends Error {
4
+ readonly code: 'INCOMPATIBLE_SCHEMA' | 'UNAVAILABLE' | 'OUTCOME_UNKNOWN';
5
+ readonly phase: 'capture' | 'lifecycle' | 'delivery';
6
+ readonly captureCommitted: boolean;
7
+ readonly lifecycleCommitted: boolean;
8
+ constructor(code: 'INCOMPATIBLE_SCHEMA' | 'UNAVAILABLE' | 'OUTCOME_UNKNOWN', phase?: 'capture' | 'lifecycle' | 'delivery', captureCommitted?: boolean, lifecycleCommitted?: boolean);
9
+ }
10
+ /** Runs the capture and lifecycle migrations before the delivery migration. If a
11
+ * later migration fails, earlier prerequisite schemas can remain installed.
12
+ * Serving constructors never call this function.
13
+ */
14
+ export declare function createPostgresEventDeliveryMigrator(pool: OwnedEventPool): Readonly<{
15
+ migrate(invocation: ExternalMcpEventInvocation): Promise<void>;
16
+ settle(invocation: ExternalMcpEventInvocation): Promise<boolean>;
17
+ }>;
18
+ //# sourceMappingURL=events-postgres-delivery-migrations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events-postgres-delivery-migrations.d.ts","sourceRoot":"","sources":["../src/events-postgres-delivery-migrations.ts"],"names":[],"mappings":"AAIA,OAAO,EAA8B,KAAK,cAAc,EAAiB,MAAM,4BAA4B,CAAC;AAC5G,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AACvE,qBAAa,mCAAoC,SAAQ,KAAK;IAChD,QAAQ,CAAC,IAAI,EAAC,qBAAqB,GAAC,aAAa,GAAC,iBAAiB;IAC7E,QAAQ,CAAC,KAAK,EAAC,SAAS,GAAC,WAAW,GAAC,UAAU;IAC/C,QAAQ,CAAC,gBAAgB;IAAO,QAAQ,CAAC,kBAAkB;gBAFxC,IAAI,EAAC,qBAAqB,GAAC,aAAa,GAAC,iBAAiB,EACpE,KAAK,GAAC,SAAS,GAAC,WAAW,GAAC,UAAqB,EACjD,gBAAgB,UAAM,EAAU,kBAAkB,UAAM;CAGpE;AAiED;;;GAGG;AACH,wBAAgB,mCAAmC,CAAC,IAAI,EAAC,cAAc;wBAoClD,0BAA0B;uBACrB,0BAA0B;GAEnD"}
@@ -0,0 +1,146 @@
1
+ import { createPostgresEventLifecycleMigrator, PostgresEventLifecycleMigrationError, } from './events-postgres-lifecycle-migrations.js';
2
+ import { createOwnedEventOperations } from './events-postgres-owned.js';
3
+ export class PostgresEventDeliveryMigrationError extends Error {
4
+ code;
5
+ phase;
6
+ captureCommitted;
7
+ lifecycleCommitted;
8
+ constructor(code, phase = 'delivery', captureCommitted = false, lifecycleCommitted = false) {
9
+ super(code);
10
+ this.code = code;
11
+ this.phase = phase;
12
+ this.captureCommitted = captureCommitted;
13
+ this.lifecycleCommitted = lifecycleCommitted;
14
+ this.name = 'PostgresEventDeliveryMigrationError';
15
+ }
16
+ }
17
+ const incompatible = () => { throw new PostgresEventDeliveryMigrationError('INCOMPATIBLE_SCHEMA'); };
18
+ const tables = ['emseepea_event_delivery_migrations', 'emseepea_event_delivery_state', 'emseepea_event_delivery_attempts'];
19
+ const names = 'namespace,source_kind,source_id,subscription_id,generation';
20
+ const keyColumns = names.split(',').map(name => `${name} pg_catalog.text NOT NULL`).join(',');
21
+ const keyTypes = names.split(',').map(name => `${name}:25:-1:true`);
22
+ const ddl = [
23
+ `CREATE TABLE public.emseepea_event_delivery_migrations(singleton pg_catalog.bool PRIMARY KEY DEFAULT true CHECK(singleton),version pg_catalog.int4 NOT NULL,revision pg_catalog.text NOT NULL)`,
24
+ `CREATE TABLE public.emseepea_event_delivery_state(${keyColumns},reservations pg_catalog.int4 NOT NULL DEFAULT 0 CHECK(reservations>=0 AND reservations<=4),
25
+ lease_id pg_catalog.text,lease_until pg_catalog.timestamptz,due_at pg_catalog.timestamptz NOT NULL DEFAULT pg_catalog.clock_timestamp(),terminal pg_catalog.text CHECK(terminal IN('accepted','suppressed','gone','too_large','exhausted')),
26
+ PRIMARY KEY(${names}),FOREIGN KEY(${names}) REFERENCES public.emseepea_event_intents(${names}) ON DELETE RESTRICT,CHECK((lease_id IS NULL)=(lease_until IS NULL)))`,
27
+ `CREATE TABLE public.emseepea_event_delivery_attempts(${keyColumns},attempt pg_catalog.int4 NOT NULL CHECK(attempt>=1 AND attempt<=4),reservation_id pg_catalog.text NOT NULL UNIQUE,
28
+ lease_id pg_catalog.text NOT NULL,reserved_at pg_catalog.timestamptz NOT NULL,outcome pg_catalog.text NOT NULL CHECK(outcome IN('reserved','accepted','failed','terminal')),
29
+ status pg_catalog.int4 CHECK(status>=100 AND status<=599),PRIMARY KEY(${names},attempt),FOREIGN KEY(${names}) REFERENCES public.emseepea_event_delivery_state(${names}) ON DELETE RESTRICT)`,
30
+ ];
31
+ const expected = {
32
+ emseepea_event_delivery_migrations: ['singleton:16:-1:true', 'version:23:-1:true', 'revision:25:-1:true'],
33
+ emseepea_event_delivery_state: [...keyTypes, 'reservations:23:-1:true', 'lease_id:25:-1:false', 'lease_until:1184:-1:false', 'due_at:1184:-1:true', 'terminal:25:-1:false'],
34
+ emseepea_event_delivery_attempts: [...keyTypes, 'attempt:23:-1:true', 'reservation_id:25:-1:true', 'lease_id:25:-1:true', 'reserved_at:1184:-1:true', 'outcome:25:-1:true', 'status:23:-1:false'],
35
+ };
36
+ const catalog = `SELECT c.relname,c.relkind,c.relrowsecurity,c.relforcerowsecurity,pg_catalog.pg_get_userbyid(c.relowner)=current_user AS owned,
37
+ pg_catalog.array_agg(a.attname::pg_catalog.text||':'||a.atttypid::pg_catalog.text||':'||a.atttypmod::pg_catalog.text||':'||a.attnotnull::pg_catalog.text ORDER BY a.attnum) AS columns,
38
+ pg_catalog.jsonb_object_agg(a.attname,pg_catalog.pg_get_expr(d.adbin,d.adrelid)) AS defaults
39
+ FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace JOIN pg_catalog.pg_attribute a ON a.attrelid=c.oid AND a.attnum>0 AND NOT a.attisdropped
40
+ LEFT JOIN pg_catalog.pg_attrdef d ON d.adrelid=c.oid AND d.adnum=a.attnum
41
+ WHERE n.nspname='public' AND c.relname=ANY($1::pg_catalog.text[])
42
+ GROUP BY c.oid,c.relname,c.relkind,c.relrowsecurity,c.relforcerowsecurity,c.relowner`;
43
+ const spaced = names.split(',').join(', ');
44
+ const expectedConstraints = [
45
+ [tables[0], 'p', 'PRIMARY KEY (singleton)'], [tables[0], 'c', 'CHECK (singleton)'],
46
+ [tables[1], 'p', `PRIMARY KEY (${spaced})`],
47
+ [tables[1], 'f', `FOREIGN KEY (${spaced}) REFERENCES emseepea_event_intents(${spaced}) ON DELETE RESTRICT`],
48
+ [tables[1], 'c', 'CHECK (((reservations >= 0) AND (reservations <= 4)))'],
49
+ [tables[1], 'c', "CHECK ((terminal = ANY (ARRAY['accepted'::text, 'suppressed'::text, 'gone'::text, 'too_large'::text, 'exhausted'::text])))"],
50
+ [tables[1], 'c', 'CHECK (((lease_id IS NULL) = (lease_until IS NULL)))'],
51
+ [tables[2], 'p', `PRIMARY KEY (${spaced}, attempt)`], [tables[2], 'u', 'UNIQUE (reservation_id)'],
52
+ [tables[2], 'f', `FOREIGN KEY (${spaced}) REFERENCES emseepea_event_delivery_state(${spaced}) ON DELETE RESTRICT`],
53
+ [tables[2], 'c', 'CHECK (((attempt >= 1) AND (attempt <= 4)))'],
54
+ [tables[2], 'c', "CHECK ((outcome = ANY (ARRAY['reserved'::text, 'accepted'::text, 'failed'::text, 'terminal'::text])))"],
55
+ [tables[2], 'c', 'CHECK (((status >= 100) AND (status <= 599)))'],
56
+ ];
57
+ async function verify(run) {
58
+ const rows = (await run(catalog, [tables])).rows;
59
+ if (rows.length !== 3)
60
+ incompatible();
61
+ for (const row of rows) {
62
+ if (typeof row.relname !== 'string' || row.relkind !== 'r' || row.owned !== true || row.relrowsecurity !== false || row.relforcerowsecurity !== false || JSON.stringify(row.columns) !== JSON.stringify(expected[row.relname]))
63
+ incompatible();
64
+ const defaults = row.defaults;
65
+ if (!defaults || typeof defaults !== 'object')
66
+ incompatible();
67
+ for (const column of expected[String(row.relname)] ?? []) {
68
+ const name = column.split(':')[0];
69
+ const wanted = row.relname === tables[0] && name === 'singleton' ? 'true' : row.relname === tables[1] && name === 'reservations' ? '0' : row.relname === tables[1] && name === 'due_at' ? 'clock_timestamp()' : null;
70
+ if (defaults[name] !== wanted)
71
+ incompatible();
72
+ }
73
+ }
74
+ const wanted = new Set(expectedConstraints.map(row => JSON.stringify(row)));
75
+ const constraints = (await run(`SELECT c.relname,t.contype,pg_catalog.pg_get_constraintdef(t.oid) AS definition,t.convalidated,t.condeferrable,t.condeferred,
76
+ CASE WHEN t.contype IN('p','u') THEN i.indisvalid AND i.indisready AND i.indisunique ELSE true END AS key_valid
77
+ FROM pg_catalog.pg_constraint t JOIN pg_catalog.pg_class c ON c.oid=t.conrelid JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace
78
+ LEFT JOIN pg_catalog.pg_index i ON i.indexrelid=t.conindid WHERE n.nspname='public' AND c.relname=ANY($1::pg_catalog.text[])`, [tables])).rows;
79
+ for (const row of constraints)
80
+ if (row.convalidated !== true || row.condeferrable !== false || row.condeferred !== false || row.key_valid !== true || !wanted.delete(JSON.stringify([row.relname, row.contype, row.definition])))
81
+ incompatible();
82
+ if (wanted.size)
83
+ incompatible();
84
+ const indexes = (await run(`SELECT i.indexrelid FROM pg_catalog.pg_index i JOIN pg_catalog.pg_class c ON c.oid=i.indrelid JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace WHERE n.nspname='public' AND c.relname=ANY($1::pg_catalog.text[])`, [tables])).rows;
85
+ if (indexes.length !== 4)
86
+ incompatible();
87
+ const triggers = (await run(`SELECT t.oid FROM pg_catalog.pg_trigger t JOIN pg_catalog.pg_class c ON c.oid=t.tgrelid JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace WHERE n.nspname='public' AND c.relname=ANY($1::pg_catalog.text[]) AND NOT t.tgisinternal`, [tables])).rows;
88
+ if (triggers.length)
89
+ incompatible();
90
+ const marker = (await run('SELECT singleton,version,revision FROM public.emseepea_event_delivery_migrations')).rows;
91
+ if (marker.length !== 1 || marker[0]?.singleton !== true || marker[0].version !== 1 || marker[0].revision !== 'delivery-v1')
92
+ incompatible();
93
+ }
94
+ /** Runs the capture and lifecycle migrations before the delivery migration. If a
95
+ * later migration fails, earlier prerequisite schemas can remain installed.
96
+ * Serving constructors never call this function.
97
+ */
98
+ export function createPostgresEventDeliveryMigrator(pool) {
99
+ let prerequisite;
100
+ try {
101
+ prerequisite = createPostgresEventLifecycleMigrator(pool);
102
+ }
103
+ catch (error) {
104
+ if (error instanceof PostgresEventLifecycleMigrationError) {
105
+ throw new PostgresEventDeliveryMigrationError(error.code, error.phase, error.captureCommitted, false);
106
+ }
107
+ throw new PostgresEventDeliveryMigrationError('UNAVAILABLE');
108
+ }
109
+ const owned = createOwnedEventOperations();
110
+ let closing = false;
111
+ async function migrate(invocation) {
112
+ if (closing)
113
+ throw new PostgresEventDeliveryMigrationError('UNAVAILABLE');
114
+ let captureCommitted = false, lifecycleCommitted = false;
115
+ try {
116
+ await prerequisite.migrate(invocation);
117
+ captureCommitted = true;
118
+ lifecycleCommitted = true;
119
+ await owned.run(pool, invocation, async (run) => {
120
+ await run('SELECT pg_catalog.pg_advisory_xact_lock(1740126,2)');
121
+ const found = (await run(catalog, [tables])).rows;
122
+ if (found.length === 0) {
123
+ for (const statement of ddl)
124
+ await run(statement);
125
+ await run("INSERT INTO public.emseepea_event_delivery_migrations VALUES(true,1,'delivery-v1')");
126
+ }
127
+ await verify(run);
128
+ }, false, error => error instanceof PostgresEventDeliveryMigrationError);
129
+ }
130
+ catch (error) {
131
+ if (error instanceof PostgresEventDeliveryMigrationError) {
132
+ throw new PostgresEventDeliveryMigrationError(error.code, 'delivery', captureCommitted, lifecycleCommitted);
133
+ }
134
+ if (error instanceof PostgresEventLifecycleMigrationError) {
135
+ throw new PostgresEventDeliveryMigrationError(error.code, error.phase, error.captureCommitted, false);
136
+ }
137
+ const code = error && typeof error === 'object' && 'code' in error ? error.code : undefined;
138
+ throw new PostgresEventDeliveryMigrationError(code === 'INCOMPATIBLE_SCHEMA' ? 'INCOMPATIBLE_SCHEMA' : code === 'OUTCOME_UNKNOWN' ? 'OUTCOME_UNKNOWN' : 'UNAVAILABLE', 'delivery', captureCommitted, lifecycleCommitted);
139
+ }
140
+ }
141
+ return Object.freeze({
142
+ migrate(invocation) { return owned.track(migrate(invocation)); },
143
+ async settle(invocation) { closing = true; const results = await Promise.allSettled([prerequisite.settle(invocation), owned.settle(invocation)]); return results.every(result => result.status === 'fulfilled' && result.value === true); },
144
+ });
145
+ }
146
+ //# sourceMappingURL=events-postgres-delivery-migrations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events-postgres-delivery-migrations.js","sourceRoot":"","sources":["../src/events-postgres-delivery-migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,oCAAoC,EACpC,oCAAoC,GACpC,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,0BAA0B,EAAsC,MAAM,4BAA4B,CAAC;AAE5G,MAAM,OAAO,mCAAoC,SAAQ,KAAK;IACvC;IACV;IACA;IAAgC;IAF3C,YAAqB,IAA0D,EACpE,QAAuC,UAAU,EACjD,mBAAiB,KAAK,EAAU,qBAAmB,KAAK;QACjE,K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AAC;IACF,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC;QACpB,OAAO,CAAC,UAAqC,IAAE,OAAO,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA,CAAC;QACxF,KAAK,CAAC,MAAM,CAAC,UAAqC,IAAE,OAAO,GAAC,IAAI,CAAC,CAAA,MAAM,OAAO,GAAC,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,EAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA,OAAO,OAAO,CAAC,KAAK,CAAC,MAAM,CAAA,EAAE,CAAA,MAAM,CAAC,MAAM,KAAG,WAAW,IAAE,MAAM,CAAC,KAAK,KAAG,IAAI,CAAC,CAAC,CAAA,CAAC;KACpP,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { type ExternalMcpEventInvocation } from './events-external.js';
2
+ import type { OwnedEventPool, EventSql } from './events-postgres-owned.js';
3
+ export interface DeliverySession {
4
+ readonly remaining: () => number;
5
+ check(): void;
6
+ transaction<T>(work: (sql: EventSql) => Promise<T>): Promise<T>;
7
+ wait<T>(work: () => T | Promise<T>, maximumMs: number): Promise<T>;
8
+ }
9
+ /** One owned connection, multiple short transactions; no caller-owned client is accepted. */
10
+ export declare function createDeliverySessionOwner(pool: OwnedEventPool): {
11
+ track: <T>(promise: Promise<T>) => Promise<T>;
12
+ run<T>(invocation: ExternalMcpEventInvocation, work: (session: DeliverySession) => Promise<T>): Promise<T>;
13
+ quiesce(): Promise<boolean>;
14
+ settle(invocation: ExternalMcpEventInvocation): Promise<boolean>;
15
+ };
16
+ //# sourceMappingURL=events-postgres-delivery-owned.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events-postgres-delivery-owned.d.ts","sourceRoot":"","sources":["../src/events-postgres-delivery-owned.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,KAAK,EAAoB,cAAc,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC7F,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,SAAS,EAAC,MAAI,MAAM,CAAC;IAC9B,KAAK,IAAG,IAAI,CAAC;IACb,WAAW,CAAC,CAAC,EAAE,IAAI,EAAC,CAAC,GAAG,EAAC,QAAQ,KAAG,OAAO,CAAC,CAAC,CAAC,GAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3D,IAAI,CAAC,CAAC,EAAE,IAAI,EAAC,MAAI,CAAC,GAAC,OAAO,CAAC,CAAC,CAAC,EAAC,SAAS,EAAC,MAAM,GAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CAC5D;AACD,6FAA6F;AAC7F,wBAAgB,0BAA0B,CAAC,IAAI,EAAC,cAAc;YAG7C,CAAC,WAAU,OAAO,CAAC,CAAC,CAAC,KAAE,OAAO,CAAC,CAAC,CAAC;QAsE1C,CAAC,cAAa,0BAA0B,QAAM,CAAC,OAAO,EAAC,eAAe,KAAG,OAAO,CAAC,CAAC,CAAC;eAGvE,OAAO,CAAC,OAAO,CAAC;uBAIR,0BAA0B,GAAE,OAAO,CAAC,OAAO,CAAC;EASvE"}