@lovrabet/lovrabet-cli 2.3.1-beta.2 → 2.3.1-beta.3

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.
Files changed (185) hide show
  1. package/README.md +53 -1
  2. package/lib/cli.js +1 -1
  3. package/lib/commands/api-doc/index.js +1 -1
  4. package/lib/commands/app/cache.js +1 -1
  5. package/lib/commands/app/definitions.js +1 -1
  6. package/lib/commands/app/eligibility.js +1 -1
  7. package/lib/commands/app/mock-loader.js +1 -1
  8. package/lib/commands/app/remote-source.js +1 -1
  9. package/lib/commands/app/shared.js +1 -1
  10. package/lib/commands/app-config/get.js +1 -1
  11. package/lib/commands/app-config/index.js +1 -1
  12. package/lib/commands/artifact/index.js +1 -1
  13. package/lib/commands/auth/device.js +1 -1
  14. package/lib/commands/auth/index.js +1 -1
  15. package/lib/commands/auth/prompt.js +1 -1
  16. package/lib/commands/bff/detail.js +1 -1
  17. package/lib/commands/bff/exec.js +1 -1
  18. package/lib/commands/bff/index.js +1 -1
  19. package/lib/commands/cli-skill/index.js +1 -1
  20. package/lib/commands/common/config-policy.js +1 -1
  21. package/lib/commands/common/constraints.js +1 -1
  22. package/lib/commands/common/flags.d.ts +2 -0
  23. package/lib/commands/common/flags.js +1 -1
  24. package/lib/commands/common/local-file.js +1 -1
  25. package/lib/commands/config/definitions.js +1 -1
  26. package/lib/commands/config/init.d.ts +2 -0
  27. package/lib/commands/config/init.js +1 -1
  28. package/lib/commands/config/shared.js +1 -1
  29. package/lib/commands/data/index.js +1 -1
  30. package/lib/commands/dataset/detail.js +1 -1
  31. package/lib/commands/dataset/index.js +1 -1
  32. package/lib/commands/dataset/list.js +1 -1
  33. package/lib/commands/dataset/sdk-doc.js +1 -1
  34. package/lib/commands/doctor.js +1 -1
  35. package/lib/commands/file/index.js +1 -1
  36. package/lib/commands/init.js +1 -1
  37. package/lib/commands/kb/index.js +1 -1
  38. package/lib/commands/logs/index.js +1 -1
  39. package/lib/commands/notification/config-list.js +1 -1
  40. package/lib/commands/notification/index.js +1 -1
  41. package/lib/commands/notification/shared.js +1 -1
  42. package/lib/commands/ocr/index.js +1 -1
  43. package/lib/commands/permit/dataset-get.js +1 -1
  44. package/lib/commands/permit/dataset-set.js +1 -1
  45. package/lib/commands/permit/index.js +1 -1
  46. package/lib/commands/permit/page-get.js +1 -1
  47. package/lib/commands/permit/page-set.js +1 -1
  48. package/lib/commands/permit/role-menus-set.js +1 -1
  49. package/lib/commands/permit/role-menus.js +1 -1
  50. package/lib/commands/permit/shared.js +1 -1
  51. package/lib/commands/personal-bff/index.js +1 -1
  52. package/lib/commands/registry.js +1 -1
  53. package/lib/commands/role/create.js +1 -1
  54. package/lib/commands/role/delete.js +1 -1
  55. package/lib/commands/role/detail.js +1 -1
  56. package/lib/commands/role/index.js +1 -1
  57. package/lib/commands/role/list.js +1 -1
  58. package/lib/commands/role/shared.js +1 -1
  59. package/lib/commands/role/update.js +1 -1
  60. package/lib/commands/role/user-add.js +1 -1
  61. package/lib/commands/role/user-remove.js +1 -1
  62. package/lib/commands/schedule/index.js +1 -1
  63. package/lib/commands/schema.js +1 -1
  64. package/lib/commands/service/dynamic.js +1 -1
  65. package/lib/commands/service/function-name-adapter.js +1 -1
  66. package/lib/commands/service/index.js +1 -1
  67. package/lib/commands/service/registry.js +1 -1
  68. package/lib/commands/skill/commands/create.js +1 -1
  69. package/lib/commands/skill/commands/diagram.js +1 -1
  70. package/lib/commands/skill/commands/install.js +1 -1
  71. package/lib/commands/skill/commands/list.js +1 -1
  72. package/lib/commands/skill/commands/push.js +1 -1
  73. package/lib/commands/skill/commands/validate.js +1 -1
  74. package/lib/commands/skill/diagram.js +1 -1
  75. package/lib/commands/skill/flags.js +1 -1
  76. package/lib/commands/skill/index.js +1 -1
  77. package/lib/commands/skill/manifest-helpers.js +1 -1
  78. package/lib/commands/skill/push-execute.js +1 -1
  79. package/lib/commands/skill/push-flow-helpers.js +1 -1
  80. package/lib/commands/skill/push-retarget.js +1 -1
  81. package/lib/commands/skill/scopes.js +1 -1
  82. package/lib/commands/skill/summary.js +1 -1
  83. package/lib/commands/skill/templates.js +1 -1
  84. package/lib/commands/skill/validate.js +1 -1
  85. package/lib/commands/sql/detail.js +1 -1
  86. package/lib/commands/sql/exec.js +1 -1
  87. package/lib/commands/sql/index.js +1 -1
  88. package/lib/commands/update.js +1 -1
  89. package/lib/commands/user-account/bind.js +1 -1
  90. package/lib/commands/user-account/index.js +1 -1
  91. package/lib/commands/workspace/index.js +1 -1
  92. package/lib/config/domain-config.d.ts +33 -1
  93. package/lib/config/domain-config.js +1 -1
  94. package/lib/config/schema.d.ts +1 -1
  95. package/lib/config/schema.js +1 -1
  96. package/lib/constant/app.js +1 -1
  97. package/lib/constant/auth-mode.js +1 -1
  98. package/lib/constant/cli.js +1 -1
  99. package/lib/constant/defaults.js +1 -1
  100. package/lib/constant/distribution.js +1 -1
  101. package/lib/constant/domain.d.ts +3 -3
  102. package/lib/constant/domain.js +1 -1
  103. package/lib/constant/env.js +1 -1
  104. package/lib/constant/output.js +1 -1
  105. package/lib/constant/product.d.ts +0 -51
  106. package/lib/constant/product.js +1 -1
  107. package/lib/constant/region.d.ts +3 -5
  108. package/lib/constant/region.js +1 -1
  109. package/lib/constant/risk.js +1 -1
  110. package/lib/constant/url.js +1 -1
  111. package/lib/context.js +1 -1
  112. package/lib/core/api-client.d.ts +16 -0
  113. package/lib/core/api-client.js +1 -1
  114. package/lib/core/db-resolver.js +1 -1
  115. package/lib/core/sdk-client.js +1 -1
  116. package/lib/errors.js +1 -1
  117. package/lib/framework/build-all-flags.js +1 -1
  118. package/lib/framework/dryrun.js +1 -1
  119. package/lib/framework/flags.js +1 -1
  120. package/lib/framework/help.js +1 -1
  121. package/lib/framework/index.js +1 -1
  122. package/lib/framework/output.js +1 -1
  123. package/lib/framework/preparse.js +1 -1
  124. package/lib/framework/rate-limit.js +1 -1
  125. package/lib/framework/raw-flags.js +1 -1
  126. package/lib/framework/response.js +1 -1
  127. package/lib/framework/runner-confirmation.js +1 -1
  128. package/lib/framework/runner-error.js +1 -1
  129. package/lib/framework/runner.js +1 -1
  130. package/lib/framework/schema-export.js +1 -1
  131. package/lib/framework/service-order.js +1 -1
  132. package/lib/framework/types.d.ts +0 -2
  133. package/lib/framework/types.js +1 -1
  134. package/lib/generated/build-info.d.ts +4 -4
  135. package/lib/generated/build-info.js +1 -1
  136. package/lib/generated/official-routing.d.ts +59 -0
  137. package/lib/generated/official-routing.js +1 -0
  138. package/lib/generated/routing-contract.d.ts +9 -0
  139. package/lib/generated/routing-contract.js +1 -0
  140. package/lib/help.js +1 -1
  141. package/lib/postinstall.js +1 -1
  142. package/lib/runtime/confirmation.js +1 -1
  143. package/lib/runtime/event.js +1 -1
  144. package/lib/runtime/index.js +1 -1
  145. package/lib/runtime/queue.js +1 -1
  146. package/lib/runtime/resolve.js +1 -1
  147. package/lib/skills/builtin-skill.js +1 -1
  148. package/lib/skills/npx-skills-add.js +1 -1
  149. package/lib/skills/runtime-skill-sync/constants.js +1 -1
  150. package/lib/skills/runtime-skill-sync/fs-utils.js +1 -1
  151. package/lib/skills/runtime-skill-sync/hashing.js +1 -1
  152. package/lib/skills/runtime-skill-sync/install-target.js +1 -1
  153. package/lib/skills/runtime-skill-sync/links.js +1 -1
  154. package/lib/skills/runtime-skill-sync/list-local.js +1 -1
  155. package/lib/skills/runtime-skill-sync/local-files.js +1 -1
  156. package/lib/skills/runtime-skill-sync/materialize.js +1 -1
  157. package/lib/skills/runtime-skill-sync/metadata.js +1 -1
  158. package/lib/skills/runtime-skill-sync/paths.js +1 -1
  159. package/lib/skills/runtime-skill-sync/push.js +1 -1
  160. package/lib/skills/runtime-skill-sync/scopes.js +1 -1
  161. package/lib/skills/runtime-skill-sync/zip-codec.js +1 -1
  162. package/lib/skills/runtime-skill-sync/zip-package.js +1 -1
  163. package/lib/skills/runtime-skill-sync.js +1 -1
  164. package/lib/skills/skill-presence.js +1 -1
  165. package/lib/utils/access-key-redaction.js +1 -1
  166. package/lib/utils/apply-jq-filter.js +1 -1
  167. package/lib/utils/cli-version-check.js +1 -1
  168. package/lib/utils/cli-version-policy.js +1 -1
  169. package/lib/utils/logger.js +1 -1
  170. package/lib/utils/lossless-json.js +1 -1
  171. package/lib/utils/params.js +1 -1
  172. package/lib/utils/platform.js +1 -1
  173. package/lib/utils/update-notice.js +1 -1
  174. package/lib/utils/version.js +1 -1
  175. package/lib/utils/write-cli-side-channel.js +1 -1
  176. package/package.json +2 -1
  177. package/skills/lovrabet/SKILL.md +4 -4
  178. package/skills/lovrabet/guides/troubleshooting.md +3 -5
  179. package/skills/lovrabet/references/lovrabet-config-commands.md +33 -10
  180. package/skills/lovrabet/references/lovrabet-config.md +8 -20
  181. package/skills/lovrabet/references/lovrabet-doctor.md +0 -2
  182. package/skills/lovrabet/references/lovrabet-kb-workflow.md +1 -3
  183. package/skills/lovrabet.manifest.json +3 -3
  184. package/lib/core/kb-search-client.d.ts +0 -30
  185. package/lib/core/kb-search-client.js +0 -1
