@yeaft/webchat-agent 1.0.192 → 1.0.194
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/local-runtime/version.json +1 -1
- package/local-runtime/web/app.bundle.js +28 -7
- package/local-runtime/web/app.bundle.js.gz +0 -0
- package/local-runtime/web/index.html +2 -2
- package/local-runtime/web/style.bundle.css +1 -1
- package/local-runtime/web/style.bundle.css.gz +0 -0
- package/package.json +1 -1
- package/yeaft/work-center/bridge.js +2 -2
- package/yeaft/work-center/controller.js +18 -6
- package/yeaft/work-center/mainline-projection.js +305 -0
- package/yeaft/work-center/projection.js +109 -8
- package/yeaft/work-center/runner.js +59 -7
- package/yeaft/work-center/service.js +2 -0
- package/yeaft/work-center/store.js +324 -43
- package/yeaft/work-center/watcher.js +2 -0
|
@@ -32,6 +32,12 @@ import { MCPManager } from '../mcp.js';
|
|
|
32
32
|
import { buildMcpFlattenedTools } from '../tools/mcp-tools.js';
|
|
33
33
|
import { recallWorkspaceSessionContext } from './workspace-context.js';
|
|
34
34
|
import { BUILT_IN_ACTION_TYPES } from './workflow.js';
|
|
35
|
+
import {
|
|
36
|
+
MAINLINE_CONTEXT_HARD_LIMIT_BYTES,
|
|
37
|
+
buildMainlineContextSnapshot,
|
|
38
|
+
hashMainlineSnapshot,
|
|
39
|
+
renderMainlineContextSnapshot,
|
|
40
|
+
} from './mainline-projection.js';
|
|
35
41
|
|
|
36
42
|
const WORK_ITEM_TOOL_NAMES = Object.freeze([
|
|
37
43
|
'FileRead',
|
|
@@ -746,17 +752,30 @@ export class WorkItemRunner {
|
|
|
746
752
|
};
|
|
747
753
|
}
|
|
748
754
|
if (action.workspaceMode !== 'isolated-write') return claim;
|
|
755
|
+
if (!run?.id || !ownerBootId || !Number.isInteger(run.leaseEpoch)) {
|
|
756
|
+
throw new Error('Work Center workspace preparation requires an owned Run lease');
|
|
757
|
+
}
|
|
749
758
|
if (!this.actionWorktreeRoot) {
|
|
750
|
-
|
|
759
|
+
const persistedAction = this.store.setActionWorkspaceForRun(
|
|
760
|
+
action.id, run.id, ownerBootId, run.leaseEpoch, action.generation, null, 'shared',
|
|
761
|
+
);
|
|
762
|
+
if (!persistedAction) throw new Error('Work Center Action workspace lost its Run lease');
|
|
763
|
+
return { ...claim, action: persistedAction };
|
|
751
764
|
}
|
|
752
765
|
const workspace = createActionWorktree({
|
|
753
766
|
workItem, action, runId: claim.run.id, rootDir: this.actionWorktreeRoot,
|
|
754
767
|
});
|
|
755
768
|
try {
|
|
756
|
-
const persistedAction = this.store.
|
|
757
|
-
action.id,
|
|
769
|
+
const persistedAction = this.store.setActionWorkspaceForRun(
|
|
770
|
+
action.id,
|
|
771
|
+
run.id,
|
|
772
|
+
ownerBootId,
|
|
773
|
+
run.leaseEpoch,
|
|
774
|
+
action.generation,
|
|
775
|
+
workspace.isolated ? workspace : null,
|
|
776
|
+
workspace.isolated ? null : 'shared',
|
|
758
777
|
);
|
|
759
|
-
if (!persistedAction) throw new Error('Work Center Action workspace lost its
|
|
778
|
+
if (!persistedAction) throw new Error('Work Center Action workspace lost its Run lease');
|
|
760
779
|
return { ...claim, action: persistedAction };
|
|
761
780
|
} catch (error) {
|
|
762
781
|
removeActionWorktree(workspace);
|
|
@@ -781,7 +800,10 @@ export class WorkItemRunner {
|
|
|
781
800
|
? resolveWorkItemWorkDir({ workspaceKey: action.workspace.path }, runtime.defaultWorkDir)
|
|
782
801
|
: workspaceDir;
|
|
783
802
|
const priorRuns = this.store.listCompletedRuns(workItem.id);
|
|
784
|
-
const
|
|
803
|
+
const v2Execution = Number(workItem.executionSchemaVersion) === 2;
|
|
804
|
+
const dependencyContext = v2Execution
|
|
805
|
+
? []
|
|
806
|
+
: this.store.listActionDependencies?.(workItem.id, action.dependsOnStageIds || []) || [];
|
|
785
807
|
const dependencyBlock = dependencyContext.length === 0 ? '' : `\n\nCompleted dependency results:\n${dependencyContext.map(dependency => {
|
|
786
808
|
const evidence = dependency.evidence?.length
|
|
787
809
|
? `\nEvidence: ${dependency.evidence.map(item => item.label).join('; ')}`
|
|
@@ -818,6 +840,15 @@ export class WorkItemRunner {
|
|
|
818
840
|
reuseMemory: workItem.reuseMemory,
|
|
819
841
|
});
|
|
820
842
|
const attachmentContext = buildWorkItemAttachmentContext(workItem, { root: this.attachmentRoot });
|
|
843
|
+
const fixedPromptSuffix = `${resumeBlock}${attachmentContext.promptBlock}${completionContract(executionAction, workItem)}`;
|
|
844
|
+
const reservedPromptBytes = Buffer.byteLength(fixedPromptSuffix, 'utf8');
|
|
845
|
+
const mainline = v2Execution
|
|
846
|
+
? buildMainlineContextSnapshot(
|
|
847
|
+
this.store.getWorkItemDetail(workItem.id),
|
|
848
|
+
executionAction,
|
|
849
|
+
{ reservedBytes: reservedPromptBytes },
|
|
850
|
+
)
|
|
851
|
+
: null;
|
|
821
852
|
const isRunActive = () => !signal.aborted
|
|
822
853
|
&& this.store.isActiveRun(run.id, ownerBootId, run.leaseEpoch);
|
|
823
854
|
const workspaceRuntime = await this.#workspaceRuntime(workspaceDir, workDir, isRunActive);
|
|
@@ -889,6 +920,18 @@ export class WorkItemRunner {
|
|
|
889
920
|
policy: resolvedModel.policy,
|
|
890
921
|
},
|
|
891
922
|
toolPolicySnapshot,
|
|
923
|
+
contextSnapshot: mainline?.contextSnapshot || null,
|
|
924
|
+
executionManifest: mainline ? {
|
|
925
|
+
schemaVersion: 2,
|
|
926
|
+
ledgerRevision: mainline.contextSnapshot.ledgerRevision,
|
|
927
|
+
planRevision: mainline.contextSnapshot.graph.planRevision,
|
|
928
|
+
contractRevision: mainline.contextSnapshot.contract.revision,
|
|
929
|
+
actionGeneration: mainline.contextSnapshot.action.generation,
|
|
930
|
+
actionSpecHash: mainline.contextSnapshot.action.specHash,
|
|
931
|
+
contextBytes: mainline.budget.bytes + mainline.budget.reservedBytes,
|
|
932
|
+
contextHash: hashMainlineSnapshot(mainline.contextSnapshot),
|
|
933
|
+
selectionReason: mainline.budget.selectionReason,
|
|
934
|
+
} : null,
|
|
892
935
|
},
|
|
893
936
|
);
|
|
894
937
|
if (!snapshotsWritten) throw new Error('Work Center Run lost its lease before execution');
|
|
@@ -950,7 +993,13 @@ export class WorkItemRunner {
|
|
|
950
993
|
vpId: vp.id,
|
|
951
994
|
});
|
|
952
995
|
try {
|
|
953
|
-
const prompt =
|
|
996
|
+
const prompt = v2Execution
|
|
997
|
+
? `${renderMainlineContextSnapshot(mainline.contextSnapshot)}${fixedPromptSuffix}`
|
|
998
|
+
: `${executionAction.instruction}${dependencyBlock}${resumeBlock}${attachmentContext.promptBlock}${workspaceSessionBlock}${memoryBlock}${completionContract(executionAction, workItem)}`;
|
|
999
|
+
const promptBytes = Buffer.byteLength(prompt, 'utf8');
|
|
1000
|
+
if (v2Execution && promptBytes > MAINLINE_CONTEXT_HARD_LIMIT_BYTES) {
|
|
1001
|
+
throw new Error(`Work Center Mainline prompt exceeds 64 KiB (${promptBytes} rendered UTF-8 bytes)`);
|
|
1002
|
+
}
|
|
954
1003
|
const promptParts = attachmentContext.promptParts.length > 0
|
|
955
1004
|
? [{ type: 'text', text: prompt }, ...attachmentContext.promptParts]
|
|
956
1005
|
: null;
|
|
@@ -1023,7 +1072,10 @@ export class WorkItemRunner {
|
|
|
1023
1072
|
} : parseStructuredResult(text, executionAction.type);
|
|
1024
1073
|
if (parsedResult.outcome === 'completed' && action.workspace?.isolated) {
|
|
1025
1074
|
const workspace = commitActionWorktree(action.workspace, action);
|
|
1026
|
-
this.store.
|
|
1075
|
+
const persistedAction = this.store.setActionWorkspaceForRun(
|
|
1076
|
+
action.id, run.id, ownerBootId, run.leaseEpoch, action.generation, workspace,
|
|
1077
|
+
);
|
|
1078
|
+
if (!persistedAction) throw new Error('Work Center Action workspace lost its Run lease');
|
|
1027
1079
|
action.workspace = workspace;
|
|
1028
1080
|
}
|
|
1029
1081
|
return {
|
|
@@ -221,6 +221,7 @@ export class WorkCenterService {
|
|
|
221
221
|
text: typeof payload.text === 'string' ? payload.text : '',
|
|
222
222
|
actionId: typeof payload.actionId === 'string' ? payload.actionId : '',
|
|
223
223
|
revision: payload.revision,
|
|
224
|
+
generation: payload.generation,
|
|
224
225
|
addedAttachmentCount: addedAttachments.length,
|
|
225
226
|
addedAttachments,
|
|
226
227
|
attachments: [...(workItem.attachments || []), ...addedAttachments],
|
|
@@ -253,6 +254,7 @@ export class WorkCenterService {
|
|
|
253
254
|
guidance: typeof payload.guidance === 'string' ? payload.guidance : '',
|
|
254
255
|
actionId: typeof payload.actionId === 'string' ? payload.actionId : '',
|
|
255
256
|
revision: payload.revision,
|
|
257
|
+
generation: payload.generation,
|
|
256
258
|
addedAttachmentCount: addedAttachments.length,
|
|
257
259
|
addedAttachments,
|
|
258
260
|
attachments: [...(workItem.attachments || []), ...addedAttachments],
|