@wirecat/bitrix24-cli 0.0.0-stage → 0.1.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 +31 -0
- package/LICENSE +204 -0
- package/README.md +17 -2
- package/dist/api-keys.d.ts +21 -0
- package/dist/api-keys.d.ts.map +1 -0
- package/dist/api-keys.js +58 -0
- package/dist/api-keys.js.map +1 -0
- package/dist/bin/b24.d.ts +3 -0
- package/dist/bin/b24.d.ts.map +1 -0
- package/dist/bin/b24.js +40 -0
- package/dist/bin/b24.js.map +1 -0
- package/dist/bitrix/errors.d.ts +22 -0
- package/dist/bitrix/errors.d.ts.map +1 -0
- package/dist/bitrix/errors.js +76 -0
- package/dist/bitrix/errors.js.map +1 -0
- package/dist/bitrix/methods.d.ts +13 -0
- package/dist/bitrix/methods.d.ts.map +1 -0
- package/dist/bitrix/methods.js +33 -0
- package/dist/bitrix/methods.js.map +1 -0
- package/dist/bitrix/transport.d.ts +50 -0
- package/dist/bitrix/transport.d.ts.map +1 -0
- package/dist/bitrix/transport.js +189 -0
- package/dist/bitrix/transport.js.map +1 -0
- package/dist/bitrix/webhook.d.ts +14 -0
- package/dist/bitrix/webhook.d.ts.map +1 -0
- package/dist/bitrix/webhook.js +29 -0
- package/dist/bitrix/webhook.js.map +1 -0
- package/dist/bundle/all-profiles-QJ444GSX.js +24 -0
- package/dist/bundle/anthropic-RHRAVHC2.js +70 -0
- package/dist/bundle/app-server-QIT6S7AZ.js +224 -0
- package/dist/bundle/b24.js +32 -0
- package/dist/bundle/bun-H6RSODZ3.js +169 -0
- package/dist/bundle/bun-sqlite-BO4LTQHX.js +69 -0
- package/dist/bundle/chunk-2KCZ7BKW.js +215 -0
- package/dist/bundle/chunk-2SNUMZ7S.js +1028 -0
- package/dist/bundle/chunk-45AKJVKV.js +24 -0
- package/dist/bundle/chunk-4PDYYS5K.js +2 -0
- package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
- package/dist/bundle/chunk-6WY72XVQ.js +216 -0
- package/dist/bundle/chunk-7GRZAKBB.js +639 -0
- package/dist/bundle/chunk-ADLS6FVG.js +24600 -0
- package/dist/bundle/chunk-BCF7P4FZ.js +558 -0
- package/dist/bundle/chunk-CNNEA2M4.js +54 -0
- package/dist/bundle/chunk-CXL33BFL.js +570 -0
- package/dist/bundle/chunk-CZ23EVP4.js +1691 -0
- package/dist/bundle/chunk-D5S6QV6R.js +95 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-DTXERR44.js +35 -0
- package/dist/bundle/chunk-EVYSBZ3I.js +153 -0
- package/dist/bundle/chunk-EXOOKUEA.js +82 -0
- package/dist/bundle/chunk-FLUEXJ4X.js +53 -0
- package/dist/bundle/chunk-FOTREPNS.js +366 -0
- package/dist/bundle/chunk-FZL7F5NR.js +2022 -0
- package/dist/bundle/chunk-H2ADPPSH.js +50910 -0
- package/dist/bundle/chunk-HAXNUIGQ.js +1245 -0
- package/dist/bundle/chunk-HGL63O5V.js +288 -0
- package/dist/bundle/chunk-INFYLWUA.js +929 -0
- package/dist/bundle/chunk-IRV2PCQ2.js +5213 -0
- package/dist/bundle/chunk-K3UIB6ZF.js +45 -0
- package/dist/bundle/chunk-LRGYKOCP.js +91 -0
- package/dist/bundle/chunk-LSPIOT6Z.js +459 -0
- package/dist/bundle/chunk-MBDK4YXG.js +34 -0
- package/dist/bundle/chunk-N6FLBXZS.js +73 -0
- package/dist/bundle/chunk-OTD2ZRXD.js +161 -0
- package/dist/bundle/chunk-P33NDCDI.js +78 -0
- package/dist/bundle/chunk-P364PLIK.js +257 -0
- package/dist/bundle/chunk-PH5FZX6E.js +193 -0
- package/dist/bundle/chunk-POC3V3AO.js +36616 -0
- package/dist/bundle/chunk-QC53QBNC.js +143 -0
- package/dist/bundle/chunk-QGMDQ2PM.js +122 -0
- package/dist/bundle/chunk-QIPTIUMJ.js +281 -0
- package/dist/bundle/chunk-QMPN6WKD.js +3512 -0
- package/dist/bundle/chunk-QQXH2OPB.js +594 -0
- package/dist/bundle/chunk-QSNROIJL.js +413 -0
- package/dist/bundle/chunk-RRJNNPR4.js +76 -0
- package/dist/bundle/chunk-SFRNX2TI.js +6848 -0
- package/dist/bundle/chunk-SGRYYE4X.js +266 -0
- package/dist/bundle/chunk-TE3FR6MI.js +884 -0
- package/dist/bundle/chunk-U5ACMCAQ.js +12049 -0
- package/dist/bundle/chunk-VEWWAGTD.js +2315 -0
- package/dist/bundle/chunk-VL6SPMZV.js +194 -0
- package/dist/bundle/chunk-WII44RXN.js +58 -0
- package/dist/bundle/chunk-WKRQ44EH.js +528 -0
- package/dist/bundle/chunk-WTPMJYMD.js +8308 -0
- package/dist/bundle/chunk-XD4FRDSL.js +565 -0
- package/dist/bundle/chunk-XJXONOB5.js +63 -0
- package/dist/bundle/chunk-XNHSPHUN.js +48 -0
- package/dist/bundle/chunk-XRFJWHY5.js +131 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-YYO7D2MO.js +783 -0
- package/dist/bundle/chunk-YZ5LHE5Q.js +31 -0
- package/dist/bundle/chunk-ZDQQCXFG.js +392 -0
- package/dist/bundle/chunk-ZEW4P6AH.js +158 -0
- package/dist/bundle/chunk-ZGZT5S6B.js +3480 -0
- package/dist/bundle/chunk-ZIAQPTUS.js +82 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/command-contract-OKQOE6G4.js +30 -0
- package/dist/bundle/decode-5ZPLTYV6.js +160 -0
- package/dist/bundle/dist-PII6Z6X3.js +7577 -0
- package/dist/bundle/echarts-J6LAPIX7.js +42501 -0
- package/dist/bundle/embed-YG5LDHME.js +35 -0
- package/dist/bundle/embedder-7FNUA5OZ.js +108 -0
- package/dist/bundle/first-run-JPZNWIJN.js +23 -0
- package/dist/bundle/first-screen-VQM4MTS7.js +28 -0
- package/dist/bundle/instructions-AXWTQHMR.js +11 -0
- package/dist/bundle/mcp-7F46P6AM.js +165 -0
- package/dist/bundle/mcp-J5R5A65I.js +87 -0
- package/dist/bundle/mcp-WALJM6QX.js +160 -0
- package/dist/bundle/node-CWKAIOEM.js +176 -0
- package/dist/bundle/node-P4E63KXA.js +2340 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-sqlite-LSEKVRDA.js +67 -0
- package/dist/bundle/oauth-THYNLRLD.js +17 -0
- package/dist/bundle/open-E47QYKFC.js +20 -0
- package/dist/bundle/openai-EWSGC3BC.js +227 -0
- package/dist/bundle/process-WKTEA3WE.js +91 -0
- package/dist/bundle/program-GO3RVP2H.js +20847 -0
- package/dist/bundle/prompt-CAQ7QR3U.js +12 -0
- package/dist/bundle/recognize-6KGHNZC3.js +23 -0
- package/dist/bundle/remote-3UO2WDC3.js +26 -0
- package/dist/bundle/rerank-2JVDPZBX.js +49 -0
- package/dist/bundle/serve-ES7AG5IK.js +19 -0
- package/dist/bundle/server-5LE5LNUQ.js +45 -0
- package/dist/bundle/server-BU4VBM6S.js +58 -0
- package/dist/bundle/state-7NH5G4XJ.js +33 -0
- package/dist/bundle/store-7O4JQD2Z.js +127 -0
- package/dist/bundle/store-maintenance-command-UDVGEY2D.js +47 -0
- package/dist/commands/api.d.ts +3 -0
- package/dist/commands/api.d.ts.map +1 -0
- package/dist/commands/api.js +130 -0
- package/dist/commands/api.js.map +1 -0
- package/dist/commands/crm-writes.d.ts +4 -0
- package/dist/commands/crm-writes.d.ts.map +1 -0
- package/dist/commands/crm-writes.js +182 -0
- package/dist/commands/crm-writes.js.map +1 -0
- package/dist/commands/crm.d.ts +3 -0
- package/dist/commands/crm.d.ts.map +1 -0
- package/dist/commands/crm.js +142 -0
- package/dist/commands/crm.js.map +1 -0
- package/dist/commands/doctor.d.ts +77 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +74 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/mcp.d.ts +3 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +97 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/session.d.ts +3 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +101 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/commands/write.d.ts +21 -0
- package/dist/commands/write.d.ts.map +1 -0
- package/dist/commands/write.js +47 -0
- package/dist/commands/write.js.map +1 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +17 -0
- package/dist/config.js.map +1 -0
- package/dist/crm/conditions.d.ts +25 -0
- package/dist/crm/conditions.d.ts.map +1 -0
- package/dist/crm/conditions.js +78 -0
- package/dist/crm/conditions.js.map +1 -0
- package/dist/crm/deal.d.ts +27 -0
- package/dist/crm/deal.d.ts.map +1 -0
- package/dist/crm/deal.js +76 -0
- package/dist/crm/deal.js.map +1 -0
- package/dist/crm/items.d.ts +30 -0
- package/dist/crm/items.d.ts.map +1 -0
- package/dist/crm/items.js +76 -0
- package/dist/crm/items.js.map +1 -0
- package/dist/crm/lead.d.ts +36 -0
- package/dist/crm/lead.d.ts.map +1 -0
- package/dist/crm/lead.js +86 -0
- package/dist/crm/lead.js.map +1 -0
- package/dist/crm/organization.d.ts +32 -0
- package/dist/crm/organization.d.ts.map +1 -0
- package/dist/crm/organization.js +68 -0
- package/dist/crm/organization.js.map +1 -0
- package/dist/crm/person.d.ts +31 -0
- package/dist/crm/person.d.ts.map +1 -0
- package/dist/crm/person.js +68 -0
- package/dist/crm/person.js.map +1 -0
- package/dist/crm/pipeline.d.ts +17 -0
- package/dist/crm/pipeline.d.ts.map +1 -0
- package/dist/crm/pipeline.js +42 -0
- package/dist/crm/pipeline.js.map +1 -0
- package/dist/crm/product.d.ts +43 -0
- package/dist/crm/product.d.ts.map +1 -0
- package/dist/crm/product.js +42 -0
- package/dist/crm/product.js.map +1 -0
- package/dist/crm/stage.d.ts +20 -0
- package/dist/crm/stage.d.ts.map +1 -0
- package/dist/crm/stage.js +65 -0
- package/dist/crm/stage.js.map +1 -0
- package/dist/crm/user.d.ts +39 -0
- package/dist/crm/user.d.ts.map +1 -0
- package/dist/crm/user.js +54 -0
- package/dist/crm/user.js.map +1 -0
- package/dist/crm/values.d.ts +30 -0
- package/dist/crm/values.d.ts.map +1 -0
- package/dist/crm/values.js +50 -0
- package/dist/crm/values.js.map +1 -0
- package/dist/crm/walk.d.ts +19 -0
- package/dist/crm/walk.d.ts.map +1 -0
- package/dist/crm/walk.js +22 -0
- package/dist/crm/walk.js.map +1 -0
- package/dist/identity.d.ts +5 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +18 -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/mcp.d.ts +29 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +99 -0
- package/dist/mcp.js.map +1 -0
- package/dist/portal.d.ts +33 -0
- package/dist/portal.d.ts.map +1 -0
- package/dist/portal.js +46 -0
- package/dist/portal.js.map +1 -0
- package/dist/program.d.ts +6 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +45 -0
- package/dist/program.js.map +1 -0
- package/dist/reasons.d.ts +10 -0
- package/dist/reasons.d.ts.map +1 -0
- package/dist/reasons.js +28 -0
- package/dist/reasons.js.map +1 -0
- package/dist/token.d.ts +12 -0
- package/dist/token.d.ts.map +1 -0
- package/dist/token.js +41 -0
- package/dist/token.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/whoami.d.ts +8 -0
- package/dist/whoami.d.ts.map +1 -0
- package/dist/whoami.js +9 -0
- package/dist/whoami.js.map +1 -0
- package/package.json +83 -4
- package/skills/bitrix24-cli/SKILL.md +41 -0
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
secretNamed,
|
|
5
|
+
withoutSecrets
|
|
6
|
+
} from "./chunk-LRGYKOCP.js";
|
|
7
|
+
import {
|
|
8
|
+
errorCodes,
|
|
9
|
+
isContentKey
|
|
10
|
+
} from "./chunk-IRV2PCQ2.js";
|
|
11
|
+
import {
|
|
12
|
+
__name
|
|
13
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
14
|
+
|
|
15
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.586.0_@wirecat+cli-base@0.79.0_commander@15.0.0_esbuild@0.28.2_type_bdecddef0ae5a50ae90cab8b9e35c13b/node_modules/@wirecat/cli-core/dist/runs/run-context.js
|
|
16
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
17
|
+
import { createHash } from "node:crypto";
|
|
18
|
+
|
|
19
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.586.0_@wirecat+cli-base@0.79.0_commander@15.0.0_esbuild@0.28.2_type_bdecddef0ae5a50ae90cab8b9e35c13b/node_modules/@wirecat/cli-core/dist/runs/error-detail.js
|
|
20
|
+
import { homedir } from "node:os";
|
|
21
|
+
|
|
22
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.586.0_@wirecat+cli-base@0.79.0_commander@15.0.0_esbuild@0.28.2_type_bdecddef0ae5a50ae90cab8b9e35c13b/node_modules/@wirecat/cli-core/dist/errors/failures.js
|
|
23
|
+
var isCliFailure = /* @__PURE__ */ __name((value) => value instanceof Error && value.name === "CliError" && errorCodes.includes(value.code), "isCliFailure");
|
|
24
|
+
var isCommanderFailure = /* @__PURE__ */ __name((value) => {
|
|
25
|
+
const { code, exitCode } = value ?? {};
|
|
26
|
+
return value instanceof Error && typeof code === "string" && code.startsWith("commander.") && typeof exitCode === "number";
|
|
27
|
+
}, "isCommanderFailure");
|
|
28
|
+
var failureKey = /* @__PURE__ */ __name((error) => isCliFailure(error) ? error.code : error instanceof Error ? error.name : "error", "failureKey");
|
|
29
|
+
|
|
30
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.586.0_@wirecat+cli-base@0.79.0_commander@15.0.0_esbuild@0.28.2_type_bdecddef0ae5a50ae90cab8b9e35c13b/node_modules/@wirecat/cli-core/dist/runs/events.js
|
|
31
|
+
var providerErrorKey = /* @__PURE__ */ __name((value) => typeof value === "string" && /^[A-Za-z][A-Za-z0-9._-]{0,63}$/.test(value) ? value : void 0, "providerErrorKey");
|
|
32
|
+
var renderEvent = /* @__PURE__ */ __name((event) => {
|
|
33
|
+
if (event.event === "warning") {
|
|
34
|
+
const counts = Object.entries(event.counts ?? {}).map(([field, count]) => `${count} ${field}`);
|
|
35
|
+
return [`${MARK.warning} ${(event.operation ?? "").padEnd(16)} ${event.code}`, ...counts, event.detail].filter(Boolean).join(" ");
|
|
36
|
+
}
|
|
37
|
+
const parts = [];
|
|
38
|
+
if (event.event === "cache") {
|
|
39
|
+
parts.push(event.reason);
|
|
40
|
+
if (event.ageMs !== void 0)
|
|
41
|
+
parts.push(`cached ${age(event.ageMs)}`);
|
|
42
|
+
} else {
|
|
43
|
+
if (event.opcode !== void 0)
|
|
44
|
+
parts.push(`op ${event.opcode}`, `seq ${event.seq}`);
|
|
45
|
+
if (event.method !== void 0 || event.endpointTemplate !== void 0)
|
|
46
|
+
parts.push([event.method, event.endpointTemplate].filter(Boolean).join(" "));
|
|
47
|
+
if (event.status !== void 0)
|
|
48
|
+
parts.push(`${event.status}`);
|
|
49
|
+
if (event.attempt !== void 0 && event.attempt > 1)
|
|
50
|
+
parts.push(`attempt ${event.attempt}`);
|
|
51
|
+
if (event.waitMs !== void 0)
|
|
52
|
+
parts.push(`waited ${age(event.waitMs)}`);
|
|
53
|
+
}
|
|
54
|
+
if (event.ids)
|
|
55
|
+
for (const [name, value] of Object.entries(event.ids))
|
|
56
|
+
parts.push(`${name} ${value}`);
|
|
57
|
+
if (event.event !== "cache") {
|
|
58
|
+
if (event.durationMs !== void 0)
|
|
59
|
+
parts.push(`${event.durationMs}ms`);
|
|
60
|
+
if (event.bytes !== void 0)
|
|
61
|
+
parts.push(size(event.bytes));
|
|
62
|
+
}
|
|
63
|
+
if (event.counts)
|
|
64
|
+
for (const [field, count] of Object.entries(event.counts))
|
|
65
|
+
parts.push(`${count} ${field}`);
|
|
66
|
+
if (event.event !== "cache") {
|
|
67
|
+
if (event.errorCode)
|
|
68
|
+
parts.push(event.errorCode);
|
|
69
|
+
if (event.providerError)
|
|
70
|
+
parts.push(event.providerError);
|
|
71
|
+
}
|
|
72
|
+
return `${MARK[event.event]} ${event.operation.padEnd(16)} ${parts.join(" ")}`.trimEnd();
|
|
73
|
+
}, "renderEvent");
|
|
74
|
+
var MARK = { request: "\u2192", response: "\u2190", cache: "\u2022", warning: "!" };
|
|
75
|
+
var age = /* @__PURE__ */ __name((ms) => ms < 1e3 ? `${ms}ms` : `${Math.round(ms / 1e3)}s`, "age");
|
|
76
|
+
var size = /* @__PURE__ */ __name((bytes) => bytes < 1e3 ? `${bytes} B` : `${(bytes / 1e3).toFixed(1)} kB`, "size");
|
|
77
|
+
|
|
78
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.586.0_@wirecat+cli-base@0.79.0_commander@15.0.0_esbuild@0.28.2_type_bdecddef0ae5a50ae90cab8b9e35c13b/node_modules/@wirecat/cli-core/dist/runs/error-detail.js
|
|
79
|
+
var MESSAGE_AT_MOST = 500;
|
|
80
|
+
var CAUSES_AT_MOST = 5;
|
|
81
|
+
var FRAMES_AT_MOST = 15;
|
|
82
|
+
var errorDetailOf = /* @__PURE__ */ __name((error, response) => {
|
|
83
|
+
const details = isCliFailure(error) ? { ...error.details } : {};
|
|
84
|
+
const thrown = error instanceof Error ? error : void 0;
|
|
85
|
+
const code = isCliFailure(error) ? error.code : codeOf(error);
|
|
86
|
+
const reason = typeof details.reason === "string" ? details.reason : void 0;
|
|
87
|
+
const causeCode = typeof details.cause_code === "string" && /^[A-Za-z0-9_.-]{1,40}$/.test(details.cause_code) ? details.cause_code : void 0;
|
|
88
|
+
const message = thrown ? redactText(thrown.message) : void 0;
|
|
89
|
+
const operation = stringOf(details.operation) ?? response?.operation;
|
|
90
|
+
const status = numberOf(details.status) ?? response?.status;
|
|
91
|
+
const method = stringOf(details.method) ?? response?.method;
|
|
92
|
+
const endpoint = stringOf(details.endpoint) ?? response?.endpointTemplate;
|
|
93
|
+
const key = providerErrorKey(details.provider_error) ?? providerErrorKey(response?.providerError);
|
|
94
|
+
const protocol = key !== void 0 && method === void 0 && endpoint === void 0;
|
|
95
|
+
const http = method !== void 0 || endpoint !== void 0 || status !== void 0 && !protocol ? {
|
|
96
|
+
...method === void 0 ? {} : { method: method.toUpperCase().slice(0, 16) },
|
|
97
|
+
...endpoint === void 0 ? {} : { endpoint_template: endpointTemplate(endpoint) },
|
|
98
|
+
...status === void 0 ? {} : { status }
|
|
99
|
+
} : void 0;
|
|
100
|
+
const causes = causesOf(thrown?.cause ?? details.cause);
|
|
101
|
+
const stack = framesOf(thrown);
|
|
102
|
+
return {
|
|
103
|
+
class: classOf(error),
|
|
104
|
+
...code === void 0 ? {} : { code },
|
|
105
|
+
...reason === void 0 ? {} : { reason },
|
|
106
|
+
...causeCode === void 0 ? {} : { cause_code: causeCode },
|
|
107
|
+
...message ? { message } : {},
|
|
108
|
+
...operation === void 0 ? {} : { operation },
|
|
109
|
+
...http ? { http } : {},
|
|
110
|
+
...key === void 0 ? {} : { provider: { key, ...protocol && status !== void 0 ? { code: status } : {} } },
|
|
111
|
+
...causes.length > 0 ? { causes } : {},
|
|
112
|
+
...stack.length > 0 ? { stack } : {}
|
|
113
|
+
};
|
|
114
|
+
}, "errorDetailOf");
|
|
115
|
+
var stringOf = /* @__PURE__ */ __name((value) => typeof value === "string" && value.trim() !== "" ? value.trim() : void 0, "stringOf");
|
|
116
|
+
var numberOf = /* @__PURE__ */ __name((value) => typeof value === "number" && Number.isInteger(value) ? value : void 0, "numberOf");
|
|
117
|
+
var classOf = /* @__PURE__ */ __name((error) => {
|
|
118
|
+
if (!(error instanceof Error))
|
|
119
|
+
return error === null ? "null" : typeof error;
|
|
120
|
+
const constructed = error.constructor?.name;
|
|
121
|
+
return constructed && constructed !== "Error" && constructed !== error.name ? constructed : error.name;
|
|
122
|
+
}, "classOf");
|
|
123
|
+
var codeOf = /* @__PURE__ */ __name((error) => {
|
|
124
|
+
const code = error?.code;
|
|
125
|
+
return typeof code === "string" && /^[A-Za-z][A-Za-z0-9._-]{0,63}$/.test(code) ? code : void 0;
|
|
126
|
+
}, "codeOf");
|
|
127
|
+
var causesOf = /* @__PURE__ */ __name((first) => {
|
|
128
|
+
const causes = [];
|
|
129
|
+
const seen = /* @__PURE__ */ new Set();
|
|
130
|
+
for (let cause = first; cause !== void 0 && cause !== null && causes.length < CAUSES_AT_MOST; ) {
|
|
131
|
+
if (seen.has(cause))
|
|
132
|
+
break;
|
|
133
|
+
seen.add(cause);
|
|
134
|
+
const message = cause instanceof Error ? redactText(cause.message) : void 0;
|
|
135
|
+
causes.push({ class: classOf(cause), ...message ? { message } : {} });
|
|
136
|
+
cause = cause instanceof Error ? cause.cause : void 0;
|
|
137
|
+
}
|
|
138
|
+
return causes;
|
|
139
|
+
}, "causesOf");
|
|
140
|
+
var framesOf = /* @__PURE__ */ __name((error, limit = FRAMES_AT_MOST) => {
|
|
141
|
+
const stack = error instanceof Error && typeof error.stack === "string" ? error.stack : "";
|
|
142
|
+
return stack.split("\n").filter((line) => line.trimStart().startsWith("at ")).flatMap((line) => {
|
|
143
|
+
const match = /^\s*at (?:async )?(?:(.+?) \()?(.+?):(\d+):\d+\)?$/.exec(line);
|
|
144
|
+
if (!match)
|
|
145
|
+
return [];
|
|
146
|
+
const [, fn, path = "", lineNumber] = match;
|
|
147
|
+
if (path.startsWith("node:"))
|
|
148
|
+
return [];
|
|
149
|
+
return [`${fn ?? "<anonymous>"} ${fileOf(path)}:${lineNumber}`];
|
|
150
|
+
}).slice(0, limit);
|
|
151
|
+
}, "framesOf");
|
|
152
|
+
var fileOf = /* @__PURE__ */ __name((path) => {
|
|
153
|
+
const plain = path.replace(/^file:\/\//, "");
|
|
154
|
+
const packaged = /\/node_modules\/((?:@[^/]+\/)?[^/]+\/.+)$/.exec(plain)?.[1];
|
|
155
|
+
if (packaged)
|
|
156
|
+
return packaged.replace(/\/(?:dist|src)\//, "/");
|
|
157
|
+
return /(?:^|\/)(?:dist|src)\/(.+)$/.exec(plain)?.[1] ?? plain.split("/").at(-1) ?? "?";
|
|
158
|
+
}, "fileOf");
|
|
159
|
+
var endpointTemplate = /* @__PURE__ */ __name((raw) => {
|
|
160
|
+
const trimmed = raw.trim().split(/[?#]/)[0] ?? "";
|
|
161
|
+
const origin = /^[a-z][a-z0-9+.-]*:\/\/(?:[^@/]*@)?([^/]*)/i.exec(trimmed);
|
|
162
|
+
const path = origin ? trimmed.slice(origin[0].length) : trimmed;
|
|
163
|
+
const scheme = origin ? `${trimmed.slice(0, trimmed.indexOf("://"))}://${origin[1]}` : "";
|
|
164
|
+
const segments = path.split("/").map((segment) => {
|
|
165
|
+
if (segment === "" || /^[:{].+/.test(segment))
|
|
166
|
+
return segment;
|
|
167
|
+
if (/^bot\d+:/.test(segment) || /^\d{6,}:[\w-]{20,}$/.test(segment))
|
|
168
|
+
return ":token";
|
|
169
|
+
if (/^-?\d+$/.test(segment) || /^[0-9a-f-]{16,}$/i.test(segment))
|
|
170
|
+
return ":id";
|
|
171
|
+
if (!/^[A-Za-z0-9._~-]{1,40}$/.test(segment))
|
|
172
|
+
return ":value";
|
|
173
|
+
return segment;
|
|
174
|
+
});
|
|
175
|
+
return `${scheme}${segments.join("/")}`.slice(0, 300);
|
|
176
|
+
}, "endpointTemplate");
|
|
177
|
+
var INTERNATIONAL_PHONE = /\+\d[\d\s()-]{6,}\d/.source;
|
|
178
|
+
var BARE_PHONE = /(^|[^\w-])\d{11,15}\b/.source;
|
|
179
|
+
var MESSENGER_ID = /\b\d+(?:-\d+)?(?::\d+)?@(?:s\.whatsapp\.net|g\.us|c\.us|lid|broadcast|newsletter)\b/g;
|
|
180
|
+
var redactText = /* @__PURE__ */ __name((text) => {
|
|
181
|
+
const home = homedir();
|
|
182
|
+
let out = home && home !== "/" ? text.split(home).join("~") : text;
|
|
183
|
+
out = withoutSecrets(out.replace(/"[^"\n]*"|“[^”\n]*”|«[^»\n]*»/g, '"[redacted]"')).replace(/\b(bearer|basic|token|key|password|secret)(\s*[:=]\s*|\s+)[^\s'"]+/gi, "$1$2[redacted]").replace(MESSENGER_ID, "[id]").replace(/[\w.+-]+@[\w-]+\.[\w.-]+/g, "[email]").replace(new RegExp(INTERNATIONAL_PHONE, "g"), "[number]").replace(new RegExp(BARE_PHONE, "g"), "$1[number]").replace(/\bbot\d+:[\w-]+/g, "bot[token]").replace(/\b\d{6,}:[\w-]{20,}\b/g, "[token]").replace(/(\?|&)[^\s#]*/g, "$1[redacted]").replace(/\b[A-Za-z0-9_-]{40,}\b/g, "[redacted]");
|
|
184
|
+
return out.length > MESSAGE_AT_MOST ? `${out.slice(0, MESSAGE_AT_MOST)}\u2026` : out;
|
|
185
|
+
}, "redactText");
|
|
186
|
+
|
|
187
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.586.0_@wirecat+cli-base@0.79.0_commander@15.0.0_esbuild@0.28.2_type_bdecddef0ae5a50ae90cab8b9e35c13b/node_modules/@wirecat/cli-core/dist/runs/run-context.js
|
|
188
|
+
var REDACTED = "[redacted]";
|
|
189
|
+
var keepsSuccess = /* @__PURE__ */ __name(({ record, fromFlag, env, caller, persistent = false }) => {
|
|
190
|
+
if (!record)
|
|
191
|
+
return false;
|
|
192
|
+
if (fromFlag)
|
|
193
|
+
return true;
|
|
194
|
+
if (persistent)
|
|
195
|
+
return false;
|
|
196
|
+
return caller !== void 0 || viaOf(env) !== "desktop";
|
|
197
|
+
}, "keepsSuccess");
|
|
198
|
+
var calls = new AsyncLocalStorage();
|
|
199
|
+
var withCaller = /* @__PURE__ */ __name((caller, work) => calls.run(caller, work), "withCaller");
|
|
200
|
+
var currentCaller = /* @__PURE__ */ __name(() => calls.getStore(), "currentCaller");
|
|
201
|
+
var clientHash = /* @__PURE__ */ __name((id) => createHash("sha256").update(id).digest("hex").slice(0, 8), "clientHash");
|
|
202
|
+
var viaOf = /* @__PURE__ */ __name((env) => env.WIRECAT_CALLER?.trim() === "desktop" ? "desktop" : "cli", "viaOf");
|
|
203
|
+
var agentOf = /* @__PURE__ */ __name((env) => {
|
|
204
|
+
const named = env.AI_AGENT?.trim().split("_")[0];
|
|
205
|
+
const kind = (named && plainWord(named) ? named.toLowerCase() : void 0) ?? (env.CLAUDECODE ? "claude-code" : void 0) ?? (env.CODEX_THREAD_ID || env.CODEX_SESSION_ID || env.CODEX_SANDBOX ? "codex" : void 0) ?? (env.GEMINI_CLI ? "gemini-cli" : void 0) ?? (env.OPENCODE ? "opencode" : void 0) ?? (env.CURSOR_AGENT ? "cursor" : void 0) ?? // Only `exec` is the agent's own command: OpenClaw also sets `tui-local` for what the owner types in its TUI.
|
|
206
|
+
(env.OPENCLAW_SHELL?.trim() === "exec" ? "openclaw" : void 0);
|
|
207
|
+
if (!kind)
|
|
208
|
+
return void 0;
|
|
209
|
+
const session = sessionOf(kind, env);
|
|
210
|
+
return {
|
|
211
|
+
kind,
|
|
212
|
+
session_id: session && SESSION.test(session) ? session : null,
|
|
213
|
+
// OpenClaw passes the sender and chat ids of a chat-started run in this variable; only its presence is kept.
|
|
214
|
+
...kind === "openclaw" && env.OPENCLAW_CHANNEL_CONTEXT?.trim() ? { from_chat: true } : {}
|
|
215
|
+
};
|
|
216
|
+
}, "agentOf");
|
|
217
|
+
var SESSION = /^[A-Za-z0-9._:-]{1,128}$/;
|
|
218
|
+
var SESSION_VARIABLE = {
|
|
219
|
+
"claude-code": "CLAUDE_CODE_SESSION_ID",
|
|
220
|
+
codex: "CODEX_THREAD_ID",
|
|
221
|
+
opencode: "OPENCODE_SESSION_ID",
|
|
222
|
+
"hermes-agent": "HERMES_SESSION_ID"
|
|
223
|
+
};
|
|
224
|
+
var sessionOf = /* @__PURE__ */ __name((kind, env) => {
|
|
225
|
+
const variable = SESSION_VARIABLE[kind];
|
|
226
|
+
return (variable === void 0 ? void 0 : env[variable]?.trim()) || void 0;
|
|
227
|
+
}, "sessionOf");
|
|
228
|
+
var plainWord = /* @__PURE__ */ __name((word) => /^[A-Za-z][A-Za-z0-9.-]{0,39}$/.test(word), "plainWord");
|
|
229
|
+
var secretInputs = /* @__PURE__ */ new WeakSet();
|
|
230
|
+
var secretInput = /* @__PURE__ */ __name((input) => {
|
|
231
|
+
secretInputs.add(input);
|
|
232
|
+
return input;
|
|
233
|
+
}, "secretInput");
|
|
234
|
+
var secretShaped = /* @__PURE__ */ __name((word) => /:\/\/[^/@\s:]+:[^/@\s]+@/.test(word) || /(^|[^A-Za-z0-9_-])[A-Za-z0-9_-]{40,}($|[^A-Za-z0-9_-])/.test(word), "secretShaped");
|
|
235
|
+
var withoutPhones = /* @__PURE__ */ __name((word) => word.replace(new RegExp(INTERNATIONAL_PHONE, "g"), REDACTED).replace(new RegExp(BARE_PHONE, "g"), `$1${REDACTED}`), "withoutPhones");
|
|
236
|
+
var maskArgv = /* @__PURE__ */ __name((program, words, { keep = false } = {}) => {
|
|
237
|
+
const argv = [];
|
|
238
|
+
let unknownCommand;
|
|
239
|
+
let current = program;
|
|
240
|
+
let positional = 0;
|
|
241
|
+
let profileSeen = false;
|
|
242
|
+
let lost = false;
|
|
243
|
+
const raw = /* @__PURE__ */ __name((word) => keep && !secretShaped(word) ? withoutPhones(withoutSecrets(word, REDACTED)) : REDACTED, "raw");
|
|
244
|
+
const keptValue = /* @__PURE__ */ __name((name, value, input) => keep ? input && secretInputs.has(input) || secretNamed(name) ? REDACTED : raw(value) : maskedValue(name, value, input?.argChoices), "keptValue");
|
|
245
|
+
const optionFor = /* @__PURE__ */ __name((flag) => {
|
|
246
|
+
for (let at = current; at; at = at.parent) {
|
|
247
|
+
const found = at.options.find((option) => option.long === flag || option.short === flag);
|
|
248
|
+
if (found)
|
|
249
|
+
return found;
|
|
250
|
+
}
|
|
251
|
+
return void 0;
|
|
252
|
+
}, "optionFor");
|
|
253
|
+
for (let at = 0; at < words.length; at++) {
|
|
254
|
+
const word = words[at];
|
|
255
|
+
if (word === "--") {
|
|
256
|
+
argv.push("--");
|
|
257
|
+
for (let after = at + 1; after < words.length; after++)
|
|
258
|
+
argv.push(raw(words[after]));
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
if (word.startsWith("-") && word.length > 1 && !NUMBER.test(word)) {
|
|
262
|
+
const equals = word.indexOf("=");
|
|
263
|
+
const flag = equals > 0 ? word.slice(0, equals) : word;
|
|
264
|
+
if (!/^--?[A-Za-z0-9][A-Za-z0-9-]*$/.test(flag)) {
|
|
265
|
+
argv.push(raw(word));
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
const option = optionFor(flag);
|
|
269
|
+
const name = option?.attributeName() ?? flag.replace(/^-+/, "");
|
|
270
|
+
if (equals > 0) {
|
|
271
|
+
argv.push(`${flag}=${keptValue(name, word.slice(equals + 1), option)}`);
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
argv.push(flag);
|
|
275
|
+
if (!option && keep && secretNamed(name) && words[at + 1] !== void 0 && !words[at + 1]?.startsWith("-")) {
|
|
276
|
+
at += 1;
|
|
277
|
+
argv.push(REDACTED);
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
if (!option || !(option.required || option.optional))
|
|
281
|
+
continue;
|
|
282
|
+
const takes = /* @__PURE__ */ __name((next) => next !== void 0 && (option.required || !next.startsWith("-") || NUMBER.test(next)), "takes");
|
|
283
|
+
if (takes(words[at + 1])) {
|
|
284
|
+
at += 1;
|
|
285
|
+
argv.push(keptValue(name, words[at], option));
|
|
286
|
+
while (option.variadic && words[at + 1] !== void 0 && !words[at + 1].startsWith("-")) {
|
|
287
|
+
at += 1;
|
|
288
|
+
argv.push(keptValue(name, words[at], option));
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
if (!lost && positional === 0) {
|
|
294
|
+
const sub = current.commands.find((one) => one.name() === word || one.aliases().includes(word));
|
|
295
|
+
if (sub) {
|
|
296
|
+
argv.push(word);
|
|
297
|
+
current = sub;
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
if (current === program && !profileSeen) {
|
|
301
|
+
profileSeen = true;
|
|
302
|
+
argv.push(keep ? raw(word) : PROFILE.test(word) && withoutPhones(withoutSecrets(word)) === word ? word : REDACTED);
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
if (current.commands.length > 0 && current.registeredArguments.length === 0) {
|
|
306
|
+
lost = true;
|
|
307
|
+
unknownCommand = commandLike(word);
|
|
308
|
+
argv.push(keep ? raw(word) : unknownCommand);
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
const declared = lost ? void 0 : current.registeredArguments;
|
|
313
|
+
const argument = declared?.[Math.min(positional, declared.length - 1)];
|
|
314
|
+
positional += 1;
|
|
315
|
+
argv.push(secretInputs.has(current) ? REDACTED : argument ? keptValue(argument.name(), word, argument) : raw(word));
|
|
316
|
+
}
|
|
317
|
+
return { argv, ...unknownCommand === void 0 ? {} : { unknownCommand } };
|
|
318
|
+
}, "maskArgv");
|
|
319
|
+
var NUMBER = /^-?\d+(\.\d+)?$/;
|
|
320
|
+
var PROFILE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
321
|
+
var commandLike = /* @__PURE__ */ __name((word) => /^[a-z][a-z0-9-]{0,31}$/i.test(word) && withoutSecrets(word) === word ? word : REDACTED, "commandLike");
|
|
322
|
+
var maskedValue = /* @__PURE__ */ __name((name, value, choices) => {
|
|
323
|
+
if (isContentKey(name))
|
|
324
|
+
return REDACTED;
|
|
325
|
+
if (name === "profile")
|
|
326
|
+
return PROFILE.test(value) ? value : REDACTED;
|
|
327
|
+
if (name === "json" || name === "fields")
|
|
328
|
+
return /^[a-z0-9_.,]{1,200}$/.test(value) ? value : REDACTED;
|
|
329
|
+
if (choices?.includes(value))
|
|
330
|
+
return value;
|
|
331
|
+
return safeShape(value) ? value : REDACTED;
|
|
332
|
+
}, "maskedValue");
|
|
333
|
+
var safeShape = /* @__PURE__ */ __name((value) => NUMBER.test(value) && !/^\d{11,}$/.test(value) || /^\d+(ms|s|m|h|d|w)$/.test(value) || /^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/.test(value) || value === "true" || value === "false", "safeShape");
|
|
334
|
+
var runContextOf = /* @__PURE__ */ __name(({ bin, command, program, argv, env, recordInput = false, caller }) => {
|
|
335
|
+
const masked = program && argv ? maskArgv(program, argv, { keep: recordInput === true }) : void 0;
|
|
336
|
+
const ifFailed = program && argv && recordInput === "failed" ? maskArgv(program, argv, { keep: true }) : void 0;
|
|
337
|
+
const agent = caller ? caller.agent : agentOf(env);
|
|
338
|
+
return {
|
|
339
|
+
cliCommand: command ? `${bin} ${command}` : bin,
|
|
340
|
+
...masked ? { argv: masked.argv } : {},
|
|
341
|
+
...ifFailed ? { argvIfFailed: ifFailed.argv } : {},
|
|
342
|
+
...masked?.unknownCommand === void 0 ? {} : { unknownCommand: masked.unknownCommand },
|
|
343
|
+
...agent ? { agent } : {},
|
|
344
|
+
via: caller?.via ?? viaOf(env),
|
|
345
|
+
...caller?.mcp ? { mcp: caller.mcp } : {}
|
|
346
|
+
};
|
|
347
|
+
}, "runContextOf");
|
|
348
|
+
|
|
349
|
+
export {
|
|
350
|
+
isCliFailure,
|
|
351
|
+
isCommanderFailure,
|
|
352
|
+
failureKey,
|
|
353
|
+
providerErrorKey,
|
|
354
|
+
renderEvent,
|
|
355
|
+
errorDetailOf,
|
|
356
|
+
framesOf,
|
|
357
|
+
endpointTemplate,
|
|
358
|
+
keepsSuccess,
|
|
359
|
+
withCaller,
|
|
360
|
+
currentCaller,
|
|
361
|
+
clientHash,
|
|
362
|
+
agentOf,
|
|
363
|
+
secretInput,
|
|
364
|
+
maskArgv,
|
|
365
|
+
runContextOf
|
|
366
|
+
};
|