@tool-bridge/server 0.23.0 → 0.25.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/dist/admin.js +164 -5
- package/dist/{airtable-VMQVXLHK.js → airtable-4HFPBKO2.js} +6 -6
- package/dist/{alt_text_generator_ai-FTWY4RU4.js → alt_text_generator_ai-TBGJCAWO.js} +5 -5
- package/dist/{amap-OK5VBHYC.js → amap-V2WZ4GP4.js} +5 -5
- package/dist/{anthropic-S67AZFZ3.js → anthropic-HVNDGFRH.js} +6 -6
- package/dist/{apify-ZE6MYQI3.js → apify-TI5DOAUG.js} +6 -6
- package/dist/{brave_search-TG2M2KOD.js → brave_search-7GFBVUIH.js} +6 -6
- package/dist/{chunk-BADVCN6K.js → chunk-3VF7MQJX.js} +40 -3
- package/dist/{chunk-TDAWLMDE.js → chunk-CXRQCZBS.js} +3 -3
- package/dist/{chunk-VWRUGUSU.js → chunk-G6GI7EMV.js} +3 -3
- package/dist/{chunk-7CTWGTDU.js → chunk-KVLI7ZFI.js} +2 -2
- package/dist/{chunk-2JNAI4OC.js → chunk-N7ZFZWGA.js} +1 -1
- package/dist/{chunk-5ICRY3VU.js → chunk-TF2N67HN.js} +1755 -1349
- package/dist/{chunk-4XJPN3DY.js → chunk-UKITQ6LN.js} +3792 -2881
- package/dist/{chunk-WJHG6OK7.js → chunk-UVG4PNWV.js} +2 -2
- package/dist/{circleci-3L3WJVSK.js → circleci-75NMIPKV.js} +6 -6
- package/dist/{clerk-EZPF2V7T.js → clerk-PB2SJAMC.js} +6 -6
- package/dist/{cohere-U27DPO64.js → cohere-UBIMGBOU.js} +6 -6
- package/dist/{confluence-G2KL6ERH.js → confluence-5436ZQBW.js} +6 -6
- package/dist/{convertapi-L4CLJ2M3.js → convertapi-CZILNAZL.js} +4 -4
- package/dist/{currencyapi-YPYXG7YY.js → currencyapi-IPUUA4ZC.js} +6 -6
- package/dist/{deepseek-6HT6WF3M.js → deepseek-F2JV4HEE.js} +6 -6
- package/dist/{docker_hub-LPE3PCVB.js → docker_hub-TRH7EULS.js} +5 -5
- package/dist/{dropbox-V56ABHTA.js → dropbox-4DCC6FQ7.js} +6 -6
- package/dist/{dub-6OKQ7MHT.js → dub-RSI5NDXK.js} +6 -6
- package/dist/{e2b-JS2U2QFU.js → e2b-KM4FJOXS.js} +6 -6
- package/dist/{exa-DPWVYXSP.js → exa-MF26RJSD.js} +6 -6
- package/dist/{fal_ai-DK6Y27ZF.js → fal_ai-4I4QJKBZ.js} +6 -6
- package/dist/{feishu-K7EGSRF3.js → feishu-KEBTN5OD.js} +3 -3
- package/dist/{feishu_custom_bot-2JUGFYNG.js → feishu_custom_bot-KJTIB3PG.js} +4 -4
- package/dist/{figma-FT5I7ITD.js → figma-OFW54Q54.js} +6 -6
- package/dist/{firehydrant-EIKLKHX2.js → firehydrant-RU3B7DXC.js} +6 -6
- package/dist/{fixer-U5QXIAKD.js → fixer-QZ4WCQN3.js} +5 -5
- package/dist/{fly-T3JYFZ2M.js → fly-ZPUXZ5Y7.js} +6 -6
- package/dist/{front-D72MGVOR.js → front-SCMVKIEA.js} +6 -6
- package/dist/{geocodio-BOTD5TI5.js → geocodio-N3QYPBRC.js} +5 -5
- package/dist/{ghost-KYP7SZGB.js → ghost-VMSBR3TP.js} +5 -5
- package/dist/{github-AGMZT3VY.js → github-XOML5UVH.js} +6 -6
- package/dist/github_events-5FCIB5E3.js +78 -0
- package/dist/{gmail-BLJNJOBG.js → gmail-FX3TTLAE.js} +6 -6
- package/dist/{googlecalendar-GTHWNCF6.js → googlecalendar-LWMUNEF5.js} +6 -6
- package/dist/{googledocs-6EEDMEBQ.js → googledocs-ZGVN66MU.js} +4 -4
- package/dist/{grafana-GMW6EKSQ.js → grafana-NKZPJG5L.js} +6 -6
- package/dist/{graphhopper-6OLGBDGB.js → graphhopper-XCRPVZNX.js} +5 -5
- package/dist/index.d.ts +315 -5
- package/dist/index.js +7 -5
- package/dist/{ip2proxy-4QN42E6T.js → ip2proxy-RDDJFPLQ.js} +5 -5
- package/dist/{ipgeolocation_io-SK4XKDA2.js → ipgeolocation_io-RTUJKI3Z.js} +5 -5
- package/dist/{ipqualityscore-6ANBPXKT.js → ipqualityscore-5NG5KR33.js} +5 -5
- package/dist/{jina_ai-IHPSVRM5.js → jina_ai-VG5X5JBE.js} +6 -6
- package/dist/{jira-46KKM4LC.js → jira-LS6ITOSL.js} +6 -6
- package/dist/{langsmith-JZA345I5.js → langsmith-TT26W3A4.js} +6 -6
- package/dist/{lemlist-43IV7DK6.js → lemlist-25WLR36L.js} +6 -6
- package/dist/{linear-5LFH7XNL.js → linear-JLE2CHI3.js} +4 -4
- package/dist/{logsnag-5RMYAHIL.js → logsnag-OI67GLMG.js} +6 -6
- package/dist/main.js +6 -5
- package/dist/{mattermost-XFL6SHGG.js → mattermost-AYJAUGNG.js} +6 -6
- package/dist/{mem0-NYO4DTP6.js → mem0-ZGEAZPCF.js} +6 -6
- package/dist/{memos-37MPQOLV.js → memos-PS2QHWZX.js} +6 -6
- package/dist/{metabase-KYBKZFMG.js → metabase-6F5P4YNZ.js} +6 -6
- package/dist/{mistral_ai-6PL3K4PM.js → mistral_ai-GKF6H3PY.js} +6 -6
- package/dist/{mother_duck-2NH7W5M5.js → mother_duck-C7KWG5OB.js} +6 -6
- package/dist/{ngrok-UO6CDYCA.js → ngrok-UZQYPMSO.js} +6 -6
- package/dist/{notes-I3P32WP4.js → notes-DO7GGFTP.js} +2 -2
- package/dist/{notion-BEAJFUOE.js → notion-JSLD5P5J.js} +6 -6
- package/dist/{open_exchange_rates-CMF62JB4.js → open_exchange_rates-NZYN73GB.js} +5 -5
- package/dist/{openai-IHOMKVND.js → openai-KOXCZZVV.js} +6 -6
- package/dist/{opengraph_io-ZQ2FGLHX.js → opengraph_io-DVAV6AK6.js} +5 -5
- package/dist/{openrouter-HXLW3NR5.js → openrouter-MPMSFAEY.js} +6 -6
- package/dist/{outline-ELCP4NEU.js → outline-E2SNFTFE.js} +6 -6
- package/dist/{paddle-O77LALVN.js → paddle-QOZOMZ6T.js} +6 -6
- package/dist/{perplexity-JCU654QV.js → perplexity-VRWYDYRW.js} +6 -6
- package/dist/{pinecone-W5W4LRKL.js → pinecone-LDU3YSBJ.js} +6 -6
- package/dist/{pipedrive-ITMJLLPZ.js → pipedrive-ZN6NDUPL.js} +6 -6
- package/dist/{polar-R33XU4L3.js → polar-H5GK75YP.js} +6 -6
- package/dist/{posthog-JVNTOLTV.js → posthog-XVJMSCPA.js} +6 -6
- package/dist/{postmark-6SBG7HWV.js → postmark-IVXNOXFI.js} +6 -6
- package/dist/{prerender-GPNKTNFC.js → prerender-FH4SBVJY.js} +5 -5
- package/dist/{pubmed-UP6ZEEIH.js → pubmed-TM7LBALS.js} +4 -4
- package/dist/{railway-KWEWXHTY.js → railway-FJ4XQ2NF.js} +4 -4
- package/dist/{readwise-BLATSMC3.js → readwise-4VQNTOLQ.js} +6 -6
- package/dist/{render-QYRVIXII.js → render-CX7AWO6F.js} +6 -6
- package/dist/{replicate-JYTWH4NF.js → replicate-U6T7GYMR.js} +6 -6
- package/dist/{resend-L5N75SZM.js → resend-RDQXZGY6.js} +6 -6
- package/dist/{rootly-MHCPEQ26.js → rootly-AWTSRSIZ.js} +6 -6
- package/dist/{scrapfly-PTPGYSJM.js → scrapfly-UWX6TBH7.js} +5 -5
- package/dist/{scrapingbee-JN6UH5PY.js → scrapingbee-BKCOLELF.js} +5 -5
- package/dist/{screenshot_fyi-4QRVSV55.js → screenshot_fyi-3OYHV6ZZ.js} +5 -5
- package/dist/{semantic_scholar-LRSWA2GE.js → semantic_scholar-EV2HDKRA.js} +6 -6
- package/dist/{sentry-2G6PF5W6.js → sentry-BPEKPIFX.js} +6 -6
- package/dist/{shodan-WKKPP5C6.js → shodan-RYTNBHVJ.js} +5 -5
- package/dist/{shopify-64YDK5T2.js → shopify-JGWZFCNO.js} +6 -6
- package/dist/{stripe-QAIGGOTF.js → stripe-RBWCW52X.js} +4 -4
- package/dist/{supabase-WHTGR6ND.js → supabase-TX5J2UBD.js} +6 -6
- package/dist/{tavily-QIXCDDWO.js → tavily-33ZRT2RT.js} +6 -6
- package/dist/{telegram-E6G7CWI6.js → telegram-HX3UKW3Y.js} +5 -5
- package/dist/{telnyx-ZDVVS7PK.js → telnyx-5J74OO5R.js} +6 -6
- package/dist/{todoist-DMYF3G7J.js → todoist-6CUCDWTH.js} +6 -6
- package/dist/{trello-HY2RYIRP.js → trello-FTFDRPZ7.js} +5 -5
- package/dist/{turso-HAQWMGRP.js → turso-33T4OAJR.js} +6 -6
- package/dist/{twilio-MLXYPHJE.js → twilio-ZBX6EHFG.js} +4 -4
- package/dist/{umami-DZHBLPVG.js → umami-QCVTF7WS.js} +6 -6
- package/dist/{unsplash-GS2OPXKE.js → unsplash-M6XCQKQE.js} +6 -6
- package/dist/{upstash_redis-XMXWTNAJ.js → upstash_redis-57JQ3XMB.js} +6 -6
- package/dist/{uptimerobot-TF5WRZ4G.js → uptimerobot-KDS5YBKZ.js} +4 -4
- package/dist/{v2ex-2BVXAPDF.js → v2ex-5YPZ6BIT.js} +6 -6
- package/dist/{vercel-YMJGQYJE.js → vercel-6VWZHALZ.js} +6 -6
- package/dist/{wolfram_alpha_api-I56SXWFZ.js → wolfram_alpha_api-4YNRTVTQ.js} +5 -5
- package/dist/{wordpress-R7TDFZ2P.js → wordpress-LKN2EV4B.js} +6 -6
- package/dist/{workos-HDNHWVMS.js → workos-DTPEULYR.js} +6 -6
- package/dist/{zhihu-LX6AGGDS.js → zhihu-LFQRTQS7.js} +6 -6
- package/package.json +5 -5
package/dist/admin.js
CHANGED
|
@@ -2,21 +2,180 @@
|
|
|
2
2
|
import {
|
|
3
3
|
BootstrapStateStore,
|
|
4
4
|
package_default
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import
|
|
5
|
+
} from "./chunk-KVLI7ZFI.js";
|
|
6
|
+
import {
|
|
7
|
+
httpsReleaseUrl,
|
|
8
|
+
pluginImageSchema
|
|
9
|
+
} from "./chunk-TF2N67HN.js";
|
|
7
10
|
import "./chunk-U67V476Y.js";
|
|
8
11
|
|
|
9
12
|
// src/admin.ts
|
|
10
|
-
import { chown, mkdir, readFile, writeFile } from "fs/promises";
|
|
13
|
+
import { chown, mkdir, readFile as readFile2, writeFile } from "fs/promises";
|
|
11
14
|
import { CreateBucketCommand, S3Client } from "@aws-sdk/client-s3";
|
|
12
15
|
import writeFileAtomic from "write-file-atomic";
|
|
13
16
|
import { randomBytes } from "crypto";
|
|
14
17
|
import { Command } from "commander";
|
|
15
18
|
import { join } from "path";
|
|
19
|
+
import pRetry2 from "p-retry";
|
|
20
|
+
|
|
21
|
+
// src/pluginRunner.ts
|
|
22
|
+
import { getRequestListener } from "@hono/node-server";
|
|
23
|
+
import { chmod, readFile } from "fs/promises";
|
|
24
|
+
import { execFile } from "child_process";
|
|
25
|
+
import { bodyLimit } from "hono/body-limit";
|
|
26
|
+
import { createHash } from "crypto";
|
|
27
|
+
import { createServer } from "http";
|
|
28
|
+
import { promisify } from "util";
|
|
16
29
|
import pRetry from "p-retry";
|
|
30
|
+
import { Hono } from "hono";
|
|
31
|
+
import { z } from "zod/v4";
|
|
32
|
+
var identity = z.strictObject({
|
|
33
|
+
id: z.string().max(128).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/),
|
|
34
|
+
image: pluginImageSchema
|
|
35
|
+
});
|
|
36
|
+
var policySchema = z.strictObject({
|
|
37
|
+
// A dedicated bridge with operator-managed egress rules. Reject Docker's special network modes.
|
|
38
|
+
network: z.string().regex(/^tb-plugins-[a-z0-9-]+$/),
|
|
39
|
+
releases: z.array(identity.extend({
|
|
40
|
+
endpoint: z.string().transform((value) => httpsReleaseUrl(value).replace(/\/+$/, "")),
|
|
41
|
+
port: z.int().min(1024).max(65535),
|
|
42
|
+
tokenFile: z.string().startsWith("/")
|
|
43
|
+
})).min(1)
|
|
44
|
+
});
|
|
45
|
+
var exec = promisify(execFile);
|
|
46
|
+
async function docker(args, pluginToken) {
|
|
47
|
+
const host = process.env.DOCKER_HOST ?? "unix:///var/run/docker.sock";
|
|
48
|
+
if (!host.startsWith("unix:///")) throw new Error("plugin runner requires a local Docker socket");
|
|
49
|
+
const { stdout } = await exec("docker", ["--host", host, ...args], {
|
|
50
|
+
timeout: args[0] === "image" && args[1] === "pull" ? 3e5 : 15e3,
|
|
51
|
+
maxBuffer: 32 * 1024,
|
|
52
|
+
env: pluginToken === void 0 ? process.env : { ...process.env, PLUGIN_TOKEN: pluginToken }
|
|
53
|
+
});
|
|
54
|
+
return stdout.trim();
|
|
55
|
+
}
|
|
56
|
+
async function checkEndpoint(port) {
|
|
57
|
+
const response = await fetch(`http://127.0.0.1:${port}/~auth`, {
|
|
58
|
+
method: "HEAD",
|
|
59
|
+
redirect: "manual",
|
|
60
|
+
signal: AbortSignal.timeout(1e3)
|
|
61
|
+
});
|
|
62
|
+
if (response.status >= 500) throw new Error("plugin is starting");
|
|
63
|
+
}
|
|
64
|
+
function createPluginRunner(policy, run = docker, ready = checkEndpoint) {
|
|
65
|
+
const { releases, network } = policySchema.parse(policy);
|
|
66
|
+
for (const values of [releases.map((r) => r.endpoint), releases.map((r) => r.port), releases.map((r) => r.id + ":" + r.image)]) {
|
|
67
|
+
if (new Set(values).size !== releases.length) throw new Error("duplicate plugin release identity, endpoint or port");
|
|
68
|
+
}
|
|
69
|
+
const pending = /* @__PURE__ */ new Map();
|
|
70
|
+
async function prepare(entry, name) {
|
|
71
|
+
const listing = await run(["container", "ls", "--all", "--filter", "name=^/" + name + "$", "--format", "{{.Names}}"]);
|
|
72
|
+
if (listing !== name) {
|
|
73
|
+
const inspectVolumes = () => run(["image", "inspect", "--format", "{{json .Config.Volumes}}", entry.image]);
|
|
74
|
+
let volumes;
|
|
75
|
+
try {
|
|
76
|
+
volumes = await inspectVolumes();
|
|
77
|
+
} catch (error) {
|
|
78
|
+
const stderr = error?.stderr;
|
|
79
|
+
if (typeof stderr !== "string" || !/no such (?:image|object)\s*:/i.test(stderr)) throw error;
|
|
80
|
+
await run(["image", "pull", "--quiet", entry.image]);
|
|
81
|
+
volumes = await inspectVolumes();
|
|
82
|
+
}
|
|
83
|
+
if (volumes !== "null" && volumes !== "{}") throw new Error("plugin images must not declare writable volumes");
|
|
84
|
+
const token = (await readFile(entry.tokenFile, "utf8")).trim();
|
|
85
|
+
if (!token) throw new Error("missing plugin credential");
|
|
86
|
+
await run([
|
|
87
|
+
"container",
|
|
88
|
+
"create",
|
|
89
|
+
"--name",
|
|
90
|
+
name,
|
|
91
|
+
"--pull",
|
|
92
|
+
"never",
|
|
93
|
+
"--read-only",
|
|
94
|
+
"--user",
|
|
95
|
+
"65532:65532",
|
|
96
|
+
"--cap-drop",
|
|
97
|
+
"ALL",
|
|
98
|
+
"--security-opt",
|
|
99
|
+
"no-new-privileges",
|
|
100
|
+
"--pids-limit",
|
|
101
|
+
"64",
|
|
102
|
+
"--memory",
|
|
103
|
+
"128m",
|
|
104
|
+
"--cpus",
|
|
105
|
+
"0.5",
|
|
106
|
+
"--tmpfs",
|
|
107
|
+
"/tmp:rw,noexec,nosuid,nodev,size=16m",
|
|
108
|
+
"--network",
|
|
109
|
+
network,
|
|
110
|
+
"--restart",
|
|
111
|
+
"unless-stopped",
|
|
112
|
+
"--log-opt",
|
|
113
|
+
"max-size=4m",
|
|
114
|
+
"--log-opt",
|
|
115
|
+
"max-file=2",
|
|
116
|
+
"--publish",
|
|
117
|
+
"127.0.0.1:" + entry.port + ":8080",
|
|
118
|
+
"--env",
|
|
119
|
+
"PLUGIN_TOKEN",
|
|
120
|
+
"--env",
|
|
121
|
+
"PORT=8080",
|
|
122
|
+
entry.image
|
|
123
|
+
], token);
|
|
124
|
+
}
|
|
125
|
+
const image = await run(["container", "inspect", "--format", "{{.Config.Image}}", name]);
|
|
126
|
+
if (image !== entry.image) throw new Error("existing container image mismatch");
|
|
127
|
+
await run(["container", "start", name]);
|
|
128
|
+
await pRetry(() => ready(entry.port), { retries: 7, minTimeout: 100, maxTimeout: 1e3 });
|
|
129
|
+
}
|
|
130
|
+
const app = new Hono();
|
|
131
|
+
app.post("/prepare", bodyLimit({ maxSize: 1024 }), async (c) => {
|
|
132
|
+
const request = identity.safeParse(await c.req.json().catch(() => null));
|
|
133
|
+
if (!request.success) return c.body(null, 400);
|
|
134
|
+
const entry = releases.find((r) => r.id === request.data.id && r.image === request.data.image);
|
|
135
|
+
if (!entry) return c.body(null, 403);
|
|
136
|
+
const name = "tb-plugin-" + createHash("sha256").update(JSON.stringify([network, entry])).digest("hex").slice(0, 24);
|
|
137
|
+
try {
|
|
138
|
+
let work = pending.get(name);
|
|
139
|
+
if (!work) {
|
|
140
|
+
work = prepare(entry, name).finally(() => pending.delete(name));
|
|
141
|
+
pending.set(name, work);
|
|
142
|
+
}
|
|
143
|
+
await work;
|
|
144
|
+
return c.body(null, 204, { "X-TB-Plugin-Endpoint": entry.endpoint });
|
|
145
|
+
} catch {
|
|
146
|
+
return c.body(null, 503);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
return app;
|
|
150
|
+
}
|
|
151
|
+
async function servePluginRunner(policyFile, socketPath) {
|
|
152
|
+
const app = createPluginRunner(JSON.parse(await readFile(policyFile, "utf8")));
|
|
153
|
+
const server = createServer(getRequestListener(app.fetch));
|
|
154
|
+
server.requestTimeout = 3e4;
|
|
155
|
+
await new Promise((resolve, reject) => {
|
|
156
|
+
server.once("error", reject);
|
|
157
|
+
server.listen(socketPath, resolve);
|
|
158
|
+
});
|
|
159
|
+
try {
|
|
160
|
+
await chmod(socketPath, 432);
|
|
161
|
+
} catch (error) {
|
|
162
|
+
server.close();
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
return server;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// src/admin.ts
|
|
17
169
|
var program = new Command("tool-bridge-admin").version(package_default.version).description(
|
|
18
170
|
"Local installation and recovery; requires access to the protected bootstrap directory"
|
|
19
171
|
);
|
|
172
|
+
program.command("plugin-runner").description("Serve locally approved immutable plugin containers on a protected Unix socket").requiredOption("--policy <file>", "Operator-owned JSON release allowlist").requiredOption("--socket <path>", "Private control socket in an operator-owned directory").action(async (opts) => {
|
|
173
|
+
process.umask(79);
|
|
174
|
+
const server = await servePluginRunner(opts.policy, opts.socket);
|
|
175
|
+
const stop = () => server.close();
|
|
176
|
+
process.once("SIGINT", stop);
|
|
177
|
+
process.once("SIGTERM", stop);
|
|
178
|
+
});
|
|
20
179
|
for (const mode of ["pair", "recover"]) {
|
|
21
180
|
program.command(mode).option(
|
|
22
181
|
"--directory <path>",
|
|
@@ -131,7 +290,7 @@ program.command("init-bucket").option(
|
|
|
131
290
|
"/secrets/s3/admin.json"
|
|
132
291
|
).option("--endpoint <url>", "Exact local S3 endpoint", "http://objects:8333").action(async (opts) => {
|
|
133
292
|
const credentials = JSON.parse(
|
|
134
|
-
await
|
|
293
|
+
await readFile2(opts.credentials, "utf8")
|
|
135
294
|
);
|
|
136
295
|
const client = new S3Client({
|
|
137
296
|
endpoint: opts.endpoint,
|
|
@@ -141,7 +300,7 @@ program.command("init-bucket").option(
|
|
|
141
300
|
maxAttempts: 1
|
|
142
301
|
});
|
|
143
302
|
try {
|
|
144
|
-
await
|
|
303
|
+
await pRetry2(
|
|
145
304
|
async () => {
|
|
146
305
|
try {
|
|
147
306
|
await client.send(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAuthedClient
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-CXRQCZBS.js";
|
|
4
|
+
import "./chunk-G6GI7EMV.js";
|
|
5
5
|
import {
|
|
6
6
|
asJsonObject,
|
|
7
7
|
booleanValue,
|
|
@@ -12,12 +12,12 @@ import {
|
|
|
12
12
|
import {
|
|
13
13
|
createProviderPlugin,
|
|
14
14
|
upstreamError
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
15
|
+
} from "./chunk-UVG4PNWV.js";
|
|
16
|
+
import "./chunk-N7ZFZWGA.js";
|
|
17
|
+
import "./chunk-3VF7MQJX.js";
|
|
18
18
|
import {
|
|
19
19
|
TBError
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-TF2N67HN.js";
|
|
21
21
|
import "./chunk-U67V476Y.js";
|
|
22
22
|
|
|
23
23
|
// ../plugins/src/airtable/api.ts
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createProviderHttpClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-G6GI7EMV.js";
|
|
4
4
|
import "./chunk-JXHMDBAY.js";
|
|
5
5
|
import {
|
|
6
6
|
createProviderPlugin,
|
|
7
7
|
requireApiKey,
|
|
8
8
|
upstreamError
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-UVG4PNWV.js";
|
|
10
|
+
import "./chunk-N7ZFZWGA.js";
|
|
11
|
+
import "./chunk-3VF7MQJX.js";
|
|
12
12
|
import {
|
|
13
13
|
TBError
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-TF2N67HN.js";
|
|
15
15
|
import "./chunk-U67V476Y.js";
|
|
16
16
|
|
|
17
17
|
// ../plugins/src/alt_text_generator_ai/schema.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createProviderHttpClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-G6GI7EMV.js";
|
|
4
4
|
import {
|
|
5
5
|
asJsonObject,
|
|
6
6
|
booleanValue,
|
|
@@ -10,12 +10,12 @@ import {
|
|
|
10
10
|
createProviderPlugin,
|
|
11
11
|
requireApiKey,
|
|
12
12
|
upstreamError
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-UVG4PNWV.js";
|
|
14
|
+
import "./chunk-N7ZFZWGA.js";
|
|
15
|
+
import "./chunk-3VF7MQJX.js";
|
|
16
16
|
import {
|
|
17
17
|
TBError
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-TF2N67HN.js";
|
|
19
19
|
import "./chunk-U67V476Y.js";
|
|
20
20
|
|
|
21
21
|
// ../plugins/src/amap/api.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAuthedClient
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-CXRQCZBS.js";
|
|
4
|
+
import "./chunk-G6GI7EMV.js";
|
|
5
5
|
import {
|
|
6
6
|
compactDefined,
|
|
7
7
|
trimmedText
|
|
@@ -9,12 +9,12 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
createProviderPlugin,
|
|
11
11
|
upstreamError
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-UVG4PNWV.js";
|
|
13
|
+
import "./chunk-N7ZFZWGA.js";
|
|
14
|
+
import "./chunk-3VF7MQJX.js";
|
|
15
15
|
import {
|
|
16
16
|
TBError
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-TF2N67HN.js";
|
|
18
18
|
import "./chunk-U67V476Y.js";
|
|
19
19
|
|
|
20
20
|
// ../plugins/src/anthropic/api.ts
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAuthedClient
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-CXRQCZBS.js";
|
|
4
|
+
import "./chunk-G6GI7EMV.js";
|
|
5
5
|
import {
|
|
6
6
|
asJsonObject
|
|
7
7
|
} from "./chunk-JXHMDBAY.js";
|
|
8
8
|
import {
|
|
9
9
|
createProviderPlugin,
|
|
10
10
|
upstreamError
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-UVG4PNWV.js";
|
|
12
|
+
import "./chunk-N7ZFZWGA.js";
|
|
13
|
+
import "./chunk-3VF7MQJX.js";
|
|
14
14
|
import {
|
|
15
15
|
TBError
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-TF2N67HN.js";
|
|
17
17
|
import "./chunk-U67V476Y.js";
|
|
18
18
|
|
|
19
19
|
// ../plugins/src/apify/api.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAuthedClient
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-CXRQCZBS.js";
|
|
4
|
+
import "./chunk-G6GI7EMV.js";
|
|
5
5
|
import {
|
|
6
6
|
asJsonObject,
|
|
7
7
|
compactDefined,
|
|
@@ -10,12 +10,12 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
createProviderPlugin,
|
|
12
12
|
upstreamError
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-UVG4PNWV.js";
|
|
14
|
+
import "./chunk-N7ZFZWGA.js";
|
|
15
|
+
import "./chunk-3VF7MQJX.js";
|
|
16
16
|
import {
|
|
17
17
|
TBError
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-TF2N67HN.js";
|
|
19
19
|
import "./chunk-U67V476Y.js";
|
|
20
20
|
|
|
21
21
|
// ../plugins/src/brave_search/api.ts
|
|
@@ -10,9 +10,10 @@ import {
|
|
|
10
10
|
isTBError,
|
|
11
11
|
parseCredentialValues,
|
|
12
12
|
toToolResult
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-TF2N67HN.js";
|
|
14
14
|
|
|
15
15
|
// ../plugin-sdk/src/index.ts
|
|
16
|
+
import { z } from "zod/v4";
|
|
16
17
|
var CONTEXT_HANDLER_VERBS = ["list", "get", "write", "update", "delete", "search"];
|
|
17
18
|
var CAPABILITY_BY_VERB = { search: "search", delete: "delete" };
|
|
18
19
|
var PROTOCOL_VERSION = "plugin/v2";
|
|
@@ -35,7 +36,7 @@ function contextVerbs(handlers) {
|
|
|
35
36
|
}
|
|
36
37
|
function helpCmds(state) {
|
|
37
38
|
if (state.kind === "tools") return state.registry.list();
|
|
38
|
-
if (state.kind === "proxyTools") return [];
|
|
39
|
+
if (state.kind === "events" || state.kind === "proxyTools") return [];
|
|
39
40
|
return contextVerbs(state.handlers).map((name) => ({ name }));
|
|
40
41
|
}
|
|
41
42
|
function createPlugin(opts = {}) {
|
|
@@ -52,6 +53,20 @@ function createPlugin(opts = {}) {
|
|
|
52
53
|
return {
|
|
53
54
|
protocolVersion: PROTOCOL_VERSION,
|
|
54
55
|
exports: [...exports.values()].map((state) => {
|
|
56
|
+
if (state.kind === "events") {
|
|
57
|
+
const { handlers } = state;
|
|
58
|
+
return {
|
|
59
|
+
id: state.id,
|
|
60
|
+
profile: "events/v1",
|
|
61
|
+
description: handlers.description,
|
|
62
|
+
auth: { kind: "single", label: "Webhook signing secret", required: true },
|
|
63
|
+
eventSource: { headers: handlers.headers, types: Object.entries(handlers.types).map(([type, definition]) => ({
|
|
64
|
+
type,
|
|
65
|
+
version: definition.version,
|
|
66
|
+
dataSchema: z.toJSONSchema(definition.schema)
|
|
67
|
+
})) }
|
|
68
|
+
};
|
|
69
|
+
}
|
|
55
70
|
if (state.kind === "tools" || state.kind === "proxyTools") {
|
|
56
71
|
return {
|
|
57
72
|
id: state.id,
|
|
@@ -206,7 +221,7 @@ function createPlugin(opts = {}) {
|
|
|
206
221
|
const state = exports.get(exportId);
|
|
207
222
|
if (state === void 0) throw new TBError("invalid_argument", `unknown export '${exportId}'`);
|
|
208
223
|
const upstreamAuth = decodeUpstreamAuth(request);
|
|
209
|
-
const credentialFields = state.kind === "
|
|
224
|
+
const credentialFields = state.kind === "tools" || state.kind === "proxyTools" ? state.credentialFields : void 0;
|
|
210
225
|
const ctx = {
|
|
211
226
|
env,
|
|
212
227
|
caller,
|
|
@@ -218,6 +233,19 @@ function createPlugin(opts = {}) {
|
|
|
218
233
|
};
|
|
219
234
|
const requestId = request.headers.get(HEADER_TB_REQUEST_ID);
|
|
220
235
|
const run = async () => {
|
|
236
|
+
if (state.kind === "events") {
|
|
237
|
+
if (call.tool !== "Verify" || !ctx.upstreamAuth) throw TBError.unauthenticated();
|
|
238
|
+
const parsed = z.strictObject({
|
|
239
|
+
rawBody: z.string(),
|
|
240
|
+
headers: z.record(z.string(), z.string())
|
|
241
|
+
}).safeParse(call.arguments);
|
|
242
|
+
if (!parsed.success) throw new TBError("invalid_argument", "invalid webhook envelope");
|
|
243
|
+
const verified = await state.handlers.verify(parsed.data, ctx);
|
|
244
|
+
if (verified === null) return null;
|
|
245
|
+
const definition = Object.hasOwn(state.handlers.types, verified.type) && state.handlers.types[verified.type];
|
|
246
|
+
if (!definition) throw new TBError("invalid_argument", "undeclared webhook event type");
|
|
247
|
+
return { ...verified, data: definition.schema.parse(verified.data), schemaVersion: definition.version };
|
|
248
|
+
}
|
|
221
249
|
if (state.kind === "tools") return await dispatchTools(state, call.tool, call.arguments, ctx);
|
|
222
250
|
if (state.kind === "proxyTools") {
|
|
223
251
|
return await dispatchProxyTools(state, call.tool, call.arguments, ctx);
|
|
@@ -228,6 +256,11 @@ function createPlugin(opts = {}) {
|
|
|
228
256
|
return json(value ?? null);
|
|
229
257
|
}
|
|
230
258
|
const plugin = {
|
|
259
|
+
events(id, handlers) {
|
|
260
|
+
assertFreshId(id);
|
|
261
|
+
exports.set(id, { id, kind: "events", handlers });
|
|
262
|
+
return plugin;
|
|
263
|
+
},
|
|
231
264
|
tools(id, meta) {
|
|
232
265
|
assertFreshId(id);
|
|
233
266
|
const state = {
|
|
@@ -357,6 +390,10 @@ function createPlugin(opts = {}) {
|
|
|
357
390
|
async fetch(request, env) {
|
|
358
391
|
try {
|
|
359
392
|
const url = new URL(request.url);
|
|
393
|
+
if (request.method === "HEAD" && url.pathname === "/~auth") {
|
|
394
|
+
assertAuthorized(request, env);
|
|
395
|
+
return new Response(null, { status: 204, headers: { "X-TB-Plugin-Auth": "plugin/v2" } });
|
|
396
|
+
}
|
|
360
397
|
if (request.method === "GET") {
|
|
361
398
|
if (url.pathname === healthPath) return json({ healthy: true });
|
|
362
399
|
if (url.pathname === "/~describe") return json(describe());
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createProviderHttpClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-G6GI7EMV.js";
|
|
4
4
|
import {
|
|
5
5
|
asJsonObject,
|
|
6
6
|
trimmedText
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
requireApiKey,
|
|
10
10
|
upstreamError
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-UVG4PNWV.js";
|
|
12
12
|
import {
|
|
13
13
|
TBError
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-TF2N67HN.js";
|
|
15
15
|
|
|
16
16
|
// ../plugins/src/_runtime/authedClient.ts
|
|
17
17
|
function extractErrorMessage(payload, keys) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
upstreamError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UVG4PNWV.js";
|
|
4
4
|
import {
|
|
5
5
|
createGuardedFetch
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-N7ZFZWGA.js";
|
|
7
7
|
import {
|
|
8
8
|
TBError,
|
|
9
9
|
isTBError
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-TF2N67HN.js";
|
|
11
11
|
|
|
12
12
|
// ../plugins/src/_runtime/providerHttp.ts
|
|
13
13
|
function credentialLike(name) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TBError,
|
|
3
3
|
createEncryptionKeyring
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-TF2N67HN.js";
|
|
5
5
|
|
|
6
6
|
// src/bootstrapState.ts
|
|
7
7
|
import {
|
|
@@ -216,7 +216,7 @@ var BootstrapStateStore = class {
|
|
|
216
216
|
// package.json
|
|
217
217
|
var package_default = {
|
|
218
218
|
name: "@tool-bridge/server",
|
|
219
|
-
version: "0.
|
|
219
|
+
version: "0.25.0",
|
|
220
220
|
description: "Self-hosted Tool Bridge Node server with PostgreSQL, S3 object storage and WebSocket device channels",
|
|
221
221
|
type: "module",
|
|
222
222
|
license: "MIT",
|