@@ -3,9 +3,9 @@
3
3
  `.lovrabet.json` 现在只承载**用户意图配置**,不再承载平台应用目录。
4
4
 
5
5
  这意味着:
6
- - `accessKey` / `env` / `format` / `riskLevel` / `defaultApp` 等仍然放在 `.lovrabet.json`
6
+ - `accessKey` / `format` / `riskLevel` / `defaultApp` 等仍然放在 `.lovrabet.json`
7
7
  - 当前 AK 在平台上可见的应用列表,放在 `~/.lovrabet/cache/.../my-apps.json`
8
- - 首次使用推荐执行 `lovrabet config init` 配置全局节点;未执行时仍按默认中国节点 `cn` 工作
8
+ - 首次使用推荐执行 `lovrabet config init` 配置全局节点。未执行时仍按默认中国大陆节点 `cn` 工作
9
9
 
10
10
  只自动读取 `.lovrabet.json`;`.lovrabetrc` 和其他 CLI 的配置文件不参与运行态配置发现。需要导入外部配置时,显式执行 `lovrabet app import --file <path>`。
11
11
 
@@ -14,7 +14,6 @@
14
14
  ```json
15
15
  {
16
16
  "appcode": "app-xxxxxxxx",
17
- "env": "daily",
18
17
  "accessKey": "<ACCESS_KEY>"
19
18
  }
20
19
  ```
