weaver-work-cli 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/LICENSE +21 -0
- package/README.md +422 -0
- package/dist/cmd/action.js +35 -0
- package/dist/cmd/commands/index.js +15 -0
- package/dist/cmd/config/index.js +64 -0
- package/dist/cmd/docs/index.js +56 -0
- package/dist/cmd/doctor/index.js +45 -0
- package/dist/cmd/e10/index.js +25 -0
- package/dist/cmd/index.js +18 -0
- package/dist/cmd/register.js +19 -0
- package/dist/cmd/root.js +36 -0
- package/dist/cmd/run/index.js +38 -0
- package/dist/cmd/setup/index.js +77 -0
- package/dist/cmd/skills/index.js +72 -0
- package/dist/core/config-store.js +43 -0
- package/dist/core/context.js +31 -0
- package/dist/core/errors.js +60 -0
- package/dist/core/hooks.js +41 -0
- package/dist/core/logger.js +27 -0
- package/dist/core/output.js +25 -0
- package/dist/core/write-with-retry.js +21 -0
- package/dist/index.js +11 -0
- package/dist/internal/e10/auth/commands.js +594 -0
- package/dist/internal/e10/auth/crypto.js +126 -0
- package/dist/internal/e10/auth/paths.js +12 -0
- package/dist/internal/e10/auth/session.js +449 -0
- package/dist/internal/e10/client.js +104 -0
- package/dist/internal/e10/context.js +20 -0
- package/dist/internal/e10/index.js +2 -0
- package/dist/internal/e10/types.js +1 -0
- package/dist/internal/skills/install.js +99 -0
- package/dist/internal/skills/reader.js +119 -0
- package/dist/services/command-runner.js +44 -0
- package/dist/shortcuts/index.js +4 -0
- package/dist/shortcuts/invoice/continuation.js +70 -0
- package/dist/shortcuts/invoice/errors.js +59 -0
- package/dist/shortcuts/invoice/host.js +337 -0
- package/dist/shortcuts/invoice/index.js +301 -0
- package/dist/shortcuts/invoice/manifest.js +288 -0
- package/dist/shortcuts/invoice/operations/add.js +106 -0
- package/dist/shortcuts/invoice/operations/delete.js +92 -0
- package/dist/shortcuts/invoice/operations/download.js +16 -0
- package/dist/shortcuts/invoice/operations/get.js +7 -0
- package/dist/shortcuts/invoice/operations/import.js +128 -0
- package/dist/shortcuts/invoice/operations/list.js +12 -0
- package/dist/shortcuts/invoice/operations/ocr-preview.js +40 -0
- package/dist/shortcuts/invoice/operations/registry.js +50 -0
- package/dist/shortcuts/invoice/operations/shared.js +640 -0
- package/dist/shortcuts/invoice/operations/types.js +1 -0
- package/dist/shortcuts/invoice/operations/update.js +109 -0
- package/dist/shortcuts/invoice/operations/upload.js +8 -0
- package/dist/shortcuts/invoice/operations/validate-preview.js +39 -0
- package/dist/shortcuts/invoice/operations.js +8 -0
- package/dist/types.js +1 -0
- package/docs/SKILL.md +36 -0
- package/docs/_catalog.md +12 -0
- package/docs/agent-invoice.md +53 -0
- package/docs/e10-auth.md +51 -0
- package/docs/invoice.md +99 -0
- package/package.json +51 -0
- package/scripts/clean.mjs +4 -0
- package/scripts/package-skill.mjs +164 -0
- package/scripts/sync-docs.mjs +17 -0
- package/skill-template/business-info.json +4 -0
- package/skill-template/domains/invoice.md +23 -0
- package/skill-template/domains/shared.md +8 -0
- package/skill-template/master-skill-template.md +29 -0
- package/skill-template/skill-template.md +60 -0
- package/skills/weaver-work-cli-invoice/SKILL.md +103 -0
- package/skills/weaver-work-cli-invoice/product.json +8 -0
- package/skills/weaver-work-cli-invoice/references/invoice-add.md +18 -0
- package/skills/weaver-work-cli-invoice/references/invoice-agent-entry.md +38 -0
- package/skills/weaver-work-cli-invoice/references/invoice-delete.md +20 -0
- package/skills/weaver-work-cli-invoice/references/invoice-detail.md +29 -0
- package/skills/weaver-work-cli-invoice/references/invoice-disabled-capabilities.md +26 -0
- package/skills/weaver-work-cli-invoice/references/invoice-download.md +22 -0
- package/skills/weaver-work-cli-invoice/references/invoice-enterprise-list.md +35 -0
- package/skills/weaver-work-cli-invoice/references/invoice-file-upload.md +28 -0
- package/skills/weaver-work-cli-invoice/references/invoice-import.md +28 -0
- package/skills/weaver-work-cli-invoice/references/invoice-ocr-preview.md +33 -0
- package/skills/weaver-work-cli-invoice/references/invoice-personal-list.md +47 -0
- package/skills/weaver-work-cli-invoice/references/invoice-update.md +38 -0
- package/skills/weaver-work-cli-invoice/references/invoice-validation-preview.md +26 -0
- package/skills/weaver-work-cli-shared/SKILL.md +53 -0
- package/skills/weaver-work-cli-shared/references/e10-auth-and-session.md +83 -0
- package/skills/weaver-work-cli-shared/references/high-risk-write.md +36 -0
- package/skills/weaver-work-cli-shared/references/json-output-contract.md +61 -0
- package/skills/weaver-work-cli-shared/references/weaver-work-cli-installation.md +61 -0
- package/templates/shortcut/index.ts.tpl +19 -0
- package/templates/shortcut/operations/ping.ts.tpl +7 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { InvoiceCliError, invoiceValidationError } from '../errors.js';
|
|
2
|
+
import { previewOcr, uploadFromInput, uploadInvoiceFile, workflow } from './shared.js';
|
|
3
|
+
export class InvoiceOcrPreviewOperation {
|
|
4
|
+
name = 'invoice.ocr.preview';
|
|
5
|
+
async execute(input, { host }) {
|
|
6
|
+
if (input.is_save !== undefined && input.is_save !== 1) {
|
|
7
|
+
throw invoiceValidationError('policy_override_forbidden', 'OCR 预览固定为 is_save=1,不允许写入票夹');
|
|
8
|
+
}
|
|
9
|
+
if (input.upload !== undefined && (input.file !== undefined || input.url !== undefined)) {
|
|
10
|
+
throw invoiceValidationError('input_ambiguous', 'upload 与 file/url 只能选择一种来源');
|
|
11
|
+
}
|
|
12
|
+
const suppliedUpload = uploadFromInput(input);
|
|
13
|
+
const upload = suppliedUpload || await uploadInvoiceFile(input, host);
|
|
14
|
+
let ocr;
|
|
15
|
+
try {
|
|
16
|
+
ocr = await previewOcr(upload, host);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
if (!suppliedUpload) {
|
|
20
|
+
throw new InvoiceCliError('partial', 'artifact_uploaded', '文件已上传但 OCR 预览失败,不能自动重复上传', {
|
|
21
|
+
partialData: { upload, workflow: workflow('invoice.ocr.preview', 'OCR_RUNNING') },
|
|
22
|
+
details: { stage: 'ocr' },
|
|
23
|
+
exitCode: 11,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
status: 'COMPLETE',
|
|
30
|
+
data: {
|
|
31
|
+
saved: false,
|
|
32
|
+
verified: false,
|
|
33
|
+
upload,
|
|
34
|
+
invoices: ocr.invoices,
|
|
35
|
+
results: ocr.results,
|
|
36
|
+
workflow: workflow('invoice.ocr.preview', 'COMPLETE'),
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { invoiceValidationError } from '../errors.js';
|
|
2
|
+
import { invoiceOperations } from '../manifest.js';
|
|
3
|
+
import { InvoiceAddApplyOperation, InvoiceAddPrepareOperation } from './add.js';
|
|
4
|
+
import { InvoiceDeleteApplyOperation, InvoiceDeletePrepareOperation } from './delete.js';
|
|
5
|
+
import { InvoiceDownloadOperation } from './download.js';
|
|
6
|
+
import { InvoiceGetOperation } from './get.js';
|
|
7
|
+
import { InvoiceImportApplyOperation, InvoiceImportPrepareOperation } from './import.js';
|
|
8
|
+
import { InvoiceListOperation } from './list.js';
|
|
9
|
+
import { InvoiceOcrPreviewOperation } from './ocr-preview.js';
|
|
10
|
+
import { InvoiceUpdateApplyOperation, InvoiceUpdatePrepareOperation } from './update.js';
|
|
11
|
+
import { InvoiceUploadOperation } from './upload.js';
|
|
12
|
+
import { InvoiceValidatePreviewOperation } from './validate-preview.js';
|
|
13
|
+
function buildRegistry() {
|
|
14
|
+
const registry = new Map();
|
|
15
|
+
const handlers = [
|
|
16
|
+
new InvoiceListOperation('invoice.list', 0),
|
|
17
|
+
new InvoiceListOperation('invoice.enterprise.list', 6),
|
|
18
|
+
new InvoiceGetOperation(),
|
|
19
|
+
new InvoiceUploadOperation(),
|
|
20
|
+
new InvoiceOcrPreviewOperation(),
|
|
21
|
+
new InvoiceValidatePreviewOperation(),
|
|
22
|
+
new InvoiceImportPrepareOperation(),
|
|
23
|
+
new InvoiceImportApplyOperation(),
|
|
24
|
+
new InvoiceAddPrepareOperation(),
|
|
25
|
+
new InvoiceAddApplyOperation(),
|
|
26
|
+
new InvoiceUpdatePrepareOperation(),
|
|
27
|
+
new InvoiceUpdateApplyOperation(),
|
|
28
|
+
new InvoiceDownloadOperation(),
|
|
29
|
+
new InvoiceDeletePrepareOperation(),
|
|
30
|
+
new InvoiceDeleteApplyOperation(),
|
|
31
|
+
];
|
|
32
|
+
for (const handler of handlers) {
|
|
33
|
+
if (registry.has(handler.name))
|
|
34
|
+
throw new Error(`duplicate invoice operation handler: ${handler.name}`);
|
|
35
|
+
registry.set(handler.name, handler);
|
|
36
|
+
}
|
|
37
|
+
for (const contract of invoiceOperations) {
|
|
38
|
+
if (!registry.has(contract.name))
|
|
39
|
+
throw new Error(`missing invoice operation handler: ${contract.name}`);
|
|
40
|
+
}
|
|
41
|
+
return registry;
|
|
42
|
+
}
|
|
43
|
+
const invoiceOperationRegistry = buildRegistry();
|
|
44
|
+
export function getInvoiceOperation(operation) {
|
|
45
|
+
const handler = invoiceOperationRegistry.get(operation);
|
|
46
|
+
if (!handler) {
|
|
47
|
+
throw invoiceValidationError('operation_unknown', `业票通不支持操作:${operation}`);
|
|
48
|
+
}
|
|
49
|
+
return handler;
|
|
50
|
+
}
|