diffcat-cli 0.2.1 → 0.3.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/README.md +34 -5
- package/connectors/workbuddy/cli.json +3 -3
- package/connectors/workbuddy/connector-meta.json +10 -4
- package/connectors/workbuddy/skills/diffcat/SKILL.md +39 -15
- package/connectors/workbuddy/skills/diffcat/references/knowledge.md +26 -0
- package/connectors/workbuddy/skills/diffcat/references/operations.md +12 -0
- package/connectors/workbuddy/skills/diffcat/references/safety.md +1 -1
- package/dist/capability-authorization.d.ts +23 -0
- package/dist/capability-authorization.js +36 -0
- package/dist/capability-authorization.js.map +1 -0
- package/dist/client.d.ts +4 -1
- package/dist/client.js +14 -0
- package/dist/client.js.map +1 -1
- package/dist/device-login.d.ts +0 -1
- package/dist/device-login.js +0 -2
- package/dist/device-login.js.map +1 -1
- package/dist/index.js +73 -40
- package/dist/index.js.map +1 -1
- package/dist/knowledge-store.d.ts +55 -0
- package/dist/knowledge-store.js +265 -0
- package/dist/knowledge-store.js.map +1 -0
- package/dist/knowledge-types.d.ts +47 -0
- package/dist/knowledge-types.js +2 -0
- package/dist/knowledge-types.js.map +1 -0
- package/dist/types.d.ts +18 -0
- package/knowledge/catalog.json +542 -0
- package/knowledge/topics/documents/consignment-reconciliation.md +7 -0
- package/knowledge/topics/documents/crowdfunding-order.md +7 -0
- package/knowledge/topics/documents/direct-order.md +7 -0
- package/knowledge/topics/documents/expense-request.md +7 -0
- package/knowledge/topics/documents/inbound-order.md +7 -0
- package/knowledge/topics/documents/invoice-request.md +7 -0
- package/knowledge/topics/documents/leave-request.md +7 -0
- package/knowledge/topics/documents/outbound-order.md +7 -0
- package/knowledge/topics/documents/purchase-request.md +7 -0
- package/knowledge/topics/documents/refund-request.md +7 -0
- package/knowledge/topics/documents/sales-order.md +17 -0
- package/knowledge/topics/documents/stocktake-order.md +7 -0
- package/knowledge/topics/documents/supply-entry-order.md +7 -0
- package/knowledge/topics/documents/supply-issue-request.md +7 -0
- package/knowledge/topics/documents/supply-purchase-request.md +7 -0
- package/knowledge/topics/documents/supply-stocktake-order.md +7 -0
- package/knowledge/topics/guides/document-drafts.md +13 -0
- package/knowledge/topics/guides/login-and-authorization.md +12 -0
- package/knowledge/topics/guides/master-data-and-query.md +13 -0
- package/knowledge/topics/guides/recovery.md +13 -0
- package/knowledge/topics/guides/workflow-tasks.md +12 -0
- package/knowledge/topics/modules/administration.md +12 -0
- package/knowledge/topics/modules/crowdfunding.md +14 -0
- package/knowledge/topics/modules/finance.md +14 -0
- package/knowledge/topics/modules/inventory.md +14 -0
- package/knowledge/topics/modules/operations.md +14 -0
- package/knowledge/topics/modules/organization.md +16 -0
- package/knowledge/topics/modules/partner.md +11 -0
- package/knowledge/topics/modules/project.md +17 -0
- package/knowledge/topics/modules/sales.md +15 -0
- package/knowledge/topics/overview/navigation.md +21 -0
- package/knowledge/topics/overview/system.md +14 -0
- package/knowledge/topics/troubleshooting/document-correction.md +16 -0
- package/knowledge/topics/troubleshooting/permission-and-not-found.md +12 -0
- package/knowledge/topics/troubleshooting/workflow-stuck.md +11 -0
- package/package.json +2 -1
- package/plugins/diffcat/.codex-plugin/plugin.json +7 -5
- package/plugins/diffcat/README.md +7 -1
- package/plugins/diffcat/skills/diffcat/SKILL.md +32 -7
- package/plugins/diffcat/skills/diffcat/agents/openai.yaml +2 -2
- package/plugins/diffcat/skills/diffcat/references/authentication.md +12 -5
- package/plugins/diffcat/skills/diffcat/references/capabilities.md +1 -0
- package/plugins/diffcat/skills/diffcat/references/knowledge.md +40 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# diffcat-cli
|
|
2
2
|
|
|
3
|
-
供 AI 智能体和本地自动化使用的 Diffcat CLI
|
|
3
|
+
供 AI 智能体和本地自动化使用的 Diffcat CLI。除受控业务操作外,CLI 内置了随版本发布的中文业务知识库,可介绍功能、模块、办理方法并辅助疑难诊断。CLI 只能调用服务端登记的能力,不能传入任意 URL 或 SQL。
|
|
4
4
|
|
|
5
5
|
## 安装
|
|
6
6
|
|
|
@@ -28,7 +28,7 @@ diffcat setup codex
|
|
|
28
28
|
|
|
29
29
|
WorkBuddy 连接器的版本必须与 npm 包版本同步。提交 WorkBuddy 审核前,应先发布对应 npm 版本,再将 `connectors/workbuddy` 目录打包提交。
|
|
30
30
|
|
|
31
|
-
##
|
|
31
|
+
## 登录与能力授权
|
|
32
32
|
|
|
33
33
|
正式环境地址如下:
|
|
34
34
|
|
|
@@ -40,13 +40,27 @@ WorkBuddy 连接器的版本必须与 npm 包版本同步。提交 WorkBuddy 审
|
|
|
40
40
|
|
|
41
41
|
CLI 默认使用正式 API,连接其他部署时可显式传入 `--server <url>`。
|
|
42
42
|
|
|
43
|
+
先登录并建立长期设备连接。登录本身不会获得任何业务能力:
|
|
44
|
+
|
|
43
45
|
```bash
|
|
44
|
-
diffcat auth login
|
|
46
|
+
diffcat auth login
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
登录后按需申请一个或多个能力,CLI 会输出独立的网页能力确认地址:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
diffcat capability request \
|
|
45
53
|
--capability pm.projects.read \
|
|
46
54
|
--capability sales.orders.read
|
|
47
55
|
```
|
|
48
56
|
|
|
49
|
-
|
|
57
|
+
需要完整只读工作空间时,可以一次申请服务端维护的全部只读能力。该预设不会包含写入能力:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
diffcat capability request --all-read
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
只有用户在网页中确认的能力才会被授予;用户当前业务权限或管理员策略不允许的能力会从授权中剔除。
|
|
50
64
|
|
|
51
65
|
## 常用命令
|
|
52
66
|
|
|
@@ -54,7 +68,12 @@ CLI 会输出浏览器授权地址。只有用户在网页中确认的能力才
|
|
|
54
68
|
diffcat --pretty auth status
|
|
55
69
|
diffcat --pretty capability list
|
|
56
70
|
diffcat --pretty capability catalog
|
|
57
|
-
diffcat
|
|
71
|
+
diffcat --pretty knowledge outline
|
|
72
|
+
diffcat --pretty knowledge search "项目模块怎么用"
|
|
73
|
+
diffcat --pretty knowledge get module.project
|
|
74
|
+
diffcat --pretty knowledge flow SALES_ORDER
|
|
75
|
+
diffcat capability request --preset master-data-read
|
|
76
|
+
diffcat capability request --all-read
|
|
58
77
|
diffcat resource list md.customers --query '{"pageSize":20}'
|
|
59
78
|
diffcat resource get md.materials 123 --include bomLines
|
|
60
79
|
diffcat document list inv.purchase_requests --query '{"status":"DRAFT"}'
|
|
@@ -68,6 +87,16 @@ diffcat task approve 456 --comment "同意"
|
|
|
68
87
|
diffcat operation resume <operation-id>
|
|
69
88
|
```
|
|
70
89
|
|
|
90
|
+
## 内置知识与实时流程
|
|
91
|
+
|
|
92
|
+
知识库采用“入口大纲 → 本地检索 → 按主题加载 → 关联主题”的结构。`knowledge search` 只返回摘要和匹配章节,Agent 应在确认命中后再用 `knowledge get` 加载正文,避免一次读取整套知识。正文为中文,英文模块名、命令名和常用术语可作为检索别名。
|
|
93
|
+
|
|
94
|
+
`knowledge outline`、`knowledge search` 和 `knowledge get` 每次都会验证当前 profile 的真实登录状态,但不要求额外业务能力。授权过期或远程撤销后会立即失败。`auth status` 同时返回当前用户的只读身份摘要,便于在诊断时判断创建人、部门、角色和办理关系。
|
|
95
|
+
|
|
96
|
+
`knowledge flow <流程编码或实体名>` 查询数据库中当前启用定义的最新 `PUBLISHED` 版本,需要用户显式授予 `knowledge.flows.read`,并要求当前用户拥有该单据的业务菜单。返回内容只包含流程名称、版本、节点职责与策略、办理人显示名称和带标签连线;不会返回版本快照、内部动作、原始条件、内部配置或办理人 ID。无该能力或菜单时仍可读取静态基线,但不能声称已经确认当前版本、实际办理人或最新分支。
|
|
97
|
+
|
|
98
|
+
知识与诊断命令不会修改单据。对于“订单填错”等问题,Agent 会先取得单号,再查询真实单据、当前身份、待办和下游影响,给出草稿修改、撤回后修改、驳回/撤销后重建或受控反冲等建议;本版本没有新增编辑、撤回、取消或重建能力。
|
|
99
|
+
|
|
71
100
|
标准输出始终是 JSON,登录提示和进度写入标准错误。写操作自动携带幂等键;也可以通过 `--idempotency-key` 指定。高风险审批第一次调用只创建五分钟有效的确认意图,用户在网页二次认证后再运行 `operation resume`。
|
|
72
101
|
|
|
73
102
|
## 凭据与协议
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"version": "22"
|
|
5
5
|
},
|
|
6
6
|
"init": {
|
|
7
|
-
"darwin": "npm install -g diffcat-cli@0.
|
|
8
|
-
"linux": "npm install -g diffcat-cli@0.
|
|
9
|
-
"win32": "npm install -g diffcat-cli@0.
|
|
7
|
+
"darwin": "npm install -g diffcat-cli@0.3.0",
|
|
8
|
+
"linux": "npm install -g diffcat-cli@0.3.0",
|
|
9
|
+
"win32": "npm install -g diffcat-cli@0.3.0"
|
|
10
10
|
}
|
|
11
11
|
}
|
|
@@ -2,19 +2,25 @@
|
|
|
2
2
|
"name": "DiffCat",
|
|
3
3
|
"name_zh": "DiffCat 企业管理",
|
|
4
4
|
"name_en": "DiffCat",
|
|
5
|
-
"description": "
|
|
6
|
-
"description_zh": "
|
|
7
|
-
"description_en": "
|
|
5
|
+
"description": "Check login first, then explain, diagnose, query, and handle authorized DiffCat business work in clear everyday language.",
|
|
6
|
+
"description_zh": "先检查登录,再用简单自然的话介绍功能、诊断问题、查询资料、创建草稿和办理审批。",
|
|
7
|
+
"description_en": "Check login first, then explain features, diagnose issues, query data, create drafts, and handle approvals in plain language.",
|
|
8
8
|
"source": "diffcat-cli",
|
|
9
9
|
"type": "cli",
|
|
10
|
-
"version": "0.
|
|
10
|
+
"version": "0.3.0",
|
|
11
11
|
"minWorkbuddyVersion": "4.24.0",
|
|
12
12
|
"examples_zh": [
|
|
13
|
+
"销售订单现在的办理流程和每个节点职责是什么",
|
|
14
|
+
"项目模块怎么用",
|
|
15
|
+
"我的订单填错了,请根据单号和当前状态告诉我怎么处理",
|
|
13
16
|
"查询我有权查看的客户和最近销售订单",
|
|
14
17
|
"根据现有基础资料创建一张采购申请草稿并核对结果",
|
|
15
18
|
"查看我的采购申请待办,在我明确确认后再审批"
|
|
16
19
|
],
|
|
17
20
|
"examples_en": [
|
|
21
|
+
"Explain the current sales order workflow and each step's responsibility",
|
|
22
|
+
"How do I use the project module",
|
|
23
|
+
"Diagnose how to correct my order based on its number and current status",
|
|
18
24
|
"List the customers and recent sales orders I can access",
|
|
19
25
|
"Create a purchase request draft from existing master data and verify it",
|
|
20
26
|
"Show my purchase request tasks and approve only after I explicitly confirm"
|
|
@@ -2,17 +2,30 @@
|
|
|
2
2
|
name: diffcat
|
|
3
3
|
display_name: DiffCat 企业管理
|
|
4
4
|
display_name_en: DiffCat Business Operations
|
|
5
|
-
description: Use the DiffCat CLI for authorized business queries, document drafts, and controlled workflow approvals.
|
|
6
|
-
description_zh: 使用 DiffCat CLI
|
|
7
|
-
description_en:
|
|
5
|
+
description: Use the DiffCat CLI for built-in business knowledge, issue diagnosis, authorized business queries, document drafts, and controlled workflow approvals. Always check login first and speak in plain, non-technical language.
|
|
6
|
+
description_zh: 使用 DiffCat CLI 介绍功能、诊断问题和办理业务;每次都先检查登录状态,并用自然、易懂的话回复。
|
|
7
|
+
description_en: Use DiffCat CLI for guidance, diagnosis, and business work; always check login first and reply in natural, non-technical language.
|
|
8
8
|
category: productivity
|
|
9
|
-
version: 0.
|
|
9
|
+
version: 0.3.0
|
|
10
10
|
author: DiffCat
|
|
11
11
|
---
|
|
12
12
|
|
|
13
13
|
# DiffCat CLI
|
|
14
14
|
|
|
15
|
-
Use the installed `diffcat` command as the only DiffCat business execution surface. Do not bypass it with internal REST endpoints, SQL, browser automation, or direct database access.
|
|
15
|
+
Use the installed `diffcat` command as the only DiffCat knowledge and business execution surface. Do not bypass it with internal REST endpoints, SQL, browser automation, or direct database access.
|
|
16
|
+
|
|
17
|
+
## Login gate — always do this first
|
|
18
|
+
|
|
19
|
+
On every invocation of this skill, run the selected profile's login check before analyzing or answering the DiffCat request, reading task references, viewing available operations, or running another DiffCat command:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
diffcat --profile workbuddy --pretty auth status
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
- If the command is unavailable, briefly ask the user to install DiffCat CLI first, then stop.
|
|
26
|
+
- If the profile is not logged in, its login has expired, or the result does not clearly confirm an active login, stop the turn. Reply only that DiffCat is not logged in and ask the user to complete login first. Do not answer any other question or any other part of the request, including unrelated parts, and do not make another DiffCat call.
|
|
27
|
+
- If the user asks for login help, help only with login. Resume the original task only after login completes and a fresh `auth status` check succeeds.
|
|
28
|
+
- When the user says they have logged in, always check again. Never rely on a previous check.
|
|
16
29
|
|
|
17
30
|
## Inputs
|
|
18
31
|
|
|
@@ -22,32 +35,30 @@ Use the installed `diffcat` command as the only DiffCat business execution surfa
|
|
|
22
35
|
|
|
23
36
|
## Output
|
|
24
37
|
|
|
25
|
-
Return the requested
|
|
38
|
+
Return the requested information or a checked result in plain language. For changes, say what was completed and whether it was checked. Include a reference number only when it will help the user follow up, and label it in ordinary language.
|
|
26
39
|
|
|
27
40
|
## Process
|
|
28
41
|
|
|
29
42
|
### 1. Check installation and authorization
|
|
30
43
|
|
|
31
|
-
|
|
44
|
+
The login gate above has already confirmed that the CLI exists and the profile is logged in. Keep using the same profile for the entire task.
|
|
32
45
|
|
|
33
|
-
|
|
34
|
-
diffcat --version
|
|
35
|
-
diffcat --profile workbuddy --pretty auth status
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
If the profile is not logged in, use the CLI's default production API unless the user explicitly requests another environment. Discover the public catalog, select only the capabilities needed for the user's workflow, and start Device Flow:
|
|
46
|
+
If the user asks for help logging in, use the CLI's default production service unless they explicitly request another environment. Select only the access needed for their workflow and start the browser login:
|
|
39
47
|
|
|
40
48
|
```bash
|
|
49
|
+
diffcat --profile workbuddy auth login
|
|
41
50
|
diffcat --pretty capability catalog
|
|
42
|
-
diffcat --profile workbuddy
|
|
51
|
+
diffcat --profile workbuddy capability request --capability md.customers.read
|
|
43
52
|
```
|
|
44
53
|
|
|
45
|
-
The default production API is `https://diffcat-api.howcat.cn`; use `--server <url>` only when the user explicitly chooses another deployment.
|
|
54
|
+
The default production API is `https://diffcat-api.howcat.cn`; use `--server <url>` only when the user explicitly chooses another deployment. Login and capability authorization use separate browser confirmation pages at `https://diffcat.howcat.cn`. Never request all capabilities by default, operate either authorization page for the user, or ask them to paste tokens, passwords, cookies, or DPoP keys into chat.
|
|
46
55
|
|
|
47
56
|
After authorization, run `auth status`, `grant list`, and `capability list`. A public capability is not automatically granted. Effective access is the intersection of the registered capability, explicit grant, live menu/action permissions, administrator policy constraints, and object-level business checks.
|
|
48
57
|
|
|
49
58
|
### 2. Discover the live contract
|
|
50
59
|
|
|
60
|
+
For feature introductions, module guidance, workflow explanations, or issue diagnosis, read @references/knowledge.md and start with `knowledge search`. Static knowledge needs only the successful login check, so do not request a business capability for it. Live `knowledge flow` requires `knowledge.flows.read` and the matching business menu.
|
|
61
|
+
|
|
51
62
|
Before constructing unfamiliar input, run:
|
|
52
63
|
|
|
53
64
|
```bash
|
|
@@ -74,9 +85,21 @@ Treat stdout as a single JSON document and stderr as progress. Require exit code
|
|
|
74
85
|
|
|
75
86
|
Never report success for `running`, `unknown`, `awaiting_confirmation`, `failed`, `verification_failed`, `rejected`, or `expired`. Use `operation status` and the recovery rules in @references/safety.md rather than replaying a write.
|
|
76
87
|
|
|
88
|
+
### 6. Use plain, human language
|
|
89
|
+
|
|
90
|
+
- Match the user's language and write like a helpful colleague. Use short sentences and assume the user knows the business, not software internals.
|
|
91
|
+
- Prefer ordinary wording such as “可查看的内容”, “需要填写的信息”, “记录”, “单据”, “办理结果”, and “避免重复提交”. Avoid terms such as capability, schema, entity, payload, endpoint, JSON, idempotency, HTTP, and API in user-facing replies.
|
|
92
|
+
- Lead with the business result or the next action. Explain errors simply and say what the user can do next.
|
|
93
|
+
- Do not show source code, request bodies, raw command output, internal field names, capability IDs, status codes, or command lines unless the user explicitly requests technical details or one exact command is needed for login or recovery.
|
|
94
|
+
- Use readable names for people, companies, products, and documents. Show an internal identifier only when needed to distinguish duplicates or continue later, and label it in ordinary language.
|
|
95
|
+
- Keep technical verification details internal. Report outcomes in business terms instead of repeating raw response fields.
|
|
96
|
+
|
|
77
97
|
## Examples
|
|
78
98
|
|
|
79
99
|
- “查询客户海猫科技最近的销售订单” → verify grant, resolve the unique customer ID, query authorized sales orders, and report pagination coverage.
|
|
100
|
+
- “项目模块怎么用” → search local knowledge, load the project topic, and explain its entry, prerequisites, core actions, states, and related modules.
|
|
101
|
+
- “销售订单办理流程” → load the sales-order topic, query the current published flow when authorized, and explain actual branches, responsibilities, and configured assignees.
|
|
102
|
+
- “我的订单填错了” → ask for the order number when missing, then combine the unique document, current subject, tasks, correction flags, and downstream records; advise only and never invent an unsupported write.
|
|
80
103
|
- “创建采购申请草稿” → describe the create capability, resolve material/company/department data, ask for missing business choices, create with a stable idempotency key, then re-read and verify `DRAFT`.
|
|
81
104
|
- “审批 456” → read the task and related purchase request, show decision-relevant details, invoke only after explicit approval intent, wait for user browser confirmation, resume the same operation, and verify completion.
|
|
82
105
|
|
|
@@ -91,4 +114,5 @@ Never report success for `running`, `unknown`, `awaiting_confirmation`, `failed`
|
|
|
91
114
|
## Reference
|
|
92
115
|
|
|
93
116
|
- @references/operations.md — available resources, commands, and query routes.
|
|
117
|
+
- @references/knowledge.md — local knowledge search, live workflow guidance, and issue-diagnosis routing.
|
|
94
118
|
- @references/safety.md — least privilege, draft, approval, idempotency, recovery, and secret-handling rules.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# DiffCat knowledge and diagnosis
|
|
2
|
+
|
|
3
|
+
After the mandatory `workbuddy` profile login check succeeds, use the packaged knowledge graph progressively:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
diffcat --profile workbuddy --pretty knowledge search "<user question>" --limit 5
|
|
7
|
+
diffcat --profile workbuddy --pretty knowledge get <topic-id>
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Use `knowledge outline` only for broad navigation. Static knowledge needs a valid login but no separate business capability.
|
|
11
|
+
|
|
12
|
+
## Workflow questions
|
|
13
|
+
|
|
14
|
+
Load the matching document topic, then use `knowledge flow <flow-code-or-entity-name>` when the current configuration matters. This live command requires explicit `knowledge.flows.read` authorization and the matching business menu. Explain the published version, ordered nodes, labeled branches, responsibilities, policies, and configured assignee names. Do not expose raw conditions, internal actions, configuration, snapshots, or assignee IDs.
|
|
15
|
+
|
|
16
|
+
If live flow access is unavailable, use the static baseline and clearly state that the current published version, actual assignees, and latest branch rules could not be verified.
|
|
17
|
+
|
|
18
|
+
## Module questions
|
|
19
|
+
|
|
20
|
+
Explain the entry, prerequisites, main actions, important states, downstream effects, and related modules from the selected module topic. Query live data only when the user asks about their own records or current configuration.
|
|
21
|
+
|
|
22
|
+
## Wrong-document diagnosis
|
|
23
|
+
|
|
24
|
+
Ask for the document number if it is missing. Identify exactly one document, then combine its detail with `auth status` subject, status, `myFlowTasks`, edit/withdraw/resubmit flags, and downstream documents. Load the correction topic and recommend the least disruptive valid path.
|
|
25
|
+
|
|
26
|
+
Give advice only. Never invent edit, withdraw, cancel, rebuild, reverse, or other write behavior. Use a write only when a separately registered live capability supports it and the user clearly requests it; this release adds no such correction capability.
|
|
@@ -13,6 +13,17 @@ diffcat --profile workbuddy grant list
|
|
|
13
13
|
diffcat --profile workbuddy auth logout
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
## Built-in knowledge
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
diffcat --profile workbuddy --pretty knowledge outline
|
|
20
|
+
diffcat --profile workbuddy --pretty knowledge search "<question>" --limit 5
|
|
21
|
+
diffcat --profile workbuddy --pretty knowledge get <topic-id>
|
|
22
|
+
diffcat --profile workbuddy --pretty knowledge flow <flow-code-or-entity-name>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The first three commands require a valid login but no additional capability. `knowledge flow` invokes `knowledge.flows.read`; it requires an explicit grant and the matching business menu. If unavailable, use the matching static topic as a baseline and clearly state that the current published version, configured assignees, and latest branch rules were not verified.
|
|
26
|
+
|
|
16
27
|
## Base and master data
|
|
17
28
|
|
|
18
29
|
Use `resource list <resource> --query <json>` and, when the live schema permits `get`, `resource get <resource> <id>`.
|
|
@@ -60,5 +71,6 @@ All current create abilities produce `DRAFT` only. They do not submit, start app
|
|
|
60
71
|
- `stats list/query` → `data_center.stats.read`; registered widgets only, never SQL.
|
|
61
72
|
- `task list/get` → `flow.tasks.read` when allowed by the live schema.
|
|
62
73
|
- `task approve` → `flow.tasks.approve`; currently limited to the current user's pending purchase-request `APPROVE/APPROVAL` task.
|
|
74
|
+
- `knowledge flow` → `knowledge.flows.read`; reads the latest enabled `PUBLISHED` Flow V2 definition through a safe business view.
|
|
63
75
|
|
|
64
76
|
List handlers default to 20 rows and cap a page at 100; a grant can impose a lower limit. Project or statistics queries can additionally require allowed project/department IDs.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Least privilege
|
|
4
4
|
|
|
5
|
-
- Prefer individual
|
|
5
|
+
- Prefer individual `capability request --capability` values. Use `all-read`, `master-data-read`, `document-read`, or `document-draft` only for a clearly requested recurring workflow.
|
|
6
6
|
- Never switch profiles or environments to evade a denial.
|
|
7
7
|
- Do not export personal credentials for CI or containers. Credentials and DPoP keys stay in the operating-system credential store.
|
|
8
8
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { DiffcatClient } from './client.js';
|
|
2
|
+
interface CapabilityAuthorizationCreated {
|
|
3
|
+
status: 'pending' | 'already_granted';
|
|
4
|
+
requestId: string | null;
|
|
5
|
+
confirmationUrl: string | null;
|
|
6
|
+
requestedCapabilities: string[];
|
|
7
|
+
capabilities?: string[];
|
|
8
|
+
expiresAt?: string;
|
|
9
|
+
interval?: number;
|
|
10
|
+
}
|
|
11
|
+
interface CapabilityAuthorizationStatus {
|
|
12
|
+
requestId: string;
|
|
13
|
+
status: 'pending' | 'approved' | 'denied' | 'expired';
|
|
14
|
+
grantedCapabilities: string[];
|
|
15
|
+
capabilities: string[];
|
|
16
|
+
expiresAt: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function requestCapabilityAuthorization(input: {
|
|
19
|
+
client: DiffcatClient;
|
|
20
|
+
capabilityIds: string[];
|
|
21
|
+
presetIds: string[];
|
|
22
|
+
}): Promise<CapabilityAuthorizationCreated | CapabilityAuthorizationStatus>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { writeProgress } from './output.js';
|
|
2
|
+
export async function requestCapabilityAuthorization(input) {
|
|
3
|
+
const created = await input.client.post('/agent/v1/capability-authorizations/create', {
|
|
4
|
+
capabilityIds: [...new Set(input.capabilityIds)],
|
|
5
|
+
presetIds: [...new Set(input.presetIds)],
|
|
6
|
+
constraints: {},
|
|
7
|
+
});
|
|
8
|
+
if (created.status === 'already_granted') {
|
|
9
|
+
await input.client.replaceScope(created.capabilities ?? []);
|
|
10
|
+
return created;
|
|
11
|
+
}
|
|
12
|
+
if (!created.requestId || !created.confirmationUrl || !created.expiresAt) {
|
|
13
|
+
throw new Error('服务端没有返回完整的能力授权事务');
|
|
14
|
+
}
|
|
15
|
+
writeProgress(`请在浏览器中确认能力授权:${created.confirmationUrl}`);
|
|
16
|
+
const deadline = new Date(created.expiresAt).getTime();
|
|
17
|
+
const intervalMs = Math.max(created.interval ?? 5, 5) * 1000;
|
|
18
|
+
while (Date.now() < deadline) {
|
|
19
|
+
await delay(intervalMs);
|
|
20
|
+
const status = await input.client.get('/agent/v1/capability-authorizations/status', { id: created.requestId });
|
|
21
|
+
if (status.status === 'pending')
|
|
22
|
+
continue;
|
|
23
|
+
if (status.status === 'approved') {
|
|
24
|
+
await input.client.replaceScope(status.capabilities);
|
|
25
|
+
return status;
|
|
26
|
+
}
|
|
27
|
+
if (status.status === 'denied')
|
|
28
|
+
throw new Error('用户拒绝了能力授权请求');
|
|
29
|
+
throw new Error('能力授权请求已过期,请重新发起');
|
|
30
|
+
}
|
|
31
|
+
throw new Error('能力授权请求已超时,请重新发起');
|
|
32
|
+
}
|
|
33
|
+
function delay(milliseconds) {
|
|
34
|
+
return new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=capability-authorization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability-authorization.js","sourceRoot":"","sources":["../src/capability-authorization.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAoB5C,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAAC,KAIpD;IACC,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CACrC,4CAA4C,EAC5C;QACE,aAAa,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAChD,SAAS,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACxC,WAAW,EAAE,EAAE;KAChB,CACF,CAAC;IACF,IAAI,OAAO,CAAC,MAAM,KAAK,iBAAiB,EAAE,CAAC;QACzC,MAAM,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;QAC5D,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,eAAe,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;QACzE,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACtC,CAAC;IAED,aAAa,CAAC,gBAAgB,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IACzD,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC;IACvD,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;IAC7D,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;QAC7B,MAAM,KAAK,CAAC,UAAU,CAAC,CAAC;QACxB,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,GAAG,CACnC,4CAA4C,EAC5C,EAAE,EAAE,EAAE,OAAO,CAAC,SAAS,EAAE,CAC1B,CAAC;QACF,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS;YAAE,SAAS;QAC1C,IAAI,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YACjC,MAAM,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;YACrD,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,KAAK,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;QAC/D,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,KAAK,CAAC,YAAoB;IACjC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;AACrE,CAAC"}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { OperationResponse, PendingOperation } from './types.js';
|
|
1
|
+
import type { CurrentAgentGrant, OperationResponse, PendingOperation } from './types.js';
|
|
2
2
|
export declare class DiffcatApiError extends Error {
|
|
3
3
|
readonly status: number;
|
|
4
4
|
readonly body: unknown;
|
|
@@ -20,6 +20,7 @@ export declare class DiffcatClient {
|
|
|
20
20
|
pendingOperationIds: string[];
|
|
21
21
|
};
|
|
22
22
|
getRefreshToken(): string;
|
|
23
|
+
replaceScope(capabilities: string[]): Promise<void>;
|
|
23
24
|
get<T>(path: string, query?: Record<string, string>): Promise<T>;
|
|
24
25
|
post<T>(path: string, body: Record<string, unknown>, headers?: Record<string, string>): Promise<T>;
|
|
25
26
|
invoke(capabilityId: string, input: Record<string, unknown>, options?: {
|
|
@@ -27,6 +28,8 @@ export declare class DiffcatClient {
|
|
|
27
28
|
idempotencyKey?: string;
|
|
28
29
|
}): Promise<OperationResponse>;
|
|
29
30
|
getPendingOperation(id: string): PendingOperation | null;
|
|
31
|
+
/** 验证当前授权仍有效,并返回登录主体信息。 */
|
|
32
|
+
currentGrant(): Promise<CurrentAgentGrant>;
|
|
30
33
|
private apiRequest;
|
|
31
34
|
private ensureAccessToken;
|
|
32
35
|
private refresh;
|
package/dist/client.js
CHANGED
|
@@ -45,6 +45,16 @@ export class DiffcatClient {
|
|
|
45
45
|
getRefreshToken() {
|
|
46
46
|
return this.credential.refreshToken;
|
|
47
47
|
}
|
|
48
|
+
async replaceScope(capabilities) {
|
|
49
|
+
await withProfileLock(this.profile, async () => {
|
|
50
|
+
const latest = loadCredential(this.keyringAccount);
|
|
51
|
+
if (!latest)
|
|
52
|
+
throw new Error(`系统凭据库中没有配置 ${this.profile} 的授权`);
|
|
53
|
+
latest.scope = [...new Set(capabilities)];
|
|
54
|
+
saveCredential(this.keyringAccount, latest);
|
|
55
|
+
this.credential = latest;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
48
58
|
async get(path, query) {
|
|
49
59
|
const suffix = query ? `?${new URLSearchParams(query).toString()}` : '';
|
|
50
60
|
return this.apiRequest('GET', `${path}${suffix}`);
|
|
@@ -71,6 +81,10 @@ export class DiffcatClient {
|
|
|
71
81
|
getPendingOperation(id) {
|
|
72
82
|
return this.credential.pendingOperations?.[id] ?? null;
|
|
73
83
|
}
|
|
84
|
+
/** 验证当前授权仍有效,并返回登录主体信息。 */
|
|
85
|
+
currentGrant() {
|
|
86
|
+
return this.post('/agent/v1/grant/current', {});
|
|
87
|
+
}
|
|
74
88
|
async apiRequest(method, path, body, headers = {}, retry = true) {
|
|
75
89
|
await this.ensureAccessToken();
|
|
76
90
|
const response = await this.fetchWithDpop(method, path, this.credential.accessToken, body, headers);
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAgB5C,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAG7B;IACA;IAHX,YACE,OAAe,EACN,MAAc,EACd,IAAa;QAEtB,KAAK,CAAC,OAAO,CAAC,CAAC;QAHN,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAS;QAGtB,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED,MAAM,OAAO,aAAa;IAEb;IACA;IACA;IACD;IAJV,YACW,OAAe,EACf,MAAc,EACd,cAAsB,EACvB,UAA4B;QAH3B,YAAO,GAAP,OAAO,CAAQ;QACf,WAAM,GAAN,MAAM,CAA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jD,KAAK,MAAM,GAAG,IAAI,CAAC,mBAAmB,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,CAAC;YACnE,IAAI,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,QAAQ;gBAAE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IACD,OAAO,qBAAqB,MAAM,GAAG,CAAC;AACxC,CAAC"}
|
package/dist/device-login.d.ts
CHANGED
package/dist/device-login.js
CHANGED
|
@@ -19,8 +19,6 @@ export async function loginWithDeviceFlow(input) {
|
|
|
19
19
|
body: JSON.stringify({
|
|
20
20
|
client_id: 'diffcat-cli',
|
|
21
21
|
device_name: input.deviceName?.trim() || `CLI · ${hostname()}`,
|
|
22
|
-
capabilities: [...new Set(input.capabilities)],
|
|
23
|
-
constraints: {},
|
|
24
22
|
}),
|
|
25
23
|
});
|
|
26
24
|
const payload = await parseResponse(response);
|
package/dist/device-login.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-login.js","sourceRoot":"","sources":["../src/device-login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE3E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAW5C,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,
|
|
1
|
+
{"version":3,"file":"device-login.js","sourceRoot":"","sources":["../src/device-login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC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