@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 +10 -0
- package/CHANGELOG.zh-CN.md +10 -0
- package/README.md +7 -3
- package/README.zh-CN.md +11 -7
- package/dist/data-sources-DItXSL_s.js +129 -0
- package/dist/{imports-Bb3NHsmd.js → imports-CSg7ebnN.js} +15 -16
- package/dist/management-iTQ9-Osc.js +206 -0
- package/dist/nezha-B_SP8BvK.js +13 -0
- package/dist/{notes-HS_N--cJ.js → notes-BUq1ciGO.js} +7 -8
- package/dist/qmind.js +434 -673
- package/dist/{schemas-DG7vaJMR.js → shared-evTnu_EB.js} +657 -45
- package/dist/{source-upload-XrNG4_4V.js → source-upload-DckYHoRo.js} +2 -3
- package/dist/{transfers-DONoEIKT.js → transfers-C0pXH5Qe.js} +11 -16
- package/dist/{wiki-DBT6JdyN.js → wiki-_a2EAozi.js} +3 -2
- package/dist/{wiki-branches-BfEMuXDW.js → wiki-branches-DViaqEOy.js} +3 -4
- package/package.json +5 -5
- package/dist/bot-gateway-C4c1bMi9.js +0 -374
- package/dist/management-BYR88TwO.js +0 -387
- package/dist/shared-CbvrtGyv.js +0 -386
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { m as requiredString, n as call } from "./shared-CbvrtGyv.js";
|
|
1
|
+
import { D as qmindPath, m as requiredString, n as call, tt as sourceUploadCapabilitiesSchema } from "./shared-evTnu_EB.js";
|
|
3
2
|
//#region ../sdk/src/operations/source-upload.ts
|
|
4
3
|
/** Notebook-scoped edit preflight, not the deployment-level capabilities lookup. */
|
|
5
4
|
async function preflightSourceUpload(context, notebookId, options) {
|
|
@@ -10,7 +9,7 @@ async function preflightSourceUpload(context, notebookId, options) {
|
|
|
10
9
|
idempotent: true,
|
|
11
10
|
method: "GET",
|
|
12
11
|
operation: "sources.uploadPreflight",
|
|
13
|
-
path:
|
|
12
|
+
path: qmindPath("notebooks", notebook, "sources", "upload", "capabilities"),
|
|
14
13
|
schema: sourceUploadCapabilitiesSchema
|
|
15
14
|
});
|
|
16
15
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as preflightSourceUpload } from "./source-upload-XrNG4_4V.js";
|
|
1
|
+
import { D as qmindPath, R as imageUploadTicketSchema, a as invalidArgument, ct as voidResponseSchema, et as sourceSchema, l as optionalString, m as requiredString, nt as sourceUploadTicketSchema, p as queryPath, r as compactUndefined, u as optionalTrimmedString, ut as QMindError, y as executeUnary } from "./shared-evTnu_EB.js";
|
|
2
|
+
import { t as preflightSourceUpload } from "./source-upload-DckYHoRo.js";
|
|
4
3
|
//#region ../sdk/src/workflows.ts
|
|
5
4
|
const QMIND_MULTIPART_UPLOAD_MAX_BYTES = 52428800;
|
|
6
5
|
const QMIND_SOURCE_UPLOAD_MAX_BYTES = 157286400;
|
|
@@ -119,11 +118,10 @@ function uploadMetadata(value) {
|
|
|
119
118
|
title: optionalTrimmedString(value.title, "title")
|
|
120
119
|
};
|
|
121
120
|
}
|
|
122
|
-
function progressReporter(
|
|
121
|
+
function progressReporter(operation, strategy, totalBytes, options) {
|
|
123
122
|
let lastUploadedBytes = 0;
|
|
124
123
|
const notify = (phase, uploadedBytes) => {
|
|
125
124
|
if (!Number.isSafeInteger(uploadedBytes) || uploadedBytes < lastUploadedBytes) throw new QMindError("HOST_POLICY_ERROR", "upload progress must be a monotonic integer", {
|
|
126
|
-
access: context.profile.access,
|
|
127
125
|
details: {
|
|
128
126
|
lastUploadedBytes,
|
|
129
127
|
totalBytes,
|
|
@@ -132,7 +130,6 @@ function progressReporter(context, operation, strategy, totalBytes, options) {
|
|
|
132
130
|
operation
|
|
133
131
|
});
|
|
134
132
|
if (uploadedBytes > totalBytes) throw new QMindError("HOST_POLICY_ERROR", "upload progress exceeds source size", {
|
|
135
|
-
access: context.profile.access,
|
|
136
133
|
details: {
|
|
137
134
|
totalBytes,
|
|
138
135
|
uploadedBytes
|
|
@@ -177,7 +174,7 @@ function transferCall(context, operation, request, schema) {
|
|
|
177
174
|
return executeUnary({
|
|
178
175
|
capability: operation.startsWith("images.") ? "images.presignUpload" : "transfers",
|
|
179
176
|
operation,
|
|
180
|
-
|
|
177
|
+
capabilities: context.capabilities,
|
|
181
178
|
request,
|
|
182
179
|
schema,
|
|
183
180
|
transport: context.transport
|
|
@@ -246,14 +243,13 @@ function createTransferOperations(context) {
|
|
|
246
243
|
const options = transferOptions(rawOptions);
|
|
247
244
|
const requestOptions = transferRequestOptions(options);
|
|
248
245
|
if (source.size > 52428800) throw new QMindError("FILE_TOO_LARGE", "image exceeds the 50 MiB upload limit", {
|
|
249
|
-
access: context.profile.access,
|
|
250
246
|
details: {
|
|
251
247
|
limitBytes: QMIND_MULTIPART_UPLOAD_MAX_BYTES,
|
|
252
248
|
size: source.size
|
|
253
249
|
},
|
|
254
250
|
operation: "images.upload"
|
|
255
251
|
});
|
|
256
|
-
const ticket = await transferCall(context, "images.presignUpload", hostRequest(
|
|
252
|
+
const ticket = await transferCall(context, "images.presignUpload", hostRequest(qmindPath("notebooks", notebook, "sources", sourceIdValue, "images", "presign"), "POST", false, options, requestOptions, "images.presignUpload", {
|
|
257
253
|
kind: "json",
|
|
258
254
|
value: {
|
|
259
255
|
filename: source.filename,
|
|
@@ -261,7 +257,7 @@ function createTransferOperations(context) {
|
|
|
261
257
|
size: source.size
|
|
262
258
|
}
|
|
263
259
|
}), imageUploadTicketSchema);
|
|
264
|
-
const progress = progressReporter(
|
|
260
|
+
const progress = progressReporter("images.upload", "presigned", source.size, options);
|
|
265
261
|
progress.start();
|
|
266
262
|
await transferCall(context, "images.upload", signedUploadRequest(ticket, source, progress, requestOptions, "images.upload"), voidResponseSchema);
|
|
267
263
|
progress.complete();
|
|
@@ -275,7 +271,6 @@ function createTransferOperations(context) {
|
|
|
275
271
|
const requestOptions = transferRequestOptions(options);
|
|
276
272
|
const limitBytes = getQMindSourceUploadMaxBytes(source.filename);
|
|
277
273
|
if (source.size > limitBytes) throw new QMindError("FILE_TOO_LARGE", "file exceeds the upload size limit for this format", {
|
|
278
|
-
access: context.profile.access,
|
|
279
274
|
details: {
|
|
280
275
|
limitBytes,
|
|
281
276
|
size: source.size
|
|
@@ -286,7 +281,7 @@ function createTransferOperations(context) {
|
|
|
286
281
|
...options,
|
|
287
282
|
...requestOptions("sources.uploadPreflight")
|
|
288
283
|
})) === "multipart") {
|
|
289
|
-
const progress = progressReporter(
|
|
284
|
+
const progress = progressReporter("transfers.source.multipart", "multipart", source.size, options);
|
|
290
285
|
progress.start();
|
|
291
286
|
const fields = compactUndefined({
|
|
292
287
|
parent_source_id: metadata.parentSourceId,
|
|
@@ -295,7 +290,7 @@ function createTransferOperations(context) {
|
|
|
295
290
|
source_type: metadata.sourceType,
|
|
296
291
|
title: metadata.title
|
|
297
292
|
});
|
|
298
|
-
const result = await transferCall(context, "transfers.source.multipart", hostRequest(queryPath(
|
|
293
|
+
const result = await transferCall(context, "transfers.source.multipart", hostRequest(queryPath(qmindPath("notebooks", notebook, "sources", "upload"), [["client", context.client]]), "POST", false, options, requestOptions, "transfers.source.multipart", {
|
|
299
294
|
file: source,
|
|
300
295
|
fields,
|
|
301
296
|
kind: "multipart",
|
|
@@ -304,7 +299,7 @@ function createTransferOperations(context) {
|
|
|
304
299
|
progress.complete();
|
|
305
300
|
return result;
|
|
306
301
|
}
|
|
307
|
-
const ticket = await transferCall(context, "transfers.source.presign", hostRequest(
|
|
302
|
+
const ticket = await transferCall(context, "transfers.source.presign", hostRequest(qmindPath("notebooks", notebook, "sources", "presign"), "POST", false, options, requestOptions, "transfers.source.presign", {
|
|
308
303
|
kind: "json",
|
|
309
304
|
value: {
|
|
310
305
|
filename: source.filename,
|
|
@@ -312,12 +307,12 @@ function createTransferOperations(context) {
|
|
|
312
307
|
size: source.size
|
|
313
308
|
}
|
|
314
309
|
}), sourceUploadTicketSchema);
|
|
315
|
-
const progress = progressReporter(
|
|
310
|
+
const progress = progressReporter("transfers.source.upload", "presigned", source.size, options);
|
|
316
311
|
progress.start();
|
|
317
312
|
await transferCall(context, "transfers.source.upload", signedUploadRequest(ticket, source, progress, requestOptions, "transfers.source.upload"), voidResponseSchema);
|
|
318
313
|
progress.complete();
|
|
319
314
|
progress.registering();
|
|
320
|
-
return transferCall(context, "transfers.source.register", hostRequest(
|
|
315
|
+
return transferCall(context, "transfers.source.register", hostRequest(qmindPath("notebooks", notebook, "sources", "register"), "POST", false, options, requestOptions, "transfers.source.register", {
|
|
321
316
|
kind: "json",
|
|
322
317
|
value: compactUndefined({
|
|
323
318
|
filename: source.filename,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { a as invalidArgument,
|
|
1
|
+
import { a as invalidArgument, m as requiredString, n as call, o as nonNegativeInteger, p as queryPath, u as optionalTrimmedString, ut as QMindError } from "./shared-evTnu_EB.js";
|
|
2
|
+
import { t as nezhaRepoWikiPath } from "./nezha-B_SP8BvK.js";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
//#region ../sdk/src/operations/wiki.ts
|
|
4
5
|
const partSchema = z.number().int().nonnegative();
|
|
@@ -52,7 +53,7 @@ function verifySnapshot(value, expected) {
|
|
|
52
53
|
return value;
|
|
53
54
|
}
|
|
54
55
|
function createWikiOperations(context) {
|
|
55
|
-
const path = (input, operation) =>
|
|
56
|
+
const path = (input, operation) => nezhaRepoWikiPath(requiredString(input?.organizationId, "organizationId"), operation);
|
|
56
57
|
return {
|
|
57
58
|
async getWikiCatalog(input, options) {
|
|
58
59
|
return call(context, {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as invalidArgument, d as pagination, m as requiredString, n as call, p as queryPath, u as optionalTrimmedString } from "./shared-CbvrtGyv.js";
|
|
1
|
+
import { O as qmindRoutes, a as invalidArgument, d as pagination, m as requiredString, n as call, p as queryPath, st as timestampSchema, u as optionalTrimmedString } from "./shared-evTnu_EB.js";
|
|
3
2
|
import { z } from "zod";
|
|
4
3
|
//#region ../sdk/src/operations/wiki-branches.ts
|
|
5
4
|
function isRecord(value) {
|
|
@@ -51,7 +50,7 @@ function createWikiBranchOperations(context) {
|
|
|
51
50
|
idempotent: true,
|
|
52
51
|
method: "GET",
|
|
53
52
|
operation: "wikiBranches.list",
|
|
54
|
-
path:
|
|
53
|
+
path: qmindRoutes.wikiBranchesPath(id),
|
|
55
54
|
schema: wikiBranchListSchema
|
|
56
55
|
})).branches;
|
|
57
56
|
},
|
|
@@ -67,7 +66,7 @@ function createWikiBranchOperations(context) {
|
|
|
67
66
|
idempotent: true,
|
|
68
67
|
method: "GET",
|
|
69
68
|
operation: "wikiBranches.listPage",
|
|
70
|
-
path: queryPath(
|
|
69
|
+
path: queryPath(qmindRoutes.wikiBranchesPath(id), [
|
|
71
70
|
["page", page],
|
|
72
71
|
["page_size", Math.min(pageSize, 50)],
|
|
73
72
|
["query", query]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qoder-ai/qmind-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "QMind command line interface",
|
|
5
5
|
"bin": {
|
|
6
6
|
"qmind": "bin/cli.js"
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"@types/picomatch": "4.0.3",
|
|
40
40
|
"@types/proper-lockfile": "4.1.4",
|
|
41
41
|
"@types/semver": "7.8.0",
|
|
42
|
-
"@ali/qmind-agent-core": "^
|
|
43
|
-
"@ali/qmind-
|
|
44
|
-
"@ali/qmind-
|
|
42
|
+
"@ali/qmind-agent-core": "^8.0.0",
|
|
43
|
+
"@ali/qmind-node-host": "^4.0.0",
|
|
44
|
+
"@ali/qmind-sdk": "^2.0.0"
|
|
45
45
|
},
|
|
46
46
|
"license": "UNLICENSED",
|
|
47
|
-
"readme": "# QMind CLI for Qoder Global\n\n[简体中文](./README.zh-CN.md)\n\nThe QMind command-line interface for Qoder Global lets you sign in, manage knowledge bases and sources, retrieve content, run RAG and task workflows, and synchronize local directories.\n\nPackage: `@qoder-ai/qmind-cli` · command: `qmind`\n\n## Install\n\nNode.js `>=22.19.0` is required.\n\n```sh\nnpm install --global @qoder-ai/qmind-cli\nqmind version\nqmind --help\n```\n\nUpgrade and uninstall through npm. `qmind self-update` only prints the npm upgrade command and never modifies npm-managed files.\n\n```sh\nnpm update --global @qoder-ai/qmind-cli\nnpm uninstall --global @qoder-ai/qmind-cli\n```\n\nThe Native standalone CLI uses the verified Global release channel instead. An installer-managed\nNative executable can check or apply the latest release without Node.js or npm:\n\n```sh\nqmind update --check\nqmind update\n```\n\n`self-update` remains an alias for `update`. The updater rejects channel/URL overrides, downgrades,\nunowned executables, release checksum mismatches, and modified installer bytes. Windows schedules\nreplacement after the running executable exits and records details beside the executable.\n\n## Quick start\n\n```sh\nqmind login\nqmind notebook list\nqmind source list --nb <notebook-id>\nqmind retrieve --nb <notebook-id> \"What must be checked before release?\"\n```\n\nInteractive login opens a browser and stores the session in a local file vault. For CI and agents, prefer an environment variable and structured output:\n\n```sh\nexport QMIND_TOKEN='<token>'\nqmind notebook list --non-interactive --format json\nqmind retrieve --nb <notebook-id> --format agent \"What is the deployment process?\"\n```\n\nDo not put tokens in command arguments, repositories, or logs. Run `qmind logout` to remove the current local session.\n\n### Login without a browser or interactive terminal\n\nCreate a PAT on the [Qoder PAT management page](https://qoder.com/account/integrations), then sign in through standard input (`--non-interactive` is also supported):\n\n```sh\nqmind login --pat-stdin < /path/to/pat-secret\nqmind notebook list --non-interactive --format json\n```\n\nAlternatively, inject `QODER_PROD_PAT` from your secret manager and run `qmind login --non-interactive`. `login --pat <token>` accepts an explicit PAT; prefer stdin or environment variables to keep secrets out of shell history and process arguments. PAT login exchanges a Job Token before saving the PAT, Job Token, and expiry in the current target's file vault. Later commands reuse the cached Job Token and exchange again on expiry or HTTP 401. Business requests use only the Job Token. `logout` removes the current target's local credentials without revoking the remote PAT.\n\nFor CI, inject a PAT and run commands directly without saving it to the vault. This product uses `QODER_PROD_PAT` for production and `QODER_TEST_PAT` for `--env test`, with `QODER_PERSONAL_ACCESS_TOKEN` as a fallback. Global `--env daily` uses only the generic variable. Dedicated PATs are never borrowed across regions or environments. Custom targets do not automatically read these PAT variables; explicitly use `--pat-stdin` or `--token`.\n\nFor browser login, `qmind login --no-browser` prints the authorization URL to open on another machine; it still requires an interactive terminal.\n\n## Commands\n\n| Command | Purpose |\n| ------------------------ | ---------------------------------------- |\n| `login` / `logout` | Sign in or remove local credentials |\n| `notebook` | Manage knowledge bases |\n| `source` | Manage knowledge-base sources |\n| `retrieve` | Retrieve context without invoking an LLM |\n| `rag` | Ask questions using a knowledge base |\n| `task` | Manage task runs |\n| `scheduled-task` | Manage notebook schedule configurations |\n| `upload-folder` / `sync` | Synchronize a local directory |\n| `image` | Obtain image upload or access URLs |\n| `version` | Print version and build information |\n| `update` / `self-update` | Update an installer-managed Native CLI |\n\n`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.\n\nRun `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.\n\n## Multi-notebook retrieval\n\n`retrieve --nb` accepts comma-separated or repeated Notebook IDs, deduplicating up to 32 distinct notebooks:\n\n```sh\nqmind retrieve --nb nb-1,nb-2 \"What is the deployment process?\" --format json\nqmind retrieve --nb nb-1 --nb nb-2 \"What is the deployment process?\" --format agent\n```\n\n- Selection is explicit; the CLI never defaults to all accessible notebooks.\n- Multiple notebooks use one unified retrieval request. The server jointly retrieves and reranks Source chunks; output retains server ranking and each chunk/citation's `notebookId` and `notebookTitle`.\n- `--top-k` controls the joint recall candidate budget per route/query/channel; it is not multiplied by notebook count. `--max-results` limits the final results across all selected notebooks. Zero uses server defaults.\n- `--sources` requires a single notebook. A single deduplicated notebook keeps the existing retrieval endpoint. All retrieval output formats expose chunks and citations without knowledge cards.\n- Multi-notebook JSON returns `{ chunks, citations, promptContext, total, reranked }`. NDJSON emits one `kind: \"chunk\"` record per returned chunk, in server order; zero hits emit no records. Table and agent output also identify each evidence item's notebook.\n- Unified retrieval fails as one request when a target is invalid or inaccessible. The CLI reports the error without retrying notebooks individually or constructing partial-success results. Retrieval results no longer contain a `cards` field.\n\n## Directory synchronization\n\nReview the plan before allowing remote deletions:\n\n```sh\nqmind upload-folder --nb <notebook-id> --dir ./docs --mode if-changed --dry-run\n```\n\nRemoving `--dry-run` enables writes. `--delete` treats the remote source root as a mirror of the local directory and removes extra remote entries. Concurrency must be between `1` and `10`.\n\n## Configuration and authentication\n\nThis 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`.\n\n```sh\nqmind login --env test\nQMIND_DEBUG_TOKEN='<debug-token>' qmind notebook list --env test --non-interactive --format json\nqmind login --sash http://localhost:8080 --dashboard http://localhost:3000\n```\n\nProduction token priority is `--token > QMIND_TOKEN > selected Qoder PAT variable > current production vault`. Debug token priority is `--token > QMIND_DEBUG_TOKEN > selected Qoder PAT variable > current debug vault`; credentials are never borrowed across targets.\n\nState is stored under `<state-root>/cli/global/<target>/`, where the state root is `QMIND_HOME` or `~/.qmind`. The CLI does not install, load, or access the OS Keyring. Credential files are plaintext JSON, not encrypted storage. On POSIX, partition directories use mode `0700` and files use `0600`; these modes do not represent Windows ACLs. Writes use atomic replacement, file locking, and compare-and-swap protection for refreshes.\n\nAfter upgrading from the legacy unpartitioned store, sign in again. Root-level config/credential files, `~/.qmind-env`, and old Keyring entries are not read, imported, or deleted automatically.\n\nThe shared 3.x Global/CN release is a breaking upgrade from Global 2.x. Upgrade this package with npm, then run `qmind login`; do not copy legacy credentials into the new partition. Existing versions before the shared release describe the Global/shared implementation only and do not imply a historical CN publication.\n\nCommon variables include `QMIND_TOKEN`, `QMIND_DEBUG_TOKEN`, `QMIND_HOME`, `QMIND_CLIENT`, `QMIND_NON_INTERACTIVE`, `QMIND_REQUEST_TIMEOUT_MS`, `QMIND_STREAM_IDLE_TIMEOUT_MS`, and `QMIND_TLS_CA_FILE`. `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` are supported. TLS verification is strict by default, and credentials are not forwarded to signed object-storage URLs.\n\n## Shared notebook discovery and access\n\n```sh\nqmind notebook list --shared --page 1 --page-size 20\nqmind notebook list --shared --format json\nqmind notebook get <notebook-id> --format json\n```\n\nBoth notebook collections support `--page` and `--page-size`. `--shared` cannot be combined with `--filter-client`. Shared results use the same flat `notebooks` output as the ordinary list and preserve the membership `permission`. JSON/NDJSON preserve server-provided `access` (current role, member count and action permissions); Agent output expands these fields. Table lists show role and member count, while details show action permissions. Missing permissions are not inferred and display as `unknown` in tables.\n\n## Commands aligned with Agent tools\n\nCore-backed workflows (`notebook discover`, `source import-url/read/delete-batch`, `mkdir --derive-path`, `mv --to/--to-root`, unified retrieval, and `scheduled-task`) return `{ ok, data/error, meta }` after entering Agent Core, with `meta.operationId` identifying the operation. `--format ndjson` emits one complete result per line; `table` and `agent` also use this JSON result. CLI validation and host/credential failures before Core keep the existing CLI error format: `{ error }` on stdout for JSON/NDJSON, or text on stderr otherwise. Command usage errors and declined confirmations go to stderr. `source list --parent` keeps the existing Source-list output. Exit codes are 0 for success, 1 for partial success/runtime failure/cancellation, and 2 for invalid arguments. A successful write does not mean Source ingestion or a scheduled run has completed.\n\n```sh\n# Select retrieval-eligible owned/shared notebooks; continue with nextCursor when hasMore is true\nqmind notebook discover --relationship all --page-size 20\nqmind notebook discover --relationship all --cursor '<nextCursor>'\n\n# Import a single page; inspect ingestion and content with source get / source read\nqmind source import-url --nb <notebook-id> --url https://example.com/guide\nqmind source list --nb <notebook-id> --parent <directory-id>\nqmind source read <source-id> --nb <notebook-id> --offset 0 --max-chars 20000\n\n# Derive paths from the actual parent and preserve the original basename when moving\nqmind source mkdir --nb <notebook-id> --title guides --parent <directory-id> --derive-path\nqmind source mv <source-id> --nb <notebook-id> --to <directory-id>\nqmind source mv <source-id> --nb <notebook-id> --to-root\n\n# 1..100 distinct IDs; confirm interactively or explicitly pass --force\nqmind source delete-batch <source-id-1> <source-id-2> --nb <notebook-id> --force\n```\n\n`notebook list/get` JSON/NDJSON preserve the server's overview, sourceCount and materialCount. Agent output expands summary/topics; table lists include summaries and Source counts. `discover` supports owned/shared/all and cursors, defaults to all, and lists retrieval-eligible notebooks; use `list` for the management collection. An empty page may still have `hasMore:true`; continue with the same relationship.\n\n`source read` checks ingestion status and returns `content/contentType/truncated/nextOffset`. It still fetches the entire body before slicing, so only output size is bounded. Existing `source content` full-text/download behavior is unchanged. `source list --parent` cannot be combined with `--all`.\n\n`mkdir --derive-path` conflicts with `--path`. `mv --to/--to-root` conflicts with the legacy parent/path/rename/status options and only moves eligible leaf documents within one notebook, preserving the basename. Existing low-level mkdir/mv patch operations remain available.\n\nBatch deletion returns the submitted sourceIds and successCount/failureCount; sourceIds is not a list of successfully deleted IDs. Partial failure exits 1. Reconcile current state before another call; do not guess failed IDs or replay the entire batch.\n\n## Precise and unified retrieval\n\nExisting `retrieve --nb` defaults and output remain unchanged. Explicit `--unified` or `--targets` selects the same unified retrieval workflow used by Agent tools, including notebook identity in single-notebook chunks:\n\n```sh\nqmind retrieve --nb <notebook-id> --unified --score-threshold 0.6 'Deployment process'\nqmind retrieve --targets '[{\"notebookId\":\"nb-1\",\"sourceIds\":[\"source-1\"]},{\"notebookId\":\"nb-2\",\"sourceIds\":[\"source-2\"]}]' --max-results 8 'Deployment process'\n```\n\n`--targets` conflicts with `--nb` and `--sources` and supports independent Source filters per notebook. Unified retrieval defaults to maxResults=8 (1..50), with optional topK (1..100); zero selects the workflow default. There may be at most 32 unique targets. Results use the envelope above: read `data.chunks/data.promptContext`. `--score-threshold` accepts 0..1 and also works on the existing retrieval path. Zero budgets on the existing path still use server defaults; scripts are not silently migrated.\n\n## Scheduled task configuration\n\n```sh\nqmind scheduled-task create --nb <notebook-id> --scene source_refresh --schedule 'CRON_TZ=Asia/Shanghai 0 9 * * *'\nqmind scheduled-task list --nb <notebook-id> --enabled true --page 1 --page-size 20\nqmind scheduled-task update <task-id> --nb <notebook-id> --schedule 'CRON_TZ=Asia/Shanghai 0 10 * * *'\nqmind scheduled-task pause <task-id> --nb <notebook-id>\nqmind scheduled-task resume <task-id> --nb <notebook-id>\nqmind scheduled-task delete <task-id> --nb <notebook-id>\n```\n\n`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`.\n\nConfiguration 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.\n\n## Unconfirmed writes\n\nWhen a new command returns `error.code=outcome_unknown` and `retryable:false`, inspect current state before deciding what to do next; do not retry automatically. Existing direct-write commands also distinguish this state in JSON/NDJSON errors and retain the original causeCode/requestId. Unknown outcomes do not prove a request reached the server; a same-name resource does not prove this call created it.\n\n`notebook delete` and `source delete` support JSON/NDJSON success receipts. Single-Source deletion stops if preflight cannot read the Source; only explicit `--force` skips directory confirmation. Default text output remains `deleted`.\n",
|
|
47
|
+
"readme": "# QMind CLI for Qoder Global\n\n[简体中文](./README.zh-CN.md)\n\nThe QMind command-line interface for Qoder Global lets you sign in, manage knowledge bases and sources, retrieve content, run RAG and task workflows, and synchronize local directories.\n\nPackage: `@qoder-ai/qmind-cli` · command: `qmind`\n\n## Install\n\nNode.js `>=22.19.0` is required.\n\n```sh\nnpm install --global @qoder-ai/qmind-cli\nqmind version\nqmind --help\n```\n\nUpgrade and uninstall through npm. `qmind self-update` only prints the npm upgrade command and never modifies npm-managed files.\n\n```sh\nnpm update --global @qoder-ai/qmind-cli\nnpm uninstall --global @qoder-ai/qmind-cli\n```\n\nThe Native standalone CLI uses the verified Global release channel instead. An installer-managed\nNative executable can check or apply the latest release without Node.js or npm:\n\n```sh\nqmind update --check\nqmind update\n```\n\n`self-update` remains an alias for `update`. The updater rejects channel/URL overrides, downgrades,\nunowned executables, release checksum mismatches, and modified installer bytes. Windows schedules\nreplacement after the running executable exits and records details beside the executable.\n\n## Quick start\n\n```sh\nqmind login\nqmind notebook list\nqmind source list --nb <notebook-id>\nqmind retrieve --nb <notebook-id> \"What must be checked before release?\"\n```\n\nInteractive login opens a browser and stores the session in a local file vault. For CI and agents, prefer an environment variable and structured output:\n\n```sh\nexport QMIND_TOKEN='<token>'\nqmind notebook list --non-interactive --format json\nqmind retrieve --nb <notebook-id> --format agent \"What is the deployment process?\"\n```\n\nDo not put tokens in command arguments, repositories, or logs. Run `qmind logout` to remove the current local session.\n\n### Login without a browser or interactive terminal\n\nCreate a PAT on the [Qoder PAT management page](https://qoder.com/account/integrations), then sign in through standard input (`--non-interactive` is also supported):\n\n```sh\nqmind login --pat-stdin < /path/to/pat-secret\nqmind notebook list --non-interactive --format json\n```\n\nAlternatively, inject `QODER_PROD_PAT` from your secret manager and run `qmind login --non-interactive`. `login --pat <token>` accepts an explicit PAT; prefer stdin or environment variables to keep secrets out of shell history and process arguments. PAT login exchanges a Job Token before saving the PAT, Job Token, and expiry in the current target's file vault. Later commands reuse the cached Job Token and exchange again on expiry or HTTP 401. Business requests use only the Job Token. `logout` removes the current target's local credentials without revoking the remote PAT.\n\nFor CI, inject a PAT and run commands directly without saving it to the vault. This product uses `QODER_PROD_PAT` for production and `QODER_TEST_PAT` for `--env test`, with `QODER_PERSONAL_ACCESS_TOKEN` as a fallback. Global `--env daily` uses only the generic variable. Dedicated PATs are never borrowed across regions or environments. Custom targets do not automatically read these PAT variables; explicitly use `--pat-stdin` or `--token`.\n\nFor browser login, `qmind login --no-browser` prints the authorization URL to open on another machine; it still requires an interactive terminal.\n\n## Commands\n\n| Command | Purpose |\n| ------------------------ | ---------------------------------------- |\n| `login` / `logout` | Sign in or remove local credentials |\n| `notebook` | Manage knowledge bases |\n| `source` | Manage knowledge-base sources |\n| `retrieve` | Retrieve context without invoking an LLM |\n| `rag` | Ask questions using a knowledge base |\n| `task` | Manage task runs |\n| `scheduled-task` | Manage notebook schedule configurations |\n| `upload-folder` / `sync` | Synchronize a local directory |\n| `image` | Obtain image upload or access URLs |\n| `version` | Print version and build information |\n| `update` / `self-update` | Update an installer-managed Native CLI |\n\n`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.\n\n`source import-site` imports at the notebook root and supports a sitemap, path filters, and a page limit.\n\nRun `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.\n\n## Multi-notebook retrieval\n\n`retrieve --nb` accepts comma-separated or repeated Notebook IDs, deduplicating up to 32 distinct notebooks:\n\n```sh\nqmind retrieve --nb nb-1,nb-2 \"What is the deployment process?\" --format json\nqmind retrieve --nb nb-1 --nb nb-2 \"What is the deployment process?\" --format agent\n```\n\n- Selection is explicit; the CLI never defaults to all accessible notebooks.\n- Multiple notebooks use one unified retrieval request. The server jointly retrieves and reranks Source chunks; output retains server ranking and each chunk/citation's `notebookId` and `notebookTitle`.\n- `--top-k` controls the joint recall candidate budget per route/query/channel; it is not multiplied by notebook count. `--max-results` limits the final results across all selected notebooks. Zero uses server defaults.\n- `--sources` requires a single notebook. A single deduplicated notebook keeps the existing retrieval endpoint. All retrieval output formats expose chunks and citations without knowledge cards.\n- Multi-notebook JSON returns `{ chunks, citations, promptContext, total, reranked }`. NDJSON emits one `kind: \"chunk\"` record per returned chunk, in server order; zero hits emit no records. Table and agent output also identify each evidence item's notebook.\n- Unified retrieval fails as one request when a target is invalid or inaccessible. The CLI reports the error without retrying notebooks individually or constructing partial-success results. Retrieval results no longer contain a `cards` field.\n\n## Directory synchronization\n\nReview the plan before allowing remote deletions:\n\n```sh\nqmind upload-folder --nb <notebook-id> --dir ./docs --mode if-changed --dry-run\n```\n\nRemoving `--dry-run` enables writes. `--delete` treats the remote source root as a mirror of the local directory and removes extra remote entries. Concurrency must be between `1` and `10`.\n\n## Configuration and authentication\n\nThis 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`.\n\n**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`.\n\n```sh\nqmind login --env test\nQMIND_DEBUG_TOKEN='<debug-token>' qmind notebook list --env test --non-interactive --format json\nqmind login --sash http://localhost:8080 --dashboard http://localhost:3000\n```\n\nProduction token priority is `--token > QMIND_TOKEN > selected Qoder PAT variable > current production vault`. Debug token priority is `--token > QMIND_DEBUG_TOKEN > selected Qoder PAT variable > current debug vault`; credentials are never borrowed across targets.\n\nState is stored under `<state-root>/cli/global/<target>/`, where the state root is `QMIND_HOME` or `~/.qmind`. The CLI does not install, load, or access the OS Keyring. Credential files are plaintext JSON, not encrypted storage. On POSIX, partition directories use mode `0700` and files use `0600`; these modes do not represent Windows ACLs. Writes use atomic replacement, file locking, and compare-and-swap protection for refreshes.\n\nAfter upgrading from the legacy unpartitioned store, sign in again. Root-level config/credential files, `~/.qmind-env`, and old Keyring entries are not read, imported, or deleted automatically.\n\nThe shared 3.x Global/CN release is a breaking upgrade from Global 2.x. Upgrade this package with npm, then run `qmind login`; do not copy legacy credentials into the new partition. Existing versions before the shared release describe the Global/shared implementation only and do not imply a historical CN publication.\n\nCommon variables include `QMIND_TOKEN`, `QMIND_DEBUG_TOKEN`, `QMIND_HOME`, `QMIND_CLIENT`, `QMIND_NON_INTERACTIVE`, `QMIND_REQUEST_TIMEOUT_MS`, `QMIND_STREAM_IDLE_TIMEOUT_MS`, and `QMIND_TLS_CA_FILE`. `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` are supported. TLS verification is strict by default, and credentials are not forwarded to signed object-storage URLs.\n\n## Shared notebook discovery and access\n\n```sh\nqmind notebook list --shared --page 1 --page-size 20\nqmind notebook list --shared --format json\nqmind notebook get <notebook-id> --format json\n```\n\nBoth notebook collections support `--page` and `--page-size`. `--shared` cannot be combined with `--filter-client`. Shared results use the same flat `notebooks` output as the ordinary list and preserve the membership `permission`. JSON/NDJSON preserve server-provided `access` (current role, member count and action permissions); Agent output expands these fields. Table lists show role and member count, while details show action permissions. Missing permissions are not inferred and display as `unknown` in tables.\n\n## Commands aligned with Agent tools\n\nCore-backed workflows (`notebook discover`, `source import-url/read/delete-batch`, `mkdir --derive-path`, `mv --to/--to-root`, unified retrieval, and `scheduled-task`) return `{ ok, data/error, meta }` after entering Agent Core, with `meta.operationId` identifying the operation. `--format ndjson` emits one complete result per line; `table` and `agent` also use this JSON result. CLI validation and host/credential failures before Core keep the existing CLI error format: `{ error }` on stdout for JSON/NDJSON, or text on stderr otherwise. Command usage errors and declined confirmations go to stderr. `source list --parent` keeps the existing Source-list output. Exit codes are 0 for success, 1 for partial success/runtime failure/cancellation, and 2 for invalid arguments. A successful write does not mean Source ingestion or a scheduled run has completed.\n\n```sh\n# Select retrieval-eligible owned/shared notebooks; continue with nextCursor when hasMore is true\nqmind notebook discover --relationship all --page-size 20\nqmind notebook discover --relationship all --cursor '<nextCursor>'\n\n# Import a single page; inspect ingestion and content with source get / source read\nqmind source import-url --nb <notebook-id> --url https://example.com/guide\nqmind source list --nb <notebook-id> --parent <directory-id>\nqmind source read <source-id> --nb <notebook-id> --offset 0 --max-chars 20000\n\n# Derive paths from the actual parent and preserve the original basename when moving\nqmind source mkdir --nb <notebook-id> --title guides --parent <directory-id> --derive-path\nqmind source mv <source-id> --nb <notebook-id> --to <directory-id>\nqmind source mv <source-id> --nb <notebook-id> --to-root\n\n# 1..100 distinct IDs; confirm interactively or explicitly pass --force\nqmind source delete-batch <source-id-1> <source-id-2> --nb <notebook-id> --force\n```\n\n`notebook list/get` JSON/NDJSON preserve the server's overview, sourceCount and materialCount. Agent output expands summary/topics; table lists include summaries and Source counts. `discover` supports owned/shared/all and cursors, defaults to all, and lists retrieval-eligible notebooks; use `list` for the management collection. An empty page may still have `hasMore:true`; continue with the same relationship.\n\n`source read` checks ingestion status and returns `content/contentType/truncated/nextOffset`. It still fetches the entire body before slicing, so only output size is bounded. Existing `source content` full-text/download behavior is unchanged. `source list --parent` cannot be combined with `--all`.\n\n`mkdir --derive-path` conflicts with `--path`. `mv --to/--to-root` conflicts with the legacy parent/path/rename/status options and only moves eligible leaf documents within one notebook, preserving the basename. Existing low-level mkdir/mv patch operations remain available.\n\nBatch deletion returns the submitted sourceIds and successCount/failureCount; sourceIds is not a list of successfully deleted IDs. Partial failure exits 1. Reconcile current state before another call; do not guess failed IDs or replay the entire batch.\n\n## Precise and unified retrieval\n\nExisting `retrieve --nb` defaults and output remain unchanged. Explicit `--unified` or `--targets` selects the same unified retrieval workflow used by Agent tools, including notebook identity in single-notebook chunks:\n\n```sh\nqmind retrieve --nb <notebook-id> --unified --score-threshold 0.6 'Deployment process'\nqmind retrieve --targets '[{\"notebookId\":\"nb-1\",\"sourceIds\":[\"source-1\"]},{\"notebookId\":\"nb-2\",\"sourceIds\":[\"source-2\"]}]' --max-results 8 'Deployment process'\n```\n\n`--targets` conflicts with `--nb` and `--sources` and supports independent Source filters per notebook. Unified retrieval defaults to maxResults=8 (1..50), with optional topK (1..100); zero selects the workflow default. There may be at most 32 unique targets. Results use the envelope above: read `data.chunks/data.promptContext`. `--score-threshold` accepts 0..1 and also works on the existing retrieval path. Zero budgets on the existing path still use server defaults; scripts are not silently migrated.\n\n## Scheduled task configuration\n\n```sh\nqmind scheduled-task create --nb <notebook-id> --scene source_refresh --schedule 'CRON_TZ=Asia/Shanghai 0 9 * * *'\nqmind scheduled-task list --nb <notebook-id> --enabled true --page 1 --page-size 20\nqmind scheduled-task update <task-id> --nb <notebook-id> --schedule 'CRON_TZ=Asia/Shanghai 0 10 * * *'\nqmind scheduled-task pause <task-id> --nb <notebook-id>\nqmind scheduled-task resume <task-id> --nb <notebook-id>\nqmind scheduled-task delete <task-id> --nb <notebook-id>\n```\n\n`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`.\n\nConfiguration 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.\n\n## Unconfirmed writes\n\nWhen a new command returns `error.code=outcome_unknown` and `retryable:false`, inspect current state before deciding what to do next; do not retry automatically. Existing direct-write commands also distinguish this state in JSON/NDJSON errors and retain the original causeCode/requestId. Unknown outcomes do not prove a request reached the server; a same-name resource does not prove this call created it.\n\n`notebook delete` and `source delete` support JSON/NDJSON success receipts. Single-Source deletion stops if preflight cannot read the Source; only explicit `--force` skips directory confirmation. Default text output remains `deleted`.\n",
|
|
48
48
|
"readmeFilename": "README.md"
|
|
49
49
|
}
|
|
@@ -1,374 +0,0 @@
|
|
|
1
|
-
import { F as timestampSchema } from "./schemas-DG7vaJMR.js";
|
|
2
|
-
import { 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-CbvrtGyv.js";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
//#region ../sdk/src/operations/bot-gateway-codecs.ts
|
|
5
|
-
const botTimestamp = z.preprocess((value) => typeof value === "object" && value !== null && !Array.isArray(value) && !("seconds" in value) ? {
|
|
6
|
-
...value,
|
|
7
|
-
seconds: 0
|
|
8
|
-
} : value, timestampSchema).optional();
|
|
9
|
-
const jsonObject = z.record(z.string(), z.json());
|
|
10
|
-
const fields = {
|
|
11
|
-
id: z.string().min(1),
|
|
12
|
-
org_id: z.string().default(""),
|
|
13
|
-
platform: z.string().default(""),
|
|
14
|
-
is_active: z.boolean().default(false),
|
|
15
|
-
created_at: botTimestamp,
|
|
16
|
-
updated_at: botTimestamp
|
|
17
|
-
};
|
|
18
|
-
function base(value) {
|
|
19
|
-
return {
|
|
20
|
-
id: value.id,
|
|
21
|
-
orgId: value.org_id,
|
|
22
|
-
platform: value.platform,
|
|
23
|
-
isActive: value.is_active,
|
|
24
|
-
...value.created_at === void 0 ? {} : { createdAt: value.created_at },
|
|
25
|
-
...value.updated_at === void 0 ? {} : { updatedAt: value.updated_at }
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
const platformAppSchema = z.object({
|
|
29
|
-
...fields,
|
|
30
|
-
app_name: z.string().default(""),
|
|
31
|
-
client_id: z.string().default("")
|
|
32
|
-
}).transform((value) => ({
|
|
33
|
-
...base(value),
|
|
34
|
-
appName: value.app_name,
|
|
35
|
-
clientId: value.client_id
|
|
36
|
-
}));
|
|
37
|
-
const expertBindingSchema = z.object({
|
|
38
|
-
...fields,
|
|
39
|
-
user_id: z.string().default(""),
|
|
40
|
-
platform_app_id: z.string().default(""),
|
|
41
|
-
external_union_id: z.string().default(""),
|
|
42
|
-
external_nickname: z.string().default("")
|
|
43
|
-
}).transform((value) => ({
|
|
44
|
-
...base(value),
|
|
45
|
-
userId: value.user_id,
|
|
46
|
-
platformAppId: value.platform_app_id,
|
|
47
|
-
externalUnionId: value.external_union_id,
|
|
48
|
-
externalNickname: value.external_nickname
|
|
49
|
-
}));
|
|
50
|
-
const groupBindingSchema = z.object({
|
|
51
|
-
...fields,
|
|
52
|
-
platform_app_id: z.string().default(""),
|
|
53
|
-
conversation_id: z.string().default(""),
|
|
54
|
-
conversation_name: z.string().default(""),
|
|
55
|
-
notebook_id: z.string().default(""),
|
|
56
|
-
context_window: z.int32().default(0),
|
|
57
|
-
writer_user_id: z.string().default(""),
|
|
58
|
-
instructions: jsonObject.nullish()
|
|
59
|
-
}).transform((value) => ({
|
|
60
|
-
...base(value),
|
|
61
|
-
platformAppId: value.platform_app_id,
|
|
62
|
-
conversationId: value.conversation_id,
|
|
63
|
-
conversationName: value.conversation_name,
|
|
64
|
-
notebookId: value.notebook_id,
|
|
65
|
-
contextWindow: value.context_window,
|
|
66
|
-
writerUserId: value.writer_user_id,
|
|
67
|
-
...value.instructions == null ? {} : { instructions: value.instructions }
|
|
68
|
-
}));
|
|
69
|
-
const pageInfoSchema = z.object({
|
|
70
|
-
current_page: z.int32().nonnegative().default(0),
|
|
71
|
-
last_page: z.int32().nonnegative().default(0),
|
|
72
|
-
next_page: z.int32().nonnegative().default(0),
|
|
73
|
-
prev_page: z.int32().nonnegative().default(0),
|
|
74
|
-
page_size: z.int32().nonnegative().default(0),
|
|
75
|
-
total_size: z.int32().nonnegative().default(0),
|
|
76
|
-
next_token: z.string().default("")
|
|
77
|
-
}).transform((value) => ({
|
|
78
|
-
currentPage: value.current_page,
|
|
79
|
-
lastPage: value.last_page,
|
|
80
|
-
nextPage: value.next_page,
|
|
81
|
-
previousPage: value.prev_page,
|
|
82
|
-
pageSize: value.page_size,
|
|
83
|
-
totalSize: value.total_size,
|
|
84
|
-
nextToken: value.next_token
|
|
85
|
-
}));
|
|
86
|
-
const platformAppListSchema = z.object({
|
|
87
|
-
apps: z.array(platformAppSchema).nullish(),
|
|
88
|
-
pages: pageInfoSchema.nullish()
|
|
89
|
-
}).transform((value) => ({
|
|
90
|
-
apps: value.apps ?? [],
|
|
91
|
-
...value.pages == null ? {} : { pages: value.pages }
|
|
92
|
-
}));
|
|
93
|
-
const expertBindingListSchema = z.object({
|
|
94
|
-
bindings: z.array(expertBindingSchema).nullish(),
|
|
95
|
-
pages: pageInfoSchema.nullish()
|
|
96
|
-
}).transform((value) => ({
|
|
97
|
-
bindings: value.bindings ?? [],
|
|
98
|
-
...value.pages == null ? {} : { pages: value.pages }
|
|
99
|
-
}));
|
|
100
|
-
const groupBindingListSchema = z.object({
|
|
101
|
-
bindings: z.array(groupBindingSchema).nullish(),
|
|
102
|
-
pages: pageInfoSchema.nullish()
|
|
103
|
-
}).transform((value) => ({
|
|
104
|
-
bindings: value.bindings ?? [],
|
|
105
|
-
...value.pages == null ? {} : { pages: value.pages }
|
|
106
|
-
}));
|
|
107
|
-
const publishDingTalkSchema = z.object({
|
|
108
|
-
binding_code: z.string().min(1),
|
|
109
|
-
bind_command: z.string().min(1),
|
|
110
|
-
group_binding: groupBindingSchema
|
|
111
|
-
}).transform((value) => ({
|
|
112
|
-
bindingCode: value.binding_code,
|
|
113
|
-
bindCommand: value.bind_command,
|
|
114
|
-
groupBinding: value.group_binding
|
|
115
|
-
}));
|
|
116
|
-
const inviteDingTalkSchema = z.object({
|
|
117
|
-
binding_code: z.string().min(1),
|
|
118
|
-
bind_command: z.string().min(1),
|
|
119
|
-
expert_binding: expertBindingSchema
|
|
120
|
-
}).transform((value) => ({
|
|
121
|
-
bindingCode: value.binding_code,
|
|
122
|
-
bindCommand: value.bind_command,
|
|
123
|
-
expertBinding: value.expert_binding
|
|
124
|
-
}));
|
|
125
|
-
const botDeleteSchema = z.object({}).transform(() => void 0);
|
|
126
|
-
function optionalInt32(value, field) {
|
|
127
|
-
if (value === void 0) return void 0;
|
|
128
|
-
if (typeof value !== "number" || !Number.isInteger(value) || value < -2147483648 || value > 2147483647) throw invalidArgument(`${field} must be an int32`, field);
|
|
129
|
-
return value;
|
|
130
|
-
}
|
|
131
|
-
function isJson(value, ancestors) {
|
|
132
|
-
if (value === null || typeof value === "string" || typeof value === "boolean") return true;
|
|
133
|
-
if (typeof value === "number") return Number.isFinite(value);
|
|
134
|
-
if (typeof value !== "object" || ancestors.has(value)) return false;
|
|
135
|
-
if (!Array.isArray(value) && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) return false;
|
|
136
|
-
if (Object.getOwnPropertySymbols(value).length > 0) return false;
|
|
137
|
-
ancestors.add(value);
|
|
138
|
-
const valid = (Array.isArray(value) ? Array.from(value) : Object.values(value)).every((child) => isJson(child, ancestors));
|
|
139
|
-
ancestors.delete(value);
|
|
140
|
-
return valid;
|
|
141
|
-
}
|
|
142
|
-
function optionalInstructions(value) {
|
|
143
|
-
const object = optionalRecord(value, "instructions");
|
|
144
|
-
if (object === void 0) return void 0;
|
|
145
|
-
try {
|
|
146
|
-
if (isJson(object, /* @__PURE__ */ new Set())) return object;
|
|
147
|
-
} catch {}
|
|
148
|
-
throw invalidArgument("instructions must contain only JSON values", "instructions");
|
|
149
|
-
}
|
|
150
|
-
//#endregion
|
|
151
|
-
//#region ../sdk/src/operations/bot-gateway.ts
|
|
152
|
-
function groupFields(input) {
|
|
153
|
-
return compactUndefined({
|
|
154
|
-
conversation_name: optionalString(input?.conversationName, "conversationName"),
|
|
155
|
-
context_window: optionalInt32(input?.contextWindow, "contextWindow"),
|
|
156
|
-
writer_user_id: optionalString(input?.writerUserId, "writerUserId"),
|
|
157
|
-
is_active: optionalBoolean(input?.isActive, "isActive"),
|
|
158
|
-
instructions: optionalInstructions(input?.instructions)
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
function patch(body) {
|
|
162
|
-
assertNonEmptyPatch(body, "input");
|
|
163
|
-
return body;
|
|
164
|
-
}
|
|
165
|
-
function createBotGatewayOperations(context) {
|
|
166
|
-
const path = (notebookId, ...segments) => context.profile.apiPath("notebooks", requiredString(notebookId, "notebookId"), "botgw", ...segments);
|
|
167
|
-
const listPath = (notebookId, resource, input = {}) => {
|
|
168
|
-
const page = pagination({
|
|
169
|
-
page: input.page ?? 1,
|
|
170
|
-
pageSize: input.pageSize ?? 20
|
|
171
|
-
});
|
|
172
|
-
const onlyActive = optionalBoolean(input.onlyActive, "onlyActive");
|
|
173
|
-
return queryPath(path(notebookId, resource), [
|
|
174
|
-
["page", optionalInt32(page.page, "page")],
|
|
175
|
-
["page_size", optionalInt32(page.pageSize, "pageSize")],
|
|
176
|
-
["platform", optionalTrimmedString(input.platform, "platform")],
|
|
177
|
-
["only_active", onlyActive === void 0 ? void 0 : String(onlyActive)],
|
|
178
|
-
["platform_app_id", resource === "platform-apps" ? void 0 : optionalTrimmedString(input.platformAppId, "platformAppId")],
|
|
179
|
-
["user_id", resource === "expert-bindings" ? optionalTrimmedString(input.userId, "userId") : void 0]
|
|
180
|
-
]);
|
|
181
|
-
};
|
|
182
|
-
return {
|
|
183
|
-
async listPlatformApps(notebookId, input, options) {
|
|
184
|
-
return call(context, {
|
|
185
|
-
callOptions: options,
|
|
186
|
-
capability: "botGateway",
|
|
187
|
-
method: "GET",
|
|
188
|
-
idempotent: true,
|
|
189
|
-
operation: "botGateway.platformApps.list",
|
|
190
|
-
path: listPath(notebookId, "platform-apps", input),
|
|
191
|
-
schema: platformAppListSchema
|
|
192
|
-
});
|
|
193
|
-
},
|
|
194
|
-
async createPlatformApp(notebookId, input, options) {
|
|
195
|
-
const body = compactUndefined({
|
|
196
|
-
platform: requiredString(input?.platform, "platform"),
|
|
197
|
-
app_name: requiredString(input?.appName, "appName"),
|
|
198
|
-
client_id: requiredString(input?.clientId, "clientId"),
|
|
199
|
-
client_secret: requiredText(input?.clientSecret, "clientSecret"),
|
|
200
|
-
is_active: optionalBoolean(input?.isActive, "isActive")
|
|
201
|
-
});
|
|
202
|
-
return call(context, {
|
|
203
|
-
body,
|
|
204
|
-
callOptions: options,
|
|
205
|
-
capability: "botGateway",
|
|
206
|
-
method: "POST",
|
|
207
|
-
idempotent: false,
|
|
208
|
-
operation: "botGateway.platformApps.create",
|
|
209
|
-
path: path(notebookId, "platform-apps"),
|
|
210
|
-
schema: platformAppSchema
|
|
211
|
-
});
|
|
212
|
-
},
|
|
213
|
-
async updatePlatformApp(notebookId, appId, input, options) {
|
|
214
|
-
const body = patch(compactUndefined({
|
|
215
|
-
app_name: optionalString(input?.appName, "appName"),
|
|
216
|
-
client_secret: optionalString(input?.clientSecret, "clientSecret"),
|
|
217
|
-
is_active: optionalBoolean(input?.isActive, "isActive")
|
|
218
|
-
}));
|
|
219
|
-
return call(context, {
|
|
220
|
-
body,
|
|
221
|
-
callOptions: options,
|
|
222
|
-
capability: "botGateway",
|
|
223
|
-
method: "PATCH",
|
|
224
|
-
idempotent: false,
|
|
225
|
-
operation: "botGateway.platformApps.update",
|
|
226
|
-
path: path(notebookId, "platform-apps", requiredString(appId, "appId")),
|
|
227
|
-
schema: platformAppSchema
|
|
228
|
-
});
|
|
229
|
-
},
|
|
230
|
-
async deletePlatformApp(notebookId, appId, options) {
|
|
231
|
-
return call(context, {
|
|
232
|
-
callOptions: options,
|
|
233
|
-
capability: "botGateway",
|
|
234
|
-
method: "DELETE",
|
|
235
|
-
idempotent: false,
|
|
236
|
-
operation: "botGateway.platformApps.delete",
|
|
237
|
-
path: path(notebookId, "platform-apps", requiredString(appId, "appId")),
|
|
238
|
-
schema: botDeleteSchema
|
|
239
|
-
});
|
|
240
|
-
},
|
|
241
|
-
async listExpertBindings(notebookId, input, options) {
|
|
242
|
-
return call(context, {
|
|
243
|
-
callOptions: options,
|
|
244
|
-
capability: "botGateway",
|
|
245
|
-
method: "GET",
|
|
246
|
-
idempotent: true,
|
|
247
|
-
operation: "botGateway.expertBindings.list",
|
|
248
|
-
path: listPath(notebookId, "expert-bindings", input),
|
|
249
|
-
schema: expertBindingListSchema
|
|
250
|
-
});
|
|
251
|
-
},
|
|
252
|
-
async updateExpertBinding(notebookId, bindingId, input, options) {
|
|
253
|
-
const body = patch(compactUndefined({
|
|
254
|
-
external_nickname: optionalString(input?.externalNickname, "externalNickname"),
|
|
255
|
-
is_active: optionalBoolean(input?.isActive, "isActive")
|
|
256
|
-
}));
|
|
257
|
-
return call(context, {
|
|
258
|
-
body,
|
|
259
|
-
callOptions: options,
|
|
260
|
-
capability: "botGateway",
|
|
261
|
-
method: "PATCH",
|
|
262
|
-
idempotent: false,
|
|
263
|
-
operation: "botGateway.expertBindings.update",
|
|
264
|
-
path: path(notebookId, "expert-bindings", requiredString(bindingId, "bindingId")),
|
|
265
|
-
schema: expertBindingSchema
|
|
266
|
-
});
|
|
267
|
-
},
|
|
268
|
-
async deleteExpertBinding(notebookId, bindingId, options) {
|
|
269
|
-
return call(context, {
|
|
270
|
-
callOptions: options,
|
|
271
|
-
capability: "botGateway",
|
|
272
|
-
method: "DELETE",
|
|
273
|
-
idempotent: false,
|
|
274
|
-
operation: "botGateway.expertBindings.delete",
|
|
275
|
-
path: path(notebookId, "expert-bindings", requiredString(bindingId, "bindingId")),
|
|
276
|
-
schema: botDeleteSchema
|
|
277
|
-
});
|
|
278
|
-
},
|
|
279
|
-
async listGroupBindings(notebookId, input, options) {
|
|
280
|
-
return call(context, {
|
|
281
|
-
callOptions: options,
|
|
282
|
-
capability: "botGateway",
|
|
283
|
-
method: "GET",
|
|
284
|
-
idempotent: true,
|
|
285
|
-
operation: "botGateway.groupBindings.list",
|
|
286
|
-
path: listPath(notebookId, "group-bindings", input),
|
|
287
|
-
schema: groupBindingListSchema
|
|
288
|
-
});
|
|
289
|
-
},
|
|
290
|
-
async createGroupBinding(notebookId, input, options) {
|
|
291
|
-
const body = {
|
|
292
|
-
...groupFields(input),
|
|
293
|
-
platform_app_id: requiredString(input?.platformAppId, "platformAppId"),
|
|
294
|
-
conversation_id: requiredString(input?.conversationId, "conversationId")
|
|
295
|
-
};
|
|
296
|
-
return call(context, {
|
|
297
|
-
body,
|
|
298
|
-
callOptions: options,
|
|
299
|
-
capability: "botGateway",
|
|
300
|
-
method: "POST",
|
|
301
|
-
idempotent: false,
|
|
302
|
-
operation: "botGateway.groupBindings.create",
|
|
303
|
-
path: path(notebookId, "group-bindings"),
|
|
304
|
-
schema: groupBindingSchema
|
|
305
|
-
});
|
|
306
|
-
},
|
|
307
|
-
async updateGroupBinding(notebookId, bindingId, input, options) {
|
|
308
|
-
const body = patch(compactUndefined({
|
|
309
|
-
...groupFields(input),
|
|
310
|
-
notebook_id: optionalString(input?.notebookId, "notebookId")
|
|
311
|
-
}));
|
|
312
|
-
return call(context, {
|
|
313
|
-
body,
|
|
314
|
-
callOptions: options,
|
|
315
|
-
capability: "botGateway",
|
|
316
|
-
method: "PATCH",
|
|
317
|
-
idempotent: false,
|
|
318
|
-
operation: "botGateway.groupBindings.update",
|
|
319
|
-
path: path(notebookId, "group-bindings", requiredString(bindingId, "bindingId")),
|
|
320
|
-
schema: groupBindingSchema
|
|
321
|
-
});
|
|
322
|
-
},
|
|
323
|
-
async deleteGroupBinding(notebookId, bindingId, options) {
|
|
324
|
-
return call(context, {
|
|
325
|
-
callOptions: options,
|
|
326
|
-
capability: "botGateway",
|
|
327
|
-
method: "DELETE",
|
|
328
|
-
idempotent: false,
|
|
329
|
-
operation: "botGateway.groupBindings.delete",
|
|
330
|
-
path: path(notebookId, "group-bindings", requiredString(bindingId, "bindingId")),
|
|
331
|
-
schema: botDeleteSchema
|
|
332
|
-
});
|
|
333
|
-
},
|
|
334
|
-
async publishDingTalk(notebookId, input, options) {
|
|
335
|
-
const body = compactUndefined({
|
|
336
|
-
platform_app_id: requiredString(input?.platformAppId, "platformAppId"),
|
|
337
|
-
context_window: optionalInt32(input?.contextWindow, "contextWindow"),
|
|
338
|
-
instructions: optionalInstructions(input?.instructions)
|
|
339
|
-
});
|
|
340
|
-
return call(context, {
|
|
341
|
-
body,
|
|
342
|
-
callOptions: options,
|
|
343
|
-
capability: "botGateway",
|
|
344
|
-
method: "POST",
|
|
345
|
-
idempotent: false,
|
|
346
|
-
operation: "botGateway.dingTalk.publish",
|
|
347
|
-
path: path(notebookId, "dingtalk", "publish"),
|
|
348
|
-
schema: publishDingTalkSchema
|
|
349
|
-
});
|
|
350
|
-
},
|
|
351
|
-
async inviteDingTalkExpert(notebookId, input, options) {
|
|
352
|
-
const userId = optionalTrimmedString(input?.userId, "userId");
|
|
353
|
-
const email = optionalTrimmedString(input?.email, "email");
|
|
354
|
-
if (userId === void 0 && email === void 0) throw invalidArgument("provide userId or email", "input");
|
|
355
|
-
const body = compactUndefined({
|
|
356
|
-
platform_app_id: requiredString(input?.platformAppId, "platformAppId"),
|
|
357
|
-
user_id: userId,
|
|
358
|
-
email
|
|
359
|
-
});
|
|
360
|
-
return call(context, {
|
|
361
|
-
body,
|
|
362
|
-
callOptions: options,
|
|
363
|
-
capability: "botGateway",
|
|
364
|
-
method: "POST",
|
|
365
|
-
idempotent: false,
|
|
366
|
-
operation: "botGateway.dingTalk.inviteExpert",
|
|
367
|
-
path: path(notebookId, "dingtalk", "experts", "invite"),
|
|
368
|
-
schema: inviteDingTalkSchema
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
};
|
|
372
|
-
}
|
|
373
|
-
//#endregion
|
|
374
|
-
export { createBotGatewayOperations };
|