@anytowork/cli 0.12.54 → 0.12.56
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/package.json +1 -1
- package/src/format.js +3 -1
- package/src/hire-commands.js +10 -15
- package/src/index.js +8 -18
- package/src/listener/hire-wake.js +59 -0
- package/src/listener/prompt.js +0 -19
- package/src/listener/run.js +62 -1
- package/src/mt/commands.js +11 -1
- package/src/mt/text.js +4 -0
package/package.json
CHANGED
package/src/format.js
CHANGED
|
@@ -1178,7 +1178,9 @@ export function hireEventLines(e) {
|
|
|
1178
1178
|
case 'hire.topup': {
|
|
1179
1179
|
const yuan = (n) => (Number(n || 0) / 100).toFixed(2).replace(/\.00$/, '');
|
|
1180
1180
|
return [
|
|
1181
|
-
|
|
1181
|
+
p.reminder
|
|
1182
|
+
? `${ind}⏰ 提醒:雇主今天的加量还在等你回复(多付 ${yuan(p.pay_minor)} 元,用量上限加 ${yuan(p.add_minor)} 元)${p.deadline_at ? ',' + p.deadline_at + ' 前不回复就全额退回雇主' : ',快到期了'}`
|
|
1183
|
+
: `${ind}➕ 雇主今天给这条聘用加量:多付 ${yuan(p.pay_minor)} 元,今天的用量上限加 ${yuan(p.add_minor)} 元${p.deadline_at ? ',' + p.deadline_at + ' 前回复' : ''}`,
|
|
1182
1184
|
`${ind}能接就同意,接不了就拒绝(拒绝或超时,雇主的钱全额退回):anytowork hire topup ${id} --accept(或 --reject)`,
|
|
1183
1185
|
];
|
|
1184
1186
|
}
|
package/src/hire-commands.js
CHANGED
|
@@ -35,7 +35,7 @@ import { moneyText } from './error-map.js';
|
|
|
35
35
|
import { UPGRADE_COMMAND } from './client-version.js';
|
|
36
36
|
import { BRAND } from './brand.js';
|
|
37
37
|
import { t as mtText } from './mt/text.js';
|
|
38
|
-
import {
|
|
38
|
+
import { ignoredPolicyNotice, mapMtError } from './mt/commands.js';
|
|
39
39
|
import { describeApplyModels } from './model-pledge.js';
|
|
40
40
|
|
|
41
41
|
const BASE = '/api/v1/agent/hire';
|
|
@@ -50,23 +50,19 @@ it lives in the cloud and a change takes effect at once.
|
|
|
50
50
|
hire openings [--cursor <游标>] [--limit <n>] 我能报的招聘:每张能不能报、能报多少
|
|
51
51
|
/ hires I can apply to, what blocks each one and the amount range
|
|
52
52
|
hire show <招聘编号> 一张招聘,从我这侧看:签署前是公开版,签署后是原文 / one hire, my side
|
|
53
|
-
hire apply <招聘编号> --offer-cents <分> [--reason "<一句>"] [--
|
|
54
|
-
[--role "<分工名>=<模型>[=<说明>]"]... [--note "<一句>"] [--model-label "<模型>"] [--json]
|
|
53
|
+
hire apply <招聘编号> --offer-cents <分> [--reason "<一句>"] [--json]
|
|
55
54
|
报名并报量(3 分钟公示期内再报一次就是改报量和理由)。公示期结束只锁定已报的价,
|
|
56
55
|
截止前还没报名的仍可以新报名
|
|
57
56
|
/ apply with an amount; applying again within the 3-minute notice updates it. After
|
|
58
57
|
the notice only the price is locked: until the deadline anyone can still apply
|
|
59
58
|
应聘必须说明主力模型和模型策略,主力模型要在平台价格表里(否则算不出用量额度,
|
|
60
|
-
|
|
61
|
-
(anytowork model policy set --primary
|
|
62
|
-
|
|
59
|
+
报不了名)。雇主在候选人卡上看到的是它的当前值:先设好
|
|
60
|
+
(anytowork model policy set --primary <模型>)。报名时不再单独带策略,
|
|
61
|
+
--primary / --role / --note 会被忽略。
|
|
63
62
|
做法见 https://a2a.linger.chimap.cn/docs/guide/agent-setup#model-policy
|
|
64
|
-
--role 可写多次,分工名自己起,例如 --role 复杂判断=<模型A>
|
|
65
|
-
--role "做图=<模型B>=只出示意图"(分工名、模型名、说明里都不能带「=」);
|
|
66
|
-
用了 --role 或 --note 就要带 --primary;--model-label 是只报一个主力的旧写法;
|
|
67
63
|
/ A main model and model policy are required, and the main model must be in the
|
|
68
64
|
platform price table (otherwise the usage amount cannot be worked out).
|
|
69
|
-
|
|
65
|
+
Set the policy once with model policy set; --primary / --role / --note on apply are ignored.
|
|
70
66
|
Details: https://a2a.linger.chimap.cn/en/docs/guide/agent-setup#model-policy
|
|
71
67
|
--role is <name>=<model>[=<note>], pick the name yourself
|
|
72
68
|
hire pass <招聘编号> [--reason "<一句>"] 这单我不报名(不在能力范围、时间不合适…):平台不记这个,只是告诉你可以放下
|
|
@@ -538,9 +534,8 @@ async function cmdApply(c, io) {
|
|
|
538
534
|
// v0.36 (MT-43): --primary / --role / --note = the model policy of THIS application (different per employer);
|
|
539
535
|
// nothing given = the platform copies the Agent's default policy; --model-label is the old main-model-only way
|
|
540
536
|
// (the platform ignores it when a policy snapshot exists).
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
if (pol.policy) body.model_policy = pol.policy;
|
|
537
|
+
// v0.38.42: no policy of its own any more: the flags are accepted and ignored, with a one-line hint after the result.
|
|
538
|
+
const ignored = ignoredPolicyNotice({ primary: c.flags.primary, roles: c.flags.roles, note: c.flags.note }, c.env || process.env);
|
|
544
539
|
// Echo #371: sit out a short 429 (Retry-After <= 10 s, at most 3 times), then say it plainly
|
|
545
540
|
let d;
|
|
546
541
|
try {
|
|
@@ -551,9 +546,9 @@ async function cmdApply(c, io) {
|
|
|
551
546
|
if (mt && mt.code && mt.code.startsWith('mt_policy_')) return io.fail(mt.exit, mt.code, mt.text);
|
|
552
547
|
throw e;
|
|
553
548
|
}
|
|
554
|
-
const policyLines = describeApplyModels({ model_policy: d.model_policy }, c.env || process.env, { sentPolicy:
|
|
549
|
+
const policyLines = describeApplyModels({ model_policy: d.model_policy }, c.env || process.env, { sentPolicy: false });
|
|
555
550
|
const text = [`报名已记下(${d.status || 'applied'}):每天报 ${money(d.offered_usage_minor)}。`
|
|
556
|
-
+ '3 分钟公示期内可以再报一次改报量和理由,之后只能撤回;被录用后按主人的授权签署协议。', ...policyLines].join('\n');
|
|
551
|
+
+ '3 分钟公示期内可以再报一次改报量和理由,之后只能撤回;被录用后按主人的授权签署协议。', ...policyLines, ...(ignored ? [ignored] : [])].join('\n');
|
|
557
552
|
return io.ok(d, text);
|
|
558
553
|
}
|
|
559
554
|
|
package/src/index.js
CHANGED
|
@@ -140,7 +140,7 @@ import { withApplyBackoff, tooFastText } from './apply-backoff.js'; // Echo #3
|
|
|
140
140
|
import { CLI_VERSION } from './client-version.js';
|
|
141
141
|
import { takeNudges, clearNudges, nudgeLines } from './listener/nudge.js'; // v0.38.7: new message while running
|
|
142
142
|
import { readCurrentSession } from './chat-state.js';
|
|
143
|
-
import { runMt, isMtCommand, isMtHelp, MT_HELP,
|
|
143
|
+
import { runMt, isMtCommand, isMtHelp, MT_HELP, ignoredPolicyNotice, 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`
|
|
144
144
|
|
|
145
145
|
/**
|
|
146
146
|
* 从 JWT access_token 里解析出 sub 字段(CLI 侧无需验签·只读 payload)。
|
|
@@ -303,16 +303,10 @@ const HELP = `${BRAND.name} CLI v${PKG_VERSION}
|
|
|
303
303
|
|
|
304
304
|
task apply <task_id> 申请接单(卖方)
|
|
305
305
|
名额有限,平台按合适程度排,挑自己最拿手的报,报得准比报得多更容易被选上。
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
也更容易选你。最省事是设一次默认策略,以后每次报名自动带上;这一单想不一样,
|
|
309
|
-
再临时说明。不说明也能报名,雇主会看到"未说明模型"。
|
|
310
|
-
做法见 https://a2a.linger.chimap.cn/docs/guide/agent-setup#model-policy
|
|
311
|
-
--primary 主力 1 到 2 个(逗号中英文都行,同一模型的不同写法算一个);
|
|
312
|
-
--role 可写多次,分工名自己起,例如 --role 复杂判断=<模型A>
|
|
313
|
-
--role "做图=<模型B>=只出示意图"(分工名、模型名、说明里都不能带「=」);
|
|
314
|
-
--note 一句补充。用了 --role 或 --note 就要带 --primary。
|
|
306
|
+
模型策略请先用 model policy set 设好,雇主在候选人卡上看到的就是它的当前值;
|
|
307
|
+
报名时不再单独带策略(--primary / --role / --note 会被忽略)。
|
|
315
308
|
只报主力也可以写 --models "<模型名,模型名>"(或 --model <模型名>)。
|
|
309
|
+
做法见 https://a2a.linger.chimap.cn/docs/guide/agent-setup#model-policy
|
|
316
310
|
Say which models you mainly use and how (the employer sees it on your card).
|
|
317
311
|
Easiest: set a default policy once; describe each job only when it differs.
|
|
318
312
|
Details: https://a2a.linger.chimap.cn/en/docs/guide/agent-setup#model-policy
|
|
@@ -1009,13 +1003,9 @@ async function runCore(argv, deps = {}, ctx = {}) {
|
|
|
1009
1003
|
if (pledge.models.length) applyData.models = pledge.models;
|
|
1010
1004
|
// v0.36: --models = main models only, sent as a policy snapshot; without it the platform copies the current policy.
|
|
1011
1005
|
// v0.36 (MT-43): --primary / --role / --note = the policy of THIS job; they win over --models.
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
else err(pol.error.text);
|
|
1016
|
-
return 2;
|
|
1017
|
-
}
|
|
1018
|
-
if (pol.policy) applyData.model_policy = pol.policy;
|
|
1006
|
+
// v0.38.42: no policy of its own any more: the flags are accepted and ignored, with a one-line hint.
|
|
1007
|
+
const ignored = ignoredPolicyNotice({ primary: flags.primary, roles: flags.roles, note: flags.note }, env);
|
|
1008
|
+
if (ignored) err(ignored);
|
|
1019
1009
|
// Prd 22: optional quote. Local check first (cheap, names the allowed range); the platform checks again.
|
|
1020
1010
|
if (flags.quoteCents != null || flags.quoteReason != null) {
|
|
1021
1011
|
let range = null;
|
|
@@ -1060,7 +1050,7 @@ async function runCore(argv, deps = {}, ctx = {}) {
|
|
|
1060
1050
|
}
|
|
1061
1051
|
throw e;
|
|
1062
1052
|
}
|
|
1063
|
-
log(formatTaskApply(data, { json: flags.json, env, sentPolicy:
|
|
1053
|
+
log(formatTaskApply(data, { json: flags.json, env, sentPolicy: false }));
|
|
1064
1054
|
return 0;
|
|
1065
1055
|
}
|
|
1066
1056
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Always-on listener: waking the Agent for a hire event that waits for its answer (v0.38.41).
|
|
2
|
+
//
|
|
3
|
+
// Before this, the listener woke the Agent only for a workbench message (`wb.wake`). A hire event such as "you were
|
|
4
|
+
// picked, sign" or "the employer paid a top-up, accept or refuse" reached only whoever ran `anytowork poll`, so an Agent
|
|
5
|
+
// that is connected through the listener never heard of it. These events now start the Agent once, in a session of its
|
|
6
|
+
// own (the fixed key `hire-events`: there is no workbench session for them), with a prompt that names what waits and
|
|
7
|
+
// the commands to answer it. Informational hire events (start, wrap-up, stop for the day, left) do not wake the Agent.
|
|
8
|
+
|
|
9
|
+
import { hireEventLines } from '../format.js';
|
|
10
|
+
import { pickLang } from '../model-pledge.js';
|
|
11
|
+
|
|
12
|
+
/** The hire events that wait for an answer from the Agent and may end in a refund or a lost hire when nobody answers. */
|
|
13
|
+
export const WAKE_HIRE_EVENTS = new Set(['hire.to_sign', 'hire.topup', 'hire.reschedule']);
|
|
14
|
+
|
|
15
|
+
/** The session key every such run uses (placeholders {sid} and {session_key} of the start command). */
|
|
16
|
+
export const HIRE_WAKE_KEY = 'hire-events';
|
|
17
|
+
|
|
18
|
+
/** Events of one poll answer that should wake the Agent for a hire (an id is needed to tell a repeat from a new one). */
|
|
19
|
+
export function hireWakeEvents(events) {
|
|
20
|
+
return (events || []).filter((e) => e && WAKE_HIRE_EVENTS.has(e.event_type) && e.id != null);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** True when the event itself says its time to answer has already gone by (an old event met after a restart). */
|
|
24
|
+
export function hireEventExpired(e, nowMs) {
|
|
25
|
+
const dl = e && e.payload && e.payload.deadline_at ? Date.parse(e.payload.deadline_at) : NaN;
|
|
26
|
+
return Number.isFinite(dl) && dl < nowMs;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const EN_LINE = {
|
|
30
|
+
'hire.to_sign': (p) => `- You were picked for a hire${p.title ? ` "${p.title}"` : ''}${p.deadline_at ? `, sign before ${p.deadline_at}` : ''}: anytowork hire sign ${p.hire_id || '<hire id>'} (or hire decline)`,
|
|
31
|
+
'hire.topup': (p) => `- ${p.reminder ? 'Reminder: ' : ''}the employer paid a top-up for today${p.deadline_at ? `, answer before ${p.deadline_at}` : ''}; no answer in time = a full refund: anytowork hire topup ${p.hire_id || '<hire id>'} --accept | --reject`,
|
|
32
|
+
'hire.reschedule': (p) => `- The employer asks to move the start date to ${p.new_start_date || 'a new date'}: anytowork hire decide ${p.hire_id || '<hire id>'} --request ${p.request_id || '<request id>'} --accept | --reject`,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/** The words handed to the Agent on standard input. */
|
|
36
|
+
export function hireWakePrompt(events, env = process.env) {
|
|
37
|
+
const lang = pickLang(env);
|
|
38
|
+
const list = hireWakeEvents(events);
|
|
39
|
+
if (lang === 'en') {
|
|
40
|
+
const lines = list.map((e) => EN_LINE[e.event_type]((e.payload) || {}));
|
|
41
|
+
return [
|
|
42
|
+
'[AnytoWork] There are hire events waiting for you (this is not a chat message).',
|
|
43
|
+
...lines,
|
|
44
|
+
'Run `anytowork poll` to see everything that waits and `anytowork hire mine` for your hires (a top-up shows there as well), then answer; stop when done.',
|
|
45
|
+
].join('\n');
|
|
46
|
+
}
|
|
47
|
+
const lines = [];
|
|
48
|
+
for (const e of list) {
|
|
49
|
+
const p = (e && e.payload) || {};
|
|
50
|
+
const own = hireEventLines(e).map((x) => `- ${x.trim()}`);
|
|
51
|
+
lines.push(...(own.length ? own : [`- ${e.event_type}`]));
|
|
52
|
+
if (p.reminder) lines.push(' (这是加量的到期提醒,快到回复截止时间了)');
|
|
53
|
+
}
|
|
54
|
+
return [
|
|
55
|
+
'[AnytoWork] 有招聘事件等你处理(不是聊天消息)。',
|
|
56
|
+
...lines,
|
|
57
|
+
'先运行 anytowork poll 看全部待办,再运行 anytowork hire mine 看你的聘用(加量也在里面);加量用 anytowork hire topup <招聘编号> --accept 或 --reject。处理完就结束。',
|
|
58
|
+
].join('\n');
|
|
59
|
+
}
|
package/src/listener/prompt.js
CHANGED
|
@@ -60,8 +60,6 @@ export function buildPrompt(payload, env = process.env, identity = null, job = n
|
|
|
60
60
|
lines.push(lang === 'en'
|
|
61
61
|
? `Session id ${sid}. Automatic call from the platform.`
|
|
62
62
|
: `会话编号 ${sid}。平台自动叫醒。`);
|
|
63
|
-
const wl = workdirLine(job, lang);
|
|
64
|
-
if (wl) lines.push(wl);
|
|
65
63
|
if (p.rewake === true) lines.push(REWAKE_LINE[lang]);
|
|
66
64
|
// v0.38.7: a hired Agent is told how much of today's usage allowance is left (the rules say what to do when it is low)
|
|
67
65
|
if (Number.isFinite(Number(p.quota_left_pct)) && p.quota_left_pct !== null && p.quota_left_pct !== '') {
|
|
@@ -98,23 +96,6 @@ export function buildPrompt(payload, env = process.env, identity = null, job = n
|
|
|
98
96
|
return lines.join('\n');
|
|
99
97
|
}
|
|
100
98
|
|
|
101
|
-
/**
|
|
102
|
-
* v0.36: one plain line asking the Agent to do this job inside its work folder (model call records are matched to the
|
|
103
|
-
* job by that folder). `job` = { scope: 'task'|'hire', id, path|null }; no job -> no line.
|
|
104
|
-
*/
|
|
105
|
-
export function workdirLine(job, lang) {
|
|
106
|
-
if (!job || !job.id) return null;
|
|
107
|
-
if (job.path) {
|
|
108
|
-
return lang === 'en'
|
|
109
|
-
? `Do this job inside its own work folder: ${job.path} (model calls made there count for this job).`
|
|
110
|
-
: `这一单的活请到它的专属工作目录里做:${job.path}(在那里用到的模型记到这一单)。`;
|
|
111
|
-
}
|
|
112
|
-
const ref = `${job.scope}:${job.id}`;
|
|
113
|
-
return lang === 'en'
|
|
114
|
-
? `Do this job inside its own work folder; if there is none on this computer yet, get one first: anytowork workdir open ${ref}.`
|
|
115
|
-
: `这一单的活请到它的专属工作目录里做。这台电脑上还没有的话,先用 anytowork workdir open ${ref} 领一个。`;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
99
|
/** The fixed prompt used by `listen test`: it asks the Agent to do nothing but answer. */
|
|
119
100
|
export function testPrompt(env = process.env) {
|
|
120
101
|
return pickLang(env) === 'en'
|
package/src/listener/run.js
CHANGED
|
@@ -20,6 +20,7 @@ import { WakeQueue } from './queue.js';
|
|
|
20
20
|
import { buildPrompt, testPrompt } from './prompt.js';
|
|
21
21
|
import { lt } from './text.js';
|
|
22
22
|
import { writeNudge } from './nudge.js';
|
|
23
|
+
import { hireWakeEvents, hireWakePrompt, hireEventExpired, HIRE_WAKE_KEY } from './hire-wake.js'; // v0.38.41: hire events that wait for an answer
|
|
23
24
|
import { wakeTestPrompt, noteWakeTests, testCode } from '../setup-hints.js'; // v0.37: wake-up test event
|
|
24
25
|
import { autoCollect } from '../mt/collect.js'; // v0.36 (MT-19): send call records while idle
|
|
25
26
|
import { workdirFromEvent, workdirsForScope } from '../mt/workdirs.js';
|
|
@@ -308,7 +309,7 @@ export class Listener {
|
|
|
308
309
|
}
|
|
309
310
|
|
|
310
311
|
// ---- waking ----------------------------------------------------------------------------------------
|
|
311
|
-
/** Turn the events of one poll answer into queue entries;
|
|
312
|
+
/** Turn the events of one poll answer into queue entries; wb.wake, wake_test and the hire events that wait for an answer wake the Agent, everything else is ignored. */
|
|
312
313
|
handleEvents(events) {
|
|
313
314
|
// v0.36: a picked / signed event may carry the work folder of the job: set it up on this computer
|
|
314
315
|
for (const e of events || []) { const wp = workdirFromEvent(this.credOpts, e); if (wp) this.logLine(`workdir ${wp}`); }
|
|
@@ -318,6 +319,7 @@ export class Listener {
|
|
|
318
319
|
for (const e of events || []) {
|
|
319
320
|
if (e && e.event_type === 'wake_test') this.handleWakeTest(e);
|
|
320
321
|
}
|
|
322
|
+
this.handleHireEvents(events);
|
|
321
323
|
for (const e of events || []) {
|
|
322
324
|
if (!e || e.event_type !== 'wb.wake') continue;
|
|
323
325
|
const p = e.payload || {};
|
|
@@ -357,6 +359,65 @@ export class Listener {
|
|
|
357
359
|
this.pump();
|
|
358
360
|
}
|
|
359
361
|
|
|
362
|
+
/**
|
|
363
|
+
* v0.38.41: a hire event that waits for the Agent (picked: sign; top-up: accept or refuse; new start date: decide).
|
|
364
|
+
* One run for all such events of one poll answer, in the session `hire-events` (no workbench session needed). An event
|
|
365
|
+
* id that was already handled is not started twice, an event whose own deadline has passed is skipped, a run already
|
|
366
|
+
* going holds the next one back until it ends. Like a wake-up it stops while paused and counts against the daily limit.
|
|
367
|
+
*/
|
|
368
|
+
handleHireEvents(events) {
|
|
369
|
+
const fresh = hireWakeEvents(events);
|
|
370
|
+
if (!fresh.length) return;
|
|
371
|
+
if (!this.seenHire) this.seenHire = new Set();
|
|
372
|
+
const now = this.nowMs();
|
|
373
|
+
for (const e of fresh) {
|
|
374
|
+
const key = String(e.id);
|
|
375
|
+
if (this.seenHire.has(key)) continue;
|
|
376
|
+
this.seenHire.add(key);
|
|
377
|
+
if (this.seenHire.size > 200) this.seenHire.delete(this.seenHire.values().next().value);
|
|
378
|
+
if (hireEventExpired(e, now)) { this.logLine(`hire event id=${key} expired`); continue; }
|
|
379
|
+
if (this.isPaused()) { this.logLine(`hire event id=${key} paused`); continue; }
|
|
380
|
+
(this.hireWaiting || (this.hireWaiting = [])).push(e);
|
|
381
|
+
}
|
|
382
|
+
this.pumpHire();
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
pumpHire() {
|
|
386
|
+
if (this.hireRunning || !this.hireWaiting || !this.hireWaiting.length || this.isPaused()) return;
|
|
387
|
+
const now = this.nowMs();
|
|
388
|
+
if (runsToday(this.state, now) >= effectiveDailyMax(this.cfg, this.state)) { this.hireWaiting = []; this.pause('cap'); return; }
|
|
389
|
+
const batch = this.hireWaiting.splice(0);
|
|
390
|
+
countRun(this.state, now);
|
|
391
|
+
this.save();
|
|
392
|
+
this.hireRunning = true;
|
|
393
|
+
const pr = this.runHireWake(batch).catch(() => {}).finally(() => { this.hireRunning = false; this.active.delete(pr); this.pumpHire(); });
|
|
394
|
+
this.active.add(pr);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
async runHireWake(batch) {
|
|
398
|
+
const now0 = this.nowMs();
|
|
399
|
+
const key = HIRE_WAKE_KEY;
|
|
400
|
+
const firstId = String(batch[0].id);
|
|
401
|
+
const promptFile = path.join(promptsDir(this.credOpts), `hire-${firstId}-${now0}.txt`);
|
|
402
|
+
let wrote = false;
|
|
403
|
+
const prompt = hireWakePrompt(batch, this.env);
|
|
404
|
+
try {
|
|
405
|
+
fs.mkdirSync(path.dirname(promptFile), { recursive: true, mode: 0o700 });
|
|
406
|
+
fs.writeFileSync(promptFile, prompt, { mode: 0o600 });
|
|
407
|
+
wrote = true;
|
|
408
|
+
} catch { /* the prompt still goes on standard input */ }
|
|
409
|
+
try {
|
|
410
|
+
const hid = batch.map((e) => e.payload && e.payload.hire_id).find((h) => isSafeId(String(h || ''))) || '';
|
|
411
|
+
const vals = { sid: key, sessionKey: key, groupId: '', wakeId: firstId, reason: 'hire_event', hireId: hid ? String(hid) : '', promptFile };
|
|
412
|
+
const env = buildRunEnv({ base: this.env, cfg: this.cfg, vals, credDir: this.credDir });
|
|
413
|
+
const res = await this.execCommand({ command: expandCommand(this.cfg.exec, vals), input: `${prompt}\n`, env, cwd: this.cfg.cwd, timeoutMs: this.cfg.timeoutMs });
|
|
414
|
+
const ok = !!res && res.code === 0 && !res.timedOut && !res.error;
|
|
415
|
+
this.logLine(`hire wake ids=${batch.map((e) => e.id).join(',')} ${ok ? 'ok' : 'fail'} ms=${this.nowMs() - now0}`);
|
|
416
|
+
} finally {
|
|
417
|
+
if (wrote) { try { fs.unlinkSync(promptFile); } catch { /* gone */ } }
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
360
421
|
/**
|
|
361
422
|
* v0.37 PA-12: the platform started a wake-up test for this Agent (`wake_test`: {test_id, nonce, deadline_at, next_action}).
|
|
362
423
|
* Start the Agent once with a prompt that only asks it to answer the test. The isolation key is the fixed word
|
package/src/mt/commands.js
CHANGED
|
@@ -85,7 +85,17 @@ export function policyBody(p) {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
|
-
*
|
|
88
|
+
* v0.38.42: an application no longer carries a model policy of its own (the Agent has one current policy, set with
|
|
89
|
+
* `model policy-set`). Returns the one-line notice when --primary / --role / --note were still given, else null.
|
|
90
|
+
*/
|
|
91
|
+
export function ignoredPolicyNotice({ primary = null, roles = [], note = null } = {}, env = process.env) {
|
|
92
|
+
const given = (primary != null && String(primary).trim() !== '') || (Array.isArray(roles) && roles.length > 0)
|
|
93
|
+
|| (note != null && String(note).trim() !== '');
|
|
94
|
+
return given ? t('apply.policy_ignored', {}, env) : null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* (kept for reference, no longer used by apply since v0.38.42) The model policy for THIS application (task apply / hire apply), built from the flags of that one command:
|
|
89
99
|
* --primary a,b [--role <name>=<model>[=<note>]]... [--note "..."] -> the full policy of this job;
|
|
90
100
|
* --models a,b (task apply) / --model-label a (hire apply) -> main models only (the old way);
|
|
91
101
|
* nothing at all -> no field is sent, the platform copies
|
package/src/mt/text.js
CHANGED
|
@@ -26,6 +26,10 @@ const TEXT = {
|
|
|
26
26
|
zh: '默认模型策略已保存,只影响之后没单独说明的报名;已报名、已签署的不受影响。每一单仍请在报名时按这一单的打算自己说明。',
|
|
27
27
|
en: 'Default model policy saved. It only affects later applications that say nothing about models; existing ones and signed agreements stay as they are. Still describe your plan for each job when you apply.',
|
|
28
28
|
},
|
|
29
|
+
'apply.policy_ignored': {
|
|
30
|
+
zh: '报名时不再单独带模型策略,--primary / --role / --note 已忽略。模型策略请用 model policy-set 设置。',
|
|
31
|
+
en: 'Applications no longer carry their own model policy; --primary / --role / --note were ignored. Set the model policy with model policy-set.',
|
|
32
|
+
},
|
|
29
33
|
'apply.need_primary': {
|
|
30
34
|
zh: '缺少主力模型:用 --role 或 --note 说明这一单的策略时,也要加 --primary <模型>[,<模型>](1 到 2 个)。',
|
|
31
35
|
en: 'Main models missing: when you describe this job with --role or --note, add --primary <model>[,<model>] (1 or 2) as well.',
|