@qoder-ai/qmind-cli 4.3.0 → 5.0.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/CHANGELOG.md CHANGED
@@ -4,6 +4,16 @@ 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
+ ## 5.0.0
8
+
9
+ ### Major Changes
10
+
11
+ - 297c6cb: Use QMind's public HTTP routes for notebook and source operations in the Global and CN CLI. Before upgrading the CLI on a custom gateway, route the Sash origin’s `/qmind/api/v1/` prefix to QMind with Bearer authentication. Keep the installed 4.x CLI pinned until that route is ready. Create schedules for condensation, source refresh or source binding sync. Historical compilation and lint schedules can be listed, paused or deleted.
12
+
13
+ Remove `--org` from scripts. For `source import-site`, remove `--parent` and `--path-prefix` because imports now start at the notebook root. For `task create`, remove `--trigger` and `--sources`. Runs are manual and source refresh covers the whole notebook. Use `scheduled-task create --scene source_binding_sync` for binding sync. Installer-managed updates use the fixed stable channel. Remove `--url`, `--channel`, `--public-key`, `--force`, and `--allow-downgrade` from updater calls. Use `update --check` to check without installing.
14
+
15
+ Use a supported `--format` and keep mode-specific flags together. `source list --all` starts at page 1 and accepts `--max-pages`. Specify `--page` for a single page. On `source content`, use `--no-overwrite` with `--download`. On `image presign-upload`, omit `--size` when passing a local `--file`.
16
+
7
17
  ## 4.3.0
8
18
 
9
19
  ### Minor Changes
@@ -4,6 +4,16 @@
4
4
 
5
5
  以下已发布版本属于 Global CLI / 共享实现,不代表 CN 曾发布过这些版本。CN 将在后续共同发行版加入同一历史。
6
6
 
7
+ ## 5.0.0
8
+
9
+ ### Major Changes
10
+
11
+ - 297c6cb: Global 和 CN CLI 的知识库和资料操作改用 QMind 公开 HTTP 路由。使用自定义网关时,升级前需在 Sash 地址将 `/qmind/api/v1/` 转发到 QMind 并启用 Bearer 鉴权。路由就绪前请锁定当前使用的 4.x CLI 版本。新建定时任务支持凝练、资料刷新和绑定同步,历史编译与 lint 任务可查询、暂停和删除。
12
+
13
+ 从脚本移除 `--org`。整站导入统一从知识库根目录开始,请从 `source import-site` 移除 `--parent` 和 `--path-prefix`。请从 `task create` 移除 `--trigger` 和 `--sources`,创建的运行均为手工触发,资料刷新覆盖整库。用 `scheduled-task create --scene source_binding_sync` 配置绑定同步。安装器管理的 CLI 固定从稳定渠道更新,请从更新命令移除 `--url`、`--channel`、`--public-key`、`--force` 和 `--allow-downgrade`。用 `update --check` 只检查更新。
14
+
15
+ 传入受支持的 `--format`,并按使用模式搭配选项。`source list --all` 从第 1 页开始,可使用 `--max-pages`,查询单页则使用 `--page`。`source content` 的 `--no-overwrite` 必须与 `--download` 一起使用。`image presign-upload` 传入本地 `--file` 时请省略 `--size`。
16
+
7
17
  ## 4.3.0
8
18
 
9
19
  ### Minor Changes
package/README.md CHANGED
@@ -85,9 +85,11 @@ For browser login, `qmind login --no-browser` prints the authorization URL to op
85
85
  | `version` | Print version and build information |
86
86
  | `update` / `self-update` | Update an installer-managed Native CLI |
87
87
 
88
- `task create` does not start `compilation` or `lint` runs; `task list` and `task get` can still inspect historical runs for those scenes. `source import-site` does not provide an automatic compilation option.
88
+ `task create` starts manual `condensation` or `source_refresh` runs. Manual refresh covers the entire notebook. Use `scheduled-task create --scene source_binding_sync` to schedule binding sync. Use `task list` and `task get` to inspect historical compilation and lint runs.
89
89
 
90
- 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.
90
+ `source import-site` imports at the notebook root and supports a sitemap, path filters, and a page limit.
91
+
92
+ Run `qmind <command> --help` for complete options. Notebook commands with `--format` support `table`, `json`, `agent`, and `ndjson`. Folder sync supports `json` and `text`. 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.
91
93
 
92
94
  ## Multi-notebook retrieval
93
95
 
@@ -119,6 +121,8 @@ Removing `--dry-run` enables writes. `--delete` treats the remote source root as
119
121
 
120
122
  This package has a fixed Qoder Global identity. Renaming the executable, changing its install path, or setting product-selection environment variables cannot switch products. Production is the default; `--env test` and `--env daily` select supported debug presets. A custom target requires both `--sash` and `--dashboard` and cannot be combined with an explicit `--env`.
121
123
 
