vgxness 0.1.0

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 (121) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +110 -0
  3. package/dist/agents/agent-activation-service.js +144 -0
  4. package/dist/agents/agent-registry-service.js +46 -0
  5. package/dist/agents/agent-resolver.js +249 -0
  6. package/dist/agents/agent-seed-service.js +146 -0
  7. package/dist/agents/manager-profile-overlay-service.js +34 -0
  8. package/dist/agents/profile-model-routing.js +26 -0
  9. package/dist/agents/renderers/claude-renderer.js +98 -0
  10. package/dist/agents/renderers/index.js +16 -0
  11. package/dist/agents/renderers/json-renderer.js +87 -0
  12. package/dist/agents/renderers/opencode-renderer.js +100 -0
  13. package/dist/agents/renderers/provider-adapter.js +6 -0
  14. package/dist/agents/repositories/agents.js +185 -0
  15. package/dist/agents/repositories/manager-profile-overlays.js +81 -0
  16. package/dist/agents/schema.js +1 -0
  17. package/dist/cli/dashboard-operational-read-models.js +153 -0
  18. package/dist/cli/dashboard-renderer.js +109 -0
  19. package/dist/cli/dashboard-screen-renderers.js +332 -0
  20. package/dist/cli/dashboard-tui-read-model.js +71 -0
  21. package/dist/cli/dashboard-tui-state.js +218 -0
  22. package/dist/cli/dispatcher.js +2880 -0
  23. package/dist/cli/index.js +27 -0
  24. package/dist/cli/interactive-dashboard.js +29 -0
  25. package/dist/cli/mcp-start-path.js +21 -0
  26. package/dist/cli/setup-status-renderer.js +29 -0
  27. package/dist/cli/setup-wizard-read-model.js +56 -0
  28. package/dist/cli/setup-wizard-renderer.js +148 -0
  29. package/dist/cli/setup-wizard-state.js +82 -0
  30. package/dist/cli/tui-render-helpers.js +192 -0
  31. package/dist/export/redaction.js +71 -0
  32. package/dist/harness/tools/agents.js +245 -0
  33. package/dist/harness/tools/memory.js +29 -0
  34. package/dist/mcp/client-install-opencode-contract.js +227 -0
  35. package/dist/mcp/client-install-opencode.js +194 -0
  36. package/dist/mcp/client-setup-preview.js +38 -0
  37. package/dist/mcp/control-plane.js +175 -0
  38. package/dist/mcp/doctor.js +193 -0
  39. package/dist/mcp/index.js +10 -0
  40. package/dist/mcp/opencode-default-agent-config.js +156 -0
  41. package/dist/mcp/opencode-visibility.js +102 -0
  42. package/dist/mcp/schema.js +234 -0
  43. package/dist/mcp/stdio-server.js +56 -0
  44. package/dist/mcp/validation.js +761 -0
  45. package/dist/memory/import/dry-run-planner.js +58 -0
  46. package/dist/memory/import/index.js +3 -0
  47. package/dist/memory/import/observation-writer.js +220 -0
  48. package/dist/memory/import/package.js +178 -0
  49. package/dist/memory/memory-service.js +126 -0
  50. package/dist/memory/repositories/artifacts.js +41 -0
  51. package/dist/memory/repositories/observations.js +133 -0
  52. package/dist/memory/repositories/sessions.js +105 -0
  53. package/dist/memory/repositories/traces.js +58 -0
  54. package/dist/memory/schema.js +1 -0
  55. package/dist/memory/search.js +11 -0
  56. package/dist/memory/sqlite/database.js +97 -0
  57. package/dist/memory/sqlite/migrations/001_initial.sql +128 -0
  58. package/dist/memory/sqlite/migrations/002_observation_revisions.sql +14 -0
  59. package/dist/memory/sqlite/migrations/003_agent_registry.sql +26 -0
  60. package/dist/memory/sqlite/migrations/004_run_runtime.sql +62 -0
  61. package/dist/memory/sqlite/migrations/005_run_approvals.sql +20 -0
  62. package/dist/memory/sqlite/migrations/006_run_operation_attempts.sql +32 -0
  63. package/dist/memory/sqlite/migrations/007_abandoned_operation_attempts.sql +46 -0
  64. package/dist/memory/sqlite/migrations/008_run_execution_plan_events.sql +105 -0
  65. package/dist/memory/sqlite/migrations/009_multiple_operation_attempts.sql +73 -0
  66. package/dist/memory/sqlite/migrations/010_skill_registry.sql +66 -0
  67. package/dist/memory/sqlite/migrations/011_skill_usage_resolution_outcomes.sql +21 -0
  68. package/dist/memory/sqlite/migrations/012_skill_improvement_proposals.sql +37 -0
  69. package/dist/memory/sqlite/migrations/013_skill_evaluation_scenarios.sql +43 -0
  70. package/dist/memory/sqlite/migrations/014_manager_profile_overlays.sql +14 -0
  71. package/dist/memory/storage-paths.js +72 -0
  72. package/dist/orchestrator/natural-language-planner.js +191 -0
  73. package/dist/orchestrator/schema.js +1 -0
  74. package/dist/permissions/index.js +2 -0
  75. package/dist/permissions/policy-evaluator.js +109 -0
  76. package/dist/permissions/schema.js +1 -0
  77. package/dist/providers/opencode/injection-preview.js +134 -0
  78. package/dist/providers/opencode/manager-payload.js +129 -0
  79. package/dist/runs/execution-planning.js +117 -0
  80. package/dist/runs/operation-execution.js +1 -0
  81. package/dist/runs/operation-retry.js +124 -0
  82. package/dist/runs/repositories/runs.js +611 -0
  83. package/dist/runs/run-insights.js +145 -0
  84. package/dist/runs/run-service.js +713 -0
  85. package/dist/runs/run-snapshot-export-service.js +31 -0
  86. package/dist/runs/sandbox-process-execution.js +218 -0
  87. package/dist/runs/sandbox-worktree-planning.js +59 -0
  88. package/dist/runs/schema.js +1 -0
  89. package/dist/sdd/artifact-portability-service.js +118 -0
  90. package/dist/sdd/schema.js +17 -0
  91. package/dist/sdd/sdd-workflow-service.js +217 -0
  92. package/dist/setup/backup-rollback-service.js +76 -0
  93. package/dist/setup/index.js +3 -0
  94. package/dist/setup/providers/antigravity-setup-adapter.js +18 -0
  95. package/dist/setup/providers/claude-setup-adapter.js +30 -0
  96. package/dist/setup/providers/custom-setup-adapter.js +18 -0
  97. package/dist/setup/providers/index.js +6 -0
  98. package/dist/setup/providers/opencode-setup-adapter.js +104 -0
  99. package/dist/setup/providers/provider-setup-adapter.js +15 -0
  100. package/dist/setup/providers/provider-setup-registry.js +11 -0
  101. package/dist/setup/schema.js +1 -0
  102. package/dist/setup/setup-defaults.js +11 -0
  103. package/dist/setup/setup-lifecycle-service.js +175 -0
  104. package/dist/setup/setup-plan.js +105 -0
  105. package/dist/skills/repositories/skill-evaluation-scenarios.js +289 -0
  106. package/dist/skills/repositories/skill-improvement-proposals.js +288 -0
  107. package/dist/skills/repositories/skills.js +430 -0
  108. package/dist/skills/schema.js +1 -0
  109. package/dist/skills/skill-payload.js +94 -0
  110. package/dist/skills/skill-registry-service.js +92 -0
  111. package/dist/skills/skill-resolver.js +191 -0
  112. package/dist/workflows/command-allowlist-adapter.js +70 -0
  113. package/dist/workflows/schema.js +4 -0
  114. package/dist/workflows/workflow-executor.js +345 -0
  115. package/dist/workflows/workflow-registry.js +66 -0
  116. package/docs/architecture.md +698 -0
  117. package/docs/cli.md +741 -0
  118. package/docs/funcionamiento-del-sistema.md +868 -0
  119. package/docs/harness-gap-analysis.md +229 -0
  120. package/docs/prd.md +372 -0
  121. package/package.json +57 -0
