@wirecat/slack-cli 0.0.0-stage → 0.2.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 +121 -0
- package/LICENSE +204 -0
- package/README.md +131 -2
- package/contracts/wirecat.json +5526 -0
- package/dist/bin/slack.d.ts +3 -0
- package/dist/bin/slack.d.ts.map +1 -0
- package/dist/bin/slack.js +40 -0
- package/dist/bin/slack.js.map +1 -0
- package/dist/bundle/agent-GOFXFUQP.js +37 -0
- package/dist/bundle/all-profiles-4C7VOT2D.js +320 -0
- package/dist/bundle/anthropic-ZD66TC5S.js +91 -0
- package/dist/bundle/app-server-QNCVEDMY.js +249 -0
- package/dist/bundle/bun-2FULBYXS.js +169 -0
- package/dist/bundle/bun-sqlite-PMS26ZUT.js +76 -0
- package/dist/bundle/chunk-2LB5BWC4.js +362 -0
- package/dist/bundle/chunk-2ZEYRHZV.js +18 -0
- package/dist/bundle/chunk-3IJ3THPV.js +7 -0
- package/dist/bundle/chunk-3IZF5ENR.js +61 -0
- package/dist/bundle/chunk-4HSVEQ3R.js +29 -0
- package/dist/bundle/chunk-4QPMHVM5.js +1007 -0
- package/dist/bundle/chunk-53LIHHXC.js +16 -0
- package/dist/bundle/chunk-5F36CXDM.js +794 -0
- package/dist/bundle/chunk-5LPREGD3.js +12636 -0
- package/dist/bundle/chunk-5R5YRYIP.js +1148 -0
- package/dist/bundle/chunk-5RSQTG7L.js +388 -0
- package/dist/bundle/chunk-5SXZETJF.js +170 -0
- package/dist/bundle/chunk-6PDQP5RM.js +50 -0
- package/dist/bundle/chunk-75BLNPN3.js +1197 -0
- package/dist/bundle/chunk-7BEO72EN.js +131 -0
- package/dist/bundle/chunk-7F6RNAIM.js +230 -0
- package/dist/bundle/chunk-AG7FP64Z.js +77 -0
- package/dist/bundle/chunk-BRXTN5LJ.js +338 -0
- package/dist/bundle/chunk-CABZAU37.js +319 -0
- package/dist/bundle/chunk-CCOSG3F2.js +24616 -0
- package/dist/bundle/chunk-CDTZSFTN.js +58 -0
- package/dist/bundle/chunk-CMZBCWND.js +1246 -0
- package/dist/bundle/chunk-CRQEEJNF.js +185 -0
- package/dist/bundle/chunk-CWYU4R65.js +358 -0
- package/dist/bundle/chunk-CZFR6JQX.js +52 -0
- package/dist/bundle/chunk-D72URWJE.js +532 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-DVHX7R54.js +4072 -0
- package/dist/bundle/chunk-DYKOG7QR.js +9596 -0
- package/dist/bundle/chunk-ECDI42G6.js +100 -0
- package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
- package/dist/bundle/chunk-ELY2TLCY.js +259 -0
- package/dist/bundle/chunk-ERRVUVKR.js +156 -0
- package/dist/bundle/chunk-FBWR4E5D.js +353 -0
- package/dist/bundle/chunk-GKS6KL57.js +6848 -0
- package/dist/bundle/chunk-H2COZZ55.js +2787 -0
- package/dist/bundle/chunk-HGXTEK7R.js +82 -0
- package/dist/bundle/chunk-HXLXM7HV.js +726 -0
- package/dist/bundle/chunk-IPP4N6HD.js +24 -0
- package/dist/bundle/chunk-IWTVR7S7.js +53 -0
- package/dist/bundle/chunk-IYJH75D4.js +63 -0
- package/dist/bundle/chunk-JCZLRT4Z.js +39 -0
- package/dist/bundle/chunk-JGRWMR5H.js +123 -0
- package/dist/bundle/chunk-JYRYQJBN.js +633 -0
- package/dist/bundle/chunk-KIKLDI74.js +161 -0
- package/dist/bundle/chunk-L4WO3XH6.js +2020 -0
- package/dist/bundle/chunk-LQDNUAK3.js +274 -0
- package/dist/bundle/chunk-LV5ONLQH.js +38 -0
- package/dist/bundle/chunk-M27Z23OZ.js +23 -0
- package/dist/bundle/chunk-M5XTZHXM.js +142 -0
- package/dist/bundle/chunk-MJBEGUIZ.js +76 -0
- package/dist/bundle/chunk-N4WOLGIV.js +2333 -0
- package/dist/bundle/chunk-N5K4OHPT.js +206 -0
- package/dist/bundle/chunk-NYAPUET7.js +108 -0
- package/dist/bundle/chunk-P4IFLOIK.js +218 -0
- package/dist/bundle/chunk-P6G2QTCD.js +288 -0
- package/dist/bundle/chunk-PL5P7UKW.js +25216 -0
- package/dist/bundle/chunk-PU7R6XNV.js +80 -0
- package/dist/bundle/chunk-QLLBACDR.js +72 -0
- package/dist/bundle/chunk-QP7XN5KX.js +407 -0
- package/dist/bundle/chunk-QY2F6A3D.js +557 -0
- package/dist/bundle/chunk-RLIT7VAZ.js +66 -0
- package/dist/bundle/chunk-S4UUN6LD.js +1410 -0
- package/dist/bundle/chunk-SKGAKI62.js +86 -0
- package/dist/bundle/chunk-SQMZP5MA.js +66653 -0
- package/dist/bundle/chunk-UB6NTICY.js +95 -0
- package/dist/bundle/chunk-UBHQO5HV.js +778 -0
- package/dist/bundle/chunk-UM4RKO24.js +106 -0
- package/dist/bundle/chunk-VAHFY732.js +1068 -0
- package/dist/bundle/chunk-VGDM4C3F.js +188 -0
- package/dist/bundle/chunk-VOUAKCPM.js +41181 -0
- package/dist/bundle/chunk-WCCFJ4Q6.js +3736 -0
- package/dist/bundle/chunk-WV6EXRDV.js +46 -0
- package/dist/bundle/chunk-WVAT5TGY.js +334 -0
- package/dist/bundle/chunk-WW76JMKE.js +1243 -0
- package/dist/bundle/chunk-XXOMUKC6.js +54 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-YDO6RJ2P.js +1337 -0
- package/dist/bundle/chunk-ZBCFZCJW.js +388 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/command-contract-BWGRUY6L.js +37 -0
- package/dist/bundle/command-server-entry-BATOWE3Y.js +166 -0
- package/dist/bundle/decode-MZQGYXJH.js +297 -0
- package/dist/bundle/definitions-3EONB23J.js +8600 -0
- package/dist/bundle/dispatch-NYC4ARWX.js +411 -0
- package/dist/bundle/dist-AMLBQVKM.js +7577 -0
- package/dist/bundle/dist-PAKDDIBT.js +191 -0
- package/dist/bundle/echarts-7OYGL2GW.js +42501 -0
- package/dist/bundle/embed-4I25DVKZ.js +38 -0
- package/dist/bundle/embedder-YXKQHAZO.js +111 -0
- package/dist/bundle/emoji-4LYX3GOS.js +4271 -0
- package/dist/bundle/failure-3YOVYZTX.js +25 -0
- package/dist/bundle/first-run-2VL2BOV7.js +29 -0
- package/dist/bundle/first-screen-C7FIWZL2.js +37 -0
- package/dist/bundle/instructions-UMNDHXG2.js +11 -0
- package/dist/bundle/mcp-V27RHILF.js +167 -0
- package/dist/bundle/meeting-combined-LS6XO4JH.js +24 -0
- package/dist/bundle/meeting-model-VIR465CY.js +25 -0
- package/dist/bundle/meeting-semantic-H5J3OOF2.js +22 -0
- package/dist/bundle/node-JJ3WDCNJ.js +2340 -0
- package/dist/bundle/node-PYFPGL4E.js +176 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-sqlite-LFWPGDVP.js +74 -0
- package/dist/bundle/oauth-42VCSIVL.js +20 -0
- package/dist/bundle/open-XJ5R5LHC.js +23 -0
- package/dist/bundle/openai-RZBLV4HG.js +238 -0
- package/dist/bundle/process-DD6H3K7L.js +91 -0
- package/dist/bundle/program-OIYIBNSA.js +35443 -0
- package/dist/bundle/prompt-NQRDM5LY.js +17 -0
- package/dist/bundle/recognize-EM7H2IZS.js +26 -0
- package/dist/bundle/remote-Z6NU6QQA.js +31 -0
- package/dist/bundle/rerank-PNPCSPNF.js +52 -0
- package/dist/bundle/schemas-JMKNP4U3.js +2765 -0
- package/dist/bundle/serve-SQVGX76J.js +199 -0
- package/dist/bundle/server-NPJH45FZ.js +212 -0
- package/dist/bundle/server-Z4ZMGRAH.js +79 -0
- package/dist/bundle/slack.js +184 -0
- package/dist/bundle/sqlite-runtime-F3AJGAPN.js +20 -0
- package/dist/bundle/state-JT7ZFSXN.js +36 -0
- package/dist/bundle/store-FXGMHRF3.js +181 -0
- package/dist/bundle/store-J5ZL2USR.js +295 -0
- package/dist/bundle/store-maintenance-command-TIHOIKLZ.js +66 -0
- package/dist/bundle/surface-NW6T5OR6.js +65 -0
- package/dist/commands/api.d.ts +7 -0
- package/dist/commands/api.d.ts.map +1 -0
- package/dist/commands/api.js +49 -0
- package/dist/commands/api.js.map +1 -0
- package/dist/commands/session.d.ts +7 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +26 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/config.d.ts +24 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +75 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +59 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +75 -0
- package/dist/context.js.map +1 -0
- package/dist/generated/definitions.d.ts +3 -0
- package/dist/generated/definitions.d.ts.map +1 -0
- package/dist/generated/definitions.js +8596 -0
- package/dist/generated/definitions.js.map +1 -0
- package/dist/generated/emoji.d.ts +2 -0
- package/dist/generated/emoji.d.ts.map +1 -0
- package/dist/generated/emoji.js +4265 -0
- package/dist/generated/emoji.js.map +1 -0
- package/dist/generated/manifest.d.ts +6 -0
- package/dist/generated/manifest.d.ts.map +1 -0
- package/dist/generated/manifest.js +6139 -0
- package/dist/generated/manifest.js.map +1 -0
- package/dist/generated/schemas.d.ts +631 -0
- package/dist/generated/schemas.d.ts.map +1 -0
- package/dist/generated/schemas.js +2426 -0
- package/dist/generated/schemas.js.map +1 -0
- package/dist/generated/types.d.ts +3220 -0
- package/dist/generated/types.d.ts.map +1 -0
- package/dist/generated/types.js +5 -0
- package/dist/generated/types.js.map +1 -0
- package/dist/identity.d.ts +29 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +32 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/messenger.d.ts +12 -0
- package/dist/messenger.d.ts.map +1 -0
- package/dist/messenger.js +184 -0
- package/dist/messenger.js.map +1 -0
- package/dist/program.d.ts +6 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +116 -0
- package/dist/program.js.map +1 -0
- package/dist/reasons.d.ts +7 -0
- package/dist/reasons.d.ts.map +1 -0
- package/dist/reasons.js +20 -0
- package/dist/reasons.js.map +1 -0
- package/dist/setup/flow.d.ts +2 -0
- package/dist/setup/flow.d.ts.map +1 -0
- package/dist/setup/flow.js +83 -0
- package/dist/setup/flow.js.map +1 -0
- package/dist/setup/guide.d.ts +6 -0
- package/dist/setup/guide.d.ts.map +1 -0
- package/dist/setup/guide.js +13 -0
- package/dist/setup/guide.js.map +1 -0
- package/dist/setup/texts.d.ts +24 -0
- package/dist/setup/texts.d.ts.map +1 -0
- package/dist/setup/texts.js +24 -0
- package/dist/setup/texts.js.map +1 -0
- package/dist/slack/adapter.d.ts +36 -0
- package/dist/slack/adapter.d.ts.map +1 -0
- package/dist/slack/adapter.js +574 -0
- package/dist/slack/adapter.js.map +1 -0
- package/dist/slack/app-manifest.d.ts +25 -0
- package/dist/slack/app-manifest.d.ts.map +1 -0
- package/dist/slack/app-manifest.js +51 -0
- package/dist/slack/app-manifest.js.map +1 -0
- package/dist/slack/client.d.ts +45 -0
- package/dist/slack/client.d.ts.map +1 -0
- package/dist/slack/client.js +236 -0
- package/dist/slack/client.js.map +1 -0
- package/dist/slack/map.d.ts +437 -0
- package/dist/slack/map.d.ts.map +1 -0
- package/dist/slack/map.js +411 -0
- package/dist/slack/map.js.map +1 -0
- package/dist/slack/mrkdwn.d.ts +9 -0
- package/dist/slack/mrkdwn.d.ts.map +1 -0
- package/dist/slack/mrkdwn.js +56 -0
- package/dist/slack/mrkdwn.js.map +1 -0
- package/dist/slack/search.d.ts +24 -0
- package/dist/slack/search.d.ts.map +1 -0
- package/dist/slack/search.js +99 -0
- package/dist/slack/search.js.map +1 -0
- package/dist/slack/threads.d.ts +28 -0
- package/dist/slack/threads.d.ts.map +1 -0
- package/dist/slack/threads.js +56 -0
- package/dist/slack/threads.js.map +1 -0
- package/dist/slack/tokens.d.ts +17 -0
- package/dist/slack/tokens.d.ts.map +1 -0
- package/dist/slack/tokens.js +27 -0
- package/dist/slack/tokens.js.map +1 -0
- package/dist/slack/writes.d.ts +43 -0
- package/dist/slack/writes.d.ts.map +1 -0
- package/dist/slack/writes.js +277 -0
- package/dist/slack/writes.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/dist/wcat.d.ts +3 -0
- package/dist/wcat.d.ts.map +1 -0
- package/dist/wcat.js +4 -0
- package/dist/wcat.js.map +1 -0
- package/package.json +89 -4
- package/skills/slack-cli/SKILL.md +117 -0
- package/skills/slack-cli/references/api/api-admin.md +541 -0
- package/skills/slack-cli/references/api/api-api.md +13 -0
- package/skills/slack-cli/references/api/api-apps.md +78 -0
- package/skills/slack-cli/references/api/api-auth.md +18 -0
- package/skills/slack-cli/references/api/api-bots.md +12 -0
- package/skills/slack-cli/references/api/api-calls.md +68 -0
- package/skills/slack-cli/references/api/api-chat.md +123 -0
- package/skills/slack-cli/references/api/api-conversations.md +230 -0
- package/skills/slack-cli/references/api/api-dialog.md +13 -0
- package/skills/slack-cli/references/api/api-dnd.md +31 -0
- package/skills/slack-cli/references/api/api-emoji.md +8 -0
- package/skills/slack-cli/references/api/api-files.md +120 -0
- package/skills/slack-cli/references/api/api-migration.md +14 -0
- package/skills/slack-cli/references/api/api-pins.md +37 -0
- package/skills/slack-cli/references/api/api-reactions.md +58 -0
- package/skills/slack-cli/references/api/api-reminders.md +51 -0
- package/skills/slack-cli/references/api/api-search.md +18 -0
- package/skills/slack-cli/references/api/api-stars.md +42 -0
- package/skills/slack-cli/references/api/api-team.md +55 -0
- package/skills/slack-cli/references/api/api-usergroups.md +80 -0
- package/skills/slack-cli/references/api/api-users.md +101 -0
- package/skills/slack-cli/references/api/api-views.md +46 -0
- package/skills/slack-cli/references/api/api-workflows.md +36 -0
- package/skills/slack-cli/references/api.md +35 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
WARM_IDLE_MS,
|
|
5
|
+
defaultThreads,
|
|
6
|
+
isTextModelInstalled,
|
|
7
|
+
loadModel,
|
|
8
|
+
meanOf,
|
|
9
|
+
openEmbedder,
|
|
10
|
+
placedText,
|
|
11
|
+
runEmbedders,
|
|
12
|
+
textModelsDirectory,
|
|
13
|
+
truncated,
|
|
14
|
+
unit,
|
|
15
|
+
warmEmbedders
|
|
16
|
+
} from "./chunk-4QPMHVM5.js";
|
|
17
|
+
import "./chunk-LQDNUAK3.js";
|
|
18
|
+
import "./chunk-XXOMUKC6.js";
|
|
19
|
+
import "./chunk-H2COZZ55.js";
|
|
20
|
+
import "./chunk-CMZBCWND.js";
|
|
21
|
+
import "./chunk-S4UUN6LD.js";
|
|
22
|
+
import "./chunk-Y5E2WNWB.js";
|
|
23
|
+
import "./chunk-QLLBACDR.js";
|
|
24
|
+
import "./chunk-ZVVMGPBJ.js";
|
|
25
|
+
export {
|
|
26
|
+
WARM_IDLE_MS,
|
|
27
|
+
defaultThreads,
|
|
28
|
+
isTextModelInstalled,
|
|
29
|
+
loadModel,
|
|
30
|
+
meanOf,
|
|
31
|
+
openEmbedder,
|
|
32
|
+
placedText,
|
|
33
|
+
runEmbedders,
|
|
34
|
+
textModelsDirectory,
|
|
35
|
+
truncated,
|
|
36
|
+
unit,
|
|
37
|
+
warmEmbedders
|
|
38
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
openSession,
|
|
5
|
+
truncated,
|
|
6
|
+
unit
|
|
7
|
+
} from "./chunk-4QPMHVM5.js";
|
|
8
|
+
import "./chunk-LQDNUAK3.js";
|
|
9
|
+
import "./chunk-XXOMUKC6.js";
|
|
10
|
+
import "./chunk-H2COZZ55.js";
|
|
11
|
+
import "./chunk-CMZBCWND.js";
|
|
12
|
+
import "./chunk-S4UUN6LD.js";
|
|
13
|
+
import {
|
|
14
|
+
importFrom
|
|
15
|
+
} from "./chunk-Y5E2WNWB.js";
|
|
16
|
+
import {
|
|
17
|
+
CliError
|
|
18
|
+
} from "./chunk-QLLBACDR.js";
|
|
19
|
+
import {
|
|
20
|
+
__name
|
|
21
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
22
|
+
|
|
23
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.738.0_@wirecat+cli-base@0.132.0_@scalar+openapi-upgrader@0.4.6_comm_2f4ef0250212140e76029d09a7f79b43/node_modules/@wirecat/cli-core/dist/images/picture/embedder.js
|
|
24
|
+
import { readFileSync } from "node:fs";
|
|
25
|
+
import { join } from "node:path";
|
|
26
|
+
|
|
27
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.738.0_@wirecat+cli-base@0.132.0_@scalar+openapi-upgrader@0.4.6_comm_2f4ef0250212140e76029d09a7f79b43/node_modules/@wirecat/cli-core/dist/images/picture/preprocess.js
|
|
28
|
+
var SIZE = 224;
|
|
29
|
+
var MEAN = [0.48145466, 0.4578275, 0.40821073];
|
|
30
|
+
var STD = [0.26862954, 0.26130258, 0.27577711];
|
|
31
|
+
var importCanvas = /* @__PURE__ */ __name(async () => {
|
|
32
|
+
try {
|
|
33
|
+
return await importFrom(new URL("images/picture/preprocess.js", import.meta.resolve("@wirecat/cli-core")).href, "@napi-rs/canvas");
|
|
34
|
+
} catch {
|
|
35
|
+
throw new CliError("validation_error", "searching pictures needs the optional package @napi-rs/canvas to read an image \u2014 install it next to this tool");
|
|
36
|
+
}
|
|
37
|
+
}, "importCanvas");
|
|
38
|
+
var preprocess = /* @__PURE__ */ __name(async (bytes, load = importCanvas) => {
|
|
39
|
+
const { createCanvas, loadImage } = await load();
|
|
40
|
+
let image;
|
|
41
|
+
try {
|
|
42
|
+
image = await loadImage(bytes);
|
|
43
|
+
} catch {
|
|
44
|
+
throw new CliError("invalid_response", "the file is not an image this tool can read");
|
|
45
|
+
}
|
|
46
|
+
const scale = SIZE / Math.min(image.width, image.height);
|
|
47
|
+
const width = Math.max(SIZE, Math.round(image.width * scale));
|
|
48
|
+
const height = Math.max(SIZE, Math.round(image.height * scale));
|
|
49
|
+
const surface = createCanvas(SIZE, SIZE);
|
|
50
|
+
const context = surface.getContext("2d");
|
|
51
|
+
context.fillStyle = "#ffffff";
|
|
52
|
+
context.fillRect(0, 0, SIZE, SIZE);
|
|
53
|
+
context.imageSmoothingQuality = "high";
|
|
54
|
+
context.drawImage(image, 0, 0, image.width, image.height, Math.round((SIZE - width) / 2), Math.round((SIZE - height) / 2), width, height);
|
|
55
|
+
const { data } = context.getImageData(0, 0, SIZE, SIZE);
|
|
56
|
+
const plane = SIZE * SIZE;
|
|
57
|
+
const pixels = new Float32Array(3 * plane);
|
|
58
|
+
for (let at = 0; at < plane; at++) {
|
|
59
|
+
for (let channel = 0; channel < 3; channel++) {
|
|
60
|
+
pixels[channel * plane + at] = (data[at * 4 + channel] / 255 - MEAN[channel]) / STD[channel];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return pixels;
|
|
64
|
+
}, "preprocess");
|
|
65
|
+
|
|
66
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.738.0_@wirecat+cli-base@0.132.0_@scalar+openapi-upgrader@0.4.6_comm_2f4ef0250212140e76029d09a7f79b43/node_modules/@wirecat/cli-core/dist/images/picture/embedder.js
|
|
67
|
+
var openPictureEmbedder = /* @__PURE__ */ __name(async (model, directory, { threads = 4, canvas } = {}) => {
|
|
68
|
+
const { Tokenizer } = await importFrom(new URL("images/picture/embedder.js", import.meta.resolve("@wirecat/cli-core")).href, "@huggingface/tokenizers");
|
|
69
|
+
const path = /* @__PURE__ */ __name((name) => join(directory, model.id, name), "path");
|
|
70
|
+
const tokenizer = new Tokenizer(JSON.parse(readFileSync(path("tokenizer.json"), "utf8")), JSON.parse(readFileSync(path("tokenizer_config.json"), "utf8")));
|
|
71
|
+
const sessions = [];
|
|
72
|
+
const lazy = /* @__PURE__ */ __name((name) => {
|
|
73
|
+
let opened;
|
|
74
|
+
return () => {
|
|
75
|
+
opened ??= openSession(readFileSync(path(name)), threads).then((created) => {
|
|
76
|
+
sessions.push(created.session);
|
|
77
|
+
return created;
|
|
78
|
+
});
|
|
79
|
+
return opened;
|
|
80
|
+
};
|
|
81
|
+
}, "lazy");
|
|
82
|
+
const vision = lazy(model.vision);
|
|
83
|
+
const text = lazy(model.text);
|
|
84
|
+
return {
|
|
85
|
+
model,
|
|
86
|
+
embedImage: /* @__PURE__ */ __name(async (bytes) => {
|
|
87
|
+
const pixels = await preprocess(bytes, canvas);
|
|
88
|
+
const { ort, session } = await vision();
|
|
89
|
+
const output = await session.run({ pixel_values: new ort.Tensor("float32", pixels, [1, 3, SIZE, SIZE]) });
|
|
90
|
+
return unit(Float32Array.from(output.image_embeds?.data));
|
|
91
|
+
}, "embedImage"),
|
|
92
|
+
embedQuery: /* @__PURE__ */ __name(async (query) => {
|
|
93
|
+
const ids = truncated(tokenizer.encode(query.toLowerCase()).ids, model.maxTokens);
|
|
94
|
+
const shape = [1, ids.length];
|
|
95
|
+
const { ort, session } = await text();
|
|
96
|
+
const feeds = {
|
|
97
|
+
input_ids: new ort.Tensor("int64", BigInt64Array.from(ids, BigInt), shape)
|
|
98
|
+
};
|
|
99
|
+
if (session.inputNames.includes("attention_mask"))
|
|
100
|
+
feeds.attention_mask = new ort.Tensor("int64", new BigInt64Array(ids.length).fill(1n), shape);
|
|
101
|
+
const output = await session.run(feeds);
|
|
102
|
+
return unit(Float32Array.from(output.text_embeds?.data));
|
|
103
|
+
}, "embedQuery"),
|
|
104
|
+
close: /* @__PURE__ */ __name(async () => {
|
|
105
|
+
await Promise.all(sessions.map((session) => session.release()));
|
|
106
|
+
}, "close")
|
|
107
|
+
};
|
|
108
|
+
}, "openPictureEmbedder");
|
|
109
|
+
export {
|
|
110
|
+
openPictureEmbedder
|
|
111
|
+
};
|