124
+ **Using CLI 5.x with a custom gateway** On the origin supplied with `--sash`, route `/qmind/api/v1/` to QMind and enable Bearer authentication for CLI requests. Keep both origin arguments and the existing sign-in and token exchange routes. Verify notebook list and create with the same pair of origins. Pin your installed 4.x CLI version while the gateway serves notebooks only under `/sash/api/v1/notebooks`.
125
+
122
126
  ```sh
123
127
  qmind login --env test
124
128
  QMIND_DEBUG_TOKEN='<debug-token>' qmind notebook list --env test --non-interactive --format json
@@ -198,7 +202,7 @@ qmind scheduled-task resume <task-id> --nb <notebook-id>
198
202
  qmind scheduled-task delete <task-id> --nb <notebook-id>
199
203
  ```
200
204
 
201
- `update --enabled false/true` also pauses/resumes. Creation defaults to enabled with empty config; arbitrary prompt/config inputs are not accepted. Updates only change schedule or enabled. Scenes are compilation, condensation, lint, source_refresh and source_binding_sync; the server decides actual availability and full Cron validity. An explicit IANA timezone is required. Compilation may be retired; source_binding_sync is currently a per-notebook singleton with a minimum five-minute interval. `list` supports `--task/--scene/--enabled`, with pageSize at most 20; the backend still reads all configurations for the notebook. Oversized config is marked `configTruncated:true`.
205
+ `update --enabled false/true` also pauses/resumes. Creation defaults to enabled with empty config; arbitrary prompt/config inputs are not accepted. Updates only change schedule or enabled. New schedules support condensation, source_refresh and source_binding_sync. Existing compilation and lint schedules can be inspected, paused and deleted. An explicit IANA timezone is required. source_binding_sync is currently a per-notebook singleton with a minimum five-minute interval. `list` supports `--task/--scene/--enabled`, with pageSize at most 20; the backend still reads all configurations for the notebook. Oversized config is marked `configTruncated:true`.
202
206
 
203
207
  Configuration is separate from execution: use `task list --scheduled-task <task-id>` for run history. Pausing/deleting does not cancel dispatched runs; resuming an overdue schedule may trigger a run immediately. Execution retains the original creator identity; revoking membership does not guarantee schedules stop automatically.
204
208
 
package/README.zh-CN.md CHANGED
@@ -85,13 +85,15 @@ CI 也可以只注入 PAT 并直接运行命令,此时不写入 vault。当前
85
85
  | `version` | 查看版本和构建信息 |
86
86
  | `update` / `self-update` | 更新 installer 管理的 Native CLI |
87
87
 
88
- `task create` 不会启动 `compilation` 或 `lint` 运行;仍可通过 `task list` 和 `task get` 查询这些场景的历史运行。`source import-site` 不提供自动编译选项。
88
+ `task create` 创建手工运行,支持 `condensation` 和 `source_refresh`。手工刷新面向整库。资料绑定同步通过 `scheduled-task create --scene source_binding_sync` 配置。通过 `task list` 和 `task get` 查询历史编译和 lint 运行。
89
89
 
90
- 使用 `qmind <command> --help` 查看完整参数。领域命令支持 `table`、`json`、`agent`、`ndjson` 等输出格式。stdout 只输出结果,进度与诊断信息输出到 stderr。退出码 `0` 表示成功,`1` 表示运行失败、部分成功或取消,`2` 表示参数错误。
90
+ `source import-site` 将站点导入到知识库根目录,支持 sitemap、路径匹配和页数限制。
91
+
92
+ 使用 `qmind <command> --help` 查看完整参数。提供 `--format` 的知识库命令支持 `table`、`json`、`agent` 和 `ndjson`。目录同步支持 `json` 和 `text`。stdout 只输出结果,进度与诊断信息输出到 stderr。退出码 `0` 表示成功,`1` 表示运行失败、部分成功或取消,`2` 表示参数错误。
91
93
 
92
94
  ## 多库检索
93
95
 
94
- `retrieve --nb` 支持逗号分隔或重复传入 Notebook ID,去重后最多选择 5 个知识库:
96
+ `retrieve --nb` 支持逗号分隔或重复传入 Notebook ID,去重后最多选择 32 个知识库:
95
97
 
