stitchkit 0.55.0 → 0.56.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 (69) hide show
  1. package/dist/browser/socket-io.d.ts +14 -6
  2. package/dist/browser/socket-io.d.ts.map +1 -1
  3. package/dist/cli.js +4 -4
  4. package/dist/contract/errors.d.ts +7 -0
  5. package/dist/contract/errors.d.ts.map +1 -1
  6. package/dist/contract/index.js +1 -1
  7. package/dist/files/boundary.d.ts +8 -5
  8. package/dist/files/boundary.d.ts.map +1 -1
  9. package/dist/files.js +1 -1
  10. package/dist/{index-rgd18hx3.js → index-28cqssm3.js} +7 -0
  11. package/dist/index-557by2db.js +34 -0
  12. package/dist/index-5r13htq1.js +283 -0
  13. package/dist/index-6y759j86.js +1031 -0
  14. package/dist/{index-1k16zv57.js → index-bfcpjw20.js} +125 -31
  15. package/dist/{index-0gv7k0ra.js → index-escqg10p.js} +73 -666
  16. package/dist/{index-v4bbq3p4.js → index-j3dem06f.js} +1 -1
  17. package/dist/{index-qx84bqzk.js → index-jcc611vh.js} +1 -1
  18. package/dist/{index-npye5kt7.js → index-n4nfa7gh.js} +3 -3
  19. package/dist/{index-pzc32v75.js → index-sm2tjx06.js} +41 -4
  20. package/dist/{index-js7yexng.js → index-xy8fmh6w.js} +83 -4
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +27 -6
  24. package/dist/node.js +5 -4
  25. package/dist/observability/index.js +3 -3
  26. package/dist/remote.js +1 -1
  27. package/dist/server/context-contribution.d.ts +8 -0
  28. package/dist/server/context-contribution.d.ts.map +1 -1
  29. package/dist/server/index.d.ts +1 -1
  30. package/dist/server/index.d.ts.map +1 -1
  31. package/dist/server/index.js +8 -5
  32. package/dist/server/middleware/auth.d.ts +29 -2
  33. package/dist/server/middleware/auth.d.ts.map +1 -1
  34. package/dist/testing/surface-conformance.d.ts +143 -10
  35. package/dist/testing/surface-conformance.d.ts.map +1 -1
  36. package/dist/testing/surface-manifest.d.ts +132 -33
  37. package/dist/testing/surface-manifest.d.ts.map +1 -1
  38. package/dist/testing.d.ts +2 -2
  39. package/dist/testing.d.ts.map +1 -1
  40. package/dist/testing.js +470 -122
  41. package/dist/tools/async-operation.d.ts +210 -18
  42. package/dist/tools/async-operation.d.ts.map +1 -1
  43. package/dist/tools/define-download-tool.d.ts.map +1 -1
  44. package/dist/tools/define-upload-tool.d.ts.map +1 -1
  45. package/dist/tools/internal/surface-projector.d.ts +101 -0
  46. package/dist/tools/internal/surface-projector.d.ts.map +1 -0
  47. package/dist/tools/managed-file-error.d.ts +6 -0
  48. package/dist/tools/managed-file-error.d.ts.map +1 -0
  49. package/dist/tools/mcp-prepare.d.ts +3 -21
  50. package/dist/tools/mcp-prepare.d.ts.map +1 -1
  51. package/dist/tools/mcp-round-policy.d.ts +9 -0
  52. package/dist/tools/mcp-round-policy.d.ts.map +1 -0
  53. package/dist/tools/mcp-round.d.ts +0 -4
  54. package/dist/tools/mcp-round.d.ts.map +1 -1
  55. package/dist/tools/mount-download.d.ts.map +1 -1
  56. package/dist/tools/mount-upload.d.ts.map +1 -1
  57. package/dist/tools/mount.d.ts +5 -9
  58. package/dist/tools/mount.d.ts.map +1 -1
  59. package/dist/tools/runtime-tool.d.ts.map +1 -1
  60. package/dist/tools/surface.d.ts +7 -0
  61. package/dist/tools/surface.d.ts.map +1 -1
  62. package/dist/tools/view-file.d.ts.map +1 -1
  63. package/dist/tools.d.ts +1 -1
  64. package/dist/tools.d.ts.map +1 -1
  65. package/dist/tools.js +348 -383
  66. package/llms-full.txt +361 -58
  67. package/package.json +1 -1
  68. package/dist/index-h60df7rj.js +0 -110
  69. package/dist/index-k4dftwf7.js +0 -66
