stitchkit 0.106.1 → 0.108.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/CHANGELOG.md +151 -0
- package/README.md +2 -0
- package/darwin-native.cjs +17 -4
- package/dist/agent-runtime/deferred-tool-types.d.ts +6 -27
- package/dist/agent-runtime/deferred-tool-types.d.ts.map +1 -1
- package/dist/browser/stream.d.ts +38 -12
- package/dist/browser/stream.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/browser.js +2 -3
- package/dist/entrypoints/agent-runtime/coding-tools.js +6 -8
- package/dist/entrypoints/agent-runtime/harness.js +7 -11
- package/dist/entrypoints/agent-runtime/realtime.js +2 -3
- package/dist/entrypoints/agent-runtime/sandbox.js +6 -8
- package/dist/entrypoints/agent-runtime.d.ts +2 -1
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime.js +20 -23
- package/dist/entrypoints/application/diagnostic-journal.js +3 -3
- package/dist/entrypoints/application/directory-inbox.js +8 -9
- package/dist/entrypoints/application/grammy.js +3 -3
- package/dist/entrypoints/application.js +7 -8
- package/dist/entrypoints/bin/upgrade-cli.d.ts +32 -0
- package/dist/entrypoints/bin/upgrade-cli.d.ts.map +1 -1
- package/dist/entrypoints/bin/upgrade-cli.js +451 -8
- package/dist/entrypoints/cli/publish.js +10 -11
- package/dist/entrypoints/cli.js +12 -16
- package/dist/entrypoints/contract.js +1 -1
- package/dist/entrypoints/files/packaging.d.ts +3 -1
- package/dist/entrypoints/files/packaging.d.ts.map +1 -1
- package/dist/entrypoints/files/packaging.js +171 -55
- package/dist/entrypoints/files.js +16 -16
- package/dist/entrypoints/index.d.ts +1 -1
- package/dist/entrypoints/index.d.ts.map +1 -1
- package/dist/entrypoints/index.js +47 -41
- package/dist/entrypoints/node.js +27 -29
- package/dist/entrypoints/observability.js +10 -12
- package/dist/entrypoints/process.js +2 -2
- package/dist/entrypoints/react.js +3 -4
- package/dist/entrypoints/remote.js +8 -9
- package/dist/entrypoints/server.js +48 -51
- package/dist/entrypoints/telegram/html.js +3 -3
- package/dist/entrypoints/telegram/screens.js +6 -6
- package/dist/entrypoints/telegram.d.ts +2 -0
- package/dist/entrypoints/telegram.d.ts.map +1 -1
- package/dist/entrypoints/telegram.js +344 -11
- package/dist/entrypoints/testing.d.ts +1 -0
- package/dist/entrypoints/testing.d.ts.map +1 -1
- package/dist/entrypoints/testing.js +138 -11
- package/dist/entrypoints/tools/connections.js +11 -11
- package/dist/entrypoints/tools/invoker.js +5 -9
- package/dist/entrypoints/tools/mcp.js +8 -14
- package/dist/entrypoints/tools.js +19 -25
- package/dist/entrypoints/tracking.js +3 -3
- package/dist/files/native-artifact.d.ts +14 -0
- package/dist/files/native-artifact.d.ts.map +1 -0
- package/dist/files/native-packaging-layout.d.ts +11 -2
- package/dist/files/native-packaging-layout.d.ts.map +1 -1
- package/dist/files/native-packaging-plugin.d.ts +53 -0
- package/dist/files/native-packaging-plugin.d.ts.map +1 -0
- package/dist/files/native-packaging.d.ts +44 -43
- package/dist/files/native-packaging.d.ts.map +1 -1
- package/dist/{index-v5ee8ath.js → index-1h2zv8rx.js} +10 -40
- package/dist/index-2kbysk9s.js +42 -0
- package/dist/{index-wbhdzxar.js → index-2s6fpehp.js} +5 -5
- package/dist/{index-ksfagmyz.js → index-4qh90tyw.js} +8 -8
- package/dist/{index-yvfk3y36.js → index-636mggad.js} +4 -3
- package/dist/{index-f199nfq5.js → index-6y9t2fwz.js} +7 -7
- package/dist/{index-w8etpm8j.js → index-9j2atjte.js} +1 -1
- package/dist/index-a5qr2rj6.js +26 -0
- package/dist/{index-azx12jgv.js → index-bh2ht9y5.js} +13 -7
- package/dist/{index-pz3y6b6g.js → index-cx2nh595.js} +3 -3
- package/dist/{index-2k91mewf.js → index-dm2fv45z.js} +9 -9
- package/dist/{index-9bskshe3.js → index-dwf0gymy.js} +10 -10
- package/dist/{index-qaqbdm7s.js → index-h7qms8f9.js} +8 -8
- package/dist/{index-drs41arz.js → index-ktjmgq9p.js} +1 -1
- package/dist/{index-916yh4e2.js → index-mep4sb48.js} +14 -14
- package/dist/{index-wdy68sh6.js → index-njs9gvrh.js} +17 -17
- package/dist/{index-1ptj98e0.js → index-nx49x0tw.js} +2 -2
- package/dist/{index-1pwwan01.js → index-p5kx5vqd.js} +214 -59
- package/dist/{index-sj28htvf.js → index-pvh3z03x.js} +1 -1
- package/dist/{index-r393tnfp.js → index-q6crhe1n.js} +4 -4
- package/dist/{index-dsnjzb62.js → index-t2bsd0hm.js} +1 -1
- package/dist/{index-4vsby8n8.js → index-w9mqgnz9.js} +1 -1
- package/dist/{index-z23rfxhj.js → index-xmgjtkvr.js} +1 -1
- package/dist/{index-e05cjgtf.js → index-xvj9h8yh.js} +28 -1
- package/dist/{index-gr5g3xfw.js → index-yz8x0hbx.js} +1 -1
- package/dist/{index-gxm9rc97.js → index-zrtrjkbf.js} +1 -1
- package/dist/internal/bounded-lines.d.ts +46 -2
- package/dist/internal/bounded-lines.d.ts.map +1 -1
- package/dist/internal/darwin-binding-error.d.ts +9 -1
- package/dist/internal/darwin-binding-error.d.ts.map +1 -1
- package/dist/internal/darwin-binding.d.ts.map +1 -1
- package/dist/internal/process-identity.d.ts.map +1 -1
- package/dist/internal/until-aborted.d.ts +9 -0
- package/dist/internal/until-aborted.d.ts.map +1 -0
- package/dist/internal/upgrade-affects.d.ts +58 -0
- package/dist/internal/upgrade-affects.d.ts.map +1 -0
- package/dist/internal/upgrade-plan.d.ts +20 -0
- package/dist/internal/upgrade-plan.d.ts.map +1 -1
- package/dist/internal/upgrade-usage.d.ts +61 -0
- package/dist/internal/upgrade-usage.d.ts.map +1 -0
- package/dist/telegram/bot-api.d.ts +10 -4
- package/dist/telegram/bot-api.d.ts.map +1 -1
- package/dist/telegram/broadcast.d.ts +2 -1
- package/dist/telegram/broadcast.d.ts.map +1 -1
- package/dist/telegram/not-dispatched.d.ts +26 -0
- package/dist/telegram/not-dispatched.d.ts.map +1 -0
- package/dist/telegram/operator-channel.d.ts +2 -1
- package/dist/telegram/operator-channel.d.ts.map +1 -1
- package/dist/telegram/send-failure.d.ts +4 -3
- package/dist/telegram/send-failure.d.ts.map +1 -1
- package/dist/telegram/transport-connect.d.ts +38 -0
- package/dist/telegram/transport-connect.d.ts.map +1 -0
- package/dist/telegram/transport.d.ts +43 -0
- package/dist/telegram/transport.d.ts.map +1 -0
- package/dist/telegram/webhook.d.ts +2 -1
- package/dist/telegram/webhook.d.ts.map +1 -1
- package/dist/testing/manual-clock.d.ts +82 -0
- package/dist/testing/manual-clock.d.ts.map +1 -0
- package/dist/tools/internal/surface-projector.d.ts +0 -7
- package/dist/tools/internal/surface-projector.d.ts.map +1 -1
- package/dist/tools/runtime-tool-declaration.d.ts +11 -0
- package/dist/tools/runtime-tool-declaration.d.ts.map +1 -1
- package/dist/tools/runtime-tool.d.ts +2 -3
- package/dist/tools/runtime-tool.d.ts.map +1 -1
- package/llms/files-packaging.txt +13 -6
- package/llms/process.txt +71 -15
- package/llms/stitchkit.2.txt +211 -628
- package/llms/stitchkit.txt +635 -10
- package/llms/telegram.txt +36 -3
- package/llms/testing.txt +47 -0
- package/llms/{upgrading-0.96.0-0.106.0.txt → upgrading-0.100.0-0.108.0.txt} +112 -144
- package/llms/{upgrading-0.37.0-0.53.0.txt → upgrading-0.37.0-0.58.0.txt} +209 -3
- package/llms/{upgrading-0.55.0-0.68.0.txt → upgrading-0.59.0-0.71.0.txt} +149 -209
- package/llms/{upgrading-0.69.0-0.95.0.txt → upgrading-0.72.0-0.99.0.txt} +137 -149
- package/llms/upgrading.txt +36 -4
- package/llms-full.txt +360 -39
- package/llms.txt +10 -10
- package/package.json +2 -1
- package/llms/stitchkit.3.txt +0 -177
- package/dist/{index-cazts87s.js → index-07dcf2yn.js} +3 -3
- package/dist/{index-n1nszyk0.js → index-7jvwrjqa.js} +3 -3
- package/dist/{index-cmzvhhtd.js → index-85qve8mq.js} +3 -3
- package/dist/{index-rpzewktb.js → index-fynr93w4.js} +3 -3
- package/dist/{index-37asdw3a.js → index-k7qdkh3n.js} +3 -3
- package/dist/{index-x7w1z6pf.js → index-q4hjtyye.js} +4 -4
- package/dist/{index-7n68nmc6.js → index-y3nemndz.js} +3 -3
- package/dist/{index-12zsej7b.js → index-y70v24cw.js} +3 -3
- package/dist/{index-pzb63z66.js → index-ykdcnq1f.js} +3 -3
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import"../index-
|
|
1
|
+
import"../index-2kbysk9s.js";
|
|
2
2
|
import {
|
|
3
3
|
ProcessInstanceSchema2,
|
|
4
4
|
observeProcessInstance2,
|
|
5
5
|
probeProcessOwner2
|
|
6
|
-
} from "../index-
|
|
6
|
+
} from "../index-bh2ht9y5.js";
|
|
7
7
|
import {
|
|
8
8
|
NativeCommandError2,
|
|
9
9
|
startNativeCommand
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isAbortLikeError
|
|
3
|
+
} from "../index-7jvwrjqa.js";
|
|
1
4
|
import {
|
|
2
5
|
ApiError2
|
|
3
6
|
} from "../index-kfjkb396.js";
|
|
4
|
-
import"../index-yex7eg1v.js";
|
|
5
|
-
import {
|
|
6
|
-
isAbortLikeError
|
|
7
|
-
} from "../index-n1nszyk0.js";
|
|
8
7
|
import {
|
|
9
8
|
isRecord
|
|
10
9
|
} from "../index-9jfdm5tg.js";
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ApiError2
|
|
3
|
-
} from "../index-kfjkb396.js";
|
|
4
1
|
import"../index-m38ej7e5.js";
|
|
5
2
|
import"../index-h2fhjqy7.js";
|
|
3
|
+
import"../index-7jvwrjqa.js";
|
|
6
4
|
import {
|
|
7
5
|
endpointHasArguments,
|
|
8
6
|
createClient2
|
|
9
|
-
} from "../index-
|
|
10
|
-
import"../index-yex7eg1v.js";
|
|
11
|
-
import"../index-n1nszyk0.js";
|
|
7
|
+
} from "../index-p5kx5vqd.js";
|
|
12
8
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} from "../index-j9gxbztg.js";
|
|
9
|
+
ApiError2
|
|
10
|
+
} from "../index-kfjkb396.js";
|
|
16
11
|
import {
|
|
17
12
|
contractMethodFields
|
|
18
13
|
} from "../index-1bx1xv1k.js";
|
|
14
|
+
import {
|
|
15
|
+
AppError2,
|
|
16
|
+
STITCH_ERROR_STATUS2
|
|
17
|
+
} from "../index-j9gxbztg.js";
|
|
19
18
|
import {
|
|
20
19
|
isRecord
|
|
21
20
|
} from "../index-9jfdm5tg.js";
|
|
@@ -1,27 +1,33 @@
|
|
|
1
|
-
import"../index-
|
|
2
|
-
import"../index-
|
|
3
|
-
import"../index-
|
|
4
|
-
import"../index-v5ee8ath.js";
|
|
5
|
-
import {
|
|
6
|
-
createFileStateStore2
|
|
7
|
-
} from "../index-1ptj98e0.js";
|
|
8
|
-
import {
|
|
9
|
-
AppError2,
|
|
10
|
-
notFound2,
|
|
11
|
-
badRequest2,
|
|
12
|
-
unauthorized2,
|
|
13
|
-
forbidden2,
|
|
14
|
-
conflict2,
|
|
15
|
-
rateLimited2,
|
|
16
|
-
STITCH_ERROR_STATUS2,
|
|
17
|
-
isStitchErrorCode2,
|
|
18
|
-
appError2
|
|
19
|
-
} from "../index-j9gxbztg.js";
|
|
1
|
+
import"../index-2kbysk9s.js";
|
|
2
|
+
import"../index-bh2ht9y5.js";
|
|
3
|
+
import"../index-t2bsd0hm.js";
|
|
20
4
|
import {
|
|
21
5
|
errorCode2,
|
|
22
6
|
normalizeError2
|
|
23
|
-
} from "../index-
|
|
24
|
-
import
|
|
7
|
+
} from "../index-fynr93w4.js";
|
|
8
|
+
import {
|
|
9
|
+
DEFAULT_CONTRACT_STREAM_FRAME_BYTES2
|
|
10
|
+
} from "../index-h2fhjqy7.js";
|
|
11
|
+
import {
|
|
12
|
+
joinRoutePath,
|
|
13
|
+
parseTrailingWildcard
|
|
14
|
+
} from "../index-m38ej7e5.js";
|
|
15
|
+
import {
|
|
16
|
+
ShutdownStateSchema2,
|
|
17
|
+
ShutdownOptionsSchema2,
|
|
18
|
+
ShutdownStatusSchema2,
|
|
19
|
+
ShutdownResultSchema2,
|
|
20
|
+
createServerLifecycle
|
|
21
|
+
} from "../index-q0th8q0z.js";
|
|
22
|
+
import {
|
|
23
|
+
toJsonSchema,
|
|
24
|
+
jsonSchemaFields
|
|
25
|
+
} from "../index-ct75c3at.js";
|
|
26
|
+
import"../index-ykdcnq1f.js";
|
|
27
|
+
import"../index-4s0fep5q.js";
|
|
28
|
+
import"../index-fsw1ybf3.js";
|
|
29
|
+
import"../index-q4hjtyye.js";
|
|
30
|
+
import"../index-xqhede6x.js";
|
|
25
31
|
import {
|
|
26
32
|
contextContributionDelta,
|
|
27
33
|
prepareContextContribution,
|
|
@@ -42,35 +48,14 @@ import {
|
|
|
42
48
|
socketIoLane2,
|
|
43
49
|
UnixClientTransportError2,
|
|
44
50
|
createUnixClientTransport2
|
|
45
|
-
} from "../index-
|
|
51
|
+
} from "../index-njs9gvrh.js";
|
|
46
52
|
import {
|
|
47
|
-
|
|
48
|
-
} from "../index-
|
|
49
|
-
import {
|
|
50
|
-
ShutdownStateSchema2,
|
|
51
|
-
ShutdownOptionsSchema2,
|
|
52
|
-
ShutdownStatusSchema2,
|
|
53
|
-
ShutdownResultSchema2,
|
|
54
|
-
createServerLifecycle
|
|
55
|
-
} from "../index-q0th8q0z.js";
|
|
56
|
-
import {
|
|
57
|
-
joinRoutePath,
|
|
58
|
-
parseTrailingWildcard
|
|
59
|
-
} from "../index-m38ej7e5.js";
|
|
60
|
-
import"../index-1bx1xv1k.js";
|
|
61
|
-
import {
|
|
62
|
-
toJsonSchema,
|
|
63
|
-
jsonSchemaFields
|
|
64
|
-
} from "../index-ct75c3at.js";
|
|
65
|
-
import"../index-pzb63z66.js";
|
|
66
|
-
import"../index-4s0fep5q.js";
|
|
67
|
-
import"../index-fsw1ybf3.js";
|
|
68
|
-
import"../index-x7w1z6pf.js";
|
|
69
|
-
import"../index-xqhede6x.js";
|
|
53
|
+
createFileStateStore2
|
|
54
|
+
} from "../index-nx49x0tw.js";
|
|
70
55
|
import {
|
|
71
56
|
bindRealtimeServer2
|
|
72
|
-
} from "../index-
|
|
73
|
-
import"../index-
|
|
57
|
+
} from "../index-xmgjtkvr.js";
|
|
58
|
+
import"../index-w9mqgnz9.js";
|
|
74
59
|
import {
|
|
75
60
|
withDeadline
|
|
76
61
|
} from "../index-9tqbxv5p.js";
|
|
@@ -81,14 +66,14 @@ import {
|
|
|
81
66
|
verifyJwt2,
|
|
82
67
|
signJwt2,
|
|
83
68
|
verifyPkce2
|
|
84
|
-
} from "../index-
|
|
69
|
+
} from "../index-k7qdkh3n.js";
|
|
85
70
|
import {
|
|
86
71
|
defineMultipartStream2,
|
|
87
72
|
createMultipartStream2,
|
|
88
73
|
implement2,
|
|
89
74
|
createImplement2,
|
|
90
75
|
createScopedImplement2
|
|
91
|
-
} from "../index-
|
|
76
|
+
} from "../index-85qve8mq.js";
|
|
92
77
|
import {
|
|
93
78
|
deriveCodeChallenge2
|
|
94
79
|
} from "../index-ap3gqe56.js";
|
|
@@ -96,7 +81,7 @@ import {
|
|
|
96
81
|
isWithinDir2,
|
|
97
82
|
realPathWithinDir
|
|
98
83
|
} from "../index-5cc6r990.js";
|
|
99
|
-
import"../index-
|
|
84
|
+
import"../index-1bx1xv1k.js";
|
|
100
85
|
import {
|
|
101
86
|
DEFAULT_CORS_ALLOW_HEADERS2,
|
|
102
87
|
DEFAULT_CORS_EXPOSE_HEADERS2,
|
|
@@ -105,7 +90,7 @@ import {
|
|
|
105
90
|
} from "../index-yk4g8805.js";
|
|
106
91
|
import {
|
|
107
92
|
getTraceId2
|
|
108
|
-
} from "../index-
|
|
93
|
+
} from "../index-y3nemndz.js";
|
|
109
94
|
import {
|
|
110
95
|
generateTraceId2,
|
|
111
96
|
resolveTraceId2,
|
|
@@ -118,6 +103,18 @@ import {
|
|
|
118
103
|
zodIssues2,
|
|
119
104
|
formatZodError2
|
|
120
105
|
} from "../index-1eeqpadm.js";
|
|
106
|
+
import {
|
|
107
|
+
AppError2,
|
|
108
|
+
notFound2,
|
|
109
|
+
badRequest2,
|
|
110
|
+
unauthorized2,
|
|
111
|
+
forbidden2,
|
|
112
|
+
conflict2,
|
|
113
|
+
rateLimited2,
|
|
114
|
+
STITCH_ERROR_STATUS2,
|
|
115
|
+
isStitchErrorCode2,
|
|
116
|
+
appError2
|
|
117
|
+
} from "../index-j9gxbztg.js";
|
|
121
118
|
import {
|
|
122
119
|
isUnsafeKey
|
|
123
120
|
} from "../index-zsarb5xp.js";
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
checkTelegramHtml2
|
|
3
|
+
} from "../../index-rz3z13e9.js";
|
|
1
4
|
import {
|
|
2
5
|
TELEGRAM_TEXT_LIMIT2,
|
|
3
6
|
TELEGRAM_CAPTION_LIMIT2,
|
|
@@ -9,9 +12,6 @@ import {
|
|
|
9
12
|
splitTelegramHtml2,
|
|
10
13
|
truncateTelegramHtml2
|
|
11
14
|
} from "../../index-nmaqxdx7.js";
|
|
12
|
-
import {
|
|
13
|
-
checkTelegramHtml2
|
|
14
|
-
} from "../../index-rz3z13e9.js";
|
|
15
15
|
export {
|
|
16
16
|
TELEGRAM_CAPTION_LIMIT2 as TELEGRAM_CAPTION_LIMIT,
|
|
17
17
|
TELEGRAM_TEXT_LIMIT2 as TELEGRAM_TEXT_LIMIT,
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TELEGRAM_TEXT_LIMIT2,
|
|
3
|
-
TELEGRAM_CAPTION_LIMIT2,
|
|
4
|
-
escapeTelegramHtml2
|
|
5
|
-
} from "../../index-nmaqxdx7.js";
|
|
6
1
|
import {
|
|
7
2
|
joinRoutePath,
|
|
8
3
|
parseRoutePattern
|
|
9
4
|
} from "../../index-m38ej7e5.js";
|
|
10
5
|
import {
|
|
11
6
|
classifyTelegramEditRefusal
|
|
12
|
-
} from "../../index-
|
|
7
|
+
} from "../../index-xvj9h8yh.js";
|
|
13
8
|
import {
|
|
14
9
|
checkTelegramHtml2
|
|
15
10
|
} from "../../index-rz3z13e9.js";
|
|
11
|
+
import {
|
|
12
|
+
TELEGRAM_TEXT_LIMIT2,
|
|
13
|
+
TELEGRAM_CAPTION_LIMIT2,
|
|
14
|
+
escapeTelegramHtml2
|
|
15
|
+
} from "../../index-nmaqxdx7.js";
|
|
16
16
|
import {
|
|
17
17
|
createMutationQueue
|
|
18
18
|
} from "../../index-sykb5ag7.js";
|
|
@@ -3,9 +3,11 @@ export { runTelegramBroadcast, type TelegramBroadcastConfig, type TelegramBroadc
|
|
|
3
3
|
export { type TelegramBroadcastFailure, TelegramBroadcastFailureSchema, } from '../telegram/broadcast-failure.js';
|
|
4
4
|
export { type TelegramInitData, type TelegramInitDataRefusal, type TelegramInitDataVerification, type VerifyTelegramInitDataOptions, verifyTelegramInitData, } from '../telegram/init-data.js';
|
|
5
5
|
export { createTelegramLocalFiles, TelegramLocalFileError, type TelegramLocalFileRefusal, type TelegramLocalFiles, type TelegramLocalFilesCheck, type TelegramLocalFilesConfig, } from '../telegram/local-files.js';
|
|
6
|
+
export { TelegramNotDispatchedError, type TelegramNotDispatchedStage, } from '../telegram/not-dispatched.js';
|
|
6
7
|
export { createTelegramOperatorChannel, type TelegramChatId, type TelegramOperatorChannel, type TelegramOperatorChannelConfig, type TelegramOperatorDrop, type TelegramOperatorMessage, type TelegramOperatorSenderConfig, telegramOperatorSender, } from '../telegram/operator-channel.js';
|
|
7
8
|
export { createTelegramOperatorDedupe, type TelegramOperatorDedupe, type TelegramOperatorDedupeVerdict, } from '../telegram/operator-dedupe.js';
|
|
8
9
|
export { classifyTelegramSendFailure, TELEGRAM_SEND_FAILURE_REASONS, type TelegramSendFailure, type TelegramSendFailureReason, } from '../telegram/send-failure.js';
|
|
10
|
+
export { createTelegramBotTransport, type TelegramBotTransportOpen, type TelegramBotTransportOptions, type TelegramBotTransportResolve, type TelegramBotTransportSocket, type TelegramFetch, } from '../telegram/transport.js';
|
|
9
11
|
export { createTelegramUpdateIntake, type TelegramUpdateEnvelope, type TelegramUpdateFailure, type TelegramUpdateIntake, type TelegramUpdateIntakeConfig, type TelegramUpdateStoreStep, } from '../telegram/update-intake.js';
|
|
10
12
|
export { memoryTelegramUpdateStore, type StoredTelegramUpdate, type TelegramUpdateClaimOptions, type TelegramUpdateDueQuery, type TelegramUpdateSettlement, type TelegramUpdateState, type TelegramUpdateStore, } from '../telegram/update-store.js';
|
|
11
13
|
export { checkTelegramUpdateStore } from '../telegram/update-store-check.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telegram.d.ts","sourceRoot":"","sources":["../../src/entrypoints/telegram.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,0BAA0B,EAC1B,KAAK,kBAAkB,EACvB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,oBAAoB,EACpB,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,EAChC,KAAK,qBAAqB,EAC1B,KAAK,6BAA6B,EAClC,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,KAAK,wBAAwB,EAC7B,8BAA8B,GAC/B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EAClC,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,GAC9B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,6BAA6B,EAC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1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BOT_TOKEN_SECRET
|
|
3
|
-
} from "../index-sznqf8fx.js";
|
|
4
1
|
import {
|
|
5
2
|
backoffDelay
|
|
6
3
|
} from "../index-g6a3na27.js";
|
|
4
|
+
import"../index-2kbysk9s.js";
|
|
5
|
+
import"../index-bh2ht9y5.js";
|
|
7
6
|
import {
|
|
7
|
+
attemptExclusiveLock
|
|
8
|
+
} from "../index-t2bsd0hm.js";
|
|
9
|
+
import {
|
|
10
|
+
TelegramNotDispatchedError2,
|
|
11
|
+
isTelegramNotDispatchedError,
|
|
8
12
|
TELEGRAM_SEND_FAILURE_REASONS2,
|
|
9
13
|
classifyTelegramSendFailure2
|
|
10
|
-
} from "../index-
|
|
11
|
-
import"../index-j4zh647a.js";
|
|
12
|
-
import {
|
|
13
|
-
attemptExclusiveLock
|
|
14
|
-
} from "../index-dsnjzb62.js";
|
|
15
|
-
import"../index-azx12jgv.js";
|
|
16
|
-
import"../index-v5ee8ath.js";
|
|
14
|
+
} from "../index-xvj9h8yh.js";
|
|
17
15
|
import {
|
|
18
16
|
TELEGRAM_TEXT_LIMIT2,
|
|
19
17
|
truncateTelegramHtml2
|
|
20
18
|
} from "../index-nmaqxdx7.js";
|
|
19
|
+
import {
|
|
20
|
+
untilAborted
|
|
21
|
+
} from "../index-a5qr2rj6.js";
|
|
21
22
|
import {
|
|
22
23
|
raceAbort
|
|
23
24
|
} from "../index-b0kddvzw.js";
|
|
24
25
|
import {
|
|
25
26
|
writeFileAtomic2
|
|
26
|
-
} from "../index-
|
|
27
|
+
} from "../index-07dcf2yn.js";
|
|
27
28
|
import {
|
|
28
29
|
MAX_TIMER_MS,
|
|
29
30
|
sleep
|
|
30
31
|
} from "../index-eemvahkc.js";
|
|
32
|
+
import {
|
|
33
|
+
assertPositiveSafeInteger
|
|
34
|
+
} from "../index-0s4xebbg.js";
|
|
35
|
+
import {
|
|
36
|
+
BOT_TOKEN_SECRET
|
|
37
|
+
} from "../index-sznqf8fx.js";
|
|
31
38
|
import {
|
|
32
39
|
isRecord,
|
|
33
40
|
transportResult
|
|
@@ -73,6 +80,8 @@ async function callTelegramBotApi(call) {
|
|
|
73
80
|
} catch (error) {
|
|
74
81
|
if (call.signal?.aborted)
|
|
75
82
|
throw call.signal.reason;
|
|
83
|
+
if (isTelegramNotDispatchedError(error))
|
|
84
|
+
throw error;
|
|
76
85
|
const kind = error instanceof Error ? error.name : "Error";
|
|
77
86
|
throw new Error(`Telegram ${call.method} request failed (${kind})`);
|
|
78
87
|
}
|
|
@@ -889,6 +898,328 @@ function telegramOperatorSender(config) {
|
|
|
889
898
|
...config.fetch && { fetch: config.fetch }
|
|
890
899
|
});
|
|
891
900
|
}
|
|
901
|
+
// src/telegram/transport-connect.ts
|
|
902
|
+
import { lookup } from "node:dns/promises";
|
|
903
|
+
import { connect as connectTcp, isIP } from "node:net";
|
|
904
|
+
import { connect as connectTls } from "node:tls";
|
|
905
|
+
var NEXT_ADDRESS_DELAY_MS = 250;
|
|
906
|
+
var MAX_ROUNDS = 3;
|
|
907
|
+
var resolveAll = async (host) => (await lookup(host, { all: true, verbatim: true })).map((entry) => entry.address);
|
|
908
|
+
var openSocket = ({ address, port, tls, servername }) => tls ? connectTls({
|
|
909
|
+
host: address,
|
|
910
|
+
port,
|
|
911
|
+
...servername !== undefined && { servername },
|
|
912
|
+
ALPNProtocols: ["http/1.1"]
|
|
913
|
+
}) : connectTcp({ host: address, port });
|
|
914
|
+
var connectedEvent = (socket) => ("encrypted" in socket) && socket.encrypted ? "secureConnect" : "connect";
|
|
915
|
+
function race(addresses, target, open, timeoutMs, signal) {
|
|
916
|
+
return new Promise((resolve) => {
|
|
917
|
+
const sockets = [];
|
|
918
|
+
const timers = [];
|
|
919
|
+
let failed = 0;
|
|
920
|
+
let started = 0;
|
|
921
|
+
let lastFailure;
|
|
922
|
+
let settled = false;
|
|
923
|
+
const finish = (winner) => {
|
|
924
|
+
if (settled)
|
|
925
|
+
return;
|
|
926
|
+
settled = true;
|
|
927
|
+
for (const timer of timers)
|
|
928
|
+
clearTimeout(timer);
|
|
929
|
+
signal?.removeEventListener("abort", abort);
|
|
930
|
+
for (const socket of sockets)
|
|
931
|
+
if (socket !== winner)
|
|
932
|
+
socket.destroy();
|
|
933
|
+
resolve(winner ? { socket: winner } : { failure: lastFailure });
|
|
934
|
+
};
|
|
935
|
+
const abort = () => finish(undefined);
|
|
936
|
+
const failOne = (cause) => {
|
|
937
|
+
lastFailure = cause;
|
|
938
|
+
if (++failed === addresses.length)
|
|
939
|
+
finish(undefined);
|
|
940
|
+
else
|
|
941
|
+
launchNext();
|
|
942
|
+
};
|
|
943
|
+
const launchNext = () => {
|
|
944
|
+
if (settled)
|
|
945
|
+
return;
|
|
946
|
+
const address = addresses[started++];
|
|
947
|
+
if (address === undefined)
|
|
948
|
+
return;
|
|
949
|
+
let socket;
|
|
950
|
+
try {
|
|
951
|
+
socket = open({ address, ...target });
|
|
952
|
+
} catch (cause) {
|
|
953
|
+
failOne(cause);
|
|
954
|
+
return;
|
|
955
|
+
}
|
|
956
|
+
sockets.push(socket);
|
|
957
|
+
socket.once(connectedEvent(socket), () => finish(socket));
|
|
958
|
+
socket.once("error", (cause) => {
|
|
959
|
+
socket.destroy();
|
|
960
|
+
failOne(cause);
|
|
961
|
+
});
|
|
962
|
+
if (started < addresses.length)
|
|
963
|
+
timers.push(setTimeout(launchNext, NEXT_ADDRESS_DELAY_MS));
|
|
964
|
+
};
|
|
965
|
+
timers.push(setTimeout(() => finish(undefined), timeoutMs));
|
|
966
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
967
|
+
if (signal?.aborted)
|
|
968
|
+
finish(undefined);
|
|
969
|
+
else
|
|
970
|
+
launchNext();
|
|
971
|
+
});
|
|
972
|
+
}
|
|
973
|
+
function lookupWithin(host, policy, signal) {
|
|
974
|
+
return new Promise((resolve, reject) => {
|
|
975
|
+
const settle = (act) => {
|
|
976
|
+
clearTimeout(timer);
|
|
977
|
+
signal?.removeEventListener("abort", abort);
|
|
978
|
+
act();
|
|
979
|
+
};
|
|
980
|
+
const abort = () => settle(() => reject(signal?.reason));
|
|
981
|
+
const timer = setTimeout(() => settle(() => reject(new Error(`Address lookup took longer than ${policy.budgetMs} ms`))), policy.budgetMs);
|
|
982
|
+
if (signal?.aborted) {
|
|
983
|
+
abort();
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
987
|
+
Promise.resolve().then(() => policy.resolve(host)).then((found) => settle(() => resolve(found)), (error) => settle(() => reject(error)));
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
async function establish(host, port, tls, policy, signal) {
|
|
991
|
+
const literal = isIP(host) !== 0;
|
|
992
|
+
let addresses;
|
|
993
|
+
if (literal)
|
|
994
|
+
addresses = [host];
|
|
995
|
+
else {
|
|
996
|
+
try {
|
|
997
|
+
addresses = await lookupWithin(host, policy, signal);
|
|
998
|
+
} catch (cause) {
|
|
999
|
+
signal?.throwIfAborted();
|
|
1000
|
+
throw new TelegramNotDispatchedError2("lookup", "Telegram address lookup failed", {
|
|
1001
|
+
cause
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
signal?.throwIfAborted();
|
|
1006
|
+
if (addresses.length === 0)
|
|
1007
|
+
throw new TelegramNotDispatchedError2("lookup", "Telegram address lookup returned nothing");
|
|
1008
|
+
const target = { port, tls, servername: tls && !literal ? host : undefined };
|
|
1009
|
+
const deadline = performance.now() + policy.budgetMs;
|
|
1010
|
+
let lastFailure;
|
|
1011
|
+
for (let round = 0;round < MAX_ROUNDS; round++) {
|
|
1012
|
+
const left = deadline - performance.now();
|
|
1013
|
+
if (left <= 0)
|
|
1014
|
+
break;
|
|
1015
|
+
const outcome = await race(addresses, target, policy.open, Math.min(policy.attemptMs, left), signal);
|
|
1016
|
+
if (signal?.aborted && "socket" in outcome)
|
|
1017
|
+
outcome.socket.destroy();
|
|
1018
|
+
signal?.throwIfAborted();
|
|
1019
|
+
if ("socket" in outcome)
|
|
1020
|
+
return outcome.socket;
|
|
1021
|
+
lastFailure = outcome.failure ?? lastFailure;
|
|
1022
|
+
}
|
|
1023
|
+
throw new TelegramNotDispatchedError2("connect", "Telegram connection was not established", {
|
|
1024
|
+
cause: lastFailure
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
// src/telegram/transport.ts
|
|
1029
|
+
function chunkedBody(body) {
|
|
1030
|
+
const parts = [];
|
|
1031
|
+
let at = 0;
|
|
1032
|
+
for (;; ) {
|
|
1033
|
+
const lineEnd = body.indexOf(`\r
|
|
1034
|
+
`, at);
|
|
1035
|
+
if (lineEnd < 0)
|
|
1036
|
+
throw new Error("Telegram chunked answer was truncated");
|
|
1037
|
+
const size = Number.parseInt(body.subarray(at, lineEnd).toString("latin1"), 16);
|
|
1038
|
+
if (!Number.isSafeInteger(size) || size < 0)
|
|
1039
|
+
throw new Error("Telegram chunked answer had an invalid chunk size");
|
|
1040
|
+
if (size === 0)
|
|
1041
|
+
return Buffer.concat(parts);
|
|
1042
|
+
const start = lineEnd + 2;
|
|
1043
|
+
if (start + size > body.length)
|
|
1044
|
+
throw new Error("Telegram chunked answer was truncated");
|
|
1045
|
+
parts.push(body.subarray(start, start + size));
|
|
1046
|
+
at = start + size + 2;
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
function answerHead(raw) {
|
|
1050
|
+
const headEnd = raw.indexOf(`\r
|
|
1051
|
+
\r
|
|
1052
|
+
`);
|
|
1053
|
+
if (headEnd < 0)
|
|
1054
|
+
return;
|
|
1055
|
+
const [statusLine = "", ...lines] = raw.subarray(0, headEnd).toString("latin1").split(`\r
|
|
1056
|
+
`);
|
|
1057
|
+
const status = /^HTTP\/1\.[01] (\d{3})/.exec(statusLine)?.[1];
|
|
1058
|
+
if (status === undefined)
|
|
1059
|
+
throw new Error("Telegram answer had an invalid status line");
|
|
1060
|
+
if (Number(status) < 200)
|
|
1061
|
+
throw new Error(`Telegram answer was an interim response (HTTP ${status}), not a final one`);
|
|
1062
|
+
const headers = new Headers;
|
|
1063
|
+
for (const line of lines) {
|
|
1064
|
+
const colon = line.indexOf(":");
|
|
1065
|
+
if (colon > 0)
|
|
1066
|
+
headers.append(line.slice(0, colon).trim(), line.slice(colon + 1).trim());
|
|
1067
|
+
}
|
|
1068
|
+
return { bodyStart: headEnd + 4, status: Number(status), headers };
|
|
1069
|
+
}
|
|
1070
|
+
var bodiless = (status) => status === 204 || status === 304;
|
|
1071
|
+
var isChunked = (headers) => /\bchunked\b/i.test(headers.get("transfer-encoding") ?? "");
|
|
1072
|
+
function declaredLength(headers) {
|
|
1073
|
+
const raw = headers.get("content-length");
|
|
1074
|
+
if (raw === null)
|
|
1075
|
+
return;
|
|
1076
|
+
const values = new Set(raw.split(",").map((value) => value.trim()));
|
|
1077
|
+
const [only = ""] = values;
|
|
1078
|
+
if (values.size !== 1 || !/^\d{1,15}$/.test(only))
|
|
1079
|
+
throw new Error("Telegram answer had an invalid Content-Length");
|
|
1080
|
+
return Number(only);
|
|
1081
|
+
}
|
|
1082
|
+
function answerComplete(raw) {
|
|
1083
|
+
const head = answerHead(raw);
|
|
1084
|
+
if (!head)
|
|
1085
|
+
return false;
|
|
1086
|
+
if (bodiless(head.status))
|
|
1087
|
+
return true;
|
|
1088
|
+
const body = raw.subarray(head.bodyStart);
|
|
1089
|
+
if (isChunked(head.headers)) {
|
|
1090
|
+
try {
|
|
1091
|
+
chunkedBody(body);
|
|
1092
|
+
return true;
|
|
1093
|
+
} catch {
|
|
1094
|
+
return false;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
const length = declaredLength(head.headers);
|
|
1098
|
+
return length !== undefined && body.length >= length;
|
|
1099
|
+
}
|
|
1100
|
+
function parseAnswer(raw) {
|
|
1101
|
+
const head = answerHead(raw);
|
|
1102
|
+
if (!head)
|
|
1103
|
+
throw new Error("Telegram answer ended inside its head");
|
|
1104
|
+
const { status, headers } = head;
|
|
1105
|
+
let body = raw.subarray(head.bodyStart);
|
|
1106
|
+
if (isChunked(headers)) {
|
|
1107
|
+
body = chunkedBody(body);
|
|
1108
|
+
headers.delete("content-length");
|
|
1109
|
+
} else {
|
|
1110
|
+
const expected = declaredLength(headers);
|
|
1111
|
+
if (expected !== undefined) {
|
|
1112
|
+
if (body.length < expected)
|
|
1113
|
+
throw new Error("Telegram answer body was truncated");
|
|
1114
|
+
body = body.subarray(0, expected);
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
headers.delete("transfer-encoding");
|
|
1118
|
+
return new Response(bodiless(status) ? null : new Uint8Array(body), { status, headers });
|
|
1119
|
+
}
|
|
1120
|
+
function exchange(socket, request, limits, signal) {
|
|
1121
|
+
return new Promise((resolve, reject) => {
|
|
1122
|
+
const chunks = [];
|
|
1123
|
+
let bytes = 0;
|
|
1124
|
+
let done = false;
|
|
1125
|
+
const finish = (error) => {
|
|
1126
|
+
if (done)
|
|
1127
|
+
return;
|
|
1128
|
+
done = true;
|
|
1129
|
+
clearTimeout(timer);
|
|
1130
|
+
signal?.removeEventListener("abort", abort);
|
|
1131
|
+
socket.destroy();
|
|
1132
|
+
if (error !== undefined) {
|
|
1133
|
+
reject(error);
|
|
1134
|
+
return;
|
|
1135
|
+
}
|
|
1136
|
+
try {
|
|
1137
|
+
resolve(parseAnswer(Buffer.concat(chunks)));
|
|
1138
|
+
} catch (parseError) {
|
|
1139
|
+
reject(parseError);
|
|
1140
|
+
}
|
|
1141
|
+
};
|
|
1142
|
+
const abort = () => finish(signal?.reason);
|
|
1143
|
+
const timer = setTimeout(() => finish(new Error(`Telegram answer took longer than ${limits.responseTimeoutMs} ms`)), limits.responseTimeoutMs);
|
|
1144
|
+
socket.on("data", (chunk) => {
|
|
1145
|
+
bytes += chunk.byteLength;
|
|
1146
|
+
if (bytes > limits.maxResponseBytes) {
|
|
1147
|
+
finish(new Error(`Telegram answer exceeded ${limits.maxResponseBytes} bytes`));
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1150
|
+
chunks.push(chunk);
|
|
1151
|
+
try {
|
|
1152
|
+
if (answerComplete(Buffer.concat(chunks)))
|
|
1153
|
+
finish(undefined);
|
|
1154
|
+
} catch (error) {
|
|
1155
|
+
finish(error);
|
|
1156
|
+
}
|
|
1157
|
+
});
|
|
1158
|
+
socket.once("end", () => finish(undefined));
|
|
1159
|
+
socket.once("close", () => finish(undefined));
|
|
1160
|
+
socket.once("error", (error) => finish(error));
|
|
1161
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
1162
|
+
if (signal?.aborted)
|
|
1163
|
+
abort();
|
|
1164
|
+
else
|
|
1165
|
+
socket.write(request);
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
async function requestBytes(url, init, signal) {
|
|
1169
|
+
let request;
|
|
1170
|
+
let headers;
|
|
1171
|
+
let body;
|
|
1172
|
+
try {
|
|
1173
|
+
request = new Request(url, { ...init, signal: null });
|
|
1174
|
+
headers = [...request.headers].filter(([name]) => !["host", "content-length", "connection", "transfer-encoding"].includes(name));
|
|
1175
|
+
const read = request.arrayBuffer();
|
|
1176
|
+
body = new Uint8Array(await (signal ? untilAborted(read, signal) : read));
|
|
1177
|
+
} catch (cause) {
|
|
1178
|
+
signal?.throwIfAborted();
|
|
1179
|
+
throw new TelegramNotDispatchedError2("request", "Telegram request body could not be read", {
|
|
1180
|
+
cause
|
|
1181
|
+
});
|
|
1182
|
+
}
|
|
1183
|
+
const head = [
|
|
1184
|
+
`${request.method} ${url.pathname}${url.search} HTTP/1.1`,
|
|
1185
|
+
`Host: ${url.host}`,
|
|
1186
|
+
...headers.map(([name, value]) => `${name}: ${value}`),
|
|
1187
|
+
`Content-Length: ${body.byteLength}`,
|
|
1188
|
+
"Connection: close",
|
|
1189
|
+
"",
|
|
1190
|
+
""
|
|
1191
|
+
].join(`\r
|
|
1192
|
+
`);
|
|
1193
|
+
return { head, body };
|
|
1194
|
+
}
|
|
1195
|
+
function createTelegramBotTransport(options = {}) {
|
|
1196
|
+
const connectAttemptMs = options.connectAttemptMs ?? 2000;
|
|
1197
|
+
const connectBudgetMs = options.connectBudgetMs ?? 5000;
|
|
1198
|
+
const responseTimeoutMs = options.responseTimeoutMs ?? 30000;
|
|
1199
|
+
const maxResponseBytes = options.maxResponseBytes ?? 1024 * 1024;
|
|
1200
|
+
assertPositiveSafeInteger("connectAttemptMs", connectAttemptMs);
|
|
1201
|
+
assertPositiveSafeInteger("connectBudgetMs", connectBudgetMs);
|
|
1202
|
+
assertPositiveSafeInteger("responseTimeoutMs", responseTimeoutMs);
|
|
1203
|
+
assertPositiveSafeInteger("maxResponseBytes", maxResponseBytes);
|
|
1204
|
+
const policy = {
|
|
1205
|
+
resolve: options.resolve ?? resolveAll,
|
|
1206
|
+
open: options.open ?? openSocket,
|
|
1207
|
+
attemptMs: connectAttemptMs,
|
|
1208
|
+
budgetMs: connectBudgetMs
|
|
1209
|
+
};
|
|
1210
|
+
return async (url, init) => {
|
|
1211
|
+
const signal = init.signal ?? undefined;
|
|
1212
|
+
signal?.throwIfAborted();
|
|
1213
|
+
const target = new URL(url);
|
|
1214
|
+
const tls = target.protocol === "https:";
|
|
1215
|
+
if (!tls && target.protocol !== "http:")
|
|
1216
|
+
throw new TelegramNotDispatchedError2("request", `Telegram transport speaks http and https, not ${target.protocol}`);
|
|
1217
|
+
const { head, body } = await requestBytes(target, init, signal);
|
|
1218
|
+
signal?.throwIfAborted();
|
|
1219
|
+
const socket = await establish(target.hostname.replace(/^\[|\]$/g, ""), Number(target.port || (tls ? 443 : 80)), tls, policy, signal);
|
|
1220
|
+
return exchange(socket, Buffer.concat([Buffer.from(head, "latin1"), body]), { maxResponseBytes, responseTimeoutMs }, signal);
|
|
1221
|
+
};
|
|
1222
|
+
}
|
|
892
1223
|
// src/telegram/update-intake.ts
|
|
893
1224
|
var SWEEP_BATCH = 100;
|
|
894
1225
|
function defaultRetry(error, attempt) {
|
|
@@ -1525,12 +1856,14 @@ export {
|
|
|
1525
1856
|
TelegramBotApiError,
|
|
1526
1857
|
TelegramBroadcastFailureSchema,
|
|
1527
1858
|
TelegramLocalFileError,
|
|
1859
|
+
TelegramNotDispatchedError2 as TelegramNotDispatchedError,
|
|
1528
1860
|
TelegramWebhookClaimError,
|
|
1529
1861
|
callTelegramBotApi,
|
|
1530
1862
|
checkTelegramUpdateStore,
|
|
1531
1863
|
checkTelegramWebhook,
|
|
1532
1864
|
claimTelegramWebhook,
|
|
1533
1865
|
classifyTelegramSendFailure2 as classifyTelegramSendFailure,
|
|
1866
|
+
createTelegramBotTransport,
|
|
1534
1867
|
createTelegramLocalFiles,
|
|
1535
1868
|
createTelegramOperatorChannel,
|
|
1536
1869
|
createTelegramOperatorDedupe,
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export * from '../testing/handler-clients.js';
|
|
6
6
|
export { type ManagedResourceConformanceConfig, type ManagedResourceConformanceControls, ManagedResourceConformanceError, type ManagedResourceConformanceFactoryInput, type ManagedResourceConformanceFixture, type ManagedResourceConformancePhase, ManagedResourceConformancePhaseSchema, type ManagedResourceConformanceScenario, type ManagedResourceConformanceScenarioId, ManagedResourceConformanceScenarioIdSchema, ManagedResourceConformanceScenarioSchema, type ManagedResourceConformanceTraceEntry, ManagedResourceConformanceTraceEntrySchema, type ManagedResourceConformanceTraceOutcome, ManagedResourceConformanceTraceOutcomeSchema, runManagedResourceConformance, } from '../testing/managed-resource-conformance.js';
|
|
7
|
+
export { createManualClock, type ManualClock, ManualClockError, type ManualClockErrorCode, type ManualClockHold, type ManualClockOptions, type ManualClockTimer, type ManualClockUntilOptions, } from '../testing/manual-clock.js';
|
|
7
8
|
export { type CreateRealtimeProbeDriverConfig, createRealtimeProbeDriver, type DefineRealtimeProbeConfig, defineRealtimeProbe, type RealtimeProbeAdapter, type RealtimeProbeFixture, type RealtimeProbeScenario, } from '../testing/realtime-probe.js';
|
|
8
9
|
export { assertSurfaceDiscovery, type ConformanceTransport, type RealtimeDisconnectObservation, RealtimeDisconnectObservationSchema, type RealtimeRejectionObservation, RealtimeRejectionObservationSchema, type RunSurfaceProbesConfig, runSurfaceProbes, type SurfaceDiscoveryObservation, type SurfaceProbe, type SurfaceProbeDriver, type SurfaceRealtimeDiscoveryObservation, type SurfaceToolDiscoveryObservation, type TransportObservation, TransportObservationSchema, } from '../testing/surface-conformance.js';
|
|
9
10
|
export { assertSurfaceManifestSnapshot, buildSurfaceManifest, type IncompatibleSchemaPolicy, type McpSchemaValidationConfig, SURFACE_MANIFEST_VERSION, type SurfaceAgentProjection, type SurfaceManifest, type SurfaceManifestConfig, type SurfaceManifestExtension, SurfaceManifestExtensionSchema, type SurfaceManifestOperation, type SurfaceManifestOperationMcp, SurfaceManifestOperationMcpSchema, SurfaceManifestOperationSchema, type SurfaceManifestOperationToolView, SurfaceManifestOperationToolViewSchema, type SurfaceManifestRealtimeEvent, SurfaceManifestRealtimeEventSchema, SurfaceManifestSchema, type SurfaceManifestTool, SurfaceManifestToolSchema, type SurfaceManifestToolSurface, SurfaceManifestToolSurfaceSchema, type SurfaceMcpPreparation, SurfaceRealtimeSchemaPairSchema, type SurfaceRuntimeToolDefinition, SurfaceSchemaDigestsSchema, type SurfaceToolDefinition, type SurfaceToolExtension, } from '../testing/surface-manifest.js';
|