stitchkit 0.123.5 → 0.123.7
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 +77 -0
- package/dist/entrypoints/application/diagnostic-journal.js +1 -1
- package/dist/entrypoints/application/directory-inbox.js +3 -3
- package/dist/entrypoints/cli/publish.js +2 -2
- package/dist/entrypoints/cli.js +2 -1
- package/dist/entrypoints/files.js +2 -2
- package/dist/entrypoints/node.js +2 -2
- package/dist/entrypoints/server.js +5 -5
- package/dist/entrypoints/telegram/grammy.d.ts +1 -0
- package/dist/entrypoints/telegram/grammy.d.ts.map +1 -1
- package/dist/entrypoints/telegram/grammy.js +81 -3
- package/dist/entrypoints/telegram/screens.js +1 -1
- package/dist/entrypoints/telegram.d.ts +1 -0
- package/dist/entrypoints/telegram.d.ts.map +1 -1
- package/dist/entrypoints/telegram.js +18 -6
- package/dist/entrypoints/tools/contract.js +4 -2
- package/dist/entrypoints/tools/toolkit.js +2 -1
- package/dist/entrypoints/tools.js +33 -27
- package/dist/{index-xjb131sc.js → index-1a741dpf.js} +188 -51
- package/dist/{index-yfpt7sxr.js → index-6qrspvxp.js} +5 -3
- package/dist/index-81t0bf0f.js +18 -0
- package/dist/{index-d9cg0gen.js → index-8yky60kq.js} +1 -1
- package/dist/{index-bph35vpy.js → index-9cxxfkhb.js} +21 -1
- package/dist/index-bgj9hbm3.js +93 -0
- package/dist/index-bknzva6n.js +39 -0
- package/dist/{index-73dappvg.js → index-ezwvsqx9.js} +1 -1
- package/dist/{index-303qne11.js → index-f56ct5gb.js} +27 -4
- package/dist/{index-chz7c830.js → index-mqttte96.js} +39 -6
- package/dist/{index-eabx6qjh.js → index-tnnmekgb.js} +1 -6
- package/dist/index-zs8cze4j.js +6 -0
- package/dist/internal/exclusive-lock.d.ts.map +1 -1
- package/dist/internal/media-extension.d.ts +3 -0
- package/dist/internal/media-extension.d.ts.map +1 -0
- package/dist/telegram/send-failure.d.ts +2 -2
- package/dist/telegram/send-failure.d.ts.map +1 -1
- package/dist/telegram/widget-api.d.ts +106 -0
- package/dist/telegram/widget-api.d.ts.map +1 -0
- package/dist/telegram/widget.d.ts +121 -0
- package/dist/telegram/widget.d.ts.map +1 -0
- package/dist/tools/cli/args.d.ts +1 -1
- package/dist/tools/cli/args.d.ts.map +1 -1
- package/dist/tools/cli/command.d.ts +7 -1
- package/dist/tools/cli/command.d.ts.map +1 -1
- package/dist/tools/cli/config.d.ts +5 -2
- package/dist/tools/cli/config.d.ts.map +1 -1
- package/dist/tools/cli/download.d.ts +25 -4
- package/dist/tools/cli/download.d.ts.map +1 -1
- package/dist/tools/cli/inline-files.d.ts +70 -0
- package/dist/tools/cli/inline-files.d.ts.map +1 -0
- package/dist/tools/cli/session.d.ts.map +1 -1
- package/dist/tools/transfer/download-core.d.ts +2 -0
- package/dist/tools/transfer/download-core.d.ts.map +1 -1
- package/dist/tools/transfer/view-file-contract.d.ts +34 -4
- package/dist/tools/transfer/view-file-contract.d.ts.map +1 -1
- package/dist/tools/transfer/view-file.d.ts.map +1 -1
- package/llms/cli.txt +63 -3
- package/llms/stitchkit.txt +2 -2
- package/llms/telegram-grammy.txt +10 -3
- package/llms/telegram.2.txt +5 -0
- package/llms/telegram.txt +70 -0
- package/llms/tools.2.txt +5 -0
- package/llms-full.txt +152 -8
- package/llms.txt +6 -6
- package/package.json +1 -1
- package/dist/index-6j725ez5.js +0 -25
- package/dist/index-sba3e6m4.js +0 -52
package/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,83 @@ additive**; the first breaking change landed in 0.10.0. Grep the file for
|
|
|
15
15
|
|
|
16
16
|
## [Unreleased]
|
|
17
17
|
|
|
18
|
+
## [0.123.7] - 2026-11-17
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- `stitchkit/cli` — **`--output-dir` saves the files a result carries inline and prints links
|
|
23
|
+
to them.** The blocks of a successful result's top-level `content` that hold a file — `image`
|
|
24
|
+
and `audio` of `McpMediaContentSchema`, and an embedded `resource` of any type with `blob` or
|
|
25
|
+
`text` (a PDF, a spreadsheet, a CSV) — are saved without a `download` callback, in the same
|
|
26
|
+
batch, pinned directory and atomic contained writer as URL downloads. This covers a
|
|
27
|
+
`defineViewFileTool` result and a tool mounted through MCP. A part of any other shape is left
|
|
28
|
+
alone. A media block's `name`, or the last path segment of a resource's `uri`, supplies the
|
|
29
|
+
file's basename; a block that names no file is `<type>-<sha256 of its bytes><extension>`.
|
|
30
|
+
Canonical base64 is validated and `maxDownloadBytes` is checked before the bytes are
|
|
31
|
+
allocated, one file at a time. On stdout each saved block becomes
|
|
32
|
+
`{ type: 'resource_link', uri: 'file://…', name, mimeType, size }`, so the bytes are not
|
|
33
|
+
printed again; a block that could not be saved keeps its bytes and the exit is `1`. A result
|
|
34
|
+
policy still receives the operation's own result. A result with no media prints and exits as
|
|
35
|
+
it does without the flag, and stderr says that nothing was saved — so `--output-dir` on a CLI
|
|
36
|
+
without a `download` callback runs the command instead of refusing it with exit `2`.
|
|
37
|
+
[guide](docs/guide/cli.md#saving-result-media). → ADR 0291
|
|
38
|
+
|
|
39
|
+
- `stitchkit/tools`, `stitchkit/tools/contract` — **An image or audio block carries the file
|
|
40
|
+
name of its source.** `McpMediaContentSchema` gains an optional `name` on its `image` and
|
|
41
|
+
`audio` blocks. `defineViewFileTool`, `mountViewFile` and `resolveMedia` set it: a managed
|
|
42
|
+
file keeps its own name, a URL takes its download name — the path's base name with the body's
|
|
43
|
+
extension. The name travels inside the block, over MCP as well. A download whose body is
|
|
44
|
+
`audio/mp4` is named `.m4a`.
|
|
45
|
+
|
|
46
|
+
### Fixed
|
|
47
|
+
|
|
48
|
+
- `stitchkit/cli` — **Two `--output-dir` files with one name do not replace each other.** A
|
|
49
|
+
`download` callback that named two different files alike left the last one on disk while both
|
|
50
|
+
printed `saved`. A name is written once per batch: the same bytes again are one file,
|
|
51
|
+
different bytes fail that file with `another file of this batch is already saved as "<name>"`
|
|
52
|
+
and exit `1`, and the first file stays.
|
|
53
|
+
**Affects:** `stitchkit/cli` behaviour
|
|
54
|
+
|
|
55
|
+
- `stitchkit/cli` — **A `maxDownloadBytes` that is not a positive safe integer is refused when
|
|
56
|
+
the CLI is created**, with the shared limit message that ends in the value received. A
|
|
57
|
+
fractional, zero, negative or non-finite cap used to reach the first download.
|
|
58
|
+
**Affects:** `stitchkit/cli` createCli(maxDownloadBytes)
|
|
59
|
+
|
|
60
|
+
- `stitchkit/files` — **Reclaiming a dead owner's lock never removes a live one.** A reclaimer
|
|
61
|
+
judged the lock's record, then removed the file by its inode number. If the judged owner
|
|
62
|
+
released in between and a new holder created the lock on the freed inode, the live lock was
|
|
63
|
+
removed and two processes held it at once — seen under load when several processes recovered
|
|
64
|
+
a lock and its reclaim guard together. The reclaimer now keeps a descriptor open on the judged
|
|
65
|
+
file, so its inode cannot be reused, and removes it only while the name still holds that file
|
|
66
|
+
with the judged record; a lock replaced meanwhile refuses the reclaim and is waited for.
|
|
67
|
+
**Affects:** `stitchkit/files` withExclusiveLock(behaviour)
|
|
68
|
+
|
|
69
|
+
## [0.123.6] - 2026-11-16
|
|
70
|
+
|
|
71
|
+
### Added
|
|
72
|
+
|
|
73
|
+
- `stitchkit/telegram/grammy` — **`telegramWidgetApi(api)`: the Bot API 10.4 widget methods over
|
|
74
|
+
the client a bot already has.** `sendWidget`, `editMessageWidgetData` and `answerWidgetQuery`
|
|
75
|
+
take their Bot API parameters and `{ signal }`, and go through the client's `api.raw`, so every
|
|
76
|
+
transformer of that client runs them: with `telegramBudgetTransformer` installed a send or an edit
|
|
77
|
+
spends one message of the token's budget and an answer waits for none. No second client, limiter
|
|
78
|
+
or retry. Input over Telegram's byte limits throws `ZodError` before any request; an already
|
|
79
|
+
aborted signal throws `TelegramNotDispatchedError`; a request is handed on once; `message is not
|
|
80
|
+
modified` on an edit is success; an unexpected successful answer is an error whose outcome is
|
|
81
|
+
unknown. The public surface ceiling of `stitchkit/telegram/grammy` moves from 1 to 7 names for
|
|
82
|
+
the function, its interface, the three parameter types and the call options.
|
|
83
|
+
[guide](docs/guide/telegram.md#widgets)
|
|
84
|
+
|
|
85
|
+
- `stitchkit/telegram` — **Widget limits and shapes.** `TELEGRAM_WIDGET_LIMITS`, the byte-counted
|
|
86
|
+
`TelegramWidgetHtmlSchema` (1–32768 bytes, at most 4096 after the runtime's zlib at level 9 — an
|
|
87
|
+
estimate of Telegram's, so keep a margin) and
|
|
88
|
+
`TelegramWidgetDataSchema` (0–1024 bytes; NUL and unpaired surrogates refused, `''` is a value),
|
|
89
|
+
`TelegramWidgetMessageSchema` for the sent message and `TelegramWidgetQuerySchema` for
|
|
90
|
+
`Update.widget_query`, both parsed loosely so fields Telegram adds pass through.
|
|
91
|
+
`parseTelegramWidgetQuery` returns the id of a query that does not parse, so it can be refused
|
|
92
|
+
instead of left to time out. The public surface ceiling of `stitchkit/telegram` moves from 107 to
|
|
93
|
+
116 names for the limits, four schemas, their three types and the parser.
|
|
94
|
+
|
|
18
95
|
## [0.123.5] - 2026-11-13
|
|
19
96
|
|
|
20
97
|
### Fixed
|
|
@@ -15,14 +15,14 @@ import {
|
|
|
15
15
|
} from "../../index-g6a3na27.js";
|
|
16
16
|
import"../../index-sqc6ezrb.js";
|
|
17
17
|
import"../../index-bqzgaj57.js";
|
|
18
|
-
import"../../index-
|
|
18
|
+
import"../../index-mqttte96.js";
|
|
19
19
|
import {
|
|
20
20
|
defineManagedResource2
|
|
21
21
|
} from "../../index-50ejfz75.js";
|
|
22
22
|
import {
|
|
23
23
|
createFileStateStore2
|
|
24
|
-
} from "../../index-
|
|
25
|
-
import"../../index-
|
|
24
|
+
} from "../../index-8yky60kq.js";
|
|
25
|
+
import"../../index-ezwvsqx9.js";
|
|
26
26
|
import {
|
|
27
27
|
isJsonData
|
|
28
28
|
} from "../../index-m6w6jtda.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import"../../index-xqhede6x.js";
|
|
2
2
|
import"../../index-sqc6ezrb.js";
|
|
3
3
|
import"../../index-bqzgaj57.js";
|
|
4
|
-
import"../../index-
|
|
4
|
+
import"../../index-mqttte96.js";
|
|
5
5
|
import {
|
|
6
6
|
signCliManifest2,
|
|
7
7
|
verifyCliManifest2,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
} from "../../index-tt3ej8r3.js";
|
|
19
19
|
import {
|
|
20
20
|
withExclusiveLock2
|
|
21
|
-
} from "../../index-
|
|
21
|
+
} from "../../index-ezwvsqx9.js";
|
|
22
22
|
import {
|
|
23
23
|
ManagedFileError2,
|
|
24
24
|
createManagedFileBoundary2
|
package/dist/entrypoints/cli.js
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
renderCliView2,
|
|
18
18
|
pollUntilDone2,
|
|
19
19
|
createCli2
|
|
20
|
-
} from "../index-
|
|
20
|
+
} from "../index-1a741dpf.js";
|
|
21
21
|
import"../index-ndjzbt2v.js";
|
|
22
22
|
import"../index-ct75c3at.js";
|
|
23
23
|
import"../index-tynna0n4.js";
|
|
@@ -26,6 +26,7 @@ import"../index-yt1gg11x.js";
|
|
|
26
26
|
import"../index-qc7tq0za.js";
|
|
27
27
|
import"../index-332d0m9g.js";
|
|
28
28
|
import"../index-sqc6ezrb.js";
|
|
29
|
+
import"../index-bknzva6n.js";
|
|
29
30
|
import"../index-0v9xb8pz.js";
|
|
30
31
|
import {
|
|
31
32
|
CliBuildSignatureSchema2,
|
|
@@ -4,14 +4,14 @@ import {
|
|
|
4
4
|
} from "../index-xqhede6x.js";
|
|
5
5
|
import"../index-sqc6ezrb.js";
|
|
6
6
|
import"../index-bqzgaj57.js";
|
|
7
|
-
import"../index-
|
|
7
|
+
import"../index-mqttte96.js";
|
|
8
8
|
import {
|
|
9
9
|
bindUnixSocket2
|
|
10
10
|
} from "../index-drcjjhy1.js";
|
|
11
11
|
import {
|
|
12
12
|
ExclusiveLockError2,
|
|
13
13
|
withExclusiveLock2
|
|
14
|
-
} from "../index-
|
|
14
|
+
} from "../index-ezwvsqx9.js";
|
|
15
15
|
import {
|
|
16
16
|
ManagedFileError2,
|
|
17
17
|
createManagedFileBoundary2
|
package/dist/entrypoints/node.js
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
createSocketIOServer2,
|
|
25
25
|
UnixClientTransportError2,
|
|
26
26
|
createUnixClientTransport2
|
|
27
|
-
} from "../index-
|
|
27
|
+
} from "../index-6qrspvxp.js";
|
|
28
28
|
import {
|
|
29
29
|
bindRealtimeServer2
|
|
30
30
|
} from "../index-sqkttz7z.js";
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
implement2,
|
|
34
34
|
createImplement2,
|
|
35
35
|
createScopedImplement2
|
|
36
|
-
} from "../index-
|
|
36
|
+
} from "../index-tnnmekgb.js";
|
|
37
37
|
import"../index-9ypczvpj.js";
|
|
38
38
|
import {
|
|
39
39
|
AppError2,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import"../index-sqc6ezrb.js";
|
|
2
2
|
import"../index-bqzgaj57.js";
|
|
3
|
-
import"../index-
|
|
3
|
+
import"../index-mqttte96.js";
|
|
4
4
|
import {
|
|
5
5
|
errorCode2,
|
|
6
6
|
normalizeError2
|
|
@@ -53,17 +53,17 @@ import {
|
|
|
53
53
|
socketIoLane2,
|
|
54
54
|
UnixClientTransportError2,
|
|
55
55
|
createUnixClientTransport2
|
|
56
|
-
} from "../index-
|
|
56
|
+
} from "../index-6qrspvxp.js";
|
|
57
57
|
import {
|
|
58
58
|
createFileStateStore2
|
|
59
|
-
} from "../index-
|
|
59
|
+
} from "../index-8yky60kq.js";
|
|
60
60
|
import {
|
|
61
61
|
bindRealtimeServer2
|
|
62
62
|
} from "../index-sqkttz7z.js";
|
|
63
63
|
import {
|
|
64
64
|
bindUnixSocket2
|
|
65
65
|
} from "../index-drcjjhy1.js";
|
|
66
|
-
import"../index-
|
|
66
|
+
import"../index-ezwvsqx9.js";
|
|
67
67
|
import {
|
|
68
68
|
withDeadline
|
|
69
69
|
} from "../index-9tqbxv5p.js";
|
|
@@ -84,7 +84,7 @@ import {
|
|
|
84
84
|
implement2,
|
|
85
85
|
createImplement2,
|
|
86
86
|
createScopedImplement2
|
|
87
|
-
} from "../index-
|
|
87
|
+
} from "../index-tnnmekgb.js";
|
|
88
88
|
import"../index-9ypczvpj.js";
|
|
89
89
|
import {
|
|
90
90
|
DEFAULT_CORS_ALLOW_HEADERS2,
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { telegramBudgetTransformer } from '../../telegram/budget-transformer.js';
|
|
2
|
+
export { type TelegramAnswerWidgetQueryParams, type TelegramEditMessageWidgetDataParams, type TelegramSendWidgetParams, type TelegramWidgetApi, type TelegramWidgetCallOptions, telegramWidgetApi, } from '../../telegram/widget-api.js';
|
|
2
3
|
//# sourceMappingURL=grammy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grammy.d.ts","sourceRoot":"","sources":["../../../src/entrypoints/telegram/grammy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC"}
|
|
1
|
+
{"version":3,"file":"grammy.d.ts","sourceRoot":"","sources":["../../../src/entrypoints/telegram/grammy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EACL,KAAK,+BAA+B,EACpC,KAAK,mCAAmC,EACxC,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,iBAAiB,GAClB,MAAM,2BAA2B,CAAC"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
TelegramWidgetHtmlSchema2,
|
|
3
|
+
TelegramWidgetDataSchema2,
|
|
4
|
+
TelegramWidgetMessageSchema2
|
|
5
|
+
} from "../../index-bgj9hbm3.js";
|
|
6
|
+
import {
|
|
7
|
+
TelegramNotDispatchedError2,
|
|
8
|
+
classifyTelegramEditRefusal
|
|
9
|
+
} from "../../index-f56ct5gb.js";
|
|
4
10
|
|
|
5
11
|
// src/telegram/budget-transformer.ts
|
|
6
12
|
function platformSignal(signal) {
|
|
@@ -45,6 +51,78 @@ function telegramBudgetTransformer(budget, options) {
|
|
|
45
51
|
}
|
|
46
52
|
};
|
|
47
53
|
}
|
|
54
|
+
// src/telegram/widget-api.ts
|
|
55
|
+
import { z } from "zod";
|
|
56
|
+
var ChatIdSchema = z.union([z.int(), z.string().min(1)]);
|
|
57
|
+
var SendInputSchema = z.object({
|
|
58
|
+
chat_id: ChatIdSchema,
|
|
59
|
+
html: TelegramWidgetHtmlSchema2,
|
|
60
|
+
public_data: TelegramWidgetDataSchema2.optional(),
|
|
61
|
+
chat_data: TelegramWidgetDataSchema2.optional()
|
|
62
|
+
});
|
|
63
|
+
var EditInputSchema = z.object({
|
|
64
|
+
chat_id: ChatIdSchema.optional(),
|
|
65
|
+
message_id: z.int().optional(),
|
|
66
|
+
inline_message_id: z.string().min(1).optional(),
|
|
67
|
+
public_data: TelegramWidgetDataSchema2.optional(),
|
|
68
|
+
chat_data: TelegramWidgetDataSchema2.optional()
|
|
69
|
+
}).refine((edit) => edit.inline_message_id === undefined ? edit.chat_id !== undefined && edit.message_id !== undefined : edit.chat_id === undefined && edit.message_id === undefined, { message: "Pass chat_id with message_id, or inline_message_id alone" }).refine((edit) => edit.chat_data !== undefined || edit.public_data !== undefined, {
|
|
70
|
+
message: "Pass chat_data or public_data to change"
|
|
71
|
+
});
|
|
72
|
+
var AnswerInputSchema = z.object({
|
|
73
|
+
widget_query_id: z.string().min(1),
|
|
74
|
+
data: TelegramWidgetDataSchema2.optional()
|
|
75
|
+
});
|
|
76
|
+
var TrueSchema = z.literal(true);
|
|
77
|
+
function payloadOf(params) {
|
|
78
|
+
return Object.fromEntries(Object.entries(params).filter(([, value]) => value !== undefined));
|
|
79
|
+
}
|
|
80
|
+
async function dispatch(api, method, payload, signal) {
|
|
81
|
+
if (signal?.aborted) {
|
|
82
|
+
throw new TelegramNotDispatchedError2("request", `the Telegram ${method} request was cancelled before it was sent`, { cause: signal.reason });
|
|
83
|
+
}
|
|
84
|
+
const call = Reflect.get(api.raw, method);
|
|
85
|
+
if (typeof call !== "function") {
|
|
86
|
+
throw new TypeError(`This grammY client has no ${method} method`);
|
|
87
|
+
}
|
|
88
|
+
return await Reflect.apply(call, api.raw, [payload, signal]);
|
|
89
|
+
}
|
|
90
|
+
function answered(method, schema, value) {
|
|
91
|
+
const parsed = schema.safeParse(value);
|
|
92
|
+
if (parsed.success)
|
|
93
|
+
return parsed.data;
|
|
94
|
+
throw new Error(`Telegram answered ${method} with an unexpected result; the request was sent and its outcome is unknown`, { cause: parsed.error });
|
|
95
|
+
}
|
|
96
|
+
function telegramWidgetApi(api) {
|
|
97
|
+
return {
|
|
98
|
+
async sendWidget(params, options) {
|
|
99
|
+
const payload = payloadOf(params);
|
|
100
|
+
SendInputSchema.parse(payload);
|
|
101
|
+
const value = await dispatch(api, "sendWidget", payload, options?.signal);
|
|
102
|
+
return answered("sendWidget", TelegramWidgetMessageSchema2, value);
|
|
103
|
+
},
|
|
104
|
+
async editMessageWidgetData(params, options) {
|
|
105
|
+
const payload = payloadOf(params);
|
|
106
|
+
EditInputSchema.parse(payload);
|
|
107
|
+
let value;
|
|
108
|
+
try {
|
|
109
|
+
value = await dispatch(api, "editMessageWidgetData", payload, options?.signal);
|
|
110
|
+
} catch (error) {
|
|
111
|
+
if (classifyTelegramEditRefusal(error) === "not-modified")
|
|
112
|
+
return;
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
115
|
+
answered("editMessageWidgetData", TrueSchema, value);
|
|
116
|
+
},
|
|
117
|
+
async answerWidgetQuery(params, options) {
|
|
118
|
+
const payload = payloadOf(params);
|
|
119
|
+
AnswerInputSchema.parse(payload);
|
|
120
|
+
const value = await dispatch(api, "answerWidgetQuery", payload, options?.signal);
|
|
121
|
+
answered("answerWidgetQuery", TrueSchema, value);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
48
125
|
export {
|
|
49
|
-
telegramBudgetTransformer
|
|
126
|
+
telegramBudgetTransformer,
|
|
127
|
+
telegramWidgetApi
|
|
50
128
|
};
|
|
@@ -17,4 +17,5 @@ export { type SqliteTelegramUpdateStoreConfig, sqliteTelegramUpdateStore, type T
|
|
|
17
17
|
export { parseTelegramUser, type TelegramUser } from '../telegram/user.js';
|
|
18
18
|
export { type ReadTelegramVoiceWaveformOptions, readTelegramVoiceWaveform, } from '../telegram/voice-waveform-pcm.js';
|
|
19
19
|
export { type ClaimTelegramWebhookConfig, checkTelegramWebhook, claimTelegramWebhook, type ReceiveTelegramWebhookOptions, receiveTelegramWebhook, TELEGRAM_WEBHOOK_NONE, type TelegramUpdateAcceptance, type TelegramWebhookClaim, TelegramWebhookClaimError, type TelegramWebhookConfig, type TelegramWebhookRefusal, type TelegramWebhookState, telegramWebhookUrl, } from '../telegram/webhook.js';
|
|
20
|
+
export { parseTelegramWidgetQuery, TELEGRAM_WIDGET_LIMITS, TelegramWidgetDataSchema, TelegramWidgetHtmlSchema, type TelegramWidgetMessage, TelegramWidgetMessageSchema, type TelegramWidgetQuery, type TelegramWidgetQueryParse, TelegramWidgetQuerySchema, } from '../telegram/widget.js';
|
|
20
21
|
//# sourceMappingURL=telegram.d.ts.map
|
|
@@ -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,KA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EAAE,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EACL,KAAK,gCAAgC,EACrC,yBAAyB,GAC1B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,KAAK,0BAA0B,EAC/B,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,6BAA6B,EAClC,sBAAsB,EACtB,qBAAqB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,yBAAyB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,KAAK,qBAAqB,EAC1B,2BAA2B,EAC3B,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC"}
|
|
@@ -5,20 +5,26 @@ import"../index-sqc6ezrb.js";
|
|
|
5
5
|
import"../index-bqzgaj57.js";
|
|
6
6
|
import {
|
|
7
7
|
attemptExclusiveLock
|
|
8
|
-
} from "../index-
|
|
8
|
+
} from "../index-mqttte96.js";
|
|
9
|
+
import {
|
|
10
|
+
TELEGRAM_WIDGET_LIMITS2,
|
|
11
|
+
TelegramWidgetHtmlSchema2,
|
|
12
|
+
TelegramWidgetDataSchema2,
|
|
13
|
+
TelegramWidgetMessageSchema2,
|
|
14
|
+
TelegramWidgetQuerySchema2,
|
|
15
|
+
parseTelegramWidgetQuery2
|
|
16
|
+
} from "../index-bgj9hbm3.js";
|
|
9
17
|
import {
|
|
10
18
|
TELEGRAM_VOICE_WAVEFORM_SAMPLES2,
|
|
11
19
|
TelegramVoiceWaveformError2,
|
|
12
20
|
packTelegramVoiceWaveform2
|
|
13
21
|
} from "../index-0jdempdr.js";
|
|
14
22
|
import {
|
|
23
|
+
TelegramNotDispatchedError2,
|
|
24
|
+
isTelegramNotDispatchedError,
|
|
15
25
|
TELEGRAM_SEND_FAILURE_REASONS2,
|
|
16
26
|
classifyTelegramSendFailure2
|
|
17
|
-
} from "../index-
|
|
18
|
-
import {
|
|
19
|
-
TelegramNotDispatchedError2,
|
|
20
|
-
isTelegramNotDispatchedError
|
|
21
|
-
} from "../index-6j725ez5.js";
|
|
27
|
+
} from "../index-f56ct5gb.js";
|
|
22
28
|
import {
|
|
23
29
|
TELEGRAM_TEXT_LIMIT2,
|
|
24
30
|
truncateTelegramHtml2
|
|
@@ -3104,12 +3110,17 @@ export {
|
|
|
3104
3110
|
TELEGRAM_BOT_TOKEN_PATTERN,
|
|
3105
3111
|
TELEGRAM_SEND_FAILURE_REASONS2 as TELEGRAM_SEND_FAILURE_REASONS,
|
|
3106
3112
|
TELEGRAM_WEBHOOK_NONE,
|
|
3113
|
+
TELEGRAM_WIDGET_LIMITS2 as TELEGRAM_WIDGET_LIMITS,
|
|
3107
3114
|
TelegramBotApiError,
|
|
3108
3115
|
TelegramBroadcastFailureSchema,
|
|
3109
3116
|
TelegramLocalFileError,
|
|
3110
3117
|
TelegramNotDispatchedError2 as TelegramNotDispatchedError,
|
|
3111
3118
|
TelegramUpdateOwnershipLostError,
|
|
3112
3119
|
TelegramWebhookClaimError,
|
|
3120
|
+
TelegramWidgetDataSchema2 as TelegramWidgetDataSchema,
|
|
3121
|
+
TelegramWidgetHtmlSchema2 as TelegramWidgetHtmlSchema,
|
|
3122
|
+
TelegramWidgetMessageSchema2 as TelegramWidgetMessageSchema,
|
|
3123
|
+
TelegramWidgetQuerySchema2 as TelegramWidgetQuerySchema,
|
|
3113
3124
|
callTelegramBotApi,
|
|
3114
3125
|
checkTelegramUpdateStore,
|
|
3115
3126
|
checkTelegramWebhook,
|
|
@@ -3122,6 +3133,7 @@ export {
|
|
|
3122
3133
|
createTelegramUpdateIntake,
|
|
3123
3134
|
memoryTelegramUpdateStore,
|
|
3124
3135
|
parseTelegramUser,
|
|
3136
|
+
parseTelegramWidgetQuery2 as parseTelegramWidgetQuery,
|
|
3125
3137
|
postgresTelegramUpdateStore,
|
|
3126
3138
|
postgresTelegramUpdateStoreSchema,
|
|
3127
3139
|
readTelegramVoiceWaveform,
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AsyncOperationCancelResultSchema2,
|
|
3
|
-
createAsyncOperationSnapshotSchema2
|
|
3
|
+
createAsyncOperationSnapshotSchema2
|
|
4
|
+
} from "../../index-81t0bf0f.js";
|
|
5
|
+
import {
|
|
4
6
|
McpAnnotationsSchema2,
|
|
5
7
|
McpMediaContentSchema2,
|
|
6
8
|
ViewFileErrorSchema2,
|
|
7
9
|
ViewFileOutputSchema2,
|
|
8
10
|
ViewFileInputSchema2
|
|
9
|
-
} from "../../index-
|
|
11
|
+
} from "../../index-bknzva6n.js";
|
|
10
12
|
import {
|
|
11
13
|
coerceJsonArgs2
|
|
12
14
|
} from "../../index-t8jz0e20.js";
|
|
@@ -11,9 +11,10 @@ import {
|
|
|
11
11
|
} from "../../index-yebkpytc.js";
|
|
12
12
|
import {
|
|
13
13
|
createCli2
|
|
14
|
-
} from "../../index-
|
|
14
|
+
} from "../../index-1a741dpf.js";
|
|
15
15
|
import"../../index-332d0m9g.js";
|
|
16
16
|
import"../../index-sqc6ezrb.js";
|
|
17
|
+
import"../../index-bknzva6n.js";
|
|
17
18
|
import"../../index-0v9xb8pz.js";
|
|
18
19
|
import {
|
|
19
20
|
mountMcp2,
|
|
@@ -37,25 +37,26 @@ import {
|
|
|
37
37
|
} from "../index-99nnsz39.js";
|
|
38
38
|
import {
|
|
39
39
|
AsyncOperationCancelResultSchema2,
|
|
40
|
-
createAsyncOperationSnapshotSchema2
|
|
40
|
+
createAsyncOperationSnapshotSchema2
|
|
41
|
+
} from "../index-81t0bf0f.js";
|
|
42
|
+
import {
|
|
43
|
+
ManagedFilePathSchema2,
|
|
44
|
+
ManagedFileRefSchema2
|
|
45
|
+
} from "../index-xqhede6x.js";
|
|
46
|
+
import {
|
|
41
47
|
McpAnnotationsSchema2,
|
|
42
48
|
McpMediaContentSchema2,
|
|
43
49
|
ViewFileErrorSchema2,
|
|
44
50
|
ViewFileOutputSchema2,
|
|
45
51
|
ViewFileInputSchema2
|
|
46
|
-
} from "../index-
|
|
47
|
-
import {
|
|
48
|
-
ManagedFilePathSchema2,
|
|
49
|
-
ManagedFileRefSchema2
|
|
50
|
-
} from "../index-xqhede6x.js";
|
|
52
|
+
} from "../index-bknzva6n.js";
|
|
51
53
|
import {
|
|
52
54
|
signJwt2,
|
|
53
55
|
verifyPkce2
|
|
54
56
|
} from "../index-hkw233vx.js";
|
|
55
57
|
import {
|
|
56
|
-
contractOnlyService
|
|
57
|
-
|
|
58
|
-
} from "../index-eabx6qjh.js";
|
|
58
|
+
contractOnlyService
|
|
59
|
+
} from "../index-tnnmekgb.js";
|
|
59
60
|
import"../index-9ypczvpj.js";
|
|
60
61
|
import {
|
|
61
62
|
describeToolCatalog2,
|
|
@@ -80,8 +81,12 @@ import {
|
|
|
80
81
|
} from "../index-96yjwwgf.js";
|
|
81
82
|
import {
|
|
82
83
|
WaitTimeoutError,
|
|
83
|
-
runWaitOperation
|
|
84
|
-
|
|
84
|
+
runWaitOperation,
|
|
85
|
+
mediaExtension
|
|
86
|
+
} from "../index-9cxxfkhb.js";
|
|
87
|
+
import {
|
|
88
|
+
mediaTypeEssence
|
|
89
|
+
} from "../index-zs8cze4j.js";
|
|
85
90
|
import {
|
|
86
91
|
collectToolSurface
|
|
87
92
|
} from "../index-993vtv1w.js";
|
|
@@ -1410,17 +1415,6 @@ function createToolLogger(config = {}) {
|
|
|
1410
1415
|
// src/tools/transfer/download-core.ts
|
|
1411
1416
|
import { basename, extname } from "node:path";
|
|
1412
1417
|
var DEFAULT_MAX_BYTES = 100 * 1024 * 1024;
|
|
1413
|
-
var MIME_EXT = {
|
|
1414
|
-
"image/png": ".png",
|
|
1415
|
-
"image/jpeg": ".jpg",
|
|
1416
|
-
"image/webp": ".webp",
|
|
1417
|
-
"image/gif": ".gif",
|
|
1418
|
-
"video/mp4": ".mp4",
|
|
1419
|
-
"video/webm": ".webm",
|
|
1420
|
-
"audio/mpeg": ".mp3",
|
|
1421
|
-
"audio/wav": ".wav",
|
|
1422
|
-
"audio/ogg": ".ogg"
|
|
1423
|
-
};
|
|
1424
1418
|
|
|
1425
1419
|
class DownloadOperationError extends Error {
|
|
1426
1420
|
code;
|
|
@@ -1433,8 +1427,9 @@ class DownloadOperationError extends Error {
|
|
|
1433
1427
|
}
|
|
1434
1428
|
}
|
|
1435
1429
|
function extensionFor(url, mime) {
|
|
1436
|
-
|
|
1437
|
-
|
|
1430
|
+
const known = mediaExtension(mime);
|
|
1431
|
+
if (known)
|
|
1432
|
+
return known;
|
|
1438
1433
|
try {
|
|
1439
1434
|
const ext = extname(new URL(url).pathname).toLowerCase();
|
|
1440
1435
|
if (ext)
|
|
@@ -1450,6 +1445,9 @@ function baseNameFor(url) {
|
|
|
1450
1445
|
return "download";
|
|
1451
1446
|
}
|
|
1452
1447
|
}
|
|
1448
|
+
function downloadFileName(url, mime) {
|
|
1449
|
+
return `${baseNameFor(url)}${extensionFor(url, mime)}`;
|
|
1450
|
+
}
|
|
1453
1451
|
async function runDownloadOperation(config) {
|
|
1454
1452
|
const res = await fetchGuarded(new URL(config.url), config.allowPrivateHosts ?? false, {
|
|
1455
1453
|
timeoutMs: config.timeoutMs,
|
|
@@ -1465,7 +1463,7 @@ async function runDownloadOperation(config) {
|
|
|
1465
1463
|
await res.body?.cancel();
|
|
1466
1464
|
throw new DownloadOperationError("DOWNLOAD_TOO_LARGE", `file exceeds the ${max}-byte cap`, 413);
|
|
1467
1465
|
}
|
|
1468
|
-
const path = config.path ??
|
|
1466
|
+
const path = config.path ?? downloadFileName(config.url, mimeType);
|
|
1469
1467
|
return config.files.write(path, res.body ?? new Uint8Array, {
|
|
1470
1468
|
maxBytes: max,
|
|
1471
1469
|
mediaType: mimeType,
|
|
@@ -1604,7 +1602,7 @@ function defineUploadTool(config) {
|
|
|
1604
1602
|
});
|
|
1605
1603
|
}
|
|
1606
1604
|
// src/tools/transfer/view-file.ts
|
|
1607
|
-
import { extname as extname2 } from "node:path";
|
|
1605
|
+
import { basename as basename2, extname as extname2 } from "node:path";
|
|
1608
1606
|
import { z as z5 } from "zod";
|
|
1609
1607
|
var MAX_INLINE_BYTES = 20 * 1024 * 1024;
|
|
1610
1608
|
var EXT_MIME = {
|
|
@@ -1621,10 +1619,16 @@ var EXT_MIME = {
|
|
|
1621
1619
|
".webm": "video/webm",
|
|
1622
1620
|
".mov": "video/quicktime"
|
|
1623
1621
|
};
|
|
1622
|
+
function isHttpUrl(pathOrUrl) {
|
|
1623
|
+
return pathOrUrl.startsWith("http://") || pathOrUrl.startsWith("https://");
|
|
1624
|
+
}
|
|
1625
|
+
function sourceName(pathOrUrl, mimeType) {
|
|
1626
|
+
return isHttpUrl(pathOrUrl) ? downloadFileName(pathOrUrl, mimeType) : basename2(pathOrUrl);
|
|
1627
|
+
}
|
|
1624
1628
|
async function fetchSource(pathOrUrl, options, maxBytes) {
|
|
1625
1629
|
const extension = extname2(pathOrUrl);
|
|
1626
1630
|
const extMime = EXT_MIME[extension.toLowerCase()];
|
|
1627
|
-
if (
|
|
1631
|
+
if (isHttpUrl(pathOrUrl)) {
|
|
1628
1632
|
const url = new URL(pathOrUrl);
|
|
1629
1633
|
const res = await fetchGuarded(url, options.allowPrivateHosts ?? false, {
|
|
1630
1634
|
timeoutMs: options.timeoutMs,
|
|
@@ -1717,6 +1721,7 @@ async function resolveMediaWithinBudget(pathOrUrl, options, maxBytes) {
|
|
|
1717
1721
|
type: "image",
|
|
1718
1722
|
data: buffer.toString("base64"),
|
|
1719
1723
|
mimeType,
|
|
1724
|
+
name: sourceName(pathOrUrl, mimeType),
|
|
1720
1725
|
annotations: { audience: ["user", "assistant"], priority: 0.9 }
|
|
1721
1726
|
},
|
|
1722
1727
|
{ type: "text", text: `[image] ${mimeType}, ${sizeKb}KB` }
|
|
@@ -1731,6 +1736,7 @@ async function resolveMediaWithinBudget(pathOrUrl, options, maxBytes) {
|
|
|
1731
1736
|
type: "audio",
|
|
1732
1737
|
data: buffer.toString("base64"),
|
|
1733
1738
|
mimeType,
|
|
1739
|
+
name: sourceName(pathOrUrl, mimeType),
|
|
1734
1740
|
annotations: { audience: ["user", "assistant"], priority: 0.9 }
|
|
1735
1741
|
},
|
|
1736
1742
|
{ type: "text", text: `[audio] ${mimeType}, ${sizeKb}KB` }
|