@yeaft/webchat-agent 1.0.191 → 1.0.192

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "1.0.191",
3
+ "version": "1.0.192",
4
4
  "description": "Remote worker agent for Yeaft Web Code Agent — connects the native Yeaft engine, CLI providers, and workbench tools",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -5,7 +5,7 @@ import {
5
5
  sanitizeDebugValue,
6
6
  sanitizeDiagnosticText,
7
7
  } from './debug-projection.js';
8
- import { normalizeActionBrief } from './workflow.js';
8
+ import { taskSpecificActionBrief } from './workflow.js';
9
9
 
10
10
  const MAX_ACTION_MESSAGE_CHARS = 16_000;
11
11
  const MAX_ACTION_DIAGNOSTIC_CHARS = 8_000;
@@ -277,7 +277,7 @@ function projectAction(action, runs, events, includeBody = true) {
277
277
  if (!action) return null;
278
278
  const execution = actionExecution(action, runs, events, includeBody);
279
279
  const alreadyProjected = !Array.isArray(runs) && Array.isArray(action.messages);
280
- const brief = alreadyProjected ? (action.brief || null) : normalizeActionBrief(action.brief, action.type);
280
+ const brief = taskSpecificActionBrief(action.brief, action.type);
281
281
  const projectedBrief = includeBody || !brief
282
282
  ? brief
283
283
  : Object.fromEntries(Object.entries(brief).map(([key, value]) => [
@@ -301,7 +301,7 @@ export function createSubmitWorkItemPlanTool({ vps, collector, isRunActive }) {
301
301
  const catalogDescription = `Action types: ${actionTypes.join(', ')}. Available VPs: ${vpCatalog.map(vp => `${vp.id} (${vp.role || vp.area || 'VP'}; ${vp.traits.join(', ') || 'no traits'})`).join('; ')}.`;
302
302
  return defineTool({
303
303
  name: 'SubmitWorkItemPlan',
304
- description: `Submit the complete initial WorkItem contract and executable Action DAG. This tool records a Run-local proposal only; Work Center validates and persists it in the current Run finalization transaction. ${catalogDescription}`,
304
+ description: `Submit the complete initial WorkItem contract and executable Action DAG. Every Action must describe this WorkItem's concrete objective, repository-aware approach, and verifiable expected outcome; never copy generic Action-type text. The reference workflow catalog does not replace this Action list. This tool records a Run-local proposal only; Work Center validates and persists it in the current Run finalization transaction. ${catalogDescription}`,
305
305
  parameters: {
306
306
  type: 'object',
307
307
  additionalProperties: false,
@@ -1028,7 +1028,7 @@ export class WorkItemRunner {
1028
1028
  }
1029
1029
  return {
1030
1030
  ...parsedResult,
1031
- response,
1031
+ response: response || parsedResult.summary,
1032
1032
  ...executionStats(),
1033
1033
  checkpoint,
1034
1034
  };
@@ -62,6 +62,13 @@ function defaultActionBrief(type) {
62
62
  return { objective, approach, expectedOutcome };
63
63
  }
64
64
 
65
+ function hasCompleteActionBrief(value) {
66
+ return value && typeof value === 'object' && !Array.isArray(value)
67
+ && ['objective', 'approach', 'expectedOutcome'].every(key => (
68
+ typeof value[key] === 'string' && value[key].trim()
69
+ ));
70
+ }
71
+
65
72
  export function normalizeActionBrief(value, type) {
66
73
  const source = value && typeof value === 'object' && !Array.isArray(value) ? value : {};
67
74
  const defaults = defaultActionBrief(type);
@@ -73,6 +80,13 @@ export function normalizeActionBrief(value, type) {
73
80
  ]));
74
81
  }
75
82
 
83
+ export function taskSpecificActionBrief(value, type) {
84
+ if (!hasCompleteActionBrief(value)) return null;
85
+ const brief = normalizeActionBrief(value, type);
86
+ const defaults = defaultActionBrief(type);
87
+ return Object.keys(defaults).every(key => brief[key] !== defaults[key]) ? brief : null;
88
+ }
89
+
76
90
  const DEFAULT_SOFTWARE_CHANGE_STAGES = Object.freeze([
77
91
  {
78
92
  id: 'triage', name: 'Triage', type: 'triage',
@@ -353,18 +367,13 @@ export function resolvePlanningWorkflowSnapshot(settings, requestedWorkItemType
353
367
  ...workflow,
354
368
  workItemType: workflow.workItemType || workflow.id,
355
369
  }));
356
- const matchingTemplate = requestedType
357
- ? actionTemplates.find(template => template.workItemType === requestedType)
358
- : null;
359
- if (matchingTemplate) return matchingTemplate;
360
-
361
370
  const catalog = actionTemplates
362
371
  .map(template => `${template.workItemType}: ${template.name} (${template.stages.map(stage => stage.type).join(' -> ')})`)
363
372
  .join('\n');
364
373
  const typeInstruction = requestedType
365
374
  ? `The user explicitly selected workItemType "${requestedType}". Keep that exact type.`
366
375
  : 'Infer one specific workItemType from the contract.';
367
- const triageInstruction = `${normalized.actionInstructions.triage}\n\n${typeInstruction}\nReusable Action templates:\n${catalog || '(none)'}\nIf the final type matches a reusable template, return its workItemType and omit actions so Work Center can apply that frozen template. Otherwise generate the smallest reliable graph of 1 to 8 Actions. Split independent work into separate Actions and declare dependsOnActionIds. Use workspaceMode read for analysis, isolated-write for independent Git changes, integrate for an integrate Action that combines isolated-write dependencies, and shared for serial side effects. Non-Git or dirty workspaces are serialized automatically. Every generated Action must state objective, approach, expectedOutcome, capability, dependencies, and workspaceMode. The objective, approach, and expectedOutcome must be specific to this WorkItem and that Action: describe the concrete work, the repository-aware execution method, and the verifiable result that will guide the executor. Generic Action-type boilerplate is invalid. Add only Actions required by this task. Do not copy a generic workflow.`;
376
+ const triageInstruction = `${normalized.actionInstructions.triage}\n\n${typeInstruction}\nReference workflow catalog:\n${catalog || '(none)'}\nUse the catalog only to understand established task categories and sequencing patterns. Always submit the smallest reliable graph of 1 to 8 task-specific Actions; never omit Actions or copy template brief text. Split independent work into separate Actions and declare dependsOnActionIds. Use workspaceMode read for analysis, isolated-write for independent Git changes, integrate for an integrate Action that combines isolated-write dependencies, and shared for serial side effects. Non-Git or dirty workspaces are serialized automatically. Every generated Action must state objective, approach, expectedOutcome, capability, dependencies, and workspaceMode. The objective, approach, and expectedOutcome must be specific to this WorkItem and that Action: describe the concrete work, the repository-aware execution method, and the verifiable result that will guide the executor. Generic Action-type boilerplate is invalid. Add only Actions required by this task. Do not copy a generic workflow.`;
368
377
  return normalizeWorkflowDefinition({
369
378
  id: 'ai-planned',
370
379
  name: 'AI planned',
@@ -434,25 +443,8 @@ export function applyGeneratedPlan(workItem, rawPlan, options = {}) {
434
443
  }
435
444
  const reservedStageIds = new Set((options.reservedStageIds || [])
436
445
  .map(id => String(id || '').trim()).filter(Boolean));
437
- const reusableTemplate = source.actionTemplates.find(template => template.workItemType === workItemType);
438
- if (reusableTemplate) {
439
- const templateActions = reusableTemplate.stages.filter(stage => stage.type !== 'triage');
440
- if (templateActions.length === 0) {
441
- throw new Error(`Reusable Action template "${workItemType}" has no executable Actions`);
442
- }
443
- const reusedStageId = templateActions.find(stage => reservedStageIds.has(stage.id))?.id;
444
- if (reusedStageId) {
445
- throw new Error(`AI-planned Action id reuses historical stage identity: ${reusedStageId}`);
446
- }
447
- return normalizeWorkflowDefinition({
448
- ...source,
449
- workItemType,
450
- actionTemplates: [],
451
- stages: [source.stages[0], ...templateActions],
452
- });
453
- }
454
446
  if (!Array.isArray(rawPlan.actions) || rawPlan.actions.length < 1 || rawPlan.actions.length > 8) {
455
- throw new Error('AI-planned triage requires between 1 and 8 Actions when no reusable template exists');
447
+ throw new Error('AI-planned triage requires between 1 and 8 task-specific Actions');
456
448
  }
457
449
  const availableVpIds = Array.isArray(options.availableVpIds)
458
450
  ? new Set(options.availableVpIds.map(id => String(id || '').trim()).filter(Boolean))