@glasser-ai/cli 0.1.56 → 0.1.58

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/README.md CHANGED
@@ -16,7 +16,7 @@ Re-run either command to upgrade. Then: `glasser login`.
16
16
  ## Commands
17
17
 
18
18
  ```
19
- glasser search ["<query>"] [--limit N] [--cursor C] # no query lists the catalog
19
+ glasser search ["<query>"] --use-case "<ask>" [--limit N] [--cursor C] # no query lists the catalog; --use-case is always required
20
20
  # -q/--query takes the same value; --query=<q> for a leading dash
21
21
  glasser inspect -p <provider> -e <endpoint> [--endpoint-version N]
22
22
  glasser run -p <provider> -e <endpoint> [-i '<json>'|@file | -f <path>]
@@ -100,7 +100,7 @@ requires `--force` so a prompt can never corrupt machine output.
100
100
  ## Development
101
101
 
102
102
  ```bash
103
- pnpm --filter @glasser-ai/cli dev -- search -q "web search" # tsx, no build
103
+ pnpm --filter @glasser-ai/cli dev -- search -q "web search" --use-case "find a web search API" # tsx, no build
104
104
  pnpm --filter @glasser-ai/cli build # esbuild → dist/glasser.js
105
105
  node apps/cli/dist/glasser.js --help
106
106
  cd apps/cli && pnpm link --global # a PATH `glasser` shim