@@ -24,7 +23,6 @@
24
23
  ```json
25
24
  {
26
25
  "accessKey": "<ACCESS_KEY>",
27
- "env": "daily",
28
26
  "defaultApp": "crm"
29
27
  }
30
28
  ```
@@ -36,7 +34,7 @@
36
34
  平台应用列表缓存路径:
37
35
 
38
36
  ```text
39
- ~/.lovrabet/cache/<env>/<ak-fingerprint>/my-apps.json
37
+ ~/.lovrabet/cache/.../my-apps.json
40
38
  ```
41
39
 
42
40
  这个 cache 由以下命令维护:
@@ -49,7 +47,6 @@
49
47
  | 字段 | 类型 | 默认值 | 说明 |
50
48
  |------|------|--------|------|
51
49
  | `appcode` | string | — | 兼容单应用模式,直接指定 appcode |
52
- | `env` | string | `production` | 环境:`production` / `development` / `daily` |
53
50
  | `accessKey` | string | — | User Access Key(client-ak) |
54
51
  | `format` | string | — | 默认输出格式:`json` / `pretty` / `compress` |
55
52
  | `pageSize` | number | — | 默认分页大小 |
@@ -60,25 +57,18 @@
60
57
  | `apiDomain` | string | 节点内置值 | 平台 API HTTPS origin 覆盖 |
