@linghun/tui 0.1.0 → 0.1.1

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.
Files changed (89) hide show
  1. package/dist/background-control-runtime.js +27 -26
  2. package/dist/capability-runtime.js +16 -15
  3. package/dist/{chunk-N7G2X2LK.js → chunk-33E6RDCY.js} +10 -10
  4. package/dist/{chunk-FTAEPAVY.js → chunk-3BPKJMIV.js} +2 -2
  5. package/dist/{chunk-WQMSRO4D.js → chunk-4E56DWEZ.js} +2 -2
  6. package/dist/chunk-4UER2AKI.js +636 -0
  7. package/dist/{chunk-WHFDDZHY.js → chunk-5CXN4JLE.js} +2 -2
  8. package/dist/{chunk-JDWXC2OQ.js → chunk-624A7BBJ.js} +3 -3
  9. package/dist/{chunk-3GCIXKCI.js → chunk-7TYK55JT.js} +4 -0
  10. package/dist/{chunk-JO5ANTMR.js → chunk-AZU7HXIT.js} +76 -29
  11. package/dist/{chunk-B4GQTZMT.js → chunk-CD54BQJ5.js} +1 -1
  12. package/dist/{chunk-ZZ2CNCXJ.js → chunk-CDVYF7RU.js} +1 -1
  13. package/dist/{chunk-ECFLCY5V.js → chunk-DYDTLRHB.js} +1 -1
  14. package/dist/{chunk-AKPXMCVF.js → chunk-HIIYRATQ.js} +1 -1
  15. package/dist/{chunk-JHGWGH2C.js → chunk-J6CYFWSW.js} +89 -7
  16. package/dist/{chunk-66BNE332.js → chunk-JJQETFCR.js} +1 -1
  17. package/dist/{chunk-RVY34HK4.js → chunk-KOULRCYJ.js} +4 -1
  18. package/dist/{chunk-QB4VWH7W.js → chunk-LIPZJNXS.js} +2 -2
  19. package/dist/{chunk-OF3K3CU5.js → chunk-MXPBYB54.js} +1 -1
  20. package/dist/{chunk-DNQN74CC.js → chunk-NL4M3V5D.js} +33 -0
  21. package/dist/{chunk-GKZYTPN2.js → chunk-O6MKVGVK.js} +1 -1
  22. package/dist/{chunk-LVIM2PA7.js → chunk-QG2FJ3NR.js} +1 -1
  23. package/dist/{chunk-2FVEKTKN.js → chunk-QJTET7EZ.js} +1 -1
  24. package/dist/{chunk-4WHZ6JKD.js → chunk-RFSSKGCE.js} +178 -45
  25. package/dist/{chunk-OEYW3JE3.js → chunk-SILJJAK2.js} +1 -1
  26. package/dist/{chunk-THZBFYAH.js → chunk-UN53MBAR.js} +1 -1
  27. package/dist/{chunk-TYF4GJR3.js → chunk-VAGL7CNR.js} +1 -1
  28. package/dist/{chunk-D7TCSOAZ.js → chunk-WOBNOBB5.js} +1 -1
  29. package/dist/{chunk-JQCRCDOC.js → chunk-XWRHWM4H.js} +9 -9
  30. package/dist/{chunk-GMUCSNUD.js → chunk-Y5ZV47XC.js} +2 -2
  31. package/dist/command-panel-runtime.js +15 -14
  32. package/dist/compact-cache-command-runtime.js +27 -26
  33. package/dist/compact-preflight-runtime.js +5 -5
  34. package/dist/connector-runtime.js +17 -16
  35. package/dist/details-status-runtime.js +15 -14
  36. package/dist/evidence-runtime.js +2 -2
  37. package/dist/extension-command-runtime.js +3 -3
  38. package/dist/extension-slash-runtime.js +16 -15
  39. package/dist/failure-learning-command-runtime.js +16 -15
  40. package/dist/git-command-runtime.js +16 -15
  41. package/dist/headless-bench-runtime.d.ts +108 -0
  42. package/dist/headless-bench-runtime.d.ts.map +1 -0
  43. package/dist/headless-bench-runtime.js +30 -0
  44. package/dist/index.d.ts +31 -0
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +492 -45
  47. package/dist/job-agent-command-runtime.d.ts +2 -1
  48. package/dist/job-agent-command-runtime.d.ts.map +1 -1
  49. package/dist/job-agent-command-runtime.js +15 -14
  50. package/dist/job-runtime.js +4 -4
  51. package/dist/mcp-index-command-runtime.js +3 -3
  52. package/dist/mcp-index-runtime.js +18 -17
  53. package/dist/mcp-stdio-runtime.js +2 -2
  54. package/dist/memory-command-runtime.js +16 -15
  55. package/dist/meta-scheduler-runtime.d.ts +10 -0
  56. package/dist/meta-scheduler-runtime.d.ts.map +1 -1
  57. package/dist/meta-scheduler-runtime.js +2 -1
  58. package/dist/model-command-runtime.js +16 -15
  59. package/dist/model-prompt-runtime.d.ts.map +1 -1
  60. package/dist/model-prompt-runtime.js +1 -1
  61. package/dist/model-stream-runtime.d.ts +4 -0
  62. package/dist/model-stream-runtime.d.ts.map +1 -1
  63. package/dist/model-stream-runtime.js +27 -26
  64. package/dist/model-tool-runtime.d.ts +2 -2
  65. package/dist/model-tool-runtime.js +27 -26
  66. package/dist/permission-approval-runtime.js +27 -26
  67. package/dist/process-command-runtime.d.ts.map +1 -1
  68. package/dist/process-command-runtime.js +2 -2
  69. package/dist/process-guard.d.ts +3 -0
  70. package/dist/process-guard.d.ts.map +1 -1
  71. package/dist/process-guard.js +1 -1
  72. package/dist/remote-command-runtime.js +16 -15
  73. package/dist/runner-runtime.js +3 -3
  74. package/dist/shell/components/ProductBlock.js +2 -2
  75. package/dist/shell/components/ShellApp.js +6 -6
  76. package/dist/shell/ink-renderer.js +6 -6
  77. package/dist/shell/view-model.js +2 -2
  78. package/dist/slash-command-runtime.js +27 -26
  79. package/dist/tui-agent-job-runtime.js +5 -5
  80. package/dist/tui-data-types.d.ts +10 -0
  81. package/dist/tui-data-types.d.ts.map +1 -1
  82. package/dist/tui-details-runtime.js +5 -5
  83. package/dist/tui-output-surface.js +3 -3
  84. package/dist/verification-command-runtime.js +6 -6
  85. package/dist/workflow-command-runtime.d.ts.map +1 -1
  86. package/dist/workflow-command-runtime.js +15 -14
  87. package/package.json +5 -5
  88. package/dist/{chunk-M4AIK2SP.js → chunk-KJVHLTQR.js} +3 -3
  89. package/dist/{chunk-64MJP6FK.js → chunk-L2GU3PWU.js} +3 -3