96
98
  ```sh
97
99
  qmind retrieve --nb nb-1,nb-2 "部署流程是什么?" --format json
@@ -101,9 +103,9 @@ qmind retrieve --nb nb-1 --nb nb-2 "部署流程是什么?" --format agent
101
103
  - 必须显式选择知识库,不会默认枚举所有可访问库。
102
104
  - 多库检索只发送一次统一请求,由服务端联合召回并重排 Source chunks;输出保留服务端排序,以及每条 chunk/citation 的 `notebookId` 和 `notebookTitle`。
103
105
  - `--top-k` 控制每路、每个查询变体、每种召回通道的联合候选预算,不按知识库数量相乘;`--max-results` 限制全部选中库的最终结果总数。零值使用服务端默认配置。
104
- - `--sources` 仅支持单库。去重后只有一个库时,保留原单库检索接口和输出,包括知识卡片及原有兜底行为。
106
+ - `--sources` 仅支持单库。去重后只有一个库时,继续使用单库接口,结果包含 chunks 和 citations。
105
107
  - 多库 JSON 返回 `{ chunks, citations, promptContext, total, reranked }`;NDJSON 按服务端顺序逐条输出 `kind: "chunk"` 记录,零命中时不输出记录。table 和 agent 格式也会标明证据所属知识库。
106
- - 目标无效或无权限时,统一请求整体失败。CLI 输出错误,不逐库重试或构造部分成功结果。多库检索不返回知识卡片。
108
+ - 目标无效或无权限时,统一请求整体失败。CLI 输出错误,不逐库重试或构造部分成功结果。检索结果已移除 `cards` 字段。
107
109
 
108
110
  ## 同步目录
109
111
 
@@ -119,6 +121,8 @@ qmind upload-folder --nb <notebook-id> --dir ./docs --mode if-changed --dry-run
119
121
 
120
122
  本包固定为 Qoder Global 产品身份。不能通过改名、安装路径或产品选择环境变量切换产品。默认使用正式环境;`--env test` 和 `--env daily` 选择受支持的调试环境。自定义目标必须同时提供 `--sash` 与 `--dashboard`,且不能与显式 `--env` 组合。
121
123
 
124
+ **自定义网关用户升级 CLI 到 5.x** 先在 `--sash` 指定的地址将 `/qmind/api/v1/` 转发到 QMind,并为该路由配置 CLI 使用的 Bearer 鉴权。两个参数仍然填写原有的服务地址,保留现有登录和令牌交换路由。使用同一组参数验证一次 Notebook 列表和创建操作。如果网关只提供旧路径 `/sash/api/v1/notebooks`,请先锁定当前使用的 4.x CLI 版本。
125
+
122
126
  ```sh
123
127
  qmind login --env test
124
128
  QMIND_DEBUG_TOKEN='<debug-token>' qmind notebook list --env test --non-interactive --format json
@@ -185,7 +189,7 @@ qmind retrieve --nb <notebook-id> --unified --score-threshold 0.6 '部署流程'
185
189
  qmind retrieve --targets '[{"notebookId":"nb-1","sourceIds":["source-1"]},{"notebookId":"nb-2","sourceIds":["source-2"]}]' --max-results 8 '部署流程'
186
190
  ```
187
191
 
188
- `--targets` 不能与 `--nb` 或 `--sources` 组合,每库可独立过滤 Source。统一检索默认 maxResults=8(1..50),topK 可选(1..100),0 表示使用该 workflow 的默认值;最多五个唯一目标。结果采用上述结构化 envelope,读取 `data.chunks/data.promptContext`;`--score-threshold` 范围为 0..1,旧检索入口也支持。旧路径的零预算继续使用服务端默认值,不隐式切换旧脚本。
192
+ `--targets` 不能与 `--nb` 或 `--sources` 组合,每库可独立过滤 Source。统一检索默认 maxResults=8(1..50),topK 可选(1..100),0 表示使用该 workflow 的默认值;最多 32 个唯一目标。结果采用上述结构化 envelope,读取 `data.chunks/data.promptContext`;`--score-threshold` 范围为 0..1,旧检索入口也支持。旧路径的零预算继续使用服务端默认值,不隐式切换旧脚本。
189
193
 
190
194
  ## 定时任务配置
191
195
 
@@ -198,7 +202,7 @@ qmind scheduled-task resume <task-id> --nb <notebook-id>
198
202
  qmind scheduled-task delete <task-id> --nb <notebook-id>
199
203
  ```
200
204
 
201
- `update --enabled false/true` 等价于暂停/恢复。创建默认启用、config 固定为空,不能提交任意 prompt/config;更新仅支持时间或 enabled。scene 为 compilation、condensation、lint、source_refresh、source_binding_sync,实际可用性和完整 Cron 语法由服务端裁决。必须显式提供 IANA 时区,不能依赖本机时区。compilation 可能已退役;source_binding_sync 当前是单库单例且间隔至少五分钟。`list` 可用 `--task/--scene/--enabled` 过滤,pageSize 最大 20;底层仍读取本库全量配置。过大的 config 会显示 `configTruncated:true`。
205
+ `update --enabled false/true` 等价于暂停/恢复。创建默认启用、config 固定为空,不能提交任意 prompt/config;更新仅支持时间或 enabled。新建任务支持 condensation、source_refresh 和 source_binding_sync。历史 compilation 和 lint 任务可查看、暂停和删除。必须显式提供 IANA 时区,不能依赖本机时区。source_binding_sync 当前是单库单例且间隔至少五分钟。`list` 可用 `--task/--scene/--enabled` 过滤,pageSize 最大 20;底层仍读取本库全量配置。过大的 config 会显示 `configTruncated:true`。
202
206
 
