@xiashe/cli 0.1.39 → 0.1.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -36,8 +36,8 @@ xiashe skills list
36
36
  xiashe skills install copywriting --connection MaxClaw-1 --watch
37
37
  xiashe agent issue --name "Local WorkBuddy"
38
38
  xiashe agent connect --token "<token>" --name "Local WorkBuddy" --transport npx
39
- xiashe agent run --ack
40
- xiashe chat send --chat "New Chat" --content "帮我处理这个文件" --file ./report.pdf --agent "Local WorkBuddy"
39
+ xiashe agent run --executor codex --workdir ./workspace
40
+ xiashe chat send --chat "New Chat" --content "请整理工作目录中的报告" --agent "Local WorkBuddy"
41
41
  xiashe skills publish draft . --source xiashe
42
42
  xiashe skills publish doctor "<submission-id>"
43
43
  xiashe skills publish submit "<submission-id>"
@@ -84,7 +84,20 @@ Fixed-number acquisition is included in 0.1.36. Source 0.1.37 adds controlled ru
84
84
 
85
85
  `skills publish draft` reads `.xiashe/xiashe.skill.json` when present. If the local CLI is not signed in, it can create or reuse the XiaShe Store draft with that registry public token; creator login is only required when the registry token is missing or rejected.
86
86
 
87
- `xiashe agent run --ack` is the recommended lightweight receiver for shell-capable Agents. It sends cheap heartbeats and only lists/executes work when the backend reports pending tasks or transfers. Default cadence is about 30s while idle, 10s while work is active, and up to 2 minutes after long idle periods.
87
+ `xiashe agent run` executes one received text task at a time with the installed Codex CLI, then submits its final answer to the originating chat. `--ack` remains accepted for command compatibility. `agent receiver --ack` retains the manual receiver behavior and does not invoke a model. Install and authenticate a current Codex CLI first; real acceptance used Codex CLI 0.160.1. Host authentication and model availability are separate from XiaShe login.
88
+
89
+ ```bash
90
+ # Verify the actual host/model without claiming tasks or calling SaaS:
91
+ xiashe agent run --check --workdir ./workspace
92
+ # Use a specific binary or host model when needed:
93
+ xiashe agent run --codex-bin /absolute/path/to/codex --model <supported-model> --workdir ./workspace
94
+ # Receive and execute at most one task:
95
+ xiashe agent run --once --workdir ./workspace --task-timeout-ms 900000
96
+ ```
97
+
98
+ Codex runs with the workspace-write sandbox, and XiaShe/Convex environment credentials are removed from its environment. Each task has a private durable receipt under `~/.xiashe/agent-tasks` (`~/.agentpie/agent-tasks` for AgentPie). A lost completion response resends only the saved answer. Interrupted execution is failed instead of replayed; if an orphan executor is still alive, reconcile that process before restarting. Cancellation, lease loss, timeout and host failures stop execution and cannot produce a success answer. `Ctrl-C` stops the worker and its active executor.
99
+
100
+ The automatic adapter currently supports text tasks and local workspace files. Incoming transfer attachments are explicitly rejected and `files.receive` is advertised as disabled; generated local files are not automatically uploaded. Other Agent products must use the manual receiver or their existing scoped runtime MCP integration, and require their own real acceptance. Gateway discovery and transport labels do not certify execution, package verification, service authorization or model access.
88
101
 
89
102
  Supported transport labels are `a2a`, `mcp`, `http`, `npx`, `claw`, and `manual`. The label is advisory for routing and diagnostics; the runtime token, task lease, ack, and complete events remain the source of truth.
90
103
 
@@ -218,3 +231,9 @@ State is isolated by official actions origin and number, written atomically with
218
231
  The delivery command validates compressed size, SHA-256 and archive paths without executing package scripts. Read the returned SKILL.md before acknowledging received. Runtime results and received/used receipts are different evidence. Creator --stats requires login and ownership; bounded samples are explicitly marked truncated. Anonymous subjects are not precise unique people.
219
232
 
220
233
  doctor reports host discovery as unverified; only a real host session can validate loading. Website staging packages retain their environment; npm defaults to production.
234
+
235
+ ## Short Skill command (0.1.40)
236
+
237
+ `xiashe use 123456` starts or resumes the number protocol in production, regardless of the saved default environment. For staging use `xiashe use 123456 --staging`. No URL configuration is needed. Existing `number` commands retain their behavior.
238
+
239
+ Without a global installation: `npx -y xiashe@0.1.40 use 123456` (Node.js 20+ required). In Codex use `$xiashe 123456` after installing the Skill entry.
package/bin/xiashe.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { expandUseNumber } from '../lib/use-number.mjs';
2
3
  import { deliverNumber } from '../lib/delivery.mjs';
