stitchkit 0.70.5 → 0.71.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 (76) hide show
  1. package/dist/agent-runtime/coding-tool-contract.d.ts +11 -1
  2. package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -1
  3. package/dist/agent-runtime/coding-tool-files.d.ts.map +1 -1
  4. package/dist/agent-runtime/coding-tool-listing.d.ts +15 -0
  5. package/dist/agent-runtime/coding-tool-listing.d.ts.map +1 -0
  6. package/dist/agent-runtime/coding-tool-paths.d.ts.map +1 -1
  7. package/dist/agent-runtime/coding-tool-refusals.d.ts +59 -0
  8. package/dist/agent-runtime/coding-tool-refusals.d.ts.map +1 -0
  9. package/dist/agent-runtime/coding-tool-search-patch.d.ts.map +1 -1
  10. package/dist/agent-runtime/coding-tools.d.ts +3 -1
  11. package/dist/agent-runtime/coding-tools.d.ts.map +1 -1
  12. package/dist/agent-runtime/compaction.d.ts +35 -0
  13. package/dist/agent-runtime/compaction.d.ts.map +1 -1
  14. package/dist/agent-runtime/contained-files.d.ts +21 -2
  15. package/dist/agent-runtime/contained-files.d.ts.map +1 -1
  16. package/dist/agent-runtime/provider-failure.d.ts +66 -0
  17. package/dist/agent-runtime/provider-failure.d.ts.map +1 -0
  18. package/dist/agent-runtime/purge.d.ts +28 -0
  19. package/dist/agent-runtime/purge.d.ts.map +1 -0
  20. package/dist/agent-runtime/run-execution.d.ts.map +1 -1
  21. package/dist/agent-runtime/runtime.d.ts +31 -1
  22. package/dist/agent-runtime/runtime.d.ts.map +1 -1
  23. package/dist/agent-runtime/schemas.d.ts +1 -0
  24. package/dist/agent-runtime/schemas.d.ts.map +1 -1
  25. package/dist/agent-runtime/sqlite-purge.d.ts +7 -0
  26. package/dist/agent-runtime/sqlite-purge.d.ts.map +1 -0
  27. package/dist/agent-runtime/sqlite.d.ts.map +1 -1
  28. package/dist/agent-runtime/store-driver.d.ts +2 -0
  29. package/dist/agent-runtime/store-driver.d.ts.map +1 -1
  30. package/dist/agent-runtime/store-purge.d.ts +13 -0
  31. package/dist/agent-runtime/store-purge.d.ts.map +1 -0
  32. package/dist/agent-runtime/store.d.ts +3 -0
  33. package/dist/agent-runtime/store.d.ts.map +1 -1
  34. package/dist/agent-runtime-coding-tools.js +438 -124
  35. package/dist/agent-runtime-harness.js +4 -4
  36. package/dist/agent-runtime-openrouter.d.ts +19 -0
  37. package/dist/agent-runtime-openrouter.d.ts.map +1 -1
  38. package/dist/agent-runtime-openrouter.js +2 -1
  39. package/dist/agent-runtime-sqlite-bun.js +2 -2
  40. package/dist/agent-runtime-sqlite-node.js +2 -2
  41. package/dist/agent-runtime.d.ts +5 -2
  42. package/dist/agent-runtime.d.ts.map +1 -1
  43. package/dist/agent-runtime.js +128 -16
  44. package/dist/cli.js +5 -5
  45. package/dist/{index-cx84zg25.js → index-118v0z41.js} +1 -1
  46. package/dist/{index-jw81xr75.js → index-19eet1qx.js} +127 -51
  47. package/dist/{index-ejv31h14.js → index-7qy2ex0m.js} +1 -1
  48. package/dist/{index-9sx8tbz2.js → index-cksjz4eg.js} +50 -1
  49. package/dist/{index-trrf7nch.js → index-ezmn6ac6.js} +3 -3
  50. package/dist/{index-ekkt4gy9.js → index-jqtsc9mj.js} +2 -2
  51. package/dist/{index-hxtm2xr2.js → index-k2zczx1g.js} +1 -1
  52. package/dist/{index-35wcrke5.js → index-m668wzyc.js} +13 -2
  53. package/dist/{index-w9m1wznn.js → index-nemjkxjp.js} +118 -1
  54. package/dist/{index-tnazr5tc.js → index-pz7ytdga.js} +3 -3
  55. package/dist/{index-1z5xxfst.js → index-rqpdar1e.js} +102 -5
  56. package/dist/{index-qm87g51s.js → index-s4c8wy8m.js} +1 -1
  57. package/dist/node.js +2 -2
  58. package/dist/observability/index.js +1 -1
  59. package/dist/server/index.d.ts +1 -1
  60. package/dist/server/index.d.ts.map +1 -1
  61. package/dist/server/index.js +4 -2
  62. package/dist/server/request.d.ts +19 -0
  63. package/dist/server/request.d.ts.map +1 -1
  64. package/dist/telegram/init-data.d.ts +134 -0
  65. package/dist/telegram/init-data.d.ts.map +1 -0
  66. package/dist/telegram/send-failure.d.ts +73 -0
  67. package/dist/telegram/send-failure.d.ts.map +1 -0
  68. package/dist/telegram.d.ts +3 -0
  69. package/dist/telegram.d.ts.map +1 -0
  70. package/dist/telegram.js +224 -0
  71. package/dist/tool-invoker.js +4 -4
  72. package/dist/tools.js +7 -7
  73. package/llms-full.txt +332 -9
  74. package/native/darwin-arm64.node +0 -0
  75. package/native/darwin-x64.node +0 -0
  76. package/package.json +6 -2