203
207
  定时配置与执行记录分开:`task list --scheduled-task <task-id>` 查看执行记录。暂停/删除不取消已派发任务;恢复过期任务可能立即触发一次。调度沿用最初创建者身份,成员撤权不保证自动停任务。
204
208
 
@@ -0,0 +1,129 @@
1
+ import { C as dataSourceResourceSchema, D as qmindPath, S as dataSourcePreviewSchema, T as dataSourceSchema, b as dataSourceConfigurationSchema, m as requiredString, n as call, p as queryPath, w as dataSourceRunsSchema, x as dataSourceListSchema } from "./shared-evTnu_EB.js";
2
+ import { z } from "zod";
3
+ //#region ../sdk/src/operations/data-sources.ts
4
+ function createDataSourceOperations(context) {
5
+ const path = (notebook, ...parts) => qmindPath("notebooks", requiredString(notebook, "notebookId"), "data-sources", ...parts);
6
+ const id = (value) => requiredString(value, "dataSourceId");
7
+ const credentials = (value) => z.record(z.string(), z.string()).parse(value);
8
+ const base = { capability: "dataSources" };
9
+ const empty = z.object({}).strict().transform(() => void 0);
10
+ return {
11
+ previewDataSource: async (notebook, configuration, secret, parentId, options) => {
12
+ return call(context, {
13
+ ...base,
14
+ operation: "dataSources.preview",
15
+ method: "POST",
16
+ idempotent: true,
17
+ path: path(notebook, "preview"),
18
+ body: {
19
+ configuration: dataSourceConfigurationSchema.parse(configuration),
20
+ credentials: credentials(secret),
21
+ ...parentId ? { parentId } : {}
22
+ },
23
+ schema: dataSourcePreviewSchema,
24
+ callOptions: options
25
+ });
26
+ },
27
+ listDataSources: (notebook, afterId, options) => call(context, {
28
+ ...base,
29
+ operation: "dataSources.list",
30
+ method: "GET",
31
+ idempotent: true,
32
+ path: queryPath(path(notebook), [["afterId", afterId]]),
33
+ schema: dataSourceListSchema,
34
+ callOptions: options
35
+ }),
36
+ getDataSource: (notebook, value, options) => call(context, {
37
+ ...base,
38
+ operation: "dataSources.get",
39
+ method: "GET",
40
+ idempotent: true,
41
+ path: path(notebook, id(value)),
42
+ schema: dataSourceSchema,
43
+ callOptions: options
44
+ }),
45
+ createDataSource: (notebook, configuration, secret, options) => call(context, {
46
+ ...base,
47
+ operation: "dataSources.create",
48
+ method: "POST",
49
+ idempotent: false,
50
+ path: path(notebook),
51
+ headers: options?.importId ? { "idempotency-key": options.importId } : void 0,
52
+ body: {
53
+ configuration: dataSourceConfigurationSchema.parse(configuration),
54
+ credentials: credentials(secret)
55
+ },
56
+ schema: dataSourceSchema,
57
+ callOptions: options
58
+ }),
59
+ updateDataSource: (notebook, value, configuration, options) => call(context, {
60
+ ...base,
61
+ operation: "dataSources.update",
62
+ method: "PUT",
63
+ idempotent: false,
64
+ path: path(notebook, id(value)),
65
+ body: { configuration: dataSourceConfigurationSchema.parse(configuration) },
66
+ schema: dataSourceSchema,
67
+ callOptions: options
68
+ }),
69
+ setDataSourceCredentials: (notebook, value, secret, options) => call(context, {
70
+ ...base,
71
+ operation: "dataSources.credentials",
72
+ method: "PUT",
73
+ idempotent: false,
74
+ path: path(notebook, id(value), "credentials"),
75
+ body: { credentials: credentials(secret) },
76
+ schema: empty,
77
+ callOptions: options
78
+ }),
79
+ deleteDataSource: (notebook, value, options) => call(context, {
80
+ ...base,
81
+ operation: "dataSources.delete",
82
+ method: "DELETE",
83
+ idempotent: false,
84
+ path: path(notebook, id(value)),
85
+ schema: empty,
86
+ callOptions: options
87
+ }),
88
+ validateDataSource: (notebook, value, options) => call(context, {
89
+ ...base,
90
+ operation: "dataSources.validate",
91
+ method: "POST",
92
+ idempotent: true,
93
+ path: path(notebook, id(value), "validate"),
94
+ body: {},
95
+ schema: empty,
96
+ callOptions: options
97
+ }),
98
+ listDataSourceResources: (notebook, value, parentId, options) => call(context, {
99
+ ...base,
100
+ operation: "dataSources.resources",
101
+ method: "GET",
102
+ idempotent: true,
103
+ path: queryPath(path(notebook, id(value), "resources"), [["parentId", parentId]]),
104
+ schema: z.object({ resources: z.array(dataSourceResourceSchema).default([]) }),
105
+ callOptions: options
106
+ }),
107
+ requestDataSourceSync: (notebook, value, options) => call(context, {
108
+ ...base,
109
+ operation: "dataSources.sync",
110
+ method: "POST",
111
+ idempotent: false,
112
+ path: path(notebook, id(value), "sync"),
113
+ body: {},
114
+ schema: z.object({ runId: z.string().min(1) }),
115
+ callOptions: options
116
+ }),
117
+ listDataSourceRuns: (notebook, value, cursor, options) => call(context, {
118
+ ...base,
119
+ operation: "dataSources.runs",
120
+ method: "GET",
121
+ idempotent: true,
122
+ path: queryPath(path(notebook, id(value), "runs"), [["beforeStartedAt", cursor?.beforeStartedAt], ["beforeId", cursor?.beforeId]]),
123
+ schema: dataSourceRunsSchema,
124
+ callOptions: options
125
+ })
126
+ };
127
+ }
128
+ //#endregion
129
+ export { createDataSourceOperations };
@@ -1,5 +1,4 @@
1
- import { L as qmindFullSiteURLImportPageLimit, c as fullSiteURLImportConfirmationSchema, f as importProvidersSchema, l as fullSiteURLImportDiscoverySchema, n as aliDingImportRunSchema, t as aliDingImportRunItemListSchema } from "./schemas-DG7vaJMR.js";
2
- import { _ as assertCapability, a as invalidArgument, d as pagination, m as requiredString, n as call, p as queryPath } from "./shared-CbvrtGyv.js";
1
+ import { A as aliDingImportRunSchema, B as importProvidersSchema, D as qmindPath, I as fullSiteURLImportConfirmationSchema, L as fullSiteURLImportDiscoverySchema, _ as assertCapability, a as invalidArgument, d as pagination, k as aliDingImportRunItemListSchema, lt as qmindFullSiteURLImportPageLimit, m as requiredString, n as call, p as queryPath } from "./shared-evTnu_EB.js";
3
2
  //#region ../sdk/src/operations/imports.ts
