weaver-work-cli 0.1.44 → 0.1.45
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/README.md +9 -5
- package/dist/chunks/{archive-P6TBQGKL.js → archive-ZQ4A4TV6.js} +388 -44
- package/dist/chunks/{archive-oa-7TQ2NXOH.js → archive-oa-BBDP7AKJ.js} +2 -2
- package/dist/chunks/{asset-3ELRG37G.js → asset-ZOJVBWZH.js} +2 -2
- package/dist/chunks/{asset-idle-WIGMUFMD.js → asset-idle-XGB5IPGT.js} +2 -2
- package/dist/chunks/{attachment-content-E3276UOV.js → attachment-content-CE3GMWTS.js} +3 -3
- package/dist/chunks/{blog-C5NMZAAC.js → blog-QSHLZSFW.js} +2 -2
- package/dist/chunks/caizhilian-KCQYFH72.js +204 -0
- package/dist/chunks/{calendar-FI2WNSBO.js → calendar-DLGMRJQA.js} +2 -2
- package/dist/chunks/{chunk-CWYGFU5B.js → chunk-3WBIQLMB.js} +2 -2
- package/dist/chunks/{chunk-PUQS5MWL.js → chunk-3YV7PKRL.js} +1 -1
- package/dist/chunks/{chunk-PC7VKEB5.js → chunk-3ZMAQQ3W.js} +161 -33
- package/dist/chunks/{chunk-GM6J7Q4B.js → chunk-4EXOIQDI.js} +40 -10
- package/dist/chunks/{chunk-ETNJSKMM.js → chunk-6NXT4ICB.js} +148 -21
- package/dist/chunks/chunk-762M5XJS.js +215 -0
- package/dist/chunks/{chunk-GAMZLAG2.js → chunk-77YP6I52.js} +1 -1
- package/dist/chunks/{chunk-WSF4NNMR.js → chunk-CZNZKOHR.js} +2 -2
- package/dist/chunks/{chunk-Z7VYWPZV.js → chunk-DGMYACGJ.js} +1 -1
- package/dist/chunks/{chunk-TA7FXXJD.js → chunk-DLY5GUXX.js} +1 -1
- package/dist/chunks/{chunk-BCVYBYYT.js → chunk-GR76ZDDX.js} +2 -2
- package/dist/chunks/{chunk-GRDRG6HP.js → chunk-HFXK54M4.js} +2 -2
- package/dist/chunks/{chunk-XNIK66I4.js → chunk-JB34OE7R.js} +790 -77
- package/dist/chunks/{chunk-QVSWRLLU.js → chunk-JWWTI63L.js} +55 -5
- package/dist/chunks/{chunk-FRZKBMSW.js → chunk-LGKWL4OH.js} +176 -39
- package/dist/chunks/{chunk-XHK4MDR5.js → chunk-LRCPNDZA.js} +38 -6
- package/dist/chunks/{chunk-OF4S23UB.js → chunk-LXFVWZLM.js} +4 -4
- package/dist/chunks/{chunk-D4ADSZ7H.js → chunk-O6CMPO65.js} +24 -1
- package/dist/chunks/{chunk-N4M2DDFE.js → chunk-OAE3AZBQ.js} +11 -11
- package/dist/chunks/chunk-P5GQRWDC.js +60 -0
- package/dist/chunks/{caizhilian-5XSM2DFP.js → chunk-PGO4ILMQ.js} +41 -521
- package/dist/chunks/{chunk-HIT4Y6OI.js → chunk-T4MWQAQB.js} +7 -5
- package/dist/chunks/{chunk-F4E4EM35.js → chunk-TGAGQV4I.js} +2 -2
- package/dist/chunks/{chunk-UFIT2UU3.js → chunk-U6R6FZHD.js} +168 -14
- package/dist/chunks/{chunk-FAZTGX7S.js → chunk-VIMCY4DI.js} +5 -5
- package/dist/chunks/chunk-VRPH24IC.js +76 -0
- package/dist/chunks/{chunk-3YBDYOC4.js → chunk-YIKSL36S.js} +2 -2
- package/dist/chunks/{chunk-IAZ3UPY6.js → chunk-Z6UUBY37.js} +2 -2
- package/dist/chunks/{conflict-ARLSZJ6V.js → conflict-IYJETSGT.js} +2 -2
- package/dist/chunks/continuation-GW6PRWK3.js +12 -0
- package/dist/chunks/{contract-DNIIW5VJ.js → contract-3QLAGYQL.js} +5793 -4591
- package/dist/chunks/{cowork-GMLRGVIW.js → cowork-3ACICHDQ.js} +2 -2
- package/dist/chunks/{create-flow-J22BO65E.js → create-flow-7JLC7UID.js} +6 -6
- package/dist/chunks/{ebuilder-form-ANV2FHYV.js → ebuilder-form-GWDTKEI2.js} +5 -5
- package/dist/chunks/{ehr-GSTGAIY3.js → ehr-MYRDCHZ4.js} +121 -49
- package/dist/chunks/{employee-22BGJ3QS.js → employee-NOHNXC46.js} +1 -1
- package/dist/chunks/{env-BX3VRFS7.js → env-3MBHAWBL.js} +2 -2
- package/dist/chunks/{esb-ATAIASX2.js → esb-4BQHNP5C.js} +4 -4
- package/dist/chunks/{factory-PETTFME6.js → factory-TZEVU4DU.js} +1 -1
- package/dist/chunks/{fna-YEKBSFSX.js → fna-ZVB2IILI.js} +2 -2
- package/dist/chunks/{group-chat-BFVXAYFX.js → group-chat-KL3HFKRM.js} +3 -3
- package/dist/chunks/{host-WIKN2EJ5.js → host-3TNBMDTR.js} +3 -3
- package/dist/chunks/host-7NTIBSPK.js +25 -0
- package/dist/chunks/{host-SZGV4UNT.js → host-7OWWPLM4.js} +3 -3
- package/dist/chunks/{host-HRBXEPDQ.js → host-G3VU7SDW.js} +3 -3
- package/dist/chunks/{host-LR55CTHP.js → host-M4XP5URR.js} +3 -3
- package/dist/chunks/{host-SUOY6VYQ.js → host-TUOIOEMC.js} +3 -3
- package/dist/chunks/{hrm-NRDO4W5G.js → hrm-UNKCCCGP.js} +5 -5
- package/dist/chunks/{im-IQ2HN23S.js → im-NJB7ZYMH.js} +3 -3
- package/dist/chunks/{invoice-MNRW76PP.js → invoice-OQP3TMKQ.js} +3 -3
- package/dist/chunks/{jiuchuanhui-DTRBAX4N.js → jiuchuanhui-ASFZBMPU.js} +2 -2
- package/dist/chunks/{lazy-dispatch-ZVWAI25B.js → lazy-dispatch-UH6HGK2I.js} +4 -4
- package/dist/chunks/{mail-ZVAUXOJA.js → mail-M3HJF5ER.js} +2 -2
- package/dist/chunks/{meeting-FEVPZ67S.js → meeting-C67EHQ4Z.js} +12 -12
- package/dist/chunks/{okr-SDH3E5RA.js → okr-EVX7FB5G.js} +2 -2
- package/dist/chunks/operations-J7PUIVWZ.js +15 -0
- package/dist/chunks/{plan-E35JFDI7.js → plan-2QJQEPBO.js} +2 -2
- package/dist/chunks/{project-73QXBAB2.js → project-XELELW2T.js} +2 -2
- package/dist/chunks/{reception-UWZVACBN.js → reception-5WITA44R.js} +2 -2
- package/dist/chunks/{recruit-stage-4MAOCKFY.js → recruit-stage-AHY5QAMF.js} +450 -117
- package/dist/chunks/{registry-JDUS4E7D.js → registry-AQVGHUM6.js} +2 -2
- package/dist/chunks/{registry-KNKSCJNT.js → registry-QJCZ2GVG.js} +4 -4
- package/dist/chunks/{registry-PO7SI256.js → registry-VWXWPVAG.js} +2 -2
- package/dist/chunks/{registry-IM5G23LS.js → registry-XPWPGHYE.js} +10 -10
- package/dist/chunks/{room-recommend-H7KLXA5R.js → room-recommend-CNWE5WQK.js} +6 -4
- package/dist/chunks/{schedule-ESZIBAUO.js → schedule-YYNYBQIE.js} +4 -4
- package/dist/chunks/{workflow-CWJFJLQU.js → workflow-BSYT5TGL.js} +6 -4
- package/dist/index.js +30 -30
- package/dist/internal/e10/auth/commands.js +32 -0
- package/dist/internal/e10/auth/error-log.js +156 -26
- package/dist/internal/e10/auth/xiaoe.js +176 -13
- package/dist/internal/e10/context.js +12 -1
- package/dist/shortcuts/archive/operations/borrow-list.js +105 -14
- package/dist/shortcuts/archive/operations/flow-url.js +182 -22
- package/dist/shortcuts/archive/operations/getPageUrl.js +75 -0
- package/dist/shortcuts/archive/operations/prelib.js +33 -4
- package/dist/shortcuts/archive/operations/shared.js +52 -0
- package/dist/shortcuts/contract/host.js +111 -4
- package/dist/shortcuts/contract/index.js +19 -0
- package/dist/shortcuts/contract/manifest.js +125 -0
- package/dist/shortcuts/contract/ooxml/clause-insert.js +249 -0
- package/dist/shortcuts/contract/operations/clause-insert.js +56 -0
- package/dist/shortcuts/contract/operations/customer.js +192 -0
- package/dist/shortcuts/contract/operations/file-download.js +75 -0
- package/dist/shortcuts/contract/operations/flow.js +44 -2
- package/dist/shortcuts/contract/operations/form-info.js +162 -62
- package/dist/shortcuts/contract/operations/registry.js +8 -0
- package/dist/shortcuts/contract/operations/review.js +116 -1
- package/dist/shortcuts/contract/operations/summary.js +177 -0
- package/dist/shortcuts/contract/operations/upload.js +64 -4
- package/dist/shortcuts/contract/upload-cache.js +104 -0
- package/dist/shortcuts/ehr/operations/recruit-candidate-import.js +4 -2
- package/dist/shortcuts/ehr/operations/recruit-position.js +136 -35
- package/dist/shortcuts/ehr/operations/recruit-write.js +17 -18
- package/dist/shortcuts/ehr/operations/recruit.js +17 -5
- package/dist/shortcuts/hrm/operations/employee.js +29 -1
- package/dist/shortcuts/meeting/operations/eb/create-flow.js +182 -58
- package/dist/shortcuts/meeting/operations/eb/draft-memory.js +56 -0
- package/dist/shortcuts/meeting/operations/eb/factory.js +58 -3
- package/dist/shortcuts/meeting/operations/eb/person-cache.js +2 -2
- package/dist/shortcuts/meeting/operations/eb/room-recommend.js +47 -5
- package/dist/shortcuts/meeting/operations/invitation-publish.js +132 -0
- package/dist/shortcuts/meeting/operations/registry.js +2 -0
- package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +86 -16
- package/dist/shortcuts/recruit-stage/operations/interview-feedback.js +6 -4
- package/dist/shortcuts/recruit-stage/operations/jd-create.js +208 -56
- package/dist/shortcuts/recruit-stage/operations/resume-import.js +42 -16
- package/dist/shortcuts/recruit-stage/shared.js +161 -18
- package/dist/shortcuts/workflow/index.js +2 -0
- package/dist/shortcuts/workflow/operations/read.js +8 -3
- package/dist/shortcuts/workflow/operations/todoSmartConvert/aigroupRules.js +92 -5
- package/dist/shortcuts/workflow/operations/todoSmartConvert/priorityExpr.js +509 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoListRows.js +22 -1
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +32 -6
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +57 -11
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.group.js +165 -52
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +57 -14
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.smartGroup.js +44 -18
- package/docs/contract.md +1 -0
- package/docs/e10-auth.md +4 -2
- package/docs/todo-smart-convert/data-contract.md +7 -0
- package/package.json +1 -1
- package/skill-template/domains/jinchengda.md +2 -0
- package/skills/weaver-e10-jinchengda/SKILL.md +198 -205
- package/skills/weaver-e10-jinchengda/references/contract-action-card.md +759 -0
- package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +250 -0
- package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +146 -7
- package/skills/weaver-e10-jinchengda/references/contract-clause-insert.md +178 -0
- package/skills/weaver-e10-jinchengda/references/contract-command-index.md +75 -0
- package/skills/weaver-e10-jinchengda/references/contract-compare-report-template.html +137 -0
- package/skills/weaver-e10-jinchengda/references/contract-compare-report.md +163 -0
- package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +52 -3
- package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +92 -5
- package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +602 -0
- package/skills/weaver-e10-jinchengda/references/contract-element-extract.md +209 -0
- package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +126 -0
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +312 -0
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +555 -0
- package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +47 -12
- package/skills/weaver-e10-jinchengda/references/contract-object-detect.md +469 -0
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +154 -1
- package/skills/weaver-e10-jinchengda/references/contract-type-fingerprints.md +224 -0
- package/skills/weaver-e10-jinchengda/references/orchestration.md +355 -0
- package/skills/weaver-e10-jucailin/references/recruit-create.md +5 -3
- package/skills/weaver-e10-jucailin/references/recruit-write.md +2 -2
- package/skills/weaver-e10-meeting/SKILL.md +57 -9
- package/skills/weaver-e10-recruit-stage/SKILL.md +11 -6
- package/skills/weaver-e10-recruit-stage/agents/openai.yaml +10 -2
- package/skills/weaver-e10-recruit-stage/references/position-templates.md +3 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +13 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +19 -18
- package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +27 -14
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +7 -1
- package/skills/weaver-e10-shared/references/e10-auth-and-session.md +4 -2
- package/skills/weaver-e10-wenshuding/SKILL.md +17 -7
- package/skills/weaver-e10-wenshuding/references/archive-borrow-list.md +28 -0
- package/skills/weaver-e10-wenshuding/references/archive-flow.md +24 -8
- package/skills/weaver-e10-wenshuding/references/archive-prelib-list.md +3 -0
- package/skills/weaver-e10-wenshuding/references/archive-prelib-open.md +4 -0
- package/skills/weaver-e10-wenshuding/references/archive-search.md +3 -1
- package/skills/weaver-e10-workflow/SKILL.md +19 -17
- package/skills/weaver-e10-workflow/aigroup/default.json +10 -6
- package/skills/weaver-e10-workflow/references/todo-smart-convert.md +36 -3
- package/skills/weaver-e10-workflow/references/workflow-memory.md +1 -1
- package/skills/weaver-e10-workflow/references/workflow-query.md +9 -6
- package/skills/weaver-e10-workflow/tools/todo-summary.cjs +152 -1
- package/skills/weaver-e10-yimiaoban/SKILL.md +17 -5
- package/skills/weaver-e10-yimiaoban/references/msg-write.md +30 -0
- package/skills/weaver-e10-yimiaoban/references/session-sysmsg.md +72 -0
- package/skills/weaver-e10-yimiaoban/references/source-manifest.json +7 -7
|
@@ -1,330 +1,20 @@
|
|
|
1
1
|
import { createRequire as __esbuildCreateRequire } from 'node:module';
|
|
2
2
|
const require = __esbuildCreateRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
CAIZHILAN_MAX_DOWNLOAD_BYTES,
|
|
5
|
+
CAIZHILAN_TRANSFER_TIMEOUT_MS,
|
|
6
|
+
caizhilianBusinessMessage,
|
|
7
|
+
isCaizhilianBusinessSuccess
|
|
8
|
+
} from "./chunk-762M5XJS.js";
|
|
9
|
+
import {
|
|
10
|
+
CaizhilianCliError,
|
|
11
|
+
caizhilianAuthError,
|
|
12
|
+
caizhilianConfirmationError,
|
|
13
|
+
caizhilianValidationError
|
|
14
|
+
} from "./chunk-P5GQRWDC.js";
|
|
6
15
|
import {
|
|
7
16
|
CONTINUATION_TTL_MS
|
|
8
17
|
} from "./chunk-7BDPM5ST.js";
|
|
9
|
-
import {
|
|
10
|
-
E10ApiError,
|
|
11
|
-
createE10RequestRuntime,
|
|
12
|
-
isE10SessionExpiredResponse,
|
|
13
|
-
requireE10Session
|
|
14
|
-
} from "./chunk-ETNJSKMM.js";
|
|
15
|
-
import {
|
|
16
|
-
E10_SESSION_EXPIRED_MESSAGE,
|
|
17
|
-
getActiveProfile
|
|
18
|
-
} from "./chunk-UFIT2UU3.js";
|
|
19
|
-
import {
|
|
20
|
-
CliError,
|
|
21
|
-
isCliError,
|
|
22
|
-
toErrorEnvelope
|
|
23
|
-
} from "./chunk-UG5G54VL.js";
|
|
24
|
-
import "./chunk-BUSC6UAE.js";
|
|
25
|
-
|
|
26
|
-
// src/shortcuts/caizhilian/index.ts
|
|
27
|
-
import { readFile as readFile5 } from "node:fs/promises";
|
|
28
|
-
|
|
29
|
-
// src/shortcuts/caizhilian/continuation.ts
|
|
30
|
-
import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
|
|
31
|
-
import { existsSync } from "node:fs";
|
|
32
|
-
import { chmod, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
33
|
-
import { homedir } from "node:os";
|
|
34
|
-
import { resolve } from "node:path";
|
|
35
|
-
|
|
36
|
-
// src/shortcuts/caizhilian/errors.ts
|
|
37
|
-
var CaizhilianCliError = class extends CliError {
|
|
38
|
-
type;
|
|
39
|
-
subtype;
|
|
40
|
-
code;
|
|
41
|
-
retryable;
|
|
42
|
-
stage;
|
|
43
|
-
details;
|
|
44
|
-
partialData;
|
|
45
|
-
constructor(type, subtype, message, options = {}) {
|
|
46
|
-
super(message, options.exitCode ?? 5 /* InternalError */);
|
|
47
|
-
this.name = "CaizhilianCliError";
|
|
48
|
-
this.type = type;
|
|
49
|
-
this.subtype = subtype;
|
|
50
|
-
this.code = options.code;
|
|
51
|
-
this.retryable = options.retryable ?? false;
|
|
52
|
-
this.stage = options.stage;
|
|
53
|
-
this.details = options.details;
|
|
54
|
-
this.partialData = options.partialData;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
function caizhilianValidationError(subtype, message, details) {
|
|
58
|
-
return new CaizhilianCliError("validation", subtype, message, {
|
|
59
|
-
details,
|
|
60
|
-
exitCode: 2 /* UsageError */
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
function caizhilianAuthError(subtype, message, details) {
|
|
64
|
-
return new CaizhilianCliError("authentication", subtype, message, {
|
|
65
|
-
details,
|
|
66
|
-
exitCode: 3 /* AuthError */
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
function caizhilianNetworkError(subtype, message, options = {}) {
|
|
70
|
-
return new CaizhilianCliError("network", subtype, message, {
|
|
71
|
-
...options,
|
|
72
|
-
retryable: options.retryable ?? true,
|
|
73
|
-
exitCode: 4 /* NetworkError */
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
function caizhilianConfirmationError(action, details) {
|
|
77
|
-
return new CaizhilianCliError("confirmation", "required", "\u8BE5\u64CD\u4F5C\u9700\u8981\u660E\u786E\u786E\u8BA4", {
|
|
78
|
-
details: { action, ...details },
|
|
79
|
-
exitCode: 10 /* ConfirmationRequired */
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// src/shortcuts/caizhilian/continuation.ts
|
|
84
|
-
function stateRoot(ctx) {
|
|
85
|
-
const configured = ctx?.config?.path();
|
|
86
|
-
if (configured) return resolve(configured, "..");
|
|
87
|
-
return process.env.WEAVER_WORK_CLI_HOME || process.env.WORK_CLI_HOME || resolve(homedir(), ".weaver-work-cli");
|
|
88
|
-
}
|
|
89
|
-
async function loadKey(ctx) {
|
|
90
|
-
const keysDir = resolve(stateRoot(ctx), "keys");
|
|
91
|
-
const filename = resolve(keysDir, "caizhilian-continuation.key");
|
|
92
|
-
await mkdir(keysDir, { recursive: true, mode: 448 });
|
|
93
|
-
if (existsSync(filename)) return readFile(filename);
|
|
94
|
-
const key = randomBytes(32);
|
|
95
|
-
try {
|
|
96
|
-
await writeFile(filename, key, { flag: "wx", mode: 384 });
|
|
97
|
-
if (process.platform !== "win32") await chmod(filename, 384).catch(() => void 0);
|
|
98
|
-
return key;
|
|
99
|
-
} catch {
|
|
100
|
-
return readFile(filename);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
function encode(value) {
|
|
104
|
-
return Buffer.from(JSON.stringify(value)).toString("base64url");
|
|
105
|
-
}
|
|
106
|
-
function signature(payload, key) {
|
|
107
|
-
return createHmac("sha256", key).update(payload).digest("base64url");
|
|
108
|
-
}
|
|
109
|
-
function createCaizhilianContinuationSigner(ctx) {
|
|
110
|
-
return {
|
|
111
|
-
async issue(payload, ttlMs = CONTINUATION_TTL_MS) {
|
|
112
|
-
const issuedAt = Date.now();
|
|
113
|
-
const body = encode({ ...payload, issuedAt, expiresAt: issuedAt + ttlMs });
|
|
114
|
-
const sig = signature(body, await loadKey(ctx));
|
|
115
|
-
return `${body}.${sig}`;
|
|
116
|
-
},
|
|
117
|
-
async verify(token, expectedOperation) {
|
|
118
|
-
if (typeof token !== "string" || !token.includes(".")) {
|
|
119
|
-
throw caizhilianValidationError("continuation_invalid", "continuation \u65E0\u6548");
|
|
120
|
-
}
|
|
121
|
-
const [body, provided] = token.split(".");
|
|
122
|
-
const expected = signature(body, await loadKey(ctx));
|
|
123
|
-
const valid = provided.length === expected.length && timingSafeEqual(Buffer.from(provided), Buffer.from(expected));
|
|
124
|
-
if (!valid) throw caizhilianValidationError("continuation_invalid", "continuation \u7B7E\u540D\u6821\u9A8C\u5931\u8D25");
|
|
125
|
-
let value;
|
|
126
|
-
try {
|
|
127
|
-
value = JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
|
|
128
|
-
} catch {
|
|
129
|
-
throw caizhilianValidationError("continuation_invalid", "continuation \u5185\u5BB9\u65E0\u6CD5\u89E3\u6790");
|
|
130
|
-
}
|
|
131
|
-
if (value.operation !== expectedOperation) {
|
|
132
|
-
throw caizhilianValidationError("continuation_mismatch", "continuation \u4E0D\u5C5E\u4E8E\u5F53\u524D\u64CD\u4F5C");
|
|
133
|
-
}
|
|
134
|
-
if (!Number.isSafeInteger(value.expiresAt) || value.expiresAt < Date.now()) {
|
|
135
|
-
throw caizhilianValidationError("continuation_expired", "continuation \u5DF2\u8FC7\u671F");
|
|
136
|
-
}
|
|
137
|
-
return value;
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// src/shortcuts/caizhilian/host.ts
|
|
143
|
-
var CAIZHILAN_TIMEOUT_MS = 12e3;
|
|
144
|
-
var CAIZHILAN_TRANSFER_TIMEOUT_MS = 12e4;
|
|
145
|
-
var CAIZHILAN_MAX_DOWNLOAD_BYTES = 100 * 1024 * 1024;
|
|
146
|
-
function inferProfile(ctx) {
|
|
147
|
-
const options = ctx.getGlobalOptions();
|
|
148
|
-
return options.profile || getActiveProfile();
|
|
149
|
-
}
|
|
150
|
-
function isCaizhilianBusinessSuccess(value) {
|
|
151
|
-
if (!value || typeof value !== "object") return false;
|
|
152
|
-
if (value.code !== void 0 && value.code !== null) return Number(value.code) === 200;
|
|
153
|
-
if (typeof value.success === "boolean") return value.success;
|
|
154
|
-
if (typeof value.status === "boolean") return value.status;
|
|
155
|
-
return false;
|
|
156
|
-
}
|
|
157
|
-
function caizhilianBusinessMessage(value) {
|
|
158
|
-
if (!value || typeof value !== "object") return "\u91C7\u77E5\u8FDE\u63A5\u53E3\u8FD4\u56DE\u4E1A\u52A1\u5931\u8D25";
|
|
159
|
-
const candidates = [value.msg, value.message, value.errMsg, value.data?.msg, value.data?.message];
|
|
160
|
-
for (const item of candidates) {
|
|
161
|
-
if (typeof item === "string" && item.trim()) return item;
|
|
162
|
-
}
|
|
163
|
-
return "\u91C7\u77E5\u8FDE\u63A5\u53E3\u8FD4\u56DE\u4E1A\u52A1\u5931\u8D25";
|
|
164
|
-
}
|
|
165
|
-
function caizhilianBusinessCode(value) {
|
|
166
|
-
if (!value || typeof value !== "object") return void 0;
|
|
167
|
-
const code = value.code ?? value.status;
|
|
168
|
-
if (typeof code === "string" || typeof code === "number") return code;
|
|
169
|
-
return void 0;
|
|
170
|
-
}
|
|
171
|
-
function assertCaizhilianPath(requestPath) {
|
|
172
|
-
if (typeof requestPath !== "string" || !requestPath.startsWith("/") || requestPath.startsWith("//")) {
|
|
173
|
-
throw caizhilianValidationError("path_invalid", "\u8BF7\u6C42\u8DEF\u5F84\u5FC5\u987B\u662F\u76F8\u5BF9\u7EDD\u5BF9\u8DEF\u5F84");
|
|
174
|
-
}
|
|
175
|
-
if (/^https?:/i.test(requestPath) || /[\r\n]/.test(requestPath) || requestPath.includes("/../")) {
|
|
176
|
-
throw caizhilianValidationError("path_invalid", "\u8BF7\u6C42\u8DEF\u5F84\u4E0D\u5141\u8BB8\u8DE8\u57DF\u6216\u8DEF\u5F84\u9003\u9038");
|
|
177
|
-
}
|
|
178
|
-
if (!requestPath.startsWith("/api/")) {
|
|
179
|
-
throw caizhilianValidationError("path_not_allowed", "\u91C7\u77E5\u8FDE\u6A21\u5757\u53EA\u80FD\u8C03\u7528 /api/ \u8DEF\u5F84");
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
function formBody(form) {
|
|
183
|
-
if (!form) return void 0;
|
|
184
|
-
const params = new URLSearchParams();
|
|
185
|
-
for (const [key, value] of Object.entries(form)) {
|
|
186
|
-
if (value === void 0 || value === null) continue;
|
|
187
|
-
params.set(key, typeof value === "string" ? value : JSON.stringify(value));
|
|
188
|
-
}
|
|
189
|
-
return params;
|
|
190
|
-
}
|
|
191
|
-
function omitEmptyQueryValues(query) {
|
|
192
|
-
if (!query) return void 0;
|
|
193
|
-
return Object.fromEntries(Object.entries(query).filter(([, value]) => value !== ""));
|
|
194
|
-
}
|
|
195
|
-
function mapRuntimeNetworkError(error) {
|
|
196
|
-
if (error instanceof E10ApiError && error.type === "network") {
|
|
197
|
-
throw caizhilianNetworkError(error.subtype, error.message, {
|
|
198
|
-
retryable: error.retryable,
|
|
199
|
-
details: error.details
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
throw error;
|
|
203
|
-
}
|
|
204
|
-
function createCaizhilianHost(ctx, dependencies = {}) {
|
|
205
|
-
let e10Session = null;
|
|
206
|
-
let sessionContext = null;
|
|
207
|
-
const requireSession = dependencies.requireSession || requireE10Session;
|
|
208
|
-
async function ensureSession() {
|
|
209
|
-
if (!e10Session) {
|
|
210
|
-
e10Session = await requireSession(ctx);
|
|
211
|
-
sessionContext = {
|
|
212
|
-
baseUrl: e10Session.getBaseUrl(),
|
|
213
|
-
profile: inferProfile(ctx),
|
|
214
|
-
userId: e10Session.userId,
|
|
215
|
-
tenantKey: e10Session.tenantKey,
|
|
216
|
-
eteamsId: e10Session.eteamsId
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
return e10Session;
|
|
220
|
-
}
|
|
221
|
-
async function getSession() {
|
|
222
|
-
await ensureSession();
|
|
223
|
-
return sessionContext;
|
|
224
|
-
}
|
|
225
|
-
async function runtime() {
|
|
226
|
-
return createE10RequestRuntime(ctx, await ensureSession(), {
|
|
227
|
-
interceptors: dependencies.interceptors,
|
|
228
|
-
fetch: dependencies.fetch
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
async function doRequest(request2, binary) {
|
|
232
|
-
const {
|
|
233
|
-
method,
|
|
234
|
-
path,
|
|
235
|
-
query,
|
|
236
|
-
body,
|
|
237
|
-
operation,
|
|
238
|
-
form,
|
|
239
|
-
multipart,
|
|
240
|
-
streamMultipart,
|
|
241
|
-
maxResponseBytes,
|
|
242
|
-
headers: extraHeaders = {},
|
|
243
|
-
timeoutMs = CAIZHILAN_TIMEOUT_MS
|
|
244
|
-
} = request2;
|
|
245
|
-
assertCaizhilianPath(path);
|
|
246
|
-
const resolvedMethod = method || (body === void 0 && form === void 0 && multipart === void 0 && streamMultipart === void 0 ? "GET" : "POST");
|
|
247
|
-
const headers = { "X-Requested-With": "XMLHttpRequest", ...extraHeaders, ...streamMultipart ? {
|
|
248
|
-
"Content-Type": streamMultipart.contentType,
|
|
249
|
-
"Content-Length": String(streamMultipart.contentLength)
|
|
250
|
-
} : {} };
|
|
251
|
-
const rt = await runtime();
|
|
252
|
-
const response = binary ? await rt.requestBinary({
|
|
253
|
-
module: "caizhilian",
|
|
254
|
-
operation,
|
|
255
|
-
method: resolvedMethod,
|
|
256
|
-
path,
|
|
257
|
-
query: omitEmptyQueryValues(query),
|
|
258
|
-
body: multipart === void 0 ? body : void 0,
|
|
259
|
-
form: multipart === void 0 && form === void 0 ? void 0 : formBody(form ?? {}),
|
|
260
|
-
formData: multipart,
|
|
261
|
-
streamBody: streamMultipart?.body,
|
|
262
|
-
maxResponseBytes,
|
|
263
|
-
headers,
|
|
264
|
-
timeoutMs
|
|
265
|
-
}) : await rt.requestJson({
|
|
266
|
-
module: "caizhilian",
|
|
267
|
-
operation,
|
|
268
|
-
method: resolvedMethod,
|
|
269
|
-
path,
|
|
270
|
-
query: omitEmptyQueryValues(query),
|
|
271
|
-
body: multipart === void 0 ? body : void 0,
|
|
272
|
-
form: multipart === void 0 && form === void 0 ? void 0 : formBody(form ?? {}),
|
|
273
|
-
formData: multipart,
|
|
274
|
-
streamBody: streamMultipart?.body,
|
|
275
|
-
maxResponseBytes,
|
|
276
|
-
headers,
|
|
277
|
-
timeoutMs
|
|
278
|
-
});
|
|
279
|
-
return response;
|
|
280
|
-
}
|
|
281
|
-
async function request(request2) {
|
|
282
|
-
const response = await doRequest(request2, false).catch((error) => mapRuntimeNetworkError(error));
|
|
283
|
-
if (isE10SessionExpiredResponse(response)) {
|
|
284
|
-
throw caizhilianAuthError("session_expired", E10_SESSION_EXPIRED_MESSAGE, { httpStatus: response.status });
|
|
285
|
-
}
|
|
286
|
-
if (response.parseError) {
|
|
287
|
-
if (response.status < 200 || response.status >= 300) {
|
|
288
|
-
throw new CaizhilianCliError("api", "http_error", `\u91C7\u77E5\u8FDE\u63A5\u53E3 HTTP ${response.status}`, {
|
|
289
|
-
code: response.status,
|
|
290
|
-
details: { status: response.status },
|
|
291
|
-
exitCode: 1
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
throw caizhilianNetworkError("protocol", `\u63A5\u53E3\u8FD4\u56DE\u4E0D\u662F\u5408\u6CD5 JSON\uFF08HTTP ${response.status}\uFF09`, { retryable: false });
|
|
295
|
-
}
|
|
296
|
-
if (response.status < 200 || response.status >= 300 || request2.requireHttp200 && response.status !== 200) {
|
|
297
|
-
throw new CaizhilianCliError("api", "http_error", `\u91C7\u77E5\u8FDE\u63A5\u53E3 HTTP ${response.status}`, {
|
|
298
|
-
code: response.status,
|
|
299
|
-
details: { status: response.status, message: caizhilianBusinessMessage(response.value) },
|
|
300
|
-
exitCode: 1
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
if (!request2.tolerateBusinessError && !isCaizhilianBusinessSuccess(response.value)) {
|
|
304
|
-
throw new CaizhilianCliError("api", "business_error", caizhilianBusinessMessage(response.value), {
|
|
305
|
-
code: caizhilianBusinessCode(response.value),
|
|
306
|
-
details: { code: caizhilianBusinessCode(response.value), message: caizhilianBusinessMessage(response.value) },
|
|
307
|
-
exitCode: 1
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
return response.value;
|
|
311
|
-
}
|
|
312
|
-
async function requestBinary(request2) {
|
|
313
|
-
const response = await doRequest(request2, true).catch((error) => mapRuntimeNetworkError(error));
|
|
314
|
-
if (isE10SessionExpiredResponse(response)) {
|
|
315
|
-
throw caizhilianAuthError("session_expired", E10_SESSION_EXPIRED_MESSAGE, { httpStatus: response.status });
|
|
316
|
-
}
|
|
317
|
-
if (response.status < 200 || response.status >= 300) {
|
|
318
|
-
throw new CaizhilianCliError("api", "http_error", `\u91C7\u77E5\u8FDE\u4E0B\u8F7D HTTP ${response.status}`, {
|
|
319
|
-
code: response.status,
|
|
320
|
-
details: { status: response.status },
|
|
321
|
-
exitCode: 1
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
return { status: response.status, contentType: response.contentType, content: response.content, headers: response.headers };
|
|
325
|
-
}
|
|
326
|
-
return { request, requestBinary, getSession };
|
|
327
|
-
}
|
|
328
18
|
|
|
329
19
|
// src/shortcuts/caizhilian/operations/shared.ts
|
|
330
20
|
import { createHash } from "node:crypto";
|
|
@@ -2106,14 +1796,14 @@ var caizhilianCollabHandlers = {
|
|
|
2106
1796
|
};
|
|
2107
1797
|
|
|
2108
1798
|
// src/shortcuts/caizhilian/operations/handlers/document.ts
|
|
2109
|
-
import { readFile as
|
|
1799
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
2110
1800
|
import { basename as basename2, extname as extname2 } from "node:path";
|
|
2111
1801
|
|
|
2112
1802
|
// src/shortcuts/caizhilian/operations/files.ts
|
|
2113
1803
|
import { createHash as createHash2 } from "node:crypto";
|
|
2114
|
-
import { existsSync
|
|
2115
|
-
import { mkdir
|
|
2116
|
-
import { basename, dirname, extname, join, resolve
|
|
1804
|
+
import { existsSync } from "node:fs";
|
|
1805
|
+
import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
1806
|
+
import { basename, dirname, extname, join, resolve } from "node:path";
|
|
2117
1807
|
var TRANSFER_TIMEOUT_MS = CAIZHILAN_TRANSFER_TIMEOUT_MS;
|
|
2118
1808
|
var IMAGE_ALLOWED_EXT = [".bmp", ".gif", ".jpeg", ".jpg", ".png", ".webp"];
|
|
2119
1809
|
var EXT_TO_CONTENT_TYPE = {
|
|
@@ -2170,14 +1860,14 @@ async function readFileMetadata(filePath) {
|
|
|
2170
1860
|
if (!info.isFile()) throw caizhilianValidationError("file_not_found", `\u6587\u4EF6\u4E0D\u5B58\u5728: ${text}`);
|
|
2171
1861
|
let content;
|
|
2172
1862
|
try {
|
|
2173
|
-
content = await
|
|
1863
|
+
content = await readFile(text);
|
|
2174
1864
|
} catch {
|
|
2175
1865
|
throw caizhilianValidationError("file_unreadable", `\u65E0\u6CD5\u8BFB\u53D6\u6587\u4EF6: ${text}`);
|
|
2176
1866
|
}
|
|
2177
1867
|
const name = basename(text);
|
|
2178
1868
|
const ext = extname(name);
|
|
2179
1869
|
return {
|
|
2180
|
-
path:
|
|
1870
|
+
path: resolve(text),
|
|
2181
1871
|
name,
|
|
2182
1872
|
size: content.length,
|
|
2183
1873
|
md5: createHash2("md5").update(content).digest("hex"),
|
|
@@ -2308,8 +1998,8 @@ async function downloadAttachment(host, request) {
|
|
|
2308
1998
|
);
|
|
2309
1999
|
}
|
|
2310
2000
|
const target = renameIfExists(await resolveTargetPath(savePath, response.headers, path));
|
|
2311
|
-
await
|
|
2312
|
-
await
|
|
2001
|
+
await mkdir(dirname(target), { recursive: true });
|
|
2002
|
+
await writeFile(target, response.content);
|
|
2313
2003
|
return { file_path: target, file_name: basename(target), file_size: response.content.length };
|
|
2314
2004
|
}
|
|
2315
2005
|
function resolveSavePathArg(savePath) {
|
|
@@ -2323,7 +2013,7 @@ function resolveSavePathArg(savePath) {
|
|
|
2323
2013
|
);
|
|
2324
2014
|
}
|
|
2325
2015
|
async function resolveTargetPath(savePath, headers, urlPath) {
|
|
2326
|
-
const absolute =
|
|
2016
|
+
const absolute = resolve(savePath);
|
|
2327
2017
|
const looksLikeDir = savePath.endsWith("/") || savePath.endsWith("\\");
|
|
2328
2018
|
if (!looksLikeDir) return absolute;
|
|
2329
2019
|
return join(absolute, extractDownloadFilename(headers, urlPath));
|
|
@@ -2364,7 +2054,7 @@ function renameIfExists(target) {
|
|
|
2364
2054
|
}
|
|
2365
2055
|
function existsSyncSafe(path) {
|
|
2366
2056
|
try {
|
|
2367
|
-
return
|
|
2057
|
+
return existsSync(path);
|
|
2368
2058
|
} catch {
|
|
2369
2059
|
return false;
|
|
2370
2060
|
}
|
|
@@ -2498,7 +2188,7 @@ function createPreview(docType, body) {
|
|
|
2498
2188
|
async function readMarkdownFile(filePath) {
|
|
2499
2189
|
let buffer;
|
|
2500
2190
|
try {
|
|
2501
|
-
buffer = await
|
|
2191
|
+
buffer = await readFile2(filePath);
|
|
2502
2192
|
} catch (error) {
|
|
2503
2193
|
throw caizhilianValidationError(
|
|
2504
2194
|
"file_unreadable",
|
|
@@ -4257,7 +3947,7 @@ async function waitScanCompletion(args, env) {
|
|
|
4257
3947
|
progress: result
|
|
4258
3948
|
});
|
|
4259
3949
|
}
|
|
4260
|
-
await new Promise((
|
|
3950
|
+
await new Promise((resolve3) => setTimeout(resolve3, intervalSeconds * 1e3));
|
|
4261
3951
|
}
|
|
4262
3952
|
throw new CaizhilianCliError("api", "timeout", `\u626B\u63CF\u7B49\u5F85\u8D85\u65F6\uFF08${timeoutSeconds}\u79D2\uFF09`, {
|
|
4263
3953
|
details: { runtime_id: runtimeId, timeout_seconds: timeoutSeconds },
|
|
@@ -5032,7 +4722,7 @@ var caizhilianFileopsHandlers = {
|
|
|
5032
4722
|
// src/shortcuts/caizhilian/file-upload/metadata.ts
|
|
5033
4723
|
import { createHash as createHash3 } from "node:crypto";
|
|
5034
4724
|
import { constants } from "node:fs";
|
|
5035
|
-
import { lstat, open, readFile as
|
|
4725
|
+
import { lstat, open, readFile as readFile3 } from "node:fs/promises";
|
|
5036
4726
|
import { basename as basename3, extname as extname3, isAbsolute } from "node:path";
|
|
5037
4727
|
var RESERVED_CONTEXT_FIELDS = [
|
|
5038
4728
|
"sf_request_type",
|
|
@@ -5135,7 +4825,7 @@ async function readUploadContext(value) {
|
|
|
5135
4825
|
if (value !== void 0 && value !== "") {
|
|
5136
4826
|
const { path, info } = await regularFile(value, "context_file");
|
|
5137
4827
|
if (info.size > 64 * 1024) throw caizhilianValidationError("context_too_large", "\u4E1A\u52A1\u4E0A\u4E0B\u6587\u4E0D\u80FD\u8D85\u8FC7 64 KiB");
|
|
5138
|
-
const content = await
|
|
4828
|
+
const content = await readFile3(path, { flag: READ_FLAGS });
|
|
5139
4829
|
if (content.length > 64 * 1024) throw caizhilianValidationError("context_too_large", "\u4E1A\u52A1\u4E0A\u4E0B\u6587\u4E0D\u80FD\u8D85\u8FC7 64 KiB");
|
|
5140
4830
|
try {
|
|
5141
4831
|
fields = JSON.parse(content.toString("utf8"));
|
|
@@ -5174,7 +4864,7 @@ function uploadTimeout(value) {
|
|
|
5174
4864
|
}
|
|
5175
4865
|
|
|
5176
4866
|
// src/shortcuts/caizhilian/file-upload/multipart.ts
|
|
5177
|
-
import { randomBytes
|
|
4867
|
+
import { randomBytes } from "node:crypto";
|
|
5178
4868
|
import { open as open2 } from "node:fs/promises";
|
|
5179
4869
|
import { Readable } from "node:stream";
|
|
5180
4870
|
function quoted(value) {
|
|
@@ -5184,7 +4874,7 @@ function encodedFilename(value) {
|
|
|
5184
4874
|
return encodeURIComponent(value).replace(/[!'()*]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
5185
4875
|
}
|
|
5186
4876
|
function uploadMultipart(fields, file) {
|
|
5187
|
-
const boundary = `weaver-${
|
|
4877
|
+
const boundary = `weaver-${randomBytes(16).toString("hex")}`;
|
|
5188
4878
|
const parts = [];
|
|
5189
4879
|
for (const [key, value] of Object.entries(fields)) {
|
|
5190
4880
|
const text = value === null || value === void 0 ? "" : typeof value === "string" ? value : JSON.stringify(value);
|
|
@@ -5361,9 +5051,9 @@ async function uploadToFileService(host, file, module, context, timeoutMs) {
|
|
|
5361
5051
|
|
|
5362
5052
|
// src/shortcuts/caizhilian/file-upload/receipt.ts
|
|
5363
5053
|
import { createHash as createHash4, randomUUID as randomUUID2 } from "node:crypto";
|
|
5364
|
-
import { chmod
|
|
5365
|
-
import { homedir
|
|
5366
|
-
import { dirname as dirname2, resolve as
|
|
5054
|
+
import { chmod, mkdir as mkdir2, writeFile as writeFile2 } from "node:fs/promises";
|
|
5055
|
+
import { homedir } from "node:os";
|
|
5056
|
+
import { dirname as dirname2, resolve as resolve2 } from "node:path";
|
|
5367
5057
|
async function writeUploadReceipt(env, chatId, module, file, context, verified) {
|
|
5368
5058
|
const session = await env.host.getSession();
|
|
5369
5059
|
const identity = JSON.stringify({ baseUrl: session.baseUrl, userId: session.userId, tenantKey: session.tenantKey });
|
|
@@ -5391,15 +5081,15 @@ async function writeUploadReceipt(env, chatId, module, file, context, verified)
|
|
|
5391
5081
|
}
|
|
5392
5082
|
};
|
|
5393
5083
|
const configPath = env.ctx.config?.path();
|
|
5394
|
-
const
|
|
5395
|
-
const directory =
|
|
5396
|
-
const filename =
|
|
5084
|
+
const stateRoot = configPath ? dirname2(configPath) : env.ctx.env?.WEAVER_WORK_CLI_HOME || env.ctx.env?.WORK_CLI_HOME || resolve2(homedir(), ".weaver-work-cli");
|
|
5085
|
+
const directory = resolve2(stateRoot, "caizhilian", "file-upload", "runs", chatId, "receipts");
|
|
5086
|
+
const filename = resolve2(directory, `upload-${randomUUID2()}.json`);
|
|
5397
5087
|
const content = `${JSON.stringify(result, null, 2)}
|
|
5398
5088
|
`;
|
|
5399
5089
|
try {
|
|
5400
|
-
await
|
|
5401
|
-
if (process.platform !== "win32") await
|
|
5402
|
-
await
|
|
5090
|
+
await mkdir2(directory, { recursive: true, mode: 448 });
|
|
5091
|
+
if (process.platform !== "win32") await chmod(directory, 448);
|
|
5092
|
+
await writeFile2(filename, content, { flag: "wx", mode: 384 });
|
|
5403
5093
|
} catch {
|
|
5404
5094
|
throw new CaizhilianCliError("partial", "receipt_write_failed", "\u6587\u4EF6\u5DF2\u4E0A\u4F20\uFF0C\u4F46\u672C\u5730\u56DE\u6267\u4FDD\u5B58\u5931\u8D25\uFF1B\u8BF7\u52FF\u91CD\u590D\u4E0A\u4F20", {
|
|
5405
5095
|
retryable: false,
|
|
@@ -7727,7 +7417,7 @@ var permissionSyncParticipantHandler = {
|
|
|
7727
7417
|
const deadline = Date.now() + PROGRESS_POLL_TIMEOUT_MS;
|
|
7728
7418
|
let progress = 0;
|
|
7729
7419
|
while (Date.now() < deadline) {
|
|
7730
|
-
await new Promise((
|
|
7420
|
+
await new Promise((resolve3) => setTimeout(resolve3, PROGRESS_POLL_INTERVAL_MS));
|
|
7731
7421
|
try {
|
|
7732
7422
|
const progressResponse = await env.host.request({
|
|
7733
7423
|
method: "GET",
|
|
@@ -7863,7 +7553,7 @@ var permissionSyncDefaultShareHandler = {
|
|
|
7863
7553
|
const deadline = Date.now() + PROGRESS_POLL_TIMEOUT_MS;
|
|
7864
7554
|
let progress = 0;
|
|
7865
7555
|
while (Date.now() < deadline) {
|
|
7866
|
-
await new Promise((
|
|
7556
|
+
await new Promise((resolve3) => setTimeout(resolve3, PROGRESS_POLL_INTERVAL_MS));
|
|
7867
7557
|
try {
|
|
7868
7558
|
const progressResponse = await env.host.request({
|
|
7869
7559
|
method: "GET",
|
|
@@ -9918,178 +9608,8 @@ async function executeCaizhilianOperation(operation, rawInput, context) {
|
|
|
9918
9608
|
return definition.handler(normalized, context);
|
|
9919
9609
|
}
|
|
9920
9610
|
|
|
9921
|
-
// src/shortcuts/caizhilian/index.ts
|
|
9922
|
-
function asOptions(value) {
|
|
9923
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
9924
|
-
}
|
|
9925
|
-
async function readStdin() {
|
|
9926
|
-
const chunks = [];
|
|
9927
|
-
for await (const chunk of process.stdin) {
|
|
9928
|
-
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
9929
|
-
}
|
|
9930
|
-
return Buffer.concat(chunks).toString("utf8");
|
|
9931
|
-
}
|
|
9932
|
-
function stripBom(value) {
|
|
9933
|
-
return value.replace(/^\uFEFF+/, "");
|
|
9934
|
-
}
|
|
9935
|
-
function parseJsonInput(raw, label) {
|
|
9936
|
-
try {
|
|
9937
|
-
const parsed = JSON.parse(stripBom(raw));
|
|
9938
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
9939
|
-
throw new Error("input must be an object");
|
|
9940
|
-
}
|
|
9941
|
-
return parsed;
|
|
9942
|
-
} catch {
|
|
9943
|
-
throw caizhilianValidationError("input_invalid", `${label} \u4E0D\u662F\u5408\u6CD5 JSON \u5BF9\u8C61`);
|
|
9944
|
-
}
|
|
9945
|
-
}
|
|
9946
|
-
async function inputFrom(options, extra = {}) {
|
|
9947
|
-
const opts = asOptions(options);
|
|
9948
|
-
let input = {};
|
|
9949
|
-
if (opts.input && opts.inputJson) {
|
|
9950
|
-
throw caizhilianValidationError("input_conflict", "\u4E0D\u80FD\u540C\u65F6\u4F20 --input \u548C --input-json");
|
|
9951
|
-
}
|
|
9952
|
-
if (opts.inputJson) {
|
|
9953
|
-
input = parseJsonInput(String(opts.inputJson), "--input-json");
|
|
9954
|
-
}
|
|
9955
|
-
if (opts.input) {
|
|
9956
|
-
let raw;
|
|
9957
|
-
try {
|
|
9958
|
-
raw = stripBom(opts.input === "-" ? await readStdin() : await readFile5(String(opts.input), "utf8"));
|
|
9959
|
-
} catch {
|
|
9960
|
-
throw caizhilianValidationError("input_unreadable", `\u65E0\u6CD5\u8BFB\u53D6 --input\uFF1A${String(opts.input)}`);
|
|
9961
|
-
}
|
|
9962
|
-
input = parseJsonInput(raw, "--input");
|
|
9963
|
-
}
|
|
9964
|
-
return {
|
|
9965
|
-
...input,
|
|
9966
|
-
...Object.fromEntries(Object.entries(extra).filter(([, value]) => value !== void 0 && value !== ""))
|
|
9967
|
-
};
|
|
9968
|
-
}
|
|
9969
|
-
function successEnvelope(operation, result) {
|
|
9970
|
-
return {
|
|
9971
|
-
schemaVersion: 1,
|
|
9972
|
-
ok: true,
|
|
9973
|
-
operation,
|
|
9974
|
-
data: result.data === void 0 ? null : result.data,
|
|
9975
|
-
...result.meta ? { meta: result.meta } : {},
|
|
9976
|
-
warnings: result.warnings ?? []
|
|
9977
|
-
};
|
|
9978
|
-
}
|
|
9979
|
-
function failureEnvelope(error) {
|
|
9980
|
-
const structured = error;
|
|
9981
|
-
return {
|
|
9982
|
-
schemaVersion: 1,
|
|
9983
|
-
ok: false,
|
|
9984
|
-
...structured?.partialData === void 0 ? {} : { data: structured.partialData },
|
|
9985
|
-
error: toErrorEnvelope(error)
|
|
9986
|
-
};
|
|
9987
|
-
}
|
|
9988
|
-
async function executeAndPrint(ctx, operation, input) {
|
|
9989
|
-
try {
|
|
9990
|
-
const result = await executeCaizhilianOperation(operation, input, {
|
|
9991
|
-
ctx,
|
|
9992
|
-
host: createCaizhilianHost(ctx),
|
|
9993
|
-
continuation: createCaizhilianContinuationSigner(ctx)
|
|
9994
|
-
});
|
|
9995
|
-
ctx.output.write(successEnvelope(operation, result), { json: true });
|
|
9996
|
-
} catch (error) {
|
|
9997
|
-
reportPlatformError(error);
|
|
9998
|
-
console.error(JSON.stringify(failureEnvelope(error), null, 2));
|
|
9999
|
-
process.exitCode = isCliError(error) ? error.exitCode : 1 /* GeneralError */;
|
|
10000
|
-
}
|
|
10001
|
-
}
|
|
10002
|
-
function operationsCatalog() {
|
|
10003
|
-
const groups = /* @__PURE__ */ new Map();
|
|
10004
|
-
for (const definition of caizhilianOperationDefinitions()) {
|
|
10005
|
-
const list = groups.get(definition.resource) ?? [];
|
|
10006
|
-
list.push({
|
|
10007
|
-
name: definition.name,
|
|
10008
|
-
summary: definition.summary,
|
|
10009
|
-
risk: definition.risk,
|
|
10010
|
-
...definition.requiresConfirmation ? { requiresConfirmation: true } : {},
|
|
10011
|
-
sourceOperation: definition.sourceOperation
|
|
10012
|
-
});
|
|
10013
|
-
groups.set(definition.resource, list);
|
|
10014
|
-
}
|
|
10015
|
-
return {
|
|
10016
|
-
schemaVersion: 1,
|
|
10017
|
-
ok: true,
|
|
10018
|
-
module: caizhilianManifest.name,
|
|
10019
|
-
sourceSkill: caizhilianManifest.sourceSkill,
|
|
10020
|
-
total: caizhilianOperationDefinitions().length,
|
|
10021
|
-
groups: [...groups.entries()].map(([resource, operations]) => ({ resource, operations })),
|
|
10022
|
-
withheldOperations: caizhilianManifest.withheldOperations
|
|
10023
|
-
};
|
|
10024
|
-
}
|
|
10025
|
-
function withJsonInputOptions(command) {
|
|
10026
|
-
return command.option("--input <path>", "JSON input file, or - for stdin").option("--input-json <json>", "inline JSON input object");
|
|
10027
|
-
}
|
|
10028
|
-
var caizhilianShortcut = {
|
|
10029
|
-
name: "caizhilian",
|
|
10030
|
-
description: "\u6CDB\u5FAEE10\u91C7\u77E5\u8FDE\uFF08\u6587\u6863\u4E2D\u5FC3\uFF09CLI",
|
|
10031
|
-
category: "shortcut",
|
|
10032
|
-
register({ program, action }) {
|
|
10033
|
-
const caizhilian = program.command("caizhilian").description("\u6CDB\u5FAEE10\u91C7\u77E5\u8FDE\u6587\u6863\u4E2D\u5FC3\uFF08\u6587\u6863/\u6587\u4EF6\u5939/\u6743\u9650\u5171\u4EAB/\u6807\u7B7E/\u53C2\u4E0E\u4EBA/\u9644\u4EF6/\u5C01\u9762/\u6587\u6863\u6BD4\u5BF9\uFF09");
|
|
10034
|
-
caizhilian.command("schema").description("Print caizhilian operation manifest for agents").action(
|
|
10035
|
-
action((ctx) => {
|
|
10036
|
-
ctx.output.write(caizhilianManifest, { json: true });
|
|
10037
|
-
})
|
|
10038
|
-
);
|
|
10039
|
-
caizhilian.command("operations").description("List caizhilian operations grouped by resource").action(
|
|
10040
|
-
action((ctx) => {
|
|
10041
|
-
ctx.output.write(operationsCatalog(), { json: true });
|
|
10042
|
-
})
|
|
10043
|
-
);
|
|
10044
|
-
withJsonInputOptions(
|
|
10045
|
-
caizhilian.command("run").description("Run a caizhilian operation with JSON input").argument("<operation>", "operation name, e.g. caizhilian.document.search / caizhilian.tag.add.apply").option("--continuation <token>", "prepare \u8FD4\u56DE\u7684\u786E\u8BA4\u7968\u636E\uFF08apply \u5FC5\u586B\uFF09").option("--yes", "confirm the write operation\uFF08apply \u5FC5\u586B\uFF09")
|
|
10046
|
-
).action(
|
|
10047
|
-
action(async (ctx, operation, options) => {
|
|
10048
|
-
const opts = asOptions(options);
|
|
10049
|
-
await executeAndPrint(
|
|
10050
|
-
ctx,
|
|
10051
|
-
String(operation),
|
|
10052
|
-
await inputFrom(options, {
|
|
10053
|
-
continuation: opts.continuation,
|
|
10054
|
-
confirm: opts.yes === true ? true : void 0
|
|
10055
|
-
})
|
|
10056
|
-
);
|
|
10057
|
-
})
|
|
10058
|
-
);
|
|
10059
|
-
withJsonInputOptions(
|
|
10060
|
-
caizhilian.command("search").description("\u68C0\u7D22\u6587\u6863\uFF08caizhilian.document.search \u8584\u5305\u88C5\uFF09").option("--keywords <kw>", "\u68C0\u7D22\u5173\u952E\u8BCD").option("--folder-id <id>", "\u6587\u4EF6\u5939 ID\uFF1A100=\u7CFB\u7EDF\uFF0C200=\u516C\u5171\uFF0C300=\u4E2A\u4EBA").option("--page-no <n>", "\u9875\u7801\uFF081-indexed\uFF09").option("--page-size <n>", "\u6BCF\u9875\u6761\u6570")
|
|
10061
|
-
).action(
|
|
10062
|
-
action(async (ctx, options) => {
|
|
10063
|
-
const opts = asOptions(options);
|
|
10064
|
-
await executeAndPrint(
|
|
10065
|
-
ctx,
|
|
10066
|
-
"caizhilian.document.search",
|
|
10067
|
-
await inputFrom(options, {
|
|
10068
|
-
keywords: opts.keywords,
|
|
10069
|
-
folder_id: opts.folderId,
|
|
10070
|
-
page_no: opts.pageNo,
|
|
10071
|
-
page_size: opts.pageSize
|
|
10072
|
-
})
|
|
10073
|
-
);
|
|
10074
|
-
})
|
|
10075
|
-
);
|
|
10076
|
-
withJsonInputOptions(
|
|
10077
|
-
caizhilian.command("get").description("\u67E5\u8BE2\u6587\u6863\u8BE6\u60C5\uFF08caizhilian.document.get \u8584\u5305\u88C5\uFF09").option("--doc-id <id>", "\u6587\u6863 ID\uFF08\u5FC5\u586B\uFF09")
|
|
10078
|
-
).action(
|
|
10079
|
-
action(async (ctx, options) => {
|
|
10080
|
-
const opts = asOptions(options);
|
|
10081
|
-
await executeAndPrint(ctx, "caizhilian.document.get", await inputFrom(options, { doc_id: opts.docId }));
|
|
10082
|
-
})
|
|
10083
|
-
);
|
|
10084
|
-
caizhilian.command("health").description("\u91C7\u77E5\u8FDE\u63A5\u53E3\u8FDE\u901A\u6027\u4E0E\u767B\u5F55\u6001\u81EA\u68C0\uFF08caizhilian.system.health \u8584\u5305\u88C5\uFF09").action(
|
|
10085
|
-
action(async (ctx) => {
|
|
10086
|
-
await executeAndPrint(ctx, "caizhilian.system.health", {});
|
|
10087
|
-
})
|
|
10088
|
-
);
|
|
10089
|
-
}
|
|
10090
|
-
};
|
|
10091
9611
|
export {
|
|
10092
|
-
|
|
10093
|
-
|
|
10094
|
-
|
|
9612
|
+
caizhilianOperationDefinitions,
|
|
9613
|
+
caizhilianManifest,
|
|
9614
|
+
executeCaizhilianOperation
|
|
10095
9615
|
};
|