@itpay/cli 2.1.45 → 2.1.46
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 +10 -16
- package/dist/src/commands/install.js +4 -4
- package/dist/src/commands/readyz.js +3 -5
- package/dist/src/commands/setup.js +37 -0
- package/dist/src/commands/skill.js +23 -6
- package/dist/src/main.js +21 -19
- package/dist/src/state/account_auth.js +9 -4
- package/dist/src/state/config.js +1 -1
- package/docs/agent/buyer/install-and-setup.json +12 -22
- package/docs/cli-reference/commands/install.md +6 -6
- package/docs/cli-reference/commands/readyz.md +6 -6
- package/docs/cli-reference/commands/setup.md +13 -0
- package/docs/cli-reference/commands/skill.md +8 -0
- package/docs/cli-reference/index.md +3 -1
- package/package.json +2 -2
- package/skills/itpay/SKILL.md +4 -2
package/README.md
CHANGED
|
@@ -6,26 +6,16 @@ The official V3 CLI and the single ItPay entry point for services, purchases, ac
|
|
|
6
6
|
|
|
7
7
|
`itpay` is the only public CLI entry point, and `$itpay` is its user-facing Skill invocation. The Agent first distinguishes a new service request, previously purchased content, order history, or a refund. Seller workflows use the existing `itpay sell` entry point.
|
|
8
8
|
|
|
9
|
+
Follow the official setup link for the authorized channel and matching Backend. Standard npm can use a host-managed persistent tool location or a global prefix; retain one exact executable.
|
|
10
|
+
|
|
9
11
|
```bash
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
itpay --agent-type codex-desktop readyz --json
|
|
13
|
-
# execute the returned next.command until the typed Skill is loaded
|
|
12
|
+
itpay setup --agent-type <actual_type> --json
|
|
13
|
+
# read and enable the same-package Skill returned by setup
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
> 安装或更新官方 `@itpay/cli`。从 `itpay install --json` 开始,选择你真实
|
|
19
|
-
> 所在的平台,完整执行 iTPay 返回的每个 `next.command` 并读取内置 Skill。
|
|
20
|
-
> 初始化后,根据我的自然语言需求自行使用 iTPay,不要让我运行命令,也不要向
|
|
21
|
-
> 我讲解命令、内部 ID 或技术步骤。只有需要我选择、授权、付款、提供联系方式
|
|
22
|
-
> 或确认退款时,才用通俗语言询问我;展示官方操作入口后停止等待。不要猜命令、
|
|
23
|
-
> 切换身份或环境、绕过授权或重复创建资源。准备完成后只回复“iTPay 已就绪”。
|
|
24
|
-
|
|
25
|
-
Use a separate test prompt to set the exact official Dev Backend. Never put a
|
|
26
|
-
Dev override in the public install prompt.
|
|
16
|
+
使用宿主允许的持久安装方式运行官方 ItPay CLI,不要求全局安装。固定本次安装的入口、实际 Agent Type 和 Backend。首次使用或更新后运行 setup;setup_ready 证明设备准备完成,账号授权状态单独列出。完整读取当前包 Skill,并按宿主方式保存启用;同版本已读且已启用时无需重复。业务请求需要真人授权时使用返回的官方入口,不以安装授权代替购买同意。安装位置变化不要求清除设备身份。
|
|
27
17
|
|
|
28
|
-
The CLI defaults to the production Backend `https://app.itpay.ai`. Explicit
|
|
18
|
+
The CLI defaults to the production Backend `https://app.itpay.ai`. Explicit test runs may set `ITPAY_BACKEND_URL=https://sandbox.itpay.ai` or `https://dev.itpay.ai`; nonofficial Backend URLs are rejected before network or local state access.
|
|
29
19
|
|
|
30
20
|
## Output Contract
|
|
31
21
|
|
|
@@ -134,3 +124,7 @@ Source boundaries:
|
|
|
134
124
|
Use `itpay services run <service_id> --input-json ./input.json --json` for a published workflow. The input file must contain a JSON object matching the service input schema. With no input file, the CLI reports required fields and a command to continue the same execution.
|
|
135
125
|
|
|
136
126
|
Use `itpay services run <service_id> --execution <execution_id> --json` to resume. At payment, the CLI uses the existing Checkout QR/card handoff. The backend continues after verified payment even if the CLI exits. `--timeout <seconds>` controls initial status polling (default 120, maximum 600). Use existing order/refund commands for refund requests; an application is not a successful refund until its final status confirms success.
|
|
127
|
+
|
|
128
|
+
## Agent preparation
|
|
129
|
+
|
|
130
|
+
Install the official package using standard npm in one host-permitted persistent tool location or a global prefix. Retain the exact callable entry. Run `itpay setup --agent-type <actual_type> --json`, then read and enable its same-package Skill before business commands. Account login is separate and occurs only when needed. See [setup](docs/cli-reference/commands/setup.md).
|
|
@@ -30,7 +30,7 @@ export function runInstall(target, options = {}) {
|
|
|
30
30
|
writeCommandEnvelope({
|
|
31
31
|
status: "install_targets",
|
|
32
32
|
result: { agent_types: agentTypes },
|
|
33
|
-
instruction: "识别当前真实运行平台,从 result.agent_types 选择对应 agent_type,并由 Agent 自行运行 itpay
|
|
33
|
+
instruction: "识别当前真实运行平台,从 result.agent_types 选择对应 agent_type,并由 Agent 自行运行 itpay setup --agent-type <agent_type> --json;不要让用户运行命令,也不要临时更换 Agent Type。",
|
|
34
34
|
next: null,
|
|
35
35
|
recovery: [{ command: "itpay docs show install-and-setup", reason: "查看安装与环境说明" }],
|
|
36
36
|
}, {
|
|
@@ -51,13 +51,13 @@ export function runInstall(target, options = {}) {
|
|
|
51
51
|
},
|
|
52
52
|
instruction: INSTRUCTIONS[normalized] + (normalized.startsWith("codex-") ? ` ${CODEX_WAIT_GUIDANCE}` : ""),
|
|
53
53
|
next: {
|
|
54
|
-
command: `itpay --agent-type ${normalized}
|
|
55
|
-
reason: "
|
|
54
|
+
command: `itpay --agent-type ${normalized} setup --json`,
|
|
55
|
+
reason: "准备当前宿主并确认设备与账号状态",
|
|
56
56
|
},
|
|
57
57
|
recovery: [],
|
|
58
58
|
}, options);
|
|
59
59
|
}
|
|
60
|
-
function isInstallAgentType(value) {
|
|
60
|
+
export function isInstallAgentType(value) {
|
|
61
61
|
return INSTALL_AGENT_TYPES.includes(value);
|
|
62
62
|
}
|
|
63
63
|
function installDefinition(agentType) {
|
|
@@ -7,12 +7,10 @@ export async function runReadyz(backend, options = {}) {
|
|
|
7
7
|
writeCommandEnvelope({
|
|
8
8
|
status: response.status,
|
|
9
9
|
result: { backend: "available", backend_url: backendURL, environment, ...(options.agentType ? { agent_type: options.agentType } : {}) },
|
|
10
|
-
instruction: environment === "development"
|
|
11
|
-
? `ItPay 开发环境 ${backendURL} 可用。只证明后端存活。尚未读此次包 Skill 时完整读取;已读同版本则无需重复,继续设备状态检查;后续必须执行返回的完整命令并保持同一 Backend。`
|
|
12
|
-
: "ItPay 可用。只证明后端存活。尚未读此次包 Skill 时完整读取;已读同版本则无需重复,继续设备状态检查;不自动登录或开始业务。",
|
|
10
|
+
instruction: `ItPay ${environment === "development" ? "开发" : "正式"}环境 ${backendURL} 可用。只证明后端存活;首次使用或更新后运行 setup,不自动登录或开始业务。`,
|
|
13
11
|
next: options.agentType
|
|
14
|
-
? { command: "itpay
|
|
15
|
-
: { command: "itpay install --json", reason: "
|
|
12
|
+
? { command: "itpay setup --json", reason: "确认同一 Backend 和宿主的设备及账号准备状态" }
|
|
13
|
+
: { command: "itpay install --json", reason: "识别实际宿主类型后执行 setup" },
|
|
16
14
|
recovery: [],
|
|
17
15
|
}, options);
|
|
18
16
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { requirePlatformCompatibility } from "./compatibility.js";
|
|
2
|
+
import { agentAuth } from "../state/account_auth.js";
|
|
3
|
+
import { CLI_VERSION } from "../state/config.js";
|
|
4
|
+
import { CommandContractError, writeCommandEnvelope } from "./guidance.js";
|
|
5
|
+
import { INSTALL_AGENT_TYPES, isInstallAgentType } from "./install.js";
|
|
6
|
+
import { packagedSkill } from "./skill.js";
|
|
7
|
+
export function validateSetup(agentType) {
|
|
8
|
+
if (!agentType || !isInstallAgentType(agentType)) {
|
|
9
|
+
throw new CommandContractError("unsupported_agent_type", "setup requires a supported actual Agent Type", `准备未完成:宿主类型。可用类型:${INSTALL_AGENT_TYPES.join(", ")}。`, [{ command: "itpay install --json", reason: "识别实际宿主类型" }]);
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
return packagedSkill().path;
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
const cause = error && typeof error === "object" && "code" in error && typeof error.code === "string"
|
|
16
|
+
? error.code : "invalid_packaged_skill";
|
|
17
|
+
throw new CommandContractError("packaged_skill_unavailable", "current package Skill is missing or invalid", "准备未完成:同包 Skill 不可读取。按返回原因确认宿主正常读取权限或恢复原位置的完整官方包。", [], undefined, { failure_stage: "packaged_skill", cause_code: cause });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export async function runSetup(backend, config, skillPath, options = {}) {
|
|
21
|
+
await requirePlatformCompatibility(backend);
|
|
22
|
+
const account = await agentAuth("status", config.baseURL, backend, undefined, undefined, { readOnlyStatus: true });
|
|
23
|
+
if (!account || typeof account !== "object" || !("status" in account)
|
|
24
|
+
|| (account.status !== "authenticated" && account.status !== "login_required")) {
|
|
25
|
+
const detail = account && typeof account === "object" && "result" in account
|
|
26
|
+
&& account.result && typeof account.result === "object" && !Array.isArray(account.result)
|
|
27
|
+
? account.result : {};
|
|
28
|
+
throw new CommandContractError("setup_status_unconfirmed", "device or account status is unconfirmed", "设备或账号状态尚未确认,本次准备未完成。保留现有身份,按返回的原因处理。", [], undefined, { failure_stage: "account_status", ...detail });
|
|
29
|
+
}
|
|
30
|
+
writeCommandEnvelope({ status: "setup_ready", result: {
|
|
31
|
+
cli_version: CLI_VERSION, backend_url: config.baseURL, agent_type: config.agentType,
|
|
32
|
+
device_status: "ready", account_status: account.status, skill_path: skillPath, skill_version: CLI_VERSION,
|
|
33
|
+
}, instruction: account.status === "authenticated"
|
|
34
|
+
? "设备已准备好,已有账号授权可继续使用。读取并启用下方 Skill 后,按用户需求开始。"
|
|
35
|
+
: "设备已准备好。读取并启用下方 Skill 后即可开始;需要账号的功能会再请用户授权。",
|
|
36
|
+
next: null, recovery: [] }, options);
|
|
37
|
+
}
|
|
@@ -11,12 +11,20 @@ export function runSkillShow(name, options = {}) {
|
|
|
11
11
|
if (normalized !== ITPAY_SKILL) {
|
|
12
12
|
throw new CommandContractError("skill_not_found", `skill not found: ${name}`, `当前 CLI 只内置 ${ITPAY_SKILL};不要猜测 Skill 名称。`, [{ command: `itpay skill show ${ITPAY_SKILL} --json`, reason: "读取完整 ItPay Skill" }]);
|
|
13
13
|
}
|
|
14
|
+
const original = packagedSkill();
|
|
14
15
|
let content;
|
|
15
16
|
try {
|
|
16
17
|
content = readFileSync(findSkillPath(), "utf8");
|
|
17
18
|
}
|
|
18
|
-
catch {
|
|
19
|
-
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (process.env.ITPAY_CLI_SKILLS_DIR) {
|
|
21
|
+
const cause = error && typeof error === "object" && "code" in error ? String(error.code) : "read_failed";
|
|
22
|
+
throw new CommandContractError("skill_override_unavailable", "configured Skill cannot be read", "覆盖路径不可读取;当前包原文可用。直接读取 result.skill_path 并按宿主方式启用,不另装全局包。", [], undefined, { skill_path: original.path, cause_code: cause });
|
|
23
|
+
}
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
if (content !== original.content) {
|
|
27
|
+
throw new CommandContractError("skill_override_mismatch", "configured Skill differs from the current package", "覆盖路径中的 Skill 不是当前包原文。直接读取 result.skill_path 并按宿主方式启用,不使用陈旧或改写内容。", [], undefined, { skill_path: original.path });
|
|
20
28
|
}
|
|
21
29
|
validateSkill(content);
|
|
22
30
|
const agentType = options.agentType ?? declaredAgentType();
|
|
@@ -27,8 +35,8 @@ export function runSkillShow(name, options = {}) {
|
|
|
27
35
|
result: { skill: ITPAY_SKILL, content },
|
|
28
36
|
instruction: agentType
|
|
29
37
|
? agentType === "workbuddy"
|
|
30
|
-
? "
|
|
31
|
-
:
|
|
38
|
+
? "完整读取原文并按宿主技能方式保存启用;按用户意图选择第一条业务命令。保持 workbuddy、同一入口和 Backend;只有实际持久化操作被拒时才沿宿主正式流程申请所需权限,拒绝后报告受阻操作,不删除 identity。"
|
|
39
|
+
: `完整读取原文并按宿主技能方式保存启用;把自己视为服务用户的代理,先理解用户意图和解释用户权益,再选择购买、已购内容、订单或退款对应的第一条命令。当前 Agent Type 是 ${agentType},后续命令保持不变。`
|
|
32
40
|
: "完整读取并遵守 Skill;先如实选择当前运行环境对应的 Agent Type。",
|
|
33
41
|
next: agentType
|
|
34
42
|
? null
|
|
@@ -41,14 +49,23 @@ export function runSkillShow(name, options = {}) {
|
|
|
41
49
|
plainResult: content.replace(/\r\n/g, "\n").replace(/\n$/, "").split("\n"),
|
|
42
50
|
});
|
|
43
51
|
}
|
|
44
|
-
function
|
|
45
|
-
|
|
52
|
+
export function packagedSkill() {
|
|
53
|
+
const path = findSkillPath(false);
|
|
54
|
+
const content = readFileSync(path, "utf8");
|
|
55
|
+
validateSkill(content);
|
|
56
|
+
return { path, content };
|
|
57
|
+
}
|
|
58
|
+
function findSkillPath(allowOverride = true) {
|
|
59
|
+
if (allowOverride && process.env.ITPAY_CLI_SKILLS_DIR) {
|
|
46
60
|
const configuredRoot = resolve(process.env.ITPAY_CLI_SKILLS_DIR);
|
|
47
61
|
const directPath = resolve(configuredRoot, "SKILL.md");
|
|
48
62
|
if (existsSync(directPath))
|
|
49
63
|
return directPath;
|
|
50
64
|
return resolve(configuredRoot, ITPAY_SKILL, "SKILL.md");
|
|
51
65
|
}
|
|
66
|
+
const bundlePath = resolve(commandDir, "skills", ITPAY_SKILL, "SKILL.md");
|
|
67
|
+
if (existsSync(bundlePath))
|
|
68
|
+
return bundlePath;
|
|
52
69
|
const packagePath = resolve(commandDir, "..", "..", "..", "skills", ITPAY_SKILL, "SKILL.md");
|
|
53
70
|
if (existsSync(packagePath))
|
|
54
71
|
return packagePath;
|
package/dist/src/main.js
CHANGED
|
@@ -7,12 +7,13 @@ import { runServicesRun } from "./commands/services.js";
|
|
|
7
7
|
// services/backend/internal/httpapi/handlers/*.go. Commands only
|
|
8
8
|
// orchestrate; HTTP and rendering live in src/client and src/render.
|
|
9
9
|
import { Command } from "commander";
|
|
10
|
-
import { BackendOverrideError, API_CONTRACT_REVISION, CLI_VERSION,
|
|
10
|
+
import { BackendOverrideError, API_CONTRACT_REVISION, CLI_VERSION, loadConfig, cartSessionPath, newBackendClient } from "./state/config.js";
|
|
11
11
|
import { DeviceAuthority, DeviceAuthorizationError, DeviceStateError } from "./state/device_authority.js";
|
|
12
12
|
import { CartSession } from "./state/cart_session.js";
|
|
13
13
|
import { defaultHostForAgentType, normalizeHost, validateContext } from "./state/client_context.js";
|
|
14
14
|
import { HttpError } from "./client/http.js";
|
|
15
15
|
import { HttpTransportError } from "./client/transport.js";
|
|
16
|
+
import { runSetup, validateSetup } from "./commands/setup.js";
|
|
16
17
|
import { runReadyz } from "./commands/readyz.js";
|
|
17
18
|
import { runBuy } from "./commands/buy.js";
|
|
18
19
|
import { runCatalogList } from "./commands/catalog.js";
|
|
@@ -39,9 +40,9 @@ program
|
|
|
39
40
|
.version(CLI_VERSION)
|
|
40
41
|
.addHelpText("after", `
|
|
41
42
|
Agent quick start:
|
|
42
|
-
1.
|
|
43
|
-
2.
|
|
44
|
-
3. Read
|
|
43
|
+
1. Use one official package in the host's permitted persistent npm location.
|
|
44
|
+
2. Run: itpay setup --agent-type <actual_type> --json
|
|
45
|
+
3. Read and enable the returned same-package Skill before business commands.
|
|
45
46
|
|
|
46
47
|
Common human intents:
|
|
47
48
|
New service or query catalog list
|
|
@@ -251,22 +252,9 @@ function docsErrorFallback(jsonOutput) {
|
|
|
251
252
|
jsonOutput,
|
|
252
253
|
code: "docs_unavailable",
|
|
253
254
|
instruction: "内置文档缺失或损坏;通过当前分发方式恢复同版本 CLI 后重试。",
|
|
254
|
-
recovery: [
|
|
255
|
+
recovery: [],
|
|
255
256
|
};
|
|
256
257
|
}
|
|
257
|
-
function distributionUpgradeAction(version) {
|
|
258
|
-
switch (cliDistribution()) {
|
|
259
|
-
case "openclaw-skill-bundle":
|
|
260
|
-
return { command: "openclaw skills update itpay", reason: `更新包含 ItPay CLI ${version} 的 Skill bundle` };
|
|
261
|
-
case "kimi-plugin-bundle":
|
|
262
|
-
return {
|
|
263
|
-
command: "/plugins install https://github.com/itpay-ai/itpay-plugin-kimi-work",
|
|
264
|
-
reason: `更新包含 ItPay CLI ${version} 的 Kimi plugin`,
|
|
265
|
-
};
|
|
266
|
-
default:
|
|
267
|
-
return { command: `npm install -g @itpay/cli@${version}`, reason: "恢复当前 CLI 版本的完整安装包" };
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
258
|
program
|
|
271
259
|
.command("readyz")
|
|
272
260
|
.description("Probe the V3 backend readiness endpoint")
|
|
@@ -290,6 +278,20 @@ program
|
|
|
290
278
|
});
|
|
291
279
|
}
|
|
292
280
|
});
|
|
281
|
+
program.command("setup")
|
|
282
|
+
.description("Prepare this actual Agent and report device/account readiness without starting login")
|
|
283
|
+
.option("--json", "output JSON instead of terminal text")
|
|
284
|
+
.action(async (options) => {
|
|
285
|
+
try {
|
|
286
|
+
const config = loadConfig();
|
|
287
|
+
const skillPath = validateSetup(config.agentType);
|
|
288
|
+
await runSetup(newBackendClient(config), config, skillPath, { jsonOutput: Boolean(options.json) });
|
|
289
|
+
}
|
|
290
|
+
catch (error) {
|
|
291
|
+
reportCLIError(error, { jsonOutput: Boolean(options.json), code: "setup_failed", initialization: true,
|
|
292
|
+
instruction: "准备未完成;保留现有身份,按返回的具体原因处理。", recovery: [] });
|
|
293
|
+
}
|
|
294
|
+
});
|
|
293
295
|
const authCmd = program.command("auth").description("Log in and bind this enrolled Agent to your ItPay account");
|
|
294
296
|
for (const action of ["login", "status"]) {
|
|
295
297
|
authCmd.command(action).option("--json", "output JSON").action(async (options) => {
|
|
@@ -444,7 +446,7 @@ skillCmd
|
|
|
444
446
|
jsonOutput: Boolean(options.json),
|
|
445
447
|
code: "skill_unavailable",
|
|
446
448
|
instruction: "内置 Skill 缺失或损坏;通过当前分发方式恢复同版本 CLI 后重试。",
|
|
447
|
-
recovery: [
|
|
449
|
+
recovery: [],
|
|
448
450
|
});
|
|
449
451
|
}
|
|
450
452
|
});
|
|
@@ -33,8 +33,8 @@ export function sellerSessionToken(baseURL, env = process.env) {
|
|
|
33
33
|
export function sellerAuth(action, baseURL, env = process.env, fetcher = fetch) {
|
|
34
34
|
return accountAuth(action, baseURL, env, fetcher);
|
|
35
35
|
}
|
|
36
|
-
export function agentAuth(action, baseURL, backend, env = process.env, fetcher = fetch) {
|
|
37
|
-
return accountAuth(action, baseURL, env, fetcher, backend);
|
|
36
|
+
export function agentAuth(action, baseURL, backend, env = process.env, fetcher = fetch, options = {}) {
|
|
37
|
+
return accountAuth(action, baseURL, env, fetcher, backend, options.readOnlyStatus === true && action === 'status');
|
|
38
38
|
}
|
|
39
39
|
// AUTH01: dashboard session stages stay distinct — the human must know exactly
|
|
40
40
|
// what the official page still needs instead of a generic "pending".
|
|
@@ -141,12 +141,17 @@ function authenticatedEnvelope(env, phoneVerified) {
|
|
|
141
141
|
}
|
|
142
142
|
return { status: 'authenticated', result, instruction, next, recovery: [] };
|
|
143
143
|
}
|
|
144
|
-
async function accountAuth(action, baseURL, env, fetcher, backend) {
|
|
144
|
+
async function accountAuth(action, baseURL, env, fetcher, backend, readOnlyStatus = false) {
|
|
145
145
|
const purpose = backend ? 'agent-login' : 'seller';
|
|
146
146
|
const command = backend ? 'itpay auth status' : 'itpay sell auth status';
|
|
147
147
|
if (backend) {
|
|
148
148
|
try {
|
|
149
149
|
const current = await backend.agentAccountStatus();
|
|
150
|
+
if (current.status !== 'authenticated' && current.status !== 'login_required')
|
|
151
|
+
throw new Error('Unexpected account binding status');
|
|
152
|
+
// Preparation must not poll, bind or consume a saved browser authorization.
|
|
153
|
+
if (readOnlyStatus)
|
|
154
|
+
return { status: current.status, result: { bound: current.status === 'authenticated' }, instruction: '设备账号状态已读取。', next: null, recovery: [] };
|
|
150
155
|
if (current.status === 'authenticated')
|
|
151
156
|
return authenticatedEnvelope(env, current.phone_verified === true);
|
|
152
157
|
}
|
|
@@ -155,7 +160,7 @@ async function accountAuth(action, baseURL, env, fetcher, backend) {
|
|
|
155
160
|
throw error;
|
|
156
161
|
// AUTH03: even the binding-status probe can hit transport failure; the
|
|
157
162
|
// truthful state is "unknown", never an implicit unbound or a fresh login.
|
|
158
|
-
return authStatusUnknown(read(baseURL, env, purpose)?.sessionID, error, "account_binding_probe");
|
|
163
|
+
return authStatusUnknown(readOnlyStatus ? undefined : read(baseURL, env, purpose)?.sessionID, error, "account_binding_probe");
|
|
159
164
|
}
|
|
160
165
|
}
|
|
161
166
|
async function request(path, init = {}) {
|
package/dist/src/state/config.js
CHANGED
|
@@ -15,7 +15,7 @@ import { OperationJournal } from "./operation_journal.js";
|
|
|
15
15
|
export const DEFAULT_BASE_URL = "https://app.itpay.ai";
|
|
16
16
|
export const DEV_BASE_URL = "https://dev.itpay.ai";
|
|
17
17
|
export const SANDBOX_BASE_URL = "https://sandbox.itpay.ai";
|
|
18
|
-
export const CLI_VERSION = "2.1.
|
|
18
|
+
export const CLI_VERSION = "2.1.46";
|
|
19
19
|
export const API_CONTRACT_REVISION = "sha256:c1e1f459c1d3844f6eeae21535b532abb2e48c3e320173c4faccd62992890dcd";
|
|
20
20
|
const CART_SESSION_DEFAULT_DIR = ".itpay-v3";
|
|
21
21
|
const CART_SESSION_FILENAME = "cart.json";
|
|
@@ -4,42 +4,32 @@
|
|
|
4
4
|
"product_scope": "itpay is the public CLI entry point for Buyer services and existing itpay sell Seller workflows.",
|
|
5
5
|
"topic": "install-and-setup",
|
|
6
6
|
"title": "Install And Identify The ItPay Agent Runtime",
|
|
7
|
-
"purpose": "
|
|
7
|
+
"purpose": "Install in one host-permitted persistent npm location, prepare the real Agent once, and enable the same-package Skill.",
|
|
8
8
|
"when_to_use": [
|
|
9
9
|
"The CLI is being installed or upgraded.",
|
|
10
10
|
"The agent needs to confirm its stable runtime identity and default output Host."
|
|
11
11
|
],
|
|
12
12
|
"commands": [
|
|
13
13
|
{
|
|
14
|
-
"intent": "
|
|
15
|
-
"command": "itpay skill show itpay --json",
|
|
16
|
-
"success_signal": "complete packaged Skill is read; the same version need not be read twice"
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"intent": "list supported Agent Types",
|
|
14
|
+
"intent": "identify actual supported Agent Type if needed",
|
|
20
15
|
"command": "itpay install --json",
|
|
21
|
-
"success_signal": "
|
|
16
|
+
"success_signal": "select actual agent_type without asking the human"
|
|
22
17
|
},
|
|
23
18
|
{
|
|
24
|
-
"intent": "
|
|
25
|
-
"command": "itpay
|
|
26
|
-
"success_signal": "
|
|
19
|
+
"intent": "prepare device and report authoritative account state",
|
|
20
|
+
"command": "itpay setup --agent-type <agent_type> --json",
|
|
21
|
+
"success_signal": "setup_ready with device_status ready and account_status authenticated or login_required; not proof Skill is enabled"
|
|
27
22
|
},
|
|
28
23
|
{
|
|
29
|
-
"intent": "
|
|
30
|
-
"command": "
|
|
31
|
-
"success_signal": "
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"intent": "verify device access after Backend liveness",
|
|
35
|
-
"command": "itpay auth status --json",
|
|
36
|
-
"success_signal": "authenticated or successful login_required proves device access; pending/unknown is not ready"
|
|
24
|
+
"intent": "read and enable complete same-package Skill",
|
|
25
|
+
"command": "itpay skill show itpay --json",
|
|
26
|
+
"success_signal": "read original Skill and persist it using the host official skill mechanism; retain actual path/version"
|
|
37
27
|
}
|
|
38
28
|
],
|
|
39
29
|
"agent_rules": [
|
|
40
|
-
"
|
|
41
|
-
"Run
|
|
42
|
-
"
|
|
30
|
+
"Use standard npm with one host-permitted persistent tool location or global prefix. Fix the exact entry, actual Agent Type and Backend; do not change HOME/npm configuration or an existing project dependency. Do not use floating npx.",
|
|
31
|
+
"Run setup once after installation or upgrade, then read and enable the current package Skill before business. Same-version already-read/enabled Skill needs no repeat. No automatic login or business to prove setup.",
|
|
32
|
+
"Preserve actual npm error and nonzero exit. ENOTEMPTY is an old package/retirement directory conflict, not proof host policy forbids writes; broker wrappers do not establish the underlying cause. Stop repeated installation; only precisely authorized old-package cleanup, never identity deletion. setup_ready requires authoritative device/account checks; unknown/404/incompatibility is not ready.",
|
|
43
33
|
"The current public setup link selects the channel and matching contract: latest/app for production, next/dev for beta. Do not let an old bundle or memory override this choice.",
|
|
44
34
|
"Production defaults to https://app.itpay.ai. Testing may set ITPAY_BACKEND_URL to the exact official URL the configured official test Backend only when explicitly requested; follow the CLI allowlist.",
|
|
45
35
|
"If Backend compatibility cannot be verified, stop this round. minimum_cli_version is a protocol floor, not a verified matching artifact. Ask the maintainer for the matching distribution; do not guess a version or downgrade.",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
**上游:** 当前 npm CLI 或平台 bundle 已经可执行。
|
|
10
10
|
|
|
11
|
-
**下游:**
|
|
11
|
+
**下游:** 使用真实 Agent Type 执行 `setup`,再读取并启用同包 Skill。authenticated 或成功 login_required 才证明设备访问可用;后者仍未登录,不自动发起授权或业务。
|
|
12
12
|
|
|
13
13
|
## 语法与参数
|
|
14
14
|
|
|
@@ -35,8 +35,8 @@ itpay install [target] [--json]
|
|
|
35
35
|
},
|
|
36
36
|
"instruction": "在 Codex Desktop 中始终传这个 Agent Type;付款时把返回的二维码和链接实际展示到当前对话。",
|
|
37
37
|
"next": {
|
|
38
|
-
"command": "itpay --agent-type codex-desktop
|
|
39
|
-
"reason": "
|
|
38
|
+
"command": "itpay --agent-type codex-desktop setup --json",
|
|
39
|
+
"reason": "准备当前宿主并确认设备与账号状态"
|
|
40
40
|
},
|
|
41
41
|
"recovery": [
|
|
42
42
|
{
|
|
@@ -63,8 +63,8 @@ OpenClaw 额外明确没有默认入口:
|
|
|
63
63
|
},
|
|
64
64
|
"instruction": "保持 openclaw Agent Type;每个展示命令都从当前可信会话上下文显式传 --host,IM 入口同时传 --target。Telegram 使用返回的原生 message action,其他入口展示标准二维码和付款链接。",
|
|
65
65
|
"next": {
|
|
66
|
-
"command": "itpay --agent-type openclaw
|
|
67
|
-
"reason": "
|
|
66
|
+
"command": "itpay --agent-type openclaw setup --json",
|
|
67
|
+
"reason": "准备当前宿主并确认设备与账号状态"
|
|
68
68
|
},
|
|
69
69
|
"recovery": [
|
|
70
70
|
{
|
|
@@ -100,7 +100,7 @@ OpenClaw 额外明确没有默认入口:
|
|
|
100
100
|
}
|
|
101
101
|
]
|
|
102
102
|
},
|
|
103
|
-
"instruction": "识别当前真实运行平台,从 result.agent_types 选择对应 agent_type,并由 Agent 自行运行 itpay
|
|
103
|
+
"instruction": "识别当前真实运行平台,从 result.agent_types 选择对应 agent_type,并由 Agent 自行运行 itpay setup --agent-type <agent_type> --json;不要让用户运行命令,也不要临时更换 Agent Type。",
|
|
104
104
|
"next": null,
|
|
105
105
|
"recovery": [
|
|
106
106
|
{
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
检查当前官方 Backend 是否可用。默认使用生产环境 `https://app.itpay.ai`;仅测试时可通过 `ITPAY_BACKEND_URL=https://sandbox.itpay.ai` 选择官方沙箱环境。它只调用 `/v1/readyz` 做 liveness 诊断,不执行平台兼容性 gate、不登记设备、不创建业务资源;需要服务端合同的命令仍会在各自入口严格检查 compatibility。
|
|
8
8
|
|
|
9
9
|
**上游:** CLI 安装;Backend 只能是官方 `https://app.itpay.ai` 、`https://sandbox.itpay.ai` 或 `https://dev.itpay.ai`,其他 override 在网络或本地状态写入前被拒绝。
|
|
10
|
-
**下游:** 实际宿主已声明时,执行同 Backend/type 的 `
|
|
10
|
+
**下游:** 实际宿主已声明时,执行同 Backend/type 的 `setup`;未声明时先 `install` 识别实际宿主。setup 后读取并启用同包 Skill,同版本不重复读取。
|
|
11
11
|
|
|
12
12
|
## 语法与参数
|
|
13
13
|
|
|
@@ -25,8 +25,8 @@ itpay readyz [--json]
|
|
|
25
25
|
{
|
|
26
26
|
"status": "ready",
|
|
27
27
|
"result": { "backend": "available", "backend_url": "https://app.itpay.ai", "environment": "production" },
|
|
28
|
-
"instruction": "ItPay
|
|
29
|
-
"next": { "command": "itpay install --json", "reason": "
|
|
28
|
+
"instruction": "ItPay 正式环境 https://app.itpay.ai 可用。只证明后端存活;首次使用或更新后运行 setup,不自动登录或开始业务。",
|
|
29
|
+
"next": { "command": "itpay install --json", "reason": "识别实际宿主类型后执行 setup" },
|
|
30
30
|
"recovery": []
|
|
31
31
|
}
|
|
32
32
|
```
|
|
@@ -37,8 +37,8 @@ itpay readyz [--json]
|
|
|
37
37
|
{
|
|
38
38
|
"status": "ready",
|
|
39
39
|
"result": { "backend": "available", "backend_url": "https://sandbox.itpay.ai", "environment": "development" },
|
|
40
|
-
"instruction": "ItPay 开发环境 https://sandbox.itpay.ai
|
|
41
|
-
"next": { "command": "ITPAY_BACKEND_URL=https://sandbox.itpay.ai itpay install --json", "reason": "
|
|
40
|
+
"instruction": "ItPay 开发环境 https://sandbox.itpay.ai 可用。只证明后端存活;首次使用或更新后运行 setup,不自动登录或开始业务。",
|
|
41
|
+
"next": { "command": "ITPAY_BACKEND_URL=https://sandbox.itpay.ai itpay install --json", "reason": "识别实际宿主类型后执行 setup" },
|
|
42
42
|
"recovery": []
|
|
43
43
|
}
|
|
44
44
|
```
|
|
@@ -66,4 +66,4 @@ itpay readyz [--json]
|
|
|
66
66
|
|
|
67
67
|
## Agent Type / Host
|
|
68
68
|
|
|
69
|
-
本命令不渲染 Host 内容。若已声明 Agent Type,`result.agent_type` 会确认该类型,且返回的 `
|
|
69
|
+
本命令不渲染 Host 内容。若已声明 Agent Type,`result.agent_type` 会确认该类型,且返回的 `setup` 命令保留同一 `--agent-type` 与 Backend;未声明时返回 `install`。只有 authenticated 或成功 login_required 才证明设备可用,后者不代表已登录。权限拒绝或未知状态停止准备,不宣称 ready。
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# `itpay setup`
|
|
2
|
+
|
|
3
|
+
Use the host's permitted persistent npm installation or a normal global install. Fix that exact executable for all commands; installation location does not change the device identity directory.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
itpay setup --agent-type <actual_type> --json
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Run once after installation or upgrade. Unsupported/missing type and unavailable same-package Skill fail before network access. This command reads authoritative device/account status using existing authentication; it does not install, launch login or run business commands.
|
|
10
|
+
|
|
11
|
+
`setup_ready` returns `cli_version`, `backend_url`, `agent_type`, `device_status: ready`, `account_status: authenticated|login_required`, absolute `skill_path` and package-bound `skill_version`. `next` is null. Read the original Skill and enable it using the host mechanism before business; setup does not claim either happened. Repeated setup preserves identity and existing authorization. Account unknown, missing endpoint or incompatible Backend fails with nonzero exit and the actual reason.
|
|
12
|
+
|
|
13
|
+
For testing set `ITPAY_BACKEND_URL=https://dev.itpay.ai` on every invocation; production defaults to app.itpay.ai. Do not switch environments to hide failure. `install`, `readyz` and `auth status` remain diagnostic/compatibility commands, not a required initialization chain.
|
|
@@ -48,3 +48,11 @@ Skill 不能默认把 Agent 引向 Catalog:用户可能要读取以前购买
|
|
|
48
48
|
|
|
49
49
|
`workbuddy` 只在 instruction 中增加既有的本地权限要求;不改变输入、输出
|
|
50
50
|
schema 或意图路由。
|
|
51
|
+
|
|
52
|
+
## 同包启用
|
|
53
|
+
|
|
54
|
+
setup 返回当前包的绝对 Skill 路径;完整读取原文,按宿主正式技能安装方式保存启用。同版本已读且启用时无需重复保存;宿主不支持持久发现时记录准确路径与限制,不声称跨会话自动发现已验证。
|
|
55
|
+
|
|
56
|
+
兼容 `ITPAY_CLI_SKILLS_DIR` 的直接/父目录路径,但其内容必须与当前包原文完全一致。陈旧或改写内容返回非0 `skill_override_mismatch`,给出同包 `result.skill_path` 供直接读取,不宣称已启用。缺包/文档错误只指向原安装方式,不生成会另装全局包的恢复命令。
|
|
57
|
+
|
|
58
|
+
覆盖路径不可读但原包有效时,返回 `skill_override_unavailable` 和实际读取原因、同包路径;不会把它误报为包损坏或建议另装全局包。
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
itpay [--agent-type <agent_type>] [--version] [--help]
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
不带子命令时显示帮助并退出,不访问 Backend、不读取或修改业务状态。`--version` 只输出当前 CLI 版本;`--help`
|
|
23
|
+
不带子命令时显示帮助并退出,不访问 Backend、不读取或修改业务状态。`--version` 只输出当前 CLI 版本;`--help` 只输出命令树。`--agent-type` 可置于子命令前或 setup 参数中,并由每个返回的 ItPay `next.command` / `recovery.command` 原样保留其规范值。
|
|
24
24
|
|
|
25
25
|
Commander 自动提供的 `itpay help [command]` 与 `itpay <group> help [subcommand]` 只显示对应帮助,语义等同于在目标命令上使用 `--help`;它们不访问 Backend、不读写本地业务状态,也没有 JSON 输出合同。
|
|
26
26
|
|
|
@@ -28,6 +28,8 @@ Commander 自动提供的 `itpay help [command]` 与 `itpay <group> help [subcom
|
|
|
28
28
|
|
|
29
29
|
### 环境与发现
|
|
30
30
|
|
|
31
|
+
- [`itpay setup`](commands/setup.md) - 一次准备设备并单独报告账号状态
|
|
32
|
+
|
|
31
33
|
- [`itpay readyz`](commands/readyz.md) - 检查后端是否可用
|
|
32
34
|
- [`itpay next`](commands/next.md) - 从本地保存的服务端句柄恢复下一步
|
|
33
35
|
- [`itpay catalog`](commands/catalog/index.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itpay/cli",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.46",
|
|
4
4
|
"description": "The ItPay CLI for services, orders, and human-authorized purchased content.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"qrcode",
|
|
84
84
|
"zod"
|
|
85
85
|
],
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "f36dd8f312628558aaff7e293348c508ed467664"
|
|
87
87
|
}
|
package/skills/itpay/SKILL.md
CHANGED
|
@@ -14,9 +14,11 @@ human the useful result or action, not the internal steps.
|
|
|
14
14
|
|
|
15
15
|
## Installation readiness
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
使用宿主允许的持久安装方式运行官方 ItPay CLI,不要求全局安装。固定本次安装的入口、实际 Agent Type 和 Backend。首次使用或更新后运行 setup;setup_ready 证明设备准备完成,账号授权状态单独列出。完整读取当前包 Skill,并按宿主方式保存启用;同版本已读且已启用时无需重复。业务请求需要真人授权时使用返回的官方入口,不以安装授权代替购买同意。安装位置变化不要求清除设备身份。
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
The public setup link selects latest/app for production or next/dev for testing. Use standard npm in the host's permitted persistent tool location or global prefix; choose one location and keep the verified entry for every returned command. Do not use floating npx, change HOME/npm configuration, modify an existing project's dependencies, or bypass protection. Preserve npm's actual output and exit status; failed installation is not ready even when an older executable runs.
|
|
20
|
+
|
|
21
|
+
Run `itpay setup --agent-type <actual_type> --json` once after installation or upgrade. Read and enable this exact package Skill before business commands. If the host cannot persist or discover a Skill, record its accurate persistent path and that limitation; do not claim it has been enabled. No repeated install/readyz/auth sequence is needed for ordinary tasks. Unknown, incompatible, or unavailable device/account status stops preparation; preserve identity and report the actual cause. Do not start login or business merely to prove readiness.
|
|
20
22
|
|
|
21
23
|
## Choose one entry
|
|
22
24
|
|