4
3
  const aliDingHost = "alidocs.dingtalk.com";
5
4
  const requestIdPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u;
@@ -61,7 +60,7 @@ function createImportOperations(context) {
61
60
  async confirmFullSiteURLImport(notebookId, input, options) {
62
61
  const notebook = requiredString(notebookId, "notebookId");
63
62
  const discovery = requiredString(input?.discoveryId, "discoveryId");
64
- assertCapability(context.profile, "imports.fullSiteURL", "imports.fullSiteURL.confirm");
63
+ assertCapability(context.capabilities, "imports.fullSiteURL", "imports.fullSiteURL.confirm");
65
64
  return call(context, {
66
65
  body: fullSiteConfirmationBody(input),
67
66
  callOptions: options,
@@ -69,14 +68,14 @@ function createImportOperations(context) {
69
68
  idempotent: false,
70
69
  method: "POST",
71
70
  operation: "imports.fullSiteURL.confirm",
72
- path: context.profile.apiPath("mind", "notebooks", notebook, "full-site-url-import", "discoveries", discovery, "confirm"),
71
+ path: qmindPath("notebooks", notebook, "full-site-url-import", "discoveries", discovery, "confirm"),
73
72
  schema: fullSiteURLImportConfirmationSchema
74
73
  });
75
74
  },
76
75
  async discoverFullSiteURLImport(notebookId, input, options) {
77
76
  const notebook = requiredString(notebookId, "notebookId");
78
77
  const url = publicHTTPURL(input?.url, "url");
79
- assertCapability(context.profile, "imports.fullSiteURL", "imports.fullSiteURL.discover");
78
+ assertCapability(context.capabilities, "imports.fullSiteURL", "imports.fullSiteURL.discover");
80
79
  return call(context, {
81
80
  body: { url },
82
81
  callOptions: options,
@@ -84,21 +83,21 @@ function createImportOperations(context) {
84
83
  idempotent: true,
85
84
  method: "POST",
86
85
  operation: "imports.fullSiteURL.discover",
87
- path: context.profile.apiPath("mind", "notebooks", notebook, "full-site-url-import", "discoveries"),
86
+ path: qmindPath("notebooks", notebook, "full-site-url-import", "discoveries"),
88
87
  schema: fullSiteURLImportDiscoverySchema
89
88
  });
90
89
  },
91
90
  async getAliDingImportRun(notebookId, runId, options) {
92
91
  const notebook = requiredString(notebookId, "notebookId");
93
92
  const run = requiredString(runId, "runId");
94
- assertCapability(context.profile, "imports.aliDing", "imports.aliDing.getRun");
93
+ assertCapability(context.capabilities, "imports.aliDing", "imports.aliDing.getRun");
95
94
  return call(context, {
96
95
  callOptions: options,
97
96
  capability: "imports.aliDing",
98
97
  idempotent: true,
99
98
  method: "GET",
100
99
  operation: "imports.aliDing.getRun",
101
- path: context.profile.apiPath("mind", "notebooks", notebook, "aliding", "import-runs", run),
100
+ path: qmindPath("notebooks", notebook, "aliding", "import-runs", run),
102
101
  schema: aliDingImportRunSchema
103
102
  });
104
103
  },
@@ -106,8 +105,8 @@ function createImportOperations(context) {
106
105
  const notebook = requiredString(notebookId, "notebookId");
107
106
  const run = requiredString(runId, "runId");
108
107
  const normalizedPage = pagination(input);
109
- assertCapability(context.profile, "imports.aliDing", "imports.aliDing.listRunItems");
110
- const base = context.profile.apiPath("mind", "notebooks", notebook, "aliding", "import-runs", run, "items");
108
+ assertCapability(context.capabilities, "imports.aliDing", "imports.aliDing.listRunItems");
109
+ const base = qmindPath("notebooks", notebook, "aliding", "import-runs", run, "items");
111
110
  return call(context, {
112
111
  callOptions: options,
113
112
  capability: "imports.aliDing",
@@ -125,21 +124,21 @@ function createImportOperations(context) {
125
124
  });
126
125
  },
127
126
  async listImportProviders(options) {
128
- assertCapability(context.profile, "imports.discover", "imports.discover");
127
+ assertCapability(context.capabilities, "imports.discover", "imports.discover");
129
128
  return call(context, {
130
129
  callOptions: options,
131
130
  capability: "imports.discover",
132
131
  idempotent: true,
133
132
  method: "GET",
134
133
  operation: "imports.discover",
135
- path: context.profile.apiPath("mind", "import-sources"),
134
+ path: qmindPath("import-sources"),
136
135
  schema: importProvidersSchema
137
136
  });
138
137
  },
139
138
  async startAliDingKnowledgeBaseImport(notebookId, input, options) {
140
139
  const notebook = requiredString(notebookId, "notebookId");
141
140
  const body = importRunBody(input, "knowledgeBase");
142
- assertCapability(context.profile, "imports.aliDing", "imports.aliDing.createKnowledgeBaseRun");
141
+ assertCapability(context.capabilities, "imports.aliDing", "imports.aliDing.createKnowledgeBaseRun");
143
142
  return call(context, {
144
143
  body,
145
144
  callOptions: options,
@@ -147,14 +146,14 @@ function createImportOperations(context) {
147
146
  idempotent: false,
148
147
  method: "POST",
149
148
  operation: "imports.aliDing.createKnowledgeBaseRun",
150
- path: context.profile.apiPath("mind", "notebooks", notebook, "aliding", "knowledge-base-import-runs"),
149
+ path: qmindPath("notebooks", notebook, "aliding", "knowledge-base-import-runs"),
151
150
  schema: aliDingImportRunSchema
152
151
  });
153
152
  },
154
153
  async startAliDingNodeSubtreeImport(notebookId, input, options) {
155
154
  const notebook = requiredString(notebookId, "notebookId");
156
155
  const body = importRunBody(input, "nodeSubtree");
157
- assertCapability(context.profile, "imports.aliDing", "imports.aliDing.createNodeSubtreeRun");
156
+ assertCapability(context.capabilities, "imports.aliDing", "imports.aliDing.createNodeSubtreeRun");
158
157
  return call(context, {
159
158
  body,
160
159
  callOptions: options,
@@ -162,7 +161,7 @@ function createImportOperations(context) {
162
161
  idempotent: false,
163
162
  method: "POST",
164
163
  operation: "imports.aliDing.createNodeSubtreeRun",
165
- path: context.profile.apiPath("mind", "notebooks", notebook, "aliding", "node-subtree-import-runs"),
164
+ path: qmindPath("notebooks", notebook, "aliding", "node-subtree-import-runs"),
166
165
  schema: aliDingImportRunSchema
167
166
  });
168
167
  }
@@ -0,0 +1,206 @@
1
+ import { D as qmindPath, a as invalidArgument, c as optionalRecord, ct as voidResponseSchema, l as optionalString, m as requiredString, n as call, r as compactUndefined, s as optionalBoolean, t as assertNonEmptyPatch, ut as QMindError } from "./shared-evTnu_EB.js";
2
+ import { z } from "zod";
3
+ //#region ../sdk/src/operations/management-schemas.ts
4
+ const memberPermissionSchema = z.enum([
5
+ "owner",
6
+ "manage",
7
+ "edit",
8
+ "view"
9
+ ]);
10
+ const resolvedMemberCandidateSchema = z.object({ candidate: z.object({
11
+ userId: z.string().min(1),
12
+ name: z.string(),
13
+ email: z.string(),
14
+ avatar: z.string().optional(),
15
+ alreadyMember: z.boolean(),
16
+ matchedBy: z.enum(["email", "userId"])
17
+ }).nullable() });
18
+ const notebookMemberSchema = z.object({
19
+ addedBy: z.string().default(""),
20
+ createdAt: z.string().default(""),
21
+ email: z.string().optional(),
22
+ id: z.string().min(1),
23
+ notebookId: z.string().default(""),
24
+ permission: memberPermissionSchema,
25
+ updatedAt: z.string().default(""),
26
+ userId: z.string().default("")
27
+ });
28
+ const notebookMemberListSchema = z.object({ members: z.array(notebookMemberSchema).nullish().transform((members) => members ?? []) });
29
+ const scheduledTaskSceneSchema = z.enum([
30
+ "compilation",
31
+ "condensation",
32
+ "lint",
33
+ "source_refresh",
34
+ "source_binding_sync"
35
+ ]);
36
+ const scheduledTaskSchema = z.object({
37
+ config: z.record(z.string(), z.unknown()).nullish().transform((value) => value ?? {}),
38
+ createdAt: z.string().default(""),
39
+ enabled: z.boolean(),
40
+ id: z.string().min(1),
41
+ lastRunAt: z.string().default(""),
42
+ nextRunAt: z.string().default(""),
43
+ notebookId: z.string().min(1),
44
+ sceneType: scheduledTaskSceneSchema,
45
+ schedule: z.string().min(1),
46
+ updatedAt: z.string().default(""),
47
+ userId: z.string().default("")
48
+ });
49
+ const scheduledTaskListSchema = z.object({ tasks: z.array(scheduledTaskSchema).nullable().transform((tasks) => tasks ?? []) });
50
+ const scheduledTaskDeletionSchema = z.union([z.object({}).strict(), z.undefined()]).transform(() => void 0);
51
+ //#endregion
52
+ //#region ../sdk/src/operations/management.ts
53
+ function memberPermission(value, field) {
54
+ if (value === "manage" || value === "edit" || value === "view") return value;
55
+ throw invalidArgument(`${field} must be manage, edit, or view`, field);
56
+ }
57
+ function scheduledTaskScene(value, field) {
58
+ if (value === "condensation" || value === "source_refresh" || value === "source_binding_sync") return value;
59
+ throw invalidArgument(`${field} must be condensation, source_refresh, or source_binding_sync`, field);
60
+ }
61
+ function createManagementOperations(context) {
62
+ return {
63
+ async resolveMemberCandidate(notebookId, input, options) {
64
+ const notebook = requiredString(notebookId, "notebookId");
65
+ const hasUserId = input?.userId !== void 0;
66
+ if (hasUserId === (input?.email !== void 0)) throw invalidArgument("exactly one of email or userId is required", "member");
67
+ const value = requiredString(hasUserId ? input.userId : input.email, hasUserId ? "userId" : "email");
68
+ if (hasUserId ? !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu.test(value) : !/^[^\s@]+@[^\s@]+\.[^\s@]+$/u.test(value)) throw invalidArgument("a complete email or UUID is required", hasUserId ? "userId" : "email");
69
+ return call(context, {
70
+ body: hasUserId ? { userId: value } : { email: value },
71
+ callOptions: options,
72
+ capability: "members.resolve",
73
+ idempotent: true,
74
+ method: "POST",
75
+ operation: "members.resolve",
76
+ path: qmindPath("notebooks", notebook, "member-candidates", "resolve"),
77
+ schema: resolvedMemberCandidateSchema
78
+ });
79
+ },
80
+ async addMember(notebookId, input, options) {
81
+ const notebook = requiredString(notebookId, "notebookId");
82
+ const hasUserId = input?.userId !== void 0;
83
+ if (hasUserId === (input?.email !== void 0)) throw invalidArgument("exactly one of email or userId is required", "member");
84
+ const identity = hasUserId ? { userId: requiredString(input.userId, "userId") } : { email: requiredString(input.email, "email") };
85
+ return call(context, {
86
+ body: {
87
+ ...identity,
88
+ permission: memberPermission(input?.permission, "permission")
89
+ },
90
+ callOptions: options,
91
+ capability: "members",
92
+ idempotent: false,
93
+ method: "POST",
94
+ operation: "members.add",
95
+ path: hasUserId ? qmindPath("notebooks", notebook, "members", "resolve-and-add") : qmindPath("notebooks", notebook, "members"),
96
+ schema: notebookMemberSchema
97
+ });
98
+ },
99
+ async searchMemberCandidates() {
100
+ throw new QMindError("UNSUPPORTED_OPERATION", "Directory search is unavailable. Use an exact email or user ID.", { operation: "members.search" });
101
+ },
102
+ async createScheduledTask(notebookId, input, options) {
103
+ const notebook = requiredString(notebookId, "notebookId");
104
+ return call(context, {
105
+ body: compactUndefined({
106
+ config: optionalRecord(input?.config, "config"),
107
+ sceneType: scheduledTaskScene(input?.sceneType, "sceneType"),
108
+ schedule: requiredString(input?.schedule, "schedule")
109
+ }),
110
+ callOptions: options,
111
+ capability: "scheduledTasks",
112
+ idempotent: false,
113
+ method: "POST",
114
+ operation: "scheduledTasks.create",
115
+ path: qmindPath("notebooks", notebook, "scheduled-tasks"),
116
+ schema: scheduledTaskSchema
117
+ });
118
+ },
119
+ async deleteScheduledTask(notebookId, taskId, options) {
120
+ const notebook = requiredString(notebookId, "notebookId");
121
+ const task = requiredString(taskId, "taskId");
122
+ return call(context, {
123
+ callOptions: options,
124
+ capability: "scheduledTasks",
125
+ idempotent: false,
126
+ method: "DELETE",
127
+ operation: "scheduledTasks.delete",
128
+ path: qmindPath("notebooks", notebook, "scheduled-tasks", task),
129
+ schema: scheduledTaskDeletionSchema
130
+ });
131
+ },
132
+ async listMembers(notebookId, options) {
133
+ const notebook = requiredString(notebookId, "notebookId");
134
+ return call(context, {
135
+ callOptions: options,
136
+ capability: "members",
137
+ idempotent: true,
138
+ method: "GET",
139
+ operation: "members.list",
140
+ path: qmindPath("notebooks", notebook, "members"),
141
+ schema: notebookMemberListSchema
142
+ });
143
+ },
144
+ async listScheduledTasks(notebookId, options) {
145
+ const notebook = requiredString(notebookId, "notebookId");
146
+ return call(context, {
147
+ callOptions: options,
148
+ capability: "scheduledTasks",
149
+ idempotent: true,
150
+ method: "GET",
151
+ operation: "scheduledTasks.list",
152
+ path: qmindPath("notebooks", notebook, "scheduled-tasks"),
153
+ schema: scheduledTaskListSchema
154
+ });
155
+ },
156
+ async removeMember(notebookId, memberId, options) {
157
+ const notebook = requiredString(notebookId, "notebookId");
158
+ const member = requiredString(memberId, "memberId");
159
+ return call(context, {
160
+ callOptions: options,
161
+ capability: "members",
162
+ idempotent: false,
163
+ method: "DELETE",
164
+ operation: "members.remove",
165
+ path: qmindPath("notebooks", notebook, "members", member),
166
+ schema: voidResponseSchema
167
+ });
168
+ },
169
+ async updateMemberPermission(notebookId, memberId, input, options) {
170
+ const notebook = requiredString(notebookId, "notebookId");
171
+ const member = requiredString(memberId, "memberId");
172
+ return call(context, {
173
+ body: { permission: memberPermission(input?.permission, "permission") },
174
+ callOptions: options,
175
+ capability: "members",
176
+ idempotent: false,
177
+ method: "PUT",
178
+ operation: "members.update",
179
+ path: qmindPath("notebooks", notebook, "members", member),
180
+ schema: notebookMemberSchema
181
+ });
182
+ },
183
+ async updateScheduledTask(notebookId, taskId, input, options) {
184
+ const notebook = requiredString(notebookId, "notebookId");
185
+ const task = requiredString(taskId, "taskId");
186
+ const patch = compactUndefined({
187
+ config: optionalRecord(input?.config, "config"),
188
+ enabled: optionalBoolean(input?.enabled, "enabled"),
189
+ schedule: optionalString(input?.schedule, "schedule")
190
+ });
191
+ assertNonEmptyPatch(patch, "scheduledTask");
192
+ return call(context, {
193
+ body: patch,
194
+ callOptions: options,
195
+ capability: "scheduledTasks",
196
+ idempotent: false,
197
+ method: "PUT",
198
+ operation: "scheduledTasks.update",
199
+ path: qmindPath("notebooks", notebook, "scheduled-tasks", task),
200
+ schema: scheduledTaskSchema
201
+ });
202
+ }
203
+ };
204
+ }
205
+ //#endregion
206
+ export { createManagementOperations };
@@ -0,0 +1,13 @@
1
+ import { E as pathBuilder, ut as QMindError } from "./shared-evTnu_EB.js";
2
+ //#region ../sdk/src/nezha.ts
3
+ const dashboardPath = pathBuilder("/api/v1");
4
+ const sashPath = pathBuilder("/sash/api/v1");
5
+ function nezhaWebOfficePath(route, notebookId, sourceId, ...segments) {
6
+ if (route === void 0) throw new QMindError("UNSUPPORTED_OPERATION", "Nezha WebOffice is unavailable");
7
+ return (route === "dashboard" ? dashboardPath : sashPath)("notebooks", notebookId, "sources", sourceId, "weboffice", ...segments);
8
+ }
9
+ function nezhaRepoWikiPath(organizationId, operation) {
10
+ return dashboardPath("organizations", organizationId, "knowledge", "wiki", operation);
11
+ }
12
+ //#endregion
13
+ export { nezhaWebOfficePath as n, nezhaRepoWikiPath as t };