@glasser-ai/cli 0.1.47 → 0.1.48

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 (2) hide show
  1. package/dist/glasser.js +134 -23
  2. package/package.json +2 -2
package/dist/glasser.js CHANGED
@@ -64528,6 +64528,11 @@ var EndpointDetail = Schema_exports.Struct({
64528
64528
  }).check(runModePairing).check(outputSchemaPairing);
64529
64529
  var SEARCH_PAGE_DEFAULT = 5;
64530
64530
  var SEARCH_PAGE_MAX = 20;
64531
+ var TaskIdField = Schema_exports.optional(
64532
+ Schema_exports.String.annotate({
64533
+ description: "The task this call belongs to. Omit on the first search of a piece of work and one is minted and returned; pass it back on every later search, inspect and run so they are recorded as one task. Any stable string is accepted."
64534
+ })
64535
+ );
64531
64536
  var SearchEndpointsRequest = Schema_exports.Struct({
64532
64537
  /** 关键词。缺省或空串返回全部(仍受 Policy 裁剪)。 */
64533
64538
  query: Schema_exports.optional(Schema_exports.String),
@@ -64535,7 +64540,23 @@ var SearchEndpointsRequest = Schema_exports.Struct({
64535
64540
  Schema_exports.Int.check(Schema_exports.isBetween({ minimum: 1, maximum: SEARCH_PAGE_MAX }))
64536
64541
  ),
64537
64542
  /** 上一页响应的 next_cursor。绑定于 query:拿别的查询的游标来翻是 400,不是从头开始。 */
64538
- cursor: Schema_exports.optional(Schema_exports.String)
64543
+ cursor: Schema_exports.optional(Schema_exports.String),
64544
+ task_id: TaskIdField,
64545
+ /**
64546
+ * Agent 转述的用户诉求。**只在这里收** —— 它属于这件事,不属于其中某一次调用,
64547
+ * 而 search 是这件事的第一次调用,也是 agent 手里那句话最新鲜的时候。
64548
+ *
64549
+ * 要的是转述,不是原话:原话会把第三方个人数据带进来,而这个字段的用途
64550
+ * (理解需求、将来做数据源匹配)不需要原话。
64551
+ *
64552
+ * 可选,而且必须可选:必填会让还没升级的调用方直接失败,也会逼一个不理解这个
64553
+ * 字段的模型去编 —— 编出来的比 null 更糟,因为在数据里分不出来。
64554
+ */
64555
+ user_request: Schema_exports.optional(
64556
+ Schema_exports.String.annotate({
64557
+ description: "One sentence, in your own words, on what the user is trying to achieve. Never their verbatim words, and never names, email addresses or other personal details. Recorded against the task as background; it does not affect results."
64558
+ })
64559
+ )
64539
64560
  });
64540
64561
  var SearchHit = Schema_exports.Struct({
64541
64562
  ...endpointFields,
@@ -64559,6 +64580,16 @@ var SearchEndpointsResponse = Schema_exports.Struct({
64559
64580
  next_cursor: Schema_exports.NullOr(Schema_exports.String),
64560
64581
  total: Schema_exports.Int.check(Schema_exports.isGreaterThanOrEqualTo(0)).annotate({
64561
64582
  description: "Total number of ranked candidates across all pages."
64583
+ }),
64584
+ /**
64585
+ * 这次检索算在哪件事上。**恒定存在** —— 请求没带就是这里签发的那个。
64586
+ *
64587
+ * 它放在 `total` 旁边而不是塞进每一行:它是关于这次调用的,不是关于某支
64588
+ * Endpoint 的。这个响应当初就没复用 `Paginated` 而是自己写了一份,为的正是
64589
+ * 能挂这种同级字段。
64590
+ */
64591
+ task_id: Schema_exports.String.annotate({
64592
+ description: "The task this search was recorded against \u2014 the one you sent, or a newly minted one if you sent none. Pass it back on every later search, inspect and run for the same piece of work."
64562
64593
  })
64563
64594
  });
64564
64595
  var InspectEndpointRequest = Schema_exports.Struct({
@@ -64568,7 +64599,8 @@ var InspectEndpointRequest = Schema_exports.Struct({
64568
64599
  Schema_exports.Int.check(Schema_exports.isGreaterThan(0)).annotate({
64569
64600
  description: "Select a supported Endpoint version, or omit for the default. Returns the current Price for that version; selecting a version does not lock its Price."
64570
64601
  })
64571
- )
64602
+ ),
64603
+ task_id: TaskIdField
64572
64604
  });
64573
64605
 
64574
64606
  // ../../packages/contract/src/rate-limit.ts
@@ -64639,7 +64671,15 @@ var Run = Schema_exports.Struct({
64639
64671
  stop_requested_at: Schema_exports.NullOr(Timestamp),
64640
64672
  created_at: Timestamp,
64641
64673
  started_at: Schema_exports.NullOr(Timestamp),
64642
- completed_at: Schema_exports.NullOr(Timestamp)
64674
+ completed_at: Schema_exports.NullOr(Timestamp),
64675
+ /**
64676
+ * 这条 Run 属于哪件事。调用方没报就是 null —— 那是常态,不是缺陷。
64677
+ *
64678
+ * 回的是**落库的那个值**,不是请求里那个:它经过了归一化(去空白、截断),
64679
+ * 而 `GET /v1/runs?task=` 拿去筛的也是归一化后的值。打印请求里那份会让人
64680
+ * 拿着一个筛不回来的串。
64681
+ */
64682
+ task_id: Schema_exports.NullOr(Schema_exports.String)
64643
64683
  });
64644
64684
  var RunRequest = Schema_exports.Struct({
64645
64685
  provider: ProviderSlug,
@@ -64651,13 +64691,32 @@ var RunRequest = Schema_exports.Struct({
64651
64691
  Schema_exports.Int.check(Schema_exports.isGreaterThan(0)).annotate({
64652
64692
  description: "Select a supported Endpoint version. Compatible updates keep this version; it does not lock the Price. New Runs use the Price at admission. Omit to use the default version. Unavailable or retired versions return 409."
64653
64693
  })
64694
+ ),
64695
+ /**
64696
+ * 这次 Run 算在哪件事上 —— 从 `POST /v1/endpoints/search` 的响应里拿。
64697
+ *
64698
+ * ⚠️ **它不进 `canonicalHash`。** 那个哈希按名字读四个键(provider、endpoint、
64699
+ * input、endpoint_version,见 `features/runs/service.ts`),所以这个同级字段
64700
+ * 永远不参与幂等判定:同一个 `Idempotency-Key` 换一个 task_id 重发仍然是重放,
64701
+ * 不会变成第二次执行。加字段时别把它挪进 `input`。
64702
+ */
64703
+ task_id: Schema_exports.optional(
64704
+ Schema_exports.String.annotate({
64705
+ description: "The task this run belongs to, from a catalog search response. Grouping only: it never affects routing, price or idempotency."
64706
+ })
64654
64707
  )
64655
64708
  });
64656
64709
  var ListRunsQuery = Schema_exports.Struct({
64657
64710
  ...PaginationQuery.fields,
64658
64711
  status: Schema_exports.optional(RunStatus),
64659
64712
  provider: Schema_exports.optional(Schema_exports.String),
64660
- endpoint: Schema_exports.optional(Schema_exports.String)
64713
+ endpoint: Schema_exports.optional(Schema_exports.String),
64714
+ /** 精确相等,不是前缀、不是包含 —— Task id 是个不透明串,要么知道全部要么不知道。 */
64715
+ task: Schema_exports.optional(
64716
+ Schema_exports.String.annotate({
64717
+ description: "Return only runs recorded against this task. Exact match."
64718
+ })
64719
+ )
64661
64720
  });
64662
64721
  var ListRunsResponse = Schema_exports.Struct({
64663
64722
  ...Paginated(Run).fields,
@@ -64706,7 +64765,19 @@ var providerField = (providers) => Schema_exports.optional(
64706
64765
  })
64707
64766
  );
64708
64767
  var commonFields = {
64709
- limit: Schema_exports.optional(Limit)
64768
+ limit: Schema_exports.optional(Limit),
64769
+ /**
64770
+ * 这次调用算在哪件事上。六个 Capability 共用 —— 一次 `auto` 兜底会产生好几条
64771
+ * Run(每一跳一条,见 api.ts),带上它那几条才是一件事。
64772
+ *
64773
+ * Solution 的调用方(Dify 插件、n8n)不走 search,所以拿不到我们签发的 id;
64774
+ * 随便一个稳定的串就行,服务端不校验形状。
64775
+ */
64776
+ task_id: Schema_exports.optional(
64777
+ Schema_exports.String.annotate({
64778
+ description: "The task this call belongs to. Reuse one value across the calls you make for one piece of work; under provider auto each fallback hop is its own run, and this is what records them as one task. Any stable string is accepted."
64779
+ })
64780
+ )
64710
64781
  };
64711
64782
  var WEB_RESEARCH_ACTIONS = [
64712
64783
  "search",
@@ -65505,6 +65576,10 @@ var cursorFlag = Flag_exports.string("cursor").pipe(
65505
65576
  Flag_exports.optional,
65506
65577
  Flag_exports.withDescription("Pagination cursor from a previous response")
65507
65578
  );
65579
+ var taskFlag = Flag_exports.string("task").pipe(
65580
+ Flag_exports.optional,
65581
+ Flag_exports.withDescription("Task id from a search response; groups these calls as one piece of work")
65582
+ );
65508
65583
  function literalsFlag(name, literals2, description) {
65509
65584
  return Flag_exports.string(name).pipe(
65510
65585
  Flag_exports.mapTryCatch(
@@ -65613,9 +65688,14 @@ var search = Command_exports.make(
65613
65688
  Flag_exports.withDescription("Keyword query; same as the positional argument")
65614
65689
  ),
65615
65690
  limit: searchLimitFlag,
65616
- cursor: cursorFlag
65691
+ cursor: cursorFlag,
65692
+ task: taskFlag,
65693
+ userRequest: Flag_exports.string("user-request").pipe(
65694
+ Flag_exports.optional,
65695
+ Flag_exports.withDescription("One sentence on what the user is trying to achieve, in your own words")
65696
+ )
65617
65697
  },
65618
- ({ queryArg, query: queryFlag, limit, cursor }) => Effect_exports.gen(function* () {
65698
+ ({ queryArg, query: queryFlag, limit, cursor, task, userRequest }) => Effect_exports.gen(function* () {
65619
65699
  const json2 = yield* JsonMode;
65620
65700
  if (Option_exports.isSome(queryArg) && Option_exports.isSome(queryFlag)) {
65621
65701
  return yield* new UsageError({
@@ -65629,13 +65709,18 @@ var search = Command_exports.make(
65629
65709
  payload: {
65630
65710
  ...Option_exports.isSome(query) ? { query: query.value } : {},
65631
65711
  ...Option_exports.isSome(limit) ? { limit: limit.value } : {},
65632
- ...Option_exports.isSome(cursor) ? { cursor: cursor.value } : {}
65712
+ ...Option_exports.isSome(cursor) ? { cursor: cursor.value } : {},
65713
+ ...Option_exports.isSome(task) ? { task_id: task.value } : {},
65714
+ ...Option_exports.isSome(userRequest) ? { user_request: userRequest.value } : {}
65633
65715
  }
65634
65716
  })
65635
65717
  );
65636
65718
  if (json2) return yield* Console_exports.log(jsonPretty(response));
65637
65719
  if (response.data.length === 0) {
65638
- return yield* Console_exports.log("No endpoints match \u2014 try other words.");
65720
+ yield* Console_exports.log("No endpoints match \u2014 try other words.");
65721
+ yield* Console_exports.error(`
65722
+ Task: ${response.task_id}`);
65723
+ return yield* Console_exports.error(`Try again: ${retryLine(response.task_id)}`);
65639
65724
  }
65640
65725
  yield* Console_exports.log(
65641
65726
  table2(
@@ -65653,14 +65738,22 @@ var search = Command_exports.make(
65653
65738
  );
65654
65739
  yield* Console_exports.error(`
65655
65740
  Showing ${response.data.length} of ${response.total} matches.`);
65656
- yield* Console_exports.error("Inspect with: glasser inspect -p <provider> -e <endpoint>");
65741
+ yield* Console_exports.error(`Task: ${response.task_id}`);
65742
+ yield* Console_exports.error(
65743
+ `Inspect with: glasser inspect -p <provider> -e <endpoint> --task ${shellQuote(response.task_id)}`
65744
+ );
65657
65745
  if (response.next_cursor !== null) {
65658
- yield* Console_exports.error(`Next page: ${nextPageLine(query, response.next_cursor)}`);
65746
+ yield* Console_exports.error(
65747
+ `Next page: ${nextPageLine(query, response.next_cursor, response.task_id)}`
65748
+ );
65659
65749
  }
65660
65750
  })
65661
65751
  ).pipe(Command_exports.withDescription("Search runnable endpoints"));
65662
- function nextPageLine(query, cursor) {
65663
- const base2 = `glasser search --cursor ${cursor}`;
65752
+ function retryLine(taskId) {
65753
+ return `glasser search --task ${shellQuote(taskId)} -- "<other words>"`;
65754
+ }
65755
+ function nextPageLine(query, cursor, taskId) {
65756
+ const base2 = `glasser search --cursor ${cursor} --task ${shellQuote(taskId)}`;
65664
65757
  return Option_exports.isSome(query) ? `${base2} -- ${shellQuote(query.value)}` : base2;
65665
65758
  }
65666
65759
  var scoreLine = (score) => score === null ? "-" : score.toFixed(2);
@@ -65677,8 +65770,13 @@ function modeLine(endpoint2) {
65677
65770
  // src/commands/inspect.ts
65678
65771
  var inspect2 = Command_exports.make(
65679
65772
  "inspect",
65680
- { provider: providerFlag, endpoint: endpointFlag, endpointVersion: endpointVersionFlag },
65681
- ({ provider, endpoint: endpoint2, endpointVersion }) => Effect_exports.gen(function* () {
65773
+ {
65774
+ provider: providerFlag,
65775
+ endpoint: endpointFlag,
65776
+ endpointVersion: endpointVersionFlag,
65777
+ task: taskFlag
65778
+ },
65779
+ ({ provider, endpoint: endpoint2, endpointVersion, task }) => Effect_exports.gen(function* () {
65682
65780
  const json2 = yield* JsonMode;
65683
65781
  const { client, call } = yield* api;
65684
65782
  const detail = yield* call(
@@ -65686,7 +65784,8 @@ var inspect2 = Command_exports.make(
65686
65784
  payload: {
65687
65785
  provider,
65688
65786
  endpoint: endpoint2,
65689
- ...Option_exports.isSome(endpointVersion) ? { endpoint_version: endpointVersion.value } : {}
65787
+ ...Option_exports.isSome(endpointVersion) ? { endpoint_version: endpointVersion.value } : {},
65788
+ ...Option_exports.isSome(task) ? { task_id: task.value } : {}
65690
65789
  }
65691
65790
  })
65692
65791
  );
@@ -65717,10 +65816,10 @@ ${jsonPretty(detail.output_schema)}`
65717
65816
  );
65718
65817
  yield* Console_exports.log(`
65719
65818
  Run it:
65720
- ${runItLine(detail)}`);
65819
+ ${runItLine(detail, task)}`);
65721
65820
  })
65722
65821
  ).pipe(Command_exports.withDescription("Inspect one endpoint: schemas, price, version"));
65723
- function runItLine(detail) {
65822
+ function runItLine(detail, task = Option_exports.none()) {
65724
65823
  return [
65725
65824
  "glasser run -p",
65726
65825
  shellQuote(detail.provider),
@@ -65729,7 +65828,8 @@ function runItLine(detail) {
65729
65828
  "-i",
65730
65829
  shellQuote(JSON.stringify(detail.sample_input)),
65731
65830
  "--endpoint-version",
65732
- String(detail.endpoint_version)
65831
+ String(detail.endpoint_version),
65832
+ ...Option_exports.isSome(task) ? ["--task", shellQuote(task.value)] : []
65733
65833
  ].join(" ");
65734
65834
  }
65735
65835
 
@@ -66152,6 +66252,13 @@ function renderRun(run7) {
66152
66252
  ["Provider", run7.provider],
66153
66253
  ["Endpoint", `${run7.endpoint} @ v${run7.endpoint_version}`],
66154
66254
  ["Charge", formatCharge(run7)],
66255
+ /*
66256
+ * 打的是 `run.task_id` —— **响应里的那个值**,不是命令行上传进去的那个。
66257
+ * 两者可能差一次归一化(去空白、截到上限),而 `runs list --task` 拿去筛的
66258
+ * 是落库的那一份;印请求里那一份会让人拿着一个筛不回来的串。
66259
+ * 没带 Task 就整行不出现,不印 "—":这一行是可选的,空破折号只是噪音。
66260
+ */
66261
+ ...run7.task_id === null ? [] : [["Task", run7.task_id]],
66155
66262
  ["Created", run7.created_at],
66156
66263
  ["Done", run7.completed_at ?? "\u2014"]
66157
66264
  ]);
@@ -66269,6 +66376,7 @@ var run6 = Command_exports.make(
66269
66376
  Flag_exports.optional,
66270
66377
  Flag_exports.withDescription("Reuse a key to retry safely; generated (and shown) when omitted")
66271
66378
  ),
66379
+ task: taskFlag,
66272
66380
  wait: waitFlag,
66273
66381
  waitTimeout: waitTimeoutFlag,
66274
66382
  output: outputFileFlag
@@ -66313,7 +66421,8 @@ var run6 = Command_exports.make(
66313
66421
  provider: flags.provider,
66314
66422
  endpoint: flags.endpoint,
66315
66423
  ...input === void 0 ? {} : { input },
66316
- ...Option_exports.isSome(flags.endpointVersion) ? { endpoint_version: flags.endpointVersion.value } : {}
66424
+ ...Option_exports.isSome(flags.endpointVersion) ? { endpoint_version: flags.endpointVersion.value } : {},
66425
+ ...Option_exports.isSome(flags.task) ? { task_id: flags.task.value } : {}
66317
66426
  },
66318
66427
  headers: { "idempotency-key": idempotencyKey }
66319
66428
  })
@@ -66381,7 +66490,8 @@ var runsList = Command_exports.make(
66381
66490
  Flag_exports.withAlias("e"),
66382
66491
  Flag_exports.optional,
66383
66492
  Flag_exports.withDescription("Filter by endpoint")
66384
- )
66493
+ ),
66494
+ task: taskFlag
66385
66495
  },
66386
66496
  (flags) => Effect_exports.gen(function* () {
66387
66497
  const json2 = yield* JsonMode;
@@ -66393,7 +66503,8 @@ var runsList = Command_exports.make(
66393
66503
  ...Option_exports.isSome(flags.cursor) ? { cursor: flags.cursor.value } : {},
66394
66504
  ...Option_exports.isSome(flags.status) ? { status: flags.status.value } : {},
66395
66505
  ...Option_exports.isSome(flags.provider) ? { provider: flags.provider.value } : {},
66396
- ...Option_exports.isSome(flags.endpoint) ? { endpoint: flags.endpoint.value } : {}
66506
+ ...Option_exports.isSome(flags.endpoint) ? { endpoint: flags.endpoint.value } : {},
66507
+ ...Option_exports.isSome(flags.task) ? { task: flags.task.value } : {}
66397
66508
  }
66398
66509
  })
66399
66510
  );
@@ -66454,7 +66565,7 @@ var runs2 = Command_exports.make("runs").pipe(
66454
66565
  // package.json
66455
66566
  var package_default = {
66456
66567
  name: "@glasser-ai/cli",
66457
- version: "0.1.47",
66568
+ version: "0.1.48",
66458
66569
  description: "Search, inspect and run paid API endpoints with one Key \u2014 the Glasser CLI",
66459
66570
  license: "MIT",
66460
66571
  type: "module",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@glasser-ai/cli",
3
- "version": "0.1.47",
4
- "description": "Search, inspect and run paid API endpoints with one Key \u2014 the Glasser CLI",
3
+ "version": "0.1.48",
4
+ "description": "Search, inspect and run paid API endpoints with one Key — the Glasser CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "bin": {