@@ -8,7 +8,16 @@ import {
8
8
  read as readDescriptor,
9
9
  write as writeDescriptor
10
10
  } from "node:fs";
11
- import { lstat, open, readdir, realpath, rename, unlink, writeFile } from "node:fs/promises";
11
+ import {
12
+ lstat,
13
+ mkdir,
14
+ open,
15
+ readdir,
16
+ realpath,
17
+ rename,
18
+ unlink,
19
+ writeFile
20
+ } from "node:fs/promises";
12
21
  import { createRequire } from "node:module";
13
22
  import path from "node:path";
14
23
  import { fileURLToPath } from "node:url";
@@ -41,6 +50,7 @@ function loadDarwinBinding() {
41
50
  "openDirectoryAt",
42
51
  "openFileAt",
43
52
  "createFileAt",
53
+ "createDirectoryAt",
44
54
  "statAt",
45
55
  "listAt",
46
56
  "renameAt",
@@ -120,9 +130,10 @@ async function openFileAt(directory, name) {
120
130
  }
121
131
  return open(path.join(descriptorPath(directory), name), constants.O_RDONLY | constants.O_NOFOLLOW);
122
132
  }
123
- function entryMetadata(mode) {
133
+ function entryMetadata(mode, size) {
124
134
  return {
125
135
  mode,
136
+ ...size !== undefined && { size },
126
137
  isDirectory: () => modeIs(mode, FILE_TYPE_DIRECTORY),
127
138
  isFile: () => modeIs(mode, FILE_TYPE_REGULAR),
128
139
  isSymbolicLink: () => modeIs(mode, FILE_TYPE_SYMLINK)
@@ -131,7 +142,7 @@ function entryMetadata(mode) {
131
142
  async function statAt(directory, name) {
132
143
  if (process.platform === "darwin") {
133
144
  const metadata = loadDarwinBinding().statAt(directory.fd, name);
134
- return metadata ? entryMetadata(metadata.mode) : null;
145
+ return metadata ? entryMetadata(metadata.mode, metadata.size) : null;
135
146
  }
136
147
  return lstat(path.join(descriptorPath(directory), name)).catch((error) => {
137
148
  if (error.code === "ENOENT")
@@ -145,7 +156,91 @@ async function listAt(directory) {
145
156
  }
146
157
  return readdir(descriptorPath(directory), { withFileTypes: true });
147
158
  }
148
- async function openContainedParent(root, relative) {
159
+ async function listContainedDirectory(root, relative, maxEntries) {
160
+ let current = await openPinnedDirectory(root);
161
+ try {
162
+ if (relative !== ".") {
163
+ for (const segment of safeSegments(relative)) {
164
+ const next = await openDirectoryAt(current, segment);
165
+ const metadata = await next.stat();
166
+ if (!metadata.isDirectory()) {
167
+ await next.close();
168
+ throw new Error("Contained ancestor is not a directory");
169
+ }
170
+ await current.close();
171
+ current = next;
172
+ }
173
+ }
174
+ const raw = [...await listAt(current)];
175
+ raw.sort((left, right) => left.name.localeCompare(right.name));
176
+ const entries = [];
177
+ for (const entry of raw.slice(0, maxEntries)) {
178
+ const kind = entry.isDirectory() ? "directory" : entry.isSymbolicLink() ? "symlink" : entry.isFile() ? "file" : "other";
179
+ if (kind !== "file") {
180
+ entries.push({ name: entry.name, kind });
181
+ continue;
182
+ }
183
+ const metadata = await statAt(current, entry.name);
184
+ entries.push({
185
+ name: entry.name,
186
+ kind,
187
+ ...metadata && { bytes: metadata.size }
188
+ });
189
+ }
190
+ entries.sort((left, right) => {
191
+ if (left.kind === right.kind)
192
+ return left.name.localeCompare(right.name);
193
+ return left.kind === "directory" ? -1 : right.kind === "directory" ? 1 : 0;
194
+ });
195
+ return { entries, truncated: raw.length > maxEntries };
196
+ } finally {
197
+ await current.close();
198
+ }
199
+ }
200
+ async function createDirectoryAt(directory, name) {
201
+ if (process.platform === "darwin") {
202
+ return loadDarwinBinding().createDirectoryAt(directory.fd, name, 511);
203
+ }
204
+ try {
205
+ await mkdir(path.join(descriptorPath(directory), name));
206
+ return true;
207
+ } catch (error) {
208
+ if (error.code === "EEXIST")
209
+ return false;
210
+ throw error;
211
+ }
212
+ }
213
+ async function missingContainedDirectories(root, relative) {
214
+ const segments = safeSegments(relative);
215
+ segments.pop();
216
+ const missing = [];
217
+ let current = await openPinnedDirectory(root);
218
+ try {
219
+ let walked = [];
220
+ for (const segment of segments) {
221
+ walked = [...walked, segment];
222
+ if (missing.length > 0) {
223
+ missing.push(walked.join(path.sep));
224
+ continue;
225
+ }
226
+ const next = await openDirectoryAt(current, segment).catch((error) => {
227
+ if (error.code === "ENOENT")
228
+ return null;
229
+ throw error;
230
+ });
231
+ if (!next) {
232
+ missing.push(walked.join(path.sep));
233
+ continue;
234
+ }
235
+ await current.close();
236
+ current = next;
237
+ }
238
+ return missing;
239
+ } finally {
240
+ await current.close();
241
+ }
242
+ }
243
+ async function openContainedParent(root, relative, options = {}) {
149
244
  const segments = safeSegments(relative);
150
245
  const basename = segments.pop();
151
246
  if (!basename)
@@ -153,6 +248,8 @@ async function openContainedParent(root, relative) {
153
248
  let current = await openPinnedDirectory(root);
154
249
  try {
155
250
  for (const segment of segments) {
251
+ if (options.create)
252
+ await createDirectoryAt(current, segment);
156
253
  const next = await openDirectoryAt(current, segment);
157
254
  const metadata = await next.stat();
158
255
  if (!metadata.isDirectory()) {
@@ -394,4 +491,4 @@ async function scanContainedFiles(input) {
394
491
  return { files, truncated, skippedDirectories, skippedSymlinks };
395
492
  }
396
493
 
397
- export { openContainedParent, openContainedFile, assertContainedFileCurrent, assertContainedParentCurrent, writeContainedFile, containedEntryMetadata, openContainedParentFile, readContainedUtf8Handle, walkContainedFiles, scanContainedFiles };
494
+ export { listContainedDirectory, missingContainedDirectories, openContainedParent, openContainedFile, assertContainedFileCurrent, assertContainedParentCurrent, writeContainedFile, containedEntryMetadata, openContainedParentFile, readContainedUtf8Handle, walkContainedFiles, scanContainedFiles };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getRequestContext,
3
3
  runWithRequestContext
4
- } from "./index-w9m1wznn.js";
4
+ } from "./index-nemjkxjp.js";
5
5
  import {
6
6
  objectShapeKeys
7
7
  } from "./index-22by16v6.js";
package/dist/node.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  createHandler,
6
6
  createSocketIOServer,
7
7
  createUnixClientTransport
8
- } from "./index-cx84zg25.js";
8
+ } from "./index-118v0z41.js";
9
9
  import {
10
10
  createImplement,
11
11
  createImplementRegistry,
@@ -15,7 +15,7 @@ import {
15
15
  implement,
16
16
  implementRegistry
17
17
  } from "./index-vbf2p6me.js";
18
- import"./index-w9m1wznn.js";
18
+ import"./index-nemjkxjp.js";
19
19
  import"./index-7b188kmz.js";
20
20
  import {
21
21
  ShutdownOptionsSchema,
@@ -21,7 +21,7 @@ import {
21
21
  setRequestError,
22
22
  setRequestUser,
23
23
  wrapInRequestContext
24
- } from "../index-w9m1wznn.js";
24
+ } from "../index-nemjkxjp.js";
25
25
  import {
26
26
  childSpan,
27
27
  createTraceContext,
@@ -20,7 +20,7 @@ export { bindProcessSignals, type ProcessSignalName, type ProcessSignalsBinding,
20
20
  export { createRateLimiter, type RateLimitConfig } from './rate-limit.js';
21
21
  export { errorResponse, parseBody, respondJson } from './raw.js';
22
22
  export { bindRealtimeServer, type RealtimeServer, type RealtimeServerConnection, type RealtimeServerHandle, } from './realtime.js';
23
- export { type ClientIpOptions, extractIp, generateTraceId, getClientInfo, resolveSocketIp, resolveTraceId, } from './request.js';
23
+ export { type ClientIpOptions, extractIp, generateTraceId, getClientInfo, isPublicIp, resolveSocketIp, resolveTraceId, } from './request.js';
24
24
  export { type ManagedServerHandle, type ShutdownOptions, ShutdownOptionsSchema, type ShutdownResult, ShutdownResultSchema, type ShutdownState, ShutdownStateSchema, type ShutdownStatus, ShutdownStatusSchema, } from './shutdown.js';
25
25
  export type { SocketIOHandshakeConfig, SocketIOPeerLoaders, SocketIORequestPolicy, SocketIOServerConfig, SocketIOServerHandle, SocketIOServerLifecycle, } from './socket-io.js';
26
26
  export { createSocketIOServer, socketIoLane } from './socket-io.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,KAAK,eAAe,EACpB,YAAY,GACb,MAAM,aAAa,CAAC;AAIrB,OAAO,EACL,SAAS,EACT,cAAc,EACd,cAAc,EACd,KAAK,eAAe,EACpB,SAAS,GACV,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EACL,KAAK,mBAAmB,IAAI,gBAAgB,EAC5C,KAAK,eAAe,IAAI,YAAY,EACpC,KAAK,gBAAgB,IAAI,aAAa,EACtC,KAAK,WAAW,IAAI,QAAQ,EAC5B,KAAK,kBAAkB,IAAI,eAAe,EAC1C,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACtB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,KAAK,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,aAAa,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,YAAY,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,SAAS,EACd,cAAc,EACd,KAAK,gBAAgB,EACrB,SAAS,EACT,WAAW,EACX,QAAQ,GACT,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,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,cAAc,EACd,sBAAsB,EACtB,QAAQ,EACR,cAAc,EACd,aAAa,EACb,UAAU,EACV,SAAS,EACT,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,cAAc,EACd,UAAU,EACV,YAAY,EACZ,gCAAgC,GACjC,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,yBAAyB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,wBAAwB,EACxB,KAAK,4BAA4B,EACjC,KAAK,oBAAoB,GAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,KAAK,YAAY,EACjB,wBAAwB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,aAAa,GACd,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,KAAK,eAAe,EACpB,YAAY,GACb,MAAM,aAAa,CAAC;AAIrB,OAAO,EACL,SAAS,EACT,cAAc,EACd,cAAc,EACd,KAAK,eAAe,EACpB,SAAS,GACV,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EACL,KAAK,mBAAmB,IAAI,gBAAgB,EAC5C,KAAK,eAAe,IAAI,YAAY,EACpC,KAAK,gBAAgB,IAAI,aAAa,EACtC,KAAK,WAAW,IAAI,QAAQ,EAC5B,KAAK,kBAAkB,IAAI,eAAe,EAC1C,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACtB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE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ACnB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,uBAAuB,EACvB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,KAAK,eAAe,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,EACL,2BAA2B,EAC3B,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,QAAQ,EACR,cAAc,GACf,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,oBAAoB,EACpB,cAAc,EACd,sBAAsB,EACtB,QAAQ,EACR,cAAc,EACd,aAAa,EACb,UAAU,EACV,SAAS,EACT,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,cAAc,EACd,UAAU,EACV,YAAY,EACZ,gCAAgC,GACjC,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,yBAAyB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,wBAAwB,EACxB,KAAK,4BAA4B,EACjC,KAAK,oBAAoB,GAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,KAAK,YAAY,EACjB,wBAAwB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,aAAa,GACd,MAAM,aAAa,CAAC"}
@@ -13,7 +13,7 @@ import {
13
13
  sseRoute,
14
14
  streamingRoute,
15
15
  webSocketLane
16
- } from "../index-cx84zg25.js";
16
+ } from "../index-118v0z41.js";
17
17
  import {
18
18
  composeAuthHooks,
19
19
  createAuthHook,
@@ -46,9 +46,10 @@ import {
46
46
  generateTraceId,
47
47
  getClientInfo,
48
48
  getTraceId,
49
+ isPublicIp,
49
50
  resolveSocketIp,
50
51
  resolveTraceId
51
- } from "../index-w9m1wznn.js";
52
+ } from "../index-nemjkxjp.js";
52
53
  import {
53
54
  isWithinDir,
54
55
  realPathWithinDir
@@ -1007,6 +1008,7 @@ export {
1007
1008
  ndjsonRoute,
1008
1009
  isWithinDir,
1009
1010
  isStitchErrorCode,
1011
+ isPublicIp,
1010
1012
  implementRegistry,
1011
1013
  implement,
1012
1014
  getClientInfo,
@@ -42,4 +42,23 @@ export declare function getClientInfo(req: Request, options?: ClientIpOptions):
42
42
  };
43
43
  /** Flatten a URL query string — repeated keys collapse to arrays. */
44
44
  export declare function parseQueryParams(url: URL): Record<string, string | string[]>;
45
+ /**
46
+ * Whether an address belongs to the public internet.
47
+ *
48
+ * The question behind it is always the same one: *may this address be handed to
49
+ * something outside this process* — resolved against a third party, fetched
50
+ * from, recorded as where a request came from. A loopback, a private LAN
51
+ * address, a carrier-NAT address or a link-local one answer no, each for its
52
+ * own reason, and none of them identifies a host anyone else can reach.
53
+ *
54
+ * **Anything it cannot parse is not public.** An empty string, a hostname, a
55
+ * truncated address: the honest answer to "is this a public peer" is no, and a
56
+ * function that returned `true` for a value it did not understand would be
57
+ * safe-by-accident exactly until the first malformed header.
58
+ *
59
+ * IPv4-mapped IPv6 (`::ffff:10.0.0.1`) is judged as the IPv4 address it
60
+ * carries — the mapping is notation, not a different host. Pair it with
61
+ * `extractIp`, which produces the value this asks about.
62
+ */
63
+ export declare function isPublicIp(value: string): boolean;
45
64
  //# sourceMappingURL=request.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/server/request.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,6EAA6E;AAC7E,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CASnD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,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C3B,GAAG,EAAE,OAAO,EACZ,OAAO,GAAE,eAAoB,GAC5B;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAKA;AAED,qEAAqE;AACrE,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAU5E;AAgGD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CA+BjD"}
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Who a Telegram Mini App request is from, proved rather than believed.
3
+ *
4
+ * A Mini App hands its backend an `initData` string. Telegram signs it with a
5
+ * key derived from the bot token, so a backend that checks the signature knows
6
+ * the user; a backend that reads `initDataUnsafe` and trusts it has an open
7
+ * door — the string is fully client-controlled, and the name Telegram gave that
8
+ * field is the whole warning.
9
+ *
10
+ * Three consuming applications wrote this check independently. Two of the three
11
+ * files agree closely enough to have shared an ancestor, and the third had
12
+ * drifted: the algorithm is short, published, and easy to get *almost* right.
13
+ * Almost right is the failure mode worth removing — a comparison that returns
14
+ * early on the first differing byte, an expiry checked before the signature, a
15
+ * `user` field read out of the string before anything proved it was ours.
16
+ *
17
+ * **This verifies; it does not phrase and it does not decide.** What a rejected
18
+ * request should answer, whether an expired one may re-authenticate, which
19
+ * fields a session keeps — those belong to the application. What the core owes
20
+ * is the distinction between *authentic* and *not*, and the reason when not.
21
+ *
22
+ * Not a domain model (→ ADR 0002): "Telegram signed this string" is a fact
23
+ * about a transport, the same kind of fact as a bearer token being well-formed.
24
+ */
25
+ import { z } from 'zod';
26
+ /**
27
+ * The Telegram user record, as our surface names things.
28
+ *
29
+ * Telegram's wire fields are `snake_case`; every other name this package
30
+ * publishes is `camelCase`, and a surface that switches convention because of
31
+ * where a value came from makes the caller remember which is which. The
32
+ * untouched wire pairs stay available in `raw`.
33
+ */
34
+ declare const TelegramInitDataUserSchema: z.ZodPipe<z.ZodObject<{
35
+ id: z.ZodInt;
36
+ is_bot: z.ZodOptional<z.ZodBoolean>;
37
+ first_name: z.ZodString;
38
+ last_name: z.ZodOptional<z.ZodString>;
39
+ username: z.ZodOptional<z.ZodString>;
40
+ language_code: z.ZodOptional<z.ZodString>;
41
+ is_premium: z.ZodOptional<z.ZodBoolean>;
42
+ allows_write_to_pm: z.ZodOptional<z.ZodBoolean>;
43
+ photo_url: z.ZodOptional<z.ZodString>;
44
+ }, z.core.$strip>, z.ZodTransform<{
45
+ id: number;
46
+ firstName: string;
47
+ isBot?: boolean | undefined;
48
+ lastName?: string | undefined;
49
+ username?: string | undefined;
50
+ languageCode?: string | undefined;
51
+ isPremium?: boolean | undefined;
52
+ allowsWriteToPm?: boolean | undefined;
53
+ photoUrl?: string | undefined;
54
+ }, {
55
+ id: number;
56
+ is_bot?: boolean | undefined;
57
+ first_name: string;
58
+ last_name?: string | undefined;
59
+ username?: string | undefined;
60
+ language_code?: string | undefined;
61
+ is_premium?: boolean | undefined;
62
+ allows_write_to_pm?: boolean | undefined;
63
+ photo_url?: string | undefined;
64
+ }>>;
65
+ export type TelegramInitDataUser = z.infer<typeof TelegramInitDataUserSchema>;
66
+ export interface TelegramInitData {
67
+ /** Absent when the Mini App was opened somewhere Telegram sends no user. */
68
+ user?: TelegramInitDataUser;
69
+ /** Whose chat the Mini App was opened from, when Telegram named one. */
70
+ receiver?: TelegramInitDataUser;
71
+ /** When Telegram signed this string. */
72
+ authDate: Date;
73
+ /** How old the signature was at verification time. */
74
+ ageSeconds: number;
75
+ queryId?: string;
76
+ startParam?: string;
77
+ chatType?: string;
78
+ chatInstance?: string;
79
+ /**
80
+ * Every signed pair exactly as Telegram sent it, `hash` excluded.
81
+ *
82
+ * Telegram adds fields without warning, and a caller that needs one this
83
+ * release has never heard of should not have to wait for a release to read
84
+ * it. Everything here was covered by the signature.
85
+ */
86
+ raw: Readonly<Record<string, string>>;
87
+ }
88
+ /**
89
+ * Why a string was not accepted.
90
+ *
91
+ * `signature-mismatch` is the only one that means someone tampered; the others
92
+ * are shapes a legitimate client can produce, and an application may well
93
+ * answer them differently — an expired string is a re-open, a malformed one is
94
+ * a bug report.
95
+ */
96
+ export type TelegramInitDataRefusal = 'missing-hash' | 'signature-mismatch' | 'malformed' | 'expired';
97
+ export type TelegramInitDataVerification = {
98
+ readonly valid: true;
99
+ readonly data: TelegramInitData;
100
+ } | {
101
+ readonly valid: false;
102
+ readonly reason: TelegramInitDataRefusal;
103
+ /** Present on `expired`, where the number is the point of the refusal. */
104
+ readonly ageSeconds?: number;
105
+ };
106
+ export interface VerifyTelegramInitDataOptions {
107
+ /** The raw query-string Telegram handed the Mini App. */
108
+ initData: string;
109
+ /** The bot the Mini App belongs to. Never leaves this function. */
110
+ botToken: string;
111
+ /**
112
+ * Refuse a signature older than this many seconds.
113
+ *
114
+ * A signed string stays valid forever unless something bounds it, so a
115
+ * captured one is a permanent credential. Omitted means no bound, which is a
116
+ * deliberate choice rather than a default: only the application knows how
117
+ * long its own session is worth.
118
+ */
119
+ maxAgeSeconds?: number;
120
+ /** Epoch milliseconds, for a caller that owns its own clock. */
121
+ now?: () => number;
122
+ }
123
+ /**
124
+ * Verify one `initData` string and report what it says.
125
+ *
126
+ * Never throws for anything a client can send: a string that fails is a
127
+ * refusal with a reason, because the caller has to answer the request either
128
+ * way and an exception for the ordinary case turns every handler into a
129
+ * `try`/`catch`. A missing bot token is not that case — it is this process
130
+ * being configured wrong, and it throws.
131
+ */
132
+ export declare function verifyTelegramInitData(options: VerifyTelegramInitDataOptions): Promise<TelegramInitDataVerification>;
133
+ export {};
134
+ //# sourceMappingURL=init-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-data.d.ts","sourceRoot":"","sources":["../../src/telegram/init-data.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CA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,gEAAgE;IAChE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAiDD;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,4BAA4B,CAAC,CAuEvC"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * What a refused Telegram send was, as a fact rather than as a sentence.
3
+ *
4
+ * Two consuming applications carry the same broadcast subsystem — three of its
5
+ * files byte-identical — and inside it the same list of substrings: *bot was
6
+ * blocked*, *user is deactivated*, *chat not found*. The list exists because
7
+ * the Bot API answers a permanently unreachable recipient and a temporarily
8
+ * throttled one with the same shape, and a sender that cannot tell them apart
9
+ * either retries a user who will never receive anything or drops one who would
10
+ * have.
11
+ *
12
+ * The two questions are separate on purpose. `retryable` asks whether *this
13
+ * send* could work if repeated; `recipientUnreachable` asks whether *this
14
+ * recipient* should be addressed again at all. A rate limit is the first
15
+ * without the second; a blocked user is the second without the first; a
16
+ * message Telegram could not parse is neither — the recipient is fine and it is
17
+ * our payload that is wrong, which is exactly the case a substring list marks
18
+ * as a delivery failure and quietly counts against the wrong party.
19
+ *
20
+ * **This classifies; it does not act.** Whether to retry, how long to wait,
21
+ * whether a blocked user is deleted or merely flagged — the application's,
22
+ * along with every sentence a human reads. → ADR 0141.
23
+ */
24
+ /**
25
+ * Why a send did not arrive.
26
+ *
27
+ * Each member earns its name by implying a different next move. The four that
28
+ * mean "not this recipient" are not folded together: a deactivated account is
29
+ * gone and its row can be closed, a block can be lifted and the row is kept, a
30
+ * user who never pressed Start needs an invitation rather than a retry, and a
31
+ * chat Telegram does not know is usually a bad identifier on our side — a
32
+ * defect in our data, not a fact about a person.
33
+ */
34
+ export type TelegramSendFailureReason = 'blocked-by-user' | 'user-deactivated' | 'chat-not-found' | 'not-started' | 'rate-limited' | 'message-invalid' | 'server-error' | 'unknown';
35
+ export interface TelegramSendFailure {
36
+ reason: TelegramSendFailureReason;
37
+ /** Telegram's `error_code`, when the failure carried one. */
38
+ status?: number;
39
+ /**
40
+ * How long Telegram asked us to wait, from its own `parameters.retry_after`.
41
+ *
42
+ * Only ever present when Telegram said it. A sender that needs a number
43
+ * anyway picks its own backoff; inventing one here would put a guess and a
44
+ * statement in the same field.
45
+ */
46
+ retryAfterSeconds?: number;
47
+ /** Repeating this same send could plausibly succeed. */
48
+ retryable: boolean;
49
+ /**
50
+ * This recipient will not receive this or any later message until something
51
+ * outside our control changes, so a broadcast should stop addressing them.
52
+ *
53
+ * Asserted only for the reasons that actually establish it. An unrecognised
54
+ * refusal leaves it `false`: marking a recipient unreachable on a guess is
55
+ * how a working subscriber is silently dropped forever, and that error is
56
+ * far more expensive than one wasted send.
57
+ */
58
+ recipientUnreachable: boolean;
59
+ /**
60
+ * How the reason was reached. `parameters` and `status` are Telegram stating
61
+ * its own answer in a structured field; `description` is us reading its
62
+ * prose, which changes without notice.
63
+ */
64
+ evidence: 'parameters' | 'status' | 'description' | 'none';
65
+ }
66
+ /**
67
+ * Classify one refused send.
68
+ *
69
+ * Never throws and never guesses: a refusal it does not recognise is `unknown`,
70
+ * which asserts nothing about the recipient and permits no retry.
71
+ */
72
+ export declare function classifyTelegramSendFailure(error: unknown): TelegramSendFailure;
73
+ //# sourceMappingURL=send-failure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send-failure.d.ts","sourceRoot":"","sources":["../../src/telegram/send-failure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH;;;;;;;;;GASG;AACH,MAAM,MAAM,yBAAyB,GACjC,iBAAiB,GACjB,kBAAkB,GAClB,gBAAgB,GAChB,aAAa,GACb,cAAc,GACd,iBAAiB,GACjB,cAAc,GACd,SAAS,CAAC;AAEd,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,yBAAyB,CAAC;IAClC,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,wDAAwD;IACxD,SAAS,EAAE,OAAO,CAAC;IACnB;;;;;;;;OAQG;IACH,oBAAoB,EAAE,OAAO,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,EAAE,YAAY,GAAG,QAAQ,GAAG,aAAa,GAAG,MAAM,CAAC;CAC5D;AAuED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,mBAAmB,CA0D/E"}
@@ -0,0 +1,3 @@
1
+ export { type TelegramInitData, type TelegramInitDataRefusal, type TelegramInitDataUser, type TelegramInitDataVerification, type VerifyTelegramInitDataOptions, verifyTelegramInitData, } from './telegram/init-data.js';
2
+ export { classifyTelegramSendFailure, type TelegramSendFailure, type TelegramSendFailureReason, } from './telegram/send-failure.js';
3
+ //# sourceMappingURL=telegram.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telegram.d.ts","sourceRoot":"","sources":["../src/telegram.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EAClC,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,2BAA2B,EAC3B,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,GAC/B,MAAM,yBAAyB,CAAC"}