@qoder-ai/qmind-cli 3.0.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/CHANGELOG.zh-CN.md +20 -0
- package/README.md +25 -13
- package/README.zh-CN.md +25 -13
- package/dist/bot-gateway-CB6KrV15.js +373 -0
- package/dist/cards-JaeY0mah.js +132 -0
- package/dist/{imports-Da88W09Q.js → imports-CHEgKeR5.js} +3 -3
- package/dist/{management-xYuUDFtg.js → management-J4OEjnLA.js} +5 -4
- package/dist/notes-CxkxuWdP.js +128 -0
- package/dist/qmind.js +396 -395
- package/dist/{shared-DwycozMA.js → shared-9iPJsfjP.js} +15 -6
- package/dist/source-upload-mZ-N52xb.js +17 -0
- package/dist/transfers-BRx_Hrlz.js +254 -0
- package/package.json +5 -3
- package/dist/cards-2J6ebaI0.js +0 -75
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,26 @@ English (default) | [简体中文](CHANGELOG.zh-CN.md)
|
|
|
4
4
|
|
|
5
5
|
Published versions below describe the Global CLI/shared implementation, not historical CN releases. CN will join the shared history with the future joint release.
|
|
6
6
|
|
|
7
|
+
## 3.1.1
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- a92c490: Add `update` and `update --check` for installer-managed Native CLI releases, with fixed Global/CN channels, release and installer checksum verification, downgrade protection, transactional replacement, and Windows post-exit update scheduling. npm-managed installations continue to return the appropriate npm upgrade command.
|
|
12
|
+
|
|
13
|
+
### Changes without version bumps
|
|
14
|
+
|
|
15
|
+
- Add repository-maintained native CLI artifact generation, candidate orchestration, Bun compile, recoverable installers, strict offline handoff verification, and macOS, Windows, and Linux finalization capabilities. This does not change the existing npm-installed `qmind` or `qmind-cn` runtime behavior.
|
|
16
|
+
|
|
17
|
+
## 3.1.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- bd500e8: Remove the `cards` command group and its top-level `list` / `search` aliases, following the Cards sunset policy. The dedicated card-list rendering path is removed as well; `retrieve` keeps its own card rendering and remains the way to query notebook context.
|
|
22
|
+
|
|
23
|
+
### Changes without version bumps
|
|
24
|
+
|
|
25
|
+
- Make CLI release verification recognize equivalent SSH and HTTPS repository destinations, and make settlement regression tests deterministic in depth-one CI checkouts. This changes release tooling only; package bytes and versions remain unchanged.
|
|
26
|
+
|
|
7
27
|
## 3.0.0
|
|
8
28
|
|
|
9
29
|
### Major Changes
|
package/CHANGELOG.zh-CN.md
CHANGED
|
@@ -4,6 +4,26 @@
|
|
|
4
4
|
|
|
5
5
|
以下已发布版本属于 Global CLI / 共享实现,不代表 CN 曾发布过这些版本。CN 将在后续共同发行版加入同一历史。
|
|
6
6
|
|
|
7
|
+
## 3.1.1
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- a92c490: 为 installer 管理的 Native CLI release 增加 `update` 与 `update --check`,固定使用 Global/CN channel,校验 release 和 installer checksum,拒绝降级,复用事务式替换,并在 Windows 上于当前进程退出后调度更新。npm 管理的安装仍返回对应的 npm 升级命令。
|
|
12
|
+
|
|
13
|
+
### Changes without version bumps
|
|
14
|
+
|
|
15
|
+
- 新增由仓库维护的 Native CLI 安装脚本制品生成、candidate 编排、Bun 编译、可恢复安装事务、严格离线 handoff 校验与 macOS、Windows、Linux finalization 能力;现有通过 npm 安装的 `qmind` 或 `qmind-cn` 运行时行为不变。
|
|
16
|
+
|
|
17
|
+
## 3.1.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- bd500e8: 按照 Cards 下线策略,移除 `cards` 命令组及其顶层 `list` / `search` 别名,并一并删除专用的卡片列表渲染路径;`retrieve` 保留自身的卡片渲染,仍可用于查询知识库上下文。
|
|
22
|
+
|
|
23
|
+
### Changes without version bumps
|
|
24
|
+
|
|
25
|
+
- 让 CLI 发布校验能够识别等价的 SSH 与 HTTPS 仓库目标,并使 settlement 回归测试在 depth-one CI checkout 中保持确定性。本次只修改发布工具,不改变包字节或版本。
|
|
26
|
+
|
|
7
27
|
## 3.0.0
|
|
8
28
|
|
|
9
29
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -23,6 +23,18 @@ npm update --global @qoder-ai/qmind-cli
|
|
|
23
23
|
npm uninstall --global @qoder-ai/qmind-cli
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
The Native standalone CLI uses the verified Global release channel instead. An installer-managed
|
|
27
|
+
Native executable can check or apply the latest release without Node.js or npm:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
qmind update --check
|
|
31
|
+
qmind update
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`self-update` remains an alias for `update`. The updater rejects channel/URL overrides, downgrades,
|
|
35
|
+
unowned executables, release checksum mismatches, and modified installer bytes. Windows schedules
|
|
36
|
+
replacement after the running executable exits and records details beside the executable.
|
|
37
|
+
|
|
26
38
|
## Quick start
|
|
27
39
|
|
|
28
40
|
```sh
|
|
@@ -44,19 +56,19 @@ Do not put tokens in command arguments, repositories, or logs. Run `qmind logout
|
|
|
44
56
|
|
|
45
57
|
## Commands
|
|
46
58
|
|
|
47
|
-
| Command
|
|
48
|
-
|
|
|
49
|
-
| `login` / `logout`
|
|
50
|
-
| `notebook`
|
|
51
|
-
| `
|
|
52
|
-
| `
|
|
53
|
-
| `
|
|
54
|
-
| `
|
|
55
|
-
| `
|
|
56
|
-
| `
|
|
57
|
-
| `
|
|
58
|
-
| `
|
|
59
|
-
| `
|
|
59
|
+
| Command | Purpose |
|
|
60
|
+
| ------------------------ | ---------------------------------------- |
|
|
61
|
+
| `login` / `logout` | Sign in or remove local credentials |
|
|
62
|
+
| `notebook` | Manage knowledge bases |
|
|
63
|
+
| `source` | Manage knowledge-base sources |
|
|
64
|
+
| `retrieve` | Retrieve context without invoking an LLM |
|
|
65
|
+
| `rag` | Ask questions using a knowledge base |
|
|
66
|
+
| `compile` / `lint` | Run compilation or validation workflows |
|
|
67
|
+
| `task` | Manage task runs |
|
|
68
|
+
| `upload-folder` / `sync` | Synchronize a local directory |
|
|
69
|
+
| `image` | Obtain image upload or access URLs |
|
|
70
|
+
| `version` | Print version and build information |
|
|
71
|
+
| `update` / `self-update` | Update an installer-managed Native CLI |
|
|
60
72
|
|
|
61
73
|
Run `qmind <command> --help` for complete options. Domain commands support formats such as `table`, `json`, `agent`, and `ndjson`. stdout contains results; progress and diagnostics go to stderr. Exit codes are `0` for success, `1` for runtime failure/partial success/cancellation, and `2` for invalid usage.
|
|
62
74
|
|
package/README.zh-CN.md
CHANGED
|
@@ -23,6 +23,18 @@ npm update --global @qoder-ai/qmind-cli
|
|
|
23
23
|
npm uninstall --global @qoder-ai/qmind-cli
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
Native standalone CLI 改为使用经过验证的 Global release channel。由官方 installer 管理的 Native
|
|
27
|
+
可执行文件无需 Node.js 或 npm 即可检查并安装最新版本:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
qmind update --check
|
|
31
|
+
qmind update
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`self-update` 保留为 `update` 的别名。updater 会拒绝 channel/URL 覆盖、降级、非 installer
|
|
35
|
+
管理的可执行文件、release 校验和冲突及被修改的 installer。Windows 会在当前进程退出后执行替换,
|
|
36
|
+
并在可执行文件旁记录结果。
|
|
37
|
+
|
|
26
38
|
## 快速开始
|
|
27
39
|
|
|
28
40
|
```sh
|
|
@@ -44,19 +56,19 @@ qmind retrieve --nb <notebook-id> --format agent "部署流程是什么?"
|
|
|
44
56
|
|
|
45
57
|
## 命令
|
|
46
58
|
|
|
47
|
-
| 命令
|
|
48
|
-
|
|
|
49
|
-
| `login` / `logout`
|
|
50
|
-
| `notebook`
|
|
51
|
-
| `
|
|
52
|
-
| `
|
|
53
|
-
| `
|
|
54
|
-
| `
|
|
55
|
-
| `
|
|
56
|
-
| `
|
|
57
|
-
| `
|
|
58
|
-
| `
|
|
59
|
-
| `
|
|
59
|
+
| 命令 | 用途 |
|
|
60
|
+
| ------------------------ | -------------------------------- |
|
|
61
|
+
| `login` / `logout` | 登录或清除本机凭证 |
|
|
62
|
+
| `notebook` | 管理知识库 |
|
|
63
|
+
| `source` | 管理知识库来源 |
|
|
64
|
+
| `retrieve` | 检索上下文,不发起 LLM 调用 |
|
|
65
|
+
| `rag` | 基于知识库提问 |
|
|
66
|
+
| `compile` / `lint` | 运行编译或检查工作流 |
|
|
67
|
+
| `task` | 管理任务运行 |
|
|
68
|
+
| `upload-folder` / `sync` | 同步本地目录 |
|
|
69
|
+
| `image` | 获取图片上传地址或访问地址 |
|
|
70
|
+
| `version` | 查看版本和构建信息 |
|
|
71
|
+
| `update` / `self-update` | 更新 installer 管理的 Native CLI |
|
|
60
72
|
|
|
61
73
|
使用 `qmind <command> --help` 查看完整参数。领域命令支持 `table`、`json`、`agent`、`ndjson` 等输出格式。stdout 只输出结果,进度与诊断信息输出到 stderr。退出码 `0` 表示成功,`1` 表示运行失败、部分成功或取消,`2` 表示参数错误。
|
|
62
74
|
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import { Y as timestampSchema, a as invalidArgument, c as optionalRecord, d as pagination, h as requiredText, l as optionalString, m as requiredString, n as call, p as queryPath, r as compactUndefined, s as optionalBoolean, t as assertNonEmptyPatch, u as optionalTrimmedString } from "./shared-9iPJsfjP.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region ../sdk/src/operations/bot-gateway-codecs.ts
|
|
4
|
+
const botTimestamp = z.preprocess((value) => typeof value === "object" && value !== null && !Array.isArray(value) && !("seconds" in value) ? {
|
|
5
|
+
...value,
|
|
6
|
+
seconds: 0
|
|
7
|
+
} : value, timestampSchema).optional();
|
|
8
|
+
const jsonObject = z.record(z.string(), z.json());
|
|
9
|
+
const fields = {
|
|
10
|
+
id: z.string().min(1),
|
|
11
|
+
org_id: z.string().default(""),
|
|
12
|
+
platform: z.string().default(""),
|
|
13
|
+
is_active: z.boolean().default(false),
|
|
14
|
+
created_at: botTimestamp,
|
|
15
|
+
updated_at: botTimestamp
|
|
16
|
+
};
|
|
17
|
+
function base(value) {
|
|
18
|
+
return {
|
|
19
|
+
id: value.id,
|
|
20
|
+
orgId: value.org_id,
|
|
21
|
+
platform: value.platform,
|
|
22
|
+
isActive: value.is_active,
|
|
23
|
+
...value.created_at === void 0 ? {} : { createdAt: value.created_at },
|
|
24
|
+
...value.updated_at === void 0 ? {} : { updatedAt: value.updated_at }
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const platformAppSchema = z.object({
|
|
28
|
+
...fields,
|
|
29
|
+
app_name: z.string().default(""),
|
|
30
|
+
client_id: z.string().default("")
|
|
31
|
+
}).transform((value) => ({
|
|
32
|
+
...base(value),
|
|
33
|
+
appName: value.app_name,
|
|
34
|
+
clientId: value.client_id
|
|
35
|
+
}));
|
|
36
|
+
const expertBindingSchema = z.object({
|
|
37
|
+
...fields,
|
|
38
|
+
user_id: z.string().default(""),
|
|
39
|
+
platform_app_id: z.string().default(""),
|
|
40
|
+
external_union_id: z.string().default(""),
|
|
41
|
+
external_nickname: z.string().default("")
|
|
42
|
+
}).transform((value) => ({
|
|
43
|
+
...base(value),
|
|
44
|
+
userId: value.user_id,
|
|
45
|
+
platformAppId: value.platform_app_id,
|
|
46
|
+
externalUnionId: value.external_union_id,
|
|
47
|
+
externalNickname: value.external_nickname
|
|
48
|
+
}));
|
|
49
|
+
const groupBindingSchema = z.object({
|
|
50
|
+
...fields,
|
|
51
|
+
platform_app_id: z.string().default(""),
|
|
52
|
+
conversation_id: z.string().default(""),
|
|
53
|
+
conversation_name: z.string().default(""),
|
|
54
|
+
notebook_id: z.string().default(""),
|
|
55
|
+
context_window: z.int32().default(0),
|
|
56
|
+
writer_user_id: z.string().default(""),
|
|
57
|
+
instructions: jsonObject.nullish()
|
|
58
|
+
}).transform((value) => ({
|
|
59
|
+
...base(value),
|
|
60
|
+
platformAppId: value.platform_app_id,
|
|
61
|
+
conversationId: value.conversation_id,
|
|
62
|
+
conversationName: value.conversation_name,
|
|
63
|
+
notebookId: value.notebook_id,
|
|
64
|
+
contextWindow: value.context_window,
|
|
65
|
+
writerUserId: value.writer_user_id,
|
|
66
|
+
...value.instructions == null ? {} : { instructions: value.instructions }
|
|
67
|
+
}));
|
|
68
|
+
const pageInfoSchema = z.object({
|
|
69
|
+
current_page: z.int32().nonnegative().default(0),
|
|
70
|
+
last_page: z.int32().nonnegative().default(0),
|
|
71
|
+
next_page: z.int32().nonnegative().default(0),
|
|
72
|
+
prev_page: z.int32().nonnegative().default(0),
|
|
73
|
+
page_size: z.int32().nonnegative().default(0),
|
|
74
|
+
total_size: z.int32().nonnegative().default(0),
|
|
75
|
+
next_token: z.string().default("")
|
|
76
|
+
}).transform((value) => ({
|
|
77
|
+
currentPage: value.current_page,
|
|
78
|
+
lastPage: value.last_page,
|
|
79
|
+
nextPage: value.next_page,
|
|
80
|
+
previousPage: value.prev_page,
|
|
81
|
+
pageSize: value.page_size,
|
|
82
|
+
totalSize: value.total_size,
|
|
83
|
+
nextToken: value.next_token
|
|
84
|
+
}));
|
|
85
|
+
const platformAppListSchema = z.object({
|
|
86
|
+
apps: z.array(platformAppSchema).nullish(),
|
|
87
|
+
pages: pageInfoSchema.nullish()
|
|
88
|
+
}).transform((value) => ({
|
|
89
|
+
apps: value.apps ?? [],
|
|
90
|
+
...value.pages == null ? {} : { pages: value.pages }
|
|
91
|
+
}));
|
|
92
|
+
const expertBindingListSchema = z.object({
|
|
93
|
+
bindings: z.array(expertBindingSchema).nullish(),
|
|
94
|
+
pages: pageInfoSchema.nullish()
|
|
95
|
+
}).transform((value) => ({
|
|
96
|
+
bindings: value.bindings ?? [],
|
|
97
|
+
...value.pages == null ? {} : { pages: value.pages }
|
|
98
|
+
}));
|
|
99
|
+
const groupBindingListSchema = z.object({
|
|
100
|
+
bindings: z.array(groupBindingSchema).nullish(),
|
|
101
|
+
pages: pageInfoSchema.nullish()
|
|
102
|
+
}).transform((value) => ({
|
|
103
|
+
bindings: value.bindings ?? [],
|
|
104
|
+
...value.pages == null ? {} : { pages: value.pages }
|
|
105
|
+
}));
|
|
106
|
+
const publishDingTalkSchema = z.object({
|
|
107
|
+
binding_code: z.string().min(1),
|
|
108
|
+
bind_command: z.string().min(1),
|
|
109
|
+
group_binding: groupBindingSchema
|
|
110
|
+
}).transform((value) => ({
|
|
111
|
+
bindingCode: value.binding_code,
|
|
112
|
+
bindCommand: value.bind_command,
|
|
113
|
+
groupBinding: value.group_binding
|
|
114
|
+
}));
|
|
115
|
+
const inviteDingTalkSchema = z.object({
|
|
116
|
+
binding_code: z.string().min(1),
|
|
117
|
+
bind_command: z.string().min(1),
|
|
118
|
+
expert_binding: expertBindingSchema
|
|
119
|
+
}).transform((value) => ({
|
|
120
|
+
bindingCode: value.binding_code,
|
|
121
|
+
bindCommand: value.bind_command,
|
|
122
|
+
expertBinding: value.expert_binding
|
|
123
|
+
}));
|
|
124
|
+
const botDeleteSchema = z.object({}).transform(() => void 0);
|
|
125
|
+
function optionalInt32(value, field) {
|
|
126
|
+
if (value === void 0) return void 0;
|
|
127
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < -2147483648 || value > 2147483647) throw invalidArgument(`${field} must be an int32`, field);
|
|
128
|
+
return value;
|
|
129
|
+
}
|
|
130
|
+
function isJson(value, ancestors) {
|
|
131
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return true;
|
|
132
|
+
if (typeof value === "number") return Number.isFinite(value);
|
|
133
|
+
if (typeof value !== "object" || ancestors.has(value)) return false;
|
|
134
|
+
if (!Array.isArray(value) && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) return false;
|
|
135
|
+
if (Object.getOwnPropertySymbols(value).length > 0) return false;
|
|
136
|
+
ancestors.add(value);
|
|
137
|
+
const valid = (Array.isArray(value) ? Array.from(value) : Object.values(value)).every((child) => isJson(child, ancestors));
|
|
138
|
+
ancestors.delete(value);
|
|
139
|
+
return valid;
|
|
140
|
+
}
|
|
141
|
+
function optionalInstructions(value) {
|
|
142
|
+
const object = optionalRecord(value, "instructions");
|
|
143
|
+
if (object === void 0) return void 0;
|
|
144
|
+
try {
|
|
145
|
+
if (isJson(object, /* @__PURE__ */ new Set())) return object;
|
|
146
|
+
} catch {}
|
|
147
|
+
throw invalidArgument("instructions must contain only JSON values", "instructions");
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region ../sdk/src/operations/bot-gateway.ts
|
|
151
|
+
function groupFields(input) {
|
|
152
|
+
return compactUndefined({
|
|
153
|
+
conversation_name: optionalString(input?.conversationName, "conversationName"),
|
|
154
|
+
context_window: optionalInt32(input?.contextWindow, "contextWindow"),
|
|
155
|
+
writer_user_id: optionalString(input?.writerUserId, "writerUserId"),
|
|
156
|
+
is_active: optionalBoolean(input?.isActive, "isActive"),
|
|
157
|
+
instructions: optionalInstructions(input?.instructions)
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
function patch(body) {
|
|
161
|
+
assertNonEmptyPatch(body, "input");
|
|
162
|
+
return body;
|
|
163
|
+
}
|
|
164
|
+
function createBotGatewayOperations(context) {
|
|
165
|
+
const path = (notebookId, ...segments) => context.profile.apiPath("notebooks", requiredString(notebookId, "notebookId"), "botgw", ...segments);
|
|
166
|
+
const listPath = (notebookId, resource, input = {}) => {
|
|
167
|
+
const page = pagination({
|
|
168
|
+
page: input.page ?? 1,
|
|
169
|
+
pageSize: input.pageSize ?? 20
|
|
170
|
+
});
|
|
171
|
+
const onlyActive = optionalBoolean(input.onlyActive, "onlyActive");
|
|
172
|
+
return queryPath(path(notebookId, resource), [
|
|
173
|
+
["page", optionalInt32(page.page, "page")],
|
|
174
|
+
["page_size", optionalInt32(page.pageSize, "pageSize")],
|
|
175
|
+
["platform", optionalTrimmedString(input.platform, "platform")],
|
|
176
|
+
["only_active", onlyActive === void 0 ? void 0 : String(onlyActive)],
|
|
177
|
+
["platform_app_id", resource === "platform-apps" ? void 0 : optionalTrimmedString(input.platformAppId, "platformAppId")],
|
|
178
|
+
["user_id", resource === "expert-bindings" ? optionalTrimmedString(input.userId, "userId") : void 0]
|
|
179
|
+
]);
|
|
180
|
+
};
|
|
181
|
+
return {
|
|
182
|
+
async listPlatformApps(notebookId, input, options) {
|
|
183
|
+
return call(context, {
|
|
184
|
+
callOptions: options,
|
|
185
|
+
capability: "botGateway",
|
|
186
|
+
method: "GET",
|
|
187
|
+
idempotent: true,
|
|
188
|
+
operation: "botGateway.platformApps.list",
|
|
189
|
+
path: listPath(notebookId, "platform-apps", input),
|
|
190
|
+
schema: platformAppListSchema
|
|
191
|
+
});
|
|
192
|
+
},
|
|
193
|
+
async createPlatformApp(notebookId, input, options) {
|
|
194
|
+
const body = compactUndefined({
|
|
195
|
+
platform: requiredString(input?.platform, "platform"),
|
|
196
|
+
app_name: requiredString(input?.appName, "appName"),
|
|
197
|
+
client_id: requiredString(input?.clientId, "clientId"),
|
|
198
|
+
client_secret: requiredText(input?.clientSecret, "clientSecret"),
|
|
199
|
+
is_active: optionalBoolean(input?.isActive, "isActive")
|
|
200
|
+
});
|
|
201
|
+
return call(context, {
|
|
202
|
+
body,
|
|
203
|
+
callOptions: options,
|
|
204
|
+
capability: "botGateway",
|
|
205
|
+
method: "POST",
|
|
206
|
+
idempotent: false,
|
|
207
|
+
operation: "botGateway.platformApps.create",
|
|
208
|
+
path: path(notebookId, "platform-apps"),
|
|
209
|
+
schema: platformAppSchema
|
|
210
|
+
});
|
|
211
|
+
},
|
|
212
|
+
async updatePlatformApp(notebookId, appId, input, options) {
|
|
213
|
+
const body = patch(compactUndefined({
|
|
214
|
+
app_name: optionalString(input?.appName, "appName"),
|
|
215
|
+
client_secret: optionalString(input?.clientSecret, "clientSecret"),
|
|
216
|
+
is_active: optionalBoolean(input?.isActive, "isActive")
|
|
217
|
+
}));
|
|
218
|
+
return call(context, {
|
|
219
|
+
body,
|
|
220
|
+
callOptions: options,
|
|
221
|
+
capability: "botGateway",
|
|
222
|
+
method: "PATCH",
|
|
223
|
+
idempotent: false,
|
|
224
|
+
operation: "botGateway.platformApps.update",
|
|
225
|
+
path: path(notebookId, "platform-apps", requiredString(appId, "appId")),
|
|
226
|
+
schema: platformAppSchema
|
|
227
|
+
});
|
|
228
|
+
},
|
|
229
|
+
async deletePlatformApp(notebookId, appId, options) {
|
|
230
|
+
return call(context, {
|
|
231
|
+
callOptions: options,
|
|
232
|
+
capability: "botGateway",
|
|
233
|
+
method: "DELETE",
|
|
234
|
+
idempotent: false,
|
|
235
|
+
operation: "botGateway.platformApps.delete",
|
|
236
|
+
path: path(notebookId, "platform-apps", requiredString(appId, "appId")),
|
|
237
|
+
schema: botDeleteSchema
|
|
238
|
+
});
|
|
239
|
+
},
|
|
240
|
+
async listExpertBindings(notebookId, input, options) {
|
|
241
|
+
return call(context, {
|
|
242
|
+
callOptions: options,
|
|
243
|
+
capability: "botGateway",
|
|
244
|
+
method: "GET",
|
|
245
|
+
idempotent: true,
|
|
246
|
+
operation: "botGateway.expertBindings.list",
|
|
247
|
+
path: listPath(notebookId, "expert-bindings", input),
|
|
248
|
+
schema: expertBindingListSchema
|
|
249
|
+
});
|
|
250
|
+
},
|
|
251
|
+
async updateExpertBinding(notebookId, bindingId, input, options) {
|
|
252
|
+
const body = patch(compactUndefined({
|
|
253
|
+
external_nickname: optionalString(input?.externalNickname, "externalNickname"),
|
|
254
|
+
is_active: optionalBoolean(input?.isActive, "isActive")
|
|
255
|
+
}));
|
|
256
|
+
return call(context, {
|
|
257
|
+
body,
|
|
258
|
+
callOptions: options,
|
|
259
|
+
capability: "botGateway",
|
|
260
|
+
method: "PATCH",
|
|
261
|
+
idempotent: false,
|
|
262
|
+
operation: "botGateway.expertBindings.update",
|
|
263
|
+
path: path(notebookId, "expert-bindings", requiredString(bindingId, "bindingId")),
|
|
264
|
+
schema: expertBindingSchema
|
|
265
|
+
});
|
|
266
|
+
},
|
|
267
|
+
async deleteExpertBinding(notebookId, bindingId, options) {
|
|
268
|
+
return call(context, {
|
|
269
|
+
callOptions: options,
|
|
270
|
+
capability: "botGateway",
|
|
271
|
+
method: "DELETE",
|
|
272
|
+
idempotent: false,
|
|
273
|
+
operation: "botGateway.expertBindings.delete",
|
|
274
|
+
path: path(notebookId, "expert-bindings", requiredString(bindingId, "bindingId")),
|
|
275
|
+
schema: botDeleteSchema
|
|
276
|
+
});
|
|
277
|
+
},
|
|
278
|
+
async listGroupBindings(notebookId, input, options) {
|
|
279
|
+
return call(context, {
|
|
280
|
+
callOptions: options,
|
|
281
|
+
capability: "botGateway",
|
|
282
|
+
method: "GET",
|
|
283
|
+
idempotent: true,
|
|
284
|
+
operation: "botGateway.groupBindings.list",
|
|
285
|
+
path: listPath(notebookId, "group-bindings", input),
|
|
286
|
+
schema: groupBindingListSchema
|
|
287
|
+
});
|
|
288
|
+
},
|
|
289
|
+
async createGroupBinding(notebookId, input, options) {
|
|
290
|
+
const body = {
|
|
291
|
+
...groupFields(input),
|
|
292
|
+
platform_app_id: requiredString(input?.platformAppId, "platformAppId"),
|
|
293
|
+
conversation_id: requiredString(input?.conversationId, "conversationId")
|
|
294
|
+
};
|
|
295
|
+
return call(context, {
|
|
296
|
+
body,
|
|
297
|
+
callOptions: options,
|
|
298
|
+
capability: "botGateway",
|
|
299
|
+
method: "POST",
|
|
300
|
+
idempotent: false,
|
|
301
|
+
operation: "botGateway.groupBindings.create",
|
|
302
|
+
path: path(notebookId, "group-bindings"),
|
|
303
|
+
schema: groupBindingSchema
|
|
304
|
+
});
|
|
305
|
+
},
|
|
306
|
+
async updateGroupBinding(notebookId, bindingId, input, options) {
|
|
307
|
+
const body = patch(compactUndefined({
|
|
308
|
+
...groupFields(input),
|
|
309
|
+
notebook_id: optionalString(input?.notebookId, "notebookId")
|
|
310
|
+
}));
|
|
311
|
+
return call(context, {
|
|
312
|
+
body,
|
|
313
|
+
callOptions: options,
|
|
314
|
+
capability: "botGateway",
|
|
315
|
+
method: "PATCH",
|
|
316
|
+
idempotent: false,
|
|
317
|
+
operation: "botGateway.groupBindings.update",
|
|
318
|
+
path: path(notebookId, "group-bindings", requiredString(bindingId, "bindingId")),
|
|
319
|
+
schema: groupBindingSchema
|
|
320
|
+
});
|
|
321
|
+
},
|
|
322
|
+
async deleteGroupBinding(notebookId, bindingId, options) {
|
|
323
|
+
return call(context, {
|
|
324
|
+
callOptions: options,
|
|
325
|
+
capability: "botGateway",
|
|
326
|
+
method: "DELETE",
|
|
327
|
+
idempotent: false,
|
|
328
|
+
operation: "botGateway.groupBindings.delete",
|
|
329
|
+
path: path(notebookId, "group-bindings", requiredString(bindingId, "bindingId")),
|
|
330
|
+
schema: botDeleteSchema
|
|
331
|
+
});
|
|
332
|
+
},
|
|
333
|
+
async publishDingTalk(notebookId, input, options) {
|
|
334
|
+
const body = compactUndefined({
|
|
335
|
+
platform_app_id: requiredString(input?.platformAppId, "platformAppId"),
|
|
336
|
+
context_window: optionalInt32(input?.contextWindow, "contextWindow"),
|
|
337
|
+
instructions: optionalInstructions(input?.instructions)
|
|
338
|
+
});
|
|
339
|
+
return call(context, {
|
|
340
|
+
body,
|
|
341
|
+
callOptions: options,
|
|
342
|
+
capability: "botGateway",
|
|
343
|
+
method: "POST",
|
|
344
|
+
idempotent: false,
|
|
345
|
+
operation: "botGateway.dingTalk.publish",
|
|
346
|
+
path: path(notebookId, "dingtalk", "publish"),
|
|
347
|
+
schema: publishDingTalkSchema
|
|
348
|
+
});
|
|
349
|
+
},
|
|
350
|
+
async inviteDingTalkExpert(notebookId, input, options) {
|
|
351
|
+
const userId = optionalTrimmedString(input?.userId, "userId");
|
|
352
|
+
const email = optionalTrimmedString(input?.email, "email");
|
|
353
|
+
if (userId === void 0 && email === void 0) throw invalidArgument("provide userId or email", "input");
|
|
354
|
+
const body = compactUndefined({
|
|
355
|
+
platform_app_id: requiredString(input?.platformAppId, "platformAppId"),
|
|
356
|
+
user_id: userId,
|
|
357
|
+
email
|
|
358
|
+
});
|
|
359
|
+
return call(context, {
|
|
360
|
+
body,
|
|
361
|
+
callOptions: options,
|
|
362
|
+
capability: "botGateway",
|
|
363
|
+
method: "POST",
|
|
364
|
+
idempotent: false,
|
|
365
|
+
operation: "botGateway.dingTalk.inviteExpert",
|
|
366
|
+
path: path(notebookId, "dingtalk", "experts", "invite"),
|
|
367
|
+
schema: inviteDingTalkSchema
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
//#endregion
|
|
373
|
+
export { createBotGatewayOperations };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { S as cardSchema, a as invalidArgument, c as optionalRecord, d as pagination, g as stringList, h as requiredText, l as optionalString, m as requiredString, n as call, p as queryPath, r as compactUndefined, u as optionalTrimmedString, x as cardListSchema, y as batchMutationResultSchema } from "./shared-9iPJsfjP.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region ../sdk/src/operations/compilation-results.ts
|
|
4
|
+
function linksBody(value, field) {
|
|
5
|
+
if (value === void 0) return void 0;
|
|
6
|
+
if (!Array.isArray(value)) throw invalidArgument(`${field} must be an array`, field);
|
|
7
|
+
return value.map((value, index) => {
|
|
8
|
+
const name = `${field}[${index}]`;
|
|
9
|
+
const link = optionalRecord(value, name);
|
|
10
|
+
const targetId = optionalTrimmedString(link?.targetId, `${name}.targetId`);
|
|
11
|
+
const targetRef = optionalTrimmedString(link?.targetRef, `${name}.targetRef`);
|
|
12
|
+
if (targetId === void 0 && targetRef === void 0) throw invalidArgument(`${name} requires targetId or targetRef`, name);
|
|
13
|
+
return compactUndefined({
|
|
14
|
+
description: optionalString(link?.description, `${name}.description`),
|
|
15
|
+
linkType: optionalTrimmedString(link?.linkType, `${name}.linkType`),
|
|
16
|
+
targetId,
|
|
17
|
+
targetRef
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function compilationResultBody(value) {
|
|
22
|
+
if (!Array.isArray(value) || value.length === 0) throw invalidArgument("cards must be a non-empty array", "cards");
|
|
23
|
+
return { cards: value.map((value, index) => {
|
|
24
|
+
const name = `cards[${index}]`;
|
|
25
|
+
const card = optionalRecord(value, name);
|
|
26
|
+
return compactUndefined({
|
|
27
|
+
cardType: optionalTrimmedString(card?.cardType, `${name}.cardType`),
|
|
28
|
+
content: requiredText(card?.content, `${name}.content`),
|
|
29
|
+
id: optionalTrimmedString(card?.id, `${name}.id`),
|
|
30
|
+
keywords: card?.keywords === void 0 ? void 0 : stringList(card.keywords, `${name}.keywords`),
|
|
31
|
+
links: linksBody(card?.links, `${name}.links`),
|
|
32
|
+
refId: optionalTrimmedString(card?.refId, `${name}.refId`),
|
|
33
|
+
title: requiredString(card?.title, `${name}.title`)
|
|
34
|
+
});
|
|
35
|
+
}) };
|
|
36
|
+
}
|
|
37
|
+
const saveCompilationResultSchema = z.object({
|
|
38
|
+
cards: z.array(z.object({
|
|
39
|
+
id: z.string().min(1),
|
|
40
|
+
refId: z.string().optional()
|
|
41
|
+
})).nullish().transform((cards) => cards ?? []),
|
|
42
|
+
failureCount: z.number().int().nonnegative(),
|
|
43
|
+
successCount: z.number().int().nonnegative()
|
|
44
|
+
});
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region ../sdk/src/operations/cards.ts
|
|
47
|
+
function createCardOperations(context) {
|
|
48
|
+
const listCards = async (notebookId, input = {}, options, featured = false) => {
|
|
49
|
+
const notebook = requiredString(notebookId, "notebookId");
|
|
50
|
+
const normalizedPage = pagination({
|
|
51
|
+
page: input.page ?? 1,
|
|
52
|
+
pageSize: input.pageSize ?? 20
|
|
53
|
+
});
|
|
54
|
+
const category = optionalTrimmedString(input.category, "category");
|
|
55
|
+
const query = optionalTrimmedString(input.query, "query");
|
|
56
|
+
const root = context.profile.apiPath(featured ? "featured-notebooks" : "notebooks", notebook, "cards");
|
|
57
|
+
const path = queryPath(root, [
|
|
58
|
+
["category", category],
|
|
59
|
+
["query", query],
|
|
60
|
+
["page", normalizedPage.page],
|
|
61
|
+
["page_size", normalizedPage.pageSize]
|
|
62
|
+
]);
|
|
63
|
+
return call(context, {
|
|
64
|
+
callOptions: options,
|
|
65
|
+
capability: featured ? "featuredNotebooks.read" : "cards.read",
|
|
66
|
+
idempotent: true,
|
|
67
|
+
method: "GET",
|
|
68
|
+
operation: featured ? "featuredCards.list" : "cards.list",
|
|
69
|
+
path,
|
|
70
|
+
schema: cardListSchema
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
return {
|
|
74
|
+
async saveCompilationResult(notebookId, input, options) {
|
|
75
|
+
const notebook = requiredString(notebookId, "notebookId");
|
|
76
|
+
return call(context, {
|
|
77
|
+
body: compilationResultBody(input?.cards),
|
|
78
|
+
callOptions: options,
|
|
79
|
+
capability: "cards.saveResults",
|
|
80
|
+
idempotent: false,
|
|
81
|
+
method: "POST",
|
|
82
|
+
operation: "cards.saveCompilationResult",
|
|
83
|
+
path: context.profile.apiPath("notebooks", notebook, "cards", "save-compilation-result"),
|
|
84
|
+
schema: saveCompilationResultSchema
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
async batchDeleteCards(notebookId, cardIds, options) {
|
|
88
|
+
const notebook = requiredString(notebookId, "notebookId");
|
|
89
|
+
const ids = stringList(cardIds, "cardIds", { min: 1 });
|
|
90
|
+
return call(context, {
|
|
91
|
+
body: { cardIds: ids },
|
|
92
|
+
callOptions: options,
|
|
93
|
+
capability: "cards.write",
|
|
94
|
+
idempotent: false,
|
|
95
|
+
method: "POST",
|
|
96
|
+
operation: "cards.batchDelete",
|
|
97
|
+
path: context.profile.apiPath("notebooks", notebook, "cards", "batch-delete"),
|
|
98
|
+
schema: batchMutationResultSchema
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
async deleteCard(notebookId, cardId, options) {
|
|
102
|
+
const notebook = requiredString(notebookId, "notebookId");
|
|
103
|
+
const card = requiredString(cardId, "cardId");
|
|
104
|
+
return call(context, {
|
|
105
|
+
callOptions: options,
|
|
106
|
+
capability: "cards.write",
|
|
107
|
+
idempotent: false,
|
|
108
|
+
method: "DELETE",
|
|
109
|
+
operation: "cards.delete",
|
|
110
|
+
path: context.profile.apiPath("notebooks", notebook, "cards", card),
|
|
111
|
+
schema: batchMutationResultSchema
|
|
112
|
+
});
|
|
113
|
+
},
|
|
114
|
+
async getCard(notebookId, cardId, options) {
|
|
115
|
+
const notebook = requiredString(notebookId, "notebookId");
|
|
116
|
+
const card = requiredString(cardId, "cardId");
|
|
117
|
+
return call(context, {
|
|
118
|
+
callOptions: options,
|
|
119
|
+
capability: "cards.read",
|
|
120
|
+
idempotent: true,
|
|
121
|
+
method: "GET",
|
|
122
|
+
operation: "cards.get",
|
|
123
|
+
path: context.profile.apiPath("notebooks", notebook, "cards", card),
|
|
124
|
+
schema: cardSchema
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
listCards: (notebookId, input, options) => listCards(notebookId, input, options),
|
|
128
|
+
listFeaturedCards: (notebookId, input, options) => listCards(notebookId, input, options, true)
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
export { createCardOperations };
|