@@ -1,32 +1,15 @@
1
- import {
2
- createVerificationPlan,
3
- createVerificationUnavailableReport,
4
- runVerificationPlan
5
- } from "./chunk-WQMSRO4D.js";
6
1
  import {
7
2
  bridgeWorkflowPlanToMainChainRequests,
8
3
  decideWorkflowStepCapability
9
4
  } from "./chunk-V7GDHHBL.js";
10
- import {
11
- createLogArtifactRegistry,
12
- findEvidence,
13
- formatAgentDetails,
14
- formatEvidenceDetails,
15
- parseLogArtifactRequest
16
- } from "./chunk-THZBFYAH.js";
17
- import {
18
- createShellBlockOutputForTest,
19
- writeErrorLine
20
- } from "./chunk-ECFLCY5V.js";
21
5
  import {
22
6
  decidePermission
23
7
  } from "./chunk-DDXS2RDZ.js";
24
8
  import {
25
- formatModeBehavior
26
- } from "./chunk-4K6UB524.js";
27
- import {
28
- createVerificationLevelForReadiness
29
- } from "./chunk-PBIPV4LD.js";
9
+ createVerificationPlan,
10
+ createVerificationUnavailableReport,
11
+ runVerificationPlan
12
+ } from "./chunk-4E56DWEZ.js";
30
13
  import {
31
14
  createAgentBackgroundTask,
32
15
  createAgentContextSummary,
@@ -52,7 +35,24 @@ import {
52
35
  registerBackgroundAbortController,
53
36
  rememberBackgroundTask,
54
37
  upsertJobBackgroundTask
55
- } from "./chunk-ZZ2CNCXJ.js";
38
+ } from "./chunk-CDVYF7RU.js";
39
+ import {
40
+ createLogArtifactRegistry,
41
+ findEvidence,
42
+ formatAgentDetails,
43
+ formatEvidenceDetails,
44
+ parseLogArtifactRequest
45
+ } from "./chunk-UN53MBAR.js";
46
+ import {
47
+ createShellBlockOutputForTest,
48
+ writeErrorLine
49
+ } from "./chunk-DYDTLRHB.js";
50
+ import {
51
+ formatModeBehavior
52
+ } from "./chunk-4K6UB524.js";
53
+ import {
54
+ createVerificationLevelForReadiness
55
+ } from "./chunk-PBIPV4LD.js";
56
56
  import {
57
57
  JOB_RECOVERY_HEARTBEAT_STALE_MS,
58
58
  appendJobLog,
@@ -68,20 +68,23 @@ import {
68
68
  rescheduleDurableJobAgents,
69
69
  updateDurableJobEffectiveAgentCap,
70
70
  writeDurableJobReport
71
- } from "./chunk-TYF4GJR3.js";
71
+ } from "./chunk-VAGL7CNR.js";
72
72
  import {
73
73
  markJobRunnerTerminal,
74
74
  refreshRunnerStatusForJob,
75
75
  startRunnerForDurableJob,
76
76
  stopRunnerForDurableJob
77
- } from "./chunk-B4GQTZMT.js";
77
+ } from "./chunk-CD54BQJ5.js";
78
78
  import {
79
79
  formatLogArtifactSlice,
80
80
  readLogArtifactSlice
81
81
  } from "./chunk-L4XXW6Y5.js";
