stitchkit 0.53.2 → 0.55.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 +4 -1
- package/dist/browser/socket-io.d.ts +11 -1
- package/dist/browser/socket-io.d.ts.map +1 -1
- package/dist/cli.d.ts +2 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +15 -8
- package/dist/contract/define.d.ts +27 -0
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/file-ref.d.ts +13 -0
- package/dist/contract/file-ref.d.ts.map +1 -0
- package/dist/contract/index.d.ts +2 -1
- package/dist/contract/index.d.ts.map +1 -1
- package/dist/contract/index.js +21 -17
- package/dist/files/boundary.d.ts +52 -0
- package/dist/files/boundary.d.ts.map +1 -0
- package/dist/files.d.ts +3 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +16 -0
- package/dist/{index-c78w2y09.js → index-0gv7k0ra.js} +515 -156
- package/dist/index-1bx83sw4.js +4 -0
- package/dist/index-1k16zv57.js +269 -0
- package/dist/index-6k1937bx.js +20 -0
- package/dist/{index-bmnhqtya.js → index-7eq9va6e.js} +1 -4
- package/dist/{index-yxpe3phd.js → index-cby4ar3v.js} +1 -18
- package/dist/index-h60df7rj.js +110 -0
- package/dist/{index-yez419px.js → index-js7yexng.js} +19 -6
- package/dist/index-k4dftwf7.js +66 -0
- package/dist/{index-pdv1mjjr.js → index-npye5kt7.js} +30 -59
- package/dist/{index-yydqk4fh.js → index-pzc32v75.js} +90 -3
- package/dist/{index-e1es808r.js → index-qh4xevf5.js} +1 -1
- package/dist/{index-gvha32jh.js → index-qx84bqzk.js} +2 -2
- package/dist/{index-pfqjb5xy.js → index-rgd18hx3.js} +23 -5
- package/dist/index-sbdmyz75.js +18 -0
- package/dist/{index-173tvqcp.js → index-v4bbq3p4.js} +9 -114
- package/dist/index.js +162 -35
- package/dist/node.js +30 -27
- package/dist/observability/event.d.ts +2 -16
- package/dist/observability/event.d.ts.map +1 -1
- package/dist/observability/index.js +28 -25
- package/dist/react.js +2 -2
- package/dist/realtime/contract.d.ts +9 -0
- package/dist/realtime/contract.d.ts.map +1 -1
- package/dist/realtime/index.d.ts +2 -1
- package/dist/realtime/index.d.ts.map +1 -1
- package/dist/realtime/request.d.ts +21 -0
- package/dist/realtime/request.d.ts.map +1 -0
- package/dist/realtime/socket.d.ts +3 -0
- package/dist/realtime/socket.d.ts.map +1 -1
- package/dist/remote.d.ts +9 -0
- package/dist/remote.d.ts.map +1 -0
- package/dist/remote.js +79 -0
- package/dist/server/context-contribution.d.ts +10 -0
- package/dist/server/context-contribution.d.ts.map +1 -0
- package/dist/server/context.d.ts.map +1 -1
- package/dist/server/index.d.ts +2 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +133 -88
- package/dist/server/lifecycle.d.ts +4 -0
- package/dist/server/lifecycle.d.ts.map +1 -0
- package/dist/server/middleware/auth.d.ts +35 -7
- package/dist/server/middleware/auth.d.ts.map +1 -1
- package/dist/server/process-signal-common.d.ts +6 -0
- package/dist/server/process-signal-common.d.ts.map +1 -0
- package/dist/server/process-signals.d.ts.map +1 -1
- package/dist/server/types.d.ts +1 -1
- package/dist/server/types.d.ts.map +1 -1
- package/dist/testing/surface-conformance.d.ts +47 -0
- package/dist/testing/surface-conformance.d.ts.map +1 -0
- package/dist/testing/surface-manifest.d.ts +156 -0
- package/dist/testing/surface-manifest.d.ts.map +1 -0
- package/dist/testing.d.ts +2 -0
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +366 -3
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/async-operation.d.ts +168 -0
- package/dist/tools/async-operation.d.ts.map +1 -0
- package/dist/tools/cli-args.d.ts +1 -1
- package/dist/tools/cli-args.d.ts.map +1 -1
- package/dist/tools/cli-command.d.ts +29 -0
- package/dist/tools/cli-command.d.ts.map +1 -0
- package/dist/tools/cli-format.d.ts +2 -2
- package/dist/tools/cli-format.d.ts.map +1 -1
- package/dist/tools/cli-wait.d.ts +11 -2
- package/dist/tools/cli-wait.d.ts.map +1 -1
- package/dist/tools/cli.d.ts +13 -6
- package/dist/tools/cli.d.ts.map +1 -1
- package/dist/tools/define-download-tool.d.ts +18 -0
- package/dist/tools/define-download-tool.d.ts.map +1 -0
- package/dist/tools/define-upload-tool.d.ts +16 -0
- package/dist/tools/define-upload-tool.d.ts.map +1 -0
- package/dist/tools/define-view-file-tool.d.ts +10 -0
- package/dist/tools/define-view-file-tool.d.ts.map +1 -0
- package/dist/tools/define-wait-tool.d.ts +22 -0
- package/dist/tools/define-wait-tool.d.ts.map +1 -0
- package/dist/tools/download-core.d.ts +20 -0
- package/dist/tools/download-core.d.ts.map +1 -0
- package/dist/tools/execute.d.ts +3 -1
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/lifecycle.d.ts +4 -0
- package/dist/tools/lifecycle.d.ts.map +1 -0
- package/dist/tools/mcp-round.d.ts +0 -1
- package/dist/tools/mcp-round.d.ts.map +1 -1
- package/dist/tools/mcp-stdio-signals.d.ts +33 -0
- package/dist/tools/mcp-stdio-signals.d.ts.map +1 -0
- package/dist/tools/mount-download.d.ts +10 -4
- package/dist/tools/mount-download.d.ts.map +1 -1
- package/dist/tools/mount-upload.d.ts +4 -2
- package/dist/tools/mount-upload.d.ts.map +1 -1
- package/dist/tools/mount-wait.d.ts.map +1 -1
- package/dist/tools/native-definition.d.ts +15 -0
- package/dist/tools/native-definition.d.ts.map +1 -0
- package/dist/tools/runtime-tool.d.ts +5 -4
- package/dist/tools/runtime-tool.d.ts.map +1 -1
- package/dist/tools/surface.d.ts.map +1 -1
- package/dist/tools/upload-core.d.ts +4 -0
- package/dist/tools/upload-core.d.ts.map +1 -0
- package/dist/tools/view-file.d.ts +84 -23
- package/dist/tools/view-file.d.ts.map +1 -1
- package/dist/tools/wait-core.d.ts +16 -2
- package/dist/tools/wait-core.d.ts.map +1 -1
- package/dist/tools.d.ts +12 -3
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +827 -495
- package/llms-full.txt +720 -53
- package/package.json +10 -2
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ALL_TRANSPORTS,
|
|
3
3
|
AppError,
|
|
4
|
+
ManagedFilePathSchema,
|
|
5
|
+
ManagedFileRefSchema,
|
|
4
6
|
STITCH_ERROR_STATUS,
|
|
5
7
|
appError,
|
|
6
8
|
badRequest,
|
|
@@ -17,7 +19,7 @@ import {
|
|
|
17
19
|
parseTrailingWildcard,
|
|
18
20
|
rateLimited,
|
|
19
21
|
unauthorized
|
|
20
|
-
} from "./index-
|
|
22
|
+
} from "./index-rgd18hx3.js";
|
|
21
23
|
import {
|
|
22
24
|
isRecord,
|
|
23
25
|
mapObject,
|
|
@@ -806,6 +808,39 @@ function createUrlBuilders(contracts, source, contractConfig) {
|
|
|
806
808
|
function createScopedUrlBuilders(contracts, source, scopeConfigs) {
|
|
807
809
|
return buildScopedRegistry(contracts, scopeConfigs, "URL builder", (contract, config) => createUrlBuilder(contract, source, config));
|
|
808
810
|
}
|
|
811
|
+
// src/realtime/request.ts
|
|
812
|
+
class RealtimeRequestTimeoutError extends Error {
|
|
813
|
+
code = "REALTIME_REQUEST_TIMEOUT";
|
|
814
|
+
event;
|
|
815
|
+
timeoutMs;
|
|
816
|
+
constructor(event, timeoutMs) {
|
|
817
|
+
super(`Realtime request "${event}" timed out after ${timeoutMs}ms`);
|
|
818
|
+
this.name = "RealtimeRequestTimeoutError";
|
|
819
|
+
this.event = event;
|
|
820
|
+
this.timeoutMs = timeoutMs;
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
class RealtimeRequestDisconnectedError extends Error {
|
|
825
|
+
code = "REALTIME_REQUEST_DISCONNECTED";
|
|
826
|
+
event;
|
|
827
|
+
constructor(event) {
|
|
828
|
+
super(`Realtime request "${event}" was interrupted by disconnect`);
|
|
829
|
+
this.name = "RealtimeRequestDisconnectedError";
|
|
830
|
+
this.event = event;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
class RealtimeRequestInvalidAcknowledgementError extends Error {
|
|
835
|
+
code = "REALTIME_REQUEST_INVALID_ACKNOWLEDGEMENT";
|
|
836
|
+
event;
|
|
837
|
+
constructor(event, cause) {
|
|
838
|
+
super(`Realtime request "${event}" received an invalid acknowledgement`, { cause });
|
|
839
|
+
this.name = "RealtimeRequestInvalidAcknowledgementError";
|
|
840
|
+
this.event = event;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
|
|
809
844
|
// src/realtime/rejection.ts
|
|
810
845
|
import { z as z2 } from "zod";
|
|
811
846
|
|
|
@@ -884,6 +919,45 @@ function reportRejected(rejected, hook, logger) {
|
|
|
884
919
|
console.error("[stitchkit] realtime rejection hook failed", error);
|
|
885
920
|
});
|
|
886
921
|
}
|
|
922
|
+
function parseRealtimeRequestArguments(registry, event, direction, args) {
|
|
923
|
+
const definition = eventDefinition(registry, event, direction);
|
|
924
|
+
const parsed = definition.args.safeParse(args);
|
|
925
|
+
if (!parsed.success) {
|
|
926
|
+
throw realtimeContractViolation({
|
|
927
|
+
event,
|
|
928
|
+
direction,
|
|
929
|
+
phase: "arguments",
|
|
930
|
+
reason: "invalid-arguments",
|
|
931
|
+
fault: "local",
|
|
932
|
+
cause: parsed.error
|
|
933
|
+
}).error;
|
|
934
|
+
}
|
|
935
|
+
if (!definition.ack) {
|
|
936
|
+
throw realtimeContractViolation({
|
|
937
|
+
event,
|
|
938
|
+
direction,
|
|
939
|
+
phase: "acknowledgement",
|
|
940
|
+
reason: "missing-acknowledgement",
|
|
941
|
+
fault: "local"
|
|
942
|
+
}).error;
|
|
943
|
+
}
|
|
944
|
+
return parsed.data;
|
|
945
|
+
}
|
|
946
|
+
function parseRealtimeRequestAcknowledgement(schema, event, direction, value, hook, logger) {
|
|
947
|
+
const parsed = schema.safeParse(value);
|
|
948
|
+
if (parsed.success)
|
|
949
|
+
return parsed.data;
|
|
950
|
+
const rejected = realtimeContractViolation({
|
|
951
|
+
event,
|
|
952
|
+
direction,
|
|
953
|
+
phase: "acknowledgement",
|
|
954
|
+
reason: "invalid-acknowledgement-value",
|
|
955
|
+
fault: "peer",
|
|
956
|
+
cause: parsed.error
|
|
957
|
+
});
|
|
958
|
+
reportRejected(rejected, hook, logger);
|
|
959
|
+
throw new RealtimeRequestInvalidAcknowledgementError(event, rejected.error);
|
|
960
|
+
}
|
|
887
961
|
function createValidatedRealtimeSocket({
|
|
888
962
|
target,
|
|
889
963
|
inbound,
|
|
@@ -1070,6 +1144,25 @@ function createRealtimeClient(contract, { onRejected, logger, ...config }) {
|
|
|
1070
1144
|
};
|
|
1071
1145
|
}
|
|
1072
1146
|
});
|
|
1147
|
+
async function request(event, ...args) {
|
|
1148
|
+
const options = args.at(-1);
|
|
1149
|
+
if (!options || typeof options !== "object" || !("timeoutMs" in options)) {
|
|
1150
|
+
throw new TypeError(`Realtime request "${event}" requires { timeoutMs }`);
|
|
1151
|
+
}
|
|
1152
|
+
const timeoutMs = options.timeoutMs;
|
|
1153
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
1154
|
+
throw new RangeError(`Realtime request "${event}" timeoutMs must be finite and > 0`);
|
|
1155
|
+
}
|
|
1156
|
+
const values = args.slice(0, -1);
|
|
1157
|
+
const parsedArgs = parseRealtimeRequestArguments(contract.clientToServer, event, "client-outbound", values);
|
|
1158
|
+
const definition = contract.clientToServer[event];
|
|
1159
|
+
if (!definition?.ack) {
|
|
1160
|
+
throw new Error(`Realtime request "${event}" has no acknowledgement schema`);
|
|
1161
|
+
}
|
|
1162
|
+
const value = await transport.emitWithAck(event, parsedArgs, { timeoutMs });
|
|
1163
|
+
const acknowledgement = parseRealtimeRequestAcknowledgement(definition.ack, event, "client-inbound", value, onRejected, logger);
|
|
1164
|
+
return acknowledgement;
|
|
1165
|
+
}
|
|
1073
1166
|
return {
|
|
1074
1167
|
...events,
|
|
1075
1168
|
connect: transport.connect,
|
|
@@ -1077,6 +1170,7 @@ function createRealtimeClient(contract, { onRejected, logger, ...config }) {
|
|
|
1077
1170
|
get connected() {
|
|
1078
1171
|
return transport.connected;
|
|
1079
1172
|
},
|
|
1173
|
+
request,
|
|
1080
1174
|
onConnectionChange: transport.onConnectionChange
|
|
1081
1175
|
};
|
|
1082
1176
|
}
|
|
@@ -1084,6 +1178,7 @@ function createSocketIOClient(config) {
|
|
|
1084
1178
|
let socket = null;
|
|
1085
1179
|
let desiredConnected = false;
|
|
1086
1180
|
let reconnectTimer = null;
|
|
1181
|
+
const pendingRequestDisconnects = new Set;
|
|
1087
1182
|
const serverDisconnectDelay = config.reconnectOnServerDisconnect ?? 1000;
|
|
1088
1183
|
const connectionListeners = new Set;
|
|
1089
1184
|
const subscriptions = new Set;
|
|
@@ -1169,6 +1264,8 @@ function createSocketIOClient(config) {
|
|
|
1169
1264
|
disconnect() {
|
|
1170
1265
|
desiredConnected = false;
|
|
1171
1266
|
clearReconnectTimer();
|
|
1267
|
+
for (const reject of [...pendingRequestDisconnects])
|
|
1268
|
+
reject();
|
|
1172
1269
|
if (!socket)
|
|
1173
1270
|
return;
|
|
1174
1271
|
const wasConnected = socket.connected;
|
|
@@ -1204,6 +1301,31 @@ function createSocketIOClient(config) {
|
|
|
1204
1301
|
socket.emit(name, ...args);
|
|
1205
1302
|
return true;
|
|
1206
1303
|
},
|
|
1304
|
+
emitWithAck(event, args, options) {
|
|
1305
|
+
const active = socket;
|
|
1306
|
+
if (!active?.connected) {
|
|
1307
|
+
return Promise.reject(new RealtimeRequestDisconnectedError(event));
|
|
1308
|
+
}
|
|
1309
|
+
return new Promise((resolve, reject) => {
|
|
1310
|
+
let settled = false;
|
|
1311
|
+
const finish = (result) => {
|
|
1312
|
+
if (settled)
|
|
1313
|
+
return;
|
|
1314
|
+
settled = true;
|
|
1315
|
+
pendingRequestDisconnects.delete(onDisconnect);
|
|
1316
|
+
active.off("disconnect", onDisconnect);
|
|
1317
|
+
result();
|
|
1318
|
+
};
|
|
1319
|
+
const onDisconnect = () => {
|
|
1320
|
+
finish(() => reject(new RealtimeRequestDisconnectedError(event)));
|
|
1321
|
+
};
|
|
1322
|
+
pendingRequestDisconnects.add(onDisconnect);
|
|
1323
|
+
active.on("disconnect", onDisconnect);
|
|
1324
|
+
active.timeout(options.timeoutMs).emitWithAck(event, ...args).then((value) => finish(() => resolve(value)), () => {
|
|
1325
|
+
finish(() => reject(active.connected ? new RealtimeRequestTimeoutError(event, options.timeoutMs) : new RealtimeRequestDisconnectedError(event)));
|
|
1326
|
+
});
|
|
1327
|
+
});
|
|
1328
|
+
},
|
|
1207
1329
|
onConnectionChange(listener) {
|
|
1208
1330
|
connectionListeners.add(listener);
|
|
1209
1331
|
return () => connectionListeners.delete(listener);
|
|
@@ -1249,39 +1371,44 @@ function defineRealtimeContract(contract) {
|
|
|
1249
1371
|
return contract;
|
|
1250
1372
|
}
|
|
1251
1373
|
export {
|
|
1252
|
-
|
|
1253
|
-
rateLimited,
|
|
1254
|
-
parseTraceparent,
|
|
1255
|
-
parseSSE,
|
|
1256
|
-
paginatedSchema,
|
|
1257
|
-
notFound,
|
|
1258
|
-
isStitchErrorCode,
|
|
1259
|
-
formatTraceparent,
|
|
1260
|
-
forbidden,
|
|
1261
|
-
encodeCursor,
|
|
1262
|
-
defineRealtimeContract,
|
|
1263
|
-
defineErrors,
|
|
1264
|
-
defineContract,
|
|
1265
|
-
decodeCursor,
|
|
1266
|
-
createUrlBuilders,
|
|
1267
|
-
createUrlBuilder,
|
|
1268
|
-
createTraceContext,
|
|
1269
|
-
createSocketIOClient,
|
|
1270
|
-
createScopedUrlBuilders,
|
|
1271
|
-
createScopedClients,
|
|
1272
|
-
createRetainedTopics,
|
|
1273
|
-
createRealtimeClient,
|
|
1274
|
-
createHttpClient,
|
|
1275
|
-
createContractFactory,
|
|
1276
|
-
createClients,
|
|
1277
|
-
createClient,
|
|
1278
|
-
contractEndpointMatchers,
|
|
1279
|
-
conflict,
|
|
1280
|
-
childSpan,
|
|
1281
|
-
badRequest,
|
|
1282
|
-
appError,
|
|
1283
|
-
STITCH_ERROR_STATUS,
|
|
1284
|
-
AppError,
|
|
1374
|
+
ALL_TRANSPORTS,
|
|
1285
1375
|
ApiError,
|
|
1286
|
-
|
|
1376
|
+
AppError,
|
|
1377
|
+
ManagedFilePathSchema,
|
|
1378
|
+
ManagedFileRefSchema,
|
|
1379
|
+
RealtimeRequestDisconnectedError,
|
|
1380
|
+
RealtimeRequestInvalidAcknowledgementError,
|
|
1381
|
+
RealtimeRequestTimeoutError,
|
|
1382
|
+
STITCH_ERROR_STATUS,
|
|
1383
|
+
appError,
|
|
1384
|
+
badRequest,
|
|
1385
|
+
childSpan,
|
|
1386
|
+
conflict,
|
|
1387
|
+
contractEndpointMatchers,
|
|
1388
|
+
createClient,
|
|
1389
|
+
createClients,
|
|
1390
|
+
createContractFactory,
|
|
1391
|
+
createHttpClient,
|
|
1392
|
+
createRealtimeClient,
|
|
1393
|
+
createRetainedTopics,
|
|
1394
|
+
createScopedClients,
|
|
1395
|
+
createScopedUrlBuilders,
|
|
1396
|
+
createSocketIOClient,
|
|
1397
|
+
createTraceContext,
|
|
1398
|
+
createUrlBuilder,
|
|
1399
|
+
createUrlBuilders,
|
|
1400
|
+
decodeCursor,
|
|
1401
|
+
defineContract,
|
|
1402
|
+
defineErrors,
|
|
1403
|
+
defineRealtimeContract,
|
|
1404
|
+
encodeCursor,
|
|
1405
|
+
forbidden,
|
|
1406
|
+
formatTraceparent,
|
|
1407
|
+
isStitchErrorCode,
|
|
1408
|
+
notFound,
|
|
1409
|
+
paginatedSchema,
|
|
1410
|
+
parseSSE,
|
|
1411
|
+
parseTraceparent,
|
|
1412
|
+
rateLimited,
|
|
1413
|
+
unauthorized
|
|
1287
1414
|
};
|
package/dist/node.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
createHandler,
|
|
9
9
|
createServerLifecycle,
|
|
10
10
|
createSocketIOServer
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-npye5kt7.js";
|
|
12
12
|
import {
|
|
13
13
|
createImplement,
|
|
14
14
|
createImplementRegistry,
|
|
@@ -17,7 +17,8 @@ import {
|
|
|
17
17
|
createScopedImplementRegistry,
|
|
18
18
|
implement,
|
|
19
19
|
implementRegistry
|
|
20
|
-
} from "./index-
|
|
20
|
+
} from "./index-pzc32v75.js";
|
|
21
|
+
import"./index-v4bbq3p4.js";
|
|
21
22
|
import {
|
|
22
23
|
AppError,
|
|
23
24
|
appError,
|
|
@@ -27,8 +28,10 @@ import {
|
|
|
27
28
|
notFound,
|
|
28
29
|
rateLimited,
|
|
29
30
|
unauthorized
|
|
30
|
-
} from "./index-
|
|
31
|
-
import"./index-
|
|
31
|
+
} from "./index-h60df7rj.js";
|
|
32
|
+
import"./index-6k1937bx.js";
|
|
33
|
+
import"./index-7eq9va6e.js";
|
|
34
|
+
import"./index-1bx83sw4.js";
|
|
32
35
|
// src/server/node.ts
|
|
33
36
|
import { serve } from "srvx/node";
|
|
34
37
|
async function serveNode(config) {
|
|
@@ -139,28 +142,28 @@ async function createNodeSocketIOServer(config) {
|
|
|
139
142
|
return createSocketIOServer(config);
|
|
140
143
|
}
|
|
141
144
|
export {
|
|
142
|
-
|
|
143
|
-
serveNode,
|
|
144
|
-
rateLimited,
|
|
145
|
-
notFound,
|
|
146
|
-
implementRegistry,
|
|
147
|
-
implement,
|
|
148
|
-
forbidden,
|
|
149
|
-
createNodeSocketIOServer as createSocketIOServer,
|
|
150
|
-
createScopedImplementRegistry,
|
|
151
|
-
createScopedImplement,
|
|
152
|
-
createMultipartStream,
|
|
153
|
-
createImplementRegistry,
|
|
154
|
-
createImplement,
|
|
155
|
-
createHandler,
|
|
156
|
-
conflict,
|
|
157
|
-
bindRealtimeServer,
|
|
158
|
-
bindProcessSignals,
|
|
159
|
-
badRequest,
|
|
160
|
-
appError,
|
|
161
|
-
ShutdownStatusSchema,
|
|
162
|
-
ShutdownStateSchema,
|
|
163
|
-
ShutdownResultSchema,
|
|
145
|
+
AppError,
|
|
164
146
|
ShutdownOptionsSchema,
|
|
165
|
-
|
|
147
|
+
ShutdownResultSchema,
|
|
148
|
+
ShutdownStateSchema,
|
|
149
|
+
ShutdownStatusSchema,
|
|
150
|
+
appError,
|
|
151
|
+
badRequest,
|
|
152
|
+
bindProcessSignals,
|
|
153
|
+
bindRealtimeServer,
|
|
154
|
+
conflict,
|
|
155
|
+
createHandler,
|
|
156
|
+
createImplement,
|
|
157
|
+
createImplementRegistry,
|
|
158
|
+
createMultipartStream,
|
|
159
|
+
createScopedImplement,
|
|
160
|
+
createScopedImplementRegistry,
|
|
161
|
+
createNodeSocketIOServer as createSocketIOServer,
|
|
162
|
+
forbidden,
|
|
163
|
+
implement,
|
|
164
|
+
implementRegistry,
|
|
165
|
+
notFound,
|
|
166
|
+
rateLimited,
|
|
167
|
+
serveNode,
|
|
168
|
+
unauthorized
|
|
166
169
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HttpMethod, TransportSource } from '../contract';
|
|
1
|
+
import type { HttpMethod, McpCallContext, TransportSource } from '../contract';
|
|
2
2
|
import type { JsonValue } from './sanitize';
|
|
3
3
|
/**
|
|
4
4
|
* A normalised audit event — one shape for a completed call on any surface
|
|
@@ -39,21 +39,7 @@ export interface RequestEvent {
|
|
|
39
39
|
/** Distinguishes a completed operation from an MRTR input-gating round. */
|
|
40
40
|
toolPhase?: 'operation' | 'input-round';
|
|
41
41
|
/** Validated MCP transport attribution, available only on MCP tool calls. */
|
|
42
|
-
mcp?:
|
|
43
|
-
era: 'modern' | 'legacy';
|
|
44
|
-
protocolVersion?: string;
|
|
45
|
-
/** Self-reported host identity from the validated modern envelope. Never auth. */
|
|
46
|
-
clientInfo?: {
|
|
47
|
-
name: string;
|
|
48
|
-
version: string;
|
|
49
|
-
};
|
|
50
|
-
method: string;
|
|
51
|
-
toolName: string;
|
|
52
|
-
/** Semantic outcome of one MRTR attempt. */
|
|
53
|
-
outcome?: 'input_required' | 'declined' | 'cancelled' | 'invalid' | 'complete';
|
|
54
|
-
/** Zero-based MRTR round for this attempt. */
|
|
55
|
-
round?: number;
|
|
56
|
-
};
|
|
42
|
+
mcp?: McpCallContext;
|
|
57
43
|
/** W3C trace id — correlates every span of one logical request. */
|
|
58
44
|
traceId: string;
|
|
59
45
|
/** W3C span id — unique to this call. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/observability/event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC/
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/observability/event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,mCAAmC;IACnC,MAAM,EAAE,eAAe,CAAC;IACxB,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,mCAAmC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2EAA2E;IAC3E,SAAS,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC;IACxC,6EAA6E;IAC7E,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,mEAAmE;IACnE,OAAO,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kCAAkC;IAClC,EAAE,EAAE,OAAO,CAAC;IACZ,6EAA6E;IAC7E,UAAU,EAAE,MAAM,CAAC;IACnB,2BAA2B;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,uEAAuE;IACvE,OAAO,EAAE,SAAS,GAAG,IAAI,CAAC;IAC1B,mDAAmD;IACnD,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,4CAA4C;IAC5C,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yBAAyB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6BAA6B;IAC7B,SAAS,EAAE,IAAI,CAAC;CACjB"}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
redact,
|
|
4
4
|
sanitizePayload,
|
|
5
5
|
truncatePreview
|
|
6
|
-
} from "../index-
|
|
6
|
+
} from "../index-qx84bqzk.js";
|
|
7
7
|
import {
|
|
8
8
|
getRequestContext,
|
|
9
9
|
getTraceId,
|
|
@@ -15,7 +15,9 @@ import {
|
|
|
15
15
|
setRequestError,
|
|
16
16
|
setRequestUser,
|
|
17
17
|
wrapInRequestContext
|
|
18
|
-
} from "../index-
|
|
18
|
+
} from "../index-v4bbq3p4.js";
|
|
19
|
+
import"../index-h60df7rj.js";
|
|
20
|
+
import"../index-6k1937bx.js";
|
|
19
21
|
import {
|
|
20
22
|
childSpan,
|
|
21
23
|
createTraceContext,
|
|
@@ -24,7 +26,8 @@ import {
|
|
|
24
26
|
parseTraceparent,
|
|
25
27
|
resolvePropagationContext,
|
|
26
28
|
resolveTraceContext
|
|
27
|
-
} from "../index-
|
|
29
|
+
} from "../index-7eq9va6e.js";
|
|
30
|
+
import"../index-1bx83sw4.js";
|
|
28
31
|
|
|
29
32
|
// src/observability/status.ts
|
|
30
33
|
import { z } from "zod";
|
|
@@ -376,27 +379,27 @@ function createObservability(config) {
|
|
|
376
379
|
};
|
|
377
380
|
}
|
|
378
381
|
export {
|
|
379
|
-
|
|
380
|
-
truncatePreview,
|
|
381
|
-
setRequestUser,
|
|
382
|
-
setRequestError,
|
|
383
|
-
setRequestEndpoint,
|
|
384
|
-
setRequestDimensions,
|
|
385
|
-
sanitizePayload,
|
|
386
|
-
runWithRequestContext,
|
|
387
|
-
resolveTraceContext,
|
|
388
|
-
resolvePropagationContext,
|
|
389
|
-
redact,
|
|
390
|
-
parseTraceparent,
|
|
391
|
-
measureSize,
|
|
392
|
-
getUserId,
|
|
393
|
-
getTraceId,
|
|
394
|
-
getRequestContext,
|
|
395
|
-
formatTraceparent,
|
|
396
|
-
createTraceContext,
|
|
397
|
-
createObservability,
|
|
398
|
-
childSpan,
|
|
399
|
-
ObservabilityStatusSchema,
|
|
382
|
+
ObservabilityDrainReportSchema,
|
|
400
383
|
ObservabilitySinkStatusSchema,
|
|
401
|
-
|
|
384
|
+
ObservabilityStatusSchema,
|
|
385
|
+
childSpan,
|
|
386
|
+
createObservability,
|
|
387
|
+
createTraceContext,
|
|
388
|
+
formatTraceparent,
|
|
389
|
+
getRequestContext,
|
|
390
|
+
getTraceId,
|
|
391
|
+
getUserId,
|
|
392
|
+
measureSize,
|
|
393
|
+
parseTraceparent,
|
|
394
|
+
redact,
|
|
395
|
+
resolvePropagationContext,
|
|
396
|
+
resolveTraceContext,
|
|
397
|
+
runWithRequestContext,
|
|
398
|
+
sanitizePayload,
|
|
399
|
+
setRequestDimensions,
|
|
400
|
+
setRequestEndpoint,
|
|
401
|
+
setRequestError,
|
|
402
|
+
setRequestUser,
|
|
403
|
+
truncatePreview,
|
|
404
|
+
wrapInRequestContext
|
|
402
405
|
};
|
package/dist/react.js
CHANGED
|
@@ -23,6 +23,15 @@ export type RealtimeEmitArguments<TDefinition extends RealtimeEventDefinition> =
|
|
|
23
23
|
} ? [(value: z.output<TAck>) => void] : [])
|
|
24
24
|
];
|
|
25
25
|
export type RealtimeEventHandler<TDefinition extends RealtimeEventDefinition> = (...args: RealtimeEventArguments<TDefinition>) => void;
|
|
26
|
+
export type RealtimeAcknowledgedEvent<TRegistry extends RealtimeEventRegistry> = {
|
|
27
|
+
[TEvent in keyof TRegistry]: TRegistry[TEvent] extends {
|
|
28
|
+
ack: z.ZodType;
|
|
29
|
+
} ? TEvent : never;
|
|
30
|
+
}[keyof TRegistry] & string;
|
|
31
|
+
export type RealtimeRequestArguments<TDefinition extends RealtimeEventDefinition> = z.input<TDefinition['args']> extends unknown[] ? z.input<TDefinition['args']> : never;
|
|
32
|
+
export type RealtimeAcknowledgement<TDefinition extends RealtimeEventDefinition> = TDefinition extends {
|
|
33
|
+
ack: infer TAck extends z.ZodType;
|
|
34
|
+
} ? z.output<TAck> : never;
|
|
26
35
|
export type InferRealtimeEventMap<TRegistry extends RealtimeEventRegistry> = {
|
|
27
36
|
[TEvent in keyof TRegistry]: RealtimeEventHandler<TRegistry[TEvent]>;
|
|
28
37
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/realtime/contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,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BAAiB,CAAC;AAEtB,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,uBAAuB,CAAC;IACnC,KAAK,EAAE,WAAW,GAAG,iBAAiB,CAAC;IACvC,MAAM,EACF,eAAe,GACf,mBAAmB,GACnB,+BAA+B,GAC/B,yBAAyB,CAAC;IAC9B,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IACxB,KAAK,EAAE,QAAQ,CAAC,6BAA6B,CAAC,CAAC;CAChD;AAED,MAAM,MAAM,yBAAyB,GAAG,CACtC,QAAQ,EAAE,qBAAqB,KAC5B,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
package/dist/realtime/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export { defineRealtimeContract, type InferRealtimeEventMap, type RealtimeContract, type RealtimeEmitArguments, type RealtimeEventArguments, type RealtimeEventDefinition, type RealtimeEventHandler, type RealtimeEventRegistry, type RealtimeRejectDirection, type RealtimeRejectedEvent, type RealtimeRejectedEventHook, } from './contract';
|
|
1
|
+
export { defineRealtimeContract, type InferRealtimeEventMap, type RealtimeAcknowledgedEvent, type RealtimeAcknowledgement, type RealtimeContract, type RealtimeEmitArguments, type RealtimeEventArguments, type RealtimeEventDefinition, type RealtimeEventHandler, type RealtimeEventRegistry, type RealtimeRejectDirection, type RealtimeRejectedEvent, type RealtimeRejectedEventHook, type RealtimeRequestArguments, } from './contract';
|
|
2
|
+
export { RealtimeRequestDisconnectedError, RealtimeRequestInvalidAcknowledgementError, type RealtimeRequestOptions, RealtimeRequestTimeoutError, } from './request';
|
|
2
3
|
export type { ValidatedRealtimeSocket } from './socket';
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/realtime/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/realtime/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,GAC9B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,gCAAgC,EAChC,0CAA0C,EAC1C,KAAK,sBAAsB,EAC3B,2BAA2B,GAC5B,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface RealtimeRequestOptions {
|
|
2
|
+
/** Maximum acknowledgement wait in milliseconds. Must be finite and > 0. */
|
|
3
|
+
timeoutMs: number;
|
|
4
|
+
}
|
|
5
|
+
export declare class RealtimeRequestTimeoutError extends Error {
|
|
6
|
+
readonly code = "REALTIME_REQUEST_TIMEOUT";
|
|
7
|
+
readonly event: string;
|
|
8
|
+
readonly timeoutMs: number;
|
|
9
|
+
constructor(event: string, timeoutMs: number);
|
|
10
|
+
}
|
|
11
|
+
export declare class RealtimeRequestDisconnectedError extends Error {
|
|
12
|
+
readonly code = "REALTIME_REQUEST_DISCONNECTED";
|
|
13
|
+
readonly event: string;
|
|
14
|
+
constructor(event: string);
|
|
15
|
+
}
|
|
16
|
+
export declare class RealtimeRequestInvalidAcknowledgementError extends Error {
|
|
17
|
+
readonly code = "REALTIME_REQUEST_INVALID_ACKNOWLEDGEMENT";
|
|
18
|
+
readonly event: string;
|
|
19
|
+
constructor(event: string, cause: unknown);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/realtime/request.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,sBAAsB;IACrC,4EAA4E;IAC5E,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,QAAQ,CAAC,IAAI,8BAA8B;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,YAAY,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAK3C;CACF;AAED,qBAAa,gCAAiC,SAAQ,KAAK;IACzD,QAAQ,CAAC,IAAI,mCAAmC;IAChD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,YAAY,KAAK,EAAE,MAAM,EAIxB;CACF;AAED,qBAAa,0CAA2C,SAAQ,KAAK;IACnE,QAAQ,CAAC,IAAI,8CAA8C;IAC3D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,YAAY,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAIxC;CACF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
1
2
|
import type { StitchLogger } from '../logger';
|
|
2
3
|
import type { RealtimeEmitArguments, RealtimeEventHandler, RealtimeEventRegistry, RealtimeRejectDirection, RealtimeRejectedEventHook } from './contract';
|
|
3
4
|
interface ValidatedRealtimeSocketOptions<TInbound extends RealtimeEventRegistry, TOutbound extends RealtimeEventRegistry> {
|
|
@@ -32,6 +33,8 @@ export interface ValidatedRealtimeSocket<TInbound extends RealtimeEventRegistry,
|
|
|
32
33
|
*/
|
|
33
34
|
emit<TEvent extends keyof TOutbound & string>(event: TEvent, ...args: RealtimeEmitArguments<TOutbound[TEvent]>): boolean;
|
|
34
35
|
}
|
|
36
|
+
export declare function parseRealtimeRequestArguments(registry: RealtimeEventRegistry, event: string, direction: RealtimeRejectDirection, args: unknown[]): unknown[];
|
|
37
|
+
export declare function parseRealtimeRequestAcknowledgement<TAck extends z.ZodType>(schema: TAck, event: string, direction: RealtimeRejectDirection, value: unknown, hook: RealtimeRejectedEventHook | undefined, logger: StitchLogger | undefined): z.output<TAck>;
|
|
35
38
|
export declare function createValidatedRealtimeSocket<const TInbound extends RealtimeEventRegistry, const TOutbound extends RealtimeEventRegistry>({ target, inbound, outbound, inboundDirection, outboundDirection, onRejected, logger, subscribe, }: ValidatedRealtimeSocketOptions<TInbound, TOutbound>): ValidatedRealtimeSocket<TInbound, TOutbound>;
|
|
36
39
|
export {};
|
|
37
40
|
//# sourceMappingURL=socket.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../../src/realtime/socket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EACV,qBAAqB,EAErB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EAEvB,yBAAyB,EAC1B,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../../src/realtime/socket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EACV,qBAAqB,EAErB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EAEvB,yBAAyB,EAC1B,MAAM,YAA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ACb,SAAS,EAAE,uBAAuB,EAClC,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,yBAAyB,GAAG,SAAS,EAC3C,MAAM,EAAE,YAAY,GAAG,SAAS,GAC/B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAahB;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,CAAC,QAAQ,SAAS,qBAAqB,EAC5C,KAAK,CAAC,SAAS,SAAS,qBAAqB,EAC7C,EACA,MAAM,EACN,OAAO,EACP,QAAQ,EACR,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,MAAM,EACN,SAAS,GACV,EAAE,8BAA8B,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,uBAAuB,CAC9E,QAAQ,EACR,SAAS,CACV,CA+HA"}
|
package/dist/remote.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `stitchkit/remote` — peer-free remote service implementation.
|
|
3
|
+
*
|
|
4
|
+
* `implementRemote` needs only the contract and HTTP client. Keeping it in its
|
|
5
|
+
* own entrypoint lets CLI and other thin processes proxy a deployed API without
|
|
6
|
+
* importing the MCP SDK or the AI SDK through the broad tools barrel.
|
|
7
|
+
*/
|
|
8
|
+
export { type ImplementRemoteOptions, implementRemote } from './tools/remote';
|
|
9
|
+
//# sourceMappingURL=remote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../src/remote.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,KAAK,sBAAsB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/remote.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ApiError,
|
|
3
|
+
createClient
|
|
4
|
+
} from "./index-qh4xevf5.js";
|
|
5
|
+
import"./index-48ffdxgk.js";
|
|
6
|
+
import {
|
|
7
|
+
AppError,
|
|
8
|
+
mergeMeta
|
|
9
|
+
} from "./index-h60df7rj.js";
|
|
10
|
+
import"./index-6k1937bx.js";
|
|
11
|
+
import {
|
|
12
|
+
isRecord
|
|
13
|
+
} from "./index-7eq9va6e.js";
|
|
14
|
+
import"./index-1bx83sw4.js";
|
|
15
|
+
|
|
16
|
+
// src/tools/remote.ts
|
|
17
|
+
var HTTP_ONLY = Object.freeze(["HTTP"]);
|
|
18
|
+
function toArgs(ctx) {
|
|
19
|
+
const { params, input } = ctx;
|
|
20
|
+
return {
|
|
21
|
+
...isRecord(params) ? params : {},
|
|
22
|
+
...isRecord(input) ? input : {}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function implementRemote(contract, http, options) {
|
|
26
|
+
const client = createClient(contract, http);
|
|
27
|
+
const groupScope = contract.meta.scope ?? "public";
|
|
28
|
+
const methods = {};
|
|
29
|
+
for (const [key, endpoint] of Object.entries(contract.endpoints)) {
|
|
30
|
+
methods[key] = {
|
|
31
|
+
method: endpoint.method,
|
|
32
|
+
path: endpoint.path,
|
|
33
|
+
desc: endpoint.desc,
|
|
34
|
+
serviceName: contract.meta.prefix,
|
|
35
|
+
key,
|
|
36
|
+
toolName: "toolName" in endpoint ? endpoint.toolName : undefined,
|
|
37
|
+
expose: endpoint.rawResponse || endpoint.rawBody || endpoint.responseMeta ? HTTP_ONLY : endpoint.expose,
|
|
38
|
+
ui: "ui" in endpoint ? endpoint.ui : undefined,
|
|
39
|
+
annotations: "annotations" in endpoint ? endpoint.annotations : undefined,
|
|
40
|
+
meta: mergeMeta(contract.meta.meta, endpoint.meta),
|
|
41
|
+
scope: endpoint.scope ?? groupScope,
|
|
42
|
+
paramsSchema: endpoint.params,
|
|
43
|
+
inputSchema: endpoint.input,
|
|
44
|
+
outputSchema: endpoint.output,
|
|
45
|
+
multipart: endpoint.multipart,
|
|
46
|
+
maxJsonBodyBytes: endpoint.maxJsonBodyBytes,
|
|
47
|
+
idempotent: endpoint.idempotent,
|
|
48
|
+
rawResponse: endpoint.rawResponse,
|
|
49
|
+
rawBody: endpoint.rawBody,
|
|
50
|
+
responseMeta: endpoint.responseMeta,
|
|
51
|
+
contentType: "contentType" in endpoint ? endpoint.contentType : undefined,
|
|
52
|
+
handler: async (ctx) => {
|
|
53
|
+
const call = client[key];
|
|
54
|
+
if (!call) {
|
|
55
|
+
throw new Error(`implementRemote: endpoint "${key}" is not exposed over HTTP`);
|
|
56
|
+
}
|
|
57
|
+
const args = toArgs(ctx);
|
|
58
|
+
try {
|
|
59
|
+
const finalArgs = options?.transformArgs ? await options.transformArgs(key, args) : args;
|
|
60
|
+
return await call(finalArgs);
|
|
61
|
+
} catch (err) {
|
|
62
|
+
if (ApiError.is(err)) {
|
|
63
|
+
throw new AppError(err.code, err.message, err.status, isRecord(err.details) ? err.details : undefined, err.hint, err.traceId);
|
|
64
|
+
}
|
|
65
|
+
throw err;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
name: contract.meta.prefix,
|
|
72
|
+
prefix: contract.meta.prefix,
|
|
73
|
+
scope: groupScope,
|
|
74
|
+
methods
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
implementRemote
|
|
79
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RuntimeContext } from '../contract';
|
|
2
|
+
/** Keys whose value is owned by a transport/runtime boundary, never by application enrichment. */
|
|
3
|
+
export declare const RUNTIME_CONTEXT_RESERVED_KEYS: Set<string>;
|
|
4
|
+
/**
|
|
5
|
+
* Validate the complete contribution before mutating the runtime context.
|
|
6
|
+
* Accessors, exotic prototypes and transport-owned keys fail closed so a
|
|
7
|
+
* rejected contribution can never leave a partial or poisoned context.
|
|
8
|
+
*/
|
|
9
|
+
export declare function mergeContextContribution(ctx: RuntimeContext, value: unknown, scope: string): void;
|
|
10
|
+
//# sourceMappingURL=context-contribution.d.ts.map
|