@actionway/cli 0.18.6 → 0.18.7
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 +11 -1
- package/assets/skill/actionway/SKILL.md +11 -0
- package/dist/index.js +90 -39
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @actionway/cli — 本地端壳(bin: `actionway`)
|
|
2
2
|
|
|
3
3
|
actionway CLI 的本地端壳(迁移文档 `docs/DL_TO_ACTIONWAY_CLI_MIGRATION.md` §3.2 / §3.4):
|
|
4
|
-
终端用户在自己机器上的 Coding Agent(Codex / Claude Code)通过它调用 Actionway 能力。
|
|
4
|
+
终端用户在自己机器上的 Coding Agent(Codex / Claude Code / WorkBuddy)通过它调用 Actionway 能力。
|
|
5
5
|
|
|
6
6
|
## 安装
|
|
7
7
|
|
|
@@ -38,6 +38,16 @@ actionway-dev status
|
|
|
38
38
|
|
|
39
39
|
`actionway-dev update` 只读取和更新 `@actionway/cli-dev@latest`。每个 dev npm 版本包含不可变 source SHA 与 Actions run metadata;同一 tarball 也保存在私有 GitHub prerelease,后者仅用于内部审计和精确回滚,普通安装不需要 GitHub 账号。
|
|
40
40
|
|
|
41
|
+
本地 Agent 在每条 Actionway 命令通过全局参数声明当前宿主:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
actionway --agent-host=codex tools search "generate a product image"
|
|
45
|
+
actionway --agent-host=claude_code tools search "generate a product image"
|
|
46
|
+
actionway --agent-host=workbuddy tools search "generate a product image"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
不带 `--agent-host` 表示用户直接使用 CLI。该声明不写入共享凭据,所以同一个用户和全局 CLI 可以交替被多个 Agent 使用。CLI 同时从每次进程的 Node.js 运行环境识别 Windows、macOS、WSL 或 Linux;这些字段只作为 Site 侧产品分析事件属性,不参与鉴权、计费或 Gateway 路由。
|
|
50
|
+
|
|
41
51
|
- **auth 唯一途径:Clerk OAuth(PKCE)**。issuer / client_id 运行时从
|
|
42
52
|
`{public origin}/api/auth/cli-config` 发现;浏览器授权走随机 `127.0.0.1` 回调端口;
|
|
43
53
|
凭据存 `~/.actionway/credentials.json`(POSIX 上为 0600 owner-only 文件;
|
|
@@ -9,6 +9,17 @@ metadata:
|
|
|
9
9
|
|
|
10
10
|
Use the installed `actionway` CLI and its server-backed Capability Registry as the source of truth. Do not memorize a complete command catalog, Schema, provider list, or price table in this Skill.
|
|
11
11
|
|
|
12
|
+
## Declare this Agent
|
|
13
|
+
|
|
14
|
+
Use one invocation prefix for every Actionway command in this Agent session, including update, authentication, discovery, calls, and waits:
|
|
15
|
+
|
|
16
|
+
- Codex: `actionway --agent-host=codex`
|
|
17
|
+
- Claude Code: `actionway --agent-host=claude_code`
|
|
18
|
+
- WorkBuddy: `actionway --agent-host=workbuddy`
|
|
19
|
+
- A human directly using the CLI: `actionway` without `--agent-host`
|
|
20
|
+
|
|
21
|
+
Where the instructions below show `actionway ...`, insert this Agent's `--agent-host` immediately after `actionway`. Do not persist one host in shared credentials: the same user and global CLI may be used by multiple Agents.
|
|
22
|
+
|
|
12
23
|
## Prepare
|
|
13
24
|
|
|
14
25
|
1. Run Actionway commands with network access and permission to read `~/.actionway`. On Windows, use the generated `actionway.cmd` entrypoint when PowerShell policy blocks `actionway.ps1`. If setup or update fails, run `actionway.cmd doctor` on Windows or `actionway doctor` elsewhere from the host terminal and preserve its failed check IDs; do not weaken registry, proxy, CA, PATH, or PowerShell policy without user approval. If a sandboxed command reports `E_NOT_AUTHENTICATED` for an already logged-in user, rerun the same command with host permission before starting login again.
|
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,
|
|
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,
|
|
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,
|
|
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 =
|
|
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,
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
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
|
-
|
|
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
|
|
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,
|
|
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
|
|
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,
|
|
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,7 +11453,7 @@ 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 },
|
|
11456
|
+
const outcome = await executeKnowledgeSearch(input, { dryRun: rawOpts.dryRun === true }, getTransport2);
|
|
11453
11457
|
emitOutcome(outcome);
|
|
11454
11458
|
});
|
|
11455
11459
|
}
|
|
@@ -12007,7 +12011,7 @@ async function searchFanout(enabled, opts, limit, searchFn) {
|
|
|
12007
12011
|
}
|
|
12008
12012
|
return { results: mergeResults(perProviderResults, limit), queried: [...enabled], failed };
|
|
12009
12013
|
}
|
|
12010
|
-
function registerStockSearch(parent,
|
|
12014
|
+
function registerStockSearch(parent, getTransport2) {
|
|
12011
12015
|
parent.command("search").description(
|
|
12012
12016
|
"Sequential-fallback search across providers (Pexels -> Pixabay -> Openverse). Use --mode=fanout for parallel."
|
|
12013
12017
|
).addHelpText(
|
|
@@ -12079,7 +12083,7 @@ function registerStockSearch(parent, getTransport3) {
|
|
|
12079
12083
|
};
|
|
12080
12084
|
const jobRef = randomUUID4();
|
|
12081
12085
|
try {
|
|
12082
|
-
const transport =
|
|
12086
|
+
const transport = getTransport2();
|
|
12083
12087
|
const searchFn = (name, o) => {
|
|
12084
12088
|
const provider = ALL_PROVIDERS[name];
|
|
12085
12089
|
if (!provider) throw new Error(`unknown stock provider: ${name}`);
|
|
@@ -12117,9 +12121,9 @@ function registerStockSearch(parent, getTransport3) {
|
|
|
12117
12121
|
}
|
|
12118
12122
|
|
|
12119
12123
|
// ../cli-core/src/commands/stock.ts
|
|
12120
|
-
function registerStockCommands(program2,
|
|
12124
|
+
function registerStockCommands(program2, getTransport2) {
|
|
12121
12125
|
const stock = program2.command("stock").description("Search and download public stock media (Pexels / Pixabay / Openverse) for b-roll.");
|
|
12122
|
-
registerStockSearch(stock,
|
|
12126
|
+
registerStockSearch(stock, getTransport2);
|
|
12123
12127
|
registerStockDownload(stock);
|
|
12124
12128
|
}
|
|
12125
12129
|
|
|
@@ -13092,19 +13096,19 @@ function accountEndpoint(path, options) {
|
|
|
13092
13096
|
const query = parameters.toString();
|
|
13093
13097
|
return `v1/account/${path}${query ? `?${query}` : ""}`;
|
|
13094
13098
|
}
|
|
13095
|
-
async function read(endpoint,
|
|
13099
|
+
async function read(endpoint, getTransport2) {
|
|
13096
13100
|
try {
|
|
13097
|
-
ok(await
|
|
13101
|
+
ok(await getTransport2().getBusiness(endpoint, { retries: 1 }));
|
|
13098
13102
|
} catch (error) {
|
|
13099
13103
|
failAccount(error);
|
|
13100
13104
|
}
|
|
13101
13105
|
}
|
|
13102
|
-
function registerAccountCommands(program2,
|
|
13106
|
+
function registerAccountCommands(program2, getTransport2) {
|
|
13103
13107
|
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),
|
|
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),
|
|
13106
|
-
account.command("wallet").description("Show the current available and held Actionway USD wallet balance.").action(() => read("v1/account/wallet",
|
|
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),
|
|
13108
|
+
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));
|
|
13109
|
+
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));
|
|
13110
|
+
account.command("wallet").description("Show the current available and held Actionway USD wallet balance.").action(() => read("v1/account/wallet", getTransport2));
|
|
13111
|
+
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
13112
|
}
|
|
13109
13113
|
|
|
13110
13114
|
// src/commands/doctor.ts
|
|
@@ -13435,6 +13439,35 @@ function materializeSkill(options = {}) {
|
|
|
13435
13439
|
};
|
|
13436
13440
|
}
|
|
13437
13441
|
|
|
13442
|
+
// src/lib/client-context.ts
|
|
13443
|
+
var ACTIONWAY_AGENT_HOST_HEADER = "x-actionway-agent-host";
|
|
13444
|
+
var ACTIONWAY_RUNTIME_OS_HEADER = "x-actionway-runtime-os";
|
|
13445
|
+
var ACTIONWAY_AGENT_HOSTS = ["codex", "claude_code", "workbuddy"];
|
|
13446
|
+
function isActionwayAgentHost(value) {
|
|
13447
|
+
return typeof value === "string" && ACTIONWAY_AGENT_HOSTS.includes(value);
|
|
13448
|
+
}
|
|
13449
|
+
function detectRuntimeOs(platform = process.platform, env = process.env) {
|
|
13450
|
+
if (platform === "win32") return "windows";
|
|
13451
|
+
if (platform === "darwin") return "macos";
|
|
13452
|
+
if (platform === "linux") {
|
|
13453
|
+
if ((env.WSL_DISTRO_NAME ?? "").trim() || (env.WSL_INTEROP ?? "").trim()) return "wsl";
|
|
13454
|
+
return "linux";
|
|
13455
|
+
}
|
|
13456
|
+
return "other";
|
|
13457
|
+
}
|
|
13458
|
+
function localClientContext(agentHost, platform = process.platform, env = process.env) {
|
|
13459
|
+
return {
|
|
13460
|
+
...isActionwayAgentHost(agentHost) ? { agentHost } : {},
|
|
13461
|
+
runtimeOs: detectRuntimeOs(platform, env)
|
|
13462
|
+
};
|
|
13463
|
+
}
|
|
13464
|
+
function localClientContextHeaders(context) {
|
|
13465
|
+
return {
|
|
13466
|
+
...context.agentHost ? { [ACTIONWAY_AGENT_HOST_HEADER]: context.agentHost } : {},
|
|
13467
|
+
[ACTIONWAY_RUNTIME_OS_HEADER]: context.runtimeOs
|
|
13468
|
+
};
|
|
13469
|
+
}
|
|
13470
|
+
|
|
13438
13471
|
// src/lib/install-session.ts
|
|
13439
13472
|
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
13473
|
var ANALYTICS_TIMEOUT_MS = 3e3;
|
|
@@ -13474,7 +13507,12 @@ async function captureInstallStarted(input) {
|
|
|
13474
13507
|
`${stripSlash2(input.gateway)}/api/analytics/install-started`,
|
|
13475
13508
|
{
|
|
13476
13509
|
method: "POST",
|
|
13477
|
-
headers: {
|
|
13510
|
+
headers: {
|
|
13511
|
+
Accept: "application/json",
|
|
13512
|
+
"Content-Type": "application/json",
|
|
13513
|
+
"x-actionway-cli-version": getCliVersion(),
|
|
13514
|
+
...input.clientContext ? localClientContextHeaders(input.clientContext) : {}
|
|
13515
|
+
},
|
|
13478
13516
|
body: JSON.stringify({
|
|
13479
13517
|
installSessionId: input.installSessionId,
|
|
13480
13518
|
installSource: input.installSource
|
|
@@ -13498,7 +13536,12 @@ async function requestCliInstallSession(input) {
|
|
|
13498
13536
|
url.toString(),
|
|
13499
13537
|
{
|
|
13500
13538
|
method: "GET",
|
|
13501
|
-
headers: {
|
|
13539
|
+
headers: {
|
|
13540
|
+
Accept: "application/json",
|
|
13541
|
+
Authorization: `Bearer ${input.accessToken}`,
|
|
13542
|
+
"x-actionway-cli-version": getCliVersion(),
|
|
13543
|
+
...input.clientContext ? localClientContextHeaders(input.clientContext) : {}
|
|
13544
|
+
}
|
|
13502
13545
|
},
|
|
13503
13546
|
SESSION_TIMEOUT_MS2,
|
|
13504
13547
|
input.fetchImpl ?? fetch
|
|
@@ -13538,6 +13581,7 @@ async function connectInstallSession(input) {
|
|
|
13538
13581
|
accessToken: credentials.access_token,
|
|
13539
13582
|
installSessionId: input.installSessionId,
|
|
13540
13583
|
installSource: input.installSource,
|
|
13584
|
+
...input.clientContext ? { clientContext: input.clientContext } : {},
|
|
13541
13585
|
fetchImpl
|
|
13542
13586
|
});
|
|
13543
13587
|
}
|
|
@@ -13552,12 +13596,14 @@ function failFromError3(err) {
|
|
|
13552
13596
|
}
|
|
13553
13597
|
fail({ code: "E_BACKEND", message: err instanceof Error ? err.message : String(err) });
|
|
13554
13598
|
}
|
|
13555
|
-
function registerInitCommand(program2) {
|
|
13599
|
+
function registerInitCommand(program2, getClientContext = () => ({ runtimeOs: "other" })) {
|
|
13556
13600
|
const distribution = cliDistribution();
|
|
13557
13601
|
program2.command("init").description(
|
|
13558
13602
|
"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
13603
|
).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
13604
|
try {
|
|
13605
|
+
const clientContext = getClientContext();
|
|
13606
|
+
const invocation = clientContext.agentHost ? `${distribution.commandName} --agent-host=${clientContext.agentHost}` : distribution.commandName;
|
|
13561
13607
|
const skill = materializeSkill();
|
|
13562
13608
|
if (opts.skillOnly) {
|
|
13563
13609
|
ok({ skill });
|
|
@@ -13568,7 +13614,8 @@ function registerInitCommand(program2) {
|
|
|
13568
13614
|
await captureInstallStarted({
|
|
13569
13615
|
gateway: initGateway,
|
|
13570
13616
|
installSessionId,
|
|
13571
|
-
installSource
|
|
13617
|
+
installSource,
|
|
13618
|
+
clientContext
|
|
13572
13619
|
});
|
|
13573
13620
|
let loginStarted = false;
|
|
13574
13621
|
if (!whoamiSnapshot()) {
|
|
@@ -13585,7 +13632,8 @@ function registerInitCommand(program2) {
|
|
|
13585
13632
|
const account = await connectInstallSession({
|
|
13586
13633
|
...opts.gateway ? { explicitGateway: opts.gateway } : {},
|
|
13587
13634
|
installSessionId,
|
|
13588
|
-
installSource
|
|
13635
|
+
installSource,
|
|
13636
|
+
clientContext
|
|
13589
13637
|
});
|
|
13590
13638
|
const snapshot = whoamiSnapshot();
|
|
13591
13639
|
ok({
|
|
@@ -13595,7 +13643,7 @@ function registerInitCommand(program2) {
|
|
|
13595
13643
|
skill,
|
|
13596
13644
|
workspace_id: account.workspaceId,
|
|
13597
13645
|
...snapshot?.user ? { user: snapshot.user } : {},
|
|
13598
|
-
hint: `Actionway is ready. Install the skill from \`skill.source\` into your agent's skill directory, then run \`${
|
|
13646
|
+
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
13647
|
});
|
|
13600
13648
|
} catch (error) {
|
|
13601
13649
|
failFromError3(error);
|
|
@@ -13744,7 +13792,7 @@ function authFailure(err) {
|
|
|
13744
13792
|
extra: { ...err.extra ?? {}, ...err.hint ? { hint: err.hint } : {} }
|
|
13745
13793
|
});
|
|
13746
13794
|
}
|
|
13747
|
-
function getTransport(env = process.env, fetchImpl) {
|
|
13795
|
+
function getTransport(env = process.env, fetchImpl, clientContext) {
|
|
13748
13796
|
return new Transport({
|
|
13749
13797
|
baseUrl: resolveTransportBaseUrl(env),
|
|
13750
13798
|
authHeader: async () => {
|
|
@@ -13766,6 +13814,7 @@ function getTransport(env = process.env, fetchImpl) {
|
|
|
13766
13814
|
}
|
|
13767
13815
|
return `Bearer ${creds.access_token}`;
|
|
13768
13816
|
},
|
|
13817
|
+
...clientContext ? { requestHeaders: localClientContextHeaders(clientContext) } : {},
|
|
13769
13818
|
...fetchImpl ? { fetchImpl } : {},
|
|
13770
13819
|
onResponse: (res) => {
|
|
13771
13820
|
const latest = res.headers.get("x-actionway-cli-latest");
|
|
@@ -13904,10 +13953,6 @@ function projectTypedToolCall(spec, commandParams, prepared) {
|
|
|
13904
13953
|
}
|
|
13905
13954
|
|
|
13906
13955
|
// src/index.ts
|
|
13907
|
-
function getTransport2() {
|
|
13908
|
-
return getTransport();
|
|
13909
|
-
}
|
|
13910
|
-
var actionDeps = { getTransport: getTransport2, projectToolCall: projectTypedToolCall };
|
|
13911
13956
|
function buildProgram() {
|
|
13912
13957
|
const distribution = cliDistribution();
|
|
13913
13958
|
const version = readOwnVersion();
|
|
@@ -13915,7 +13960,13 @@ function buildProgram() {
|
|
|
13915
13960
|
const program2 = new Command(distribution.commandName);
|
|
13916
13961
|
program2.version(version);
|
|
13917
13962
|
program2.description("Actionway CLI: run Actionway media and research capabilities from your local agent.");
|
|
13918
|
-
|
|
13963
|
+
program2.addOption(
|
|
13964
|
+
new Option("--agent-host <host>", "declare the local Agent invoking this command").choices([...ACTIONWAY_AGENT_HOSTS])
|
|
13965
|
+
);
|
|
13966
|
+
const getClientContext = () => localClientContext(program2.opts().agentHost);
|
|
13967
|
+
const getTransport2 = () => getTransport(process.env, void 0, getClientContext());
|
|
13968
|
+
const actionDeps = { getTransport: getTransport2, projectToolCall: projectTypedToolCall };
|
|
13969
|
+
registerInitCommand(program2, getClientContext);
|
|
13919
13970
|
registerDoctorCommand(program2);
|
|
13920
13971
|
registerUpdateCommand(program2);
|
|
13921
13972
|
registerDevelopmentStatusCommand(program2);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@actionway/cli",
|
|
3
|
-
"version": "0.18.
|
|
4
|
-
"description": "actionway CLI 的本地端壳:Clerk OAuth 鉴权 + cli-core 共享命令面 + init / update / skill 物化 / 版本三链路(终端用户本地 Codex / Claude Code 使用)",
|
|
3
|
+
"version": "0.18.7",
|
|
4
|
+
"description": "actionway CLI 的本地端壳:Clerk OAuth 鉴权 + cli-core 共享命令面 + init / update / skill 物化 / 版本三链路(终端用户本地 Codex / Claude Code / WorkBuddy 使用)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"actionway": "./dist/index.js"
|