weaver-work-cli 0.1.5 → 0.1.7
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 +14 -9
- package/dist/cmd/skills/index.js +60 -0
- package/dist/internal/e10/auth/commands.js +48 -32
- package/dist/internal/e10/auth/session.js +44 -3
- package/dist/internal/e10/auth/xiaoe.js +363 -11
- package/dist/internal/e10/context.js +4 -2
- package/dist/internal/skills/detector.js +42 -0
- package/dist/internal/skills/install.js +50 -3
- package/dist/shortcuts/archive/render/search-format.js +12 -3
- package/dist/shortcuts/ebuilder-form/continuation.js +70 -0
- package/dist/shortcuts/ebuilder-form/errors.js +54 -0
- package/dist/shortcuts/ebuilder-form/host.js +1238 -0
- package/dist/shortcuts/ebuilder-form/index.js +108 -0
- package/dist/shortcuts/ebuilder-form/manifest.js +347 -0
- package/dist/shortcuts/ebuilder-form/operations/read.js +157 -0
- package/dist/shortcuts/ebuilder-form/operations/registry.js +56 -0
- package/dist/shortcuts/ebuilder-form/operations/shared.js +132 -0
- package/dist/shortcuts/ebuilder-form/operations/types.js +19 -0
- package/dist/shortcuts/ebuilder-form/operations/write.js +277 -0
- package/dist/shortcuts/ebuilder-form/operations.js +8 -0
- package/dist/shortcuts/ehr/operations/salary.js +2 -140
- package/dist/shortcuts/im/continuation.js +70 -0
- package/dist/shortcuts/{yimiaoban → im}/errors.js +14 -14
- package/dist/shortcuts/{yimiaoban → im}/host.js +26 -26
- package/dist/shortcuts/{yimiaoban → im}/index.js +42 -42
- package/dist/shortcuts/{yimiaoban → im}/manifest.js +7 -6
- package/dist/shortcuts/{yimiaoban → im}/operations/file-user.js +54 -41
- package/dist/shortcuts/{yimiaoban → im}/operations/group-read.js +46 -44
- package/dist/shortcuts/{yimiaoban → im}/operations/group-write.js +113 -66
- package/dist/shortcuts/{yimiaoban → im}/operations/msg-sync.js +164 -141
- package/dist/shortcuts/{yimiaoban → im}/operations/msg-write.js +47 -47
- package/dist/shortcuts/{yimiaoban → im}/operations/person.js +10 -10
- package/dist/shortcuts/{yimiaoban → im}/operations/registry.js +10 -8
- package/dist/shortcuts/{yimiaoban → im}/operations/session.js +82 -83
- package/dist/shortcuts/im/operations/shared.js +442 -0
- package/dist/shortcuts/{yimiaoban → im}/operations/types.js +1 -1
- package/dist/shortcuts/im/operations/user-remind.js +201 -0
- package/dist/shortcuts/{yimiaoban → im}/operations/write-util.js +7 -7
- package/dist/shortcuts/{yimiaoban → im}/operations.js +3 -3
- package/dist/shortcuts/index.js +10 -2
- package/dist/shortcuts/invoice/manifest.js +113 -10
- package/dist/shortcuts/invoice/operations/import.js +39 -14
- package/dist/shortcuts/invoice/operations/reim.js +38 -18
- package/dist/shortcuts/invoice/operations/shared.js +35 -6
- package/dist/shortcuts/jiuchuanhui/manifest.js +3 -3
- package/dist/shortcuts/jiuchuanhui/operations/registry.js +2 -2
- package/dist/shortcuts/{yimiaoban → okr}/continuation.js +10 -10
- package/dist/shortcuts/okr/errors.js +70 -0
- package/dist/shortcuts/okr/host.js +169 -0
- package/dist/shortcuts/okr/index.js +155 -0
- package/dist/shortcuts/okr/manifest.js +70 -0
- package/dist/shortcuts/okr/operations/link.js +305 -0
- package/dist/shortcuts/okr/operations/read.js +481 -0
- package/dist/shortcuts/okr/operations/registry.js +31 -0
- package/dist/shortcuts/okr/operations/shared.js +381 -0
- package/dist/shortcuts/okr/operations/types.js +88 -0
- package/dist/shortcuts/okr/operations/write.js +838 -0
- package/dist/shortcuts/okr/operations.js +8 -0
- package/dist/shortcuts/project/continuation.js +70 -0
- package/dist/shortcuts/project/errors.js +53 -0
- package/dist/shortcuts/project/host.js +160 -0
- package/dist/shortcuts/project/index.js +106 -0
- package/dist/shortcuts/project/manifest.js +36 -0
- package/dist/shortcuts/project/operations/read.js +551 -0
- package/dist/shortcuts/project/operations/registry.js +31 -0
- package/dist/shortcuts/project/operations/shared.js +68 -0
- package/dist/shortcuts/project/operations/types.js +39 -0
- package/dist/shortcuts/project/operations/write.js +266 -0
- package/dist/shortcuts/project/operations.js +8 -0
- package/dist/shortcuts/workflow/continuation.js +508 -0
- package/dist/shortcuts/workflow/endpoints.js +149 -0
- package/dist/shortcuts/workflow/errors.js +112 -0
- package/dist/shortcuts/workflow/host.js +224 -0
- package/dist/shortcuts/workflow/index.js +116 -0
- package/dist/shortcuts/workflow/manifest.js +30 -0
- package/dist/shortcuts/workflow/operations/form.js +4159 -0
- package/dist/shortcuts/workflow/operations/read.js +3778 -0
- package/dist/shortcuts/workflow/operations/registry.js +33 -0
- package/dist/shortcuts/workflow/operations/shared.js +167 -0
- package/dist/shortcuts/workflow/operations/types.js +44 -0
- package/dist/shortcuts/workflow/operations/write.js +1991 -0
- package/dist/shortcuts/workflow/operations.js +119 -0
- package/dist/shortcuts/workflow/state.js +182 -0
- package/docs/SKILL.md +5 -3
- package/docs/_catalog.md +10 -1
- package/docs/agent-invoice.md +2 -2
- package/docs/agent-skill-install.md +2 -2
- package/docs/e10-auth.md +3 -1
- package/docs/ebuilder-form.md +38 -0
- package/docs/im.md +104 -0
- package/docs/invoice.md +5 -5
- package/docs/okr.md +122 -0
- package/docs/operation-manual.md +10 -7
- package/docs/project.md +69 -0
- package/docs/skill-review-2026-09-19.md +68 -0
- package/package.json +3 -2
- package/scripts/package-skill.mjs +38 -11
- package/scripts/sync-connector-skills.mjs +172 -0
- package/skill-template/business-info.json +357 -16
- package/skill-template/domains/ebuilder-form.md +5 -0
- package/skill-template/domains/okr.md +18 -0
- package/skill-template/domains/shijingran.md +3 -0
- package/skill-template/domains/skill-maker.md +4 -4
- package/skill-template/domains/workflow.md +22 -0
- package/skill-template/domains/yepiaotong.md +4 -2
- package/skill-template/domains/yimiaoban.md +13 -10
- package/skill-template/product.json +5 -0
- package/skill-template/skill-template.md +1 -0
- package/skills/weaver-e10-calendar/SKILL.md +5 -1
- package/skills/weaver-e10-calendar/references/calendar-query.md +7 -0
- package/skills/weaver-e10-calendar/references/source-manifest.json +314 -32
- package/skills/weaver-e10-ebuilder-form/SKILL.md +123 -0
- package/skills/weaver-e10-ebuilder-form/references/context-routing.md +90 -0
- package/skills/weaver-e10-ebuilder-form/references/custom-api.md +86 -0
- package/skills/weaver-e10-ebuilder-form/references/disabled-capabilities.md +50 -0
- package/skills/weaver-e10-ebuilder-form/references/fields-browser.md +100 -0
- package/skills/weaver-e10-ebuilder-form/references/list-nlist.md +91 -0
- package/skills/weaver-e10-ebuilder-form/references/openapi-read.md +74 -0
- package/skills/weaver-e10-ebuilder-form/references/openapi-write.md +86 -0
- package/skills/weaver-e10-ebuilder-form/references/source-manifest.json +107 -0
- package/skills/weaver-e10-esb/SKILL.md +1 -1
- package/skills/weaver-e10-esb/references/source-manifest.json +15 -14
- package/skills/weaver-e10-hrm/SKILL.md +1 -1
- package/skills/weaver-e10-hrm/references/source-manifest.json +357 -38
- package/skills/weaver-e10-jiuchuanhui/SKILL.md +22 -4
- package/skills/weaver-e10-jiuchuanhui/references/clue.md +4 -2
- package/skills/weaver-e10-jiuchuanhui/references/contact.md +1 -1
- package/skills/weaver-e10-jiuchuanhui/references/customer.md +3 -3
- package/skills/weaver-e10-jiuchuanhui/references/disabled-capabilities.md +1 -1
- package/skills/weaver-e10-jiuchuanhui/references/discovery-config.md +10 -10
- package/skills/weaver-e10-jiuchuanhui/references/general-helpers.md +3 -3
- package/skills/weaver-e10-jiuchuanhui/references/sale.md +7 -7
- package/skills/weaver-e10-jiuchuanhui/references/source-manifest.json +3 -3
- package/skills/weaver-e10-jucailin/SKILL.md +2 -2
- package/skills/weaver-e10-mail/SKILL.md +22 -6
- package/skills/weaver-e10-meeting/SKILL.md +22 -1
- package/skills/weaver-e10-okr/SKILL.md +139 -0
- package/skills/weaver-e10-okr/references/okr-align.md +59 -0
- package/skills/weaver-e10-okr/references/okr-keyresult.md +68 -0
- package/skills/weaver-e10-okr/references/okr-link-routing.md +67 -0
- package/skills/weaver-e10-okr/references/okr-query.md +105 -0
- package/skills/weaver-e10-okr/references/okr-write.md +94 -0
- package/skills/weaver-e10-okr/references/source-manifest.json +672 -0
- package/skills/weaver-e10-plan/SKILL.md +3 -3
- package/skills/weaver-e10-plan/references/plan-report-write.md +1 -1
- package/skills/weaver-e10-plan/references/source-manifest.json +20 -20
- package/skills/weaver-e10-qiyecheng/SKILL.md +21 -1
- package/skills/weaver-e10-qiyecheng/references/source-manifest.json +17 -17
- package/skills/weaver-e10-shared/SKILL.md +79 -11
- package/skills/weaver-e10-shared/references/e10-auth-and-session.md +41 -8
- package/skills/weaver-e10-shared/references/non-interactive-environment.md +78 -0
- package/skills/weaver-e10-shared/references/weaver-e10-installation.md +39 -0
- package/skills/weaver-e10-shijingran/SKILL.md +83 -0
- package/skills/weaver-e10-shijingran/references/field-resolution.md +105 -0
- package/skills/weaver-e10-shijingran/references/operations.md +154 -0
- package/skills/weaver-e10-shijingran/references/source-manifest.json +1380 -0
- package/skills/weaver-e10-shijingran/references/write-operations.md +90 -0
- package/skills/weaver-e10-skill-maker/SKILL.md +26 -9
- package/skills/weaver-e10-skill-maker/references/business-skill-generation.md +39 -8
- package/skills/weaver-e10-skill-maker/references/detector-validation.md +25 -8
- package/skills/weaver-e10-skill-maker/references/module-cli-generation.md +66 -5
- package/skills/weaver-e10-skill-maker/references/module-gap-audit-and-repair.md +86 -0
- package/skills/weaver-e10-skill-maker/references/source-update-detection.md +59 -5
- package/skills/weaver-e10-skill-maker/references/weaver-skill-style.md +16 -8
- package/skills/weaver-e10-wenshuding/SKILL.md +28 -4
- package/skills/weaver-e10-wenshuding/references/archive-search.md +14 -0
- package/skills/weaver-e10-wenshuding/references/source-manifest.json +27 -26
- package/skills/weaver-e10-workflow/SKILL.md +250 -0
- package/skills/weaver-e10-workflow/references/source-manifest.json +1062 -0
- package/skills/weaver-e10-workflow/references/workflow-agent-entry.md +96 -0
- package/skills/weaver-e10-workflow/references/workflow-batch.md +275 -0
- package/skills/weaver-e10-workflow/references/workflow-create.md +182 -0
- package/skills/weaver-e10-workflow/references/workflow-edit.md +106 -0
- package/skills/weaver-e10-workflow/references/workflow-memory.md +165 -0
- package/skills/weaver-e10-workflow/references/workflow-operate.md +153 -0
- package/skills/weaver-e10-workflow/references/workflow-query.md +821 -0
- package/skills/weaver-e10-workflow/references/workflow-share.md +117 -0
- package/skills/weaver-e10-workflow/references/workflow-view.md +189 -0
- package/skills/weaver-e10-yepiaotong/SKILL.md +28 -28
- package/skills/weaver-e10-yepiaotong/references/invoice-disabled-capabilities.md +11 -5
- package/skills/weaver-e10-yepiaotong/references/invoice-import.md +14 -8
- package/skills/weaver-e10-yepiaotong/references/invoice-issuing-examples.md +9 -43
- package/skills/weaver-e10-yepiaotong/references/invoice-issuing.md +8 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +13 -17
- package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +6 -7
- package/skills/weaver-e10-yepiaotong/references/reim-examples.md +2 -2
- package/skills/weaver-e10-yepiaotong/references/source-manifest.json +1155 -553
- package/skills/weaver-e10-yimiaoban/SKILL.md +56 -38
- package/skills/weaver-e10-yimiaoban/references/ding-write.md +8 -8
- package/skills/weaver-e10-yimiaoban/references/error-codes.md +16 -0
- package/skills/weaver-e10-yimiaoban/references/field-resolution.md +10 -10
- package/skills/weaver-e10-yimiaoban/references/file-user-i18n.md +12 -12
- package/skills/weaver-e10-yimiaoban/references/group-read.md +16 -16
- package/skills/weaver-e10-yimiaoban/references/group-write.md +17 -15
- package/skills/weaver-e10-yimiaoban/references/msg-read.md +21 -17
- package/skills/weaver-e10-yimiaoban/references/msg-write.md +10 -10
- package/skills/weaver-e10-yimiaoban/references/person.md +6 -6
- package/skills/weaver-e10-yimiaoban/references/safety-boundaries.md +15 -11
- package/skills/weaver-e10-yimiaoban/references/session-sysmsg.md +11 -10
- package/skills/weaver-e10-yimiaoban/references/source-manifest.json +2164 -154
- package/skills/weaver-e10-yimiaoban/references/user-remind.md +75 -0
- package/skills/weaver-e10-ziguanjia/SKILL.md +4 -2
- package/skills/weaver-e10-ziguanjia/references/source-manifest.json +99 -29
- package/tools/weaver-skill-detector-1.0.13/SKILL.md +253 -0
- package/tools/weaver-skill-detector-1.0.13/_meta.json +6 -0
- package/tools/weaver-skill-detector-1.0.13/references/checklist.md +298 -0
- package/tools/weaver-skill-detector-1.0.13/scripts/validate_skill.py +4190 -0
- package/dist/shortcuts/yimiaoban/operations/shared.js +0 -236
- package/docs/yimiaoban.md +0 -86
- package/skills/weaver-e10-calendar/product.json +0 -8
- package/skills/weaver-e10-esb/product.json +0 -8
- package/skills/weaver-e10-hrm/product.json +0 -8
- package/skills/weaver-e10-jiuchuanhui/product.json +0 -8
- package/skills/weaver-e10-jucailin/product.json +0 -8
- package/skills/weaver-e10-mail/product.json +0 -8
- package/skills/weaver-e10-meeting/product.json +0 -8
- package/skills/weaver-e10-plan/product.json +0 -8
- package/skills/weaver-e10-qiyecheng/product.json +0 -8
- package/skills/weaver-e10-skill-maker/product.json +0 -8
- package/skills/weaver-e10-wenshuding/product.json +0 -8
- package/skills/weaver-e10-yepiaotong/product.json +0 -8
- package/skills/weaver-e10-yepiaotong/references/invoice-red.md +0 -261
- package/skills/weaver-e10-yimiaoban/product.json +0 -8
- package/skills/weaver-e10-ziguanjia/product.json +0 -8
- /package/dist/shortcuts/{yimiaoban → im}/operations/msg-parse.js +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { workflowValidationError } from '../errors.js';
|
|
2
|
+
import { workflowFormOperations } from './form.js';
|
|
3
|
+
import { workflowReadOperations } from './read.js';
|
|
4
|
+
import { workflowWriteOperations } from './write.js';
|
|
5
|
+
function buildRegistry() {
|
|
6
|
+
const registry = new Map();
|
|
7
|
+
const definitions = [
|
|
8
|
+
...workflowReadOperations,
|
|
9
|
+
...workflowFormOperations,
|
|
10
|
+
...workflowWriteOperations,
|
|
11
|
+
];
|
|
12
|
+
for (const definition of definitions) {
|
|
13
|
+
if (registry.has(definition.name)) {
|
|
14
|
+
throw new Error(`duplicate workflow operation: ${definition.name}`);
|
|
15
|
+
}
|
|
16
|
+
registry.set(definition.name, definition);
|
|
17
|
+
}
|
|
18
|
+
return registry;
|
|
19
|
+
}
|
|
20
|
+
const workflowOperationRegistry = buildRegistry();
|
|
21
|
+
export function workflowOperationDefinitions() {
|
|
22
|
+
return [...workflowOperationRegistry.values()];
|
|
23
|
+
}
|
|
24
|
+
export function getWorkflowOperation(operation) {
|
|
25
|
+
const definition = workflowOperationRegistry.get(operation);
|
|
26
|
+
if (!definition) {
|
|
27
|
+
throw workflowValidationError('operation_unknown', `流程模块不支持操作:${operation}`);
|
|
28
|
+
}
|
|
29
|
+
return definition;
|
|
30
|
+
}
|
|
31
|
+
export function hasWorkflowOperation(operation) {
|
|
32
|
+
return workflowOperationRegistry.has(operation);
|
|
33
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { WorkflowCliError, workflowValidationError } from '../errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* 模型输入中永远不允许出现的键。
|
|
4
|
+
*
|
|
5
|
+
* 依据共享规则:认证态由 CLI 托管,业务输入只描述业务对象与意图;
|
|
6
|
+
* 出现这些键说明调用方试图自行注入会话凭据或绕过封装层。
|
|
7
|
+
*/
|
|
8
|
+
export const FORBIDDEN_INPUT_KEYS = new Set([
|
|
9
|
+
'access_token',
|
|
10
|
+
'app_key',
|
|
11
|
+
'app_secret',
|
|
12
|
+
'cookie',
|
|
13
|
+
'cookies',
|
|
14
|
+
'eteamsid',
|
|
15
|
+
'token',
|
|
16
|
+
'sedit',
|
|
17
|
+
'dubboFlag',
|
|
18
|
+
'dubboToken',
|
|
19
|
+
'skipFlag',
|
|
20
|
+
'secondSectionType',
|
|
21
|
+
'authStr',
|
|
22
|
+
'authSignatureStr',
|
|
23
|
+
]);
|
|
24
|
+
export function asObject(value) {
|
|
25
|
+
if (value === undefined || value === null)
|
|
26
|
+
return {};
|
|
27
|
+
if (typeof value !== 'object' || Array.isArray(value)) {
|
|
28
|
+
throw workflowValidationError('input_invalid', '输入必须是 JSON 对象');
|
|
29
|
+
}
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
export function assertNoForbiddenKeys(input) {
|
|
33
|
+
const hits = Object.keys(input).filter((key) => FORBIDDEN_INPUT_KEYS.has(key));
|
|
34
|
+
if (hits.length) {
|
|
35
|
+
throw workflowValidationError('input_forbidden', `输入中包含不允许的认证相关字段:${hits.join('、')}。认证态由 weaver-work-cli 托管,请不要传入凭据。`, { fields: hits });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** 去掉 undefined / null / 空串,便于构造请求体。 */
|
|
39
|
+
export function compact(value) {
|
|
40
|
+
const output = {};
|
|
41
|
+
for (const [key, item] of Object.entries(value)) {
|
|
42
|
+
if (item === undefined || item === null || item === '')
|
|
43
|
+
continue;
|
|
44
|
+
output[key] = item;
|
|
45
|
+
}
|
|
46
|
+
return output;
|
|
47
|
+
}
|
|
48
|
+
export function asString(value) {
|
|
49
|
+
if (value === undefined || value === null)
|
|
50
|
+
return undefined;
|
|
51
|
+
const text = String(value).trim();
|
|
52
|
+
return text ? text : undefined;
|
|
53
|
+
}
|
|
54
|
+
export function asInt(value) {
|
|
55
|
+
if (value === undefined || value === null || value === '')
|
|
56
|
+
return undefined;
|
|
57
|
+
const parsed = Number(value);
|
|
58
|
+
return Number.isInteger(parsed) ? parsed : undefined;
|
|
59
|
+
}
|
|
60
|
+
export function asStringArray(value, field) {
|
|
61
|
+
if (value === undefined || value === null || value === '')
|
|
62
|
+
return undefined;
|
|
63
|
+
if (!Array.isArray(value)) {
|
|
64
|
+
throw workflowValidationError('input_invalid', `${field} 必须是字符串数组`);
|
|
65
|
+
}
|
|
66
|
+
return value.map((item) => String(item));
|
|
67
|
+
}
|
|
68
|
+
/** 请求 flag 是否开启(支持布尔与 0/1、"true"/"false")。 */
|
|
69
|
+
export function asBool(value, fallback = false) {
|
|
70
|
+
if (value === undefined || value === null || value === '')
|
|
71
|
+
return fallback;
|
|
72
|
+
if (typeof value === 'boolean')
|
|
73
|
+
return value;
|
|
74
|
+
const text = String(value).trim().toLowerCase();
|
|
75
|
+
if (['1', 'true', 'yes', 'y'].includes(text))
|
|
76
|
+
return true;
|
|
77
|
+
if (['0', 'false', 'no', 'n'].includes(text))
|
|
78
|
+
return false;
|
|
79
|
+
return fallback;
|
|
80
|
+
}
|
|
81
|
+
/** 从响应中取数据主体(兼容 res_base 包裹与 data 包裹)。 */
|
|
82
|
+
export function responseData(response) {
|
|
83
|
+
if (!response || typeof response !== 'object') {
|
|
84
|
+
throw new WorkflowCliError('api', 'unexpected_response', '接口返回结构异常');
|
|
85
|
+
}
|
|
86
|
+
const record = response;
|
|
87
|
+
if (record.res_base && typeof record.res_base === 'object')
|
|
88
|
+
return record.res_base;
|
|
89
|
+
if (record.data !== undefined)
|
|
90
|
+
return record.data;
|
|
91
|
+
return response;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* 记忆应用 ID(来源:原 Python `DEFAULT_MEMORY_APP_ID` / `memory_app_id_from_runtime`)。
|
|
95
|
+
*
|
|
96
|
+
* 记忆接口(buildAgentMemoryPrompt / agentMemoryExtract)要求 `chatParams.appid` 必须是
|
|
97
|
+
* 有效的 AI 应用 ID:缺省时接口直接返回空 promptText(表现为「记忆永远读不到」)。
|
|
98
|
+
* 解析顺序:显式入参 > 环境变量 `E10_MEMORY_APP_ID` > 内置默认值。
|
|
99
|
+
*/
|
|
100
|
+
export const DEFAULT_MEMORY_APP_ID = '1299808011830755362';
|
|
101
|
+
export function resolveMemoryAppId(explicit) {
|
|
102
|
+
const text = (explicit ?? '').trim();
|
|
103
|
+
if (text)
|
|
104
|
+
return text;
|
|
105
|
+
return (process.env.E10_MEMORY_APP_ID ?? '').trim() || DEFAULT_MEMORY_APP_ID;
|
|
106
|
+
}
|
|
107
|
+
export function toArray(value) {
|
|
108
|
+
if (Array.isArray(value))
|
|
109
|
+
return value;
|
|
110
|
+
if (value === undefined || value === null)
|
|
111
|
+
return [];
|
|
112
|
+
return [value];
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* 把指针/元信息字段排到 JSON 最前(同名键保留 meta 的位置)。
|
|
116
|
+
*
|
|
117
|
+
* 原因:输出体积大时模型习惯用 `| head` 截断,而 JSON 尾部字段必然读不到
|
|
118
|
+
* —— `resultFile` 这类"续取指针"必须出现在前部,被截断也看得见。
|
|
119
|
+
*/
|
|
120
|
+
export function withLeadingMeta(meta, body) {
|
|
121
|
+
const ordered = {};
|
|
122
|
+
for (const [key, value] of Object.entries(meta)) {
|
|
123
|
+
if (value !== undefined)
|
|
124
|
+
ordered[key] = value;
|
|
125
|
+
}
|
|
126
|
+
for (const [key, value] of Object.entries(body)) {
|
|
127
|
+
if (value !== undefined)
|
|
128
|
+
ordered[key] = value;
|
|
129
|
+
}
|
|
130
|
+
return ordered;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* 单次工具输出的体积安全线:超过就落盘 + 只回精简版。
|
|
134
|
+
*
|
|
135
|
+
* 宿主对单次工具输出有截断(V12.1.34 实测:24,000 B 与 28,000 B 完整内联,32,000 B(报 31.3 KB)
|
|
136
|
+
* 被截成 2048 B 预览 + 落盘),一旦被截断,模型只能写脚本反复读回、每读一次又被截断,
|
|
137
|
+
* 白花好几轮工具往返(实测某次会话多花 4 轮、约 54 s)。与其让宿主事后截,不如 CLI 主动落盘。
|
|
138
|
+
*
|
|
139
|
+
* **量这个线必须用 `stdoutBytesOf()`(美化口径)**,不能用压缩口径 —— 见该函数注释。
|
|
140
|
+
*/
|
|
141
|
+
export const STDOUT_SAFE_BYTES = 24_000;
|
|
142
|
+
/** 结果序列化后的字节数(**压缩**口径,用作相对大小参考)。 */
|
|
143
|
+
export function outputBytesOf(value) {
|
|
144
|
+
try {
|
|
145
|
+
return Buffer.byteLength(JSON.stringify(value), 'utf8');
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
return 0;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* 宿主**实际看到**的 stdout 体积(**美化**口径,缩进 2,与 CLI 打印格式一致)。
|
|
153
|
+
*
|
|
154
|
+
* ★ 安全线必须用这个量。CLI 打出来的是美化 JSON,而 `outputBytesOf()` 量的是压缩 JSON,
|
|
155
|
+
* 两者**实测相差 1.79 倍**(同一份 createForm 输出:压缩 21,146 / 美化 37,887)。用压缩口径判线会
|
|
156
|
+
* **系统性低估**,于是:① 该降级的没降级(`form.ts` 的第三档兜底 `writableFieldsOmitted` 从未触发);
|
|
157
|
+
* ② 输出冲出宿主阈值被截成 2048 B 预览,而排在 2048 字节之后的内容(如 `writableFields`)
|
|
158
|
+
* **永远看不见** —— 模型于是自己去写脚本挖 resultFile,白烧好几轮往返。
|
|
159
|
+
*/
|
|
160
|
+
export function stdoutBytesOf(value) {
|
|
161
|
+
try {
|
|
162
|
+
return Buffer.byteLength(JSON.stringify(value, null, 2), 'utf8');
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
return 0;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export function workflowSuccess(action, data, meta) {
|
|
2
|
+
const payload = { ok: true, action, data };
|
|
3
|
+
if (meta && Object.keys(meta).length > 0)
|
|
4
|
+
payload.meta = meta;
|
|
5
|
+
return payload;
|
|
6
|
+
}
|
|
7
|
+
/** 构造「对象类型 + 严格禁止额外字段」的 JSON Schema。 */
|
|
8
|
+
export function schemaOf(properties, options = {}) {
|
|
9
|
+
return {
|
|
10
|
+
type: 'object',
|
|
11
|
+
additionalProperties: false,
|
|
12
|
+
properties,
|
|
13
|
+
...(options.required?.length ? { required: options.required } : {}),
|
|
14
|
+
...(options.description ? { description: options.description } : {}),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** 流程 requestId:服务端返回字符串,请求也接受数字或数字字符串。 */
|
|
18
|
+
export const SCHEMA_REQUEST_ID = { oneOf: [{ type: 'integer' }, { type: 'string', pattern: '^\\d+$' }] };
|
|
19
|
+
/** 流程分类:待办 / 已办 / 我发起 / 全部 */
|
|
20
|
+
export const SCHEMA_CATEGORY = {
|
|
21
|
+
type: 'string',
|
|
22
|
+
enum: ['todo', 'done', 'mine', 'all'],
|
|
23
|
+
description: '这批流程属于哪个列表:待办=todo、已办=done、我发起的=mine、全部流程=all。'
|
|
24
|
+
+ '只按"用户要看哪个列表"判定,与问句里的其他条件无关——句中的"我/我的"若只是筛选条件取值'
|
|
25
|
+
+ '(如"费用承担人是我")、"提交/发起/创建"若只是时间短语的修饰(如"本月提交的")都**不构成 mine**。'
|
|
26
|
+
+ '按这些判不出列表但用户给了筛选条件时用 all;连筛选条件都没有时先反问用户要查哪一批。',
|
|
27
|
+
};
|
|
28
|
+
/** 序号(1 基) */
|
|
29
|
+
export const SCHEMA_INDEX = { type: 'integer', minimum: 1 };
|
|
30
|
+
/** 分页大小 */
|
|
31
|
+
export const SCHEMA_PAGE_SIZE = { type: 'integer', minimum: 1, maximum: 100 };
|
|
32
|
+
/** prepare 阶段返回的续跑句柄(CLI 在本机托管载荷,模型只原样回传) */
|
|
33
|
+
export const SCHEMA_CONTINUATION = {
|
|
34
|
+
type: 'string',
|
|
35
|
+
minLength: 1,
|
|
36
|
+
description: 'Prepare 阶段(含 createForm / editLoad 等前置步骤)返回的续跑句柄,形如 wc-1a2b3c4d5e6f7a8b;载荷由 CLI 在本机托管,原样回传即可,不要解析、改写、拼接或跨操作复用',
|
|
37
|
+
};
|
|
38
|
+
/** 写操作明确确认标记 */
|
|
39
|
+
export const SCHEMA_CONFIRM = { const: true };
|
|
40
|
+
/** prepare/apply 成对写操作共用的输入属性。 */
|
|
41
|
+
export const CONTINUATION_INPUT = {
|
|
42
|
+
continuation: SCHEMA_CONTINUATION,
|
|
43
|
+
confirm: SCHEMA_CONFIRM,
|
|
44
|
+
};
|