@xopcai/xopc 0.0.243 → 0.0.245
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/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-CAah-_8h.js → activity-store-BlxqErph.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DDH4HgP7.js → agent-avatar-dicebear-DRQnogaU.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-BDCfJZhh.js → agent-defaults-settings-panel-CpOxGbMD.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-B0ZWgf-U.js → agents-flnXZLaT.js} +1 -1
- package/dist/gateway/static/root/assets/{api-B2tKxbcz.js → api-BbXzyQMj.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-Blfwszzn.js → app-management-settings-panel-CZl6n2xi.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-C3V7Na75.js → appearance-settings-Bglp-pn6.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-BiEks0-F.js → apps-page-CmsWarVB.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-BmSx7wzY.js → archive-plugin-DD2SweEH.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-BS-S4LJ9.js → attachment-load-G0HenUmG.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-C7Y3L30D.js → automations-page-B78bFjH2.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-A3zPkPuo.js → automations-workspace-BMQGmn50.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-BM9B5kcm.js → binary-plugins-BbSQmXqn.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-BbnpkYP9.js → block-editor-DutTIH81.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-Dk4FQ7fY.js → browser-settings-page-CALiFKm4.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-CRnkgZHI.js → browser-workflow-inputs-BAAc151l.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-B9qGL-it.js → browser-workflows-page-DE5HPrHZ.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-settings-panel--tR_El9e.js → capabilities-settings-panel-Dts7XtP3.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-D347vl_J.js → channels-settings-CWEd3wzh.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-status-swr-DuY4MGxe.js → channels-status-swr-CCBCtLDg.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-DABPvwBT.js → chat-terminal-dock-Bp1fXQm1.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-B-tvJkRJ.js → connectors-page-CQ6wVNLm.js} +1 -1
- package/dist/gateway/static/root/assets/{cron-expression-D3bsKbNd.js → cron-expression-B8HA5IRb.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-BsGM6Yty.js → date-picker-DD8b7oad.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-Dj3g6YXZ.js → dependency-picker-BC9zwIyH.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-C1QT0Sur.js → desktop-pet-DsrsPZTW.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-r6kAOnfY.js → desktop-pet-settings-D7gp_HNA.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-DOkf7nh9.js → extension-debug-page-BoKbOX7x.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-Cq2IA4Ho.js → extension-page-BegL4FW8.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DQn4qjDZ.js → extension-settings-page-CjPqq57s.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-DM3poL22.js → gateway-config-api-DaG57o4X.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-BC3pgb_P.js → gateway-config-swr-826dipyU.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-DPgH1hnh.js → gateway-settings-DkJGpgm6.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-uMcSfLru.js → gateway-startup-retry-DyvcAIMm.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-Bk80-E3b.js → heartbeat-settings-BLZ48kSU.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-DKo5JiMR.js → home-page-Dtw7Ipt1.js} +1 -1
- package/dist/gateway/static/root/assets/{image-generation-api-D1qlQA-A.js → image-generation-api-D7cyfks6.js} +1 -1
- package/dist/gateway/static/root/assets/{index-B0WJL9N1.js → index-DG5CfYat.js} +10 -10
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BEwvd8ZU.js → keyboard-shortcuts-settings-D2Has7-N.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page--eJ5rmNj.js → local-app-workbench-page-BWidWY93.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-CgkY9E-r.js → local-apps-page-Bkekjoxf.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-CMZljTJx.js → locale-store-CBoCuIMx.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-Z49Td0J9.js → logs-page-C5zSSgvA.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-Dv8NSJKt.js → management-settings-B8c62vRS.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-Cm0RBB-t.js → markdown-split-3kxTTGO7.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-PPCLt7fu.js → markdown-view-BXsHghJd.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-Bcr5sU1f.js → media-plugins-BW8J1nCG.js} +1 -1
- package/dist/gateway/static/root/assets/messages-BbdwoxVo.js +3 -0
- package/dist/gateway/static/root/assets/{mobile-pairing-wizard-kKDiXofY.js → mobile-pairing-wizard-nwQ8iUcd.js} +1 -1
- package/dist/gateway/static/root/assets/models-hub-cache-88f4fzYS.js +1 -0
- package/dist/gateway/static/root/assets/{notes-page-CgsaRaGi.js → notes-page-DdybD0QM.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-workbench-C1DEE09k.js → notes-workbench-IYfpy2Jx.js} +2 -2
- package/dist/gateway/static/root/assets/{oauth-api-4VeMbkTJ.js → oauth-api-BjSUDIgq.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-BU0HiZtv.js → product-open-page-CAJeUXeU.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-isRapnp5.js → project-detail-page-4wjw-b7h.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-zvsjg0mi.js → projects-page-CCMj9PeL.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-CWOtPFrE.js → registry-api-BhGKnvLP.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-C9TGZ9Hc.js → remote-access-hub-DsBJqWIk.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-2zm9edMA.js → runtime-tools-settings-panel-B4IDcqx0.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-54A5gzkN.js → schema-form-DiGUUjO6.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-BP8RyiUn.js → sessions-page-BwGj0t-2.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BJCfUghk.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-DzDhoyxv.js → settings-page-CVQUsAhd.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-uDicHU1w.js → setup-status-panel-CQACRh1i.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-lOmLCWFS.js → share-preview-page-DTP1dtuS.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-T4Yvouvv.js → shares-settings-D_YPh6Rw.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-B43xlJlX.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-CnyNH3To.js → skills-page-Czpn7Y28.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-CgDtf2qs.js → skills-page.utils-d39rm3hb.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-C8yWfwtR.js → system-settings-panel-CXXySCSp.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-Tzfjlbf3.js → task-detail-page-DHiOqQMx.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-uxUwr10D.js → theme-store-hybK3oC9.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-Bvg679no.js → tunnel-api-BiBGK7O2.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-D88VGoyG.js → use-autosave-DjpzpeIm.js} +1 -1
- package/dist/gateway/static/root/assets/{user-context-page-RijPtyfO.js → user-context-page-1XBRV5gX.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-CBHLsMcc.js → voice-api-key-field-CUIPNmOc.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-MqyI6cgq.js → voice-config-api-CBbiF1T3.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-GGe2TQ98.js → work-discovery-overlay-DVNxhb1x.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-C0layUE9.js → workflow-run-setup-panel-HxxFQFY7.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-DQXIzBAc.js → workflows-page-BCgL7PRm.js} +1 -1
- package/dist/gateway/static/root/index.html +11 -11
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/turn-outcome.js +3 -1
- package/dist/src/agent/agent-instance-gateway.d.ts +3 -1
- package/dist/src/agent/agent-manager.d.ts +2 -4
- package/dist/src/agent/agent-manager.js +24 -28
- package/dist/src/agent/background-review/coordinator.js +1 -1
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/child-agent-factory.d.ts +10 -7
- package/dist/src/agent/child-agent-factory.js +112 -158
- package/dist/src/agent/coding/index.d.ts +1 -1
- package/dist/src/agent/coding/index.js +2 -2
- package/dist/src/agent/coding/repository-instructions.d.ts +12 -0
- package/dist/src/agent/coding/repository-instructions.js +76 -0
- package/dist/src/agent/coding/run-verification.d.ts +34 -0
- package/dist/src/agent/coding/run-verification.js +134 -0
- package/dist/src/agent/coding/verification-command.d.ts +3 -0
- package/dist/src/agent/coding/verification-command.js +50 -0
- package/dist/src/agent/coding/workspace-revision.d.ts +2 -0
- package/dist/src/agent/coding/workspace-revision.js +77 -0
- package/dist/src/agent/commands/command-isolation.d.ts +21 -0
- package/dist/src/agent/commands/command-isolation.js +71 -0
- package/dist/src/agent/commands/command-registry.d.ts +56 -0
- package/dist/src/agent/commands/command-registry.js +259 -0
- package/dist/src/agent/embedded/index.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +2 -1
- package/dist/src/agent/embedded/run-turn.js +88 -25
- package/dist/src/agent/embedded/session-tool-result-guard.js +2 -2
- package/dist/src/agent/embedded/subscribe-session.d.ts +2 -1
- package/dist/src/agent/embedded/subscribe-session.js +2 -1
- package/dist/src/agent/embedded/types.d.ts +3 -1
- package/dist/src/agent/embedded/xopc-tools-bridge.js +4 -1
- package/dist/src/agent/image/index.js +1 -1
- package/dist/src/agent/index.js +3 -3
- package/dist/src/agent/memory/user-context-coordinator.js +1 -1
- package/dist/src/agent/middleware/index.d.ts +0 -5
- package/dist/src/agent/middleware/index.js +1 -2
- package/dist/src/agent/orchestration/agent-event-handler.d.ts +0 -5
- package/dist/src/agent/orchestration/agent-event-handler.js +1 -96
- package/dist/src/agent/orchestration/agent-orchestrator.js +1 -1
- package/dist/src/agent/orchestration/agent-turn-policy.js +5 -5
- package/dist/src/agent/orchestration/index.d.ts +1 -1
- package/dist/src/agent/orchestration/index.js +2 -2
- package/dist/src/agent/orchestration/loop-guard.d.ts +4 -31
- package/dist/src/agent/orchestration/loop-guard.js +14 -99
- package/dist/src/agent/prompt/sections/tooling.js +2 -4
- package/dist/src/agent/sandbox/types.d.ts +2 -2
- package/dist/src/agent/sandbox/types.js +1 -1
- package/dist/src/agent/service/direct-turn-helpers.js +1 -1
- package/dist/src/agent/service/process-direct-streaming.js +1 -1
- package/dist/src/agent/service.d.ts +0 -2
- package/dist/src/agent/service.js +6 -23
- package/dist/src/agent/tasks/task-judge-service.d.ts +7 -0
- package/dist/src/agent/tasks/task-judge-service.js +24 -2
- package/dist/src/agent/tools/delegate-tool.d.ts +2 -1
- package/dist/src/agent/tools/delegate-tool.js +102 -124
- package/dist/src/agent/tools/exec-command.d.ts +8 -1
- package/dist/src/agent/tools/exec-command.js +77 -169
- package/dist/src/agent/tools/executor.js +9 -2
- package/dist/src/agent/tools/factory.js +50 -5
- package/dist/src/agent/tools/find.d.ts +10 -13
- package/dist/src/agent/tools/find.js +33 -80
- package/dist/src/agent/tools/grep.d.ts +14 -18
- package/dist/src/agent/tools/grep.js +56 -144
- package/dist/src/agent/tools/index.d.ts +0 -1
- package/dist/src/agent/tools/index.js +2 -3
- package/dist/src/agent/tools/language-diagnostics.d.ts +11 -0
- package/dist/src/agent/tools/language-diagnostics.js +62 -0
- package/dist/src/agent/tools/managed-job-tool.d.ts +2 -1
- package/dist/src/agent/tools/managed-job-tool.js +58 -118
- package/dist/src/agent/tools/read.js +24 -7
- package/dist/src/agent/tools/repository-search.d.ts +5 -0
- package/dist/src/agent/tools/repository-search.js +56 -0
- package/dist/src/agent/tools/review-workspace.d.ts +2 -0
- package/dist/src/agent/tools/review-workspace.js +103 -0
- package/dist/src/agent/tools/write.js +4 -4
- package/dist/src/agent/transcript/index.js +2 -2
- package/dist/src/agent/transcript/transcript-hygiene.js +2 -2
- package/dist/src/agent/workflow/subagent-runner.d.ts +0 -2
- package/dist/src/agent/workflow/subagent-runner.js +12 -31
- package/dist/src/agent-config/schema.d.ts +42 -0
- package/dist/src/agent-config/schema.js +5 -0
- package/dist/src/automations/draft/automation-draft-service.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/config/schema.d.ts +28 -0
- package/dist/src/execution-environments/local-worktree-manager.d.ts +3 -1
- package/dist/src/execution-environments/local-worktree-manager.js +8 -3
- package/dist/src/execution-environments/session-environment-service.js +5 -3
- package/dist/src/extensions/update.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +7 -0
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/connectors.js +23 -23
- package/dist/src/gateway/hono/routes/sessions.js +1 -1
- package/dist/src/gateway/media-access.js +1 -1
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service/run-gateway-agent.js +4 -1
- package/dist/src/gateway/service.js +1 -1
- package/dist/src/gateway/session-reset-service.js +1 -1
- package/dist/src/gateway/workspace-ripgrep.d.ts +0 -6
- package/dist/src/gateway/workspace-ripgrep.js +2 -40
- package/dist/src/infra/ripgrep.d.ts +13 -0
- package/dist/src/infra/ripgrep.js +46 -0
- package/dist/src/infra/update-runner.js +1 -1
- package/dist/src/proactive/execution/agent-executor.js +1 -1
- package/dist/src/session/store.js +1 -1
- package/dist/src/session/turn-outcome-projector.js +26 -6
- package/dist/src/tasks/task-run-coordinator.d.ts +2 -2
- package/dist/src/tasks/task-run-coordinator.js +14 -12
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/messages-CTSgFlE4.js +0 -3
- package/dist/gateway/static/root/assets/models-hub-cache-ZrbGRiGY.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-D4EMxWAZ.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DVb7nrXz.js +0 -1
- package/dist/src/agent/coding/turn-diff-tracker.d.ts +0 -67
- package/dist/src/agent/coding/turn-diff-tracker.js +0 -231
- package/dist/src/agent/middleware/self-verify.d.ts +0 -136
- package/dist/src/agent/middleware/self-verify.js +0 -380
- package/dist/src/agent/tools/execute-code-tool.d.ts +0 -11
- package/dist/src/agent/tools/execute-code-tool.js +0 -208
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./locale-store-CMZljTJx.js";import{o as t}from"./vendor-swr-BIWyz7Rc.js";import{n}from"./gateway-config-swr-BC3pgb_P.js";import{r}from"./registry-api-CWOtPFrE.js";var i=`models-json-config`,a=`model-catalog`,o=`capability-readiness`;async function s(){await Promise.all([n(),t(e(`/api/providers/meta`)),t(i),t(a),t(o),r()])}export{s as i,i as n,a as r,o as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$t as e}from"./index-B0WJL9N1.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{i as t,r as n}from"./locale-store-CMZljTJx.js";import{Zt as r}from"./index-B0WJL9N1.js";var i=e({reloadSkills:()=>a});async function a(){let e=await t(n(`/api/skills/reload`),{method:`POST`});if(!e.ok)throw Error(await r(e))}export{i as n,a as t};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
export type WorkspaceMutationKind = 'add' | 'update' | 'delete' | 'move' | 'rewrite' | 'unknown';
|
|
2
|
-
export interface TurnFileChange {
|
|
3
|
-
kind: WorkspaceMutationKind;
|
|
4
|
-
path: string;
|
|
5
|
-
moveTo?: string;
|
|
6
|
-
added?: number;
|
|
7
|
-
removed?: number;
|
|
8
|
-
diff?: string;
|
|
9
|
-
toolName: string;
|
|
10
|
-
at: number;
|
|
11
|
-
}
|
|
12
|
-
export interface TurnVerificationRecord {
|
|
13
|
-
toolName: string;
|
|
14
|
-
command?: string;
|
|
15
|
-
success: boolean;
|
|
16
|
-
status?: string;
|
|
17
|
-
exitCode?: number | null;
|
|
18
|
-
timedOut?: boolean;
|
|
19
|
-
}
|
|
20
|
-
export interface TurnDiffState {
|
|
21
|
-
sessionKey: string;
|
|
22
|
-
turnId: string;
|
|
23
|
-
changedFiles: string[];
|
|
24
|
-
changes: TurnFileChange[];
|
|
25
|
-
cumulativeDiff: string;
|
|
26
|
-
added: number;
|
|
27
|
-
removed: number;
|
|
28
|
-
dirty: boolean;
|
|
29
|
-
dirtyReason?: string;
|
|
30
|
-
diffReviewed: boolean;
|
|
31
|
-
verificationAttempted: boolean;
|
|
32
|
-
lastVerification?: TurnVerificationRecord;
|
|
33
|
-
}
|
|
34
|
-
export declare class TurnDiffTracker {
|
|
35
|
-
private readonly states;
|
|
36
|
-
beginTurn(sessionKey: string, turnId?: string): void;
|
|
37
|
-
getState(sessionKey: string): TurnDiffState;
|
|
38
|
-
reset(sessionKey: string): void;
|
|
39
|
-
recordToolResult(input: {
|
|
40
|
-
sessionKey: string;
|
|
41
|
-
toolName: string;
|
|
42
|
-
args?: unknown;
|
|
43
|
-
result?: unknown;
|
|
44
|
-
isError?: boolean;
|
|
45
|
-
}): void;
|
|
46
|
-
recordMutation(input: {
|
|
47
|
-
sessionKey: string;
|
|
48
|
-
toolName: string;
|
|
49
|
-
changes: TurnFileChange[];
|
|
50
|
-
}): void;
|
|
51
|
-
recordDiffReviewed(sessionKey: string): void;
|
|
52
|
-
recordVerification(input: {
|
|
53
|
-
sessionKey: string;
|
|
54
|
-
toolName: string;
|
|
55
|
-
command?: string;
|
|
56
|
-
success: boolean;
|
|
57
|
-
status?: string;
|
|
58
|
-
exitCode?: number | null;
|
|
59
|
-
timedOut?: boolean;
|
|
60
|
-
}): void;
|
|
61
|
-
markDirty(sessionKey: string, reason: string): void;
|
|
62
|
-
buildFinalGuardContext(sessionKey: string): string;
|
|
63
|
-
private mutableState;
|
|
64
|
-
private recordApplyPatch;
|
|
65
|
-
private recordWriteFile;
|
|
66
|
-
private recordExecCommand;
|
|
67
|
-
}
|
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
//#region src/agent/coding/turn-diff-tracker.ts
|
|
2
|
-
const DEFAULT_TURN_ID = "default";
|
|
3
|
-
function createState(sessionKey, turnId = DEFAULT_TURN_ID) {
|
|
4
|
-
return {
|
|
5
|
-
sessionKey,
|
|
6
|
-
turnId,
|
|
7
|
-
changedFiles: [],
|
|
8
|
-
changes: [],
|
|
9
|
-
cumulativeDiff: "",
|
|
10
|
-
added: 0,
|
|
11
|
-
removed: 0,
|
|
12
|
-
dirty: false,
|
|
13
|
-
diffReviewed: false,
|
|
14
|
-
verificationAttempted: false
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
function readRecord(value) {
|
|
18
|
-
return value && typeof value === "object" ? value : null;
|
|
19
|
-
}
|
|
20
|
-
function readDetails(result) {
|
|
21
|
-
return readRecord(readRecord(result)?.details);
|
|
22
|
-
}
|
|
23
|
-
function readString(value) {
|
|
24
|
-
return typeof value === "string" && value.trim() ? value : void 0;
|
|
25
|
-
}
|
|
26
|
-
function readNumber(value) {
|
|
27
|
-
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
28
|
-
}
|
|
29
|
-
function readExitCode(value) {
|
|
30
|
-
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
31
|
-
if (value === null) return null;
|
|
32
|
-
}
|
|
33
|
-
function readStringArray(value) {
|
|
34
|
-
return Array.isArray(value) ? value.filter((item) => typeof item === "string" && item.trim().length > 0) : [];
|
|
35
|
-
}
|
|
36
|
-
function uniqueSorted(values) {
|
|
37
|
-
return Array.from(new Set(Array.from(values).filter(Boolean))).sort();
|
|
38
|
-
}
|
|
39
|
-
function extractExecCommand(args, result) {
|
|
40
|
-
const argRec = readRecord(args);
|
|
41
|
-
const fromArgs = readString(argRec?.cmd) ?? readString(argRec?.command);
|
|
42
|
-
if (fromArgs) return fromArgs;
|
|
43
|
-
return readString(readDetails(result)?.command) ?? "";
|
|
44
|
-
}
|
|
45
|
-
function isDiffReviewCommand(command) {
|
|
46
|
-
return /\bgit\s+(diff|status)\b/i.test(command);
|
|
47
|
-
}
|
|
48
|
-
function isVerificationCommand(command) {
|
|
49
|
-
return /\b(test|vitest|jest|mocha|ava|playwright|typecheck|type-check|tsc|build|lint)\b/i.test(command);
|
|
50
|
-
}
|
|
51
|
-
function commandMayMutateWorkspace(command) {
|
|
52
|
-
return /\b(sed\s+-i|perl\s+-pi|rm\s+|mv\s+|cp\s+|git\s+(checkout|reset|clean|apply|merge|rebase)|writeFile|write\(|open\([^)]*['"]w['"])/i.test(command);
|
|
53
|
-
}
|
|
54
|
-
function execSuccess(isError, result) {
|
|
55
|
-
if (isError) return false;
|
|
56
|
-
const details = readDetails(result);
|
|
57
|
-
if (!details) return false;
|
|
58
|
-
if (details.timedOut === true) return false;
|
|
59
|
-
if (details.status === "success") return true;
|
|
60
|
-
return details.exitCode === 0;
|
|
61
|
-
}
|
|
62
|
-
function appendSection(lines, title, body) {
|
|
63
|
-
if (body.length === 0) return;
|
|
64
|
-
lines.push(title, ...body);
|
|
65
|
-
}
|
|
66
|
-
var TurnDiffTracker = class {
|
|
67
|
-
states = /* @__PURE__ */ new Map();
|
|
68
|
-
beginTurn(sessionKey, turnId = `${Date.now()}`) {
|
|
69
|
-
this.states.set(sessionKey, createState(sessionKey, turnId));
|
|
70
|
-
}
|
|
71
|
-
getState(sessionKey) {
|
|
72
|
-
const state = this.states.get(sessionKey) ?? createState(sessionKey);
|
|
73
|
-
return {
|
|
74
|
-
...state,
|
|
75
|
-
changedFiles: [...state.changedFiles],
|
|
76
|
-
changes: state.changes.map((change) => ({ ...change })),
|
|
77
|
-
lastVerification: state.lastVerification ? { ...state.lastVerification } : void 0
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
reset(sessionKey) {
|
|
81
|
-
this.states.delete(sessionKey);
|
|
82
|
-
}
|
|
83
|
-
recordToolResult(input) {
|
|
84
|
-
if (input.isError) return;
|
|
85
|
-
const name = input.toolName.toLowerCase();
|
|
86
|
-
if (name === "apply_patch") {
|
|
87
|
-
this.recordApplyPatch(input.sessionKey, input.toolName, input.result);
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
if (name === "write_file") {
|
|
91
|
-
this.recordWriteFile(input.sessionKey, input.toolName, input.args, input.result);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
if (name === "exec_command") this.recordExecCommand(input.sessionKey, input.toolName, input.args, input.result, input.isError);
|
|
95
|
-
}
|
|
96
|
-
recordMutation(input) {
|
|
97
|
-
const state = this.mutableState(input.sessionKey);
|
|
98
|
-
for (const change of input.changes) {
|
|
99
|
-
state.changes.push({
|
|
100
|
-
...change,
|
|
101
|
-
toolName: input.toolName
|
|
102
|
-
});
|
|
103
|
-
state.added += change.added ?? 0;
|
|
104
|
-
state.removed += change.removed ?? 0;
|
|
105
|
-
if (change.diff) state.cumulativeDiff = [state.cumulativeDiff.trimEnd(), change.diff.trimEnd()].filter(Boolean).join("\n");
|
|
106
|
-
}
|
|
107
|
-
state.changedFiles = uniqueSorted([...state.changedFiles, ...input.changes.flatMap((change) => [change.path, change.moveTo].filter(Boolean))]);
|
|
108
|
-
}
|
|
109
|
-
recordDiffReviewed(sessionKey) {
|
|
110
|
-
this.mutableState(sessionKey).diffReviewed = true;
|
|
111
|
-
}
|
|
112
|
-
recordVerification(input) {
|
|
113
|
-
const state = this.mutableState(input.sessionKey);
|
|
114
|
-
state.verificationAttempted = true;
|
|
115
|
-
state.lastVerification = {
|
|
116
|
-
toolName: input.toolName,
|
|
117
|
-
command: input.command,
|
|
118
|
-
success: input.success,
|
|
119
|
-
status: input.status,
|
|
120
|
-
exitCode: input.exitCode,
|
|
121
|
-
timedOut: input.timedOut
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
markDirty(sessionKey, reason) {
|
|
125
|
-
const state = this.mutableState(sessionKey);
|
|
126
|
-
state.dirty = true;
|
|
127
|
-
state.dirtyReason = reason;
|
|
128
|
-
}
|
|
129
|
-
buildFinalGuardContext(sessionKey) {
|
|
130
|
-
const state = this.states.get(sessionKey);
|
|
131
|
-
if (!state) return "";
|
|
132
|
-
if (!(state.changedFiles.length > 0 || state.changes.length > 0 || state.dirty)) return "";
|
|
133
|
-
const needsDiff = !state.diffReviewed;
|
|
134
|
-
const needsVerification = !state.verificationAttempted;
|
|
135
|
-
const failedVerification = state.lastVerification && !state.lastVerification.success;
|
|
136
|
-
if (!needsDiff && !needsVerification && !failedVerification) return "";
|
|
137
|
-
const lines = ["## Coding final check reminder"];
|
|
138
|
-
if (state.changedFiles.length > 0) appendSection(lines, "This turn changed workspace files:", state.changedFiles.map((file) => `- ${file}`));
|
|
139
|
-
if (state.dirty && needsDiff) lines.push(`A command may have modified the workspace${state.dirtyReason ? `: ${state.dirtyReason}` : "."}`);
|
|
140
|
-
const actions = [];
|
|
141
|
-
if (needsDiff) actions.push("- Inspect the diff/status with `git_status` before final response.");
|
|
142
|
-
if (needsVerification) actions.push("- Run the smallest meaningful verification command if feasible.");
|
|
143
|
-
if (failedVerification) {
|
|
144
|
-
const v = state.lastVerification;
|
|
145
|
-
actions.push(`- Last verification failed${v.command ? `: ${v.command}` : ""}. Do not claim success until fixed or clearly report the blocker.`);
|
|
146
|
-
}
|
|
147
|
-
actions.push("- If skipping verification, say why in the final answer.");
|
|
148
|
-
appendSection(lines, "Before final response:", actions);
|
|
149
|
-
return lines.join("\n");
|
|
150
|
-
}
|
|
151
|
-
mutableState(sessionKey) {
|
|
152
|
-
let state = this.states.get(sessionKey);
|
|
153
|
-
if (!state) {
|
|
154
|
-
state = createState(sessionKey);
|
|
155
|
-
this.states.set(sessionKey, state);
|
|
156
|
-
}
|
|
157
|
-
return state;
|
|
158
|
-
}
|
|
159
|
-
recordApplyPatch(sessionKey, toolName, result) {
|
|
160
|
-
const details = readDetails(result);
|
|
161
|
-
if (!details) return;
|
|
162
|
-
const now = Date.now();
|
|
163
|
-
const changes = (Array.isArray(details.changes) ? details.changes : []).flatMap((raw) => {
|
|
164
|
-
const rec = readRecord(raw);
|
|
165
|
-
const path = readString(rec?.path);
|
|
166
|
-
if (!path) return [];
|
|
167
|
-
return [{
|
|
168
|
-
kind: readString(rec?.kind) ?? "update",
|
|
169
|
-
path,
|
|
170
|
-
moveTo: readString(rec?.moveTo),
|
|
171
|
-
added: readNumber(rec?.added),
|
|
172
|
-
removed: readNumber(rec?.removed),
|
|
173
|
-
diff: readString(rec?.diff),
|
|
174
|
-
toolName,
|
|
175
|
-
at: now
|
|
176
|
-
}];
|
|
177
|
-
});
|
|
178
|
-
if (changes.length === 0) {
|
|
179
|
-
const files = readStringArray(details.files);
|
|
180
|
-
for (const file of files) changes.push({
|
|
181
|
-
kind: "unknown",
|
|
182
|
-
path: file,
|
|
183
|
-
toolName,
|
|
184
|
-
at: now
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
this.recordMutation({
|
|
188
|
-
sessionKey,
|
|
189
|
-
toolName,
|
|
190
|
-
changes
|
|
191
|
-
});
|
|
192
|
-
const state = this.mutableState(sessionKey);
|
|
193
|
-
state.added = readNumber(details.added) ?? state.added;
|
|
194
|
-
state.removed = readNumber(details.removed) ?? state.removed;
|
|
195
|
-
const diff = readString(details.diff);
|
|
196
|
-
if (diff && !state.cumulativeDiff.includes(diff.trim())) state.cumulativeDiff = [state.cumulativeDiff.trimEnd(), diff.trimEnd()].filter(Boolean).join("\n");
|
|
197
|
-
}
|
|
198
|
-
recordWriteFile(sessionKey, toolName, args, result) {
|
|
199
|
-
if (typeof readDetails(result)?.size !== "number") return;
|
|
200
|
-
const path = readString(readRecord(args)?.path);
|
|
201
|
-
if (!path) return;
|
|
202
|
-
this.recordMutation({
|
|
203
|
-
sessionKey,
|
|
204
|
-
toolName,
|
|
205
|
-
changes: [{
|
|
206
|
-
kind: "rewrite",
|
|
207
|
-
path,
|
|
208
|
-
toolName,
|
|
209
|
-
at: Date.now()
|
|
210
|
-
}]
|
|
211
|
-
});
|
|
212
|
-
this.markDirty(sessionKey, "`write_file` rewrote file content without a captured unified diff");
|
|
213
|
-
}
|
|
214
|
-
recordExecCommand(sessionKey, toolName, args, result, isError) {
|
|
215
|
-
const command = extractExecCommand(args, result);
|
|
216
|
-
const details = readDetails(result);
|
|
217
|
-
if (command && isDiffReviewCommand(command)) this.recordDiffReviewed(sessionKey);
|
|
218
|
-
if (command && isVerificationCommand(command)) this.recordVerification({
|
|
219
|
-
sessionKey,
|
|
220
|
-
toolName,
|
|
221
|
-
command,
|
|
222
|
-
success: execSuccess(isError, result),
|
|
223
|
-
status: readString(details?.status),
|
|
224
|
-
exitCode: readExitCode(details?.exitCode),
|
|
225
|
-
timedOut: details?.timedOut === true
|
|
226
|
-
});
|
|
227
|
-
if (command && commandMayMutateWorkspace(command)) this.markDirty(sessionKey, `exec_command may have changed files: ${command.slice(0, 120)}`);
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
//#endregion
|
|
231
|
-
export { TurnDiffTracker };
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Self-Verification Middleware
|
|
3
|
-
*
|
|
4
|
-
* Implements the "Build & Self-Verify" pattern from harness engineering:
|
|
5
|
-
* - Intercepts agent before completion to remind verification
|
|
6
|
-
* - Tracks file edits to detect potential issues
|
|
7
|
-
* - Injects verification reminders into context
|
|
8
|
-
*
|
|
9
|
-
* Inspired by: https://blog.langchain.com/improving-deep-agents-with-harness-engineering/
|
|
10
|
-
*/
|
|
11
|
-
export interface FileEditRecord {
|
|
12
|
-
path: string;
|
|
13
|
-
editCount: number;
|
|
14
|
-
lastEditTime: number;
|
|
15
|
-
operations: string[];
|
|
16
|
-
}
|
|
17
|
-
export interface SelfVerifyConfig {
|
|
18
|
-
/** Max edits to same file before warning (default: 5) */
|
|
19
|
-
maxEditsPerFile: number;
|
|
20
|
-
/** Enable pre-completion verification check (default: true) */
|
|
21
|
-
enablePreCompletionCheck: boolean;
|
|
22
|
-
/** Min turns before triggering verification reminder (default: 3) */
|
|
23
|
-
minTurnsForVerification: number;
|
|
24
|
-
/** Reset counters on successful verification (default: true) */
|
|
25
|
-
resetOnVerification: boolean;
|
|
26
|
-
}
|
|
27
|
-
export interface VerificationTask {
|
|
28
|
-
isError?: boolean;
|
|
29
|
-
result?: unknown;
|
|
30
|
-
}
|
|
31
|
-
export interface VerificationRecord {
|
|
32
|
-
toolName: string;
|
|
33
|
-
command?: string;
|
|
34
|
-
success: boolean;
|
|
35
|
-
exitCode?: number | null;
|
|
36
|
-
status?: string;
|
|
37
|
-
timedOut?: boolean;
|
|
38
|
-
}
|
|
39
|
-
export interface SelfVerifyState {
|
|
40
|
-
hasUnverifiedEdits: boolean;
|
|
41
|
-
changedFiles: string[];
|
|
42
|
-
diffReviewed: boolean;
|
|
43
|
-
verificationAttempted: boolean;
|
|
44
|
-
lastVerificationFailed: boolean;
|
|
45
|
-
lastVerification?: VerificationRecord;
|
|
46
|
-
lastMutationTool?: string;
|
|
47
|
-
}
|
|
48
|
-
export type SelfVerifyAgentKind = 'coder' | 'data' | 'writer' | 'researcher' | 'creative' | 'generic';
|
|
49
|
-
/**
|
|
50
|
-
* Tracks file modifications and provides verification guidance
|
|
51
|
-
*/
|
|
52
|
-
export declare class SelfVerifyMiddleware {
|
|
53
|
-
private readonly states;
|
|
54
|
-
private config;
|
|
55
|
-
constructor(config?: Partial<SelfVerifyConfig>);
|
|
56
|
-
private getState;
|
|
57
|
-
/**
|
|
58
|
-
* Record a file edit operation
|
|
59
|
-
*/
|
|
60
|
-
recordEdit(filePath: string, operation: 'write' | 'edit' | 'command', sessionKey?: string): void;
|
|
61
|
-
recordVerification(toolName: string, args?: unknown, task?: VerificationTask, sessionKey?: string): void;
|
|
62
|
-
getVerificationState(sessionKey?: string): SelfVerifyState;
|
|
63
|
-
getPendingVerificationContext(sessionKey?: string, agentId?: string): string;
|
|
64
|
-
private extractExecCommand;
|
|
65
|
-
private extractResultDetails;
|
|
66
|
-
private isSuccessfulExecVerification;
|
|
67
|
-
private isVerificationCommand;
|
|
68
|
-
private isDiffReviewCommand;
|
|
69
|
-
/**
|
|
70
|
-
* Get edit count for a specific file
|
|
71
|
-
*/
|
|
72
|
-
getEditCount(filePath: string, sessionKey?: string): number;
|
|
73
|
-
/**
|
|
74
|
-
* Check if any file has excessive edits (potential doom loop)
|
|
75
|
-
*/
|
|
76
|
-
hasExcessiveEdits(sessionKey?: string): {
|
|
77
|
-
file: string;
|
|
78
|
-
count: number;
|
|
79
|
-
} | null;
|
|
80
|
-
/**
|
|
81
|
-
* Increment turn counter
|
|
82
|
-
*/
|
|
83
|
-
onTurnStart(sessionKey?: string): void;
|
|
84
|
-
/**
|
|
85
|
-
* Reset all tracking (e.g., after successful task completion)
|
|
86
|
-
*/
|
|
87
|
-
reset(sessionKey?: string): void;
|
|
88
|
-
consumePostEditReminder(sessionKey?: string): string;
|
|
89
|
-
/**
|
|
90
|
-
* Get context injection for system prompt
|
|
91
|
-
* Adds verification guidance based on current state
|
|
92
|
-
*/
|
|
93
|
-
getContextInjection(sessionKey?: string, agentId?: string): string;
|
|
94
|
-
/**
|
|
95
|
-
* Check if we should inject verification reminder
|
|
96
|
-
*/
|
|
97
|
-
private shouldPromptForVerification;
|
|
98
|
-
/**
|
|
99
|
-
* Mark verification as requested (to avoid spam)
|
|
100
|
-
*/
|
|
101
|
-
markVerificationRequested(sessionKey?: string): void;
|
|
102
|
-
/**
|
|
103
|
-
* Build workflow guidance section
|
|
104
|
-
*/
|
|
105
|
-
private buildWorkflowGuidance;
|
|
106
|
-
private classifyAgent;
|
|
107
|
-
private buildPendingVerificationReminder;
|
|
108
|
-
private verificationProfile;
|
|
109
|
-
/**
|
|
110
|
-
* Build warning for excessive file edits (doom loop detection)
|
|
111
|
-
*/
|
|
112
|
-
private buildExcessiveEditWarning;
|
|
113
|
-
/**
|
|
114
|
-
* Build pre-completion verification reminder
|
|
115
|
-
*/
|
|
116
|
-
private buildPreCompletionReminder;
|
|
117
|
-
/**
|
|
118
|
-
* Get summary of file edits for debugging
|
|
119
|
-
*/
|
|
120
|
-
getEditSummary(sessionKey?: string): {
|
|
121
|
-
totalFiles: number;
|
|
122
|
-
totalEdits: number;
|
|
123
|
-
topFiles: Array<{
|
|
124
|
-
path: string;
|
|
125
|
-
count: number;
|
|
126
|
-
}>;
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* Update configuration
|
|
130
|
-
*/
|
|
131
|
-
setConfig(config: Partial<SelfVerifyConfig>): void;
|
|
132
|
-
/**
|
|
133
|
-
* Get current configuration
|
|
134
|
-
*/
|
|
135
|
-
getConfig(): SelfVerifyConfig;
|
|
136
|
-
}
|