@hcmai/sdk 0.4.19 → 0.4.20

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/dist/index.d.ts CHANGED
@@ -183,6 +183,7 @@ declare function listModels(http: AxiosInstance): Promise<ModelEntry[]>;
183
183
  interface ModelQueryDsl {
184
184
  filter?: Record<string, unknown>;
185
185
  sort?: Array<Record<string, unknown>>;
186
+ additions?: Array<Record<string, unknown>>;
186
187
  fields?: string[];
187
188
  keyword?: string;
188
189
  limit?: number;
@@ -2199,14 +2200,15 @@ declare function createHttpClient(opts: HttpClientOptions): AxiosInstance;
2199
2200
  * 必须先装技能才能建租户。所以本模块只需要 endpoint,不碰 identity/token。
2200
2201
  *
2201
2202
  * 后端契约(ChironController):
2202
- * - `GET {base}/skills.json` 目录 manifest
2203
- * - `GET {base}/skills/{id}.md` 技能原文
2204
- * - `GET {base}/skills/{id}/references/{path}` 技能自带的参考文件
2205
- * - `GET {base}/skills/{id}/files?path=...` 完整 Skill 目录中的原始文件
2203
+ * - `GET {base}.json` 目录 manifest
2204
+ * - `GET {base}/{id}.md` 技能原文
2205
+ * - `GET {base}/{id}/references/{path}` 技能自带的参考文件
2206
+ * - `GET {base}/{id}/files?path=...` 完整 Skill 目录中的原始文件
2206
2207
  *
2207
- * 🔴 `{base}` 是 `'/api'` 或 `''`,由 {@link resolveChironBase} 探出来。真实部署只把
2208
- * `/api/**` 路由给后端,根路径归前端 SPA——`GET /skills.json` 在客户环境上拿回来的是
2209
- * 一段 HTML。而老版本后端只有根路径。两种都要能连上,所以先探再用,不写死。
2208
+ * 🔴 `{base}` 是实际探中的挂载根(优先 `'/api/chiron'`,旧后端可能是
2209
+ * `'/api/skills'` / `'/chiron'` / `'/skills'`)。真实部署只把 `/api/**` 路由给后端,
2210
+ * 根路径归前端 SPA;同时旧后端还没有 `/chiron*` 正名。两类环境都要能连上,
2211
+ * 所以先按优先级探测,再让所有后续请求跟随同一个挂载根。
2210
2212
  */
2211
2213
  interface ChironSkillFile {
2212
2214
  path: string;
@@ -2258,10 +2260,11 @@ interface ChironManifest {
2258
2260
  /**
2259
2261
  * 探出本环境技能库的前缀。
2260
2262
  *
2261
- * 为什么不能写死任何一个:
2263
+ * 为什么不能只写死正名:
2262
2264
  * - 真实部署(反代把 `/api/**` 给后端、其余给前端)下根路径返回的是前端 SPA 的 HTML,
2263
2265
  * HTTP 200 但根本不是 manifest —— 所以判据必须看**内容**,不能看状态码;
2264
- * - 还没升级到带 `/api` 别名那一版的后端,只有根路径可用。
2266
+ * - CLI 可能连接只提供 `/api/skills*` 兼容面的旧后端;
2267
+ * - 更老的本地直连环境只有根路径。
2265
2268
  *
2266
2269
  * 两条都探不到时抛出可执行的错误,而不是把一段 HTML 当目录解析出满屏乱码。
2267
2270
  */
package/dist/index.js CHANGED
@@ -954,6 +954,7 @@ async function query(http, model, dsl) {
954
954
  if (filter !== void 0) body.filter = filter;
955
955
  const orders = normalizeOrders(dsl.sort);
956
956
  if (orders !== void 0) body.orders = orders;
957
+ if (dsl.additions !== void 0) body.additions = dsl.additions;
957
958
  if (dsl.fields !== void 0) body.fields = dsl.fields;
958
959
  if (dsl.keyword !== void 0) body.keyword = dsl.keyword;
959
960
  const size = dsl.limit ?? 20;
@@ -9139,7 +9140,7 @@ function explainJacksonError(raw) {
9139
9140
 
9140
9141
  // src/skills.ts
9141
9142
  import yaml9, { JSON_SCHEMA as JSON_SCHEMA3 } from "js-yaml";
9142
- var CHIRON_BASE_CANDIDATES = ["/api", ""];
9143
+ var CHIRON_BASE_CANDIDATES = ["/api/chiron", "/api/skills", "/chiron", "/skills"];
9143
9144
  function looksLikeManifest(data) {
9144
9145
  if (!data || typeof data !== "object") return false;
9145
9146
  const m = data;
@@ -9148,7 +9149,7 @@ function looksLikeManifest(data) {
9148
9149
  async function resolveChironBase(http) {
9149
9150
  const tried = [];
9150
9151
  for (const base of CHIRON_BASE_CANDIDATES) {
9151
- const url = `${base}/skills.json`;
9152
+ const url = `${base}.json`;
9152
9153
  tried.push(url);
9153
9154
  try {
9154
9155
  const resp = await http.get(url);
@@ -9159,15 +9160,15 @@ async function resolveChironBase(http) {
9159
9160
  }
9160
9161
  throw new CliError({
9161
9162
  code: "INVALID_ARGUMENT" /* INVALID_ARGUMENT */,
9162
- message: `\u8FD9\u4E2A\u73AF\u5883\u4E0A\u627E\u4E0D\u5230\u777F\u620E\u6280\u80FD\u5E93\uFF08\u8BD5\u8FC7 ${tried.join(" \u548C ")}\uFF09\u3002\u5E38\u89C1\u539F\u56E0\uFF1A\u2460 \u540E\u7AEF\u7248\u672C\u8FD8\u6CA1\u6709 /api/skills \u7AEF\u70B9\uFF0C\u5347\u7EA7\u540E\u7AEF\u5373\u53EF\uFF1B\u2461 endpoint \u586B\u7684\u662F\u524D\u7AEF\u5730\u5740\u4E14\u672A\u53CD\u4EE3\u5230\u540E\u7AEF\uFF1B\u2462 \u5730\u5740\u6216\u7F51\u7EDC\u4E0D\u901A\u3002`
9163
+ message: `\u8FD9\u4E2A\u73AF\u5883\u4E0A\u627E\u4E0D\u5230\u777F\u620E\u6280\u80FD\u5E93\uFF08\u8BD5\u8FC7 ${tried.join(" \u548C ")}\uFF09\u3002\u5E38\u89C1\u539F\u56E0\uFF1A\u2460 \u540E\u7AEF\u7248\u672C\u8FD8\u6CA1\u6709 /api/chiron \u6216 /api/skills \u7AEF\u70B9\uFF0C\u5347\u7EA7\u540E\u7AEF\u5373\u53EF\uFF1B\u2461 endpoint \u586B\u7684\u662F\u524D\u7AEF\u5730\u5740\u4E14\u672A\u53CD\u4EE3\u5230\u540E\u7AEF\uFF1B\u2462 \u5730\u5740\u6216\u7F51\u7EDC\u4E0D\u901A\u3002`
9163
9164
  });
9164
9165
  }
9165
9166
  async function fetchSkillCatalog(http, base) {
9166
- const resp = await http.get(`${base}/skills.json`);
9167
+ const resp = await http.get(`${base}.json`);
9167
9168
  return resp.data?.data ?? resp.data;
9168
9169
  }
9169
9170
  async function fetchSkillMarkdown(http, id, base) {
9170
- const resp = await http.get(`${base}/skills/${encodeURIComponent(id)}.md`, {
9171
+ const resp = await http.get(`${base}/${encodeURIComponent(id)}.md`, {
9171
9172
  responseType: "text",
9172
9173
  transformResponse: [(d) => d]
9173
9174
  });
@@ -9176,7 +9177,7 @@ async function fetchSkillMarkdown(http, id, base) {
9176
9177
  async function fetchSkillFile(http, id, relativePath, base) {
9177
9178
  assertSafeSkillId(id);
9178
9179
  assertSafeSkillFilePath(relativePath);
9179
- const resp = await http.get(`${base}/skills/${encodeURIComponent(id)}/files`, {
9180
+ const resp = await http.get(`${base}/${encodeURIComponent(id)}/files`, {
9180
9181
  params: { path: relativePath },
9181
9182
  responseType: "arraybuffer",
9182
9183
  transformResponse: [(data) => data]
@@ -9186,7 +9187,7 @@ async function fetchSkillFile(http, id, relativePath, base) {
9186
9187
  async function fetchSkillReference(http, id, relativePath, base) {
9187
9188
  assertSafeReferencePath(relativePath);
9188
9189
  const encoded = relativePath.split("/").map(encodeURIComponent).join("/");
9189
- const resp = await http.get(`${base}/skills/${encodeURIComponent(id)}/references/${encoded}`, {
9190
+ const resp = await http.get(`${base}/${encodeURIComponent(id)}/references/${encoded}`, {
9190
9191
  responseType: "text",
9191
9192
  transformResponse: [(d) => d]
9192
9193
  });