82
+ import {
83
+ formatEngineeringProfileStrategyHint
84
+ } from "./chunk-4UER2AKI.js";
82
85
  import {
83
86
  formatWorkflows
84
- } from "./chunk-LVIM2PA7.js";
87
+ } from "./chunk-QG2FJ3NR.js";
85
88
  import {
86
89
  messages
87
90
  } from "./chunk-RBOQJFIZ.js";
@@ -102,7 +105,7 @@ import {
102
105
  appendToolResultEvent,
103
106
  createEvidenceRecord,
104
107
  createToolEndEvent
105
- } from "./chunk-64MJP6FK.js";
108
+ } from "./chunk-L2GU3PWU.js";
106
109
  import {
107
110
  WORKFLOW_ARCHITECTURE_REVIEW_FILE_LIMIT
108
111
  } from "./chunk-RDGM4RUE.js";
@@ -413,6 +416,17 @@ function buildWorkflowPlannerContextInput(context) {
413
416
  } : {}
414
417
  };
415
418
  }
419
+ function snapshotEngineeringSignal(context) {
420
+ const signal = context.lastMetaSchedulerDecision?.policyDecision.engineeringSignal;
421
+ if (!signal) return void 0;
422
+ return {
423
+ profile: signal.profile,
424
+ strategyHint: signal.strategyHint,
425
+ artifactTargets: signal.artifactTargets.slice(),
426
+ ...signal.failureCategory ? { failureCategory: signal.failureCategory } : {},
427
+ ...signal.finalBoundaryHint ? { finalBoundaryHint: signal.finalBoundaryHint } : {}
428
+ };
429
+ }
416
430
  function syncSelectedWorkflowRun(context) {
417
431
  const runs = context.workflows.activeRuns ?? [];
418
432
  if (runs.length === 0) {
@@ -559,6 +573,7 @@ function recoverWorkflowRunState(state) {
559
573
  startedAt: state.startedAt,
560
574
  endedAt: state.endedAt,
561
575
  result: status === "completed" ? "partial" : status === "stale" ? "stale" : state.result,
576
+ ...state.engineeringSignal ? { engineeringSignal: state.engineeringSignal } : {},
562
577
  phaseGateConfirmed: state.phaseGateConfirmed === true,
563
578
  confirmedPhaseStopPoints: Array.isArray(state.confirmedPhaseStopPoints) ? state.confirmedPhaseStopPoints.filter((item) => typeof item === "string") : []
564
579
  };
@@ -795,6 +810,7 @@ async function runWorkflowPlanSteps(goal, plan, context, output, options = {}) {
795
810
  }),
796
811
  nextAction: "\u7B49\u5F85 step_result\uFF1B\u5931\u8D25\u65F6\u67E5\u770B /failures \u548C transcript\u3002"
797
812
  };