61
58
  | `runtimeDomain` | string | 节点内置值 | 普通 Runtime HTTPS origin 覆盖 |
62
59
  | `skillDomain` | string | 节点默认 | SkillHub HTTPS origin 覆盖 |
63
- | `kbDomain` | string | 节点默认 | Personal KB 管理与 `kb search` Runtime 网关 HTTPS origin 覆盖 |
60
+ | `kbDomain` | string | 节点默认 | 知识库 HTTPS origin 覆盖 |
64
61
 
65
- 五个 Domain 各自独立覆盖同名服务地址。没有显式配置的字段按 `region` 和 `env` 使用内置值;`development` 与 `daily` 共用非生产地址。KB Service 下游地址由 Runtime Java 配置管理。当前开放的官方节点如下:
66
-
67
- | region | env | userDomain | apiDomain | runtimeDomain | skillDomain | kbDomain |
68
- |--------|-----|------------|-----------|---------------|-------------|----------|
69
- | `cn` | `production` | `https://user.lovrabet.com` | `https://api.lovrabet.com` | `https://runtime.lovrabet.com` | `https://skills.lovrabet.com` | `https://runtime.lovrabet.com` |
70
- | `cn` | `development` / `daily` | `https://user-daily.lovrabet.com` | `https://daily-api.lovrabet.com` | `https://daily-runtime.lovrabet.com` | `https://skills-daily.lovrabet.com` | `https://daily-runtime.lovrabet.com` |
71
- | `id` | `production` | `https://user.lovrabet.id` | `https://api.lovrabet.id` | `https://runtime.lovrabet.id` | `https://skills.lovrabet.id` | `https://runtime.lovrabet.id` |
72
- | `id` | `development` / `daily` | `https://user-daily.lovrabet.id` | `https://daily-api.lovrabet.id` | `https://daily-runtime.lovrabet.id` | `https://skills-daily.lovrabet.id` | `https://daily-runtime.lovrabet.id` |
62
+ 五个 Domain 各自独立覆盖同名服务地址。没有显式配置时,CLI 按 `region` 使用内置节点:`cn` 对应中国大陆,`id` 对应 Indonesia,且 Indonesia 的最终服务地址统一使用 `*.lovrabet.id`。执行 `lovrabet doctor` 可查看当前实际生效的五个 Domain,无需理解内部地址层级。
73
63
 
