@actionway/cli-dev 0.0.0-dev.32704160099.89976dd6db2f → 0.0.0-dev.32848766753.0e740c8908f1

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 (35) hide show
  1. package/README.md +11 -1
  2. package/assets/skill/actionway/SKILL.md +80 -5
  3. package/assets/skill/actionway/references/capabilities/analyze-beats.md +12 -0
  4. package/assets/skill/actionway/references/capabilities/asset-get.md +12 -0
  5. package/assets/skill/actionway/references/capabilities/asset-register.md +12 -0
  6. package/assets/skill/actionway/references/capabilities/detect-shots.md +12 -0
  7. package/assets/skill/actionway/references/capabilities/download-media.md +12 -0
  8. package/assets/skill/actionway/references/capabilities/fetch.md +12 -0
  9. package/assets/skill/actionway/references/capabilities/generate-image.md +19 -0
  10. package/assets/skill/actionway/references/capabilities/generate-lyrics.md +12 -0
  11. package/assets/skill/actionway/references/capabilities/generate-music.md +16 -0
  12. package/assets/skill/actionway/references/capabilities/generate-sound.md +12 -0
  13. package/assets/skill/actionway/references/capabilities/generate-tts.md +16 -0
  14. package/assets/skill/actionway/references/capabilities/generate-video.md +35 -0
  15. package/assets/skill/actionway/references/capabilities/image-search.md +15 -0
  16. package/assets/skill/actionway/references/capabilities/image-to-3d.md +15 -0
  17. package/assets/skill/actionway/references/capabilities/images-to-3d.md +12 -0
  18. package/assets/skill/actionway/references/capabilities/income-statement.md +12 -0
  19. package/assets/skill/actionway/references/capabilities/knowledge-search.md +12 -0
  20. package/assets/skill/actionway/references/capabilities/lipsync.md +17 -0
  21. package/assets/skill/actionway/references/capabilities/market-quote.md +12 -0
  22. package/assets/skill/actionway/references/capabilities/motion-control.md +15 -0
  23. package/assets/skill/actionway/references/capabilities/ocr.md +12 -0
  24. package/assets/skill/actionway/references/capabilities/search-securities.md +12 -0
  25. package/assets/skill/actionway/references/capabilities/search.md +18 -0
  26. package/assets/skill/actionway/references/capabilities/segment-image-rle.md +12 -0
  27. package/assets/skill/actionway/references/capabilities/segment-image.md +12 -0
  28. package/assets/skill/actionway/references/capabilities/stock-download.md +12 -0
  29. package/assets/skill/actionway/references/capabilities/stock-search.md +12 -0
  30. package/assets/skill/actionway/references/capabilities/transcribe.md +12 -0
  31. package/assets/skill/actionway/references/capabilities/weather-alert-types.md +12 -0
  32. package/assets/skill/actionway/references/capabilities/weather-alert.md +12 -0
  33. package/assets/skill/actionway/references/capabilities/weather-alerts.md +12 -0
  34. package/dist/index.js +131 -164
  35. package/package.json +6 -6
