stitchkit 0.123.2 → 0.123.4
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/CHANGELOG.md +44 -0
- package/dist/agent-runtime/sandbox-broker.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/sandbox.js +16 -4
- package/dist/entrypoints/files.d.ts +1 -0
- package/dist/entrypoints/files.d.ts.map +1 -1
- package/dist/entrypoints/files.js +4 -0
- package/dist/entrypoints/server.js +33 -20
- package/dist/entrypoints/telegram/voice.d.ts +2 -0
- package/dist/entrypoints/telegram/voice.d.ts.map +1 -0
- package/dist/entrypoints/telegram/voice.js +18 -0
- package/dist/entrypoints/telegram.d.ts +1 -0
- package/dist/entrypoints/telegram.d.ts.map +1 -1
- package/dist/entrypoints/telegram.js +43 -0
- package/dist/entrypoints/tracking/performance.js +3 -3
- package/dist/index-0jdempdr.js +69 -0
- package/dist/index-drcjjhy1.js +40 -0
- package/dist/internal/unix-socket.d.ts +28 -0
- package/dist/internal/unix-socket.d.ts.map +1 -0
- package/dist/server/bun.d.ts +5 -4
- package/dist/server/bun.d.ts.map +1 -1
- package/dist/telegram/voice-waveform-pcm.d.ts +21 -0
- package/dist/telegram/voice-waveform-pcm.d.ts.map +1 -0
- package/dist/telegram/voice-waveform.d.ts +67 -0
- package/dist/telegram/voice-waveform.d.ts.map +1 -0
- package/llms/files.txt +1 -0
- package/llms/process.2.txt +133 -0
- package/llms/process.txt +37 -133
- package/llms/server.5.txt +1 -1
- package/llms/server.txt +8 -5
- package/llms/stitchkit.txt +3 -1
- package/llms/telegram-voice.txt +29 -0
- package/llms/telegram.2.txt +71 -0
- package/llms/telegram.txt +51 -59
- package/llms-full.txt +115 -7
- package/llms.txt +7 -6
- package/package.json +5 -1
package/llms/process.2.txt
CHANGED
|
@@ -11,6 +11,139 @@ Parts of this slice:
|
|
|
11
11
|
# Guide: Native IO (docs/guide/native-io.md) (continued)
|
|
12
12
|
==============================================================================
|
|
13
13
|
|
|
14
|
+
## Public native packaging
|
|
15
|
+
|
|
16
|
+
Custom archives and installers use `stitchkit/files/packaging` at **build time**.
|
|
17
|
+
`createNativePackaging` resolves the installed version and target addon, reads the addon once and
|
|
18
|
+
checks it against the size and SHA256 that Stitchkit published in its `native-assets.json` when the
|
|
19
|
+
package was built. A ready asset carries those verified `bytes` with the published `size` and
|
|
20
|
+
`sha256`; its Bun-compatible plugin integrates the same bytes with the same lazy native loader.
|
|
21
|
+
Each call reads and hashes the selected addons, so call it once per build and reuse the result.
|
|
22
|
+
The leaf is evolving. It requires no optional peer or Bun ambient declarations for Node imports.
|
|
23
|
+
Calling it must happen in a process that runs it from its installed package: it locates the
|
|
24
|
+
package's `native-assets.json` beside its own file and throws `Native packaging must run from its
|
|
25
|
+
installed Stitchkit package` anywhere else, such as inside an application's runtime artifact.
|
|
26
|
+
Importing the leaf is side-effect free (it loads no addon and reads no file), so a module that
|
|
27
|
+
both builds and is bundled may import it; only the call has to stay in the build step.
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { createNativePackaging } from 'stitchkit/files/packaging'
|
|
31
|
+
import { mkdirSync, writeFileSync } from 'node:fs'
|
|
32
|
+
import { dirname, join } from 'node:path'
|
|
33
|
+
|
|
34
|
+
const native = createNativePackaging({
|
|
35
|
+
platform: 'darwin', architecture: 'arm64', delivery: 'companion',
|
|
36
|
+
entryPath: 'app/native.js', assetPath: 'addons/owner.node',
|
|
37
|
+
})
|
|
38
|
+
if (native.state !== 'ready') throw new Error(native.code)
|
|
39
|
+
const result = await Bun.build({
|
|
40
|
+
entrypoints: ['src/native.ts'], target: 'node', format: 'esm',
|
|
41
|
+
outdir: 'dist', naming: { entry: 'app/native.js' }, splitting: false,
|
|
42
|
+
plugins: [native.plugin],
|
|
43
|
+
})
|
|
44
|
+
if (!result.success) throw new AggregateError(result.logs, 'Build failed')
|
|
45
|
+
// Preserve every result.outputs file under dist, then write the verified companion bytes.
|
|
46
|
+
for (const asset of native.assets) {
|
|
47
|
+
const destination = join('dist', asset.outputPath)
|
|
48
|
+
mkdirSync(dirname(destination), { recursive: true })
|
|
49
|
+
writeFileSync(destination, asset.bytes)
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
In companion delivery, `entryPath` and `assetPath` are relative paths inside the application's output root, without
|
|
54
|
+
absolute paths, traversal or overlapping file/directory paths. `assetPath` may contain `[hash]`,
|
|
55
|
+
which becomes the first 16 hex digits of that addon's published SHA256: the digest is known before
|
|
56
|
+
the build, so `addons/darwin-arm64-[hash].node` gives two installed versions of the package
|
|
57
|
+
different companion names, and the loader requires exactly that name. It is the only template an
|
|
58
|
+
addon path accepts. `entryPath` is fixed, without
|
|
59
|
+
Bun naming templates such as `[dir]` or `[name]`. Companion JS builds require one entry, no splitting,
|
|
60
|
+
and `naming.entry` exactly matching `entryPath`; the plugin rejects a mismatching layout.
|
|
61
|
+
Choose any application layout; the framework does not prescribe an app directory or installer.
|
|
62
|
+
The plugin packages the loader of the installation it was created from. A build whose entry
|
|
63
|
+
imports another `stitchkit` installation — another version, or the same version under another
|
|
64
|
+
path, as when a build tool carries its own copy — fails with an error naming both versions and
|
|
65
|
+
roots: that installation's loader would refuse the addon at run time, so the artifact is never
|
|
66
|
+
written. Call `createNativePackaging` from the `stitchkit` the entry imports.
|
|
67
|
+
Keep every bundler output and write `asset.bytes`; never read the addon from `node_modules` a
|
|
68
|
+
second time. An installed addon whose size or SHA256 differs from the published manifest refuses
|
|
69
|
+
with `mismatch` / `NATIVE_ASSET_DIGEST_MISMATCH`, so a file substituted after installation never
|
|
70
|
+
reaches an artifact. Archive the complete output directory with an integrity manifest that records
|
|
71
|
+
`asset.sha256`, unpack to a clean directory, verify the same hashes there, and run offline without
|
|
72
|
+
the build tree or `node_modules`. The published digest ties the bytes to the package Stitchkit
|
|
73
|
+
built; the package itself is only as trusted as its tarball (the lockfile integrity of the install).
|
|
74
|
+
Signature and trust policy remain application-owned.
|
|
75
|
+
|
|
76
|
+
One JS artifact can run on both Darwin architectures; change only the packaging inputs:
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
const native = createNativePackaging({
|
|
80
|
+
platform: 'darwin', architecture: ['arm64', 'x64'], delivery: 'companion',
|
|
81
|
+
entryPath: 'app/native.js',
|
|
82
|
+
assetPath: { arm64: 'addons/arm.node', x64: 'addons/intel.node' },
|
|
83
|
+
})
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Use the same single plugin and write loop above. A single-target loader deliberately refuses the
|
|
87
|
+
other architecture; two competing plugins cannot produce a universal loader. The array form
|
|
88
|
+
requires exactly one distinct output path per declared target. A ready result carries the target
|
|
89
|
+
array and both verified assets with their published digests; `NativePackagingOptions<true>` /
|
|
90
|
+
`NativePackagingResult<true>` describe this form when explicitly annotating variables.
|
|
91
|
+
The loader selects only `process.arch`: a missing or wrong-architecture selected addon refuses,
|
|
92
|
+
even when the other valid addon is present. Linux runtime imports remain lazy and use Linux
|
|
93
|
+
process primitives without loading Darwin assets. Qualify the exact same JS bytes on real
|
|
94
|
+
Darwin arm64 and x64 machines, with both companions preserved through archive delivery.
|
|
95
|
+
Build-machine architecture and cross-build success cannot establish universal native support.
|
|
96
|
+
|
|
97
|
+
For a standalone executable use `delivery: 'embedded'` and its plugin in `Bun.build` with
|
|
98
|
+
`compile`. An executable carries the addon inside itself, so this form names no `entryPath` or
|
|
99
|
+
`assetPath`; passing one is a type error and a schema refusal, never silently ignored:
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
const native = createNativePackaging({
|
|
103
|
+
platform: 'darwin', architecture: 'arm64', delivery: 'embedded',
|
|
104
|
+
})
|
|
105
|
+
if (native.state !== 'ready') throw new Error(native.code)
|
|
106
|
+
const result = await Bun.build({
|
|
107
|
+
entrypoints: ['src/cli.ts'], minify: true,
|
|
108
|
+
compile: { target: 'bun-darwin-arm64', outfile: 'dist/cli' },
|
|
109
|
+
plugins: [native.plugin],
|
|
110
|
+
})
|
|
111
|
+
if (!result.success) throw new AggregateError(result.logs, 'Build failed')
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Bun embeds the selected addon from the verified bytes the plugin holds, not from a second read of
|
|
115
|
+
the file, and the executable loads it from `/$bunfs/root/darwin-arm64-<hash>.node`. Its `assets`
|
|
116
|
+
(`NativePackagingEmbeddedAsset`: `bytes`, `size`, `sha256`) identify those bytes and their
|
|
117
|
+
published digest for qualification; there is nothing to write beside the executable.
|
|
118
|
+
Cross-builds must select the requested architecture explicitly; the artifact must run on that target.
|
|
119
|
+
The installed package must contain that target's addon. No automatic fallback/downgrade occurs.
|
|
120
|
+
|
|
121
|
+
`platform` is the closed set of platforms with native addons, today `'darwin'`: another name is a
|
|
122
|
+
type error and a schema refusal that throws, so pass the literal (or narrow `process.platform`
|
|
123
|
+
with `=== 'darwin'`) rather than a free string. The API returns `unsupported` /
|
|
124
|
+
`NATIVE_TARGET_UNSUPPORTED` for an unsupported architecture, `missing` / `NATIVE_ASSET_MISSING` for
|
|
125
|
+
an addon the package does not publish or whose file is gone, and `mismatch` /
|
|
126
|
+
`NATIVE_ASSET_DIGEST_MISMATCH` for an addon whose bytes differ from the published size or SHA256.
|
|
127
|
+
A `mismatch` names the first differing `architecture` and carries `expected` (the published
|
|
128
|
+
`{ size, sha256 }`) and `actual` (the installed file's size and the SHA256 of the bytes read), so
|
|
129
|
+
a build log can tell a truncated copy from a substituted one:
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
if (native.state === 'mismatch')
|
|
133
|
+
throw new Error(
|
|
134
|
+
`${native.architecture} addon: expected ${native.expected.size} bytes ` +
|
|
135
|
+
`${native.expected.sha256}, found ${native.actual.size} bytes ${native.actual.sha256}`,
|
|
136
|
+
)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Portable libraries
|
|
140
|
+
and Linux builds use their normal build, without a Darwin plugin; merely importing the build leaf
|
|
141
|
+
loads no addon.
|
|
142
|
+
Malformed inputs, a manifest whose `formatVersion` is not 2 and other IO errors throw before packaging.
|
|
143
|
+
A missing or corrupt companion at runtime yields the native `unavailable` result with the safe
|
|
144
|
+
stage and code from the observer; it never certifies a dead owner. Preserve the raw cause internally.
|
|
145
|
+
The plugin does not parse consumer JS or establish a second runtime native implementation.
|
|
146
|
+
|
|
14
147
|
## A client as one self-contained file
|
|
15
148
|
|
|
16
149
|
A package that owns a server usually ships a typed client for it, and the client's consumers
|
package/llms/process.txt
CHANGED
|
@@ -96,6 +96,43 @@ filesystems or survival of a power loss; the disk state is whatever the filesyst
|
|
|
96
96
|
`createManagedFileBoundary.write(..., { durable: true })` uses the same publish owner and parent sync;
|
|
97
97
|
its create stays a create, and `replace: true` allows replacement explicitly.
|
|
98
98
|
|
|
99
|
+
## A unix socket private from birth
|
|
100
|
+
|
|
101
|
+
When access to a socket is the credential, the socket must never exist with wider rights. `bind(2)`
|
|
102
|
+
accepts no mode — a socket file takes its rights from the process umask — so `chmod` after `listen`
|
|
103
|
+
leaves the umask rights (`0755` under `022`) on disk until it runs, and a process watching the path
|
|
104
|
+
sees them even when `chmodSync` is the very next line. `bindUnixSocket` binds under a umask narrowed
|
|
105
|
+
to exactly `mode` for one synchronous call and restores it before any other JavaScript runs:
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
import { createServer } from 'node:http'
|
|
109
|
+
import { bindUnixSocket } from 'stitchkit/files'
|
|
110
|
+
|
|
111
|
+
// Bun
|
|
112
|
+
const server = bindUnixSocket({ path: '/run/app/door.sock', mode: 0o600 }, (path) =>
|
|
113
|
+
Bun.serve({ unix: path, fetch: () => new Response('ok') }),
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
// Node (and Bun's node:http) — the bind happens inside `listen`; its error arrives on 'error'
|
|
117
|
+
const door = createServer(handler)
|
|
118
|
+
bindUnixSocket({ path: '/run/app/door.sock', mode: 0o600 }, (path) => door.listen(path))
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
`createServer({ unix: { path, mode } })` from `stitchkit/server` binds through the same function.
|
|
122
|
+
|
|
123
|
+
- The path must be free: whatever stands there after the call was created by it. Remove a stale
|
|
124
|
+
socket first (`createServer` probes and reclaims one); an existing file is refused before anything
|
|
125
|
+
binds.
|
|
126
|
+
- After the call the path must be a socket with exactly `mode`, or the call throws. A bind that
|
|
127
|
+
failed (Node and Bun report a `listen` error asynchronously), one that binds later than the call,
|
|
128
|
+
and a directory whose default ACL — not the umask — decides the rights all end here; a socket born
|
|
129
|
+
with other rights is removed first, so no client reaches it by path. The listener your `bind`
|
|
130
|
+
started is yours to stop.
|
|
131
|
+
- The umask is process-wide. A file another thread creates during the call is born at most as
|
|
132
|
+
permissive as the socket — narrower, never wider. Work that needs the normal umask, a child
|
|
133
|
+
process above all, runs before the call, not inside `bind`. A Node worker thread cannot set the
|
|
134
|
+
umask and gets that error.
|
|
135
|
+
|
|
99
136
|
## Strict reads
|
|
100
137
|
|
|
101
138
|
```ts
|
|
@@ -635,136 +672,3 @@ no recognized native error code, the stage stays `load`; the loader never infers
|
|
|
635
672
|
|
|
636
673
|
This delivery removes a runtime kernel installation; it does not remove the build-time
|
|
637
674
|
Stitchkit installation or create an independent lightweight npm package.
|
|
638
|
-
|
|
639
|
-
## Public native packaging
|
|
640
|
-
|
|
641
|
-
Custom archives and installers use `stitchkit/files/packaging` at **build time**.
|
|
642
|
-
`createNativePackaging` resolves the installed version and target addon, reads the addon once and
|
|
643
|
-
checks it against the size and SHA256 that Stitchkit published in its `native-assets.json` when the
|
|
644
|
-
package was built. A ready asset carries those verified `bytes` with the published `size` and
|
|
645
|
-
`sha256`; its Bun-compatible plugin integrates the same bytes with the same lazy native loader.
|
|
646
|
-
Each call reads and hashes the selected addons, so call it once per build and reuse the result.
|
|
647
|
-
The leaf is evolving. It requires no optional peer or Bun ambient declarations for Node imports.
|
|
648
|
-
Calling it must happen in a process that runs it from its installed package: it locates the
|
|
649
|
-
package's `native-assets.json` beside its own file and throws `Native packaging must run from its
|
|
650
|
-
installed Stitchkit package` anywhere else, such as inside an application's runtime artifact.
|
|
651
|
-
Importing the leaf is side-effect free (it loads no addon and reads no file), so a module that
|
|
652
|
-
both builds and is bundled may import it; only the call has to stay in the build step.
|
|
653
|
-
|
|
654
|
-
```ts
|
|
655
|
-
import { createNativePackaging } from 'stitchkit/files/packaging'
|
|
656
|
-
import { mkdirSync, writeFileSync } from 'node:fs'
|
|
657
|
-
import { dirname, join } from 'node:path'
|
|
658
|
-
|
|
659
|
-
const native = createNativePackaging({
|
|
660
|
-
platform: 'darwin', architecture: 'arm64', delivery: 'companion',
|
|
661
|
-
entryPath: 'app/native.js', assetPath: 'addons/owner.node',
|
|
662
|
-
})
|
|
663
|
-
if (native.state !== 'ready') throw new Error(native.code)
|
|
664
|
-
const result = await Bun.build({
|
|
665
|
-
entrypoints: ['src/native.ts'], target: 'node', format: 'esm',
|
|
666
|
-
outdir: 'dist', naming: { entry: 'app/native.js' }, splitting: false,
|
|
667
|
-
plugins: [native.plugin],
|
|
668
|
-
})
|
|
669
|
-
if (!result.success) throw new AggregateError(result.logs, 'Build failed')
|
|
670
|
-
// Preserve every result.outputs file under dist, then write the verified companion bytes.
|
|
671
|
-
for (const asset of native.assets) {
|
|
672
|
-
const destination = join('dist', asset.outputPath)
|
|
673
|
-
mkdirSync(dirname(destination), { recursive: true })
|
|
674
|
-
writeFileSync(destination, asset.bytes)
|
|
675
|
-
}
|
|
676
|
-
```
|
|
677
|
-
|
|
678
|
-
In companion delivery, `entryPath` and `assetPath` are relative paths inside the application's output root, without
|
|
679
|
-
absolute paths, traversal or overlapping file/directory paths. `assetPath` may contain `[hash]`,
|
|
680
|
-
which becomes the first 16 hex digits of that addon's published SHA256: the digest is known before
|
|
681
|
-
the build, so `addons/darwin-arm64-[hash].node` gives two installed versions of the package
|
|
682
|
-
different companion names, and the loader requires exactly that name. It is the only template an
|
|
683
|
-
addon path accepts. `entryPath` is fixed, without
|
|
684
|
-
Bun naming templates such as `[dir]` or `[name]`. Companion JS builds require one entry, no splitting,
|
|
685
|
-
and `naming.entry` exactly matching `entryPath`; the plugin rejects a mismatching layout.
|
|
686
|
-
Choose any application layout; the framework does not prescribe an app directory or installer.
|
|
687
|
-
The plugin packages the loader of the installation it was created from. A build whose entry
|
|
688
|
-
imports another `stitchkit` installation — another version, or the same version under another
|
|
689
|
-
path, as when a build tool carries its own copy — fails with an error naming both versions and
|
|
690
|
-
roots: that installation's loader would refuse the addon at run time, so the artifact is never
|
|
691
|
-
written. Call `createNativePackaging` from the `stitchkit` the entry imports.
|
|
692
|
-
Keep every bundler output and write `asset.bytes`; never read the addon from `node_modules` a
|
|
693
|
-
second time. An installed addon whose size or SHA256 differs from the published manifest refuses
|
|
694
|
-
with `mismatch` / `NATIVE_ASSET_DIGEST_MISMATCH`, so a file substituted after installation never
|
|
695
|
-
reaches an artifact. Archive the complete output directory with an integrity manifest that records
|
|
696
|
-
`asset.sha256`, unpack to a clean directory, verify the same hashes there, and run offline without
|
|
697
|
-
the build tree or `node_modules`. The published digest ties the bytes to the package Stitchkit
|
|
698
|
-
built; the package itself is only as trusted as its tarball (the lockfile integrity of the install).
|
|
699
|
-
Signature and trust policy remain application-owned.
|
|
700
|
-
|
|
701
|
-
One JS artifact can run on both Darwin architectures; change only the packaging inputs:
|
|
702
|
-
|
|
703
|
-
```ts
|
|
704
|
-
const native = createNativePackaging({
|
|
705
|
-
platform: 'darwin', architecture: ['arm64', 'x64'], delivery: 'companion',
|
|
706
|
-
entryPath: 'app/native.js',
|
|
707
|
-
assetPath: { arm64: 'addons/arm.node', x64: 'addons/intel.node' },
|
|
708
|
-
})
|
|
709
|
-
```
|
|
710
|
-
|
|
711
|
-
Use the same single plugin and write loop above. A single-target loader deliberately refuses the
|
|
712
|
-
other architecture; two competing plugins cannot produce a universal loader. The array form
|
|
713
|
-
requires exactly one distinct output path per declared target. A ready result carries the target
|
|
714
|
-
array and both verified assets with their published digests; `NativePackagingOptions<true>` /
|
|
715
|
-
`NativePackagingResult<true>` describe this form when explicitly annotating variables.
|
|
716
|
-
The loader selects only `process.arch`: a missing or wrong-architecture selected addon refuses,
|
|
717
|
-
even when the other valid addon is present. Linux runtime imports remain lazy and use Linux
|
|
718
|
-
process primitives without loading Darwin assets. Qualify the exact same JS bytes on real
|
|
719
|
-
Darwin arm64 and x64 machines, with both companions preserved through archive delivery.
|
|
720
|
-
Build-machine architecture and cross-build success cannot establish universal native support.
|
|
721
|
-
|
|
722
|
-
For a standalone executable use `delivery: 'embedded'` and its plugin in `Bun.build` with
|
|
723
|
-
`compile`. An executable carries the addon inside itself, so this form names no `entryPath` or
|
|
724
|
-
`assetPath`; passing one is a type error and a schema refusal, never silently ignored:
|
|
725
|
-
|
|
726
|
-
```ts
|
|
727
|
-
const native = createNativePackaging({
|
|
728
|
-
platform: 'darwin', architecture: 'arm64', delivery: 'embedded',
|
|
729
|
-
})
|
|
730
|
-
if (native.state !== 'ready') throw new Error(native.code)
|
|
731
|
-
const result = await Bun.build({
|
|
732
|
-
entrypoints: ['src/cli.ts'], minify: true,
|
|
733
|
-
compile: { target: 'bun-darwin-arm64', outfile: 'dist/cli' },
|
|
734
|
-
plugins: [native.plugin],
|
|
735
|
-
})
|
|
736
|
-
if (!result.success) throw new AggregateError(result.logs, 'Build failed')
|
|
737
|
-
```
|
|
738
|
-
|
|
739
|
-
Bun embeds the selected addon from the verified bytes the plugin holds, not from a second read of
|
|
740
|
-
the file, and the executable loads it from `/$bunfs/root/darwin-arm64-<hash>.node`. Its `assets`
|
|
741
|
-
(`NativePackagingEmbeddedAsset`: `bytes`, `size`, `sha256`) identify those bytes and their
|
|
742
|
-
published digest for qualification; there is nothing to write beside the executable.
|
|
743
|
-
Cross-builds must select the requested architecture explicitly; the artifact must run on that target.
|
|
744
|
-
The installed package must contain that target's addon. No automatic fallback/downgrade occurs.
|
|
745
|
-
|
|
746
|
-
`platform` is the closed set of platforms with native addons, today `'darwin'`: another name is a
|
|
747
|
-
type error and a schema refusal that throws, so pass the literal (or narrow `process.platform`
|
|
748
|
-
with `=== 'darwin'`) rather than a free string. The API returns `unsupported` /
|
|
749
|
-
`NATIVE_TARGET_UNSUPPORTED` for an unsupported architecture, `missing` / `NATIVE_ASSET_MISSING` for
|
|
750
|
-
an addon the package does not publish or whose file is gone, and `mismatch` /
|
|
751
|
-
`NATIVE_ASSET_DIGEST_MISMATCH` for an addon whose bytes differ from the published size or SHA256.
|
|
752
|
-
A `mismatch` names the first differing `architecture` and carries `expected` (the published
|
|
753
|
-
`{ size, sha256 }`) and `actual` (the installed file's size and the SHA256 of the bytes read), so
|
|
754
|
-
a build log can tell a truncated copy from a substituted one:
|
|
755
|
-
|
|
756
|
-
```ts
|
|
757
|
-
if (native.state === 'mismatch')
|
|
758
|
-
throw new Error(
|
|
759
|
-
`${native.architecture} addon: expected ${native.expected.size} bytes ` +
|
|
760
|
-
`${native.expected.sha256}, found ${native.actual.size} bytes ${native.actual.sha256}`,
|
|
761
|
-
)
|
|
762
|
-
```
|
|
763
|
-
|
|
764
|
-
Portable libraries
|
|
765
|
-
and Linux builds use their normal build, without a Darwin plugin; merely importing the build leaf
|
|
766
|
-
loads no addon.
|
|
767
|
-
Malformed inputs, a manifest whose `formatVersion` is not 2 and other IO errors throw before packaging.
|
|
768
|
-
A missing or corrupt companion at runtime yields the native `unavailable` result with the safe
|
|
769
|
-
stage and code from the observer; it never certifies a dead owner. Preserve the raw cause internally.
|
|
770
|
-
The plugin does not parse consumer JS or establish a second runtime native implementation.
|
package/llms/server.5.txt
CHANGED
|
@@ -71,7 +71,7 @@ Also re-exports the error helpers from `stitchkit/contract`.
|
|
|
71
71
|
| `BunServerConfig` | _type_ | config for `createServer` (Bun); `unix` listens on a unix domain socket (mutually exclusive with `port`/`hostname`) — [details](../guide/server.md#local-daemon-over-a-unix-socket) |
|
|
72
72
|
| `defineRequestIngress` / `RequestIngress` / `RequestIngressSource` | function / _type_ | a typed key the code that builds a `Request` attaches a value to (`attach(request, value)`) and an endpoint, `authorize`, `beforeHandle` or `onError` reads from its `ctx` (`from(ctx)`); a header, `clone()` and `new Request(request)` carry nothing, a second `attach` is refused, and `ctx.req` is the very request the handler received — [guide](../guide/server.md#request-attributes-from-the-ingress) |
|
|
73
73
|
| `ProxyOriginConfig` | _type_ | explicit real-peer trust for Bun `createServer({ proxyOrigin })`; strict external-scheme normalization before composition — [details](../guide/server.md#external-origin-behind-a-trusted-proxy) |
|
|
74
|
-
| `UnixListenConfig` | _type_ | unix listener — a socket path, or `{ path, mode }`
|
|
74
|
+
| `UnixListenConfig` | _type_ | unix listener — a socket path bound under the process umask, or `{ path, mode }` for a socket born with exactly `mode` (`bindUnixSocket`) |
|
|
75
75
|
| `BunServerHandle` | _type_ | managed Bun handle (`url`, `port`, `runtime`, `status`, `shutdown`) |
|
|
76
76
|
| `ManagedServerHandle` | _type_ | shared lifecycle shape generic over the runtime escape hatch |
|
|
77
77
|
| `ShutdownOptionsSchema` / `ShutdownOptions` | schema / _type_ | HTTP/application grace, a separate WebSocket close-handshake bound, bounded forced-completion timeout, retry hint and optional external abort signal |
|
package/llms/server.txt
CHANGED
|
@@ -398,11 +398,14 @@ bind error of the loser). A regular file at the path, another user's socket, or
|
|
|
398
398
|
a live listener each fail with a specific error instead of being unlinked. A
|
|
399
399
|
clean `server.shutdown()` removes the file.
|
|
400
400
|
|
|
401
|
-
`mode`
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
401
|
+
`mode` is the socket's permission from birth: the socket is bound under a umask
|
|
402
|
+
narrowed to exactly that mode, so no other process ever sees it wider — a
|
|
403
|
+
`chmod` after listen leaves the umask rights on disk until it runs
|
|
404
|
+
([`bindUnixSocket`](native-io.md#a-unix-socket-private-from-birth)). Without
|
|
405
|
+
`mode` Bun creates the file `0755` under a normal umask — since `connect(2)`
|
|
406
|
+
requires *write* permission that is already owner-only in practice — but when
|
|
407
|
+
access to the socket **is** the credential, set `mode: 0o600` explicitly and let
|
|
408
|
+
the filesystem be the policy. The Socket.IO lifecycle (`socket`) cannot mount on a unix listener
|
|
406
409
|
(socket.io clients dial TCP only — construction error); Bun's own WebSocket
|
|
407
410
|
client cannot dial a unix path either. Unix listeners are Bun-only: `srvx`
|
|
408
411
|
resolves a numeric port unconditionally, so `stitchkit/node` does not offer
|
package/llms/stitchkit.txt
CHANGED
|
@@ -78,9 +78,10 @@ own, recorded as an ADR.
|
|
|
78
78
|
| `stitchkit/process/owner-loss` | bundled server entry (Bun, POSIX) | evolving | narrow bootstrap that keeps the process runner lazy while carrying its owner-loss guard in a single-file bundle |
|
|
79
79
|
| `stitchkit/files/packaging` | build time (Bun or Node) | evolving | installed native asset graph, integrity, Bun packaging plugin and the artifact loader check; a client bundled into one self-contained, hashed and verified file; no runtime install policy |
|
|
80
80
|
| `stitchkit/files` | server (Bun or Node) | stable | peer-free managed local-file boundary |
|
|
81
|
-
| `stitchkit/telegram` | server (Bun or Node) | evolving | peer-free Telegram platform primitives — Mini App `initData` verification, send-failure classification, one outbound budget per bot token with weighted albums and per-chat 429 pauses, resumable broadcasts, the operator channel with dedupe, a Bot API transport that separates a request that never left from an unknown outcome, local Bot API files, webhook ownership and durable webhook update intake |
|
|
81
|
+
| `stitchkit/telegram` | server (Bun or Node) | evolving | peer-free Telegram platform primitives — Mini App `initData` verification, send-failure classification, one outbound budget per bot token with weighted albums and per-chat 429 pauses, resumable broadcasts, the operator channel with dedupe, a Bot API transport that separates a request that never left from an unknown outcome, local Bot API files, the waveform of a voice message read from its PCM, webhook ownership and durable webhook update intake |
|
|
82
82
|
| `stitchkit/telegram/grammy` | server (Bun or Node) | evolving | the token's outbound budget as one grammY client transformer — a 429 that comes back as a response pauses its chat, and a cancelled wait is a request that never left |
|
|
83
83
|
| `stitchkit/telegram/html` | browser and server | evolving | Telegram's HTML as a tree — clean any markup to what Telegram accepts, cut long text into valid parts by what the reader sees, check markup before it is sent |
|
|
84
|
+
| `stitchkit/telegram/voice` | browser and server | evolving | the waveform of a voice message as one format — packed for `sendVoice` the way Telegram Desktop scales it, unpacked to draw it, a `getMe` read of whether the server takes it |
|
|
84
85
|
| `stitchkit/telegram/screens` | server (Bun or Node) | evolving | a bot's menus as declared screens over grammY — typed paths, actions and input, message reconciliation, state in any `StorageAdapter`, a test chat |
|
|
85
86
|
| `stitchkit/tracking` | browser **and** server | evolving | visitor-tracking mechanics — `createTrackingClient`, the tab-shared outbox, the page-leave beacon, attribution, the contract factory; no event vocabulary, no React |
|
|
86
87
|
| `stitchkit/tracking/contract` | browser **and** server | evolving | the wire shapes — the contract factory, event and visit schemas, the performance sample and its trust threshold; brings `zod` |
|
|
@@ -237,6 +238,7 @@ map — feature → packages:
|
|
|
237
238
|
| grammY lifecycle adapters (`stitchkit/application/grammy`) | `grammy` |
|
|
238
239
|
| Telegram platform primitives (`stitchkit/telegram`) | — (peer-free) |
|
|
239
240
|
| Telegram message markup (`stitchkit/telegram/html`) | — (peer-free) |
|
|
241
|
+
| Telegram voice waveforms (`stitchkit/telegram/voice`) | — (peer-free) |
|
|
240
242
|
| Telegram grammY client transformer (`stitchkit/telegram/grammy`) | `grammy` (types only; the bot brings it) |
|
|
241
243
|
| Telegram screens (`stitchkit/telegram/screens`) | `grammy` (types only; the bot brings it) |
|
|
242
244
|
| OpenTelemetry gauges (`stitchkit/application/opentelemetry`) | `@opentelemetry/api` |
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# stitchkit/telegram/voice — stitchkit docs slice
|
|
2
|
+
|
|
3
|
+
> Generated from the `docs/` tree by `bun run gen:llms`. The index of all slices is
|
|
4
|
+
> `llms.txt` in this package.
|
|
5
|
+
|
|
6
|
+
Contains: API reference: `stitchkit/telegram/voice` (docs/api/reference.md)
|
|
7
|
+
|
|
8
|
+
Also read:
|
|
9
|
+
- see `llms/telegram.txt` for the Telegram bots guide
|
|
10
|
+
|
|
11
|
+
==============================================================================
|
|
12
|
+
# API reference: `stitchkit/telegram/voice` (docs/api/reference.md)
|
|
13
|
+
==============================================================================
|
|
14
|
+
|
|
15
|
+
## `stitchkit/telegram/voice`
|
|
16
|
+
|
|
17
|
+
The waveform of a voice message — the bars under its play button — as one format for the server
|
|
18
|
+
that packs it and the page that draws it. No peer, no file, no network. →
|
|
19
|
+
[guide](../guide/telegram.md#voice-waveforms)
|
|
20
|
+
|
|
21
|
+
| Export | Kind | Summary |
|
|
22
|
+
|--------|------|---------|
|
|
23
|
+
| `packTelegramVoiceWaveform` | function | the 100 loudest absolute samples of 100 equal parts (`0`–`32768`) into the base64 of 63 bytes `sendVoice` takes: 5-bit levels packed little-endian, scaled like Telegram Desktop by 1.8 × the mean peak, never below a floor of 2500, so silence stays zero and a quiet recording stays low |
|
|
24
|
+
| `unpackTelegramVoiceWaveform` | function | the levels of a waveform, `0`–`31`, one per 5 bits: 100 from a packed one, as many as it holds from one Telegram drew |
|
|
25
|
+
| `readTelegramVoiceWaveformSupport` / `TelegramVoiceWaveformSupport` | function / _type_ | from a `getMe` result of any shape: `supported` only when the server declares `supports_voice_waveform` and `voice_waveform_version` 1; `version` as declared, `null` when none (the public Bot API) |
|
|
26
|
+
| `TelegramVoiceWaveformError` / `TelegramVoiceWaveformRefusal` | class / _type_ | `peak-count` / `peak-value` / `malformed` / `empty-pcm` / `truncated-pcm` |
|
|
27
|
+
| `TELEGRAM_VOICE_WAVEFORM_SAMPLES` / `TELEGRAM_VOICE_WAVEFORM_MAX_LEVEL` / `TELEGRAM_VOICE_WAVEFORM_VERSION` | constant | 100 parts, levels up to 31, field version 1 |
|
|
28
|
+
|
|
29
|
+
---
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# stitchkit/telegram — stitchkit docs slice, part 2 of 2
|
|
2
|
+
|
|
3
|
+
> Generated from the `docs/` tree by `bun run gen:llms`. The index of all slices is
|
|
4
|
+
> `llms.txt` in this package.
|
|
5
|
+
|
|
6
|
+
Parts of this slice:
|
|
7
|
+
- `llms/telegram.txt`: Guide: Telegram bots (docs/guide/telegram.md)
|
|
8
|
+
- `llms/telegram.2.txt`: API reference: `stitchkit/telegram` (docs/api/reference.md)
|
|
9
|
+
|
|
10
|
+
Also read:
|
|
11
|
+
- see `llms/telegram-screens.txt` for the Telegram screens guide
|
|
12
|
+
|
|
13
|
+
==============================================================================
|
|
14
|
+
# API reference: `stitchkit/telegram` (docs/api/reference.md)
|
|
15
|
+
==============================================================================
|
|
16
|
+
|
|
17
|
+
## `stitchkit/telegram`
|
|
18
|
+
|
|
19
|
+
Peer-free server-only Telegram platform primitives — the Bot API's own
|
|
20
|
+
protocols and the jobs every bot rewrote around them. Importing this resolves no
|
|
21
|
+
bot library; `stitchkit/application/grammy` remains the lifecycle adapter for an
|
|
22
|
+
injected grammY bot. → ADR 0143, ADR 0201, ADR 0274 — [guide](../guide/telegram.md)
|
|
23
|
+
|
|
24
|
+
| Export | Kind | Summary |
|
|
25
|
+
|--------|------|---------|
|
|
26
|
+
| `verifyTelegramInitData` | function | verify a Mini App `initData` signature against the bot token in constant time, before reading anything out of it |
|
|
27
|
+
| `VerifyTelegramInitDataOptions` | _type_ | raw `initData`, bot token, optional `maxAgeSeconds` bound and injected clock |
|
|
28
|
+
| `TelegramInitDataVerification` | _type_ | `{ valid: true, data }` or a refusal carrying its reason |
|
|
29
|
+
| `TelegramInitData` | _type_ | verified `user`/`receiver` as `TelegramUser`, `authDate`, `ageSeconds`, `queryId`, `startParam`, `chatType`, `chatInstance` and every signed pair in `raw` |
|
|
30
|
+
| `parseTelegramUser` / `TelegramUser` | function / _type_ | Telegram's `snake_case` user — grammY's `ctx.from`, a Bot API `User`, a Mini App `user` — as the one camelCase record initData returns too; `undefined` when it is not a user |
|
|
31
|
+
| `TelegramInitDataRefusal` | _type_ | `missing-hash` / `signature-mismatch` / `malformed` / `expired` — an expired string is not a forged one |
|
|
32
|
+
| `classifyTelegramSendFailure` | function | name a refused Bot API send and separate "retry this send" from "stop addressing this recipient" |
|
|
33
|
+
| `TelegramSendFailure` | _type_ | reason, `status`, Telegram-stated `retryAfterSeconds`, `retryable`, `recipientUnreachable` and which evidence produced the answer |
|
|
34
|
+
| `createTelegramBotTransport` / `TelegramBotTransportOptions` | function / _type_ | a `fetch` for the Bot API senders that connects before it writes, so a failure before the first byte is `TelegramNotDispatchedError`; connection attempt and budget, answer timeout and size, injectable resolver and socket factory — [guide](../guide/telegram.md#a-transport-that-knows-whether-a-request-left) |
|
|
35
|
+
| `TelegramFetch` / `TelegramBotTransportOpen` / `TelegramBotTransportResolve` / `TelegramBotTransportSocket` | _types_ | the `(url, init) => Promise<Response>` the senders take; the transport's socket factory, resolver and the structural socket it needs (a Node `net.Socket` or `tls.TLSSocket` fits) |
|
|
36
|
+
| `TelegramNotDispatchedError` / `TelegramNotDispatchedStage` | class / _type_ | a request that provably never left (`lookup`, `connect` or `request`), so repeating it cannot duplicate a message |
|
|
37
|
+
| `TelegramSendFailureReason` / `TELEGRAM_SEND_FAILURE_REASONS` | _type_ / constant | `blocked-by-user` / `user-deactivated` / `chat-not-found` / `not-started` / `bot-to-bot-disabled` / `rate-limited` / `message-invalid` / `server-error` / `not-dispatched` / `unknown`, and the same as a list; a `Record<TelegramSendFailureReason, …>` over them fails to compile when a reason is added |
|
|
38
|
+
| `telegramOutboundBudget` / `TelegramOutboundBudget` / `TelegramOutboundBudgetConfig` / `TelegramOutboundBudgetStats` / `TelegramOutboundCallOptions` / `TelegramOutboundChatOptions` / `TelegramOutboundLane` | function / _type_ | one token-wide outbound budget: one object per token in the process, strict 24 messages/s by default, weighted albums and multi-message copies, an `interactive` lane granted before `bulk`, `run(method, payload, signal, send, { lane, maxWaitMs })` as the transformer adapter (a 429 on a send pauses its `chat_id` whether `send` throws it or resolves with the Bot API's `{ ok: false, … }` body, and refusals from `tokenPauseChats` chats pause the token), `pause`/`pauseAfter` for 429, `waitUntilResumed` for non-send retries and `stats`; it paces and never retries, and no public value carries the token |
|
|
39
|
+
| `runTelegramBroadcast` | function | a resumable broadcast by `name` under a state `directory`: audience and journal durably recorded, pacing at `ratePerSecond` (25), exact retry delays within the finite declared budget, injected classifier, uncertain send outcomes never replayed, `dryRun`, one fenced runner per name |
|
|
40
|
+
| `TelegramBroadcastConfig` / `TelegramBroadcastSend` / `TelegramBroadcastReport` / `TelegramBroadcastRunOutcome` / `TelegramBroadcastOutcome` / `TelegramBroadcastRecipient` | _type_ | `name`, `directory`, `recipients()`, `send({ recipient, attempt })`, `maxAttempts`, `signal`, `onProgress`; counts `delivered` / `unreachable` / `failed` / `uncertain` / `pending` and `finished` / `stopped` / `halted` / `dry-run` |
|
|
41
|
+
| `TelegramBroadcastFailureSchema` / `TelegramBroadcastFailure` | schema / _type_ | injected `classify` answers retry-after/transient/permanent/ambiguous; exact provider delay is bounded by `maxRetryDelayMs` without shortening, unknown outcome remains uncertain and is never replayed |
|
|
42
|
+
| `telegramBroadcastSender` / `TelegramBroadcastSenderConfig` / `TelegramBroadcastMessage` | function / _type_ | the standard `send`: `sendMessage` with a text or `copyMessage` of a prepared message, through the Bot API |
|
|
43
|
+
| `createTelegramOperatorChannel` | function | the operator chat, apart from the journal: `post(text, topic?)` returns at once and never throws; paced sends into forum topics, 429 honoured, oldest dropped on overflow, `drain(signal)` and `close()` for the way down |
|
|
44
|
+
| `TelegramOperatorChannelConfig` / `TelegramOperatorChannel` / `TelegramOperatorMessage` / `TelegramOperatorDrop` / `TelegramChatId` | _type_ | `chatId`, `topics`, `send`, `maxQueued`, `minIntervalMs`, `maxAttempts`, `onDropped`, `sensitivePatterns` and `sensitiveValues` (a bot token is always masked), `dedupe`; a drop is `overflow` / `refused` / `attempts` / `closed` / `repeated` / `over-budget` with its classification |
|
|
45
|
+
| `createTelegramOperatorDedupe` / `TelegramOperatorDedupeVerdict` | function / _type_ | the channel's dedupe window alone, for a sender with its own bot and retry: `(text, topic?)` → `{ send: true, text }` with the held-back counts, or `{ send: false, reason: 'repeated' \| 'over-budget' }` |
|
|
46
|
+
| `TelegramOperatorDedupe` | _type_ | `windowMs` (10 min): one message per `fingerprint` per window, the next one sent carries `repeatedLine(count)`; `maxPerWindow` (20) across fingerprints, the overflow counted onto the next one sent with `overBudgetLine(count)`; `now` |
|
|
47
|
+
| `telegramOperatorSender` / `TelegramOperatorSenderConfig` | function / _type_ | the standard `send`: `sendMessage` into the chat and topic, plain text unless `parseMode`; with `'HTML'` the markup is cleaned and cut by what it shows, so the channel's cut never leaves a tag open |
|
|
48
|
+
| `createTelegramLocalFiles` | function | files the local Bot API server wrote under `<root>/<token>/`: `resolve(file_path)` and `remove(file_path)` only inside the bot's directory, judged on real paths so a link is judged by where it leads; `check()` for readiness. Recommended root variable: `BOT_API_FILES_ROOT` |
|
|
49
|
+
| `TelegramLocalFilesConfig` / `TelegramLocalFiles` / `TelegramLocalFilesCheck` / `TelegramLocalFileError` / `TelegramLocalFileRefusal` | _type_ / class | `root`, `token`; refusals `root-not-absolute` / `bot-directory-unavailable` / `outside-bot-directory` / `missing` / `not-a-file`, never carrying the path or the token |
|
|
50
|
+
| `readTelegramVoiceWaveform` / `ReadTelegramVoiceWaveformOptions` | function / _type_ | the packed waveform `sendVoice` takes, from a mono 16-bit little-endian PCM side copy of the recording, read in chunks; `signal` stops it between chunks; an empty or cut file is refused with `TelegramVoiceWaveformError` (`stitchkit/telegram/voice`), never named in it — [guide](../guide/telegram.md#voice-waveforms) |
|
|
51
|
+
| `callTelegramBotApi` / `TelegramBotApiCall` / `TelegramBotApiError` | function / _type_ / class | one Bot API method over `fetch`; a refusal keeps `error_code`, `description` and `parameters` for the classifier, and no error names the URL |
|
|
52
|
+
| `TELEGRAM_BOT_TOKEN_PATTERN` / `redactTelegramBotToken` | constant / function | the secret half of a bot token — the bot's id before the colon is not matched; `redact` and every logger on it mask it already, `redactTelegramBotToken(text)` masks every token in a string to `123456:[redacted]` |
|
|
53
|
+
| `claimTelegramWebhook` | function | set the webhook only where it already points here, or by naming the host it is taken from; confirm Telegram holds it; pending updates kept unless `dropPendingUpdates` |
|
|
54
|
+
| `ClaimTelegramWebhookConfig` / `TelegramWebhookConfig` / `TelegramWebhookClaim` | _type_ | `token`, `url`, `secret`, `apiRoot`, `fetch`, `signal`; `takeoverFrom` (a host, or `'none'`), `allowedUpdates`, `maxConnections`, `dropPendingUpdates`; the claim's tagged `url`, `takenFrom`, `pendingUpdates` |
|
|
55
|
+
| `TelegramWebhookClaimError` / `TelegramWebhookRefusal` / `TELEGRAM_WEBHOOK_NONE` | class / _type_ / constant | `owned-elsewhere` / `other-secret` / `not-confirmed` with `ownerHost` — a host, never a path; `'none'` names no webhook |
|
|
56
|
+
| `telegramWebhookUrl` | function | the address with an `owner` tag derived from the secret: equal for one secret, different for another, the path untouched |
|
|
57
|
+
| `checkTelegramWebhook` / `TelegramWebhookState` | function / _type_ | whether the webhook still points here: `owned`, `ownerHost`, `pendingUpdates`, Telegram's `lastError` |
|
|
58
|
+
| `receiveTelegramWebhook` / `ReceiveTelegramWebhookOptions` / `TelegramUpdateAcceptance` | function / _type_ | one webhook `Request`: 403 without the secret (compared in constant time), 405 for another method, 400 for no update, 200 once `accept` recorded it |
|
|
59
|
+
| `createTelegramUpdateIntake` | function | webhook updates recorded before Telegram is answered and handled after: chat order kept, other chats alongside up to `maxConcurrent`, a renewed lease and immutable fence per attempt, a sweep that takes over what a restart or a dead process left, retries, `maxAttempts`, optional recoverable exhaustion delivery, finished updates remembered `retainMs` to refuse repeats; at least once |
|
|
60
|
+
| `TelegramUpdateIntakeConfig` / `TelegramUpdateAttemptIntakeConfig` / `TelegramUpdateIntakeOptions` / `TelegramUpdateIntake` / `TelegramUpdateEnvelope` / `TelegramUpdateFailure` / `TelegramUpdateStoreStep` | _type_ | `store`, unchanged `handle(update)` or attempt-aware `handleAttempt(update, context)` (a grammY `BotError` is unwrapped), shared `retry`, `maxAttempts` (5), `leaseMs` (120 000), `pendingGraceMs` (60 000), `sweepEveryMs` (30 000), `retainMs` (24 h), `maxConcurrent` (32), `onFailure`, durable `handleExhaustion`, `onExhaustionFailure`, `onStoreError`, `now`; `accept(body)`, `start()`, `sweep()`, `idle()`, `close()` |
|
|
61
|
+
| `TelegramUpdateAttemptContext` / `TelegramUpdateAttemptIdentity` / `TelegramUpdateOwnershipLostError` | _type_ / class | immutable `{ updateId, attempt, claimId }` fence plus `ownerLost`; the persisted opaque claim token prevents a stale capability from matching after prune/re-add, while a store check in the consumer's DB transaction fences a domain write |
|
|
62
|
+
| `TelegramUpdateExhaustion` / `TelegramUpdateExhaustionFailure` / `StoredTelegramUpdateExhaustion` / `TelegramUpdateExhaustionQuery` | _type_ | a terminal update/attempt/error retained in the update store until `handleExhaustion` resolves; ordered `{ limit, afterUpdateId? }` pages prevent a failing first batch from starving later rows; delivery failures are observational and leave it due |
|
|
63
|
+
| `TelegramUpdateStore` / `StoredTelegramUpdate` / `TelegramUpdateState` / `TelegramUpdateSettlement` / `TelegramUpdateClaimOptions` / `TelegramUpdateDueQuery` | _type_ | the base store an intake runs on: `add`, `claim`, `renew`, `settle`, `due`, `prune`, each atomic on one record — a claim takes `pending`, a due `failed` or a lapsed `processing`; renew and settle only by the attempt holding it; `due` returns one page and continues strictly after `afterUpdateId` |
|
|
64
|
+
| `TelegramUpdateFencedStore` / `TelegramUpdateDurableStore` | _type_ | reference-store capabilities: `claimOwned` creates and returns the persisted identity, `renewOwned`, `owns(identity, at)` and `settleOwned(identity, settlement)` act only on that exact unexpired claim; `exhaust`, `dueExhaustions`, `acknowledgeExhaustion` keep a final consumer obligation in the same row until exact acknowledgement |
|
|
65
|
+
| `memoryTelegramUpdateStore` | function | the store in this process's memory — tests, or a bot that accepts losing unhandled updates to a restart |
|
|
66
|
+
| `sqliteTelegramUpdateStore` / `SqliteTelegramUpdateStoreConfig` / `TelegramSqliteDatabase` | function / _type_ | the store in SQLite over the handle the application opened — `bun:sqlite` `Database` or `node:sqlite` `DatabaseSync`; `table` (default `telegram_updates`) created when missing |
|
|
67
|
+
| `postgresTelegramUpdateStore` / `PostgresTelegramUpdateStoreConfig` / `TelegramPostgresQuery` | function / _type_ | the store in Postgres over the client the application holds, as one `query(text, parameters)` returning rows — Bun `sql.unsafe`, Prisma `$queryRawUnsafe`, `pg` `pool.query`; each rule one conditional statement; `table`, `createTable` (default `true`) |
|
|
68
|
+
| `postgresTelegramUpdateStoreSchema` | function | the table, idempotent `claim_id` upgrade and index as a statement for a migration, safe to run twice; required before fenced methods when `createTable: false`, while legacy base methods remain compatible with the prior table |
|
|
69
|
+
| `checkTelegramUpdateStore` | function | put any store through every rule, each on a fresh store from `make`, concurrent claims included; resolves with the violations, empty when it keeps them |
|
|
70
|
+
|
|
71
|
+
---
|