813
+ const engineeringSignal = snapshotEngineeringSignal(context);
798
814
  const workflowRun = upsertWorkflowRun(context, {
799
815
  id: runId,
800
816
  goal,
@@ -803,6 +819,7 @@ async function runWorkflowPlanSteps(goal, plan, context, output, options = {}) {
803
819
  steps: stepStates,
804
820
  startedAt,
805
821
  result: "partial",
822
+ ...engineeringSignal ? { engineeringSignal } : {},
806
823
  phaseGateConfirmed: true,
807
824
  confirmedPhaseStopPoints,
808
825
  multiAgent: options.multiAgent === true
@@ -1028,6 +1045,7 @@ async function runRegistryWorkflow(workflow, goal, runInBackground, context, out
1028
1045
  }),
1029
1046
  nextAction: "\u67E5\u770B /workflows registry\u3001/background \u6216 /details background\u3002"
1030
1047
  };
1048
+ const engineeringSignal = snapshotEngineeringSignal(context);
1031
1049
  const workflowRun = upsertWorkflowRun(context, {
1032
1050
  id: runId,
1033
1051
  goal: goal || workflow.description,
@@ -1036,6 +1054,7 @@ async function runRegistryWorkflow(workflow, goal, runInBackground, context, out
1036
1054
  steps: stepStates,
1037
1055
  startedAt,
1038
1056
  result: "partial",
1057
+ ...engineeringSignal ? { engineeringSignal } : {},
1039
1058
  phaseGateConfirmed: true,
1040
1059
  confirmedPhaseStopPoints: [workflow.id]
1041
1060
  });
@@ -1157,6 +1176,7 @@ async function executeRegistryWorkflowRun(workflow, goal, runId, stepStates, tas
1157
1176
  async function executeRegistryWorkflowStep(workflow, step, goal, context, output, workflowRunId) {
1158
1177
  const beforeEvidence = context.evidence.map((item) => item.id);
1159
1178
  let handledKnownAction = false;
1179
+ const run = workflowRunId ? getWorkflowRun(context, workflowRunId) : context.workflows.activeRun;
1160
1180
  try {
1161
1181
  const isRegistryMutating = step.action === "write" || step.action === "bash" || step.action === "agent";
1162
1182
  if (isRegistryMutating) {
@@ -1172,7 +1192,6 @@ async function executeRegistryWorkflowStep(workflow, step, goal, context, output
1172
1192
  evidenceRefs: []
1173
1193
  };
1174
1194
  }
1175
- const run = workflowRunId ? getWorkflowRun(context, workflowRunId) : context.workflows.activeRun;
1176
1195
  if (!run?.confirmedPhaseStopPoints?.includes(workflow.id)) {
1177
1196
  return {
1178
1197
  status: "blocked",
@@ -1191,7 +1210,10 @@ async function executeRegistryWorkflowStep(workflow, step, goal, context, output
1191
1210
  const role = step.role ?? "worker";
1192
1211
  const task = step.task ?? (goal || workflow.description);
1193
1212
  const previousAgentIds = new Set(context.agents.map((agent2) => agent2.id));
1194
- await handleForkCommand([role, task], context, output);
1213
+ await handleForkCommand([role, task], context, output, {
1214
+ ...workflowRunId ? { workflowRunId } : {},
1215
+ ...run?.engineeringSignal ? { engineeringSignal: run.engineeringSignal } : {}
1216
+ });
1195
1217
  const agent = context.agents.find((item) => !previousAgentIds.has(item.id));
1196
1218
  if (!agent) {
1197
1219
  return {
@@ -1379,7 +1401,10 @@ async function executeWorkflowStep(request, context, output, workflowRunId, work
1379
1401
  };
1380
1402
  }
1381
1403
  const previousAgentIds = new Set(context.agents.map((agent2) => agent2.id));
1382
- await handleForkCommand([req.role, req.task], context, output, { workflowRunId });
1404
+ await handleForkCommand([req.role, req.task], context, output, {
1405
+ workflowRunId,
1406
+ ...run?.engineeringSignal ? { engineeringSignal: run.engineeringSignal } : {}
1407
+ });
1383
1408
  const agent = context.agents.find((item) => !previousAgentIds.has(item.id));
1384
1409
  const agentTask = agent ? context.backgroundTasks.find((task) => task.id === agent.id) : void 0;
1385
1410
  if (agentTask && workflowRunId) {
@@ -2611,6 +2636,22 @@ var AGENT_ASSIGNABLE_STATUSES = /* @__PURE__ */ new Set(["running", "idle", "com
2611
2636
  function getAgentRunsDir(context) {
2612
2637
  return resolveStoragePaths2(context.config, context.projectPath).agentRuns;
2613
2638
  }
2639
+ function snapshotEngineeringSignal2(context) {
2640
+ const signal = context.lastMetaSchedulerDecision?.policyDecision.engineeringSignal;
2641
+ if (!signal) {
2642
+ return {
2643
+ profile: "generic",
2644
+ strategyHint: formatEngineeringProfileStrategyHint("generic")
2645
+ };
2646
+ }
2647
+ return {
2648
+ profile: signal.profile,
2649
+ strategyHint: signal.strategyHint,
2650
+ artifactTargets: signal.artifactTargets.slice(),
2651
+ ...signal.failureCategory ? { failureCategory: signal.failureCategory } : {},
2652
+ ...signal.finalBoundaryHint ? { finalBoundaryHint: signal.finalBoundaryHint } : {}
2653
+ };
2654
+ }
2614
2655
  function formatAgentCompletionSummary(agent, context) {
2615
2656
  const text = messages[context.language];
2616
2657
  const elapsed = Date.now() - Date.parse(agent.startedAt);
@@ -3381,6 +3422,7 @@ async function startDurableJobAgentRun(context, job, assignment, output) {
3381
3422
  parentSessionId,
3382
3423
  forkedFrom: packet.id,
3383
3424
  task,
3425
+ engineeringSignal: snapshotEngineeringSignal2(context),
3384
3426
  model: effectiveModel,
3385
3427
  permissionMode: getAgentPermissionMode(assignment.type, context.permissionMode),
3386
3428
  status: routeUsable ? "running" : "blocked",
@@ -4114,6 +4156,7 @@ async function handleForkCommand(args, context, output, runtimeOptions = {}) {
4114
4156
  return;
4115
4157
  }
4116
4158
  const workflowTaskId = runtimeOptions.workflowRunId ?? getWorkflowRuns(context).find((run) => run.status === "running")?.id;
4159
+ const engineeringSignal = runtimeOptions.engineeringSignal ?? snapshotEngineeringSignal2(context);
4117
4160
  const guard = deps().checkBackgroundStartGuard(context, "agent", false, workflowTaskId);
4118
4161
  if (guard) {
4119
4162
  writeLine(output, guard);
@@ -4171,6 +4214,7 @@ Task: ${task}` : task;
4171
4214
  parentSessionId,
4172
4215
  forkedFrom: packet.id,
4173
4216
  task: effectiveTask,
4217
+ engineeringSignal,
4174
4218
  model: effectiveModel,
4175
4219
  ...registryAgent ? { registryAgentId: registryAgent.id } : {},
4176
4220
  ...registryAllowedTools ? { allowedTools: registryAllowedTools } : {},
@@ -5138,6 +5182,8 @@ async function denyAgentToolUse(agent, toolCall, toolName, context, parentSessio
5138
5182
  }
5139
5183
  function createAgentLoopSystemPrompt(agent, context) {
5140
5184
  const readonlyAuditHint = createReadonlyAuditToolHint(agent);
5185
+ const engineeringProfile = agent.engineeringSignal?.profile ?? context.lastMetaSchedulerDecision?.policyDecision.engineeringSignal.profile ?? "generic";
5186
+ const engineeringStrategy = agent.engineeringSignal?.strategyHint ?? context.lastMetaSchedulerDecision?.policyDecision.engineeringSignal.strategyHint ?? formatEngineeringProfileStrategyHint(engineeringProfile);
5141
5187
  const roleHint = agent.type === "explorer" ? "Explore with read-only tools first. Return concise findings and evidence." : agent.type === "planner" ? "Build a practical plan. Use Todo when it helps, but do not stop at a stub." : agent.type === "worker" ? "Execute the assigned work with real tools. Stop and report blocked if permission is required." : "Verify with real project commands and report PASS/FAIL/PARTIAL honestly.";
5142
5188
  return [
5143
5189
  `You are a Linghun ${agent.type} child agent running in an isolated sidechain transcript.`,
@@ -5151,6 +5197,7 @@ function createAgentLoopSystemPrompt(agent, context) {
5151
5197
  "Use structured tools only; never write raw tool_use/tool_result protocol as text.",
5152
5198
  readonlyAuditHint,
5153
5199
  "Respect the actual OS/shell before Bash. On Windows/PowerShell, prefer PowerShell cmdlets or Node one-liners; avoid Unix-only find|sed|head pipelines unless verified available.",
5200
+ `EngineeringTaskProfile: profile=${engineeringProfile}; strategy=${engineeringStrategy}; not validation evidence.`,
5154
5201
  "If a required tool is denied, asks for approval, or fails, report blocked instead of claiming completion."
5155
5202
  ].join("\n");
5156
5203
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  redactedPath
3
- } from "./chunk-RVY34HK4.js";
3
+ } from "./chunk-KOULRCYJ.js";
4
4
  import {
5
5
  formatJobRunnerInline
6
6
  } from "./chunk-UDQT5CWK.js";
@@ -9,7 +9,7 @@ import {
9
9
  getDurableJobPaths,
10
10
  getDurableJobsRoot,
11
11
  listDurableJobs
12
- } from "./chunk-TYF4GJR3.js";
12
+ } from "./chunk-VAGL7CNR.js";
13
13
  import {
14
14
  formatJobNextAction,
15
15
  mapDurableJobToBackgroundResult,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createOutputBlock
3
- } from "./chunk-AKPXMCVF.js";
3
+ } from "./chunk-HIIYRATQ.js";
4
4
  import {
5
5
  writeLine
6
6
  } from "./chunk-OMZYPQVA.js";
@@ -27,7 +27,7 @@ import {
27
27
  } from "./chunk-KI7C6ZOD.js";
28
28
  import {
29
29
  sanitizeMainScreenLeakage
30
- } from "./chunk-3GCIXKCI.js";
30
+ } from "./chunk-7TYK55JT.js";
31
31
  import {
32
32
  SLASH_COMMAND_REGISTRY
33
33
  } from "./chunk-PGNALDEH.js";
@@ -17,9 +17,20 @@ var ProcessGuardRegistry = class {
17
17
  child,
18
18
  pid,
19
19
  detached: options.detached === true,
20
- label: options.label
20
+ label: options.label,
21
+ cwd: options.cwd,
22
+ retainAfterExit: options.retainAfterExit === true,
23
+ childExited: false,
24
+ workspaceSweep: options.workspaceSweep === true
21
25
  });
22
- const cleanup = () => this.untrack(pid);
26
+ const cleanup = () => {
27
+ const entry = this.tracked.get(pid);
28
+ if (!entry) return;
29
+ entry.childExited = true;
30
+ if (!entry.retainAfterExit) {
31
+ this.untrack(pid);
32
+ }
33
+ };
23
34
  child.once("exit", cleanup);
24
35
  child.once("close", cleanup);
25
36
  return true;
@@ -45,11 +56,17 @@ var ProcessGuardRegistry = class {
45
56
  skipped: 0,
46
57
  failures: []
47
58
  };
59
+ const removePids = [];
48
60
  for (const entry of this.tracked.values()) {
49
61
  if (onlyPids && !onlyPids.has(entry.pid)) {
50
62
  continue;
51
63
  }
52
- stopEntry(entry, force, deps, allowAsyncWindowsTreeKill, result);
64
+ if (stopEntry(entry, force, deps, allowAsyncWindowsTreeKill, result)) {
65
+ removePids.push(entry.pid);
66
+ }
67
+ }
68
+ for (const pid of removePids) {
69
+ this.untrack(pid);
53
70
  }
54
71
  return result;
55
72
  }
@@ -127,15 +144,15 @@ function recordStopResult(result) {
127
144
  function stopEntry(entry, force, deps, allowAsyncWindowsTreeKill, result) {
128
145
  if (entry.stopState === "force" || entry.stopState === "graceful" && !force) {
129
146
  result.skipped += 1;
130
- return;
147
+ return false;
131
148
  }
132
149
  entry.stopState = force ? "force" : "graceful";
133
150
  result.attempted += 1;
134
151
  if (deps.platform === "win32" && allowAsyncWindowsTreeKill) {
135
152
  stopWindowsTree(entry, force, deps, result);
136
- return;
153
+ return force;
137
154
  }
138
- stopWithSignal(entry, force, deps, result);
155
+ return stopWithSignal(entry, force, deps, result);
139
156
  }
140
157
  function stopWindowsTree(entry, force, deps, result) {
141
158
  const args = ["/pid", String(entry.pid), "/t"];
@@ -152,19 +169,84 @@ function stopWindowsTree(entry, force, deps, result) {
152
169
  result.failures.push({ pid: entry.pid, message: formatError(error) });
153
170
  stopWithSignal(entry, force, deps, result);
154
171
  }
172
+ if (force && entry.cwd && shouldRunWindowsWorkspaceSweep(entry)) {
173
+ stopWindowsWorkspaceProcesses(entry.pid, entry.cwd, deps);
174
+ }
155
175
  }
156
176
  function stopWithSignal(entry, force, deps, result) {
157
177
  const signal = force ? "SIGKILL" : "SIGTERM";
158
178
  try {
159
179
  if (deps.platform !== "win32" && entry.detached) {
160
180
  deps.kill(-entry.pid, signal);
161
- return;
181
+ return force;
162
182
  }
163
183
  entry.child.kill(signal);
184
+ return force;
164
185
  } catch (error) {
186
+ if (isProcessGone(error)) {
187
+ return true;
188
+ }
165
189
  result.failures.push({ pid: entry.pid, message: formatError(error) });
190
+ return false;
166
191
  }
167
192
  }
193
+ function stopWindowsWorkspaceProcesses(rootPid, cwd, deps) {
194
+ const script = `
195
+ $rootPid = ${rootPid}
196
+ $cwd = ${JSON.stringify(cwd)}
197
+ $cwdLower = $cwd.ToLowerInvariant()
198
+ $rows = @(Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,CommandLine)
199
+ $byPid = @{}
200
+ $children = @{}
201
+ foreach ($row in $rows) {
202
+ $pidInt = [int]$row.ProcessId
203
+ $parentInt = [int]$row.ParentProcessId
204
+ $byPid[$pidInt] = $row
205
+ if (-not $children.ContainsKey($parentInt)) { $children[$parentInt] = @() }
206
+ $children[$parentInt] += $pidInt
207
+ }
208
+ $protected = New-Object 'System.Collections.Generic.HashSet[int]'
209
+ $cursor = $PID
210
+ while ($cursor -gt 0 -and $byPid.ContainsKey($cursor)) {
211
+ [void]$protected.Add($cursor)
212
+ $cursor = [int]$byPid[$cursor].ParentProcessId
213
+ }
214
+ $targets = New-Object 'System.Collections.Generic.HashSet[int]'
215
+ $queue = New-Object 'System.Collections.Generic.Queue[int]'
216
+ $queue.Enqueue($rootPid)
217
+ while ($queue.Count -gt 0) {
218
+ $pid = $queue.Dequeue()
219
+ if (-not $targets.Add($pid)) { continue }
220
+ if ($children.ContainsKey($pid)) {
221
+ foreach ($childPid in $children[$pid]) { $queue.Enqueue($childPid) }
222
+ }
223
+ }
224
+ foreach ($row in $rows) {
225
+ $cmd = [string]$row.CommandLine
226
+ if ($cmd.ToLowerInvariant().Contains($cwdLower)) {
227
+ [void]$targets.Add([int]$row.ProcessId)
228
+ }
229
+ }
230
+ foreach ($targetPid in $targets) {
231
+ if ($targetPid -gt 0 -and -not $protected.Contains($targetPid)) {
232
+ Stop-Process -Id $targetPid -Force -ErrorAction SilentlyContinue
233
+ }
234
+ }
235
+ `;
236
+ try {
237
+ deps.spawn("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], {
238
+ windowsHide: true,
239
+ stdio: "ignore"
240
+ });
241
+ } catch {
242
+ }
243
+ }
244
+ function isProcessGone(error) {
245
+ return typeof error === "object" && error !== null && "code" in error && error.code === "ESRCH";
246
+ }
247
+ function shouldRunWindowsWorkspaceSweep(entry) {
248
+ return entry.workspaceSweep || process.env.LINGHUN_PROCESS_GUARD_WORKSPACE_SWEEP === "1";
249
+ }
168
250
  function formatError(error) {
169
251
  return error instanceof Error ? error.message : String(error);
170
252
  }
@@ -27,7 +27,7 @@ import {
27
27
  } from "./chunk-CFXB5SE5.js";
28
28
  import {
29
29
  showCommandPanel
30
- } from "./chunk-JO5ANTMR.js";
30
+ } from "./chunk-AZU7HXIT.js";
31
31
  import {
32
32
  redactRemoteSummary,
33
33
  remoteTranscriptSummary
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createProcessGuard
3
- } from "./chunk-JHGWGH2C.js";
3
+ } from "./chunk-J6CYFWSW.js";
4
4
  import {
5
5
  sanitizeDiagnosticText,
6
6
  truncateDisplay
@@ -37,6 +37,9 @@ async function runCommandCapture(command, args, cwd, timeoutMs) {
37
37
  const stderr = [];
38
38
  const timer = setTimeout(() => {
39
39
  guard.requestStop(false);
40
+ setTimeout(() => {
41
+ guard.requestStop(true);
42
+ }, 1e3).unref();
40
43
  resolvePromise({
41
44
  exitCode: 124,
42
45
  stdout: Buffer.concat(stdout).toString("utf8"),
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ensureSession,
3
3
  showCommandPanel
4
- } from "./chunk-JO5ANTMR.js";
4
+ } from "./chunk-AZU7HXIT.js";
5
5
  import {
6
6
  decidePermission
7
7
  } from "./chunk-DDXS2RDZ.js";
@@ -10,7 +10,7 @@ import {
10
10
  budgetToolResultTranscriptContent,
11
11
  createEvidenceRecord,
12
12
  rememberEvidence
13
- } from "./chunk-64MJP6FK.js";
13
+ } from "./chunk-L2GU3PWU.js";
14
14
  import {
15
15
  sanitizeDiagnosticText,
16
16
  truncateDisplay,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  redactedPath
3
- } from "./chunk-RVY34HK4.js";
3
+ } from "./chunk-KOULRCYJ.js";
4
4
  import {
5
5
  truncateDisplay
6
6
  } from "./chunk-OMZYPQVA.js";
@@ -1,6 +1,11 @@
1
1
  import {
2
2
  evaluateUserStateSignal
3
3
  } from "./chunk-KQJHVJZB.js";
4
+ import {
5
+ detectEngineeringArtifactTargets,
6
+ formatEngineeringFailureBoundaryHint,
7
+ formatEngineeringProfileStrategyHint
8
+ } from "./chunk-4UER2AKI.js";
4
9
  import {
5
10
  LINGHUN_AGENT_CHILD_TURNS_AGENT,
6
11
  LINGHUN_AGENT_CHILD_TURNS_BASE,
@@ -119,6 +124,23 @@ function evaluateMetaScheduler(input) {
119
124
  const suggestedRole = highRiskClaim ? "verifier" : taskKind === "workflow" || taskKind === "agent" ? "planner" : void 0;
120
125
  const recentDeniedCount = input.recentDeniedCount ?? 0;
121
126
  const providerPlan = input.providerCooldownBlocked ? "cooldownBlocked" : providerFailure ? "fallbackCandidate" : "keepCurrent";
127
+ const engineeringProfile = input.engineeringProfile ?? "generic";
128
+ const inferredFailureCategory = input.engineeringFailureCategory ?? inferEngineeringFailureCategory({
129
+ providerFailure,
130
+ lastVerificationStatus: input.lastVerificationStatus,
131
+ lastToolFailure: input.lastToolFailure
132
+ });
133
+ const finalBoundaryHint = formatEngineeringFailureBoundaryHint({
134
+ profile: engineeringProfile,
135
+ failureCategory: inferredFailureCategory
136
+ });
137
+ const engineeringSignal = {
138
+ profile: engineeringProfile,
139
+ strategyHint: formatEngineeringProfileStrategyHint(engineeringProfile),
140
+ artifactTargets: detectEngineeringArtifactTargets(input.userText),
141
+ ...inferredFailureCategory ? { failureCategory: inferredFailureCategory } : {},
142
+ ...finalBoundaryHint ? { finalBoundaryHint } : {}
143
+ };
122
144
  const trustScore = input.trustScore ?? 50;
123
145
  const consecutiveFailures = input.consecutiveFailures ?? 0;
124
146
  const consecutiveSuccesses = input.consecutiveSuccesses ?? 0;
@@ -230,6 +252,7 @@ function evaluateMetaScheduler(input) {
230
252
  userState: adjustedUserStateDecision,
231
253
  capabilityPlan,
232
254
  userStatePersistence,
255
+ engineeringSignal,
233
256
  permissionSignal: {
234
257
  permissionMode: input.permissionMode ?? "default",
235
258
  recentDenied: recentDeniedCount > 0,
@@ -364,6 +387,7 @@ function formatMetaSchedulerDirective(decision) {
364
387
  "MetaSchedulerForModel:",
365
388
  ...decision.directives.map((item) => `- ${item}`),
366
389
  `- Typed policy route: task ${decision.policyDecision.taskKind}; risk ${decision.policyDecision.riskLevel}; budget ${decision.suggestedMaxTodoRounds} rounds; agent-max-turns ${decision.suggestedMaxAgentChildTurns}; agent-tool-rounds ${decision.suggestedMaxAgentToolRounds}; bg-concurrency ${decision.suggestedBackgroundConcurrency}; provider ${decision.policyDecision.providerPlan}; source-first ${decision.policyDecision.executionPlan.preferSourceFirst ? "yes" : "no"}; verification ${decision.policyDecision.executionPlan.requireVerification ? "required" : "normal"}; explicit-gate ${decision.policyDecision.permissionPlan.requireExplicitGate ? "required" : "normal"}; user-state ${decision.policyDecision.userState.kind}; capability ${decision.policyDecision.capabilitySignal.active ? "candidate" : "none"}.`,
390
+ `- EngineeringTaskProfile: profile=${decision.policyDecision.engineeringSignal.profile}; strategy=${decision.policyDecision.engineeringSignal.strategyHint}; failure=${decision.policyDecision.engineeringSignal.failureCategory ?? "none"}; final-boundary=${decision.policyDecision.engineeringSignal.finalBoundaryHint ?? "normal"}.`,
367
391
  ...decision.policyDecision.executionPlan.preferAgent || decision.policyDecision.executionPlan.preferWorkflow ? ["- Action: this is an agent/workflow-classified task. Delegate execution via StartAgent or RunWorkflow tools. Do not serial-Todo-plan every step yourself; use the extended planning budget to set up delegation, then call the tool."] : [],
368
392
  "- Keep RuntimeStatusForModel, UserStateDecision, capabilitySignal, capabilityPlan, CapabilityExecutionRequest, CapabilityExecutionResult, raw capability payload, interactionPlan, verificationPlan, notificationPlan, confidence, gateId, raw evidence, raw tool_result, and internal scheduler labels out of the user-visible final answer."
369
393
  ].join("\n");
@@ -832,6 +856,14 @@ function classifyVerificationLevel(input) {
832
856
  function isRiskyVerificationStatus(status) {
833
857
  return status === "fail" || status === "partial" || status === "stale" || status === "cancelled" || status === "timeout";
834
858
  }
859
+ function inferEngineeringFailureCategory(input) {
860
+ if (input.providerFailure) return "provider_error";
861
+ if (input.lastVerificationStatus === "timeout") return "test_timeout";
862
+ if (input.lastToolFailure && /missing artifact|missing required artifact|no such file|not found/iu.test(input.lastToolFailure.summary)) {
863
+ return "missing_artifact";
864
+ }
865
+ return void 0;
866
+ }
835
867
  function summarizeRuntimeSignal(input, evidenceFreshness) {
836
868
  let runningAgents = 0;
837
869
  let runningJobs = 0;
@@ -1097,6 +1129,7 @@ function createPolicyDecision(input) {
1097
1129
  permission: input.capabilityPlan.permission,
1098
1130
  riskLevel: input.capabilityPlan.riskLevel
1099
1131
  },
1132
+ engineeringSignal: input.engineeringSignal,
1100
1133
  capabilityPlan: input.capabilityPlan,
1101
1134
  runtimeSignal: input.runtimeSignal,
1102
1135
  userState: input.userState,
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-GTP2KPLY.js";
6
6
  import {
7
7
  showCommandPanel
8
- } from "./chunk-JO5ANTMR.js";
8
+ } from "./chunk-AZU7HXIT.js";
9
9
  import {
10
10
  MANAGED_WORKTREE_DIRNAME,
11
11
  redactWorktreePath,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  redactedPath,
3
3
  runCommandCapture
4
- } from "./chunk-RVY34HK4.js";
4
+ } from "./chunk-KOULRCYJ.js";
5
5
  import {
6
6
  formatFeatureFlags,
7
7
  getFeatureFlags
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-X7A22JHP.js";
4
4
  import {
5
5
  showCommandPanel
6
- } from "./chunk-JO5ANTMR.js";
6
+ } from "./chunk-AZU7HXIT.js";
7
7
  import {
8
8
  findFailureRecord,
9
9
  setFailureRecordStatus,