@nowcrew/daemon 0.1.2 → 0.2.0
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/dist/prompt.js +2 -2
- package/dist/runner.js +1 -1
- package/dist/token.js +7 -2
- package/package.json +2 -2
package/dist/prompt.js
CHANGED
|
@@ -37,7 +37,7 @@ export function buildSystemPrompt(ctx) {
|
|
|
37
37
|
\`\`\`
|
|
38
38
|
也可用 \`--content "<短正文>"\`。线程内回复:加 \`--thread <msg码>\`(msg 码来自 read/search 输出里的 \`msg=\` 前 8 位)。
|
|
39
39
|
5. **\`crew task list --channel <id>\`** —— 看任务板。支持 \`--status <s>\` / \`--mine\`。
|
|
40
|
-
6. **\`crew task create --channel <id> --title "<标题>"
|
|
40
|
+
6. **\`crew task create --channel <id> --title "<标题>" --thread <当前线程根msgId>\`** —— 新建任务并**绑定到当前线程**。\`--thread\` 传你读到的那条**触发消息 id**(线程根),任务就和讨论同处一个线程。省略 \`--thread\` 会另起新线程,**几乎总是错的——务必带上**。
|
|
41
41
|
7. **\`crew task claim <taskId>\`** —— 认领任务(动手前必做)。
|
|
42
42
|
8. **\`crew task update <taskId> --status <in_progress|in_review|done>\`** —— 推进任务状态。
|
|
43
43
|
9. **\`crew task unclaim <taskId>\`** —— 释放认领,把任务让给别人。
|
|
@@ -64,7 +64,7 @@ CRITICAL 规则:
|
|
|
64
64
|
- 你读到的消息形如 \`#<seq> [<type>] <sender>: <正文>\`,\`type\` 为 \`human\` / \`agent\` / \`system\`。
|
|
65
65
|
- **\`system\` 消息**通报频道状态变化(如新建任务),除非明确要求你行动(如刚给你指派了任务),否则不要回复。
|
|
66
66
|
- **判定规则**:若满足来信需要你"回复之外的动作"(跑工具/改代码/做变更),先 claim;若只是回答问题或闲聊,无需 claim。
|
|
67
|
-
- **线程 = 工作单元 / 一个请求一个 task(CRITICAL)**:一条对话(thread)对应一件事,最多绑**一个** task。被唤醒处理来信时,对这件事**只建一个 task
|
|
67
|
+
- **线程 = 工作单元 / 一个请求一个 task(CRITICAL)**:一条对话(thread)对应一件事,最多绑**一个** task。被唤醒处理来信时,对这件事**只建一个 task,且必须把它绑到当前线程**:\`crew task create --title "…" --thread <触发你的那条消息 id>\`(那条消息就是线程根)。**一定要带 \`--thread\`**——不带会另起一条飘在顶层的新线程,task 就和你的讨论分家了(这正是要避免的)。**别把一个请求拆成多个 task**(如"拉代码"+"读文档"+"写记忆"是同一件事 → 一个 task,用 todo/进度推进,不要建第二个)。当前线程已有 task 时再建会被服务端拒绝(报错会提示你)。
|
|
68
68
|
- **进度/产出回本线程**:这件事的认领/进度/完成汇报都用 \`crew message send --thread <当前线程根>\` 回复在**这个线程里**(线程根 = 触发你的那条消息 id,即 \$CREW_WAKE_MESSAGE_ID)。**严禁把进度发到别的线程或频道顶层。**
|
|
69
69
|
- **毫不相关的新任务才另起线程**:只有要处理的事**和当前线程毫不相关**(或用户明确要求新建)时,才用 \`crew task create --new-thread --title "…"\`——系统另起一个子线程(parent=当前线程)绑新 task;之后这件事的回复要发到**这个新子线程**里。能不拆就不拆。
|
|
70
70
|
- 任务状态流:\`todo → in_progress → in_review → done\`。claim 后用 \`crew task update\` 推进:开工→in_progress、完成待验收→in_review、人类确认后→done。只有 assignee 能改自己任务的状态。
|
package/dist/runner.js
CHANGED
|
@@ -20,7 +20,7 @@ export async function runAgent(config, input, onActivity = defaultPrint,
|
|
|
20
20
|
// 终端透传:每条 stream-json 事件除归一化为状态活动外,再产出 console 行供前端终端窗口渲染。
|
|
21
21
|
onConsole = () => { }) {
|
|
22
22
|
// 1) 用机器令牌换 per-launch agent 令牌
|
|
23
|
-
const cred = await mintAgentToken(config.serverUrl, config.machineToken, input.handle, input.displayName);
|
|
23
|
+
const cred = await mintAgentToken(config.serverUrl, config.machineToken, input.handle, input.displayName, input.wakeMessageId);
|
|
24
24
|
// 2) 准备 workspace(共享 home + 本任务隔离 cwd + per-task work-log)。
|
|
25
25
|
// 先 prepare 拿到 memory/workLog,再 build 系统提示词(注入记忆索引)写入。
|
|
26
26
|
const ws = await prepareWorkspace({
|
package/dist/token.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
/** 用机器令牌为某 agent 换取 per-launch 的 sk_agent_*。 */
|
|
2
|
-
export async function mintAgentToken(serverUrl, machineToken, handle, displayName, fetchImpl = fetch) {
|
|
2
|
+
export async function mintAgentToken(serverUrl, machineToken, handle, displayName, wakeThreadRoot, fetchImpl = fetch) {
|
|
3
3
|
const res = await fetchImpl(`${serverUrl}/daemon/agents/token`, {
|
|
4
4
|
method: "POST",
|
|
5
5
|
headers: {
|
|
6
6
|
authorization: `Bearer ${machineToken}`,
|
|
7
7
|
"content-type": "application/json",
|
|
8
8
|
},
|
|
9
|
-
|
|
9
|
+
// 把本轮唤醒的线程根钉到 per-launch 令牌:服务端据此让 task/消息默认绑/回当前线程。
|
|
10
|
+
body: JSON.stringify({
|
|
11
|
+
handle,
|
|
12
|
+
...(displayName ? { displayName } : {}),
|
|
13
|
+
...(wakeThreadRoot ? { wakeThreadRoot } : {}),
|
|
14
|
+
}),
|
|
10
15
|
});
|
|
11
16
|
const body = (await res.json().catch(() => null));
|
|
12
17
|
if (!res.ok || !body?.success || !body.data) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nowcrew/daemon",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "crew daemon — 运行在用户机器:拉起/管理 agent 进程,注入 crew CLI,归一化 runtime 事件",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"ws": "^8",
|
|
21
|
-
"@nowcrew/cli": "^0.
|
|
21
|
+
"@nowcrew/cli": "^0.2.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^22.0.0",
|