@@ -0,0 +1,12 @@
1
+ # Weather Alert (`weather.alert.get`)
2
+
3
+ Get the current details of one U.S. weather alert by its alert identifier.
4
+
5
+ - Users ask for it as: get details for a weather alert; 查询一条天气预警的详情; weather alert details; NWS alert details; 天气预警详情.
6
+ - Takes text → returns structured-data. Runs synchronously.
7
+
8
+ ## Indicative price
9
+
10
+ free
11
+
12
+ Prices are indicative catalog values refreshed with each skill release. Before calling, Inspect the chosen variant: Inspect's input Schema and USD quote are authoritative.
@@ -0,0 +1,12 @@
1
+ # Weather Alerts (`weather.alerts.list`)
2
+
3
+ List active U.S. weather alerts for a state, territory, or marine area.
4
+
5
+ - Users ask for it as: list active weather alerts for an area; 查询某个地区当前的天气预警; active weather alerts; NWS alerts; 天气预警; 气象预警.
6
+ - Takes text → returns structured-data. Runs synchronously.
7
+
8
+ ## Indicative price
9
+
10
+ free
11
+
12
+ Prices are indicative catalog values refreshed with each skill release. Before calling, Inspect the chosen variant: Inspect's input Schema and USD quote are authoritative.
package/dist/index.js CHANGED
@@ -9353,9 +9353,11 @@ var Transport = class {
9353
9353
  authHeader;
9354
9354
  fetchImpl;
9355
9355
  onResponse;
9356
+ requestHeaders;
9356
9357
  constructor(init) {
9357
9358
  this.baseUrl = init.baseUrl.replace(/\/+$/, "");
9358
9359
  this.authHeader = init.authHeader;
9360
+ this.requestHeaders = init.requestHeaders;
9359
9361
  this.fetchImpl = init.fetchImpl ?? fetch;
9360
9362
  this.onResponse = init.onResponse;
9361
9363
  }
@@ -9392,7 +9394,9 @@ var Transport = class {
9392
9394
  }
9393
9395
  async headers(hasBody, opts) {
9394
9396
  const auth = typeof this.authHeader === "function" ? await this.authHeader() : this.authHeader;
9397
+ const requestHeaders = typeof this.requestHeaders === "function" ? await this.requestHeaders() : this.requestHeaders;
9395
9398
  return {
9399
+ ...requestHeaders,
9396
9400
  authorization: auth,
9397
9401
  accept: "application/json",
9398
9402
  "x-actionway-cli-version": getCliVersion(),
@@ -10324,7 +10328,7 @@ function emitUseWaitHint() {
10324
10328
  message: "The job is still pending. Run actionway wait with this job_ref now; never resubmit the job or create a shell polling loop."
10325
10329
  });
10326
10330
  }
10327
- function registerPollCommand(program2, getTransport3) {
10331
+ function registerPollCommand(program2, getTransport2) {
10328
10332
  program2.command("poll").description(
10329
10333
  "Run one authenticated status snapshot for recovery or diagnostics. Use actionway wait for normal async completion."
10330
10334
  ).addHelpText(
@@ -10337,7 +10341,7 @@ function registerPollCommand(program2, getTransport3) {
10337
10341
  ).requiredOption("--job-ref <ref>", "the job_ref returned by a previous async submit").action(async (opts) => {
10338
10342
  try {
10339
10343
  const jobRef = validateJobRef(opts.jobRef);
10340
- const body = await pollJob(jobRef, getTransport3());
10344
+ const body = await pollJob(jobRef, getTransport2());
10341
10345
  if (body.status === "pending") emitUseWaitHint();
10342
10346
  ok({ job_ref: jobRef, ...body });
10343
10347
  } catch (err) {
@@ -10409,7 +10413,7 @@ async function waitForJob(options) {
10409
10413
  await sleep(Math.min(intervalMs, timeoutMs - elapsedMs));
10410
10414
  }
10411
10415
  }
10412
- function registerWaitCommand(program2, getTransport3) {
10416
+ function registerWaitCommand(program2, getTransport2) {
10413
10417
  program2.command("wait").description("Wait for an async job and print only its terminal result.").requiredOption("--job-ref <ref>", "the full job_ref returned by the submit command").option("--timeout-seconds <n>", "maximum wait time in seconds (default: 1800)", Number, 1800).addHelpText(
10414
10418
  "after",
10415
10419
  [
@@ -10427,7 +10431,7 @@ function registerWaitCommand(program2, getTransport3) {
10427
10431
  job_ref: jobRef
10428
10432
  });
10429
10433
  }
10430
- const transport = getTransport3();
10434
+ const transport = getTransport2();
10431
10435
  const terminal = await waitForJob({
10432
10436
  jobRef,
10433
10437
  timeoutMs: opts.timeoutSeconds * 1e3,
@@ -11068,7 +11072,7 @@ function emitCall(response) {
11068
11072
  }
11069
11073
  ok(response);
11070
11074
  }
11071
- function registerToolsCommands(program2, getTransport3) {
11075
+ function registerToolsCommands(program2, getTransport2) {
11072
11076
  const tools = program2.command("tools").description("Discover, inspect, and call Actionway capabilities through the canonical Tool protocol.");
11073
11077
  tools.command("search <query>").description("Search the current capability catalog by natural-language intent.").option("--limit <n>", "maximum candidates (1-5)", (value) => Number(value)).option("--domain <id>", "required capability domain; repeatable", values, []).option("--input-modality <name>", "required input modality; repeatable", values, []).option("--output-modality <name>", "required output modality; repeatable", values, []).option("--effect <name>", "required capability effect; repeatable", values, []).option("--max-price-usd <amount>", "maximum fixed Actionway USD price").action(async (query, options) => {
11074
11078
  const filters = {};
@@ -11078,14 +11082,14 @@ function registerToolsCommands(program2, getTransport3) {
11078
11082
  if (Array.isArray(options.effect) && options.effect.length) filters.effects = options.effect;
11079
11083
  if (typeof options.maxPriceUsd === "string") filters.maxPriceUsd = options.maxPriceUsd;
11080
11084
  try {
11081
- ok(await getTransport3().searchTools({ query, ...options.limit !== void 0 ? { limit: Number(options.limit) } : {}, ...filters }, { retries: 1 }));
11085
+ ok(await getTransport2().searchTools({ query, ...options.limit !== void 0 ? { limit: Number(options.limit) } : {}, ...filters }, { retries: 1 }));
11082
11086
  } catch (error) {
11083
11087
  failTool(error);
11084
11088
  }
11085
11089
  });
11086
11090
  tools.command("inspect <tool_ref>").description("Read the current canonical Schema, variants, effects, guidance, and Actionway USD price.").action(async (toolRef) => {
11087
11091
  try {
11088
- ok(await getTransport3().inspectTool(toolRef, { retries: 1 }));
11092
+ ok(await getTransport2().inspectTool(toolRef, { retries: 1 }));
11089
11093
  } catch (error) {
11090
11094
  failTool(error);
11091
11095
  }
@@ -11096,7 +11100,7 @@ function registerToolsCommands(program2, getTransport3) {
11096
11100
  if (toolRef || options.variant || options.inputJson || options.inputFile) {
11097
11101
  throw new CliError("E_SCHEMA", "--resume cannot be combined with tool_ref, --variant, or input arguments.");
11098
11102
  }
11099
- emitCall(await getTransport3().resumeToolCall(options.resume, { retries: 1 }));
11103
+ emitCall(await getTransport2().resumeToolCall(options.resume, { retries: 1 }));
11100
11104
  }
11101
11105
  if (!toolRef) throw new CliError("E_SCHEMA", "tool_ref is required unless --resume is used.");
11102
11106
  const args = await resolveJsonObjectInlineOrFile(options.inputJson, options.inputFile, {
@@ -11104,7 +11108,7 @@ function registerToolsCommands(program2, getTransport3) {
11104
11108
  file: "--input-file"
11105
11109
  });
11106
11110
  if (!options.inputJson && !options.inputFile) throw new CliError("E_SCHEMA", "Use --input-json or --input-file for canonical arguments.");
11107
- const response = await getTransport3().callTool({
11111
+ const response = await getTransport2().callTool({
11108
11112
  toolRef,
11109
11113
  ...typeof options.variant === "string" ? { variantId: options.variant } : {},
11110
11114
  arguments: args,
@@ -11216,7 +11220,7 @@ function failFromError(err) {
11216
11220
  }
11217
11221
  fail({ code: "E_BACKEND", message: err instanceof Error ? err.message : String(err) });
11218
11222
  }
11219
- function registerAssetCommands(program2, getTransport3) {
11223
+ function registerAssetCommands(program2, getTransport2) {
11220
11224
  const asset = program2.command("asset").description("Register / fetch media assets (groups + assets) for downstream generate-* verbs.");
11221
11225
  asset.command("register").description(
11222
11226
  "Create an asset group and register one Image / Video / Audio asset under it; the server assigns the real group_id."
@@ -11258,7 +11262,7 @@ Examples:
11258
11262
  assetType,
11259
11263
  projectName: String(opts.projectName ?? "default")
11260
11264
  },
11261
- getTransport3()
11265
+ getTransport2()
11262
11266
  );
11263
11267
  ok(res);
11264
11268
  } catch (err) {
@@ -11267,7 +11271,7 @@ Examples:
11267
11271
  });
11268
11272
  asset.command("get").description("Fetch a single asset by id.").requiredOption("--id <id>").action(async (opts) => {
11269
11273
  try {
11270
- const res = await getTransport3().post(
11274
+ const res = await getTransport2().post(
11271
11275
  ASSET_GET_ENDPOINT,
11272
11276
  { id: String(opts.id) },
11273
11277
  { timeoutMs: ASSET_TIMEOUT_MS, retries: 1 }
@@ -11333,7 +11337,7 @@ async function resolveKnowledgeFilters(params) {
11333
11337
  file: "--filters-file"
11334
11338
  });
11335
11339
  }
11336
- async function executeKnowledgeSearch(input, opts, getTransport3) {
11340
+ async function executeKnowledgeSearch(input, opts, getTransport2) {
11337
11341
  if (input.provider && input.domain !== "voice") {
11338
11342
  return {
11339
11343
  kind: "fail",
@@ -11351,7 +11355,7 @@ async function executeKnowledgeSearch(input, opts, getTransport3) {
11351
11355
  };
11352
11356
  }
11353
11357
  try {
11354
- const res = await getTransport3().post(KNOWLEDGE_SEARCH_ENDPOINT, body, {
11358
+ const res = await getTransport2().post(KNOWLEDGE_SEARCH_ENDPOINT, body, {
11355
11359
  timeoutMs: KNOWLEDGE_TIMEOUT_MS,
11356
11360
  retries: 1
11357
11361
  });
@@ -11376,7 +11380,7 @@ async function executeKnowledgeSearch(input, opts, getTransport3) {
11376
11380
  return { kind: "fail", code: "E_BACKEND", exitCode: 1, message: err instanceof Error ? err.message : String(err) };
11377
11381
  }
11378
11382
  }
11379
- function registerKnowledgeCommands(program2, getTransport3) {
11383
+ function registerKnowledgeCommands(program2, getTransport2) {
11380
11384
  const kb = program2.command("knowledge").description("Knowledge-base search across domain libraries (sfx, bgm, visual_style, voice, writing, meme).");
11381
11385
  const filtersFileFlag = {
11382
11386
  flag: "filters-file",
@@ -11449,22 +11453,19 @@ function registerKnowledgeCommands(program2, getTransport3) {
11449
11453
  ...typeof params.k === "number" ? { k: params.k } : {},
11450
11454
  ...Object.keys(filters).length > 0 ? { filters } : {}
11451
11455
  };
11452
- const outcome = await executeKnowledgeSearch(input, { dryRun: rawOpts.dryRun === true }, getTransport3);
11456
+ const outcome = await executeKnowledgeSearch(input, { dryRun: rawOpts.dryRun === true }, getTransport2);
11453
11457
  emitOutcome(outcome);
11454
11458
  });
11455
11459
  }
11456
11460
 
11457
11461
  // ../cli-core/src/commands/stock-download.ts
11458
11462
  import { randomUUID as randomUUID3 } from "node:crypto";
11459
- import { mkdir, writeFile } from "node:fs/promises";
11463
+ import { mkdir, rename, rm, writeFile } from "node:fs/promises";
11460
11464
  import { dirname, extname, isAbsolute as isAbsolute2 } from "node:path";
11461
11465
  var DEFAULT_DOWNLOAD_DIR = "/workspace/.stock-media";
11462
11466
  var FETCH_TIMEOUT_MS = 6e4;
11463
11467
  var MAX_DOWNLOAD_BYTES = 200 * 1024 * 1024;
11464
11468
  var ASSET_ID_RE = /^([a-z0-9_-]+):([a-zA-Z0-9_.-]+)$/;
11465
- function stockDownloadAvailable() {
11466
- return false;
11467
- }
11468
11469
  var MIME_TO_EXT = /* @__PURE__ */ new Map([
11469
11470
  ["image/jpeg", "jpg"],
11470
11471
  ["image/jpg", "jpg"],
@@ -11575,7 +11576,7 @@ async function fetchBytes(url) {
11575
11576
  clearTimeout(timer);
11576
11577
  }
11577
11578
  }
11578
- function registerStockDownload(parent) {
11579
+ function registerStockDownload(parent, deps) {
11579
11580
  parent.command("download").description("Fetch a stock-media asset (CDN URL from search result) into /workspace and echo full metadata.").addHelpText(
11580
11581
  "after",
11581
11582
  [
@@ -11585,19 +11586,12 @@ function registerStockDownload(parent) {
11585
11586
  "so the local result retains its source and license metadata."
11586
11587
  ].join("\n")
11587
11588
  ).requiredOption("--asset-id <id>", "<provider>:<native_id> from a search result").requiredOption("--url <url>", "direct CDN URL from search result's download_url").option("--to <path>", `absolute path under /workspace (default: ${DEFAULT_DOWNLOAD_DIR}/<provider>-<id>.<ext>)`).option("--metadata-json <json>", "JSON-encoded metadata object from the search result; echoed back in output").action(async (opts) => {
11588
- if (!stockDownloadAvailable()) {
11589
- fail({
11590
- code: "E_CAPABILITY_NOT_AVAILABLE",
11591
- message: "stock download is deferred until Gateway command-level billing is available",
11592
- hint: "do not fetch the asset directly as a workaround; wait for the stage-two stock billing integration"
11593
- });
11594
- }
11595
11589
  const { provider, nativeId } = parseAssetId(String(opts.assetId));
11596
11590
  const url = String(opts.url);
11597
11591
  try {
11598
11592
  const parsedUrl = new URL(url);
11599
- if (parsedUrl.protocol !== "https:" && parsedUrl.protocol !== "http:") {
11600
- fail({ code: "E_SCHEMA", message: `--url must be http(s); got protocol ${parsedUrl.protocol}` });
11593
+ if (parsedUrl.protocol !== "https:") {
11594
+ fail({ code: "E_SCHEMA", message: `--url must use https; got protocol ${parsedUrl.protocol}` });
11601
11595
  }
11602
11596
  } catch (err) {
11603
11597
  if (err.name === "TypeError") {
@@ -11614,7 +11608,22 @@ function registerStockDownload(parent) {
11614
11608
  const defaultPath = `${DEFAULT_DOWNLOAD_DIR}/${provider}-${nativeId}.${ext}`;
11615
11609
  const destination = explicitDestination ?? validateDestination(void 0, defaultPath);
11616
11610
  await mkdir(dirname(destination), { recursive: true });
11617
- await writeFile(destination, buf);
11611
+ const temporary = `${destination}.actionway-${jobRef}.tmp`;
11612
+ await writeFile(temporary, buf, { flag: "wx" });
11613
+ try {
11614
+ const transport = deps.getTransport();
11615
+ const body = { provider, native_id: nativeId, url, destination, kind: contentType?.startsWith("video/") ? "video" : "image" };
11616
+ if (deps.projectToolCall) {
11617
+ const response = await transport.callTool({ toolRef: "stock-media.download", arguments: body, idempotencyKey: jobRef, confirmation: { kind: "typed-command" } }, { jobRef, retries: 1 });
11618
+ if (response.status !== "completed") throw new StockDownloadError("stock download authorization did not complete");
11619
+ } else {
11620
+ await transport.post("internal/stock/download", body, { jobRef, retries: 1 });
11621
+ }
11622
+ await rename(temporary, destination);
11623
+ } catch (error) {
11624
+ await rm(temporary, { force: true });
11625
+ throw error;
11626
+ }
11618
11627
  ok({
11619
11628
  job_ref: jobRef,
11620
11629
  asset_id: `${provider}:${nativeId}`,
@@ -11896,9 +11905,6 @@ var STOCK_DEFAULT_PROVIDER_ORDER = ["pexels", "pixabay", "openverse"];
11896
11905
  var STOCK_ORIENTATIONS = ["landscape", "portrait", "square"];
11897
11906
  var STOCK_TYPES = ["image", "video"];
11898
11907
  var STOCK_MODES = ["fallback", "fanout"];
11899
- function isStockSearchAvailable() {
11900
- return false;
11901
- }
11902
11908
  function parsePositiveInt(raw, flag, max) {
11903
11909
  const n = Number(raw);
11904
11910
  if (!Number.isFinite(n) || !Number.isInteger(n) || n < 1 || n > max) {
@@ -11934,88 +11940,15 @@ function parseProviders(csv, type) {
11934
11940
  }
11935
11941
  return enabled;
11936
11942
  }
11937
- function describeProviderFailure(provider, err) {
11938
- if (err instanceof TransportError) {
11939
- return {
11940
- provider,
11941
- ...err.status !== void 0 ? { status: err.status } : {},
11942
- reason: `${err.status ?? "transport"}: ${err.message}`
11943
- };
11944
- }
11945
- if (err instanceof Error) return { provider, reason: err.message };
11946
- return { provider, reason: String(err) };
11947
- }
11948
- function mergeResults(perProvider, limit) {
11949
- const merged = [];
11950
- const seen = /* @__PURE__ */ new Set();
11951
- const cursors = perProvider.map(() => 0);
11952
- let active = perProvider.filter((arr) => arr.length > 0).length;
11953
- while (merged.length < limit && active > 0) {
11954
- active = 0;
11955
- for (let i = 0; i < perProvider.length; i++) {
11956
- const arr = perProvider[i];
11957
- const cursor = cursors[i];
11958
- if (arr === void 0 || cursor === void 0 || cursor >= arr.length) continue;
11959
- const r = arr[cursor];
11960
- cursors[i] = cursor + 1;
11961
- if (r !== void 0 && !seen.has(r.asset_id)) {
11962
- seen.add(r.asset_id);
11963
- merged.push(r);
11964
- if (merged.length >= limit) break;
11965
- }
11966
- if (cursor + 1 < arr.length) active += 1;
11967
- }
11968
- }
11969
- return merged;
11970
- }
11971
- async function searchSequential(enabled, opts, limit, searchFn) {
11972
- const collected = [];
11973
- const seen = /* @__PURE__ */ new Set();
11974
- const queried = [];
11975
- const failed = [];
11976
- for (const name of enabled) {
11977
- queried.push(name);
11978
- try {
11979
- const results = await searchFn(name, opts);
11980
- for (const r of results) {
11981
- if (!seen.has(r.asset_id)) {
11982
- seen.add(r.asset_id);
11983
- collected.push(r);
11984
- if (collected.length >= limit) break;
11985
- }
11986
- }
11987
- } catch (err) {
11988
- failed.push(describeProviderFailure(name, err));
11989
- }
11990
- if (collected.length >= limit) break;
11991
- }
11992
- return { results: collected.slice(0, limit), queried, failed };
11993
- }
11994
- async function searchFanout(enabled, opts, limit, searchFn) {
11995
- const settled = await Promise.allSettled(enabled.map((n) => searchFn(n, opts)));
11996
- const perProviderResults = [];
11997
- const failed = [];
11998
- for (let i = 0; i < enabled.length; i++) {
11999
- const r = settled[i];
12000
- const name = enabled[i];
12001
- if (r !== void 0 && r.status === "fulfilled") {
12002
- perProviderResults.push(r.value);
12003
- } else {
12004
- perProviderResults.push([]);
12005
- if (r !== void 0 && name !== void 0) failed.push(describeProviderFailure(name, r.reason));
12006
- }
12007
- }
12008
- return { results: mergeResults(perProviderResults, limit), queried: [...enabled], failed };
12009
- }
12010
- function registerStockSearch(parent, getTransport3) {
11943
+ function registerStockSearch(parent, deps) {
12011
11944
  parent.command("search").description(
12012
11945
  "Sequential-fallback search across providers (Pexels -> Pixabay -> Openverse). Use --mode=fanout for parallel."
12013
11946
  ).addHelpText(
12014
11947
  "after",
12015
11948
  [
12016
11949
  "",
12017
- "Availability:",
12018
- " Stage one is fail-closed until Gateway command-level billing orchestration is available.",
11950
+ "Execution:",
11951
+ " Gateway orchestrates all selected providers and bills the search once.",
12019
11952
  "",
12020
11953
  "Modes:",
12021
11954
  " fallback (default) - calls Pexels -> Pixabay -> Openverse in order and stops once limit results are collected.",
@@ -12044,13 +11977,6 @@ function registerStockSearch(parent, getTransport3) {
12044
11977
  `search strategy: ${STOCK_MODES.join(" | ")} (default fallback saves API budget)`,
12045
11978
  "fallback"
12046
11979
  ).action(async (opts) => {
12047
- if (!isStockSearchAvailable()) {
12048
- fail({
12049
- code: "E_CAPABILITY_NOT_AVAILABLE",
12050
- message: "stock search is not available in migration stage one",
12051
- hint: "Gateway command-level stock billing/orchestration is required before this command can be enabled."
12052
- });
12053
- }
12054
11980
  const type = String(opts.type);
12055
11981
  if (!STOCK_TYPES.includes(type)) {
12056
11982
  fail({ code: "E_SCHEMA", message: `--type must be image|video; got ${String(opts.type)}` });
@@ -12067,42 +11993,35 @@ function registerStockSearch(parent, getTransport3) {
12067
11993
  }
12068
11994
  const limit = typeof opts.limit === "number" ? opts.limit : 10;
12069
11995
  const enabled = parseProviders(opts.providers !== void 0 ? String(opts.providers) : void 0, type);
12070
- const perProviderLimit = mode === "fanout" ? Math.max(1, Math.ceil(limit * 1.5 / enabled.length)) : limit;
12071
11996
  const searchOpts = {
12072
11997
  query: String(opts.query),
12073
11998
  type,
12074
11999
  ...opts.orientation !== void 0 ? { orientation: String(opts.orientation) } : {},
12075
12000
  ...typeof opts.minWidth === "number" ? { minWidth: opts.minWidth } : {},
12076
12001
  ...typeof opts.durationMin === "number" ? { durationMin: opts.durationMin } : {},
12077
- ...typeof opts.durationMax === "number" ? { durationMax: opts.durationMax } : {},
12078
- perProviderLimit
12002
+ ...typeof opts.durationMax === "number" ? { durationMax: opts.durationMax } : {}
12079
12003
  };
12080
12004
  const jobRef = randomUUID4();
12081
12005
  try {
12082
- const transport = getTransport3();
12083
- const searchFn = (name, o) => {
12084
- const provider = ALL_PROVIDERS[name];
12085
- if (!provider) throw new Error(`unknown stock provider: ${name}`);
12086
- return provider.search(o, transport);
12087
- };
12088
- const { results, queried, failed } = mode === "fanout" ? await searchFanout(enabled, searchOpts, limit, searchFn) : await searchSequential(enabled, searchOpts, limit, searchFn);
12089
- if (results.length === 0 && failed.length > 0 && failed.length === queried.length) {
12090
- fail({
12091
- code: "E_BACKEND",
12092
- message: `all stock-media providers failed for "${String(opts.query)}"`,
12093
- hint: "check gateway provider routes / quota; see providers_failed for per-provider reason.",
12094
- extra: { job_ref: jobRef, mode, providers_queried: queried, providers_failed: failed }
12095
- });
12096
- }
12097
- ok({
12098
- job_ref: jobRef,
12006
+ const transport = deps.getTransport();
12007
+ const body = {
12099
12008
  query: searchOpts.query,
12100
12009
  type,
12101
12010
  mode,
12102
- results,
12103
- providers_queried: queried,
12104
- providers_failed: failed
12105
- });
12011
+ limit,
12012
+ providers: enabled,
12013
+ ...searchOpts.orientation ? { orientation: searchOpts.orientation } : {},
12014
+ ...searchOpts.minWidth !== void 0 ? { min_width: searchOpts.minWidth } : {},
12015
+ ...searchOpts.durationMin !== void 0 ? { duration_min: searchOpts.durationMin } : {},
12016
+ ...searchOpts.durationMax !== void 0 ? { duration_max: searchOpts.durationMax } : {}
12017
+ };
12018
+ if (deps.projectToolCall) {
12019
+ const response2 = await transport.callTool({ toolRef: "stock-media.search", arguments: body, idempotencyKey: jobRef, confirmation: { kind: "typed-command" } }, { jobRef, retries: 1 });
12020
+ if (response2.status !== "completed") return ok({ ...response2, job_ref: jobRef });
12021
+ return ok({ job_ref: jobRef, ...response2.result });
12022
+ }
12023
+ const response = await transport.post("internal/stock/search", body, { jobRef, retries: 1 });
12024
+ ok({ job_ref: jobRef, ...response });
12106
12025
  } catch (err) {
12107
12026
  if (err instanceof TransportError) {
12108
12027
  fail({ code: err.code, message: err.message, extra: { ...err.extra ?? {}, job_ref: jobRef } });
@@ -12117,10 +12036,11 @@ function registerStockSearch(parent, getTransport3) {
12117
12036
  }
12118
12037
 
12119
12038
  // ../cli-core/src/commands/stock.ts
12120
- function registerStockCommands(program2, getTransport3) {
12039
+ function registerStockCommands(program2, depsOrTransport) {
12040
+ const deps = typeof depsOrTransport === "function" ? { getTransport: depsOrTransport } : depsOrTransport;
12121
12041
  const stock = program2.command("stock").description("Search and download public stock media (Pexels / Pixabay / Openverse) for b-roll.");
12122
- registerStockSearch(stock, getTransport3);
12123
- registerStockDownload(stock);
12042
+ registerStockSearch(stock, deps);
12043
+ registerStockDownload(stock, deps);
12124
12044
  }
12125
12045
 
12126
12046
  // ../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/esm.mjs
@@ -13092,19 +13012,19 @@ function accountEndpoint(path, options) {
13092
13012
  const query = parameters.toString();
13093
13013
  return `v1/account/${path}${query ? `?${query}` : ""}`;
13094
13014
  }
13095
- async function read(endpoint, getTransport3) {
13015
+ async function read(endpoint, getTransport2) {
13096
13016
  try {
13097
- ok(await getTransport3().getBusiness(endpoint, { retries: 1 }));
13017
+ ok(await getTransport2().getBusiness(endpoint, { retries: 1 }));
13098
13018
  } catch (error) {
13099
13019
  failAccount(error);
13100
13020
  }
13101
13021
  }
13102
- function registerAccountCommands(program2, getTransport3) {
13022
+ function registerAccountCommands(program2, getTransport2) {
13103
13023
  const account = program2.command("account").description("Access your Actionway invitation, USD wallet, service usage, and wallet transactions.");
13104
- account.command("invitation").description("Get or create your permanent invitation code, link, and localized share message.").option("--locale <locale>", "Share-message locale: zh-cn, zh-tw, en, or ja.", "en").action((options) => read(invitationEndpoint(options.locale), getTransport3));
13105
- account.command("usage").description("Query held, charged, released, and free capability calls.").option("--limit <count>", "Maximum records in this page (1-100).").option("--cursor <cursor>", "Opaque nextCursor returned by the previous page.").option("--from <date>", "Inclusive ISO date or timestamp (UTC for date-only values).").option("--to <date>", "Exclusive ISO date or timestamp (UTC for date-only values).").option("--status <status>", "held, settled, or expired.").option("--service <service-id>", "Exact public serviceId.").option("--pricing-kind <kind>", "priced or free.").action((options) => read(accountEndpoint("usage", options), getTransport3));
13106
- account.command("wallet").description("Show the current available and held Actionway USD wallet balance.").action(() => read("v1/account/wallet", getTransport3));
13107
- account.command("transactions").description("Query wallet top-ups, charges, promotions, refunds, and other fund movements.").option("--limit <count>", "Maximum records in this page (1-50).").option("--cursor <cursor>", "Opaque nextCursor returned by the previous page.").option("--from <date>", "Inclusive ISO date or timestamp (UTC for date-only values).").option("--to <date>", "Exclusive ISO date or timestamp (UTC for date-only values).").option("--status <status>", "pending, succeeded, or failed.").option("--kind <kind>", "top_up, charge, refund, dispute, or promotion kind.").action((options) => read(accountEndpoint("transactions", options), getTransport3));
13024
+ account.command("invitation").description("Get or create your permanent invitation code, link, and localized share message.").option("--locale <locale>", "Share-message locale: zh-cn, zh-tw, en, or ja.", "en").action((options) => read(invitationEndpoint(options.locale), getTransport2));
13025
+ account.command("usage").description("Query held, charged, released, and free capability calls.").option("--limit <count>", "Maximum records in this page (1-100).").option("--cursor <cursor>", "Opaque nextCursor returned by the previous page.").option("--from <date>", "Inclusive ISO date or timestamp (UTC for date-only values).").option("--to <date>", "Exclusive ISO date or timestamp (UTC for date-only values).").option("--status <status>", "held, settled, or expired.").option("--service <service-id>", "Exact public serviceId.").option("--pricing-kind <kind>", "priced or free.").action((options) => read(accountEndpoint("usage", options), getTransport2));
13026
+ account.command("wallet").description("Show the current available and held Actionway USD wallet balance.").action(() => read("v1/account/wallet", getTransport2));
13027
+ account.command("transactions").description("Query wallet top-ups, charges, promotions, refunds, and other fund movements.").option("--limit <count>", "Maximum records in this page (1-50).").option("--cursor <cursor>", "Opaque nextCursor returned by the previous page.").option("--from <date>", "Inclusive ISO date or timestamp (UTC for date-only values).").option("--to <date>", "Exclusive ISO date or timestamp (UTC for date-only values).").option("--status <status>", "pending, succeeded, or failed.").option("--kind <kind>", "top_up, charge, refund, dispute, or promotion kind.").action((options) => read(accountEndpoint("transactions", options), getTransport2));
13108
13028
  }
13109
13029
 
13110
13030
  // src/commands/doctor.ts
@@ -13435,6 +13355,35 @@ function materializeSkill(options = {}) {
13435
13355
  };
13436
13356
  }
13437
13357
 
13358
+ // src/lib/client-context.ts
13359
+ var ACTIONWAY_AGENT_HOST_HEADER = "x-actionway-agent-host";
13360
+ var ACTIONWAY_RUNTIME_OS_HEADER = "x-actionway-runtime-os";
13361
+ var ACTIONWAY_AGENT_HOSTS = ["codex", "claude_code", "workbuddy"];
13362
+ function isActionwayAgentHost(value) {
13363
+ return typeof value === "string" && ACTIONWAY_AGENT_HOSTS.includes(value);
13364
+ }
13365
+ function detectRuntimeOs(platform = process.platform, env = process.env) {
13366
+ if (platform === "win32") return "windows";
13367
+ if (platform === "darwin") return "macos";
13368
+ if (platform === "linux") {
13369
+ if ((env.WSL_DISTRO_NAME ?? "").trim() || (env.WSL_INTEROP ?? "").trim()) return "wsl";
13370
+ return "linux";
13371
+ }
13372
+ return "other";
13373
+ }
13374
+ function localClientContext(agentHost, platform = process.platform, env = process.env) {
13375
+ return {
13376
+ ...isActionwayAgentHost(agentHost) ? { agentHost } : {},
13377
+ runtimeOs: detectRuntimeOs(platform, env)
13378
+ };
13379
+ }
13380
+ function localClientContextHeaders(context) {
13381
+ return {
13382
+ ...context.agentHost ? { [ACTIONWAY_AGENT_HOST_HEADER]: context.agentHost } : {},
13383
+ [ACTIONWAY_RUNTIME_OS_HEADER]: context.runtimeOs
13384
+ };
13385
+ }
13386
+
13438
13387
  // src/lib/install-session.ts
13439
13388
  var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
13440
13389
  var ANALYTICS_TIMEOUT_MS = 3e3;
@@ -13474,7 +13423,12 @@ async function captureInstallStarted(input) {
13474
13423
  `${stripSlash2(input.gateway)}/api/analytics/install-started`,
13475
13424
  {
13476
13425
  method: "POST",
13477
- headers: { Accept: "application/json", "Content-Type": "application/json" },
13426
+ headers: {
13427
+ Accept: "application/json",
13428
+ "Content-Type": "application/json",
13429
+ "x-actionway-cli-version": getCliVersion(),
13430
+ ...input.clientContext ? localClientContextHeaders(input.clientContext) : {}
13431
+ },
13478
13432
  body: JSON.stringify({
13479
13433
  installSessionId: input.installSessionId,
13480
13434
  installSource: input.installSource
@@ -13498,7 +13452,12 @@ async function requestCliInstallSession(input) {
13498
13452
  url.toString(),
13499
13453
  {
13500
13454
  method: "GET",
13501
- headers: { Accept: "application/json", Authorization: `Bearer ${input.accessToken}` }
13455
+ headers: {
13456
+ Accept: "application/json",
13457
+ Authorization: `Bearer ${input.accessToken}`,
13458
+ "x-actionway-cli-version": getCliVersion(),
13459
+ ...input.clientContext ? localClientContextHeaders(input.clientContext) : {}
13460
+ }
13502
13461
  },
13503
13462
  SESSION_TIMEOUT_MS2,
13504
13463
  input.fetchImpl ?? fetch
@@ -13538,6 +13497,7 @@ async function connectInstallSession(input) {
13538
13497
  accessToken: credentials.access_token,
13539
13498
  installSessionId: input.installSessionId,
13540
13499
  installSource: input.installSource,
13500
+ ...input.clientContext ? { clientContext: input.clientContext } : {},
13541
13501
  fetchImpl
13542
13502
  });
13543
13503
  }
@@ -13552,12 +13512,14 @@ function failFromError3(err) {
13552
13512
  }
13553
13513
  fail({ code: "E_BACKEND", message: err instanceof Error ? err.message : String(err) });
13554
13514
  }
13555
- function registerInitCommand(program2) {
13515
+ function registerInitCommand(program2, getClientContext = () => ({ runtimeOs: "other" })) {
13556
13516
  const distribution = cliDistribution();
13557
13517
  program2.command("init").description(
13558
13518
  "Complete browser authentication and stage the Actionway Skill for your agent to install. The CLI never writes into an agent's own configuration directory."
13559
13519
  ).option("--gateway <url>", "Actionway public origin").option("--client-id <id>", "Actionway OAuth client id (must be paired with --issuer)").option("--issuer <url>", "Actionway OAuth issuer (must be paired with --client-id)").option("--timeout-seconds <n>", "how long to wait for browser authentication").option("--install-session-id <uuid>", "onboarding install session id").option("--no-browser", "print the authorize URL instead of opening a browser").addOption(new Option("--skill-only").hideHelp()).action(async (opts) => {
13560
13520
  try {
13521
+ const clientContext = getClientContext();
13522
+ const invocation = clientContext.agentHost ? `${distribution.commandName} --agent-host=${clientContext.agentHost}` : distribution.commandName;
13561
13523
  const skill = materializeSkill();
13562
13524
  if (opts.skillOnly) {
13563
13525
  ok({ skill });
@@ -13568,7 +13530,8 @@ function registerInitCommand(program2) {
13568
13530
  await captureInstallStarted({
13569
13531
  gateway: initGateway,
13570
13532
  installSessionId,
13571
- installSource
13533
+ installSource,
13534
+ clientContext
13572
13535
  });
13573
13536
  let loginStarted = false;
13574
13537
  if (!whoamiSnapshot()) {
@@ -13585,7 +13548,8 @@ function registerInitCommand(program2) {
13585
13548
  const account = await connectInstallSession({
13586
13549
  ...opts.gateway ? { explicitGateway: opts.gateway } : {},
13587
13550
  installSessionId,
13588
- installSource
13551
+ installSource,
13552
+ clientContext
13589
13553
  });
13590
13554
  const snapshot = whoamiSnapshot();
13591
13555
  ok({
@@ -13595,7 +13559,7 @@ function registerInitCommand(program2) {
13595
13559
  skill,
13596
13560
  workspace_id: account.workspaceId,
13597
13561
  ...snapshot?.user ? { user: snapshot.user } : {},
13598
- hint: `Actionway is ready. Install the skill from \`skill.source\` into your agent's skill directory, then run \`${distribution.commandName} --help\` to discover supported capabilities.`
13562
+ hint: `Actionway is ready. Install the skill from \`skill.source\` into your agent's skill directory, then run \`${invocation} --help\` to discover supported capabilities.`
13599
13563
  });
13600
13564
  } catch (error) {
13601
13565
  failFromError3(error);
@@ -13744,7 +13708,7 @@ function authFailure(err) {
13744
13708
  extra: { ...err.extra ?? {}, ...err.hint ? { hint: err.hint } : {} }
13745
13709
  });
13746
13710
  }
13747
- function getTransport(env = process.env, fetchImpl) {
13711
+ function getTransport(env = process.env, fetchImpl, clientContext) {
13748
13712
  return new Transport({
13749
13713
  baseUrl: resolveTransportBaseUrl(env),
13750
13714
  authHeader: async () => {
@@ -13766,6 +13730,7 @@ function getTransport(env = process.env, fetchImpl) {
13766
13730
  }
13767
13731
  return `Bearer ${creds.access_token}`;
13768
13732
  },
13733
+ ...clientContext ? { requestHeaders: localClientContextHeaders(clientContext) } : {},
13769
13734
  ...fetchImpl ? { fetchImpl } : {},
13770
13735
  onResponse: (res) => {
13771
13736
  const latest = res.headers.get("x-actionway-cli-latest");
@@ -13904,10 +13869,6 @@ function projectTypedToolCall(spec, commandParams, prepared) {
13904
13869
  }
13905
13870
 
13906
13871
  // src/index.ts
13907
- function getTransport2() {
13908
- return getTransport();
13909
- }
13910
- var actionDeps = { getTransport: getTransport2, projectToolCall: projectTypedToolCall };
13911
13872
  function buildProgram() {
13912
13873
  const distribution = cliDistribution();
13913
13874
  const version = readOwnVersion();
@@ -13915,7 +13876,13 @@ function buildProgram() {
13915
13876
  const program2 = new Command(distribution.commandName);
13916
13877
  program2.version(version);
13917
13878
  program2.description("Actionway CLI: run Actionway media and research capabilities from your local agent.");
13918
- registerInitCommand(program2);
13879
+ program2.addOption(
13880
+ new Option("--agent-host <host>", "declare the local Agent invoking this command").choices([...ACTIONWAY_AGENT_HOSTS])
13881
+ );
13882
+ const getClientContext = () => localClientContext(program2.opts().agentHost);
13883
+ const getTransport2 = () => getTransport(process.env, void 0, getClientContext());
13884
+ const actionDeps = { getTransport: getTransport2, projectToolCall: projectTypedToolCall };
13885
+ registerInitCommand(program2, getClientContext);
13919
13886
  registerDoctorCommand(program2);
13920
13887
  registerUpdateCommand(program2);
13921
13888
  registerDevelopmentStatusCommand(program2);
@@ -13942,7 +13909,7 @@ function buildProgram() {
13942
13909
  registerPollCommand(program2, getTransport2);
13943
13910
  registerKnowledgeCommands(program2, getTransport2);
13944
13911
  registerAssetCommands(program2, getTransport2);
13945
- registerStockCommands(program2, getTransport2);
13912
+ registerStockCommands(program2, actionDeps);
13946
13913
  return program2;
13947
13914
  }
13948
13915
  var invokedAsBin = isDirectExecution(import.meta.url);