@@ -0,0 +1,145 @@
1
+ const insightSafety = { executableResume: false, executorInvoked: false, operationExecuted: false, writesProviderConfig: false, createsSandbox: false, createsWorktree: false };
2
+ export function buildRunInsights(run) {
3
+ const resumePlan = buildResumePlan(run);
4
+ return {
5
+ runId: run.id,
6
+ timeline: buildTimeline(run),
7
+ debug: buildDebugSummary(run),
8
+ resumePlan,
9
+ safety: insightSafety,
10
+ };
11
+ }
12
+ export function buildRunOperatorResumePlan(run) {
13
+ const insights = buildRunInsights(run);
14
+ const pendingApprovals = run.approvals.filter((approval) => approval.status === 'pending');
15
+ const activeAttempts = run.operationAttempts.filter((attempt) => attempt.status === 'reserved');
16
+ const failedAttempts = run.operationAttempts.filter((attempt) => attempt.status === 'failed');
17
+ return {
18
+ run: {
19
+ id: run.id,
20
+ project: run.project,
21
+ status: run.status,
22
+ ...(run.outcome === undefined ? {} : { outcome: run.outcome }),
23
+ ...(run.outcomeReason === undefined ? {} : { outcomeReason: run.outcomeReason }),
24
+ workflow: run.workflow,
25
+ phase: run.phase,
26
+ },
27
+ debug: insights.debug,
28
+ resumePlan: insights.resumePlan,
29
+ latestCheckpoint: insights.resumePlan.latestCheckpoint ?? null,
30
+ blockers: insights.resumePlan.blockers,
31
+ pendingApprovals,
32
+ activeAttempts,
33
+ failedAttempts,
34
+ manualNextCommands: buildManualNextCommands(run.id, insights.resumePlan.latestCheckpoint?.id, pendingApprovals),
35
+ evidenceReferences: buildEvidenceReferences(run.id, insights.resumePlan.latestCheckpoint?.id, pendingApprovals, activeAttempts, failedAttempts, insights.debug),
36
+ safety: insightSafety,
37
+ };
38
+ }
39
+ function buildTimeline(run) {
40
+ const entries = [{ id: `${run.id}:created`, type: 'run-created', timestamp: run.createdAt, order: 0, sourceOrder: 0, label: 'Run created', evidence: { runId: run.id, status: run.status } }];
41
+ for (const event of run.events)
42
+ entries.push({ id: event.id, type: 'event', timestamp: event.createdAt, order: 0, sourceOrder: event.sequence, label: event.title, evidence: { kind: event.kind, payload: event.payload } });
43
+ for (const checkpoint of run.checkpoints)
44
+ entries.push({ id: checkpoint.id, type: 'checkpoint', timestamp: checkpoint.createdAt, order: 0, sourceOrder: checkpoint.sequence, label: `Checkpoint: ${checkpoint.label}`, evidence: { checkpointId: checkpoint.id, sequence: checkpoint.sequence, state: checkpoint.state } });
45
+ for (const approval of run.approvals)
46
+ entries.push({ id: approval.id, type: 'approval', timestamp: approval.resolvedAt ?? approval.requestedAt, order: 0, sourceOrder: 0, label: `Approval ${approval.status}`, evidence: approvalEvidence(approval) });
47
+ for (const attempt of run.operationAttempts)
48
+ entries.push({ id: attempt.id, type: 'operation-attempt', timestamp: attempt.completedAt ?? attempt.updatedAt, order: 0, sourceOrder: attempt.attemptSequence, label: `Operation ${attempt.status}: ${attempt.category} ${attempt.operation}`, evidence: attemptEvidence(attempt) });
49
+ if (run.outcome !== undefined || isTerminal(run.status))
50
+ entries.push({ id: `${run.id}:outcome`, type: 'outcome', timestamp: run.completedAt ?? latestTimestamp(entries, run.updatedAt), order: 0, sourceOrder: Number.MAX_SAFE_INTEGER, label: `Run ${run.status}`, evidence: { status: run.status, outcome: run.outcome ?? null, outcomeReason: run.outcomeReason ?? null } });
51
+ return entries
52
+ .sort((left, right) => left.timestamp.localeCompare(right.timestamp) || typeRank(left.type) - typeRank(right.type) || left.sourceOrder - right.sourceOrder || left.id.localeCompare(right.id))
53
+ .map(({ sourceOrder: _sourceOrder, ...entry }, order) => ({ ...entry, order }));
54
+ }
55
+ function buildDebugSummary(run) {
56
+ const evidence = [];
57
+ if (run.outcomeReason !== undefined)
58
+ evidence.push({ source: 'outcome', message: run.outcomeReason });
59
+ for (const attempt of run.operationAttempts.filter((item) => item.status === 'failed')) {
60
+ evidence.push({ source: 'operation-attempt', relatedId: attempt.id, message: `Failed attempt ${attempt.category} ${attempt.operation}: ${readErrorMessage(attempt.error)}` });
61
+ }
62
+ if (run.operationAttempts.some((attempt) => attempt.status === 'failed'))
63
+ return { cause: 'operation-failed', summary: 'A recorded operation attempt failed. Treat this as the likely cause, not proof of root cause.', evidence, recommendedAction: 'Inspect the failed operation evidence, fix the underlying issue, then consider a manual restart from the latest safe checkpoint.' };
64
+ if (run.approvals.some((approval) => approval.status === 'pending'))
65
+ return { cause: 'pending-approval', summary: 'The run is waiting on recorded human approval.', evidence: pendingApprovalEvidence(run), recommendedAction: 'Resolve the pending approval or inspect debug details before retrying.' };
66
+ if (run.status === 'blocked')
67
+ return { cause: 'blocked', summary: 'The run is blocked by recorded status or outcome evidence.', evidence: evidence.length === 0 ? [{ source: 'status', message: 'Run status is blocked' }] : evidence, recommendedAction: 'Inspect blockers and resolve the recorded constraint before starting another run.' };
68
+ if (run.status === 'completed')
69
+ return { cause: 'completed', summary: 'The run completed successfully.', evidence: evidence.length === 0 ? [{ source: 'status', message: 'Run status is completed' }] : evidence, recommendedAction: 'No resume action is recommended for a completed run.' };
70
+ if (!isTerminal(run.status))
71
+ return { cause: 'still-running', summary: 'The run has not reached a terminal outcome yet.', evidence: [{ source: 'status', message: `Run status is ${run.status}` }], recommendedAction: 'Wait for the run to finish or inspect live run events.' };
72
+ return { cause: 'insufficient-evidence', summary: 'The run stopped without enough recorded evidence to classify a cause.', evidence, recommendedAction: 'Inspect the timeline and raw recorded details before deciding on a manual restart.' };
73
+ }
74
+ function buildResumePlan(run) {
75
+ const latestCheckpoint = findLatestCheckpoint(run);
76
+ const blockers = [];
77
+ if (latestCheckpoint === undefined)
78
+ blockers.push({ code: 'no-checkpoint', message: 'No recorded checkpoint is available for manual resume consideration.' });
79
+ for (const approval of run.approvals.filter((item) => item.status === 'pending'))
80
+ blockers.push({ code: 'pending-approval', message: 'A pending approval must be resolved first.', relatedId: approval.id });
81
+ for (const attempt of run.operationAttempts.filter((item) => item.status === 'reserved'))
82
+ blockers.push({ code: 'active-attempt', message: 'An active reserved operation attempt is already in progress.', relatedId: attempt.id });
83
+ if (!isTerminal(run.status))
84
+ blockers.push({ code: 'run-still-active', message: `Run status is ${run.status}; wait for a stopped state before resume planning.` });
85
+ if (run.status === 'completed')
86
+ blockers.push({ code: 'already-completed', message: 'Completed runs do not need resume.' });
87
+ if (run.status === 'blocked')
88
+ blockers.push({ code: 'blocked-run', message: 'Blocked runs require inspection before manual resume consideration.' });
89
+ const plan = { resumable: blockers.length === 0, executable: false, blockers, recommendedAction: blockers.length === 0 ? 'Review the latest safe checkpoint and manually decide whether to start a new run from that state.' : 'Resolve blockers or inspect debug details before considering a manual restart.' };
90
+ if (latestCheckpoint !== undefined)
91
+ plan.latestCheckpoint = { id: latestCheckpoint.id, label: latestCheckpoint.label, sequence: latestCheckpoint.sequence, createdAt: latestCheckpoint.createdAt, state: latestCheckpoint.state };
92
+ return plan;
93
+ }
94
+ function findLatestCheckpoint(run) {
95
+ const byId = run.latestCheckpointId === undefined ? undefined : run.checkpoints.find((checkpoint) => checkpoint.id === run.latestCheckpointId);
96
+ return byId ?? [...run.checkpoints].sort((left, right) => right.sequence - left.sequence || right.createdAt.localeCompare(left.createdAt))[0];
97
+ }
98
+ function approvalEvidence(approval) {
99
+ return { approvalId: approval.id, status: approval.status, decisionEventId: approval.decisionEventId, resolvedBy: approval.resolvedBy ?? null, resolutionReason: approval.resolutionReason ?? null };
100
+ }
101
+ function attemptEvidence(attempt) {
102
+ return { attemptId: attempt.id, status: attempt.status, category: attempt.category, operation: attempt.operation, operationMetadata: attempt.operationMetadata, output: attempt.output ?? null, error: attempt.error ?? null };
103
+ }
104
+ function pendingApprovalEvidence(run) {
105
+ return run.approvals.filter((approval) => approval.status === 'pending').map((approval) => ({ source: 'approval', relatedId: approval.id, message: 'Approval is pending' }));
106
+ }
107
+ function buildManualNextCommands(runId, checkpointId, pendingApprovals) {
108
+ return [
109
+ `vgxness runs get --id ${runId}`,
110
+ `vgxness runs timeline --id ${runId}`,
111
+ `vgxness runs debug --id ${runId}`,
112
+ `vgxness runs resume-plan --id ${runId}`,
113
+ ...manualApprovalCommands(runId, pendingApprovals),
114
+ checkpointId === undefined
115
+ ? 'No checkpoint is recorded; inspect the run details before deciding on manual recovery.'
116
+ : `Review checkpoint ${checkpointId} manually before starting any new run.`,
117
+ ];
118
+ }
119
+ function manualApprovalCommands(runId, pendingApprovals) {
120
+ if (pendingApprovals.length === 0)
121
+ return [];
122
+ return [`vgxness runs approvals --run ${runId}`, ...pendingApprovals.map((approval) => `vgxness runs retry-check --approval ${approval.id}`)];
123
+ }
124
+ function buildEvidenceReferences(runId, checkpointId, pendingApprovals, activeAttempts, failedAttempts, debug) {
125
+ return [
126
+ `run:${runId}`,
127
+ ...(checkpointId === undefined ? [] : [`checkpoint:${checkpointId}`]),
128
+ ...pendingApprovals.map((approval) => `approval:${approval.id}`),
129
+ ...activeAttempts.map((attempt) => `attempt:${attempt.id}`),
130
+ ...failedAttempts.map((attempt) => `attempt:${attempt.id}`),
131
+ ...debug.evidence.map((item) => `debug:${item.relatedId ?? item.message}`),
132
+ ];
133
+ }
134
+ function readErrorMessage(error) {
135
+ return typeof error === 'object' && error !== null && !Array.isArray(error) && typeof error.message === 'string' ? error.message : 'recorded error unavailable';
136
+ }
137
+ function isTerminal(status) {
138
+ return status === 'completed' || status === 'failed' || status === 'blocked' || status === 'cancelled';
139
+ }
140
+ function typeRank(type) {
141
+ return ['run-created', 'checkpoint', 'approval', 'operation-attempt', 'event', 'outcome'].indexOf(type);
142
+ }
143
+ function latestTimestamp(entries, fallback) {
144
+ return entries.reduce((latest, entry) => entry.timestamp > latest ? entry.timestamp : latest, fallback);
145
+ }