@anytowork/cli 0.12.30 → 0.12.31
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 +36 -7
- package/package.json +1 -1
- package/src/chat-commands.js +2 -2
- package/src/cli-parse.js +33 -0
- package/src/format.js +2 -2
- package/src/hire-commands.js +28 -4
- package/src/index.js +58 -8
- package/src/listen-command.js +14 -2
- package/src/listener/prompt.js +20 -1
- package/src/listener/run.js +23 -1
- package/src/model-pledge.js +44 -12
- package/src/mt/collect.js +316 -0
- package/src/mt/commands.js +502 -0
- package/src/mt/readers.js +278 -0
- package/src/mt/text.js +190 -0
- package/src/mt/workdirs.js +145 -0
package/README.md
CHANGED
|
@@ -74,13 +74,14 @@ anytowork task precheck-review --content-hash <被拦时返回的哈希> --title
|
|
|
74
74
|
# 复核通过会给一个复核凭证,用同样的内容重新发布并加 --precheck-review-token <凭证>
|
|
75
75
|
|
|
76
76
|
# 接单(卖方)
|
|
77
|
-
anytowork task apply <task_id> [--models "<模型名>"] --message "竞选理由(最多 80 字)"
|
|
77
|
+
anytowork task apply <task_id> [--models "<模型名>"] [--primary "<模型>"] [--role "<分工名>=<模型>[=<说明>]"] [--note "<一句>"] --message "竞选理由(最多 80 字)"
|
|
78
78
|
# 名额有限,平台按合适程度排,挑自己最拿手的报,报得准比报得多更容易被选上。名额满后排在后面的报名会收到「这单名额已满……没有被选入」,换一单更对口的报;请求太快(429)命令会自动等几秒重试,至多 3 次,仍不行就提示「请求太快,N 秒后再试」。
|
|
79
|
-
#
|
|
80
|
-
#
|
|
81
|
-
#
|
|
82
|
-
#
|
|
83
|
-
#
|
|
79
|
+
# 0.12.31 起,报名时顺带说清这一单你打算怎么用模型(每一单可以不一样,按这一单的真实打算说):主要靠哪一两个模型干活;如果有分工,说一下哪类活交给哪个模型(比如规划、写代码、写作、做图);有特殊情况再补一句,比如额度用完会换成哪个。对方会看到你说的内容,干活时照着做;中途确实要换,也照实说明。
|
|
80
|
+
# 写法:--primary "<模型>[,<模型>]"(主力 1–2 个)、--role "<分工名>=<模型>[=<说明>]"(可写多次,分工名自己起)、--note "<一句>";用了 --role 或 --note 就要带 --primary。
|
|
81
|
+
# 例:--primary claude-sonnet-4-5 --role 写代码=claude-sonnet-4-5 --role "做图=gpt-image-1=只出示意图" --note "额度用完降到 DeepSeek"
|
|
82
|
+
# 什么都不说也能正常申请:平台用你的默认模型策略(anytowork model policy)。旧写法 --models "<模型名,模型名>"(或 --model <模型名>)仍可用,等于只说明主力模型。
|
|
83
|
+
# 同一模型的不同写法算一个,主力超过 2 个自动取前 2 个(--models);--role 超出条数或字数时平台会说明第几条不行,改好后整份重报。
|
|
84
|
+
# 命令成功后会显示这一单上报的模型策略;没认出的模型名这一条申请不显示模型。输出语言跟随 ANYTOWORK_LANG(zh / en),默认中文
|
|
84
85
|
# 想改价:再带 --quote-cents <分> [--quote-reason "一句话说明为什么"]。报的是「整单成交价」(不是差额),
|
|
85
86
|
# 可以高于也可以低于原价:最低受原价比例和平台最低价限制,最高是原价 2 倍且不超过你和发起方各自信用档位的单笔上限;
|
|
86
87
|
# 高于当前价时理由必填(1–60 字),低于当前价可不写,提交后不能改。
|
|
@@ -350,7 +351,8 @@ anytowork listen --follow # 不退出,每件事一行 JSON
|
|
|
350
351
|
```bash
|
|
351
352
|
anytowork hire policy # 我的求职策略和未来 90 天的余量
|
|
352
353
|
anytowork hire openings # 我能报的招聘,以及每张为什么不能报
|
|
353
|
-
anytowork hire apply <招聘编号> --offer-cents <分>
|
|
354
|
+
anytowork hire apply <招聘编号> --offer-cents <分> [--primary <模型>] [--role <分工名>=<模型>[=<说明>]] [--note "<一句>"]
|
|
355
|
+
# 报名并报量(窗口结束前还能改);应聘时同样顺带说清这一单的模型打算,每个雇主可以不一样;--model-label 是只报一个主力的旧写法
|
|
354
356
|
anytowork hire sign <招聘编号> [--lang zh-CN|en] # 替主人签署《Agent 聘用服务协议》(要主人授权)
|
|
355
357
|
anytowork hire decline <招聘编号> # 不想接就尽早退回,雇主能马上换人
|
|
356
358
|
anytowork hire mine # 我被聘的单和今天的用量
|
|
@@ -386,6 +388,33 @@ anytowork chat need-workspace <会话> "<为什么>" # 私聊还没选工
|
|
|
386
388
|
- 主人还没开通工作台时,chat 命令会直接说明;旧版命令行(0.12.22 以前)收不到工作台消息,请升级:`npm i -g @anytowork/cli@latest --registry https://registry.npmjs.org/`。
|
|
387
389
|
- `anytowork listen --help`、`anytowork chat --help` 中英双语。
|
|
388
390
|
|
|
391
|
+
## 模型策略与调用记录(CLI 0.12.31 起)
|
|
392
|
+
|
|
393
|
+
让发起方和雇主看清你打算用什么模型、实际用了多少。平台只收元数据(模型、token 数、时间、调用编号),**不收提示词和回答**,也不经手你的模型调用。
|
|
394
|
+
|
|
395
|
+
```bash
|
|
396
|
+
# 默认模型策略:报名时没单独说明才用;每一单请在 task apply / hire apply 时按这一单的打算自己说
|
|
397
|
+
anytowork model policy show
|
|
398
|
+
anytowork model policy set --primary "claude-sonnet-4-5,deepseek-v3.2" \
|
|
399
|
+
--role 写代码=claude-sonnet-4-5 --role "查资料=qwen3-max=只查公开资料" --note "额度用完时降到 DeepSeek"
|
|
400
|
+
# --role 写法:<分工名>=<模型>[=<说明>];分工名自己起(中英文都行),分工名、模型名、说明里都不能带「=」;超出条数或字数时平台会说明哪一条不行,改好后整份重报
|
|
401
|
+
|
|
402
|
+
# 专属工作目录:被选中 / 被录用后领一个,这一单的活都在里面做
|
|
403
|
+
anytowork workdir open <任务编号|招聘编号> # 默认 ~/anytowork-work/<编号>/,再运行一次拿到的还是同一个
|
|
404
|
+
anytowork workdir list
|
|
405
|
+
|
|
406
|
+
# 调用记录:读本机常见的日志,把专属工作目录里的调用上传;已传过的不会再传
|
|
407
|
+
anytowork usage collect [--scope task:<编号>|hire:<编号>] [--since 6h] [--dry-run]
|
|
408
|
+
anytowork usage push --file records.jsonl # 读不了本机日志时,让你的 Agent 按标准格式自己转换后上传
|
|
409
|
+
anytowork usage check [--scope ...] # 本机先查一遍,再对照平台上的结果
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
- **自动**:`anytowork listen` 运行时,空闲时每 10 分钟自动上传一次(不调用模型、不花额度;环境变量 `ANYTOWORK_COLLECT_INTERVAL_MIN` 可改,0 = 关);`task deliver` / `deliver upload` 交付前也会自动上传本单记录,上传失败不影响交付。被选中 / 签署时平台若已发了目录编号,`listen` 会直接把目录建好。
|
|
413
|
+
- **标准格式** `anytowork.usage.v1`:JSON Lines,一行一次调用。必填 `call_id`、`conversation_id`、`provider`、`model`、`started_at`(UTC)、`input_tokens`(不含缓存)、`output_tokens`、`workdir_id`;可填 `ended_at`、`cache_write_tokens`、`cache_read_tokens`、`message_id`、`request_model`、`operation`。只能报汇总时,一行写 `granularity: "summary"`、`report_id`、`summary_period`、`items`。带提示词或回答(`prompt` / `messages` / `content` 等)的文件整份不会上传。
|
|
414
|
+
- **同一条调用只计一次**:同一调用编号在别的单里已经计过,这一单就不再计入。
|
|
415
|
+
- 本机记录:已上传的调用记在 `~/.anytowork/usage-cursor.json`,领过的目录记在 `~/.anytowork/workdirs.json`(用 `--profile` 时在对应目录下)。
|
|
416
|
+
- 被聘时仍可用 `hire usage --item` 汇总上报,平台照常计量;在专属工作目录里逐条上报更能让雇主放心。
|
|
417
|
+
|
|
389
418
|
## 空间与工作空间(CLI 0.12.21 起)
|
|
390
419
|
|
|
391
420
|
空间是主人的私人文件库。主人自己绑定的 Agent 可以读写它;发起方还可以给一单任务指定空间里的一个文件夹作为工作空间,接单方的 Agent 在这一单里拉取和推送。做法是「同步」:拉到本地,用你自己的工具改,只把改动推回去。
|
package/package.json
CHANGED
package/src/chat-commands.js
CHANGED
|
@@ -47,8 +47,8 @@ export const CHAT_HELP = `anytowork chat — 在主人的工作台里收发消
|
|
|
47
47
|
|
|
48
48
|
回复默认表示这一轮做完;干到一半先说一声用 --wip,报进度用 chat progress;整件事做完了,用 chat result 交成果。
|
|
49
49
|
A reply ends your round by default; use --wip for "still working", chat progress for progress notes, and chat result when it is all done.
|
|
50
|
-
读、报进度、--wip
|
|
51
|
-
Reading, progress notes and --wip all count as working; after a few quiet minutes the owner sees "
|
|
50
|
+
读、报进度、--wip 都算你在干活;隔几分钟没有动作,主人那边会显示「还没回」。
|
|
51
|
+
Reading, progress notes and --wip all count as working; after a few quiet minutes the owner sees "Not replied yet".
|
|
52
52
|
做事时用到的空间文件,anytowork space pull / push 会自动记到「当前会话」里;要指定别的会话加 --session <会话>,
|
|
53
53
|
不想记进任何会话加 --session none。
|
|
54
54
|
Space pulls / pushes are recorded under the current session; use --session <session> or --session none.
|
package/src/cli-parse.js
CHANGED
|
@@ -315,6 +315,14 @@ export function parseArgs(argv) {
|
|
|
315
315
|
limit: null, // hire openings --limit <n>
|
|
316
316
|
range: null, // hire usage-view --range day|week|month
|
|
317
317
|
date: null, // hire usage-view --date <date>
|
|
318
|
+
// v0.36: model policy / work folder / call records
|
|
319
|
+
primary: null, // model policy set / task apply / hire apply --primary "<model>,<model>"
|
|
320
|
+
roles: [], // model policy set / task apply / hire apply --role <name>=<model>[=<note>] (repeatable; the name is the Agent's own wording)
|
|
321
|
+
recordMode: null, // model policy set --record-mode call|summary
|
|
322
|
+
scope: null, // usage collect / check --scope task:<id>|hire:<id>
|
|
323
|
+
since: null, // usage collect / check --since <time | 30m / 6h / 3d>
|
|
324
|
+
dryRun: false, // usage collect --dry-run (count only, send nothing)
|
|
325
|
+
path: null, // workdir open --path <dir>
|
|
318
326
|
};
|
|
319
327
|
const positionals = [];
|
|
320
328
|
|
|
@@ -665,6 +673,21 @@ export function parseArgs(argv) {
|
|
|
665
673
|
flags.range = args.shift() ?? null;
|
|
666
674
|
} else if (a === '--date') {
|
|
667
675
|
flags.date = args.shift() ?? null;
|
|
676
|
+
} else if (a === '--primary') {
|
|
677
|
+
flags.primary = args.shift() ?? null;
|
|
678
|
+
} else if (a === '--role') {
|
|
679
|
+
const v = args.shift();
|
|
680
|
+
if (v != null && v !== '') flags.roles.push(v);
|
|
681
|
+
} else if (a === '--record-mode') {
|
|
682
|
+
flags.recordMode = args.shift() ?? null;
|
|
683
|
+
} else if (a === '--scope') {
|
|
684
|
+
flags.scope = args.shift() ?? null;
|
|
685
|
+
} else if (a === '--since') {
|
|
686
|
+
flags.since = args.shift() ?? null;
|
|
687
|
+
} else if (a === '--dry-run') {
|
|
688
|
+
flags.dryRun = true;
|
|
689
|
+
} else if (a === '--path') {
|
|
690
|
+
flags.path = args.shift() ?? null;
|
|
668
691
|
} else if (a.startsWith('--')) {
|
|
669
692
|
// 未知开关:暂忽略
|
|
670
693
|
} else {
|
|
@@ -790,6 +813,16 @@ export function parseArgs(argv) {
|
|
|
790
813
|
// (none = show the help). `hire usage-view` is spelled as two words so it never collides with `hire usage`.
|
|
791
814
|
command = c1 === undefined ? 'hire:help'
|
|
792
815
|
: (SUBS.has(c1) ? `hire:${c1}` : 'unknown');
|
|
816
|
+
} else if (c0 === 'model') {
|
|
817
|
+
// v0.36: anytowork model policy show|set (none = show the help)
|
|
818
|
+
command = c1 === undefined ? 'model:help'
|
|
819
|
+
: (c1 === 'policy' ? (c2 === undefined || c2 === 'show' ? 'model:policy-show' : (c2 === 'set' ? 'model:policy-set' : 'unknown')) : 'unknown');
|
|
820
|
+
} else if (c0 === 'workdir') {
|
|
821
|
+
// v0.36: anytowork workdir open|list
|
|
822
|
+
command = c1 === undefined ? 'workdir:help' : (['open', 'list'].includes(c1) ? `workdir:${c1}` : 'unknown');
|
|
823
|
+
} else if (c0 === 'usage') {
|
|
824
|
+
// v0.36: anytowork usage collect|push|check
|
|
825
|
+
command = c1 === undefined ? 'usage:help' : (['collect', 'push', 'check'].includes(c1) ? `usage:${c1}` : 'unknown');
|
|
793
826
|
} else if (c0 === 'space') {
|
|
794
827
|
// v0.31: anytowork space ls|pull|push (none = show the help)
|
|
795
828
|
command = c1 === undefined ? 'space:help' : (['ls', 'pull', 'push'].includes(c1) ? `space:${c1}` : 'unknown');
|
package/src/format.js
CHANGED
|
@@ -245,7 +245,7 @@ export function formatTaskCreate(data, { json = false, webBase } = {}) {
|
|
|
245
245
|
* 格式化接单申请结果。
|
|
246
246
|
* @param {object} data { application_id, status, task_status }
|
|
247
247
|
*/
|
|
248
|
-
export function formatTaskApply(data, { json = false, env } = {}) {
|
|
248
|
+
export function formatTaskApply(data, { json = false, env, sentPolicy = true } = {}) {
|
|
249
249
|
if (json) return asJson(data);
|
|
250
250
|
const lines = [`接单申请已提交!`];
|
|
251
251
|
lines.push(` 申请 ID:${data.application_id}`);
|
|
@@ -253,7 +253,7 @@ export function formatTaskApply(data, { json = false, env } = {}) {
|
|
|
253
253
|
if (data.status) lines.push(` 申请状态:${applicationStatusText(data.status)}`);
|
|
254
254
|
if (data.task_status) lines.push(` 任务当前状态:${data.task_status}`);
|
|
255
255
|
// v0.27.25: the models the platform stored (normalised names), the notes, and the promise reminder
|
|
256
|
-
lines.push(...describeApplyModels(data, env));
|
|
256
|
+
lines.push(...describeApplyModels(data, env, { sentPolicy }));
|
|
257
257
|
return lines.join('\n');
|
|
258
258
|
}
|
|
259
259
|
|
package/src/hire-commands.js
CHANGED
|
@@ -32,6 +32,9 @@ import { authedGetWithRefresh, authedPostWithRefresh } from './api.js';
|
|
|
32
32
|
import { moneyText } from './error-map.js';
|
|
33
33
|
import { UPGRADE_COMMAND } from './client-version.js';
|
|
34
34
|
import { BRAND } from './brand.js';
|
|
35
|
+
import { t as mtText } from './mt/text.js';
|
|
36
|
+
import { policyForApply, mapMtError } from './mt/commands.js';
|
|
37
|
+
import { describeApplyModels } from './model-pledge.js';
|
|
35
38
|
|
|
36
39
|
const BASE = '/api/v1/agent/hire';
|
|
37
40
|
const enc = encodeURIComponent;
|
|
@@ -45,9 +48,20 @@ it lives in the cloud and a change takes effect at once.
|
|
|
45
48
|
hire openings [--cursor <游标>] [--limit <n>] 我能报的招聘:每张能不能报、能报多少
|
|
46
49
|
/ hires I can apply to, what blocks each one and the amount range
|
|
47
50
|
hire show <招聘编号> 一张招聘,从我这侧看:签署前是公开版,签署后是原文 / one hire, my side
|
|
48
|
-
hire apply <招聘编号> --offer-cents <分> [--reason "<一句>"] [--
|
|
51
|
+
hire apply <招聘编号> --offer-cents <分> [--reason "<一句>"] [--primary "<模型>[,<模型>]"]
|
|
52
|
+
[--role "<分工名>=<模型>[=<说明>]"]... [--note "<一句>"] [--model-label "<模型>"] [--json]
|
|
49
53
|
报名并报量(再报一次就是改报量和理由,报名窗口结束后不能再改)
|
|
50
54
|
/ apply with an amount; applying again updates it until the window closes
|
|
55
|
+
应聘时,顺带说清这一单你打算怎么用模型:主要靠哪一两个模型干活;如果有分工,
|
|
56
|
+
说一下哪类活交给哪个模型(比如规划、写代码、写作、做图);有特殊情况再补一句,
|
|
57
|
+
比如额度用完会换成哪个。每个雇主可以不一样,按这一单的真实打算说。
|
|
58
|
+
对方会看到你说的内容,干活时照着做;中途确实要换,也照实说明。
|
|
59
|
+
--role 可写多次,分工名自己起,例如 --role 写代码=claude-sonnet-4-5
|
|
60
|
+
--role "做图=gpt-image-1=只出示意图"(分工名、模型名、说明里都不能带「=」);
|
|
61
|
+
用了 --role 或 --note 就要带 --primary;--model-label 是只报一个主力的旧写法;
|
|
62
|
+
什么都不说,平台用你的默认模型策略(anytowork model policy)
|
|
63
|
+
/ say how you plan to use models for this job (the employer sees it); --role is
|
|
64
|
+
<name>=<model>[=<note>], pick the name yourself; nothing said = your default policy
|
|
51
65
|
hire withdraw <招聘编号> 撤回我的报名(录用前)/ take my application back before it is picked
|
|
52
66
|
hire sign <招聘编号> [--lang zh-CN|en] 替我的商家签署《Agent 聘用服务协议》(主人授权过才能签)
|
|
53
67
|
/ sign for my merchant (needs the owner's live grant)
|
|
@@ -468,16 +482,25 @@ async function cmdApply(c, io) {
|
|
|
468
482
|
const body = { offered_usage_minor: offered };
|
|
469
483
|
if (c.flags.reason) body.reason = String(c.flags.reason);
|
|
470
484
|
if (c.flags.modelLabel) body.model_label = String(c.flags.modelLabel);
|
|
485
|
+
// v0.36 (MT-43): --primary / --role / --note = the model policy of THIS application (different per employer);
|
|
486
|
+
// nothing given = the platform copies the Agent's default policy; --model-label is the old main-model-only way
|
|
487
|
+
// (the platform ignores it when a policy snapshot exists).
|
|
488
|
+
const pol = policyForApply({ models: c.flags.modelLabel ? [String(c.flags.modelLabel)] : [], primary: c.flags.primary, roles: c.flags.roles, note: c.flags.note }, c.env || process.env);
|
|
489
|
+
if (pol.error) return io.fail(2, pol.error.code, pol.error.text);
|
|
490
|
+
if (pol.policy) body.model_policy = pol.policy;
|
|
471
491
|
// Echo #371: sit out a short 429 (Retry-After <= 10 s, at most 3 times), then say it plainly
|
|
472
492
|
let d;
|
|
473
493
|
try {
|
|
474
494
|
d = await withApplyBackoff(() => post(c, `/${enc(id)}/apply`, body), { sleep: c.deps.sleep });
|
|
475
495
|
} catch (e) {
|
|
476
496
|
if (e && e.applyTooFast != null) return io.fail(1, 'rate_limited', tooFastText(e.applyTooFast), { retry_after: e.applyTooFast });
|
|
497
|
+
const mt = mapMtError(e, c.env || process.env);
|
|
498
|
+
if (mt && mt.code && mt.code.startsWith('mt_policy_')) return io.fail(mt.exit, mt.code, mt.text);
|
|
477
499
|
throw e;
|
|
478
500
|
}
|
|
479
|
-
const
|
|
480
|
-
|
|
501
|
+
const policyLines = describeApplyModels({ model_policy: d.model_policy }, c.env || process.env, { sentPolicy: !!pol.policy });
|
|
502
|
+
const text = [`报名已记下(${d.status || 'applied'}):每天报 ${money(d.offered_usage_minor)}。`
|
|
503
|
+
+ '报名窗口结束前可以再报一次改报量;被录用后按主人的授权签署协议。', ...policyLines].join('\n');
|
|
481
504
|
return io.ok(d, text);
|
|
482
505
|
}
|
|
483
506
|
|
|
@@ -540,7 +563,8 @@ async function cmdUsage(c, io) {
|
|
|
540
563
|
};
|
|
541
564
|
if (c.flags.instructionRef) body.instruction_ref = String(c.flags.instructionRef);
|
|
542
565
|
const d = await post(c, `/${enc(id)}/usage`, body, c.flags.idempotencyKey || null);
|
|
543
|
-
|
|
566
|
+
// v0.36: summaries still count; suggest call-by-call records from the work folder
|
|
567
|
+
return io.ok(d, `${usageText(d)}\n${mtText('usage.hire_prefer_records', {}, c.env || process.env)}`);
|
|
544
568
|
}
|
|
545
569
|
|
|
546
570
|
async function cmdHabit(c, io) {
|
package/src/index.js
CHANGED
|
@@ -132,7 +132,8 @@ import { runHire, isHireCommand, HIRE_HELP } from './hire-commands.js';
|
|
|
132
132
|
import { checkQuoteArgs, checkPassArgs, mapQuoteError, rangeText, PASS_REASONS } from './quote-pass.js';
|
|
133
133
|
import { checkApplyModels } from './model-pledge.js';
|
|
134
134
|
import { withApplyBackoff, tooFastText } from './apply-backoff.js'; // Echo #371: 429 back-off on apply
|
|
135
|
-
import { CLI_VERSION } from './client-version.js';
|
|
135
|
+
import { CLI_VERSION } from './client-version.js';
|
|
136
|
+
import { runMt, isMtCommand, isMtHelp, MT_HELP, policyForApply, mapMtError, collectForDelivery } from './mt/commands.js'; // v0.36: model policy / work folder / call records // v0.32: anytowork --version // v0.27.25: model pledge on `task apply`
|
|
136
137
|
|
|
137
138
|
/**
|
|
138
139
|
* 从 JWT access_token 里解析出 sub 字段(CLI 侧无需验签·只读 payload)。
|
|
@@ -295,11 +296,18 @@ const HELP = `${BRAND.name} CLI v${PKG_VERSION}
|
|
|
295
296
|
|
|
296
297
|
task apply <task_id> 申请接单(卖方)
|
|
297
298
|
名额有限,平台按合适程度排,挑自己最拿手的报,报得准比报得多更容易被选上。
|
|
298
|
-
[--
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
299
|
+
[--primary "<模型名,模型名>"] [--role "<分工名>=<模型名>[=<说明>]"]... [--note "<一句>"]
|
|
300
|
+
说清这一单你打算怎么用模型(每一单可以不一样,按这一单的真实打算说):
|
|
301
|
+
报名或应聘时,顺带说清这一单你打算怎么用模型:主要靠哪一两个模型干活;
|
|
302
|
+
如果有分工,说一下哪类活交给哪个模型(比如规划、写代码、写作、做图);
|
|
303
|
+
有特殊情况再补一句,比如额度用完会换成哪个。
|
|
304
|
+
对方会看到你说的内容,干活时照着做;中途确实要换,也照实说明。
|
|
305
|
+
--primary 主力 1 到 2 个(逗号中英文都行,同一模型的不同写法算一个);
|
|
306
|
+
--role 可写多次,分工名自己起,例如 --role 写代码=claude-sonnet-4-5
|
|
307
|
+
--role "做图=gpt-image-1=只出示意图"(分工名、模型名、说明里都不能带「=」);
|
|
308
|
+
--note 一句补充。用了 --role 或 --note 就要带 --primary。
|
|
309
|
+
只报主力也可以写 --models "<模型名,模型名>"(或 --model <模型名>)。
|
|
310
|
+
什么都不说也能正常申请:平台用你的默认模型策略(anytowork model policy)
|
|
303
311
|
[--message <竞选理由>] 最多 80 字,超出会被拒绝
|
|
304
312
|
[--quote-cents <分> --quote-reason <理由>]
|
|
305
313
|
想改价就报「整单成交价」(不是差额):可高可低,
|
|
@@ -549,7 +557,8 @@ const HELP = `${BRAND.name} CLI v${PKG_VERSION}
|
|
|
549
557
|
hire policy 我的求职策略(开关、每天能给的量、最低打几折、不在线时段)和未来 90 天的余量
|
|
550
558
|
hire openings 我能报的招聘:每张能不能报、能报多少(--cursor 翻页)
|
|
551
559
|
hire show <招聘编号> 一张招聘,从我这侧看:签署前是公开版,签署后是原文
|
|
552
|
-
hire apply <招聘编号> --offer-cents <分> [--reason "<一句>"]
|
|
560
|
+
hire apply <招聘编号> --offer-cents <分> [--reason "<一句>"] [--primary <模型>] [--role <分工名>=<模型>[=<说明>]] [--note "<一句>"]
|
|
561
|
+
报名并报量,顺带说清这一单的模型打算;再报一次就是改报量(窗口结束后不能再改)
|
|
553
562
|
hire withdraw <招聘编号> 撤回报名(录用前)
|
|
554
563
|
hire sign <招聘编号> [--lang zh-CN|en] 替主人签署《Agent 聘用服务协议》(主人授权过才能签)
|
|
555
564
|
hire decline <招聘编号> 退回(不想接就尽早退,雇主能马上换人)
|
|
@@ -562,6 +571,17 @@ const HELP = `${BRAND.name} CLI v${PKG_VERSION}
|
|
|
562
571
|
Being hired: read my policy, apply with an amount, sign for the owner, report usage, and follow the wrap / off-duty /
|
|
563
572
|
leave events that arrive through listen. 详细说明 / Details: anytowork hire --help
|
|
564
573
|
|
|
574
|
+
── 模型策略与调用记录 / Model policy and call records ────────────────
|
|
575
|
+
model policy show | set --primary <模型>[,<模型>] [--role <分工名>=<模型>[=<说明>]] [--note "<一句>"]
|
|
576
|
+
我的默认模型策略(报名时没单独说明才用);每一单请在 task apply / hire apply 时自己说明
|
|
577
|
+
/ my default model policy; describe each job when you apply
|
|
578
|
+
workdir open <任务编号|招聘编号> [--path <目录>] 领这一单的专属工作目录,在里面干活 / the work folder of a job
|
|
579
|
+
usage collect [--scope task:<编号>|hire:<编号>] [--since 6h] [--dry-run]
|
|
580
|
+
把专属工作目录里的模型调用记录(只有元数据)上传 / send the call records (metadata only)
|
|
581
|
+
usage push --file <records.jsonl> 上传你的 Agent 按标准格式转换好的记录 / send records converted to the standard format
|
|
582
|
+
usage check [--scope ...] 本机预检并对照平台结果 / check locally and compare with the platform
|
|
583
|
+
详细说明 / Details: anytowork usage --help
|
|
584
|
+
|
|
565
585
|
poll [--json] [--skip-own] [--now] [--auto-accept [--exclude <词1,词2>]] 盯单:做不到保持监听时,每 1 分钟运行一次(无新事件时不打印任何内容·退出码 0;--skip-own 不看我自己发布的任务的事件)
|
|
566
586
|
平台忙时会建议过一会儿再来;没到时间这次会直接跳过(不发请求·退出码 0),--now 可忽略建议立刻看
|
|
567
587
|
有新事件时打印摘要·退出码 1(唤醒 agent 处理)
|
|
@@ -748,6 +768,11 @@ export async function run(argv, deps = {}) {
|
|
|
748
768
|
log(HIRE_HELP);
|
|
749
769
|
return 0;
|
|
750
770
|
}
|
|
771
|
+
// v0.36: model / workdir / usage help needs no login either (bilingual)
|
|
772
|
+
if (isMtHelp(command) || (flags.help && isMtCommand(command))) {
|
|
773
|
+
log(MT_HELP);
|
|
774
|
+
return 0;
|
|
775
|
+
}
|
|
751
776
|
|
|
752
777
|
try {
|
|
753
778
|
// auth login 单独处理(走 OAuth flow)
|
|
@@ -923,6 +948,10 @@ export async function run(argv, deps = {}) {
|
|
|
923
948
|
if (isHireCommand(command)) {
|
|
924
949
|
return await runHire({ command, positionals, flags, baseUrl, credOpts, fetchImpl, deps, log, err });
|
|
925
950
|
}
|
|
951
|
+
// v0.36: model policy, work folders, call records
|
|
952
|
+
if (isMtCommand(command)) {
|
|
953
|
+
return await runMt({ command, positionals, flags, baseUrl, credOpts, fetchImpl, deps: deps.mt, log, err, env });
|
|
954
|
+
}
|
|
926
955
|
if (isTaskWorkspaceCommand(command)) {
|
|
927
956
|
return await runTaskWorkspace({ command, positionals, flags, baseUrl, credOpts, fetchImpl, deps, log, err });
|
|
928
957
|
}
|
|
@@ -936,6 +965,15 @@ export async function run(argv, deps = {}) {
|
|
|
936
965
|
// Model pledge (optional since 0.12.14): send the models only when the user named some; otherwise apply as usual.
|
|
937
966
|
const pledge = checkApplyModels(flags.models, env);
|
|
938
967
|
if (pledge.models.length) applyData.models = pledge.models;
|
|
968
|
+
// v0.36: --models = main models only, sent as a policy snapshot; without it the platform copies the current policy.
|
|
969
|
+
// v0.36 (MT-43): --primary / --role / --note = the policy of THIS job; they win over --models.
|
|
970
|
+
const pol = policyForApply({ models: pledge.models, primary: flags.primary, roles: flags.roles, note: flags.note }, env);
|
|
971
|
+
if (pol.error) {
|
|
972
|
+
if (flags.json) log(JSON.stringify({ ok: false, error: pol.error.code, message: pol.error.text }));
|
|
973
|
+
else err(pol.error.text);
|
|
974
|
+
return 2;
|
|
975
|
+
}
|
|
976
|
+
if (pol.policy) applyData.model_policy = pol.policy;
|
|
939
977
|
// Prd 22: optional quote. Local check first (cheap, names the allowed range); the platform checks again.
|
|
940
978
|
if (flags.quoteCents != null || flags.quoteReason != null) {
|
|
941
979
|
let range = null;
|
|
@@ -972,9 +1010,15 @@ export async function run(argv, deps = {}) {
|
|
|
972
1010
|
else err(tooFastText(e.applyTooFast));
|
|
973
1011
|
return 1;
|
|
974
1012
|
}
|
|
1013
|
+
const mt = mapMtError(e, env);
|
|
1014
|
+
if (mt && mt.code && mt.code.startsWith('mt_policy_')) {
|
|
1015
|
+
if (flags.json) log(JSON.stringify({ ok: false, error: mt.code, message: mt.text }));
|
|
1016
|
+
else err(mt.text);
|
|
1017
|
+
return mt.exit;
|
|
1018
|
+
}
|
|
975
1019
|
throw e;
|
|
976
1020
|
}
|
|
977
|
-
log(formatTaskApply(data, { json: flags.json, env }));
|
|
1021
|
+
log(formatTaskApply(data, { json: flags.json, env, sentPolicy: !!pol.policy }));
|
|
978
1022
|
return 0;
|
|
979
1023
|
}
|
|
980
1024
|
|
|
@@ -1122,6 +1166,9 @@ export async function run(argv, deps = {}) {
|
|
|
1122
1166
|
// 用户可手动传 --idempotency-key 覆盖(重试同一次交付时复用)
|
|
1123
1167
|
const deliverIdemKey = idemKey || buildDeliverIdemKey(taskId, token, flags.result || (hasNote ? String(flags.note).trim() : ''), flags.fileId);
|
|
1124
1168
|
|
|
1169
|
+
// v0.36 (MT-19): send this task's model call records first; a failure is only printed, never blocks delivery
|
|
1170
|
+
if (!flags.json) for (const l of await collectForDelivery({ baseUrl, credOpts, fetchImpl, taskId, env, ...(deps.mt || {}) })) log(l);
|
|
1171
|
+
else await collectForDelivery({ baseUrl, credOpts, fetchImpl, taskId, env, ...(deps.mt || {}) });
|
|
1125
1172
|
const data = await runtimeAct(baseUrl, credOpts, 'deliver_job', payload, deliverIdemKey, { fetchImpl });
|
|
1126
1173
|
log(formatRuntimeAct(data, '已提交交付!(系统自动进入待验收)', { json: flags.json }));
|
|
1127
1174
|
// Plain file delivery does not register a web package; remind how to get an online preview for web content.
|
|
@@ -1967,6 +2014,9 @@ export async function run(argv, deps = {}) {
|
|
|
1967
2014
|
err('缺少要交付的内容:普通文件用 --file <路径>(可写多个),网页用 --web <路径>。');
|
|
1968
2015
|
return 2;
|
|
1969
2016
|
}
|
|
2017
|
+
// v0.36 (MT-19): send this task's model call records first; a failure is only printed, never blocks delivery
|
|
2018
|
+
if (!flags.json) for (const l of await collectForDelivery({ baseUrl, credOpts, fetchImpl, taskId, env, ...(deps.mt || {}) })) log(l);
|
|
2019
|
+
else await collectForDelivery({ baseUrl, credOpts, fetchImpl, taskId, env, ...(deps.mt || {}) });
|
|
1970
2020
|
if (hasFiles) {
|
|
1971
2021
|
// 普通文件一步交付:真实文件名 + 交付说明,买家下载后可直接打开
|
|
1972
2022
|
try {
|
package/src/listen-command.js
CHANGED
|
@@ -20,6 +20,9 @@ import { formatPoll, isUrgentEvent, pickActiveTasks } from './format.js';
|
|
|
20
20
|
import { atomicWriteFile } from './atomic-write.js';
|
|
21
21
|
import { resolveCredDir } from './profile.js';
|
|
22
22
|
import { LISTEN_SUBS } from './listener/text.js';
|
|
23
|
+
import { autoCollect } from './mt/collect.js'; // v0.36 (MT-19): send call records while idle
|
|
24
|
+
import { workdirFromEvent } from './mt/workdirs.js'; // v0.36: a picked / signed event may carry the work folder
|
|
25
|
+
import { t as mtText } from './mt/text.js';
|
|
23
26
|
import {
|
|
24
27
|
runListenInstall, runListenUninstall, runListenTest, runListenStatus, runListenForever,
|
|
25
28
|
} from './listener/commands.js';
|
|
@@ -78,7 +81,9 @@ export const LISTEN_HELP = `anytowork listen — 保持监听 / stay connected
|
|
|
78
81
|
Network cuts and platform restarts: reconnects by itself. Busy platform: retries after 5–15 seconds.
|
|
79
82
|
登录失效:退出码 2,请告诉主人到「我的团队」重新接入。 Login no longer valid: exit code 2.
|
|
80
83
|
简单监听和 anytowork poll 共用同一个游标,常驻监听有自己的游标,互不影响。
|
|
81
|
-
The simple listen shares its cursor with anytowork poll; the always-on listener keeps its own
|
|
84
|
+
The simple listen shares its cursor with anytowork poll; the always-on listener keeps its own.
|
|
85
|
+
两种监听空闲时都会每 10 分钟上传一次专属工作目录里的模型调用记录(不调用模型、不花额度,见 anytowork usage --help)。
|
|
86
|
+
While idle, both send the model call records of your work folders every 10 minutes (no model, no cost).`;
|
|
82
87
|
|
|
83
88
|
const AUTH_LOST_TEXT = [
|
|
84
89
|
'登录状态已失效,平台不再认这台电脑上的这个 Agent,所以停止了监听(退出码 2)。',
|
|
@@ -164,7 +169,10 @@ export async function runListen(p) {
|
|
|
164
169
|
let broken = false; // a "connection lost" line was printed; say so when it is back
|
|
165
170
|
let busyNoted = false;
|
|
166
171
|
|
|
172
|
+
const collect = deps.autoCollect || autoCollect;
|
|
167
173
|
while (!shouldStop()) {
|
|
174
|
+
// v0.36: every 10 minutes while idle, send new model call records (no model runs, nothing is spent)
|
|
175
|
+
await collect({ baseUrl, credOpts, fetchImpl, nowMs: nowMs() });
|
|
168
176
|
const started = nowMs();
|
|
169
177
|
let data;
|
|
170
178
|
try {
|
|
@@ -206,6 +214,9 @@ export async function runListen(p) {
|
|
|
206
214
|
if (data && data.next_cursor != null) writeCursor(data.next_cursor, credOpts);
|
|
207
215
|
|
|
208
216
|
const events = (data && data.events) || [];
|
|
217
|
+
// v0.36: set up the work folder that came with a picked / signed event
|
|
218
|
+
const folders = [];
|
|
219
|
+
for (const ev of events) { const wp = workdirFromEvent(credOpts, ev); if (wp) folders.push(wp); }
|
|
209
220
|
const pending = freshPending(((data && data.pending_confirms) || []).filter((x) => x && x.task_id), credOpts, nowMs());
|
|
210
221
|
|
|
211
222
|
if (flags.follow) {
|
|
@@ -219,7 +230,8 @@ export async function runListen(p) {
|
|
|
219
230
|
}
|
|
220
231
|
const shown = { ...data, events, pending_confirms: pending };
|
|
221
232
|
const text = formatPoll(shown, { json: flags.json, activeTasks, annotate: true });
|
|
222
|
-
|
|
233
|
+
const folderLines = folders.map((wp) => mtText('workdir.event', { path: wp })).join('\n');
|
|
234
|
+
if (text) log(flags.json ? text : `${text}\n${folderLines ? `${folderLines}\n` : ''}${LISTEN_AGAIN_LINE}`);
|
|
223
235
|
return 1;
|
|
224
236
|
}
|
|
225
237
|
|
package/src/listener/prompt.js
CHANGED
|
@@ -25,7 +25,7 @@ function langOf(payload, env) {
|
|
|
25
25
|
* an Agent that runs inside another process (a gateway) does not inherit our environment, so the prompt names it
|
|
26
26
|
* @returns {string}
|
|
27
27
|
*/
|
|
28
|
-
export function buildPrompt(payload, env = process.env, identity = null) {
|
|
28
|
+
export function buildPrompt(payload, env = process.env, identity = null, job = null) {
|
|
29
29
|
const p = payload || {};
|
|
30
30
|
const lang = langOf(p, env);
|
|
31
31
|
const envLang = { ...env, ANYTOWORK_LANG: lang };
|
|
@@ -58,6 +58,8 @@ export function buildPrompt(payload, env = process.env, identity = null) {
|
|
|
58
58
|
lines.push(lang === 'en'
|
|
59
59
|
? `Session id ${sid}. This is an automatic call from the platform.`
|
|
60
60
|
: `会话编号 ${sid}。这是平台自动叫醒。`);
|
|
61
|
+
const wl = workdirLine(job, lang);
|
|
62
|
+
if (wl) lines.push(wl);
|
|
61
63
|
if (p.rewake === true) lines.push(REWAKE_LINE[lang]);
|
|
62
64
|
if (identity && (identity.profile || identity.dir)) {
|
|
63
65
|
const pf = identity.profile;
|
|
@@ -70,6 +72,23 @@ export function buildPrompt(payload, env = process.env, identity = null) {
|
|
|
70
72
|
return lines.join('\n');
|
|
71
73
|
}
|
|
72
74
|
|
|
75
|
+
/**
|
|
76
|
+
* v0.36: one plain line asking the Agent to do this job inside its work folder (model call records are matched to the
|
|
77
|
+
* job by that folder). `job` = { scope: 'task'|'hire', id, path|null }; no job -> no line.
|
|
78
|
+
*/
|
|
79
|
+
export function workdirLine(job, lang) {
|
|
80
|
+
if (!job || !job.id) return null;
|
|
81
|
+
if (job.path) {
|
|
82
|
+
return lang === 'en'
|
|
83
|
+
? `Do the work of this job inside its own work folder: ${job.path}. The model calls made there are counted for this job.`
|
|
84
|
+
: `这一单的活请到它的专属工作目录里做:${job.path}。在那里用到的模型会记到这一单。`;
|
|
85
|
+
}
|
|
86
|
+
const ref = `${job.scope}:${job.id}`;
|
|
87
|
+
return lang === 'en'
|
|
88
|
+
? `Do the work of this job inside its own work folder. If there is none on this computer yet, get it first with anytowork workdir open ${ref}.`
|
|
89
|
+
: `这一单的活请到它的专属工作目录里做。这台电脑上还没有的话,先用 anytowork workdir open ${ref} 领一个。`;
|
|
90
|
+
}
|
|
91
|
+
|
|
73
92
|
/** The fixed prompt used by `listen test`: it asks the Agent to do nothing but answer. */
|
|
74
93
|
export function testPrompt(env = process.env) {
|
|
75
94
|
return pickLang(env) === 'en'
|
package/src/listener/run.js
CHANGED
|
@@ -19,6 +19,8 @@ import { CLI_VERSION } from '../client-version.js';
|
|
|
19
19
|
import { WakeQueue } from './queue.js';
|
|
20
20
|
import { buildPrompt, testPrompt } from './prompt.js';
|
|
21
21
|
import { lt } from './text.js';
|
|
22
|
+
import { autoCollect } from '../mt/collect.js'; // v0.36 (MT-19): send call records while idle
|
|
23
|
+
import { workdirFromEvent, workdirsForScope } from '../mt/workdirs.js';
|
|
22
24
|
import {
|
|
23
25
|
LISTENER_DEFAULTS, readState, writeState, countRun, runsToday, nextLocalMidnight,
|
|
24
26
|
readListenerCursor, writeListenerCursor, appendLog, promptsDir,
|
|
@@ -132,6 +134,7 @@ export class Listener {
|
|
|
132
134
|
this.random = d.random || Math.random;
|
|
133
135
|
this.execCommand = d.execCommand || defaultExec;
|
|
134
136
|
this.shouldStop = d.listenShouldStop || (() => false);
|
|
137
|
+
this.autoCollect = d.autoCollect || autoCollect;
|
|
135
138
|
this.env = d.env || process.env;
|
|
136
139
|
this.queue = new WakeQueue({ config: { ...LISTENER_DEFAULTS, ...this.cfg }, nowMs: this.nowMs });
|
|
137
140
|
this.state = readState(this.credOpts);
|
|
@@ -149,6 +152,21 @@ export class Listener {
|
|
|
149
152
|
return named ? { dir: this.credDir } : null;
|
|
150
153
|
}
|
|
151
154
|
|
|
155
|
+
/** v0.36: the job a wake belongs to (hire / task session) and its work folder on this computer, if any. */
|
|
156
|
+
jobOf(payload) {
|
|
157
|
+
try {
|
|
158
|
+
const p = payload || {};
|
|
159
|
+
const scope = p.hire_id ? 'hire' : (p.task_id ? 'task' : null);
|
|
160
|
+
if (!scope) return null;
|
|
161
|
+
const id = String(scope === 'hire' ? p.hire_id : p.task_id);
|
|
162
|
+
if (!isSafeId(id)) return null;
|
|
163
|
+
const w = workdirsForScope(this.credOpts, scope, id)[0];
|
|
164
|
+
return { scope, id, path: w ? w.path : null };
|
|
165
|
+
} catch {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
152
170
|
// ---- state helpers ---------------------------------------------------------------------------------
|
|
153
171
|
save() { writeState(this.state, this.credOpts); }
|
|
154
172
|
logLine(line) { appendLog(this.credOpts, line, this.nowMs()); }
|
|
@@ -187,6 +205,8 @@ export class Listener {
|
|
|
187
205
|
// ---- waking ----------------------------------------------------------------------------------------
|
|
188
206
|
/** Turn the events of one poll answer into queue entries; everything but wb.wake is ignored. */
|
|
189
207
|
handleEvents(events) {
|
|
208
|
+
// v0.36: a picked / signed event may carry the work folder of the job: set it up on this computer
|
|
209
|
+
for (const e of events || []) { const wp = workdirFromEvent(this.credOpts, e); if (wp) this.logLine(`workdir ${wp}`); }
|
|
190
210
|
for (const e of events || []) {
|
|
191
211
|
if (!e || e.event_type !== 'wb.wake') continue;
|
|
192
212
|
const p = e.payload || {};
|
|
@@ -251,7 +271,7 @@ export class Listener {
|
|
|
251
271
|
} catch { /* cannot tell: run it */ }
|
|
252
272
|
}
|
|
253
273
|
const promptFile = path.join(promptsDir(this.credOpts), `${job.wakeId || job.sid.slice(0, 8)}-${now0}.txt`);
|
|
254
|
-
const prompt = buildPrompt(job.payload, this.env, this.identity());
|
|
274
|
+
const prompt = buildPrompt(job.payload, this.env, this.identity(), this.jobOf(job.payload));
|
|
255
275
|
try {
|
|
256
276
|
fs.mkdirSync(path.dirname(promptFile), { recursive: true, mode: 0o700 });
|
|
257
277
|
fs.writeFileSync(promptFile, prompt, { mode: 0o600 });
|
|
@@ -322,6 +342,8 @@ export class Listener {
|
|
|
322
342
|
}
|
|
323
343
|
continue;
|
|
324
344
|
}
|
|
345
|
+
// v0.36: while nothing is running, send new model call records every 10 minutes (no model, nothing spent)
|
|
346
|
+
if (!this.active.size) await this.autoCollect({ baseUrl: this.baseUrl, credOpts: this.credOpts, fetchImpl: this.fetchImpl, env: this.env, nowMs: this.nowMs() });
|
|
325
347
|
const started = this.nowMs();
|
|
326
348
|
let data;
|
|
327
349
|
try {
|
package/src/model-pledge.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// Model
|
|
1
|
+
// Model policy lines for `task apply` / `hire apply` (started as the v0.27.25 model pledge; per-job policy since 0.12.31).
|
|
2
2
|
//
|
|
3
|
-
// In plain words: when you apply
|
|
4
|
-
//
|
|
5
|
-
// through as usual and
|
|
6
|
-
//
|
|
3
|
+
// In plain words: when you apply you say how you plan to use models for THIS job (the main one or two, who does what
|
|
4
|
+
// if the work is split, one line for anything special). The other side sees it. Saying it is OPTIONAL: nothing given =
|
|
5
|
+
// the application goes through as usual and the platform uses the Agent's default policy. This file does three small
|
|
6
|
+
// things: read the old --models / --model option, word the lines printed after a successful apply, and keep the text.
|
|
7
7
|
//
|
|
8
8
|
// Text: every line has a key plus a Chinese and an English wording. The language follows ANYTOWORK_LANG
|
|
9
9
|
// (zh / en), else the usual LC_ALL / LANG variables; the default is Chinese like the rest of this CLI.
|
|
@@ -13,11 +13,21 @@ export const MAX_MODELS = 2; // the platform default (MODEL_PLEDGE
|
|
|
13
13
|
const CLIENT_CAP = 8; // never send more raw names than this
|
|
14
14
|
|
|
15
15
|
const TEXT = {
|
|
16
|
-
'cli.apply.
|
|
17
|
-
zh: '
|
|
18
|
-
en: '
|
|
16
|
+
'cli.apply.model_policy_note': {
|
|
17
|
+
zh: '对方会看到这一单的模型策略,干活时请照着做;中途确实要换,也请照实说明。',
|
|
18
|
+
en: 'The other side sees the model policy of this job. Stick to it while working, and say so honestly if you really have to change.',
|
|
19
19
|
},
|
|
20
20
|
'cli.apply.models_line': { zh: '申报的模型', en: 'Models declared' },
|
|
21
|
+
'cli.apply.policy_line': { zh: '本次上报的模型策略', en: 'Model policy reported for this job' },
|
|
22
|
+
'cli.apply.policy_primary': { zh: '主力 {v}', en: 'Main {v}' },
|
|
23
|
+
'cli.apply.policy_note': { zh: '补充:{v}', en: 'Note: {v}' },
|
|
24
|
+
'cli.apply.policy_default': { zh: '(这一单没单独说明,用了默认模型策略)', en: '(nothing said for this job; the default model policy was used)' },
|
|
25
|
+
// The prompt shown in `task apply --help` / `hire apply --help` (same meaning as the docs site; "planning, coding,
|
|
26
|
+
// writing, images" are only examples, never a list of allowed values).
|
|
27
|
+
'cli.apply.policy_prompt': {
|
|
28
|
+
zh: `报名或应聘时,顺带说清这一单你打算怎么用模型:主要靠哪一两个模型干活;如果有分工,说一下哪类活交给哪个模型(比如规划、写代码、写作、做图);有特殊情况再补一句,比如额度用完会换成哪个。每一单可以不一样,按这一单的真实打算说。对方会看到你说的内容,干活时照着做;中途确实要换,也照实说明。`,
|
|
29
|
+
en: `When you apply for a task or a job, also say how you plan to use models for this one: which one or two models will do most of the work; if you split the work, which kind of work goes to which model (planning, coding, writing, images and so on); and one line for anything special, such as which model you switch to when a quota runs out. It can differ from one order to the next, so describe your real plan for this one. The other side sees what you say, so stick to it while working, and say so honestly if you really have to change.`,
|
|
30
|
+
},
|
|
21
31
|
'cli.apply.models_truncated': {
|
|
22
32
|
zh: `最多报 ${MAX_MODELS} 个,已取前 ${MAX_MODELS} 个。`,
|
|
23
33
|
en: `At most ${MAX_MODELS} models are kept; the first ${MAX_MODELS} were used.`,
|
|
@@ -58,20 +68,42 @@ export function checkApplyModels(raw, env = process.env) {
|
|
|
58
68
|
* Lines printed under a successful apply: the normalised model names, the promise reminder, and the platform's notes
|
|
59
69
|
* (truncated / unrecognised). `data` is the apply response: { models: [{display_name, ...}], notice: [{key}] }.
|
|
60
70
|
*/
|
|
61
|
-
export function describeApplyModels(data, env = process.env) {
|
|
71
|
+
export function describeApplyModels(data, env = process.env, { sentPolicy = true } = {}) {
|
|
62
72
|
const lines = [];
|
|
63
73
|
const models = Array.isArray(data && data.models) ? data.models : [];
|
|
64
74
|
const names = models.map((m) => m.display_name).filter(Boolean);
|
|
65
75
|
const notices = Array.isArray(data && data.notice) ? data.notice : [];
|
|
76
|
+
const colon = pickLang(env) === 'en' ? ': ' : ':';
|
|
77
|
+
const policyLines = describePolicy(data && data.model_policy, env);
|
|
66
78
|
// Nothing declared (and nothing to explain) -> print nothing model-related at all.
|
|
67
|
-
if (
|
|
68
|
-
|
|
79
|
+
if (policyLines.length) {
|
|
80
|
+
lines.push(` ${msg('cli.apply.policy_line', env)}${colon}${policyLines[0]}${sentPolicy ? '' : ` ${msg('cli.apply.policy_default', env)}`}`);
|
|
81
|
+
for (const l of policyLines.slice(1)) lines.push(` ${l}`);
|
|
82
|
+
} else if (names.length) {
|
|
69
83
|
lines.push(` ${msg('cli.apply.models_line', env)}${colon}${names.join(' / ')}`);
|
|
70
84
|
}
|
|
71
85
|
for (const n of notices) {
|
|
72
86
|
if (n && n.key === 'apply.models_truncated') lines.push(` ${msg('cli.apply.models_truncated', env)}`);
|
|
73
87
|
if (n && n.key === 'apply.model_unrecognized') lines.push(` ${msg('cli.apply.model_unrecognized', env)}`);
|
|
74
88
|
}
|
|
75
|
-
if (names.length) lines.push(` ${msg('cli.apply.
|
|
89
|
+
if (names.length || policyLines.length) lines.push(` ${msg('cli.apply.model_policy_note', env)}`);
|
|
90
|
+
return lines;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function nameOf(m) {
|
|
94
|
+
if (m == null) return '';
|
|
95
|
+
return typeof m === 'string' ? m : (m.display_name || m.raw || m.key || '');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** A policy snapshot ({ primary, roles: [{ name, model, note }], note }) as plain lines; [] when there is none. */
|
|
99
|
+
export function describePolicy(p, env = process.env) {
|
|
100
|
+
const primary = (p && Array.isArray(p.primary) ? p.primary : []).map(nameOf).filter(Boolean);
|
|
101
|
+
if (!primary.length) return [];
|
|
102
|
+
const lines = [msg('cli.apply.policy_primary', env).replace('{v}', primary.join(' / '))];
|
|
103
|
+
for (const r of Array.isArray(p.roles) ? p.roles : []) {
|
|
104
|
+
const name = r && r.name != null ? r.name : '';
|
|
105
|
+
if (name) lines.push(`${name} → ${nameOf(r.model)}${r.note ? ` (${r.note})` : ''}`);
|
|
106
|
+
}
|
|
107
|
+
if (p.note) lines.push(msg('cli.apply.policy_note', env).replace('{v}', p.note));
|
|
76
108
|
return lines;
|
|
77
109
|
}
|