stitchkit 0.59.4 → 0.60.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/README.md +7 -3
- package/dist/agent-runtime/admission-lanes.d.ts +35 -0
- package/dist/agent-runtime/admission-lanes.d.ts.map +1 -0
- package/dist/agent-runtime/coordinator.d.ts +36 -2
- package/dist/agent-runtime/coordinator.d.ts.map +1 -1
- package/dist/agent-runtime/events.d.ts +7 -0
- package/dist/agent-runtime/events.d.ts.map +1 -1
- package/dist/agent-runtime/history.d.ts +7 -0
- package/dist/agent-runtime/history.d.ts.map +1 -1
- package/dist/agent-runtime/models.d.ts +2 -3
- package/dist/agent-runtime/models.d.ts.map +1 -1
- package/dist/agent-runtime/observability.d.ts.map +1 -1
- package/dist/agent-runtime/run-execution.d.ts +31 -0
- package/dist/agent-runtime/run-execution.d.ts.map +1 -0
- package/dist/agent-runtime/runtime-internals.d.ts +25 -0
- package/dist/agent-runtime/runtime-internals.d.ts.map +1 -0
- package/dist/agent-runtime/runtime-result.d.ts +11 -0
- package/dist/agent-runtime/runtime-result.d.ts.map +1 -0
- package/dist/agent-runtime/runtime.d.ts +16 -15
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/schemas.d.ts.map +1 -1
- package/dist/agent-runtime/store-driver.d.ts.map +1 -1
- package/dist/agent-runtime/store.d.ts +9 -2
- package/dist/agent-runtime/store.d.ts.map +1 -1
- package/dist/agent-runtime/terminal-commit.d.ts.map +1 -1
- package/dist/agent-runtime/terminal-status.d.ts +13 -0
- package/dist/agent-runtime/terminal-status.d.ts.map +1 -0
- package/dist/agent-runtime.d.ts +5 -3
- package/dist/agent-runtime.d.ts.map +1 -1
- package/dist/agent-runtime.js +211 -156
- package/dist/application/activity.d.ts +7 -2
- package/dist/application/activity.d.ts.map +1 -1
- package/dist/application/grammy.d.ts +6 -0
- package/dist/application/grammy.d.ts.map +1 -1
- package/dist/application/health.d.ts +9 -2
- package/dist/application/health.d.ts.map +1 -1
- package/dist/application/kernel.d.ts +49 -3
- package/dist/application/kernel.d.ts.map +1 -1
- package/dist/application/schemas.d.ts +42 -0
- package/dist/application/schemas.d.ts.map +1 -1
- package/dist/application-opentelemetry.js +2 -2
- package/dist/application.d.ts +3 -3
- package/dist/application.d.ts.map +1 -1
- package/dist/application.js +16 -8
- package/dist/cli.js +6 -6
- package/dist/contract/errors.d.ts +6 -0
- package/dist/contract/errors.d.ts.map +1 -1
- package/dist/contract/index.js +1 -1
- package/dist/declaration.d.ts +345 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +183 -0
- package/dist/{index-5c8n2123.js → index-1zencgcb.js} +64 -30
- package/dist/{index-sa2mbwa7.js → index-2akar0rq.js} +2 -2
- package/dist/{index-41wm56v0.js → index-3hn10n4c.js} +1 -1
- package/dist/{index-f6pymtqe.js → index-3w74r08v.js} +2 -2
- package/dist/{index-7c0gkyvj.js → index-6fbp58g8.js} +2 -2
- package/dist/{index-gnvzyw0k.js → index-8es1hrv4.js} +2 -2
- package/dist/{index-mgf6cdkm.js → index-8eywc9zv.js} +35 -1
- package/dist/{index-3nwng7hs.js → index-8pc5s3pz.js} +4 -4
- package/dist/{index-28cqssm3.js → index-9h1vba8n.js} +6 -0
- package/dist/{index-0nc0cddp.js → index-a59da114.js} +17 -28
- package/dist/{index-s8w2y7kr.js → index-f7521k0x.js} +22 -16
- package/dist/{index-y2rb7dwx.js → index-pzyt11ch.js} +5 -1
- package/dist/{index-mr617n62.js → index-svqhcrrj.js} +1 -1
- package/dist/{index-ps5pxp3h.js → index-v6e8hnkx.js} +7 -1
- package/dist/{index-1tkyng3g.js → index-vkk06pv1.js} +1 -9
- package/dist/{index-2nzpcfbp.js → index-x8v8b7rc.js} +2 -2
- package/dist/index.js +1 -1
- package/dist/internal/observability-sink.d.ts.map +1 -1
- package/dist/internal/route-pattern.d.ts +9 -0
- package/dist/internal/route-pattern.d.ts.map +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +5 -5
- package/dist/observability/index.js +5 -5
- package/dist/observability/sanitize.d.ts +3 -1
- package/dist/observability/sanitize.d.ts.map +1 -1
- package/dist/remote.js +3 -3
- package/dist/server/error-hook.d.ts +10 -3
- package/dist/server/error-hook.d.ts.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +9 -12
- package/dist/server/middleware/cors.d.ts +5 -2
- package/dist/server/middleware/cors.d.ts.map +1 -1
- package/dist/server/openapi.d.ts.map +1 -1
- package/dist/server/router.d.ts.map +1 -1
- package/dist/server/socket-io-config.d.ts +68 -3
- package/dist/server/socket-io-config.d.ts.map +1 -1
- package/dist/server/socket-io-node.d.ts +1 -1
- package/dist/server/socket-io-node.d.ts.map +1 -1
- package/dist/server/socket-io.d.ts +1 -1
- package/dist/server/socket-io.d.ts.map +1 -1
- package/dist/testing/surface-manifest.d.ts.map +1 -1
- package/dist/testing.js +8 -10
- package/dist/tools/flatten-join.d.ts +2 -0
- package/dist/tools/flatten-join.d.ts.map +1 -1
- package/dist/tools/flatten.d.ts.map +1 -1
- package/dist/tools/mcp-prepare.d.ts +0 -2
- package/dist/tools/mcp-prepare.d.ts.map +1 -1
- package/dist/tools/runtime-tool.d.ts +0 -3
- package/dist/tools/runtime-tool.d.ts.map +1 -1
- package/dist/tools/schema.d.ts +0 -4
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools.js +9 -9
- package/llms-full.txt +924 -68
- package/llms.txt +1 -0
- package/package.json +6 -2
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
ApplicationIdSchema,
|
|
3
3
|
ApplicationShutdownResultSchema,
|
|
4
4
|
ApplicationSnapshotSchema
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-8eywc9zv.js";
|
|
6
6
|
import {
|
|
7
7
|
ShutdownOptionsSchema
|
|
8
8
|
} from "./index-dk6e56g0.js";
|
|
@@ -61,6 +61,18 @@ class ResourceCompletionBeforeReadyError extends Error {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
class ApplicationStartupInterruptedError extends Error {
|
|
65
|
+
constructor() {
|
|
66
|
+
super("[stitchkit] application startup interrupted by shutdown");
|
|
67
|
+
this.name = "ApplicationStartupInterruptedError";
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
var ApplicationShutdownOptionsSchema = ShutdownOptionsSchema.pick({
|
|
71
|
+
gracePeriodMs: true,
|
|
72
|
+
forceTimeoutMs: true,
|
|
73
|
+
signal: true
|
|
74
|
+
});
|
|
75
|
+
|
|
64
76
|
class ApplicationAdmissionError extends Error {
|
|
65
77
|
code = "APPLICATION_NOT_ACCEPTING";
|
|
66
78
|
constructor() {
|
|
@@ -87,6 +99,15 @@ function createApplication(config) {
|
|
|
87
99
|
const id = ApplicationIdSchema.parse(config.id);
|
|
88
100
|
const ordered = resolveResourceGraph(config.resources ?? []);
|
|
89
101
|
const reverse = [...ordered].reverse();
|
|
102
|
+
const reportFailure = (resourceId, phase, error) => {
|
|
103
|
+
if (!config.onResourceFailure)
|
|
104
|
+
return;
|
|
105
|
+
try {
|
|
106
|
+
Promise.resolve(config.onResourceFailure({ resourceId, phase, error })).catch(() => {
|
|
107
|
+
return;
|
|
108
|
+
});
|
|
109
|
+
} catch {}
|
|
110
|
+
};
|
|
90
111
|
const records = new Map;
|
|
91
112
|
for (const entry of ordered) {
|
|
92
113
|
records.set(entry.id, {
|
|
@@ -187,8 +208,10 @@ function createApplication(config) {
|
|
|
187
208
|
const markLateCompletion = (record, failure) => {
|
|
188
209
|
if (shutdownRequested || record.state === "stopping" || record.state === "stopped")
|
|
189
210
|
return;
|
|
190
|
-
if (failure)
|
|
211
|
+
if (failure) {
|
|
191
212
|
record.failures.push("completion");
|
|
213
|
+
reportFailure(record.entry.id, "completion", failure.error);
|
|
214
|
+
}
|
|
192
215
|
record.state = "failed";
|
|
193
216
|
record.health = "unhealthy";
|
|
194
217
|
accepting = activationComplete && isReady();
|
|
@@ -209,6 +232,7 @@ function createApplication(config) {
|
|
|
209
232
|
} catch (error) {
|
|
210
233
|
record.failures.push("close");
|
|
211
234
|
record.state = "failed";
|
|
235
|
+
reportFailure(entry.id, "close", error);
|
|
212
236
|
errors.push(error);
|
|
213
237
|
}
|
|
214
238
|
publish();
|
|
@@ -222,7 +246,7 @@ function createApplication(config) {
|
|
|
222
246
|
try {
|
|
223
247
|
for (const entry of ordered) {
|
|
224
248
|
if (shutdownRequested || startupAbort.signal.aborted) {
|
|
225
|
-
throw new
|
|
249
|
+
throw new ApplicationStartupInterruptedError;
|
|
226
250
|
}
|
|
227
251
|
const record = records.get(entry.id);
|
|
228
252
|
if (!record)
|
|
@@ -244,7 +268,7 @@ function createApplication(config) {
|
|
|
244
268
|
try {
|
|
245
269
|
const started = await entry.resource.start(contextFor(record, { signal: startupAbort.signal }));
|
|
246
270
|
if (shutdownRequested || startupAbort.signal.aborted) {
|
|
247
|
-
throw new
|
|
271
|
+
throw new ApplicationStartupInterruptedError;
|
|
248
272
|
}
|
|
249
273
|
if (isStartResult(started)) {
|
|
250
274
|
record.runtime = started;
|
|
@@ -254,12 +278,12 @@ function createApplication(config) {
|
|
|
254
278
|
const completion = started.completion?.then(() => {
|
|
255
279
|
completionSettled = true;
|
|
256
280
|
if (resourceReady)
|
|
257
|
-
markLateCompletion(record
|
|
281
|
+
markLateCompletion(record);
|
|
258
282
|
}, (error) => {
|
|
259
283
|
completionSettled = true;
|
|
260
284
|
completionFailure = error;
|
|
261
285
|
if (resourceReady)
|
|
262
|
-
markLateCompletion(record,
|
|
286
|
+
markLateCompletion(record, { error });
|
|
263
287
|
});
|
|
264
288
|
if (started.ready && completion) {
|
|
265
289
|
const readiness = started.ready.then(() => "ready");
|
|
@@ -278,19 +302,21 @@ function createApplication(config) {
|
|
|
278
302
|
} else if (completion) {}
|
|
279
303
|
}
|
|
280
304
|
if (shutdownRequested || startupAbort.signal.aborted) {
|
|
281
|
-
throw new
|
|
305
|
+
throw new ApplicationStartupInterruptedError;
|
|
282
306
|
}
|
|
283
307
|
record.state = "ready";
|
|
284
308
|
record.health = "healthy";
|
|
285
309
|
publish();
|
|
286
310
|
} catch (error) {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
311
|
+
const interrupted = shutdownRequested || startupAbort.signal.aborted;
|
|
312
|
+
if (!(error instanceof ApplicationStartupInterruptedError)) {
|
|
313
|
+
record.failures.push(error instanceof ResourceCompletionBeforeReadyError ? "completion" : record.runtime?.ready ? "ready" : "start");
|
|
314
|
+
record.state = "failed";
|
|
315
|
+
record.health = "unhealthy";
|
|
316
|
+
reportFailure(entry.id, record.failures[record.failures.length - 1] ?? "start", error);
|
|
317
|
+
publish();
|
|
318
|
+
}
|
|
319
|
+
if (interrupted || entry.required)
|
|
294
320
|
throw error;
|
|
295
321
|
}
|
|
296
322
|
}
|
|
@@ -298,7 +324,7 @@ function createApplication(config) {
|
|
|
298
324
|
publish();
|
|
299
325
|
for (const entry of ordered) {
|
|
300
326
|
if (shutdownRequested || startupAbort.signal.aborted) {
|
|
301
|
-
throw new
|
|
327
|
+
throw new ApplicationStartupInterruptedError;
|
|
302
328
|
}
|
|
303
329
|
const record = records.get(entry.id);
|
|
304
330
|
if (record?.state !== "ready")
|
|
@@ -320,25 +346,27 @@ function createApplication(config) {
|
|
|
320
346
|
try {
|
|
321
347
|
await entry.resource.activate?.(contextFor(record));
|
|
322
348
|
if (shutdownRequested || startupAbort.signal.aborted) {
|
|
323
|
-
throw new
|
|
349
|
+
throw new ApplicationStartupInterruptedError;
|
|
324
350
|
}
|
|
325
351
|
record.activated = true;
|
|
326
352
|
if (entry.required && (record.state !== "ready" || record.health !== "healthy")) {
|
|
327
353
|
throw new Error(`[stitchkit] required resource "${entry.id}" lost readiness during activation`);
|
|
328
354
|
}
|
|
329
355
|
} catch (error) {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
356
|
+
const interrupted = shutdownRequested || startupAbort.signal.aborted;
|
|
357
|
+
if (!(error instanceof ApplicationStartupInterruptedError)) {
|
|
358
|
+
record.failures.push("start");
|
|
359
|
+
record.state = "failed";
|
|
360
|
+
record.health = "unhealthy";
|
|
361
|
+
reportFailure(entry.id, "start", error);
|
|
362
|
+
publish();
|
|
363
|
+
}
|
|
364
|
+
if (interrupted || entry.required)
|
|
337
365
|
throw error;
|
|
338
366
|
}
|
|
339
367
|
}
|
|
340
368
|
if (shutdownRequested) {
|
|
341
|
-
throw new
|
|
369
|
+
throw new ApplicationStartupInterruptedError;
|
|
342
370
|
}
|
|
343
371
|
if (!isReady()) {
|
|
344
372
|
throw new Error("[stitchkit] a required resource lost readiness during startup");
|
|
@@ -417,7 +445,7 @@ function createApplication(config) {
|
|
|
417
445
|
const shutdown = (options) => {
|
|
418
446
|
if (shutdownPromise)
|
|
419
447
|
return shutdownPromise;
|
|
420
|
-
const parsed =
|
|
448
|
+
const parsed = ApplicationShutdownOptionsSchema.parse(options ?? {});
|
|
421
449
|
const startedAt = performance.now();
|
|
422
450
|
const graceDeadlineAt = startedAt + parsed.gracePeriodMs;
|
|
423
451
|
const forceDeadlineAt = graceDeadlineAt + parsed.forceTimeoutMs;
|
|
@@ -464,8 +492,9 @@ function createApplication(config) {
|
|
|
464
492
|
break;
|
|
465
493
|
if (result.error !== undefined)
|
|
466
494
|
throw result.error;
|
|
467
|
-
} catch {
|
|
495
|
+
} catch (error) {
|
|
468
496
|
record.failures.push("admission");
|
|
497
|
+
reportFailure(entry.id, "admission", error);
|
|
469
498
|
gracefulFailed = true;
|
|
470
499
|
lifetimeAbort.abort();
|
|
471
500
|
}
|
|
@@ -491,8 +520,9 @@ function createApplication(config) {
|
|
|
491
520
|
}
|
|
492
521
|
if (drained.error !== undefined)
|
|
493
522
|
throw drained.error;
|
|
494
|
-
} catch {
|
|
523
|
+
} catch (error) {
|
|
495
524
|
record.failures.push("drain");
|
|
525
|
+
reportFailure(entry.id, "drain", error);
|
|
496
526
|
gracefulFailed = true;
|
|
497
527
|
lifetimeAbort.abort();
|
|
498
528
|
break;
|
|
@@ -518,8 +548,9 @@ function createApplication(config) {
|
|
|
518
548
|
record.closed = true;
|
|
519
549
|
record.state = "stopped";
|
|
520
550
|
publish();
|
|
521
|
-
} catch {
|
|
551
|
+
} catch (error) {
|
|
522
552
|
record.failures.push("close");
|
|
553
|
+
reportFailure(entry.id, "close", error);
|
|
523
554
|
record.state = "failed";
|
|
524
555
|
gracefulFailed = true;
|
|
525
556
|
lifetimeAbort.abort();
|
|
@@ -556,17 +587,20 @@ function createApplication(config) {
|
|
|
556
587
|
})));
|
|
557
588
|
} else if (entry.resource.close) {
|
|
558
589
|
record.failures.push("force");
|
|
590
|
+
reportFailure(entry.id, "force", new Error(`[stitchkit] resource "${entry.id}" was already closing and did not settle before the force deadline`));
|
|
559
591
|
return;
|
|
560
592
|
}
|
|
561
593
|
const forced = await untilDeadline(cleanup ?? Promise.resolve(), forceAbort.signal);
|
|
562
594
|
if (!forced.settled || forced.error !== undefined) {
|
|
563
595
|
record.failures.push("force");
|
|
596
|
+
reportFailure(entry.id, "force", forced.settled ? forced.error : new Error("[stitchkit] forced cleanup did not settle in time"));
|
|
564
597
|
return;
|
|
565
598
|
}
|
|
566
599
|
record.closed = true;
|
|
567
600
|
record.state = "stopped";
|
|
568
|
-
} catch {
|
|
601
|
+
} catch (error) {
|
|
569
602
|
record.failures.push("force");
|
|
603
|
+
reportFailure(entry.id, "force", error);
|
|
570
604
|
}
|
|
571
605
|
}));
|
|
572
606
|
clearTimeout(forceTimer);
|
|
@@ -614,4 +648,4 @@ function createApplication(config) {
|
|
|
614
648
|
};
|
|
615
649
|
}
|
|
616
650
|
|
|
617
|
-
export { ApplicationAdmissionError, createApplication };
|
|
651
|
+
export { ApplicationShutdownOptionsSchema, ApplicationAdmissionError, createApplication };
|
|
@@ -7,14 +7,14 @@ import {
|
|
|
7
7
|
normalizeError,
|
|
8
8
|
runWithRequestContext,
|
|
9
9
|
validateDeclaredOutput
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-6fbp58g8.js";
|
|
11
11
|
import {
|
|
12
12
|
AppError,
|
|
13
13
|
STITCH_ERROR_STATUS,
|
|
14
14
|
isStitchErrorCode,
|
|
15
15
|
isUnsafeKey,
|
|
16
16
|
safeJsonParse
|
|
17
|
-
} from "./index-
|
|
17
|
+
} from "./index-v6e8hnkx.js";
|
|
18
18
|
import {
|
|
19
19
|
isRecord
|
|
20
20
|
} from "./index-smpbdg6k.js";
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
contextContributionDelta,
|
|
3
3
|
mergeContextContribution,
|
|
4
4
|
prepareContextContribution
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-3hn10n4c.js";
|
|
6
6
|
import {
|
|
7
7
|
base64UrlToBytes,
|
|
8
8
|
bytesToBase64Url,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
isUnsafeKey,
|
|
11
11
|
safeJsonParse,
|
|
12
12
|
unauthorized
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-v6e8hnkx.js";
|
|
14
14
|
import {
|
|
15
15
|
isRecord
|
|
16
16
|
} from "./index-smpbdg6k.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isUnsafeKey
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-v6e8hnkx.js";
|
|
4
4
|
import {
|
|
5
5
|
isRecord
|
|
6
6
|
} from "./index-smpbdg6k.js";
|
|
@@ -83,7 +83,7 @@ function redact(value, options = {}) {
|
|
|
83
83
|
ancestors.add(input);
|
|
84
84
|
const result = [...input.entries()].map(([key, value2]) => [
|
|
85
85
|
walk(key, depth + 1),
|
|
86
|
-
walk(value2, depth + 1)
|
|
86
|
+
typeof key === "string" && isSensitive(key) ? MASK : walk(value2, depth + 1)
|
|
87
87
|
]);
|
|
88
88
|
ancestors.delete(input);
|
|
89
89
|
return { _type: "map", entries: result };
|
|
@@ -46,6 +46,40 @@ var ApplicationSnapshotSchema = z.object({
|
|
|
46
46
|
admission: ApplicationAdmissionSnapshotSchema,
|
|
47
47
|
resources: z.array(ManagedResourceSnapshotSchema).readonly()
|
|
48
48
|
}).readonly();
|
|
49
|
+
var ApplicationStatusProjectionSchema = z.object({
|
|
50
|
+
id: ApplicationIdSchema,
|
|
51
|
+
lifecycle: ApplicationLifecycleSchema,
|
|
52
|
+
health: ApplicationHealthSchema,
|
|
53
|
+
ready: z.boolean(),
|
|
54
|
+
capturedAt: z.string().datetime({ offset: true }),
|
|
55
|
+
resources: z.object({
|
|
56
|
+
total: NonNegativeIntegerSchema,
|
|
57
|
+
ready: NonNegativeIntegerSchema,
|
|
58
|
+
degraded: NonNegativeIntegerSchema,
|
|
59
|
+
failed: NonNegativeIntegerSchema
|
|
60
|
+
}).readonly()
|
|
61
|
+
}).readonly();
|
|
62
|
+
function projectApplicationStatus(snapshot) {
|
|
63
|
+
let ready = 0;
|
|
64
|
+
let degraded = 0;
|
|
65
|
+
let failed = 0;
|
|
66
|
+
for (const resource of snapshot.resources) {
|
|
67
|
+
if (resource.ready)
|
|
68
|
+
ready += 1;
|
|
69
|
+
if (resource.health === "degraded")
|
|
70
|
+
degraded += 1;
|
|
71
|
+
if (resource.state === "failed")
|
|
72
|
+
failed += 1;
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
id: snapshot.id,
|
|
76
|
+
lifecycle: snapshot.lifecycle,
|
|
77
|
+
health: snapshot.health,
|
|
78
|
+
ready: snapshot.ready,
|
|
79
|
+
capturedAt: snapshot.capturedAt,
|
|
80
|
+
resources: { total: snapshot.resources.length, ready, degraded, failed }
|
|
81
|
+
};
|
|
82
|
+
}
|
|
49
83
|
var ApplicationResourceShutdownSchema = z.object({
|
|
50
84
|
id: ApplicationIdSchema,
|
|
51
85
|
state: z.enum(["not-started", "closed", "force-failed"]),
|
|
@@ -63,4 +97,4 @@ var ApplicationShutdownResultSchema = z.object({
|
|
|
63
97
|
durationMs: z.number().nonnegative()
|
|
64
98
|
}).readonly();
|
|
65
99
|
|
|
66
|
-
export { ApplicationIdSchema, ApplicationLifecycleSchema, ApplicationHealthSchema, ManagedResourceStateSchema, ApplicationAdmissionSnapshotSchema, ManagedResourceSnapshotSchema, ApplicationSnapshotSchema, ApplicationResourceShutdownSchema, ApplicationShutdownResultSchema };
|
|
100
|
+
export { ApplicationIdSchema, ApplicationLifecycleSchema, ApplicationHealthSchema, ManagedResourceStateSchema, ApplicationAdmissionSnapshotSchema, ManagedResourceSnapshotSchema, ApplicationSnapshotSchema, ApplicationStatusProjectionSchema, projectApplicationStatus, ApplicationResourceShutdownSchema, ApplicationShutdownResultSchema };
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
coerceJsonArgs,
|
|
3
3
|
executeToolMethod,
|
|
4
4
|
toolResultFromError
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-2akar0rq.js";
|
|
6
6
|
import {
|
|
7
7
|
isWithinDir
|
|
8
8
|
} from "./index-sbdmyz75.js";
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
buildToolPresentationSchema,
|
|
13
13
|
projectRuntimeTool,
|
|
14
14
|
projectToolSurface
|
|
15
|
-
} from "./index-
|
|
15
|
+
} from "./index-vkk06pv1.js";
|
|
16
16
|
import {
|
|
17
17
|
mergeSchemas,
|
|
18
18
|
objectShapeKeys,
|
|
@@ -24,11 +24,11 @@ import {
|
|
|
24
24
|
import {
|
|
25
25
|
formatZodError,
|
|
26
26
|
validateDeclaredOutput
|
|
27
|
-
} from "./index-
|
|
27
|
+
} from "./index-6fbp58g8.js";
|
|
28
28
|
import {
|
|
29
29
|
isUnsafeKey,
|
|
30
30
|
safeJsonParse
|
|
31
|
-
} from "./index-
|
|
31
|
+
} from "./index-v6e8hnkx.js";
|
|
32
32
|
import {
|
|
33
33
|
isRecord
|
|
34
34
|
} from "./index-smpbdg6k.js";
|
|
@@ -284,6 +284,12 @@ var STITCH_ERROR_STATUS = {
|
|
|
284
284
|
FILE_TOO_LARGE: 413,
|
|
285
285
|
FILE_EXISTS: 409,
|
|
286
286
|
REALTIME_CONTRACT_VIOLATION: 500,
|
|
287
|
+
APPLICATION_NOT_ACCEPTING: 503,
|
|
288
|
+
WAIT_TIMEOUT: 408,
|
|
289
|
+
WAIT_FAILED: 409,
|
|
290
|
+
DOWNLOAD_NOT_FOUND: 404,
|
|
291
|
+
VIEW_HTTP_ERROR: 502,
|
|
292
|
+
OPERATION_NOT_SUCCEEDED: 409,
|
|
287
293
|
INTERNAL_SERVER_ERROR: 500
|
|
288
294
|
};
|
|
289
295
|
function isStitchErrorCode(code) {
|
|
@@ -138,41 +138,30 @@ function createBoundedSinkManager(config) {
|
|
|
138
138
|
flush() {
|
|
139
139
|
return awaitGeneration(sequence);
|
|
140
140
|
},
|
|
141
|
-
getStatus
|
|
142
|
-
return ObservabilitySinkStatusSchema.parse({
|
|
143
|
-
capacity: maxPending,
|
|
144
|
-
received,
|
|
145
|
-
accepted,
|
|
146
|
-
filtered,
|
|
147
|
-
completed,
|
|
148
|
-
dropped,
|
|
149
|
-
failed,
|
|
150
|
-
preparationFailed,
|
|
151
|
-
preparing: preparing.size,
|
|
152
|
-
pending: writes.size,
|
|
153
|
-
closed
|
|
154
|
-
});
|
|
155
|
-
},
|
|
141
|
+
getStatus,
|
|
156
142
|
close() {
|
|
157
143
|
if (closePromise)
|
|
158
144
|
return closePromise;
|
|
159
145
|
closed = true;
|
|
160
|
-
closePromise = awaitGeneration(sequence).then(
|
|
161
|
-
capacity: maxPending,
|
|
162
|
-
received,
|
|
163
|
-
accepted,
|
|
164
|
-
filtered,
|
|
165
|
-
completed,
|
|
166
|
-
dropped,
|
|
167
|
-
failed,
|
|
168
|
-
preparationFailed,
|
|
169
|
-
preparing: preparing.size,
|
|
170
|
-
pending: writes.size,
|
|
171
|
-
closed
|
|
172
|
-
}));
|
|
146
|
+
closePromise = awaitGeneration(sequence).then(getStatus);
|
|
173
147
|
return closePromise;
|
|
174
148
|
}
|
|
175
149
|
};
|
|
150
|
+
function getStatus() {
|
|
151
|
+
return ObservabilitySinkStatusSchema.parse({
|
|
152
|
+
capacity: maxPending,
|
|
153
|
+
received,
|
|
154
|
+
accepted,
|
|
155
|
+
filtered,
|
|
156
|
+
completed,
|
|
157
|
+
dropped,
|
|
158
|
+
failed,
|
|
159
|
+
preparationFailed,
|
|
160
|
+
preparing: preparing.size,
|
|
161
|
+
pending: writes.size,
|
|
162
|
+
closed
|
|
163
|
+
});
|
|
164
|
+
}
|
|
176
165
|
}
|
|
177
166
|
|
|
178
167
|
export { ObservabilitySinkStatusSchema, ObservabilityStatusSchema, ObservabilityDrainReportSchema, aggregateObservabilityStatus, createBoundedSinkManager };
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
defaultSignalSource,
|
|
8
8
|
guardSignalCallback,
|
|
9
9
|
reportSignalError
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-3hn10n4c.js";
|
|
11
11
|
import {
|
|
12
12
|
ShutdownOptionsSchema
|
|
13
13
|
} from "./index-dk6e56g0.js";
|
|
@@ -26,17 +26,18 @@ import {
|
|
|
26
26
|
setRequestError,
|
|
27
27
|
validateDeclaredOutput,
|
|
28
28
|
zodIssues
|
|
29
|
-
} from "./index-
|
|
29
|
+
} from "./index-6fbp58g8.js";
|
|
30
30
|
import {
|
|
31
31
|
AppError,
|
|
32
32
|
badRequest,
|
|
33
33
|
isUnsafeKey,
|
|
34
34
|
safeJsonParse
|
|
35
|
-
} from "./index-
|
|
35
|
+
} from "./index-v6e8hnkx.js";
|
|
36
36
|
import {
|
|
37
|
+
joinRoutePath,
|
|
37
38
|
parseTrailingWildcard,
|
|
38
39
|
resolveTraceContext
|
|
39
|
-
} from "./index-
|
|
40
|
+
} from "./index-pzyt11ch.js";
|
|
40
41
|
import {
|
|
41
42
|
isRecord,
|
|
42
43
|
transportResult
|
|
@@ -827,10 +828,6 @@ function applyResponseMetadata(target, metadata, endpointIdentity) {
|
|
|
827
828
|
}
|
|
828
829
|
|
|
829
830
|
// src/server/router.ts
|
|
830
|
-
function joinPath(...parts) {
|
|
831
|
-
const joined = parts.filter(Boolean).map((part) => part.replace(/^\/+|\/+$/g, "")).filter(Boolean).join("/");
|
|
832
|
-
return `/${joined}`;
|
|
833
|
-
}
|
|
834
831
|
function routeSegments(path) {
|
|
835
832
|
return path.split("/").filter(Boolean);
|
|
836
833
|
}
|
|
@@ -914,8 +911,8 @@ function buildRouteMap(groups) {
|
|
|
914
911
|
for (const [, method] of Object.entries(service.methods)) {
|
|
915
912
|
if (method.expose && !method.expose.includes("HTTP"))
|
|
916
913
|
continue;
|
|
917
|
-
const servicePath =
|
|
918
|
-
const fullPath = prefix ?
|
|
914
|
+
const servicePath = joinRoutePath("/", service.prefix, method.path === "/" ? "" : method.path);
|
|
915
|
+
const fullPath = prefix ? joinRoutePath(prefix, servicePath) : servicePath;
|
|
919
916
|
const segments = routeSegments(fullPath);
|
|
920
917
|
const entries = map.get(method.method) ?? [];
|
|
921
918
|
entries.push({ method, pattern: fullPath, segments, groupHooks: hooks });
|
|
@@ -1853,16 +1850,19 @@ function isModuleNotFound(err) {
|
|
|
1853
1850
|
const message = "message" in err && typeof err.message === "string" ? err.message : "";
|
|
1854
1851
|
return code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND" || message.includes("Cannot find module") || message.includes("Cannot find package");
|
|
1855
1852
|
}
|
|
1856
|
-
async function importPeer(load, pkg) {
|
|
1853
|
+
async function importPeer(load, pkg, injected) {
|
|
1857
1854
|
try {
|
|
1858
1855
|
return await load();
|
|
1859
1856
|
} catch (err) {
|
|
1860
1857
|
if (isModuleNotFound(err)) {
|
|
1861
|
-
throw new Error(`[stitchkit] createSocketIOServer needs the optional peer "${pkg}" — install it: bun add ${pkg}
|
|
1858
|
+
throw new Error(injected ? `[stitchkit] createSocketIOServer could not load the optional peer "${pkg}" through the loader passed in \`peers\` — the artifact does not contain it. Check that the loader is a literal \`import('${pkg}')\` your bundler can follow, and that "${pkg}" is a dependency of the package being bundled.` : `[stitchkit] createSocketIOServer needs the optional peer "${pkg}" — install it: bun add ${pkg}. Shipping one self-contained artifact instead? Pass \`peers: { … }\` so your bundler puts it inside.`, { cause: err });
|
|
1862
1859
|
}
|
|
1863
1860
|
throw err;
|
|
1864
1861
|
}
|
|
1865
1862
|
}
|
|
1863
|
+
function isBunEngineModule(value) {
|
|
1864
|
+
return typeof value === "object" && value !== null && typeof Reflect.get(value, "Server") === "function";
|
|
1865
|
+
}
|
|
1866
1866
|
function handshakeRejection(message) {
|
|
1867
1867
|
const error = new Error(message);
|
|
1868
1868
|
error.data = { code: "handshake_rejected" };
|
|
@@ -1906,11 +1906,11 @@ async function createSocketIOServer(config) {
|
|
|
1906
1906
|
const transports = config.transports ?? (onBun ? ["websocket", "polling"] : ["websocket"]);
|
|
1907
1907
|
const pingTimeout = config.pingTimeout ?? 20000;
|
|
1908
1908
|
const pingInterval = config.pingInterval ?? 1e4;
|
|
1909
|
-
const cors = {
|
|
1909
|
+
const cors = config.cors ? {
|
|
1910
1910
|
origin: config.cors.origin,
|
|
1911
1911
|
credentials: config.cors.credentials ?? true,
|
|
1912
1912
|
methods: ["GET", "POST"]
|
|
1913
|
-
};
|
|
1913
|
+
} : undefined;
|
|
1914
1914
|
let accepting = true;
|
|
1915
1915
|
let attached = false;
|
|
1916
1916
|
let closePromise;
|
|
@@ -1939,7 +1939,8 @@ async function createSocketIOServer(config) {
|
|
|
1939
1939
|
});
|
|
1940
1940
|
checkRequest(webRequest).then(() => done(null, true), (error) => done(error instanceof Error ? error.message : "Request rejected", false));
|
|
1941
1941
|
};
|
|
1942
|
-
const
|
|
1942
|
+
const injectedServer = config.peers?.server;
|
|
1943
|
+
const { Server } = await importPeer(injectedServer ?? (() => import(SOCKET_IO_SERVER).then((module) => module)), SOCKET_IO_SERVER, injectedServer !== undefined);
|
|
1943
1944
|
const io = new Server({
|
|
1944
1945
|
...config.serverOptions,
|
|
1945
1946
|
path,
|
|
@@ -1966,7 +1967,12 @@ async function createSocketIOServer(config) {
|
|
|
1966
1967
|
}
|
|
1967
1968
|
};
|
|
1968
1969
|
if (onBun) {
|
|
1969
|
-
const
|
|
1970
|
+
const injectedEngine = config.peers?.bunEngine;
|
|
1971
|
+
const engineModule = await importPeer(injectedEngine ?? (() => import(SOCKET_IO_BUN_ENGINE).then((module) => module)), SOCKET_IO_BUN_ENGINE, injectedEngine !== undefined);
|
|
1972
|
+
if (!isBunEngineModule(engineModule)) {
|
|
1973
|
+
throw new Error(`[stitchkit] the loader passed in \`peers.bunEngine\` did not return the "${SOCKET_IO_BUN_ENGINE}" module — it must resolve to the module itself, as \`() => import('${SOCKET_IO_BUN_ENGINE}')\`.`);
|
|
1974
|
+
}
|
|
1975
|
+
const { Server: Engine } = engineModule;
|
|
1970
1976
|
const engineOpts = {
|
|
1971
1977
|
path,
|
|
1972
1978
|
cors,
|
|
@@ -80,6 +80,10 @@ function resolvePropagationContext(metadata, fallback) {
|
|
|
80
80
|
|
|
81
81
|
// src/internal/route-pattern.ts
|
|
82
82
|
var PARAM_IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
83
|
+
function joinRoutePath(...parts) {
|
|
84
|
+
const joined = parts.filter((part) => Boolean(part)).map((part) => part.replace(/^\/+|\/+$/g, "")).filter(Boolean).join("/");
|
|
85
|
+
return `/${joined}`;
|
|
86
|
+
}
|
|
83
87
|
function parseTrailingWildcard(path) {
|
|
84
88
|
const segments = path.split("/").filter(Boolean);
|
|
85
89
|
const paramNames = new Set;
|
|
@@ -120,4 +124,4 @@ function parseTrailingWildcard(path) {
|
|
|
120
124
|
return wildcard;
|
|
121
125
|
}
|
|
122
126
|
|
|
123
|
-
export { parseTrailingWildcard, createTraceContext, parseTraceparent, formatTraceparent, resolveTraceContext, childSpan, resolvePropagationContext };
|
|
127
|
+
export { joinRoutePath, parseTrailingWildcard, createTraceContext, parseTraceparent, formatTraceparent, resolveTraceContext, childSpan, resolvePropagationContext };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseTrailingWildcard
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-pzyt11ch.js";
|
|
4
4
|
|
|
5
5
|
// src/contract/errors.ts
|
|
6
6
|
var APP_ERROR_BRAND = Symbol.for("stitchkit.AppError");
|
|
@@ -70,6 +70,12 @@ var STITCH_ERROR_STATUS = {
|
|
|
70
70
|
FILE_TOO_LARGE: 413,
|
|
71
71
|
FILE_EXISTS: 409,
|
|
72
72
|
REALTIME_CONTRACT_VIOLATION: 500,
|
|
73
|
+
APPLICATION_NOT_ACCEPTING: 503,
|
|
74
|
+
WAIT_TIMEOUT: 408,
|
|
75
|
+
WAIT_FAILED: 409,
|
|
76
|
+
DOWNLOAD_NOT_FOUND: 404,
|
|
77
|
+
VIEW_HTTP_ERROR: 502,
|
|
78
|
+
OPERATION_NOT_SUCCEEDED: 409,
|
|
73
79
|
INTERNAL_SERVER_ERROR: 500
|
|
74
80
|
};
|
|
75
81
|
function isStitchErrorCode(code) {
|
|
@@ -338,14 +338,6 @@ function rebuild(value) {
|
|
|
338
338
|
node[key] = rebuild(child);
|
|
339
339
|
return flattenNode(node);
|
|
340
340
|
}
|
|
341
|
-
function stringValues2(schema) {
|
|
342
|
-
if (typeof schema.const === "string")
|
|
343
|
-
return [schema.const];
|
|
344
|
-
if (!Array.isArray(schema.enum))
|
|
345
|
-
return null;
|
|
346
|
-
const values = schema.enum.filter((value) => typeof value === "string");
|
|
347
|
-
return values.length === schema.enum.length ? values : null;
|
|
348
|
-
}
|
|
349
341
|
function objectVariants(node) {
|
|
350
342
|
if (!Array.isArray(node.oneOf) || node.oneOf.length < 2)
|
|
351
343
|
return null;
|
|
@@ -372,7 +364,7 @@ function findDiscriminator(variants) {
|
|
|
372
364
|
}
|
|
373
365
|
const properties = variant.properties;
|
|
374
366
|
const field = isRecord(properties) ? properties[key] : undefined;
|
|
375
|
-
const branchValues = isRecord(field) ?
|
|
367
|
+
const branchValues = isRecord(field) ? stringValues(field) : null;
|
|
376
368
|
if (!branchValues || branchValues.length === 0) {
|
|
377
369
|
valid = false;
|
|
378
370
|
break;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ApplicationIdSchema
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-8eywc9zv.js";
|
|
4
4
|
|
|
5
5
|
// src/application/latest-sink.ts
|
|
6
6
|
import { z } from "zod";
|
|
@@ -557,4 +557,4 @@ function createManagedSchedule(config) {
|
|
|
557
557
|
};
|
|
558
558
|
}
|
|
559
559
|
|
|
560
|
-
export { ApplicationSnapshotSinkStatusSchema, createApplicationSnapshotSink, ActivityIdSchema, ActivityStageIdSchema, ActivityStageSnapshotSchema, ActivitySnapshotSchema, ActivityLiveStateSchema, createActivityProjection, ManagedScheduleOverlapSchema, ManagedScheduleErrorPolicySchema, ManagedScheduleDescriptorSchema, ManagedScheduleStatusSchema, createManagedSchedule };
|
|
560
|
+
export { ApplicationSnapshotSinkStatusSchema, createApplicationSnapshotSink, ActivityIdSchema, ActivityStageIdSchema, ActivityStageSnapshotSchema, ActivitySnapshotSchema, ActivityLiveStateSchema, ActivityTokenBrand, createActivityProjection, ManagedScheduleOverlapSchema, ManagedScheduleErrorPolicySchema, ManagedScheduleDescriptorSchema, ManagedScheduleStatusSchema, createManagedSchedule };
|