74
64
  `config init` 的完整模式切换、独立部署 JSON 和校验规则见 [配置管理](lovrabet-config-commands.md#config-init--初始化连接配置)。
75
65
 
76
66
  ## 解析优先级
77
67
 
78
68
  ```
79
- CLI flag (--appcode, --env, --format, --app ...)
69
+ CLI flag (--appcode, --format, --app ...)
80
70
  ↓
81
- 环境变量 (LOVRABET_APPCODE, LOVRABET_ENV ...)
71
+ 环境变量 (LOVRABET_APPCODE, LOVRABET_FORMAT ...)
82
72
  ↓
83
73
  当前目录 .lovrabet.json(兼容本地配置)
84
74
  ↓
@@ -101,7 +91,6 @@ CLI flag (--appcode, --env, --format, --app ...)
101
91
  | 环境变量 | 对应字段 |
102
92
  |----------|----------|
103
93
  | `LOVRABET_APPCODE` | `appcode` |
104
- | `LOVRABET_ENV` | `env` |
105
94
  | `LOVRABET_ACCESS_KEY` | `accessKey` |
106
95
  | `LOVRABET_FORMAT` | `format` |
107
96
  | `LOVRABET_PAGE_SIZE` | `pageSize` |
@@ -121,7 +110,7 @@ CLI flag (--appcode, --env, --format, --app ...)
121
110
  - `apps`:当前目录显式声明时整体覆盖全局 `apps`;当前目录未声明时使用全局 `apps`
122
111
  - `inherit` 不是受支持的配置项;旧字段会被忽略,可用 `lovrabet config delete inherit` 清理
123
112
 
124
- 因此,`lovrabet config init` 虽然固定更新全局连接配置,当前目录文件中的 `region` 或 Domain 仍具有更高优先级。初始化后可执行 `lovrabet doctor` 查看最终生效值。
113
+ 因此,`lovrabet config init` 固定更新全局连接配置;当前目录文件中的兼容路由字段仍可能覆盖全局同名字段。初始化后可执行 `lovrabet doctor` 查看最终生效值。
125
114
 
126
115
  ## 示例
127
116
 
@@ -130,7 +119,6 @@ CLI flag (--appcode, --env, --format, --app ...)
130
119
  ```json
131
120
  {
132
121
  "accessKey": "<ACCESS_KEY>",
133
- "env": "daily",
134
122
  "defaultApp": "crm"
135
123
  }
136
124
  ```
@@ -24,5 +24,3 @@ lovrabet doctor
24
24
  ```
25
25
 
26
26
  `doctor` 不修改配置、不安装 Skill,也不替代业务命令的认证和权限检查。
27
-
28
- `API Endpoints` 显示 `kbDomain`,该地址同时承载 Personal KB 管理与 `kb search` Runtime 网关。KB Service 下游地址由 Runtime Java 配置管理,不在 CLI doctor 中显示。
@@ -10,9 +10,7 @@ lovrabet kb detail --id <id> --format compress
10
10
  lovrabet kb search --query "订单审批" --topk 5 --format compress
11
11
  ```
12
12
 
13
- `kb search` 只携带当前 AK,通过 `kbDomain` 调用固定 Runtime 搜索网关;Runtime 再按其 Java 环境配置访问 KB Service。返回范围是 `public/company/personal`,使用 `scope` 区分来源。
14
-
15
- 结构化输出固定为 `data: { schemaVersion:2, profile:"runtime", total, strategyFingerprint, timingsMs, hits }`。`--topk` 可选且必须是 1–50 的整数;命中完整保留 `documentId/revision/chunkId/scope/title/text/tags/rank/rawScore/finalScore/scoreKind` 的服务端顺序和值,不输出 legacy 别名。无命中是 `total:0/hits:[]` 的成功;字段、rank、score、timing、`no-store` 或 scope 漂移都会以脱敏错误失败。
13
+ `kb search` 会返回当前用户可见的多来源知识,使用 `scope` 区分来源。结果顺序由服务端当前检索策略决定;CLI 保留服务端返回顺序,不在本地重新排序,也不根据 `scope` 推断固定来源优先级。
16
14
 
17
15
  ## 业务执行中的 KB 消费
18
16
 
@@ -2,8 +2,8 @@
2
2
  "schemaVersion": 1,
3
3
  "name": "lovrabet",
4
4
  "packageName": "@lovrabet/lovrabet-cli",
5
- "packageVersion": "2.3.1-beta.2",
6
- "skillVersion": "2.3.1-beta.2",
5
+ "packageVersion": "2.3.1-beta.3",
6
+ "skillVersion": "2.3.1-beta.3",
7
7
  "files": [
8
8
  "SKILL.md",
9
9
  "guides/app-resolution.md",
@@ -37,5 +37,5 @@
37
37
  "references/lovrabet-user-account.md",
38
38
  "references/lovrabet-workspace.md"
39
39
  ],
40
- "digest": "3a473f03db5d7d55bc3007abf7659e5d9dbe90a6b65f729d751c68c79510c059"
40
+ "digest": "a731aa4a6155920b8d585bd588c640933ef8d32de8567d7c88a9ceb3e6221be5"
41
41
  }
@@ -1,30 +0,0 @@
1
- export type KnowledgeSearchScope = "public" | "company" | "personal";
2
- export interface KnowledgeSearchHit {
3
- documentId: string;
4
- revision: number;
5
- chunkId: string;
6
- scope: KnowledgeSearchScope;
7
- title: string;
8
- text: string;
9
- tags: string[];
10
- rank: number;
11
- rawScore: number;
12
- finalScore: number;
13
- scoreKind: string;
14
- }
15
- export interface RuntimeKnowledgeSearchResult {
16
- schemaVersion: 2;
17
- profile: "runtime";
18
- total: number;
19
- strategyFingerprint: string;
20
- timingsMs: Record<string, number>;
21
- hits: KnowledgeSearchHit[];
22
- }
23
- export interface RuntimeKnowledgeSearchInput {
24
- appCode: string;
25
- accessKey: string;
26
- query: string;
27
- topK?: number;
28
- signal?: AbortSignal;
29
- }
30
- export declare function searchRuntimeKnowledge(input: RuntimeKnowledgeSearchInput): Promise<RuntimeKnowledgeSearchResult>;
@@ -1 +0,0 @@
1
- const a105_0x10dd76=a105_0x3237;function a105_0x3b79(){const _0x1ddf41=['Runtime\x20knowledge\x20search\x20response\x20is\x20missing\x20Cache-Control:\x20no-store.','public','Knowledge\x20search\x20appCode\x20is\x20required.','1391430YGHYfv','POST','status','total','content-type','cache-control','response','get','validation','text','finalScore','score','rank','object','scoreKind','toLowerCase','test','cli:lovrabet','success','isSafeInteger','isFinite','Runtime\x20knowledge\x20search\x20returned\x20invalid\x20JSON.','personal','sort','Runtime\x20knowledge\x20search\x20returned\x20an\x20invalid\x20','entries','56tWgSvd','revision','profile','timingsMs','schemaVersion','\x20contract.','hits','isArray','Runtime\x20knowledge\x20search\x20returned\x20a\x20non-JSON\x20content\x20type.','trim','number','132DNQnTn','some','scope','length','response\x20envelope','Knowledge\x20search\x20query\x20is\x20required.','string','title','map','data','apiError','Runtime\x20knowledge\x20search\x20failed.','2149844xsuuOA','chunkId','company','stringify','Runtime\x20knowledge\x20search\x20request\x20failed.','networkError','appCode','Knowledge\x20search\x20topK\x20must\x20be\x20an\x20integer\x20from\x201\x20through\x2050.','query','documentId','2917320LYYIiZ','36JmjdVj','4851vprvsV','5123995zpaKuK','topK','no-store','name','json','tags','rawScore','authRequired','accessKey','648968lhYGib','293650EsKBXY','split','headers','application/json','strategyFingerprint'];a105_0x3b79=function(){return _0x1ddf41;};return a105_0x3b79();}(function(_0x10f837,_0x2e4ab8){const _0x279328=a105_0x3237,_0x408308=_0x10f837();while(!![]){try{const _0x50a1c3=-parseInt(_0x279328(0xdf))/0x1+parseInt(_0x279328(0xb2))/0x2*(-parseInt(_0x279328(0xd5))/0x3)+-parseInt(_0x279328(0xc9))/0x4+parseInt(_0x279328(0xd6))/0x5+-parseInt(_0x279328(0xbd))/0x6*(-parseInt(_0x279328(0xe0))/0x7)+parseInt(_0x279328(0xd3))/0x8+parseInt(_0x279328(0xd4))/0x9*(-parseInt(_0x279328(0xe8))/0xa);if(_0x50a1c3===_0x2e4ab8)break;else _0x408308['push'](_0x408308['shift']());}catch(_0x5b1ab4){_0x408308['push'](_0x408308['shift']());}}}(a105_0x3b79,0x7ff37));import{getKbDomain}from'../constant/domain.js';import{CliError,CliErrors}from'../errors.js';const RESPONSE_KEYS=[a105_0x10dd76(0xb6),a105_0x10dd76(0xb4),'total',a105_0x10dd76(0xb8),a105_0x10dd76(0xe4),a105_0x10dd76(0xb5)],HIT_KEYS=['documentId','revision',a105_0x10dd76(0xca),'scope',a105_0x10dd76(0xc4),a105_0x10dd76(0xa1),'tags',a105_0x10dd76(0xa4),'rawScore','finalScore',a105_0x10dd76(0xa6)];export async function searchRuntimeKnowledge(_0x80b993){const _0x40abe2=a105_0x10dd76,_0x1fb72e=_0x80b993[_0x40abe2(0xcf)][_0x40abe2(0xbb)](),_0x598d4f=_0x80b993[_0x40abe2(0xd1)]['trim']();if(!_0x1fb72e)throw CliErrors[_0x40abe2(0xa0)](_0x40abe2(0xe7));if(!_0x80b993[_0x40abe2(0xde)][_0x40abe2(0xbb)]())throw CliErrors[_0x40abe2(0xdd)]();if(!_0x598d4f)throw CliErrors['validation'](_0x40abe2(0xc2));validateTopK(_0x80b993[_0x40abe2(0xd7)]);const _0x24596a=getKbDomain()+'/client/knowledge-base/search';let _0x55d4ef;try{_0x55d4ef=await fetch(_0x24596a,{'method':_0x40abe2(0xe9),'headers':{'Content-Type':_0x40abe2(0xe3),'X-User-AK':_0x80b993[_0x40abe2(0xde)],'X-Invoke-Source':_0x40abe2(0xa9)},'body':JSON[_0x40abe2(0xcc)]({'appCode':_0x1fb72e,'query':_0x598d4f,..._0x80b993[_0x40abe2(0xd7)]!==undefined?{'topK':_0x80b993[_0x40abe2(0xd7)]}:{}}),'signal':_0x80b993['signal']});}catch(_0x168ab9){if(_0x168ab9 instanceof CliError)throw _0x168ab9;if(_0x168ab9 instanceof Error&&_0x168ab9[_0x40abe2(0xd9)]==='AbortError')throw _0x168ab9;throw CliErrors[_0x40abe2(0xce)](_0x40abe2(0xcd));}if(!hasNoStore(_0x55d4ef[_0x40abe2(0xe2)]))throw CliErrors[_0x40abe2(0xc7)](_0x40abe2(0xe5));if(_0x55d4ef[_0x40abe2(0xea)]===0x191)throw CliErrors[_0x40abe2(0xdd)]();if(!_0x55d4ef['ok'])throw CliErrors['apiError']('Runtime\x20knowledge\x20search\x20failed\x20(HTTP\x20'+_0x55d4ef[_0x40abe2(0xea)]+').');if(!(_0x55d4ef[_0x40abe2(0xe2)][_0x40abe2(0x9f)](_0x40abe2(0xec))??'')['toLowerCase']()['includes'](_0x40abe2(0xe3)))throw CliErrors[_0x40abe2(0xc7)](_0x40abe2(0xba));let _0xfc8909;try{_0xfc8909=await _0x55d4ef[_0x40abe2(0xda)]();}catch{throw CliErrors[_0x40abe2(0xc7)](_0x40abe2(0xad));}return parseRuntimeSearchResponse(readEnvelopeData(_0xfc8909),_0x80b993[_0x40abe2(0xd7)]);}function readEnvelopeData(_0x27fa19){const _0x5a27a0=a105_0x10dd76,_0x3f3de6=requireRecord(_0x27fa19,_0x5a27a0(0xc1));if(_0x3f3de6[_0x5a27a0(0xaa)]===![])throw CliErrors[_0x5a27a0(0xc7)](_0x5a27a0(0xc8));if(!('data'in _0x3f3de6))throw invalidContract(_0x5a27a0(0xc1));return _0x3f3de6[_0x5a27a0(0xc6)];}function validateTopK(_0x1fcb1d){const _0x15d7bd=a105_0x10dd76;if(_0x1fcb1d!==undefined&&(!Number[_0x15d7bd(0xab)](_0x1fcb1d)||_0x1fcb1d<0x1||_0x1fcb1d>0x32))throw CliErrors[_0x15d7bd(0xa0)](_0x15d7bd(0xd0));}function hasNoStore(_0x26187f){const _0x394ff8=a105_0x10dd76;return(_0x26187f[_0x394ff8(0x9f)](_0x394ff8(0xed))??'')[_0x394ff8(0xe1)](',')[_0x394ff8(0xbe)](_0x181021=>_0x181021[_0x394ff8(0xbb)]()[_0x394ff8(0xa7)]()===_0x394ff8(0xd8));}function parseRuntimeSearchResponse(_0x23100e,_0x3a3eef){const _0x414e4b=a105_0x10dd76,_0x350f7c=requireExactRecord(_0x23100e,RESPONSE_KEYS,_0x414e4b(0x9e));if(_0x350f7c[_0x414e4b(0xb6)]!==0x2||_0x350f7c[_0x414e4b(0xb4)]!=='runtime')throw invalidContract('profile');if(!Array[_0x414e4b(0xb9)](_0x350f7c[_0x414e4b(0xb8)])||_0x350f7c[_0x414e4b(0xb8)][_0x414e4b(0xc0)]>(_0x3a3eef??0x32))throw invalidContract('hits');if(typeof _0x350f7c[_0x414e4b(0xe4)]!==_0x414e4b(0xc3)||!/^sha256:[0-9a-f]{64}$/['test'](_0x350f7c['strategyFingerprint']))throw invalidContract('strategyFingerprint');const _0x268625=requireRecord(_0x350f7c[_0x414e4b(0xb5)],_0x414e4b(0xb5)),_0x4921cf={};for(const [_0x5f4dbb,_0x36d7f0]of Object[_0x414e4b(0xb1)](_0x268625)){if(!/^[A-Za-z][A-Za-z0-9]*$/[_0x414e4b(0xa8)](_0x5f4dbb)||typeof _0x36d7f0!==_0x414e4b(0xbc)||!Number[_0x414e4b(0xac)](_0x36d7f0)||_0x36d7f0<0x0)throw invalidContract(_0x414e4b(0xb5));_0x4921cf[_0x5f4dbb]=_0x36d7f0;}const _0x408be8=_0x350f7c[_0x414e4b(0xb8)][_0x414e4b(0xc5)]((_0x42d2a6,_0x22c538)=>parseHit(_0x42d2a6,_0x22c538));if(!Number[_0x414e4b(0xab)](_0x350f7c['total'])||_0x350f7c['total']!==_0x408be8[_0x414e4b(0xc0)])throw invalidContract(_0x414e4b(0xeb));return{'schemaVersion':_0x350f7c[_0x414e4b(0xb6)],'profile':_0x350f7c[_0x414e4b(0xb4)],'total':_0x350f7c[_0x414e4b(0xeb)],'strategyFingerprint':_0x350f7c[_0x414e4b(0xe4)],'timingsMs':_0x4921cf,'hits':_0x408be8};}function parseHit(_0x16c255,_0x5a7414){const _0x2f2777=a105_0x10dd76,_0x2f69e7=requireExactRecord(_0x16c255,HIT_KEYS,'hits['+_0x5a7414+']'),_0xeb56ad=_0x73a4fd=>{const _0x56f026=a105_0x3237,_0x3ff785=_0x2f69e7[_0x73a4fd];if(typeof _0x3ff785!==_0x56f026(0xc3)||!_0x3ff785)throw invalidContract(_0x73a4fd);return _0x3ff785;};if(!Number[_0x2f2777(0xab)](_0x2f69e7['revision'])||_0x2f69e7[_0x2f2777(0xb3)]<0x1)throw invalidContract('revision');if(_0x2f69e7[_0x2f2777(0xbf)]!==_0x2f2777(0xe6)&&_0x2f69e7['scope']!==_0x2f2777(0xcb)&&_0x2f69e7[_0x2f2777(0xbf)]!==_0x2f2777(0xae))throw invalidContract(_0x2f2777(0xbf));if(typeof _0x2f69e7[_0x2f2777(0xc4)]!==_0x2f2777(0xc3)||typeof _0x2f69e7[_0x2f2777(0xa1)]!==_0x2f2777(0xc3))throw invalidContract('text');if(!Array[_0x2f2777(0xb9)](_0x2f69e7[_0x2f2777(0xdb)])||_0x2f69e7[_0x2f2777(0xdb)][_0x2f2777(0xbe)](_0x2eb17f=>typeof _0x2eb17f!=='string'))throw invalidContract(_0x2f2777(0xdb));if(!Number['isSafeInteger'](_0x2f69e7[_0x2f2777(0xa4)])||_0x2f69e7['rank']!==_0x5a7414+0x1)throw invalidContract(_0x2f2777(0xa4));if(!isFiniteNumber(_0x2f69e7[_0x2f2777(0xdc)])||!isFiniteNumber(_0x2f69e7[_0x2f2777(0xa2)]))throw invalidContract(_0x2f2777(0xa3));return{'documentId':_0xeb56ad(_0x2f2777(0xd2)),'revision':_0x2f69e7[_0x2f2777(0xb3)],'chunkId':_0xeb56ad('chunkId'),'scope':_0x2f69e7['scope'],'title':_0x2f69e7[_0x2f2777(0xc4)],'text':_0x2f69e7['text'],'tags':[..._0x2f69e7[_0x2f2777(0xdb)]],'rank':_0x2f69e7[_0x2f2777(0xa4)],'rawScore':_0x2f69e7[_0x2f2777(0xdc)],'finalScore':_0x2f69e7['finalScore'],'scoreKind':_0xeb56ad('scoreKind')};}function requireExactRecord(_0x1ae2d8,_0x5dc8be,_0x589535){const _0x93afce=a105_0x10dd76,_0xdd91bb=requireRecord(_0x1ae2d8,_0x589535),_0x508f88=Object['keys'](_0xdd91bb)[_0x93afce(0xaf)](),_0x1fb95f=[..._0x5dc8be][_0x93afce(0xaf)]();if(_0x508f88[_0x93afce(0xc0)]!==_0x1fb95f[_0x93afce(0xc0)]||_0x508f88[_0x93afce(0xbe)]((_0x34b79a,_0x2eff21)=>_0x34b79a!==_0x1fb95f[_0x2eff21]))throw invalidContract(_0x589535);return _0xdd91bb;}function a105_0x3237(_0x14e60c,_0x2e416a){_0x14e60c=_0x14e60c-0x9e;const _0x3b79e8=a105_0x3b79();let _0x32373c=_0x3b79e8[_0x14e60c];return _0x32373c;}function requireRecord(_0xe0f37d,_0x158dca){const _0x390d6a=a105_0x10dd76;if(!_0xe0f37d||typeof _0xe0f37d!==_0x390d6a(0xa5)||Array['isArray'](_0xe0f37d))throw invalidContract(_0x158dca);return _0xe0f37d;}function isFiniteNumber(_0x4f778a){const _0x549325=a105_0x10dd76;return typeof _0x4f778a===_0x549325(0xbc)&&Number[_0x549325(0xac)](_0x4f778a);}function invalidContract(_0x45e0a9){const _0x4703b3=a105_0x10dd76;return CliErrors[_0x4703b3(0xc7)](_0x4703b3(0xb0)+_0x45e0a9+_0x4703b3(0xb7));}