3
4
  import { runAccessCommand } from '../skills/xiashe/scripts/runtime-state.mjs';
4
5
  import { runDoctorCommand } from '../lib/doctor.mjs';
@@ -27,6 +28,9 @@ const sdk = await import(sdkEntry);
27
28
 
28
29
  const {
29
30
  VERSION,
31
+ configDir,
32
+ runAgentTaskCycle,
33
+ createCodexTaskExecutor,
30
34
  probeRuntimeGateway,
31
35
  runtimeSetupTemplate,
32
36
  DEFAULTS,
@@ -172,7 +176,7 @@ ${` ${c} access <number> deliver|prepare|start|prompt|describe_action|execute|a
172
176
  ${c} agent heartbeat [--webhook-url <https-url>] [--webhook-token <secret>|--disable-webhook]
173
177
  ${c} agent list
174
178
  ${c} agent revoke --agent <id-or-name>
175
- ${c} agent run [--once] [--ack] [--idle-ms <ms>] [--busy-ms <ms>] [--max-idle-ms <ms>]
179
+ ${c} agent run [--check] [--executor codex] [--model <model>] [--codex-bin <path>] [--workdir <directory>] [--task-timeout-ms <ms>] [--once] [--ack] [--idle-ms <ms>] [--busy-ms <ms>] [--max-idle-ms <ms>]
176
180
  ${c} agent tasks list|watch|ack <taskId>|complete <taskId> [--content <text>]
177
181
  ${c} agent transfers list|accept <transferId>|complete <transferId>|fail <transferId>
178
182
  ${c} agent task create --agent <id-or-name> --chat <id-or-title> --content <text>
@@ -197,6 +201,7 @@ ${` ${c} access <number> deliver|prepare|start|prompt|describe_action|execute|a
197
201
  Global flags:
198
202
  --profile <name> Local config profile. Default: active profile.
199
203
  --convex-url <url> Convex deployment URL.
204
+ use <number> [--staging] Use a creator Skill (production by default).
200
205
  --actions-url <url> ${PRODUCT_NAME} action site URL.
201
206
  --json Print JSON output.
202
207
  --timeout-ms <ms> HTTP timeout. Default: 20000.
@@ -1245,7 +1250,11 @@ async function cmdAgent(sub, args, global) {
1245
1250
  return;
1246
1251
  }
1247
1252
  if (sub === 'run' || sub === 'receiver' || sub === 'loop') {
1248
- await cmdAgentReceiver(flags, client, global);
1253
+ if (sub === 'run' || sub === 'loop') {
1254
+ await cmdAgentExecutor(flags, client, global);
1255
+ } else {
1256
+ await cmdAgentReceiver(flags, client, global);
1257
+ }
1249
1258
  return;
1250
1259
  }
1251
1260
  if (sub === 'list' || sub === 'agents' || !sub) {
@@ -1297,6 +1306,43 @@ async function cmdAgent(sub, args, global) {
1297
1306
  fail(`Unknown agent command: ${sub}`, EXIT_USAGE);
1298
1307
  }
1299
1308
 
1309
+ async function cmdAgentExecutor(flags, client, global) {
1310
+ const executor = flags.executor || 'codex';
1311
+ if (executor !== 'codex') fail('Supported executor: codex. Use agent receiver for manual hosts.', EXIT_USAGE);
1312
+ const directory = path.join(configDir(), 'agent-tasks');
1313
+ const execute = createCodexTaskExecutor({
1314
+ workdir: flags.workdir || process.cwd(), directory: path.join(directory, 'output'), model: flags.model,
1315
+ command: flags['codex-bin'] || 'codex', timeoutMs: numericFlag(flags, 'task-timeout-ms', 15 * 60_000)
1316
+ });
1317
+ if (flags.check) {
1318
+ const result = await execute({ prompt: 'This is a local host readiness check. Reply with exactly XIASHE_HOST_READY. Do not use tools or change files.' });
1319
+ if (result.trim() !== 'XIASHE_HOST_READY') fail('Host readiness response was invalid.', EXIT_RUNTIME);
1320
+ print({ ok: true, executor, hostExecutionVerified: true, workdir: path.resolve(flags.workdir || process.cwd()), businessCalls: 0 }, global);
1321
+ return;
1322
+ }
1323
+ const controller = new AbortController();
1324
+ const stop = () => controller.abort();
1325
+ process.once('SIGINT', stop); process.once('SIGTERM', stop);
1326
+ const deadline = Date.now() + numericFlag(flags, 'timeout-ms', 24 * 60 * 60_000);
1327
+ try {
1328
+ while (Date.now() < deadline && !controller.signal.aborted) {
1329
+ try {
1330
+ await runAgentTaskCycle(client, { directory: path.join(directory, 'receipts'), execute, signal: controller.signal,
1331
+ onEvent: event => console.log(JSON.stringify(event)) });
1332
+ } catch (error) {
1333
+ if (flags.once) throw error;
1334
+ console.error(`${PRODUCT_NAME} agent executor: ${error.message}. Saved results will be retried.`);
1335
+ }
1336
+ if (flags.once || controller.signal.aborted) return;
1337
+ await new Promise(resolve => {
1338
+ const done = () => { clearTimeout(timer); controller.signal.removeEventListener('abort', done); resolve(); };
1339
+ const timer = setTimeout(done, numericFlag(flags, 'idle-ms', 30_000));
1340
+ controller.signal.addEventListener('abort', done, { once: true });
1341
+ });
1342
+ }
1343
+ } finally { process.removeListener('SIGINT', stop); process.removeListener('SIGTERM', stop); }
1344
+ }
1345
+
1300
1346
  async function cmdAgentReceiver(flags, client, global) {
1301
1347
  const idleMs = numericFlag(flags, 'idle-ms', 30_000);
1302
1348
  const busyMs = numericFlag(flags, 'busy-ms', 10_000);
@@ -1832,7 +1878,10 @@ function osPlatform() {
1832
1878
  }
1833
1879
 
1834
1880
  async function main() {
1835
- const parsed = parseGlobal(process.argv.slice(2));
1881
+ let argv;
1882
+ try { argv = expandUseNumber(process.argv.slice(2)); }
1883
+ catch (error) { fail(error.message, EXIT_USAGE); }
1884
+ const parsed = parseGlobal(argv);
1836
1885
  const [command, sub, ...args] = parsed.argv;
1837
1886
  const global = parsed.global;
1838
1887
  if (!command) {
@@ -0,0 +1,8 @@
1
+ /** Short use command always selects an official environment, independent of saved defaults. */
2
+ export function expandUseNumber(argv) {
3
+ if (argv[0] !== 'use') return argv;
4
+ const [, number, ...flags] = argv;
5
+ if (!/^[1-9]\d{5,8}$/.test(number || '')) throw new Error('Usage: xiashe use <6–9 digit number> [--staging] [--json]');
6
+ if (flags.some(flag => !['--staging', '--json'].includes(flag))) throw new Error('Supported use flags: --staging, --json');
7
+ return ['number', number, '--start', '--actions-url', flags.includes('--staging') ? 'https://actions.projectphenix.site' : 'https://actions.xiashe.chat', ...flags.filter(flag => flag === '--json')];
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiashe/cli",
3
- "version": "0.1.39",
3
+ "version": "0.1.41",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "xiashe": "bin/xiashe.mjs"
@@ -12,7 +12,7 @@
12
12
  "lib"
13
13
  ],
14
14
  "dependencies": {
15
- "@xiashe/sdk": "0.1.39"
15
+ "@xiashe/sdk": "0.1.41"
16
16
  },
17
17
  "engines": {
18
18
  "node": ">=20"
@@ -5,7 +5,7 @@ description: 通过虾舍公开 Skill 的固定号码获取和使用创作者能
5
5
 
6
6
  # 虾舍 Skill 号码
7
7
 
8
- Claude Code 使用 `/xiashe 123456`,Codex 使用 `$xiashe 123456`(或在技能选择器选择 xiashe)。自然语言提及“虾舍号码”也可触发。
8
+ Claude Code 使用 `/xiashe 123456`,Codex 使用 `$xiashe 123456`(或在技能选择器选择 xiashe)。自然语言提及“虾舍号码”也可触发。Codex 的文档引导以 `$xiashe` 为准;`/xiashe` 作为部分宿主入口或文本触发兼容,不承诺所有 Codex 客户端都提供同名斜杠菜单。终端使用 `xiashe use 123456`,测试环境使用 `xiashe use 123456 --staging`;斜杠和美元前缀不用于 Shell。
9
9
 
10
10
  `/xiashe 123456`、`/xiashe number 123456`、`/xiashe numbers 123456` 含义相同。123456 只是格式示例。将脚本路径解析为本 Skill 目录下的绝对路径;参数作为独立参数传递,不拼接用户 Shell 文本。
11
11