package/dist/glasser.js CHANGED
@@ -64565,22 +64565,24 @@ var SearchEndpointsRequest = Schema_exports.Struct({
64565
64565
  * 眼里就是无用收集。它**不**参与这一次的排序;用途见 ADR-0024 —— use case 与最后
64566
64566
  * 跑了哪支 Endpoint 配成一对,就是一条带标注的相关性样本。
64567
64567
  *
64568
- * 旧名 `user_request` 仍然收,见下面那个字段。
64568
+ * 旧名 `user_request` 仍然收但不再读,见下面那个字段。
64569
64569
  *
64570
- * 可选,而且必须可选:必填会让还没升级的调用方直接失败,也会逼一个不理解这个
64571
- * 字段的模型去编 —— 编出来的比 null 更糟,因为在数据里分不出来。
64570
+ * **必填,每一次 search 都要**,翻页、换词重搜、不带 query 的浏览都不例外
64571
+ * (2026-09-28 起,Keith:初期先必填)。此前它是可选的,理由是必填会让还没升级的
64572
+ * 调用方直接失败,也会逼一个不理解这个字段的模型去编。这两条代价现在都接受:
64573
+ * 眼下要的是每一件事都带着用户的诉求,而可选的时候大量 Task 是空的。
64574
+ *
64575
+ * 不能是空白串:`normalizeUseCase` 会把它归一成 null,等于没填。
64572
64576
  */
64573
- use_case: Schema_exports.optional(
64574
- Schema_exports.String.annotate({
64575
- description: "The use case behind this search: what the user asked for, in their own words, with the subject in it \u2014 the company, domain, ticker, place or topic. Shorten a long request rather than rewriting it."
64576
- })
64577
- ),
64577
+ use_case: Schema_exports.String.check(Schema_exports.isPattern(/\S/)).annotate({
64578
+ description: "Required on every search. The use case behind this search: what the user asked for, in their own words, with the subject in it \u2014 the company, domain, ticker, place or topic. Shorten a long request rather than rewriting it."
64579
+ }),
64578
64580
  /**
64579
- * `use_case` 的旧名(2026-09-24 之前),**只为还没升级的调用方留着**。
64581
+ * `use_case` 的旧名(2026-09-24 之前)。
64580
64582
  *
64581
- * 0.1.54 及更早的 CLI、以及本地还装着旧 SKILL.md 的 agent 都发这个名字。不收的话
64582
- * 服务端按默认把它剥掉 —— 不报错,但那一句静静丢了,而这个字段存在的全部理由就是
64583
- * 那一句。两个都带时 `use_case` 优先(searchOperation)。
64583
+ * 2026-09-28 `use_case` 改为必填之后,这个字段**收而不读**:只带它的请求(0.1.54 及更早的
64584
+ * CLI)在解码时就因缺 `use_case` 被拒,两个都带时读的是 `use_case`。留着只是为了带着它的
64585
+ * 新请求不报错;随 `tasks.user_request` 列一起删。
64584
64586
  */
64585
64587
  user_request: Schema_exports.optional(
64586
64588
  Schema_exports.String.annotate({
@@ -64588,6 +64590,7 @@ var SearchEndpointsRequest = Schema_exports.Struct({
64588
64590
  })
64589
64591
  )
64590
64592
  });
64593
+ var LEGACY_SEARCH_FIELDS = ["user_request"];
64591
64594
  var SearchHit = Schema_exports.Struct({
64592
64595
  ...endpointFields,
64593
64596
  /**
@@ -65242,12 +65245,19 @@ var balance = HttpApiGroup_exports.make("Balance").add(
65242
65245
  )
65243
65246
  )
65244
65247
  );
65248
+ var withoutLegacySearchFields = (document) => {
65249
+ const spec = document;
65250
+ const schema2 = spec.paths["/v1/endpoints/search"]?.post?.requestBody?.content["application/json"]?.schema;
65251
+ const properties = schema2?.properties;
65252
+ for (const field of LEGACY_SEARCH_FIELDS) delete properties?.[field];
65253
+ return document;
65254
+ };
65245
65255
  var glasserApi = HttpApi_exports.make("glasser").add(solutions).add(endpoints).add(runs).add(balance).middleware(RateLimit).middleware(Authentication).middleware(SchemaErrors).annotateMerge(
65246
65256
  OpenApi_exports.annotations({
65247
65257
  title: "Glasser",
65248
65258
  description: "One key, no contract, pay per call, across paid APIs bought wholesale. Every response carries x-request-id; every error body carries the same envelope."
65249
65259
  })
65250
- );
65260
+ ).annotate(OpenApi_exports.Transform, withoutLegacySearchFields);
65251
65261
 
65252
65262
  // src/config.ts
65253
65263
  import os from "node:os";
@@ -65721,18 +65731,27 @@ var search = Command_exports.make(
65721
65731
  cursor: cursorFlag,
65722
65732
  task: taskFlag,
65723
65733
  /*
65724
- * `--user-request` 是 2026-09-24 之前的名字(契约字段改名为 `use_case`),**留作别名**:
65725
- * agent 装在本地的 SKILL.md 只在它自己升级后才重新拉,旧 skill 配新 CLI 是常态。
65726
- * 没有这个别名,那样的 agent 每一次 search 都是 unknown flag —— 与 `-q` 同一条:
65727
- * 已发布的写法不能断。
65734
+ * 必填(契约 2026-09-28 起),但解析器里仍是 optional:隐藏的旧名 `--user-request`
65735
+ * 也能满足它,两个都没有才是用法错误 —— 在本地报,不白跑一趟服务端的 400。
65728
65736
  */
65729
65737
  useCase: Flag_exports.string("use-case").pipe(
65730
- Flag_exports.withAlias("user-request"),
65731
65738
  Flag_exports.optional,
65732
- Flag_exports.withDescription("What the user asked for, in their own words, with the subject in it")
65733
- )
65739
+ Flag_exports.withDescription(
65740
+ "Required. What the user asked for, in their own words, with the subject in it"
65741
+ )
65742
+ ),
65743
+ /*
65744
+ * `--user-request` 是 2026-09-24 之前的名字(契约字段改名为 `use_case`),**照收不公示**:
65745
+ * agent 装在本地的 SKILL.md 只在它自己升级后才重新拉,旧 skill 配新 CLI 是常态。
65746
+ * 不收的话那样的 agent 每一次 search 都是 unknown flag —— 与 `-q` 同一条:
65747
+ * 已发布的写法不能断。
65748
+ *
65749
+ * 不用 `Flag.withAlias`:help 会把别名印在新名旁边,读起来像两个现行名字。
65750
+ * `Flag.withHidden` 只能藏整个旗标,所以单独立一个隐藏旗标,两个都给时新名优先。
65751
+ */
65752
+ legacyUseCase: Flag_exports.string("user-request").pipe(Flag_exports.optional, Flag_exports.withHidden)
65734
65753
  },
65735
- ({ queryArg, query: queryFlag, limit, cursor, task, useCase }) => Effect_exports.gen(function* () {
65754
+ ({ queryArg, query: queryFlag, limit, cursor, task, useCase: useCaseFlag, legacyUseCase }) => Effect_exports.gen(function* () {
65736
65755
  const json2 = yield* JsonMode;
65737
65756
  if (Option_exports.isSome(queryArg) && Option_exports.isSome(queryFlag)) {
65738
65757
  return yield* new UsageError({
@@ -65740,6 +65759,15 @@ var search = Command_exports.make(
65740
65759
  });
65741
65760
  }
65742
65761
  const query = Option_exports.isSome(queryArg) ? queryArg : queryFlag;
65762
+ const given = Option_exports.orElse(useCaseFlag, () => legacyUseCase).pipe(
65763
+ Option_exports.filter((value3) => value3.trim() !== "")
65764
+ );
65765
+ if (Option_exports.isNone(given)) {
65766
+ return yield* new UsageError({
65767
+ message: 'Every search needs --use-case: what the user asked for, in their own words, with the subject in it. For example: `glasser search "<query>" --use-case "<what the user asked for>"`.'
65768
+ });
65769
+ }
65770
+ const useCase = given.value;
65743
65771
  const { client, call } = yield* api;
65744
65772
  const response = yield* call(
65745
65773
  client.Endpoints["endpoints-search"]({
@@ -65748,7 +65776,7 @@ var search = Command_exports.make(
65748
65776
  ...Option_exports.isSome(limit) ? { limit: limit.value } : {},
65749
65777
  ...Option_exports.isSome(cursor) ? { cursor: cursor.value } : {},
65750
65778
  ...Option_exports.isSome(task) ? { task_id: task.value } : {},
65751
- ...Option_exports.isSome(useCase) ? { use_case: useCase.value } : {}
65779
+ use_case: useCase
65752
65780
  }
65753
65781
  })
65754
65782
  );
@@ -65757,7 +65785,7 @@ var search = Command_exports.make(
65757
65785
  yield* Console_exports.log("No endpoints match \u2014 try other words.");
65758
65786
  yield* Console_exports.error(`
65759
65787
  Task: ${response.task_id}`);
65760
- return yield* Console_exports.error(`Try again: ${retryLine(response.task_id)}`);
65788
+ return yield* Console_exports.error(`Try again: ${retryLine(response.task_id, useCase)}`);
65761
65789
  }
65762
65790
  yield* Console_exports.log(
65763
65791
  table2(
@@ -65781,17 +65809,17 @@ Showing ${response.data.length} of ${response.total} matches.`);
65781
65809
  );
65782
65810
  if (response.next_cursor !== null) {
65783
65811
  yield* Console_exports.error(
65784
- `Next page: ${nextPageLine(query, response.next_cursor, response.task_id)}`
65812
+ `Next page: ${nextPageLine(query, response.next_cursor, response.task_id, useCase)}`
65785
65813
  );
65786
65814
  }
65787
- yield* Console_exports.error(`Search again: ${retryLine(response.task_id)}`);
65815
+ yield* Console_exports.error(`Search again: ${retryLine(response.task_id, useCase)}`);
65788
65816
  })
65789
65817
  ).pipe(Command_exports.withDescription("Search runnable endpoints"));
65790
- function retryLine(taskId) {
65791
- return `glasser search --task ${shellQuote(taskId)} -- "<other words>"`;
65818
+ function retryLine(taskId, useCase) {
65819
+ return `glasser search --task ${shellQuote(taskId)} --use-case ${shellQuote(useCase)} -- "<other words>"`;
65792
65820
  }
65793
- function nextPageLine(query, cursor, taskId) {
65794
- const base2 = `glasser search --cursor ${cursor} --task ${shellQuote(taskId)}`;
65821
+ function nextPageLine(query, cursor, taskId, useCase) {
65822
+ const base2 = `glasser search --cursor ${cursor} --task ${shellQuote(taskId)} --use-case ${shellQuote(useCase)}`;
65795
65823
  return Option_exports.isSome(query) ? `${base2} -- ${shellQuote(query.value)}` : base2;
65796
65824
  }
65797
65825
  var scoreLine = (score) => score === null ? "-" : score.toFixed(2);
@@ -66222,7 +66250,9 @@ ${kvBlock([
66222
66250
  )
66223
66251
  )
66224
66252
  );
66225
- yield* Console_exports.error('\nNext: glasser search -q "<what you need>"');
66253
+ yield* Console_exports.error(
66254
+ '\nNext: glasser search -q "<what you need>" --use-case "<what the user asked for>"'
66255
+ );
66226
66256
  })
66227
66257
  ).pipe(Command_exports.withDescription("Log in through the browser and store a Key"));
66228
66258
 
@@ -66603,7 +66633,7 @@ var runs2 = Command_exports.make("runs").pipe(
66603
66633
  // package.json
66604
66634
  var package_default = {
66605
66635
  name: "@glasser-ai/cli",
66606
- version: "0.1.56",
66636
+ version: "0.1.58",
66607
66637
  description: "Search, inspect and run paid API endpoints with one Key \u2014 the Glasser CLI",
66608
66638
  license: "MIT",
66609
66639
  type: "module",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glasser-ai/cli",
3
- "version": "0.1.56",
3
+ "version": "0.1.58",
4
4
  "description": "Search, inspect and run paid API endpoints with one Key — the Glasser CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",