@yeaft/webchat-agent 1.0.136 → 1.0.138
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
CHANGED
|
@@ -8,6 +8,7 @@ import { WorkItemRunner } from './runner.js';
|
|
|
8
8
|
import { projectWorkCenterEvent, projectWorkItemDetail } from './projection.js';
|
|
9
9
|
import { previewWorkCenterPlan } from './planner.js';
|
|
10
10
|
import { readWorkCenterSettings, writeWorkCenterSettings } from './settings.js';
|
|
11
|
+
import { defaultWorkCenterStageInstructions } from './workflow.js';
|
|
11
12
|
import { join } from 'node:path';
|
|
12
13
|
|
|
13
14
|
let service = null;
|
|
@@ -52,6 +53,7 @@ async function getSettingsRuntime() {
|
|
|
52
53
|
models: Array.isArray(runtime.config.availableModels) ? runtime.config.availableModels : [],
|
|
53
54
|
primaryModel: runtime.config.primaryModel || runtime.config.model || null,
|
|
54
55
|
fastModel: runtime.config.fastModel || null,
|
|
56
|
+
defaultStageInstructions: defaultWorkCenterStageInstructions(),
|
|
55
57
|
};
|
|
56
58
|
}
|
|
57
59
|
|
|
@@ -245,7 +245,7 @@ export class WorkItemRunner {
|
|
|
245
245
|
// Agent-level fallback would silently execute a different model while
|
|
246
246
|
// leaving the Run snapshot unchanged, so WorkItems must fail explicitly.
|
|
247
247
|
fallbackModel: null,
|
|
248
|
-
|
|
248
|
+
modelEffort: resolvedModel.effort,
|
|
249
249
|
_readOnly: true,
|
|
250
250
|
serverMode: true,
|
|
251
251
|
// WorkItem messages live in the Work Center DB. Never archive their
|
|
@@ -5,7 +5,7 @@ import { WorkflowController } from './controller.js';
|
|
|
5
5
|
import { WorkItemWatcher } from './watcher.js';
|
|
6
6
|
import { projectWorkItemDetail, projectWorkItemSummary } from './projection.js';
|
|
7
7
|
import { readWorkCenterSettings, writeWorkCenterSettings } from './settings.js';
|
|
8
|
-
import { resolveWorkflowSnapshot } from './workflow.js';
|
|
8
|
+
import { defaultWorkCenterStageInstructions, resolveWorkflowSnapshot } from './workflow.js';
|
|
9
9
|
|
|
10
10
|
function requiredString(value, name) {
|
|
11
11
|
if (typeof value !== 'string' || !value.trim()) throw new Error(`${name} is required`);
|
|
@@ -21,6 +21,10 @@ export class WorkCenterService {
|
|
|
21
21
|
this.runtimeInfoProvider = typeof options.runtimeInfoProvider === 'function'
|
|
22
22
|
? options.runtimeInfoProvider
|
|
23
23
|
: async () => ({ vps: [], models: [], primaryModel: null, fastModel: null });
|
|
24
|
+
this.runtimeInfo = async () => ({
|
|
25
|
+
...(await this.runtimeInfoProvider()),
|
|
26
|
+
defaultStageInstructions: defaultWorkCenterStageInstructions(),
|
|
27
|
+
});
|
|
24
28
|
this.ownerBootId = options.ownerBootId || randomUUID();
|
|
25
29
|
this.store = options.store || new WorkItemStore(join(yeaftDir, 'work-center', 'work-center.db'));
|
|
26
30
|
this.controller = options.controller || new WorkflowController(this.store);
|
|
@@ -48,11 +52,11 @@ export class WorkCenterService {
|
|
|
48
52
|
return projectWorkItemDetail(this.#requiredItem(payload.id));
|
|
49
53
|
case 'get_settings': {
|
|
50
54
|
const settings = this.settingsReader(this.yeaftDir);
|
|
51
|
-
return { settings, runtime: await this.
|
|
55
|
+
return { settings, runtime: await this.runtimeInfo() };
|
|
52
56
|
}
|
|
53
57
|
case 'update_settings': {
|
|
54
58
|
const settings = this.settingsWriter(this.yeaftDir, payload.settings);
|
|
55
|
-
return { settings, runtime: await this.
|
|
59
|
+
return { settings, runtime: await this.runtimeInfo() };
|
|
56
60
|
}
|
|
57
61
|
case 'create': {
|
|
58
62
|
const settings = this.settingsReader(this.yeaftDir);
|
|
@@ -3,6 +3,17 @@ const ASSIGNMENT_MODES = new Set(['auto', 'pool', 'fixed']);
|
|
|
3
3
|
const MODEL_MODES = new Set(['inherit', 'primary', 'fast', 'specific']);
|
|
4
4
|
const MODEL_EFFORTS = new Set(['minimal', 'low', 'medium', 'high', 'xhigh', 'max']);
|
|
5
5
|
|
|
6
|
+
const DEFAULT_STAGE_INSTRUCTIONS = Object.freeze({
|
|
7
|
+
triage: 'Analyze the request, verify scope and risks, and make the contract executable. Do not implement yet. If the goal or acceptance criteria need refinement, submit a contractPatch.',
|
|
8
|
+
implement: 'Implement the smallest correct change in the supplied work directory. Add and run relevant tests. Use the prior triage/review findings. Do not approve your own work.',
|
|
9
|
+
test: 'Verify the implementation against the acceptance criteria. Run focused tests and report reproducible evidence. Do not modify unrelated code.',
|
|
10
|
+
review: 'Review the implementation and evidence independently. Return approved or changes_requested with concrete findings.',
|
|
11
|
+
deliver: 'Deliver the approved change using the repository release policy. Verify the final remote state and provide evidence.',
|
|
12
|
+
research: 'Research the question using verifiable sources. Separate evidence from inference and return a concise synthesis.',
|
|
13
|
+
write: 'Produce the requested written deliverable, then verify it against every acceptance criterion.',
|
|
14
|
+
custom: 'Complete this stage and return verifiable evidence.',
|
|
15
|
+
});
|
|
16
|
+
|
|
6
17
|
const DEFAULT_SOFTWARE_CHANGE_STAGES = Object.freeze([
|
|
7
18
|
{
|
|
8
19
|
id: 'triage', name: 'Triage', type: 'triage',
|
|
@@ -75,6 +86,14 @@ export function normalizeModelPolicy(value) {
|
|
|
75
86
|
return { mode, model, effort };
|
|
76
87
|
}
|
|
77
88
|
|
|
89
|
+
export function defaultWorkCenterStageInstruction(type) {
|
|
90
|
+
return DEFAULT_STAGE_INSTRUCTIONS[STAGE_TYPES.has(type) ? type : 'custom'];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function defaultWorkCenterStageInstructions() {
|
|
94
|
+
return { ...DEFAULT_STAGE_INSTRUCTIONS };
|
|
95
|
+
}
|
|
96
|
+
|
|
78
97
|
export function normalizeWorkflowDefinition(value, index = 0) {
|
|
79
98
|
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
80
99
|
throw new Error('Work Center workflow must be an object');
|
|
@@ -95,7 +114,9 @@ export function normalizeWorkflowDefinition(value, index = 0) {
|
|
|
95
114
|
id: stageId,
|
|
96
115
|
name: String(source.name || stageId).trim() || stageId,
|
|
97
116
|
type,
|
|
98
|
-
instruction: typeof source.instruction === 'string'
|
|
117
|
+
instruction: typeof source.instruction === 'string' && source.instruction.trim()
|
|
118
|
+
? source.instruction.trim()
|
|
119
|
+
: defaultWorkCenterStageInstruction(type),
|
|
99
120
|
assignmentPolicy: normalizeAssignmentPolicy(source.assignmentPolicy, type),
|
|
100
121
|
modelPolicy: normalizeModelPolicy(source.modelPolicy),
|
|
101
122
|
maxAttempts: Math.min(Math.max(Number(source.maxAttempts) || 2, 1), 5),
|
|
@@ -266,25 +287,7 @@ function renderContext(context = []) {
|
|
|
266
287
|
export function actionInstruction(stage, workItem, context = []) {
|
|
267
288
|
const criteria = (workItem.acceptanceCriteria || []).map(item => `- ${item}`).join('\n') || '- No explicit criteria';
|
|
268
289
|
const common = `WorkItem: ${workItem.title}\nGoal: ${workItem.goal}\nAcceptance criteria:\n${criteria}${renderContext(context)}`;
|
|
269
|
-
|
|
270
|
-
switch (stage.type) {
|
|
271
|
-
case 'triage':
|
|
272
|
-
return `${common}\n\nAnalyze the request, verify scope and risks, and make the contract executable. Do not implement yet. If the goal or acceptance criteria need refinement, submit a contractPatch.`;
|
|
273
|
-
case 'implement':
|
|
274
|
-
return `${common}\n\nImplement the smallest correct change in the supplied work directory. Add and run relevant tests. Use the prior triage/review findings. Do not approve your own work.`;
|
|
275
|
-
case 'test':
|
|
276
|
-
return `${common}\n\nVerify the implementation against the acceptance criteria. Run focused tests and report reproducible evidence. Do not modify unrelated code.`;
|
|
277
|
-
case 'review':
|
|
278
|
-
return `${common}\n\nReview the implementation and evidence independently. Return approved or changes_requested with concrete findings.`;
|
|
279
|
-
case 'deliver':
|
|
280
|
-
return `${common}\n\nDeliver the approved change using the repository release policy. Verify the final remote state and provide evidence.`;
|
|
281
|
-
case 'research':
|
|
282
|
-
return `${common}\n\nResearch the question using verifiable sources. Separate evidence from inference and return a concise synthesis.`;
|
|
283
|
-
case 'write':
|
|
284
|
-
return `${common}\n\nProduce the requested written deliverable, then verify it against every acceptance criterion.`;
|
|
285
|
-
default:
|
|
286
|
-
return `${common}\n\nComplete this stage and return verifiable evidence.`;
|
|
287
|
-
}
|
|
290
|
+
return `${common}\n\n${stage.instruction || defaultWorkCenterStageInstruction(stage.type)}`;
|
|
288
291
|
}
|
|
289
292
|
|
|
290
293
|
export function actionForStage(stage, workItem, context = []) {
|