@yeaft/webchat-agent 0.1.972 → 0.1.974
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/yeaft/dream/apply.js +2 -2
- package/yeaft/dream/prompts/create.md +19 -2
- package/yeaft/dream/prompts/extract-session.md +49 -47
- package/yeaft/dream/prompts/extract-topic.md +46 -50
- package/yeaft/dream/prompts/extract-user.md +56 -45
- package/yeaft/dream/prompts/extract-vp.md +49 -47
- package/yeaft/dream/prompts/index.js +19 -1
- package/yeaft/dream/prompts/summarize-scope.md +34 -25
- package/yeaft/dream/prompts/triage-pass1.md +25 -2
- package/yeaft/dream/prompts/triage-pass2.md +18 -0
- package/yeaft/dream/prompts/update.md +38 -2
- package/yeaft/dream/triage.js +2 -2
- package/yeaft/prompts.js +255 -118
- package/yeaft/sub-agent/liveness.js +34 -0
- package/yeaft/sub-agent/notifications.js +16 -15
- package/yeaft/sub-agent/runner.js +56 -2
- package/yeaft/templates/base.md +44 -96
- package/yeaft/templates/common-rules.md +68 -82
- package/yeaft/templates/harness/router-shape.md +31 -32
- package/yeaft/templates/harness/worker-shape.md +23 -22
- package/yeaft/templates/identity-yeaft.md +4 -4
- package/yeaft/templates/mode-unified.md +10 -48
- package/yeaft/templates/personas/explorer.md +23 -4
- package/yeaft/templates/personas/implementer.md +23 -4
- package/yeaft/templates/personas/researcher.md +25 -6
- package/yeaft/templates/personas/reviewer.md +23 -4
- package/yeaft/templates/plan-instruction.md +40 -44
- package/yeaft/tools/agent.js +19 -16
- package/yeaft/tools/list-agents.js +14 -5
- package/yeaft/tools/wait-agent.js +27 -14
- package/yeaft/vp/seed-defaults.js +498 -24
- package/yeaft/vp/seed-topup.js +81 -5
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
import { defineTool } from './types.js';
|
|
34
34
|
import { agentBelongsToCaller, getAgentRegistry } from './agent.js';
|
|
35
35
|
import { isTerminalAgentStatus, STATUS } from '../sub-agent/status.js';
|
|
36
|
-
import {
|
|
36
|
+
import { diagnoseAgentLiveness } from '../sub-agent/liveness.js';
|
|
37
37
|
import { consumeNotificationForAgent } from '../sub-agent/notifications.js';
|
|
38
38
|
|
|
39
39
|
/**
|
|
@@ -43,7 +43,7 @@ import { consumeNotificationForAgent } from '../sub-agent/notifications.js';
|
|
|
43
43
|
* tail-positioned nudges when `result` is long).
|
|
44
44
|
*
|
|
45
45
|
* @param {string} status
|
|
46
|
-
* @param {{ timedOut?: boolean, runningInBackground?: boolean, budgetExceeded?: boolean }} [opts]
|
|
46
|
+
* @param {{ timedOut?: boolean, runningInBackground?: boolean, budgetExceeded?: boolean, stale?: boolean }} [opts]
|
|
47
47
|
*/
|
|
48
48
|
function nextStepsFor(status, opts = {}) {
|
|
49
49
|
if (opts.budgetExceeded) {
|
|
@@ -55,15 +55,20 @@ function nextStepsFor(status, opts = {}) {
|
|
|
55
55
|
'as an ordinary successful completion.'
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
|
+
if (opts.timedOut && opts.stale) {
|
|
59
|
+
return (
|
|
60
|
+
'Sub-agent still has a running record but appears stalled. Do NOT keep ' +
|
|
61
|
+
'calling WaitAgent in a loop. Use ListAgents/outputFile to inspect it, ' +
|
|
62
|
+
'CloseAgent if you want to stop it, or report the stalled background ' +
|
|
63
|
+
'task and start a fresh agent if needed.'
|
|
64
|
+
);
|
|
65
|
+
}
|
|
58
66
|
if (opts.timedOut) {
|
|
59
67
|
return (
|
|
60
|
-
'Sub-agent is
|
|
61
|
-
'
|
|
62
|
-
'
|
|
63
|
-
'
|
|
64
|
-
'user the agent is still working and ask whether to keep waiting. ' +
|
|
65
|
-
'Read `outputFile` for the full event timeline. Do NOT end your turn ' +
|
|
66
|
-
'silently.'
|
|
68
|
+
'Sub-agent is running in the background; it does not need another ' +
|
|
69
|
+
'PromptAgent to keep going. Continue the main task or tell the user it ' +
|
|
70
|
+
'is still running. Use ListAgents later for a non-blocking status check; ' +
|
|
71
|
+
'only call WaitAgent again if the user explicitly wants to wait.'
|
|
67
72
|
);
|
|
68
73
|
}
|
|
69
74
|
switch (status) {
|
|
@@ -124,6 +129,7 @@ function errorNextSteps() {
|
|
|
124
129
|
*/
|
|
125
130
|
function buildEnvelope(agent, { timedOut = false } = {}) {
|
|
126
131
|
const status = agent.status;
|
|
132
|
+
const liveness = diagnoseAgentLiveness(agent);
|
|
127
133
|
const budgetResult = agent.result && typeof agent.result === 'object'
|
|
128
134
|
&& agent.result.status === 'budget_exceeded'
|
|
129
135
|
? agent.result
|
|
@@ -134,13 +140,18 @@ function buildEnvelope(agent, { timedOut = false } = {}) {
|
|
|
134
140
|
? agent.result
|
|
135
141
|
: (agent.lastResult || ''));
|
|
136
142
|
const env = {
|
|
137
|
-
next_steps: nextStepsFor(status, { timedOut, budgetExceeded: !!budgetResult }),
|
|
143
|
+
next_steps: nextStepsFor(status, { timedOut, budgetExceeded: !!budgetResult, stale: liveness.stale }),
|
|
138
144
|
agentId: agent.id,
|
|
139
145
|
name: agent.name,
|
|
140
146
|
status,
|
|
141
147
|
error: agent.error || null,
|
|
142
148
|
outputFile: agent.outputFile || null,
|
|
143
|
-
liveness
|
|
149
|
+
liveness,
|
|
150
|
+
stale: liveness.stale,
|
|
151
|
+
stalled: liveness.stalled,
|
|
152
|
+
msSinceLastEvent: liveness.msSinceLastEvent,
|
|
153
|
+
lastEventType: liveness.lastEventType,
|
|
154
|
+
diagnostic: liveness.diagnostic,
|
|
144
155
|
messages: Array.isArray(agent.messages) ? agent.messages.length : 0,
|
|
145
156
|
turns: agent.usage?.turns || 0,
|
|
146
157
|
};
|
|
@@ -188,7 +199,7 @@ NEVER end your turn silently right after WaitAgent — the user has not seen
|
|
|
188
199
|
the sub-agent's reply yet; only you have. The orchestration loop is
|
|
189
200
|
SpawnAgent → (PromptAgent ↔ WaitAgent)+ → CloseAgent → final reply to user.
|
|
190
201
|
|
|
191
|
-
The default wait is
|
|
202
|
+
Compatibility tool. The default wait is a short 5000ms poll. Callers may request up to 300000ms (5 minutes), but this is no longer the primary sub-agent workflow; prefer SpawnAgent + ListAgents + completion notifications for async background work.`,
|
|
192
203
|
parameters: {
|
|
193
204
|
type: 'object',
|
|
194
205
|
properties: {
|
|
@@ -200,7 +211,7 @@ The default wait is 30000ms. Callers may request up to 300000ms (5 minutes).`,
|
|
|
200
211
|
type: 'number',
|
|
201
212
|
minimum: 0,
|
|
202
213
|
maximum: 300000,
|
|
203
|
-
description: 'Maximum time to wait in milliseconds (default:
|
|
214
|
+
description: 'Maximum time to wait in milliseconds (default: 5000 short poll, max: 300000 / 5 minutes)',
|
|
204
215
|
},
|
|
205
216
|
},
|
|
206
217
|
required: ['agent_id'],
|
|
@@ -209,7 +220,7 @@ The default wait is 30000ms. Callers may request up to 300000ms (5 minutes).`,
|
|
|
209
220
|
isConcurrencySafe: () => true,
|
|
210
221
|
isReadOnly: () => true,
|
|
211
222
|
async execute(input, ctx) {
|
|
212
|
-
const { agent_id, timeout_ms =
|
|
223
|
+
const { agent_id, timeout_ms = 5000 } = input;
|
|
213
224
|
if (!agent_id) {
|
|
214
225
|
return JSON.stringify({ next_steps: errorNextSteps(), error: 'agent_id is required' });
|
|
215
226
|
}
|
|
@@ -234,6 +245,7 @@ The default wait is 30000ms. Callers may request up to 300000ms (5 minutes).`,
|
|
|
234
245
|
return JSON.stringify(buildEnvelope(agent));
|
|
235
246
|
}
|
|
236
247
|
if (agent.status === STATUS.IDLE) {
|
|
248
|
+
consumeNotificationForAgent(agent.id);
|
|
237
249
|
return JSON.stringify(buildEnvelope(agent));
|
|
238
250
|
}
|
|
239
251
|
if (ctx?.signal?.aborted) {
|
|
@@ -248,6 +260,7 @@ The default wait is 30000ms. Callers may request up to 300000ms (5 minutes).`,
|
|
|
248
260
|
return JSON.stringify(buildEnvelope(agent));
|
|
249
261
|
}
|
|
250
262
|
if (agent.status === STATUS.IDLE) {
|
|
263
|
+
consumeNotificationForAgent(agent.id);
|
|
251
264
|
return JSON.stringify(buildEnvelope(agent));
|
|
252
265
|
}
|
|
253
266
|
if (ctx?.signal?.aborted) {
|