@wirecat/attio-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 +33 -0
- package/LICENSE +204 -0
- package/README.md +249 -2
- package/contracts/wirecat.json +2339 -0
- package/dist/bin/attio.d.ts +3 -0
- package/dist/bin/attio.d.ts.map +1 -0
- package/dist/bin/attio.js +40 -0
- package/dist/bin/attio.js.map +1 -0
- package/dist/bundle/agent-DYTWDBTT.js +37 -0
- package/dist/bundle/all-profiles-LZDKPHN2.js +320 -0
- package/dist/bundle/anthropic-BF72H77D.js +91 -0
- package/dist/bundle/app-server-H57FZJX5.js +249 -0
- package/dist/bundle/attio.js +183 -0
- package/dist/bundle/bun-WO77T4LG.js +169 -0
- package/dist/bundle/bun-sqlite-2BP7JDVO.js +76 -0
- package/dist/bundle/chunk-2E6JGBM5.js +1392 -0
- package/dist/bundle/chunk-34FJ26K2.js +54 -0
- package/dist/bundle/chunk-3I2FGNWO.js +23 -0
- package/dist/bundle/chunk-3NVOKVRY.js +42148 -0
- package/dist/bundle/chunk-3YFDZSM3.js +37 -0
- package/dist/bundle/chunk-4SMGM2Q6.js +274 -0
- package/dist/bundle/chunk-4STBJZR4.js +3571 -0
- package/dist/bundle/chunk-5K3FGXZH.js +46 -0
- package/dist/bundle/chunk-6ALPRBNV.js +100 -0
- package/dist/bundle/chunk-6NDJDDSQ.js +2000 -0
- package/dist/bundle/chunk-6SK3YB2B.js +218 -0
- package/dist/bundle/chunk-76RRELCU.js +65310 -0
- package/dist/bundle/chunk-7MXCUMHG.js +18 -0
- package/dist/bundle/chunk-7ZUOI3HY.js +73 -0
- package/dist/bundle/chunk-AMUONYQR.js +106 -0
- package/dist/bundle/chunk-ASCUOOLO.js +53 -0
- package/dist/bundle/chunk-BUGROVF3.js +72 -0
- package/dist/bundle/chunk-CHZ26CW5.js +9578 -0
- package/dist/bundle/chunk-CMO5ND3Y.js +794 -0
- package/dist/bundle/chunk-D72URWJE.js +532 -0
- package/dist/bundle/chunk-DF2IIO32.js +12645 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-DQ6P3R4B.js +170 -0
- package/dist/bundle/chunk-DSRXCLPO.js +7 -0
- package/dist/bundle/chunk-EEPE3SOW.js +338 -0
- package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
- package/dist/bundle/chunk-EQGXEKSV.js +1197 -0
- package/dist/bundle/chunk-EQXT7KO4.js +388 -0
- package/dist/bundle/chunk-ERW2WOJT.js +24 -0
- package/dist/bundle/chunk-ESH2QGCA.js +372 -0
- package/dist/bundle/chunk-G3JTLVVL.js +771 -0
- package/dist/bundle/chunk-G6FQMVKW.js +52 -0
- package/dist/bundle/chunk-GBZ6JUXU.js +108 -0
- package/dist/bundle/chunk-GLHFJPYS.js +156 -0
- package/dist/bundle/chunk-GW4G5KLS.js +2333 -0
- package/dist/bundle/chunk-H7QDPW3D.js +78 -0
- package/dist/bundle/chunk-HG7FT3H3.js +319 -0
- package/dist/bundle/chunk-I3WS6V5H.js +188 -0
- package/dist/bundle/chunk-IDU4ESRZ.js +95 -0
- package/dist/bundle/chunk-IXCIQ7FZ.js +161 -0
- package/dist/bundle/chunk-J5P5VSRG.js +1233 -0
- package/dist/bundle/chunk-JA26HG7T.js +353 -0
- package/dist/bundle/chunk-JSTBW7F4.js +259 -0
- package/dist/bundle/chunk-KHDXRFJZ.js +185 -0
- package/dist/bundle/chunk-L5WS6CYZ.js +288 -0
- package/dist/bundle/chunk-LWJ4ZGUM.js +407 -0
- package/dist/bundle/chunk-MC2RQ2OB.js +38 -0
- package/dist/bundle/chunk-MNQACPXG.js +1332 -0
- package/dist/bundle/chunk-MOSH2KPD.js +358 -0
- package/dist/bundle/chunk-MRREDVPY.js +733 -0
- package/dist/bundle/chunk-MT2ZUZRA.js +1028 -0
- package/dist/bundle/chunk-O4A33Y54.js +29 -0
- package/dist/bundle/chunk-OBXDRUO4.js +63 -0
- package/dist/bundle/chunk-OFR3YYT6.js +6848 -0
- package/dist/bundle/chunk-P4U6AGWD.js +41 -0
- package/dist/bundle/chunk-PL5P7UKW.js +25216 -0
- package/dist/bundle/chunk-PMP37KLR.js +142 -0
- package/dist/bundle/chunk-Q3JCUUOR.js +80 -0
- package/dist/bundle/chunk-Q7BSTQ3T.js +633 -0
- package/dist/bundle/chunk-QLHDUYGE.js +16 -0
- package/dist/bundle/chunk-RU5J7DWY.js +988 -0
- package/dist/bundle/chunk-S4UUN6LD.js +1410 -0
- package/dist/bundle/chunk-S7K2XFQB.js +95 -0
- package/dist/bundle/chunk-SQHDE3TC.js +230 -0
- package/dist/bundle/chunk-TF7ZGCOK.js +76 -0
- package/dist/bundle/chunk-V6BTAILB.js +4072 -0
- package/dist/bundle/chunk-VDMIJ3JW.js +50 -0
- package/dist/bundle/chunk-VW5F6FK3.js +206 -0
- package/dist/bundle/chunk-W6F2CQZ6.js +1068 -0
- package/dist/bundle/chunk-WARIIYSW.js +58 -0
- package/dist/bundle/chunk-WK7GLHHL.js +334 -0
- package/dist/bundle/chunk-X5S5KUSU.js +2788 -0
- package/dist/bundle/chunk-X6R74TWX.js +131 -0
- package/dist/bundle/chunk-XQUUANA2.js +24600 -0
- package/dist/bundle/chunk-XXLQNHKF.js +82 -0
- package/dist/bundle/chunk-XXOTX4M3.js +362 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-ZDBTYBFR.js +66 -0
- package/dist/bundle/chunk-ZGADZ4CH.js +557 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/command-contract-7M6EPH3D.js +37 -0
- package/dist/bundle/command-server-entry-MNVPYQZ3.js +166 -0
- package/dist/bundle/decode-MQNKNXLK.js +297 -0
- package/dist/bundle/definitions-FODOIPM2.js +43379 -0
- package/dist/bundle/dispatch-TAQ7635E.js +411 -0
- package/dist/bundle/dist-EM7KLEG4.js +7577 -0
- package/dist/bundle/dist-PAKDDIBT.js +191 -0
- package/dist/bundle/echarts-6ZSUNO4L.js +42501 -0
- package/dist/bundle/embed-PHCCJJ5Z.js +38 -0
- package/dist/bundle/embedder-WLZZQTKZ.js +111 -0
- package/dist/bundle/failure-MR2XVHFP.js +25 -0
- package/dist/bundle/first-run-64LREHSV.js +29 -0
- package/dist/bundle/first-screen-YSCAZIYJ.js +37 -0
- package/dist/bundle/instructions-22GCKNR5.js +11 -0
- package/dist/bundle/mcp-CNV7F2XZ.js +167 -0
- package/dist/bundle/meeting-combined-YX3T5WJD.js +24 -0
- package/dist/bundle/meeting-model-JWDTCGLZ.js +25 -0
- package/dist/bundle/meeting-semantic-375GYPZQ.js +22 -0
- package/dist/bundle/node-ITDTNRRZ.js +176 -0
- package/dist/bundle/node-KM3CUABH.js +2340 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-sqlite-IRAGRMEZ.js +74 -0
- package/dist/bundle/oauth-CACOQJEL.js +20 -0
- package/dist/bundle/open-HU4KHKDR.js +23 -0
- package/dist/bundle/openai-JQUPAVKX.js +238 -0
- package/dist/bundle/process-QS5OHEUK.js +91 -0
- package/dist/bundle/program-QLCUCR76.js +33428 -0
- package/dist/bundle/prompt-VA5MKXJU.js +17 -0
- package/dist/bundle/recognize-JGA5IVKC.js +26 -0
- package/dist/bundle/remote-NPY2KZQ4.js +31 -0
- package/dist/bundle/rerank-4H2QR4XU.js +52 -0
- package/dist/bundle/schemas-THAI3G5S.js +21410 -0
- package/dist/bundle/serve-UH46SZQG.js +199 -0
- package/dist/bundle/server-6H7JS6SU.js +212 -0
- package/dist/bundle/server-SR52KBL3.js +79 -0
- package/dist/bundle/sqlite-runtime-EJWEUTBR.js +20 -0
- package/dist/bundle/state-34B6AUQZ.js +36 -0
- package/dist/bundle/store-3R4ILTCJ.js +177 -0
- package/dist/bundle/store-XSE35P3U.js +291 -0
- package/dist/bundle/store-maintenance-command-ABJARLI4.js +66 -0
- package/dist/bundle/surface-NOTIEJB5.js +65 -0
- package/dist/commands/api.d.ts +12 -0
- package/dist/commands/api.d.ts.map +1 -0
- package/dist/commands/api.js +27 -0
- package/dist/commands/api.js.map +1 -0
- package/dist/commands/crm.d.ts +4 -0
- package/dist/commands/crm.d.ts.map +1 -0
- package/dist/commands/crm.js +66 -0
- package/dist/commands/crm.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 +22 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/config.d.ts +14 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +14 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +37 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +31 -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 +43375 -0
- package/dist/generated/definitions.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 +5158 -0
- package/dist/generated/manifest.js.map +1 -0
- package/dist/generated/schemas.d.ts +383 -0
- package/dist/generated/schemas.d.ts.map +1 -0
- package/dist/generated/schemas.js +21196 -0
- package/dist/generated/schemas.js.map +1 -0
- package/dist/generated/types.d.ts +10166 -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/generated/wirecat-config.d.ts +15 -0
- package/dist/generated/wirecat-config.d.ts.map +1 -0
- package/dist/generated/wirecat-config.js +333 -0
- package/dist/generated/wirecat-config.js.map +1 -0
- package/dist/hooks.d.ts +3 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +7 -0
- package/dist/hooks.js.map +1 -0
- package/dist/identity.d.ts +33 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +31 -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/program.d.ts +6 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +54 -0
- package/dist/program.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 +87 -4
- package/skills/attio-cli/SKILL.md +58 -0
- package/skills/attio-cli/references/api/api-activities.md +62 -0
- package/skills/attio-cli/references/api/api-activity-records.md +96 -0
- package/skills/attio-cli/references/api/api-attributes.md +148 -0
- package/skills/attio-cli/references/api/api-call-recordings.md +53 -0
- package/skills/attio-cli/references/api/api-comments.md +36 -0
- package/skills/attio-cli/references/api/api-emails.md +23 -0
- package/skills/attio-cli/references/api/api-entries.md +127 -0
- package/skills/attio-cli/references/api/api-files.md +63 -0
- package/skills/attio-cli/references/api/api-lists.md +44 -0
- package/skills/attio-cli/references/api/api-meetings.md +82 -0
- package/skills/attio-cli/references/api/api-meta.md +8 -0
- package/skills/attio-cli/references/api/api-notes.md +64 -0
- package/skills/attio-cli/references/api/api-objects.md +55 -0
- package/skills/attio-cli/references/api/api-records.md +168 -0
- package/skills/attio-cli/references/api/api-sequences.md +15 -0
- package/skills/attio-cli/references/api/api-sql.md +15 -0
- package/skills/attio-cli/references/api/api-tasks.md +67 -0
- package/skills/attio-cli/references/api/api-threads.md +35 -0
- package/skills/attio-cli/references/api/api-transcripts.md +17 -0
- package/skills/attio-cli/references/api/api-views.md +133 -0
- package/skills/attio-cli/references/api/api-webhooks.md +62 -0
- package/skills/attio-cli/references/api/api-workspace-blocklist.md +39 -0
- package/skills/attio-cli/references/api/api-workspace-members.md +19 -0
- package/skills/attio-cli/references/api.md +35 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
AUDIT_MIN_SCORE
|
|
5
|
+
} from "./chunk-3NVOKVRY.js";
|
|
6
|
+
import {
|
|
7
|
+
LIST_QUERY_GUIDE,
|
|
8
|
+
nativeTerms
|
|
9
|
+
} from "./chunk-MRREDVPY.js";
|
|
10
|
+
import {
|
|
11
|
+
DEFAULT_CONFIG,
|
|
12
|
+
environmentOf,
|
|
13
|
+
itemOf,
|
|
14
|
+
listOf,
|
|
15
|
+
nextStep,
|
|
16
|
+
renderAnswer,
|
|
17
|
+
snakeKeys,
|
|
18
|
+
withAgentLevels
|
|
19
|
+
} from "./chunk-DF2IIO32.js";
|
|
20
|
+
import {
|
|
21
|
+
formatReference
|
|
22
|
+
} from "./chunk-6NDJDDSQ.js";
|
|
23
|
+
import {
|
|
24
|
+
queryError
|
|
25
|
+
} from "./chunk-V6BTAILB.js";
|
|
26
|
+
import {
|
|
27
|
+
CliError
|
|
28
|
+
} from "./chunk-BUGROVF3.js";
|
|
29
|
+
import {
|
|
30
|
+
__name
|
|
31
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
32
|
+
|
|
33
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.703.0_@wirecat+cli-base@0.119.0_commander@15.0.0_esbuild@0.28.2_typ_5630bd43f49d4f78ecc9c491970e88a0/node_modules/@wirecat/cli-core/dist/cli/paging.js
|
|
34
|
+
var positiveCount = /* @__PURE__ */ __name((flag) => (value) => {
|
|
35
|
+
if (!/^\d+$/.test(value.trim()) || Number(value) < 1)
|
|
36
|
+
throw new CliError("validation_error", `${flag} takes a whole number from 1 upwards, not "${value}"`);
|
|
37
|
+
return Number(value);
|
|
38
|
+
}, "positiveCount");
|
|
39
|
+
var configuredLimit = /* @__PURE__ */ __name((command, most = Number.POSITIVE_INFINITY) => {
|
|
40
|
+
const { resolveSettings, env } = environmentOf(command);
|
|
41
|
+
const { limit: _typed, ...flags } = command.optsWithGlobals();
|
|
42
|
+
const configured = resolveSettings?.(flags, { needsProfile: false, ...env ? { env } : {} }).limit ?? DEFAULT_CONFIG.defaults.limit;
|
|
43
|
+
return Math.min(configured, most);
|
|
44
|
+
}, "configuredLimit");
|
|
45
|
+
var withPaging = /* @__PURE__ */ __name((command) => command.option("--limit <n>", "how many to show", positiveCount("--limit")).option("--page <n>", "which page, starting at 1", positiveCount("--page")).option("--all", "every row, no paging"), "withPaging");
|
|
46
|
+
var window = /* @__PURE__ */ __name(({ limit, page, all }) => all ? { offset: 0 } : { limit, offset: (page - 1) * limit }, "window");
|
|
47
|
+
var pagingOf = /* @__PURE__ */ __name((command) => {
|
|
48
|
+
const environment = environmentOf(command);
|
|
49
|
+
const flags = command.optsWithGlobals();
|
|
50
|
+
if (!environment.resolveSettings)
|
|
51
|
+
return { limit: flags.limit ?? DEFAULT_CONFIG.defaults.limit, page: flags.page ?? 1 };
|
|
52
|
+
const { limit, page } = environment.resolveSettings(withAgentLevels(command, command.optsWithGlobals()), {
|
|
53
|
+
env: environment.env ?? process.env,
|
|
54
|
+
needsProfile: false,
|
|
55
|
+
readOnly: true
|
|
56
|
+
});
|
|
57
|
+
return { limit: limit ?? DEFAULT_CONFIG.defaults.limit, page: page ?? 1 };
|
|
58
|
+
}, "pagingOf");
|
|
59
|
+
|
|
60
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.703.0_@wirecat+cli-base@0.119.0_commander@15.0.0_esbuild@0.28.2_typ_5630bd43f49d4f78ecc9c491970e88a0/node_modules/@wirecat/cli-core/dist/cli/messenger/chat-answers.js
|
|
61
|
+
var defined = /* @__PURE__ */ __name((record) => Object.fromEntries(Object.entries(record).filter(([, value]) => value !== void 0)), "defined");
|
|
62
|
+
var chatRef = /* @__PURE__ */ __name((account, chat) => formatReference({ type: "chat", provider: account.provider, account: account.account, chat }), "chatRef");
|
|
63
|
+
var settingsOf = /* @__PURE__ */ __name((settings) => defined({
|
|
64
|
+
all_can_pin: settings.allCanPin,
|
|
65
|
+
only_admins_add: settings.onlyAdminsAdd,
|
|
66
|
+
only_admins_call: settings.onlyAdminsCall,
|
|
67
|
+
only_owner_edits_info: settings.onlyOwnerEditsInfo,
|
|
68
|
+
members_see_link: settings.membersSeeLink,
|
|
69
|
+
join_approval: settings.joinApproval,
|
|
70
|
+
only_admins_send: settings.onlyAdminsSend,
|
|
71
|
+
only_admins_edit_info: settings.onlyAdminsEditInfo,
|
|
72
|
+
disappearing_seconds: settings.disappearingSeconds
|
|
73
|
+
}), "settingsOf");
|
|
74
|
+
var chatAnswer = /* @__PURE__ */ __name((account, chat) => defined({
|
|
75
|
+
ref: chatRef(account, chat.id),
|
|
76
|
+
id: chat.id,
|
|
77
|
+
title: chat.title,
|
|
78
|
+
kind: chat.kind,
|
|
79
|
+
unread_count: chat.unreadCount,
|
|
80
|
+
unread_mentions: chat.unreadMentions,
|
|
81
|
+
last_message_at: chat.lastMessageAt,
|
|
82
|
+
participants_count: chat.participantsCount,
|
|
83
|
+
muted: chat.muted,
|
|
84
|
+
muted_until: chat.mutedUntil ?? void 0,
|
|
85
|
+
archived: chat.archived,
|
|
86
|
+
marked_unread: chat.markedUnread,
|
|
87
|
+
membership_state: chat.membershipState,
|
|
88
|
+
parent_chat_id: chat.parentChatId ?? void 0,
|
|
89
|
+
scope: chat.scope,
|
|
90
|
+
provider_metadata: chat.providerMetadata,
|
|
91
|
+
description: chat.description,
|
|
92
|
+
invite_link: chat.link,
|
|
93
|
+
settings: chat.settings ? settingsOf(chat.settings) : void 0,
|
|
94
|
+
members: chat.members?.map(memberAnswer)
|
|
95
|
+
}), "chatAnswer");
|
|
96
|
+
var memberAnswer = /* @__PURE__ */ __name((member) => {
|
|
97
|
+
const group = member;
|
|
98
|
+
return defined({
|
|
99
|
+
id: member.id,
|
|
100
|
+
name: member.name,
|
|
101
|
+
username: member.username,
|
|
102
|
+
role: group.role,
|
|
103
|
+
last_seen_at: group.lastSeenAt,
|
|
104
|
+
registered_at: group.registeredAt,
|
|
105
|
+
joined_at: group.joinedAt,
|
|
106
|
+
invited_by: group.invitedBy,
|
|
107
|
+
is_bot: group.isBot,
|
|
108
|
+
deleted: group.deleted,
|
|
109
|
+
flagged: group.flagged,
|
|
110
|
+
has_photo: group.hasPhoto,
|
|
111
|
+
score: group.score,
|
|
112
|
+
reasons: group.reasons,
|
|
113
|
+
check: group.check ? snakeKeys(group.check) : void 0
|
|
114
|
+
});
|
|
115
|
+
}, "memberAnswer");
|
|
116
|
+
var contactRef = /* @__PURE__ */ __name((provider, id) => formatReference({ type: "contact", provider, id }), "contactRef");
|
|
117
|
+
var contactAnswer = /* @__PURE__ */ __name((account, contact) => {
|
|
118
|
+
const card = contact;
|
|
119
|
+
return defined({
|
|
120
|
+
ref: contactRef(account.provider, contact.id),
|
|
121
|
+
id: contact.id,
|
|
122
|
+
name: contact.name,
|
|
123
|
+
username: contact.username,
|
|
124
|
+
alias: contact.alias,
|
|
125
|
+
display_name: contact.displayName,
|
|
126
|
+
description: contact.description,
|
|
127
|
+
last_messaged_at: contact.lastMessagedAt,
|
|
128
|
+
chats: card.chats?.map((chat) => ({
|
|
129
|
+
ref: chatRef(account, chat.id),
|
|
130
|
+
id: chat.id,
|
|
131
|
+
title: chat.title,
|
|
132
|
+
kind: chat.kind,
|
|
133
|
+
last_message_at: chat.lastMessageAt
|
|
134
|
+
})),
|
|
135
|
+
notes: card.notes?.map(({ id, text, revision, createdAt, updatedAt }) => ({
|
|
136
|
+
id,
|
|
137
|
+
text,
|
|
138
|
+
revision,
|
|
139
|
+
created_at: createdAt,
|
|
140
|
+
updated_at: updatedAt
|
|
141
|
+
}))
|
|
142
|
+
});
|
|
143
|
+
}, "contactAnswer");
|
|
144
|
+
var contactShown = /* @__PURE__ */ __name((account, card, profile) => {
|
|
145
|
+
const { id: _id, name: _name, bio, chats, ...facts } = profile;
|
|
146
|
+
const listed = new Map(card.chats.map((chat) => [chat.id, chat]));
|
|
147
|
+
const active = new Set(chats.map(({ id }) => id));
|
|
148
|
+
const shared = [
|
|
149
|
+
...chats.map((chat) => ({
|
|
150
|
+
ref: chatRef(account, chat.id),
|
|
151
|
+
id: chat.id,
|
|
152
|
+
title: chat.title,
|
|
153
|
+
kind: chat.kind,
|
|
154
|
+
last_message_at: listed.get(chat.id)?.lastMessageAt ?? chat.lastAt,
|
|
155
|
+
their_messages: chat.theirMessages,
|
|
156
|
+
first_at: chat.firstAt,
|
|
157
|
+
last_at: chat.lastAt,
|
|
158
|
+
complete: chat.complete
|
|
159
|
+
})),
|
|
160
|
+
...card.chats.filter(({ id }) => !active.has(id)).map((chat) => ({
|
|
161
|
+
ref: chatRef(account, chat.id),
|
|
162
|
+
id: chat.id,
|
|
163
|
+
title: chat.title,
|
|
164
|
+
kind: chat.kind,
|
|
165
|
+
last_message_at: chat.lastMessageAt
|
|
166
|
+
}))
|
|
167
|
+
];
|
|
168
|
+
const answer = contactAnswer(account, card);
|
|
169
|
+
return {
|
|
170
|
+
...answer,
|
|
171
|
+
...snakeKeys(facts),
|
|
172
|
+
description: answer.description ?? bio,
|
|
173
|
+
chats: shared
|
|
174
|
+
};
|
|
175
|
+
}, "contactShown");
|
|
176
|
+
var chatEventAnswer = /* @__PURE__ */ __name((chatId, event) => defined({
|
|
177
|
+
chat_id: chatId,
|
|
178
|
+
time: event.timestamp,
|
|
179
|
+
type: event.event,
|
|
180
|
+
message_id: event.messageId,
|
|
181
|
+
by: event.by,
|
|
182
|
+
people: event.people,
|
|
183
|
+
title: event.title
|
|
184
|
+
}), "chatEventAnswer");
|
|
185
|
+
var HISTORY_TYPES = { joined: "join", left: "leave", changed: "profile" };
|
|
186
|
+
var memberEventAnswer = /* @__PURE__ */ __name((chatId, event) => defined({
|
|
187
|
+
chat_id: chatId,
|
|
188
|
+
time: event.at,
|
|
189
|
+
type: HISTORY_TYPES[event.event],
|
|
190
|
+
by: event.invitedBy === void 0 ? void 0 : { id: event.invitedBy, name: null },
|
|
191
|
+
people: [{ id: event.id, name: event.name, username: event.username }],
|
|
192
|
+
before: event.before ? { name: event.before.name, username: event.before.username } : void 0
|
|
193
|
+
}), "memberEventAnswer");
|
|
194
|
+
var inviteLinkAnswer = /* @__PURE__ */ __name((link) => defined({
|
|
195
|
+
link: link.link,
|
|
196
|
+
approval: link.approval,
|
|
197
|
+
expires_at: link.expiresAt,
|
|
198
|
+
max_uses: link.maxUses,
|
|
199
|
+
primary: link.primary,
|
|
200
|
+
revoked: link.revoked,
|
|
201
|
+
pending_count: link.pending,
|
|
202
|
+
joined_count: link.joined
|
|
203
|
+
}), "inviteLinkAnswer");
|
|
204
|
+
var joinRequestAnswer = /* @__PURE__ */ __name((request) => defined({
|
|
205
|
+
person_id: request.person.id,
|
|
206
|
+
name: request.person.name,
|
|
207
|
+
username: request.person.username,
|
|
208
|
+
requested_at: request.requestedAt,
|
|
209
|
+
about: request.about
|
|
210
|
+
}), "joinRequestAnswer");
|
|
211
|
+
var pollVoteAnswer = /* @__PURE__ */ __name((vote) => ({
|
|
212
|
+
person_id: vote.person.id,
|
|
213
|
+
name: vote.person.name,
|
|
214
|
+
username: vote.person.username,
|
|
215
|
+
answers: vote.answers,
|
|
216
|
+
voted_at: vote.votedAt
|
|
217
|
+
}), "pollVoteAnswer");
|
|
218
|
+
var reactorAnswer = /* @__PURE__ */ __name((reactor) => ({
|
|
219
|
+
person: { id: reactor.person.id, name: reactor.person.name, username: reactor.person.username },
|
|
220
|
+
reaction: reactor.reaction,
|
|
221
|
+
reacted_at: reactor.reactedAt
|
|
222
|
+
}), "reactorAnswer");
|
|
223
|
+
var topicAnswer = /* @__PURE__ */ __name((topic) => defined({
|
|
224
|
+
id: topic.id,
|
|
225
|
+
title: topic.title,
|
|
226
|
+
closed: topic.closed,
|
|
227
|
+
pinned: topic.pinned,
|
|
228
|
+
hidden: topic.hidden,
|
|
229
|
+
unread_count: topic.unreadCount,
|
|
230
|
+
last_message_at: topic.lastMessageAt,
|
|
231
|
+
created_at: topic.createdAt,
|
|
232
|
+
untrusted: ["title"]
|
|
233
|
+
}), "topicAnswer");
|
|
234
|
+
var folderAnswer = /* @__PURE__ */ __name((folder) => {
|
|
235
|
+
const shown = "chats" in folder ? folder : void 0;
|
|
236
|
+
const listed = shown ? void 0 : folder;
|
|
237
|
+
return defined({
|
|
238
|
+
id: folder.id,
|
|
239
|
+
title: folder.title,
|
|
240
|
+
chat_ids: listed ? listed.chatIds : shown?.chats.map((chat) => chat.id) ?? [],
|
|
241
|
+
emoji: folder.emoji,
|
|
242
|
+
include: folder.include,
|
|
243
|
+
skip: folder.skip,
|
|
244
|
+
excluded_chat_ids: listed?.excludedChatIds ?? shown?.excluded.map((chat) => chat.id),
|
|
245
|
+
pinned_chat_ids: listed?.pinnedChatIds ?? shown?.pinned.map((chat) => chat.id),
|
|
246
|
+
chats: shown?.chats,
|
|
247
|
+
pinned_chats: shown?.pinned,
|
|
248
|
+
excluded_chats: shown?.excluded
|
|
249
|
+
});
|
|
250
|
+
}, "folderAnswer");
|
|
251
|
+
var lines = /* @__PURE__ */ __name((line) => (body) => (body.items ?? (body.item === void 0 ? [] : [body.item])).map((item) => `${line(item).trimEnd()}
|
|
252
|
+
`).join(""), "lines");
|
|
253
|
+
var pageOf = /* @__PURE__ */ __name(({ limit, page, all }, { items, hasMore }) => all ? { limit: Math.max(1, items.length), has_more: false, page: 1 } : { limit, has_more: hasMore, page }, "pageOf");
|
|
254
|
+
var wholeList = /* @__PURE__ */ __name((command, items, extra = {}) => listOf(command, { items, limit: Math.max(1, items.length), has_more: false, ...extra }), "wholeList");
|
|
255
|
+
var chatShown = /* @__PURE__ */ __name((account, card) => {
|
|
256
|
+
const listed = card.members?.length;
|
|
257
|
+
const short = listed !== void 0 && card.participantsCount !== null && listed < card.participantsCount;
|
|
258
|
+
return itemOf(chatAnswer(account, card), short ? {
|
|
259
|
+
missing: [
|
|
260
|
+
{
|
|
261
|
+
field: "members",
|
|
262
|
+
why: `${listed} listed; the chat reports ${card.participantsCount} \u2014 the list may omit your account or be partial`,
|
|
263
|
+
step: "chats.members"
|
|
264
|
+
}
|
|
265
|
+
],
|
|
266
|
+
next: [nextStep("chats.members", { args: { chat: card.id } })]
|
|
267
|
+
} : {});
|
|
268
|
+
}, "chatShown");
|
|
269
|
+
var scoreFloor = /* @__PURE__ */ __name((ast) => {
|
|
270
|
+
const term = nativeTerms(ast, "chats members check").get("score");
|
|
271
|
+
if (!term)
|
|
272
|
+
return AUDIT_MIN_SCORE;
|
|
273
|
+
const upper = term.operator === "range" ? term.upper ?? "*" : term.value;
|
|
274
|
+
if (term.operator !== "range" || upper !== "*")
|
|
275
|
+
queryError("query.unsupported-operator", term.span, "score takes a lower bound: score>=3", {
|
|
276
|
+
command: "chats members check",
|
|
277
|
+
guide: LIST_QUERY_GUIDE
|
|
278
|
+
});
|
|
279
|
+
const floor = Number(term.value);
|
|
280
|
+
return Math.ceil(term.lower_inclusive === false ? floor + 1 : floor);
|
|
281
|
+
}, "scoreFloor");
|
|
282
|
+
var auditAnswer = /* @__PURE__ */ __name((audit) => wholeList("chats members check", audit.items.map(memberAnswer), {
|
|
283
|
+
...audit.more ? { meta: { truncated: true } } : {},
|
|
284
|
+
...audit.completeness && audit.completeness.state !== "complete" ? {
|
|
285
|
+
missing: [
|
|
286
|
+
{
|
|
287
|
+
field: "reasons",
|
|
288
|
+
why: "never_wrote counts only stored messages, and the store does not hold the chat whole",
|
|
289
|
+
...audit.fetch ? { step: "messages.sync" } : {}
|
|
290
|
+
}
|
|
291
|
+
],
|
|
292
|
+
...audit.fetch ? { next: [nextStep("messages.sync", { args: { chat: audit.chatId } })] } : {}
|
|
293
|
+
} : {}
|
|
294
|
+
}), "auditAnswer");
|
|
295
|
+
var renderItem = /* @__PURE__ */ __name((command, output, value, next = []) => renderAnswer(command, output, itemOf(snakeKeys(value), { next })), "renderItem");
|
|
296
|
+
var withPage = /* @__PURE__ */ __name((command) => command.option("--limit <n>", "how many to show", positiveCount("--limit")).option("--page <n>", "which page, starting at 1", positiveCount("--page")), "withPage");
|
|
297
|
+
var documentLinkAnswer = /* @__PURE__ */ __name(({ url, documentId, title, inStore, locator, sentAt, sender }) => ({
|
|
298
|
+
url,
|
|
299
|
+
document_id: documentId,
|
|
300
|
+
title,
|
|
301
|
+
in_store: inStore,
|
|
302
|
+
ref: locator,
|
|
303
|
+
sent_at: sentAt,
|
|
304
|
+
sender
|
|
305
|
+
}), "documentLinkAnswer");
|
|
306
|
+
var accountAnswer = /* @__PURE__ */ __name((provider, { id, name, username, phone }) => ({
|
|
307
|
+
provider,
|
|
308
|
+
id,
|
|
309
|
+
name,
|
|
310
|
+
username,
|
|
311
|
+
...phone === void 0 ? {} : { phone }
|
|
312
|
+
}), "accountAnswer");
|
|
313
|
+
var sessionAnswer = /* @__PURE__ */ __name(({ current, client, device, location, lastActiveAt, createdAt }) => ({
|
|
314
|
+
current,
|
|
315
|
+
client,
|
|
316
|
+
device,
|
|
317
|
+
location,
|
|
318
|
+
last_active_at: lastActiveAt,
|
|
319
|
+
...createdAt === void 0 ? {} : { created_at: createdAt }
|
|
320
|
+
}), "sessionAnswer");
|
|
321
|
+
|
|
322
|
+
export {
|
|
323
|
+
positiveCount,
|
|
324
|
+
configuredLimit,
|
|
325
|
+
withPaging,
|
|
326
|
+
window,
|
|
327
|
+
pagingOf,
|
|
328
|
+
chatRef,
|
|
329
|
+
chatAnswer,
|
|
330
|
+
memberAnswer,
|
|
331
|
+
contactRef,
|
|
332
|
+
contactAnswer,
|
|
333
|
+
contactShown,
|
|
334
|
+
chatEventAnswer,
|
|
335
|
+
memberEventAnswer,
|
|
336
|
+
inviteLinkAnswer,
|
|
337
|
+
joinRequestAnswer,
|
|
338
|
+
pollVoteAnswer,
|
|
339
|
+
reactorAnswer,
|
|
340
|
+
topicAnswer,
|
|
341
|
+
folderAnswer,
|
|
342
|
+
lines,
|
|
343
|
+
pageOf,
|
|
344
|
+
wholeList,
|
|
345
|
+
chatShown,
|
|
346
|
+
scoreFloor,
|
|
347
|
+
auditAnswer,
|
|
348
|
+
renderItem,
|
|
349
|
+
withPage,
|
|
350
|
+
documentLinkAnswer,
|
|
351
|
+
accountAnswer,
|
|
352
|
+
sessionAnswer
|
|
353
|
+
};
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
textModel,
|
|
5
|
+
vectorModelKey
|
|
6
|
+
} from "./chunk-WK7GLHHL.js";
|
|
7
|
+
import {
|
|
8
|
+
OPENAI_URL,
|
|
9
|
+
openRemote,
|
|
10
|
+
remoteKey,
|
|
11
|
+
remoteModel
|
|
12
|
+
} from "./chunk-KHDXRFJZ.js";
|
|
13
|
+
import {
|
|
14
|
+
endpointFetch
|
|
15
|
+
} from "./chunk-ESH2QGCA.js";
|
|
16
|
+
import {
|
|
17
|
+
isTextModelInstalled,
|
|
18
|
+
openEmbedder,
|
|
19
|
+
textModelsDirectory
|
|
20
|
+
} from "./chunk-MT2ZUZRA.js";
|
|
21
|
+
import {
|
|
22
|
+
CliError
|
|
23
|
+
} from "./chunk-BUGROVF3.js";
|
|
24
|
+
import {
|
|
25
|
+
__name
|
|
26
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
27
|
+
|
|
28
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.703.0_@wirecat+cli-base@0.119.0_commander@15.0.0_esbuild@0.28.2_typ_5630bd43f49d4f78ecc9c491970e88a0/node_modules/@wirecat/cli-core/dist/services/meeting-model.js
|
|
29
|
+
var integer = /* @__PURE__ */ __name((value, name, max) => {
|
|
30
|
+
if (!Number.isSafeInteger(value) || value < 1 || value > max)
|
|
31
|
+
throw new CliError("validation_error", `Invalid ${name}`);
|
|
32
|
+
return value;
|
|
33
|
+
}, "integer");
|
|
34
|
+
var cancelled = /* @__PURE__ */ __name((signal) => {
|
|
35
|
+
if (signal?.aborted)
|
|
36
|
+
throw new CliError("cancelled", "Meeting embedding was cancelled");
|
|
37
|
+
}, "cancelled");
|
|
38
|
+
var validatedRemote = /* @__PURE__ */ __name((remote) => {
|
|
39
|
+
let url;
|
|
40
|
+
try {
|
|
41
|
+
url = new URL(remote.baseUrl);
|
|
42
|
+
} catch {
|
|
43
|
+
throw new CliError("validation_error", "Invalid embedding endpoint");
|
|
44
|
+
}
|
|
45
|
+
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password || url.search || url.hash)
|
|
46
|
+
throw new CliError("validation_error", "Embedding endpoint requires HTTP/S without credentials, query or fragment");
|
|
47
|
+
if (typeof remote.model !== "string" || !/^[\w./:-]{1,200}$/.test(remote.model))
|
|
48
|
+
throw new CliError("validation_error", "Invalid embedding model name");
|
|
49
|
+
const dims = integer(remote.dims, "embedding dimensions", 8192);
|
|
50
|
+
const baseUrl = remote.baseUrl.replace(/\/+$/, "");
|
|
51
|
+
const result = remoteModel({ model: remote.model, dims, ...baseUrl === OPENAI_URL ? {} : { baseUrl } });
|
|
52
|
+
return result;
|
|
53
|
+
}, "validatedRemote");
|
|
54
|
+
var meetingEmbeddingModel = /* @__PURE__ */ __name((choice, env) => {
|
|
55
|
+
if (typeof choice === "string") {
|
|
56
|
+
const model = textModel(choice, env);
|
|
57
|
+
return { key: vectorModelKey(model), dims: model.dims, kind: "local", model: model.id };
|
|
58
|
+
}
|
|
59
|
+
if (!choice || typeof choice !== "object" || !choice.remote)
|
|
60
|
+
throw new CliError("validation_error", "An explicit embedding model is required");
|
|
61
|
+
const remote = validatedRemote(choice.remote);
|
|
62
|
+
if (choice.concurrency !== void 0 && choice.concurrency !== 1)
|
|
63
|
+
throw new CliError("validation_error", "Meeting embedding supports one remote request worker");
|
|
64
|
+
return { key: remoteKey(remote), dims: remote.dims, kind: "remote", model: remote.model };
|
|
65
|
+
}, "meetingEmbeddingModel");
|
|
66
|
+
var createMeetingRemoteModel = /* @__PURE__ */ __name((input) => {
|
|
67
|
+
try {
|
|
68
|
+
return validatedRemote(remoteModel(input));
|
|
69
|
+
} catch (error) {
|
|
70
|
+
if (error instanceof CliError)
|
|
71
|
+
throw error;
|
|
72
|
+
throw new CliError("validation_error", "Invalid embedding endpoint");
|
|
73
|
+
}
|
|
74
|
+
}, "createMeetingRemoteModel");
|
|
75
|
+
var withAbort = /* @__PURE__ */ __name(async (pending, signal) => {
|
|
76
|
+
cancelled(signal);
|
|
77
|
+
if (!signal)
|
|
78
|
+
return pending;
|
|
79
|
+
let onAbort = /* @__PURE__ */ __name(() => {
|
|
80
|
+
}, "onAbort");
|
|
81
|
+
const interrupted = new Promise((_, reject) => {
|
|
82
|
+
onAbort = /* @__PURE__ */ __name(() => reject(new CliError("cancelled", "Meeting embedding was cancelled")), "onAbort");
|
|
83
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
84
|
+
});
|
|
85
|
+
try {
|
|
86
|
+
return await Promise.race([pending, interrupted]);
|
|
87
|
+
} finally {
|
|
88
|
+
signal.removeEventListener("abort", onAbort);
|
|
89
|
+
}
|
|
90
|
+
}, "withAbort");
|
|
91
|
+
var boundedResponse = /* @__PURE__ */ __name(async (response, maxBytes, signal) => {
|
|
92
|
+
const length = response.headers.get("content-length");
|
|
93
|
+
if (length !== null && (!/^\d+$/.test(length) || Number(length) > maxBytes)) {
|
|
94
|
+
void response.body?.cancel().catch(() => {
|
|
95
|
+
});
|
|
96
|
+
throw new CliError("invalid_response", "Embedding response exceeds the byte budget");
|
|
97
|
+
}
|
|
98
|
+
if (!response.body)
|
|
99
|
+
throw new CliError("invalid_response", "Embedding response has no body");
|
|
100
|
+
const reader = response.body.getReader();
|
|
101
|
+
const chunks = [];
|
|
102
|
+
let bytes = 0;
|
|
103
|
+
try {
|
|
104
|
+
for (; ; ) {
|
|
105
|
+
cancelled(signal);
|
|
106
|
+
const part = await withAbort(reader.read(), signal);
|
|
107
|
+
cancelled(signal);
|
|
108
|
+
if (part.done)
|
|
109
|
+
break;
|
|
110
|
+
bytes += part.value.byteLength;
|
|
111
|
+
if (bytes > maxBytes)
|
|
112
|
+
throw new CliError("invalid_response", "Embedding response exceeds the byte budget");
|
|
113
|
+
chunks.push(part.value);
|
|
114
|
+
}
|
|
115
|
+
const body = Buffer.concat(chunks, bytes).toString("utf8");
|
|
116
|
+
try {
|
|
117
|
+
return JSON.parse(body);
|
|
118
|
+
} catch {
|
|
119
|
+
throw new CliError("invalid_response", "Embedding response is not JSON");
|
|
120
|
+
}
|
|
121
|
+
} finally {
|
|
122
|
+
void reader.cancel().catch(() => {
|
|
123
|
+
});
|
|
124
|
+
reader.releaseLock();
|
|
125
|
+
}
|
|
126
|
+
}, "boundedResponse");
|
|
127
|
+
var openMeetingEmbedder = /* @__PURE__ */ __name(async (choice, options = {}) => {
|
|
128
|
+
const descriptor = meetingEmbeddingModel(choice, options.env);
|
|
129
|
+
const { signal } = options;
|
|
130
|
+
cancelled(signal);
|
|
131
|
+
const maxInputBytes = integer(options.maxInputBytes ?? 1024 * 1024, "input byte budget", 16 * 1024 * 1024);
|
|
132
|
+
const maxResponseBytes = integer(options.maxResponseBytes ?? 8 * 1024 * 1024, "response byte budget", 64 * 1024 * 1024);
|
|
133
|
+
if (options.threads !== void 0)
|
|
134
|
+
integer(options.threads, "embedding threads", 128);
|
|
135
|
+
let engine;
|
|
136
|
+
let remoteFailure;
|
|
137
|
+
if (typeof choice === "string") {
|
|
138
|
+
const model = textModel(choice, options.env);
|
|
139
|
+
const directory = options.directory ?? textModelsDirectory(options.env);
|
|
140
|
+
if (!isTextModelInstalled(model, directory))
|
|
141
|
+
throw new CliError("configuration_error", "The explicit local embedding model is not installed");
|
|
142
|
+
engine = await openEmbedder(model, directory, {
|
|
143
|
+
...options.threads === void 0 ? {} : { threads: options.threads }
|
|
144
|
+
});
|
|
145
|
+
} else {
|
|
146
|
+
const remote = validatedRemote(choice.remote);
|
|
147
|
+
const key = choice.apiKey ?? (remote.provider === "openai" ? (options.env ?? process.env).OPENAI_API_KEY : void 0);
|
|
148
|
+
if (remote.provider === "openai" && !key)
|
|
149
|
+
throw new CliError("authentication_error", "The explicit remote embedding model requires an API key");
|
|
150
|
+
const post = options.fetch ?? endpointFetch(remote.baseUrl, 12e4);
|
|
151
|
+
const guarded = /* @__PURE__ */ __name(async (url, init) => {
|
|
152
|
+
try {
|
|
153
|
+
cancelled(signal);
|
|
154
|
+
const responseTask = post(url, { ...init, redirect: "manual", ...signal ? { signal } : {} }).then((response2) => {
|
|
155
|
+
if (signal?.aborted) {
|
|
156
|
+
void response2.body?.cancel().catch(() => {
|
|
157
|
+
});
|
|
158
|
+
cancelled(signal);
|
|
159
|
+
}
|
|
160
|
+
return response2;
|
|
161
|
+
});
|
|
162
|
+
const response = await withAbort(responseTask, signal);
|
|
163
|
+
if (signal?.aborted) {
|
|
164
|
+
void response.body?.cancel().catch(() => {
|
|
165
|
+
});
|
|
166
|
+
cancelled(signal);
|
|
167
|
+
}
|
|
168
|
+
if (response.status >= 300 && response.status < 400) {
|
|
169
|
+
void response.body?.cancel().catch(() => {
|
|
170
|
+
});
|
|
171
|
+
throw new CliError("invalid_response", "Embedding redirects are refused");
|
|
172
|
+
}
|
|
173
|
+
if (!response.ok) {
|
|
174
|
+
void response.body?.cancel().catch(() => {
|
|
175
|
+
});
|
|
176
|
+
return new Response("{}", { status: response.status });
|
|
177
|
+
}
|
|
178
|
+
const body = await boundedResponse(response, maxResponseBytes, signal);
|
|
179
|
+
if (!body || typeof body !== "object" || !("data" in body) || !Array.isArray(body.data) || body.data.length > 256)
|
|
180
|
+
throw new CliError("invalid_response", "Embedding response lacks vector data");
|
|
181
|
+
for (const entry of body.data) {
|
|
182
|
+
if (!entry || typeof entry !== "object" || !Number.isSafeInteger(entry.index) || entry.index < 0 || !Array.isArray(entry.embedding) || entry.embedding.length !== remote.dims || entry.embedding.some((value) => typeof value !== "number" || !Number.isFinite(value) || !Number.isFinite(Math.fround(value))))
|
|
183
|
+
throw new CliError("invalid_response", "Embedding response contains invalid vectors");
|
|
184
|
+
}
|
|
185
|
+
const indices = body.data.map((entry) => entry.index).sort((a, b) => a - b);
|
|
186
|
+
if (indices.some((index, position) => index !== position))
|
|
187
|
+
throw new CliError("invalid_response", "Embedding response contains invalid vector indices");
|
|
188
|
+
return new Response(JSON.stringify({ data: body.data.map((entry) => ({ index: entry.index, embedding: entry.embedding })) }), { status: response.status });
|
|
189
|
+
} catch (error) {
|
|
190
|
+
remoteFailure = error;
|
|
191
|
+
throw error;
|
|
192
|
+
}
|
|
193
|
+
}, "guarded");
|
|
194
|
+
engine = openRemote(remote, key, { concurrency: 1, fetch: guarded, tries: 1, env: options.env ?? process.env });
|
|
195
|
+
}
|
|
196
|
+
if (signal?.aborted) {
|
|
197
|
+
await engine.close();
|
|
198
|
+
cancelled(signal);
|
|
199
|
+
}
|
|
200
|
+
let closed = false;
|
|
201
|
+
let running = false;
|
|
202
|
+
let active = null;
|
|
203
|
+
let closing = null;
|
|
204
|
+
return {
|
|
205
|
+
...descriptor,
|
|
206
|
+
async embed(texts, kind) {
|
|
207
|
+
cancelled(signal);
|
|
208
|
+
if (closed)
|
|
209
|
+
throw new CliError("configuration_error", "Meeting embedder is closed");
|
|
210
|
+
if (!Array.isArray(texts) || texts.length > 1e3 || texts.some((text) => typeof text !== "string") || !["query", "passage"].includes(kind))
|
|
211
|
+
throw new CliError("validation_error", "Invalid meeting embedding inputs");
|
|
212
|
+
if (Buffer.byteLength(JSON.stringify(texts), "utf8") > maxInputBytes || texts.length * descriptor.dims * 4 > maxResponseBytes)
|
|
213
|
+
throw new CliError("validation_error", "Meeting embedding input or vector payload exceeds its byte budget");
|
|
214
|
+
if (running)
|
|
215
|
+
throw new CliError("validation_error", "A meeting embedding request is already running");
|
|
216
|
+
running = true;
|
|
217
|
+
let settled = /* @__PURE__ */ __name(() => {
|
|
218
|
+
}, "settled");
|
|
219
|
+
active = new Promise((resolve) => {
|
|
220
|
+
settled = resolve;
|
|
221
|
+
});
|
|
222
|
+
remoteFailure = void 0;
|
|
223
|
+
try {
|
|
224
|
+
const vectors = await engine.embed([...texts], kind);
|
|
225
|
+
cancelled(signal);
|
|
226
|
+
if (vectors.length !== texts.length || vectors.some((vector) => vector.length !== descriptor.dims || !vector.some((value) => value !== 0) || [...vector].some((value) => !Number.isFinite(value))))
|
|
227
|
+
throw new CliError("invalid_response", "Meeting embedder returned invalid vectors");
|
|
228
|
+
return vectors;
|
|
229
|
+
} catch (error) {
|
|
230
|
+
cancelled(signal);
|
|
231
|
+
if (remoteFailure instanceof CliError)
|
|
232
|
+
throw remoteFailure;
|
|
233
|
+
if (error instanceof CliError)
|
|
234
|
+
throw error;
|
|
235
|
+
throw new CliError("provider_error", "Meeting embedding failed");
|
|
236
|
+
} finally {
|
|
237
|
+
running = false;
|
|
238
|
+
settled();
|
|
239
|
+
active = null;
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
async close() {
|
|
243
|
+
if (!closing) {
|
|
244
|
+
closed = true;
|
|
245
|
+
closing = (async () => {
|
|
246
|
+
await active;
|
|
247
|
+
await engine.close();
|
|
248
|
+
})();
|
|
249
|
+
}
|
|
250
|
+
await closing;
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
}, "openMeetingEmbedder");
|
|
254
|
+
|
|
255
|
+
export {
|
|
256
|
+
meetingEmbeddingModel,
|
|
257
|
+
createMeetingRemoteModel,
|
|
258
|
+
openMeetingEmbedder
|
|
259
|
+
};
|