stitchkit 0.59.3 → 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.
Files changed (122) hide show
  1. package/README.md +14 -4
  2. package/dist/agent-runtime/admission-lanes.d.ts +35 -0
  3. package/dist/agent-runtime/admission-lanes.d.ts.map +1 -0
  4. package/dist/agent-runtime/coordinator.d.ts +36 -2
  5. package/dist/agent-runtime/coordinator.d.ts.map +1 -1
  6. package/dist/agent-runtime/events.d.ts +7 -0
  7. package/dist/agent-runtime/events.d.ts.map +1 -1
  8. package/dist/agent-runtime/history.d.ts +7 -0
  9. package/dist/agent-runtime/history.d.ts.map +1 -1
  10. package/dist/agent-runtime/models.d.ts +2 -3
  11. package/dist/agent-runtime/models.d.ts.map +1 -1
  12. package/dist/agent-runtime/observability.d.ts.map +1 -1
  13. package/dist/agent-runtime/run-execution.d.ts +31 -0
  14. package/dist/agent-runtime/run-execution.d.ts.map +1 -0
  15. package/dist/agent-runtime/runtime-internals.d.ts +25 -0
  16. package/dist/agent-runtime/runtime-internals.d.ts.map +1 -0
  17. package/dist/agent-runtime/runtime-result.d.ts +11 -0
  18. package/dist/agent-runtime/runtime-result.d.ts.map +1 -0
  19. package/dist/agent-runtime/runtime.d.ts +16 -15
  20. package/dist/agent-runtime/runtime.d.ts.map +1 -1
  21. package/dist/agent-runtime/schemas.d.ts.map +1 -1
  22. package/dist/agent-runtime/store-driver.d.ts.map +1 -1
  23. package/dist/agent-runtime/store.d.ts +9 -2
  24. package/dist/agent-runtime/store.d.ts.map +1 -1
  25. package/dist/agent-runtime/terminal-commit.d.ts.map +1 -1
  26. package/dist/agent-runtime/terminal-status.d.ts +13 -0
  27. package/dist/agent-runtime/terminal-status.d.ts.map +1 -0
  28. package/dist/agent-runtime.d.ts +5 -3
  29. package/dist/agent-runtime.d.ts.map +1 -1
  30. package/dist/agent-runtime.js +211 -156
  31. package/dist/application/activity.d.ts +7 -2
  32. package/dist/application/activity.d.ts.map +1 -1
  33. package/dist/application/grammy.d.ts +6 -0
  34. package/dist/application/grammy.d.ts.map +1 -1
  35. package/dist/application/health.d.ts +20 -1
  36. package/dist/application/health.d.ts.map +1 -1
  37. package/dist/application/kernel.d.ts +49 -3
  38. package/dist/application/kernel.d.ts.map +1 -1
  39. package/dist/application/opentelemetry.d.ts +25 -0
  40. package/dist/application/opentelemetry.d.ts.map +1 -0
  41. package/dist/application/schemas.d.ts +42 -0
  42. package/dist/application/schemas.d.ts.map +1 -1
  43. package/dist/application-opentelemetry.d.ts +2 -0
  44. package/dist/application-opentelemetry.d.ts.map +1 -0
  45. package/dist/application-opentelemetry.js +248 -0
  46. package/dist/application.d.ts +4 -4
  47. package/dist/application.d.ts.map +1 -1
  48. package/dist/application.js +69 -1243
  49. package/dist/cli.js +6 -6
  50. package/dist/contract/errors.d.ts +6 -0
  51. package/dist/contract/errors.d.ts.map +1 -1
  52. package/dist/contract/index.js +1 -1
  53. package/dist/declaration.d.ts +345 -0
  54. package/dist/declaration.d.ts.map +1 -0
  55. package/dist/declaration.js +183 -0
  56. package/dist/index-1zencgcb.js +651 -0
  57. package/dist/{index-sa2mbwa7.js → index-2akar0rq.js} +2 -2
  58. package/dist/{index-41wm56v0.js → index-3hn10n4c.js} +1 -1
  59. package/dist/{index-f6pymtqe.js → index-3w74r08v.js} +2 -2
  60. package/dist/{index-7c0gkyvj.js → index-6fbp58g8.js} +2 -2
  61. package/dist/{index-gnvzyw0k.js → index-8es1hrv4.js} +2 -2
  62. package/dist/index-8eywc9zv.js +100 -0
  63. package/dist/{index-3nwng7hs.js → index-8pc5s3pz.js} +4 -4
  64. package/dist/{index-28cqssm3.js → index-9h1vba8n.js} +6 -0
  65. package/dist/{index-0nc0cddp.js → index-a59da114.js} +17 -28
  66. package/dist/{index-0tszzfxp.js → index-f7521k0x.js} +25 -19
  67. package/dist/{index-y2rb7dwx.js → index-pzyt11ch.js} +5 -1
  68. package/dist/{index-mr617n62.js → index-svqhcrrj.js} +1 -1
  69. package/dist/{index-ps5pxp3h.js → index-v6e8hnkx.js} +7 -1
  70. package/dist/{index-1tkyng3g.js → index-vkk06pv1.js} +1 -9
  71. package/dist/index-x8v8b7rc.js +560 -0
  72. package/dist/index.js +1 -1
  73. package/dist/internal/observability-sink.d.ts.map +1 -1
  74. package/dist/internal/route-pattern.d.ts +9 -0
  75. package/dist/internal/route-pattern.d.ts.map +1 -1
  76. package/dist/node.d.ts +1 -1
  77. package/dist/node.d.ts.map +1 -1
  78. package/dist/node.js +12 -12
  79. package/dist/observability/index.js +5 -5
  80. package/dist/observability/sanitize.d.ts +3 -1
  81. package/dist/observability/sanitize.d.ts.map +1 -1
  82. package/dist/remote.js +3 -3
  83. package/dist/server/error-hook.d.ts +10 -3
  84. package/dist/server/error-hook.d.ts.map +1 -1
  85. package/dist/server/index.d.ts +1 -1
  86. package/dist/server/index.d.ts.map +1 -1
  87. package/dist/server/index.js +16 -19
  88. package/dist/server/middleware/cors.d.ts +5 -2
  89. package/dist/server/middleware/cors.d.ts.map +1 -1
  90. package/dist/server/openapi.d.ts.map +1 -1
  91. package/dist/server/router.d.ts.map +1 -1
  92. package/dist/server/socket-io-config.d.ts +68 -3
  93. package/dist/server/socket-io-config.d.ts.map +1 -1
  94. package/dist/server/socket-io-node.d.ts +1 -1
  95. package/dist/server/socket-io-node.d.ts.map +1 -1
  96. package/dist/server/socket-io.d.ts +1 -1
  97. package/dist/server/socket-io.d.ts.map +1 -1
  98. package/dist/testing/managed-resource-conformance-contract.d.ts +114 -0
  99. package/dist/testing/managed-resource-conformance-contract.d.ts.map +1 -0
  100. package/dist/testing/managed-resource-conformance-driver.d.ts +20 -0
  101. package/dist/testing/managed-resource-conformance-driver.d.ts.map +1 -0
  102. package/dist/testing/managed-resource-conformance-scenarios.d.ts +33 -0
  103. package/dist/testing/managed-resource-conformance-scenarios.d.ts.map +1 -0
  104. package/dist/testing/managed-resource-conformance.d.ts +5 -0
  105. package/dist/testing/managed-resource-conformance.d.ts.map +1 -0
  106. package/dist/testing/surface-manifest.d.ts.map +1 -1
  107. package/dist/testing.d.ts +1 -0
  108. package/dist/testing.d.ts.map +1 -1
  109. package/dist/testing.js +664 -78
  110. package/dist/tools/flatten-join.d.ts +2 -0
  111. package/dist/tools/flatten-join.d.ts.map +1 -1
  112. package/dist/tools/flatten.d.ts.map +1 -1
  113. package/dist/tools/mcp-prepare.d.ts +0 -2
  114. package/dist/tools/mcp-prepare.d.ts.map +1 -1
  115. package/dist/tools/runtime-tool.d.ts +0 -3
  116. package/dist/tools/runtime-tool.d.ts.map +1 -1
  117. package/dist/tools/schema.d.ts +0 -4
  118. package/dist/tools/schema.d.ts.map +1 -1
  119. package/dist/tools.js +9 -9
  120. package/llms-full.txt +1212 -67
  121. package/llms.txt +2 -0
  122. package/package.json +16 -3
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  AppError,
3
3
  isUnsafeKey