@@ -1,110 +0,0 @@
1
- // src/contract/errors.ts
2
- var APP_ERROR_BRAND = Symbol.for("stitchkit.AppError");
3
-
4
- class AppError extends Error {
5
- code;
6
- status;
7
- details;
8
- hint;
9
- traceId;
10
- constructor(code, message, status = 500, details, hint, traceId) {
11
- super(message ?? code);
12
- this.code = code;
13
- this.status = status;
14
- this.details = details;
15
- this.hint = hint;
16
- this.traceId = traceId;
17
- this.name = "AppError";
18
- Object.defineProperty(this, APP_ERROR_BRAND, { value: true });
19
- }
20
- static is(err) {
21
- return typeof err === "object" && err !== null && APP_ERROR_BRAND in err;
22
- }
23
- toJSON() {
24
- return {
25
- error: {
26
- code: this.code,
27
- message: this.message,
28
- ...this.details && { details: this.details },
29
- ...this.hint && { hint: this.hint }
30
- }
31
- };
32
- }
33
- }
34
- function notFound(message = "Not found") {
35
- throw new AppError("NOT_FOUND", message, 404);
36
- }
37
- function badRequest(message, details) {
38
- throw new AppError("BAD_REQUEST", message, 400, details);
39
- }
40
- function unauthorized(message = "Unauthorized") {
41
- throw new AppError("UNAUTHORIZED", message, 401);
42
- }
43
- function forbidden(message = "Forbidden") {
44
- throw new AppError("FORBIDDEN", message, 403);
45
- }
46
- function conflict(message = "Conflict", details) {
47
- throw new AppError("CONFLICT", message, 409, details);
48
- }
49
- function rateLimited(message = "Too many requests") {
50
- throw new AppError("RATE_LIMITED", message, 429);
51
- }
52
- var STITCH_ERROR_STATUS = {
53
- BAD_REQUEST: 400,
54
- UNAUTHORIZED: 401,
55
- FORBIDDEN: 403,
56
- NOT_FOUND: 404,
57
- METHOD_NOT_ALLOWED: 405,
58
- CONFLICT: 409,
59
- RATE_LIMITED: 429,
60
- VALIDATION_ERROR: 400,
61
- REALTIME_CONTRACT_VIOLATION: 500,
62
- INTERNAL_SERVER_ERROR: 500
63
- };
64
- function isStitchErrorCode(code) {
65
- return Object.hasOwn(STITCH_ERROR_STATUS, code);
66
- }
67
- function appError(code, message, details) {
68
- throw new AppError(code, message, isStitchErrorCode(code) ? STITCH_ERROR_STATUS[code] : 500, details);
69
- }
70
-
71
- // src/contract/define.ts
72
- import { z } from "zod";
73
-
74
- // src/internal/safe-json.ts
75
- function isUnsafeKey(key) {
76
- return key === "__proto__";
77
- }
78
- function safeJsonParse(text) {
79
- return JSON.parse(text, (key, value) => isUnsafeKey(key) ? undefined : value);
80
- }
81
-
82
- // src/contract/define.ts
83
- function mergeMeta(contractMeta, endpointMeta) {
84
- if (!contractMeta)
85
- return endpointMeta;
86
- if (!endpointMeta)
87
- return { ...contractMeta };
88
- return { ...contractMeta, ...endpointMeta };
89
- }
90
- // src/contract/errors-factory.ts
91
- import { z as z2 } from "zod";
92
- // src/contract/pagination.ts
93
- import { z as z3 } from "zod";
94
-
95
- // src/internal/base64url.ts
96
- function bytesToBase64Url(bytes) {
97
- let binary = "";
98
- for (const byte of bytes)
99
- binary += String.fromCharCode(byte);
100
- return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
101
- }
102
- function base64UrlToBytes(segment) {
103
- if (!/^[A-Za-z0-9_-]*$/.test(segment) || segment.length % 4 === 1) {
104
- throw new Error("invalid base64url segment");
105
- }
106
- const b64 = segment.replace(/-/g, "+").replace(/_/g, "/");
107
- const padded = b64.padEnd(Math.ceil(b64.length / 4) * 4, "=");
108
- return Uint8Array.from(atob(padded), (c) => c.charCodeAt(0));
109
- }
110
- export { isUnsafeKey, safeJsonParse, mergeMeta, AppError, notFound, badRequest, unauthorized, forbidden, conflict, rateLimited, STITCH_ERROR_STATUS, isStitchErrorCode, appError, bytesToBase64Url, base64UrlToBytes };
@@ -1,66 +0,0 @@
1
- // src/tools/names.ts
2
- var SINGULAR_EXCEPTIONS = new Set([
3
- "analytics",
4
- "status",
5
- "stats",
6
- "settings",
7
- "media",
8
- "progress",
9
- "news"
10
- ]);
11
- var TOOL_NAME_RE = /^[a-zA-Z0-9_-]{1,64}$/;
12
- function normalizeService(value) {
13
- return value.replace(/[^a-zA-Z0-9_]/g, "_");
14
- }
15
- function normalizeMethod(value) {
16
- return value.replace(/[^a-zA-Z0-9_-]/g, "_");
17
- }
18
- function singularize(name) {
19
- if (SINGULAR_EXCEPTIONS.has(name))
20
- return name;
21
- if (name.endsWith("ies"))
22
- return `${name.slice(0, -3)}y`;
23
- if (name.endsWith("s") && !name.endsWith("ss"))
24
- return name.slice(0, -1);
25
- return name;
26
- }
27
- function singularizeTail(name) {
28
- const cut = name.lastIndexOf("_");
29
- if (cut === -1)
30
- return singularize(name);
31
- return `${name.slice(0, cut + 1)}${singularize(name.slice(cut + 1))}`;
32
- }
33
- function hasUsableChars(value) {
34
- return /[a-zA-Z0-9]/.test(value);
35
- }
36
- function assertToolName(name, serviceName, key) {
37
- const where = `service "${serviceName}", method "${key}"`;
38
- if (!TOOL_NAME_RE.test(name)) {
39
- const why = name.length > 64 ? `is ${name.length} characters (max 64) — set an explicit \`toolName\`` : "must match [a-zA-Z0-9_-]";
40
- throw new Error(`Tool name "${name}" (${where}) ${why}`);
41
- }
42
- }
43
- function toToolName(serviceName, methodName) {
44
- const normalized = normalizeService(serviceName);
45
- const singular = singularizeTail(normalized);
46
- const method = normalizeMethod(methodName);
47
- if (method === "list")
48
- return `list_${normalized}`;
49
- if (method === "get")
50
- return `get_${singular}`;
51
- if (method === "create")
52
- return `create_${singular}`;
53
- if (method === "update")
54
- return `update_${singular}`;
55
- if (method === "delete")
56
- return `delete_${singular}`;
57
- const snake = method.replace(/([A-Z])/g, "_$1").toLowerCase();
58
- return `${snake}_${singular}`.replace(/^_/, "");
59
- }
60
- function assertUniqueToolName(name, taken, surface) {
61
- if (taken) {
62
- throw new Error(`Duplicate ${surface} "${name}" across mounted operations`);
63
- }
64
- }
65
-
66
- export { hasUsableChars, assertToolName, toToolName, assertUniqueToolName };