4
- } from "./index-ps5pxp3h.js";
4
+ } from "./index-v6e8hnkx.js";
5
5
  import {
6
6
  resolveTraceContext
7
- } from "./index-y2rb7dwx.js";
7
+ } from "./index-pzyt11ch.js";
8
8
  import {
9
9
  isRecord
10
10
  } from "./index-smpbdg6k.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isUnsafeKey
3
- } from "./index-ps5pxp3h.js";
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 };
@@ -0,0 +1,100 @@
1
+ // src/application/schemas.ts
2
+ import { z } from "zod";
3
+ var ApplicationIdSchema = z.string().min(1).max(128).regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]*$/);
4
+ var ApplicationLifecycleSchema = z.enum([
5
+ "created",
6
+ "starting",
7
+ "ready",
8
+ "draining",
9
+ "stopping",
10
+ "stopped",
11
+ "failed"
12
+ ]);
13
+ var ApplicationHealthSchema = z.enum(["unknown", "healthy", "degraded", "unhealthy"]);
14
+ var ManagedResourceStateSchema = z.enum([
15
+ "registered",
16
+ "starting",
17
+ "ready",
18
+ "failed",
19
+ "stopping",
20
+ "stopped"
21
+ ]);
22
+ var NonNegativeIntegerSchema = z.number().int().nonnegative();
23
+ var ApplicationAdmissionSnapshotSchema = z.object({
24
+ accepting: z.boolean(),
25
+ accepted: NonNegativeIntegerSchema,
26
+ completed: NonNegativeIntegerSchema,
27
+ pending: NonNegativeIntegerSchema
28
+ }).readonly();
29
+ var ManagedResourceSnapshotSchema = z.object({
30
+ id: ApplicationIdSchema,
31
+ required: z.boolean(),
32
+ dependsOn: z.array(ApplicationIdSchema).readonly(),
33
+ state: ManagedResourceStateSchema,
34
+ health: ApplicationHealthSchema,
35
+ ready: z.boolean()
36
+ }).readonly();
37
+ var ApplicationSnapshotSchema = z.object({
38
+ id: ApplicationIdSchema,
39
+ epoch: z.string().uuid(),
40
+ revision: NonNegativeIntegerSchema,
41
+ lifecycle: ApplicationLifecycleSchema,
42
+ health: ApplicationHealthSchema,
43
+ ready: z.boolean(),
44
+ capturedAt: z.string().datetime({ offset: true }),
45
+ changedAt: z.string().datetime({ offset: true }),
46
+ admission: ApplicationAdmissionSnapshotSchema,
47
+ resources: z.array(ManagedResourceSnapshotSchema).readonly()
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
+ }
83
+ var ApplicationResourceShutdownSchema = z.object({
84
+ id: ApplicationIdSchema,
85
+ state: z.enum(["not-started", "closed", "force-failed"]),
86
+ failures: z.array(z.enum(["start", "ready", "completion", "admission", "drain", "close", "force"])).readonly()
87
+ }).readonly();
88
+ var ApplicationShutdownResultSchema = z.object({
89
+ outcome: z.enum(["clean", "forced"]),
90
+ reason: z.enum(["deadline", "signal"]).optional(),
91
+ cleanupComplete: z.boolean(),
92
+ acceptedOperations: NonNegativeIntegerSchema,
93
+ completedOperations: NonNegativeIntegerSchema,
94
+ pendingOperations: NonNegativeIntegerSchema,
95
+ pendingOperationsAtForce: NonNegativeIntegerSchema,
96
+ resources: z.array(ApplicationResourceShutdownSchema).readonly(),
97
+ durationMs: z.number().nonnegative()
98
+ }).readonly();
99
+
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-sa2mbwa7.js";
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-1tkyng3g.js";
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-7c0gkyvj.js";
27
+ } from "./index-6fbp58g8.js";
28
28
  import {
29
29
  isUnsafeKey,
30
30
  safeJsonParse
31
- } from "./index-ps5pxp3h.js";
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(() => ObservabilitySinkStatusSchema.parse({
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 };
@@ -1,6 +1,3 @@
1
- import {
2
- ShutdownOptionsSchema
3
- } from "./index-dk6e56g0.js";
4
1
  import {
5
2
  DEFAULT_PROCESS_SIGNALS,
6
3
  RUNTIME_CONTEXT_RESERVED_KEYS,
@@ -10,7 +7,10 @@ import {
10
7
  defaultSignalSource,
11
8
  guardSignalCallback,
12
9
  reportSignalError
13
- } from "./index-41wm56v0.js";
10
+ } from "./index-3hn10n4c.js";
11
+ import {
12
+ ShutdownOptionsSchema
13
+ } from "./index-dk6e56g0.js";
14
14
  import {
15
15
  errorCode,
16
16
  extractIp,
@@ -26,17 +26,18 @@ import {
26
26
  setRequestError,
27
27
  validateDeclaredOutput,
28
28
  zodIssues
29
- } from "./index-7c0gkyvj.js";
29
+ } from "./index-6fbp58g8.js";
30
30
  import {
31
31
  AppError,
32
32
  badRequest,
33
33
  isUnsafeKey,
34
34
  safeJsonParse
35
- } from "./index-ps5pxp3h.js";
35
+ } from "./index-v6e8hnkx.js";
36
36
  import {
37
+ joinRoutePath,
37
38
  parseTrailingWildcard,
38
39
  resolveTraceContext
39
- } from "./index-y2rb7dwx.js";
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 = joinPath("/", service.prefix, method.path === "/" ? "" : method.path);
918
- const fullPath = prefix ? joinPath(prefix, servicePath) : servicePath;
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}`, { cause: err });
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 { Server } = await importPeer(() => import(SOCKET_IO_SERVER).then((module) => module), SOCKET_IO_SERVER);
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 { Server: Engine } = await importPeer(() => import(SOCKET_IO_BUN_ENGINE).then((module) => module), SOCKET_IO_BUN_ENGINE);
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 };
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-48ffdxgk.js";
4
4
  import {
5
5
  parseTrailingWildcard
6
- } from "./index-y2rb7dwx.js";
6
+ } from "./index-pzyt11ch.js";
7
7
  import {
8
8
  isRecord,
9
9
  mapObject,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  parseTrailingWildcard
3
- } from "./index-y2rb7dwx.js";
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) ? stringValues2(field) : null;
367
+ const branchValues = isRecord(field) ? stringValues(field) : null;
376
368
  if (!branchValues || branchValues.length === 0) {
377
369
  valid = false;
378
370
  break;