@vibgrate/cli 2026.731.2 → 2026.801.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.
- package/dist/{agent-6PPW5GIV.js → agent-4DAECASW.js} +8 -8
- package/dist/{agent-6PPW5GIV.js.map → agent-4DAECASW.js.map} +1 -1
- package/dist/{baseline-ZMHL6DXF.js → baseline-4BDH4F2W.js} +3 -3
- package/dist/{baseline-ZMHL6DXF.js.map → baseline-4BDH4F2W.js.map} +1 -1
- package/dist/{chunk-X634FZVG.js → chunk-3LOWJSAF.js} +11 -16
- package/dist/{chunk-X634FZVG.js.map → chunk-3LOWJSAF.js.map} +1 -1
- package/dist/{chunk-QWOJO32H.js → chunk-76TDXGGF.js} +3 -3
- package/dist/{chunk-QWOJO32H.js.map → chunk-76TDXGGF.js.map} +1 -1
- package/dist/chunk-7G5S5KZN.js +99 -0
- package/dist/chunk-7G5S5KZN.js.map +1 -0
- package/dist/{chunk-RIWLXMMT.js → chunk-7PVCHLR2.js} +4 -4
- package/dist/{chunk-RIWLXMMT.js.map → chunk-7PVCHLR2.js.map} +1 -1
- package/dist/{chunk-RGEVBSLK.js → chunk-A43I2AJ4.js} +3 -3
- package/dist/{chunk-RGEVBSLK.js.map → chunk-A43I2AJ4.js.map} +1 -1
- package/dist/{chunk-TNCD5VFX.js → chunk-B3OMGYZZ.js} +3 -3
- package/dist/{chunk-TNCD5VFX.js.map → chunk-B3OMGYZZ.js.map} +1 -1
- package/dist/{chunk-LZX5NH4V.js → chunk-BNEHDLVZ.js} +8 -8
- package/dist/{chunk-LZX5NH4V.js.map → chunk-BNEHDLVZ.js.map} +1 -1
- package/dist/{chunk-4CGLQXSI.js → chunk-E6H2F2XF.js} +3 -3
- package/dist/{chunk-4CGLQXSI.js.map → chunk-E6H2F2XF.js.map} +1 -1
- package/dist/{chunk-MYM5VIJ4.js → chunk-G25STLE7.js} +15 -9
- package/dist/chunk-G25STLE7.js.map +1 -0
- package/dist/{chunk-4DZC3ADC.js → chunk-G7W4MFPZ.js} +4 -4
- package/dist/{chunk-4DZC3ADC.js.map → chunk-G7W4MFPZ.js.map} +1 -1
- package/dist/{chunk-FHJBGPJZ.js → chunk-I6RBAIS3.js} +3 -3
- package/dist/{chunk-FHJBGPJZ.js.map → chunk-I6RBAIS3.js.map} +1 -1
- package/dist/{chunk-Q7HUXIUF.js → chunk-IRCYOTRG.js} +30 -57
- package/dist/chunk-IRCYOTRG.js.map +1 -0
- package/dist/{chunk-EVLS2M5G.js → chunk-JFE7XCAE.js} +3 -3
- package/dist/{chunk-EVLS2M5G.js.map → chunk-JFE7XCAE.js.map} +1 -1
- package/dist/{chunk-4TC6RJ7U.js → chunk-JLWI2JGA.js} +4 -4
- package/dist/{chunk-4TC6RJ7U.js.map → chunk-JLWI2JGA.js.map} +1 -1
- package/dist/{chunk-Y44GPOBL.js → chunk-KL65SSR7.js} +7 -7
- package/dist/{chunk-Y44GPOBL.js.map → chunk-KL65SSR7.js.map} +1 -1
- package/dist/{chunk-US2DAKCM.js → chunk-MPP4S4OE.js} +4 -4
- package/dist/{chunk-US2DAKCM.js.map → chunk-MPP4S4OE.js.map} +1 -1
- package/dist/{chunk-EETK7S43.js → chunk-SDG242R4.js} +399 -23
- package/dist/chunk-SDG242R4.js.map +1 -0
- package/dist/{chunk-IZNOMGR6.js → chunk-T6DRYOMT.js} +3 -3
- package/dist/{chunk-IZNOMGR6.js.map → chunk-T6DRYOMT.js.map} +1 -1
- package/dist/chunk-TGDHOAXX.js +6 -0
- package/dist/{chunk-NNB2H4BA.js.map → chunk-TGDHOAXX.js.map} +1 -1
- package/dist/{chunk-EX2SH5CT.js → chunk-V2QK3IUY.js} +5 -5
- package/dist/{chunk-EX2SH5CT.js.map → chunk-V2QK3IUY.js.map} +1 -1
- package/dist/{chunk-L6BRBFBP.js → chunk-V3X3DBZL.js} +5 -5
- package/dist/{chunk-L6BRBFBP.js.map → chunk-V3X3DBZL.js.map} +1 -1
- package/dist/{chunk-WBMMRERH.js → chunk-WIDZ5IE7.js} +4 -4
- package/dist/{chunk-WBMMRERH.js.map → chunk-WIDZ5IE7.js.map} +1 -1
- package/dist/{chunk-5J45MN3K.js → chunk-XEJJGDGX.js} +7 -7
- package/dist/{chunk-5J45MN3K.js.map → chunk-XEJJGDGX.js.map} +1 -1
- package/dist/cli.js +67 -121
- package/dist/cli.js.map +1 -1
- package/dist/{ensure-map-C3NEC2GI.js → ensure-map-SMWHKOUY.js} +11 -11
- package/dist/{ensure-map-C3NEC2GI.js.map → ensure-map-SMWHKOUY.js.map} +1 -1
- package/dist/{graph-backend-G5Y6QQV4.js → graph-backend-I4I72J4W.js} +4 -4
- package/dist/{graph-backend-G5Y6QQV4.js.map → graph-backend-I4I72J4W.js.map} +1 -1
- package/dist/index.d.ts +11 -4
- package/dist/index.js +10 -10
- package/dist/{interactive-2TAYVEHE.js → interactive-TMQR6TXM.js} +23 -23
- package/dist/{interactive-2TAYVEHE.js.map → interactive-TMQR6TXM.js.map} +1 -1
- package/dist/{llm-host-DZBD5D36.js → llm-host-XFYFOAAX.js} +4 -4
- package/dist/{llm-host-DZBD5D36.js.map → llm-host-XFYFOAAX.js.map} +1 -1
- package/dist/load-E3OTM7BS.js +10 -0
- package/dist/{load-A5BGEQWP.js.map → load-E3OTM7BS.js.map} +1 -1
- package/dist/{run-outcome-OSIVMVT7.js → run-outcome-QWLNBASF.js} +5 -5
- package/dist/{run-outcome-OSIVMVT7.js.map → run-outcome-QWLNBASF.js.map} +1 -1
- package/dist/runtime-session-UQ7UVAPL.js +20 -0
- package/dist/{runtime-session-UPTC3E6N.js.map → runtime-session-UQ7UVAPL.js.map} +1 -1
- package/dist/{session-3OBIQLE4.js → session-MG6BJVAG.js} +6 -6
- package/dist/{session-3OBIQLE4.js.map → session-MG6BJVAG.js.map} +1 -1
- package/dist/session-store-SQECEXUU.js +4 -0
- package/dist/{session-store-O4XPXKOV.js.map → session-store-SQECEXUU.js.map} +1 -1
- package/dist/{stream-json-CFKBL3MR.js → stream-json-GM44SP7L.js} +8 -8
- package/dist/{stream-json-CFKBL3MR.js.map → stream-json-GM44SP7L.js.map} +1 -1
- package/dist/{vg-mcp-bridge-JHRKJBVT.js → vg-mcp-bridge-3WFC7LGE.js} +6 -6
- package/dist/{vg-mcp-bridge-JHRKJBVT.js.map → vg-mcp-bridge-3WFC7LGE.js.map} +1 -1
- package/dist/{vgd-HNPOSXKZ.js → vgd-ZUSBEVUL.js} +8 -8
- package/dist/vgd-ZUSBEVUL.js.map +1 -0
- package/package.json +4 -2
- package/dist/chunk-EETK7S43.js.map +0 -1
- package/dist/chunk-K3SLGULW.js +0 -50
- package/dist/chunk-K3SLGULW.js.map +0 -1
- package/dist/chunk-MYM5VIJ4.js.map +0 -1
- package/dist/chunk-NNB2H4BA.js +0 -6
- package/dist/chunk-Q7HUXIUF.js.map +0 -1
- package/dist/load-A5BGEQWP.js +0 -10
- package/dist/runtime-session-UPTC3E6N.js +0 -20
- package/dist/session-store-O4XPXKOV.js +0 -4
- package/dist/vgd-HNPOSXKZ.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { EmbeddedLlmHost, LLM_HOST_IPC_SCHEMA, ProcessBridgeLlmHost, ProcessLlmHost, createLlmHost, defaultProcessEndpoint, generateWithLlamaBinding, resolveInferenceIsolation, startProcessHostServer } from './chunk-
|
|
2
|
-
export { acquireHostSession, allowGrammarStringFallback, assertGrammarOrThrow, attachDynamicIdentFilter, attachGrammar, buildIdentifierTokenBias, clearHostSessionPool, composePromptConstraints, createIdentStreamState, dropHostSession, dynamicAllowedNextChars, evictIdleSessions, filterTokenTexts, generateOnSession, hostSessionPoolSize, listHostSessions, pickBestDraft, planNextCharMask, probeBindingCapabilities, rankDraftCandidates, sessionKey, stepIdentStream, supportsDynamicIdentSampler, supportsKvPrefixEvaluate, tokenCompatibleWithTrie, trieFingerprint } from './chunk-
|
|
1
|
+
export { EmbeddedLlmHost, LLM_HOST_IPC_SCHEMA, ProcessBridgeLlmHost, ProcessLlmHost, createLlmHost, defaultProcessEndpoint, generateWithLlamaBinding, resolveInferenceIsolation, startProcessHostServer } from './chunk-JFE7XCAE.js';
|
|
2
|
+
export { acquireHostSession, allowGrammarStringFallback, assertGrammarOrThrow, attachDynamicIdentFilter, attachGrammar, buildIdentifierTokenBias, clearHostSessionPool, composePromptConstraints, createIdentStreamState, dropHostSession, dynamicAllowedNextChars, evictIdleSessions, filterTokenTexts, generateOnSession, hostSessionPoolSize, listHostSessions, pickBestDraft, planNextCharMask, probeBindingCapabilities, rankDraftCandidates, sessionKey, stepIdentStream, supportsDynamicIdentSampler, supportsKvPrefixEvaluate, tokenCompatibleWithTrie, trieFingerprint } from './chunk-3LOWJSAF.js';
|
|
3
3
|
import './chunk-5HYCB55P.js';
|
|
4
4
|
import './chunk-BWPBB45M.js';
|
|
5
5
|
import './chunk-JFGYT6BI.js';
|
|
6
6
|
import './chunk-BPF3YX2U.js';
|
|
7
7
|
import './chunk-Z6ZWNWWR.js';
|
|
8
|
-
//# sourceMappingURL=llm-host-
|
|
9
|
-
//# sourceMappingURL=llm-host-
|
|
8
|
+
//# sourceMappingURL=llm-host-XFYFOAAX.js.map
|
|
9
|
+
//# sourceMappingURL=llm-host-XFYFOAAX.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"llm-host-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"llm-host-XFYFOAAX.js"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { loadGraph } from './chunk-T6DRYOMT.js';
|
|
2
|
+
import './chunk-76TDXGGF.js';
|
|
3
|
+
import './chunk-TGDHOAXX.js';
|
|
4
|
+
import './chunk-ZKNB4YH4.js';
|
|
5
|
+
import './chunk-BWPBB45M.js';
|
|
6
|
+
import './chunk-JFGYT6BI.js';
|
|
7
|
+
import './chunk-BPF3YX2U.js';
|
|
8
|
+
import './chunk-Z6ZWNWWR.js';
|
|
9
|
+
//# sourceMappingURL=load-E3OTM7BS.js.map
|
|
10
|
+
//# sourceMappingURL=load-E3OTM7BS.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"load-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"load-E3OTM7BS.js"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { installId } from './chunk-
|
|
1
|
+
import { installId } from './chunk-B3OMGYZZ.js';
|
|
2
2
|
import './chunk-HTLDXEHW.js';
|
|
3
|
-
import { ensureVibgrateGitignore } from './chunk-
|
|
4
|
-
import './chunk-
|
|
3
|
+
import { ensureVibgrateGitignore } from './chunk-76TDXGGF.js';
|
|
4
|
+
import './chunk-TGDHOAXX.js';
|
|
5
5
|
import './chunk-ZKNB4YH4.js';
|
|
6
6
|
export { repositoryIdFromRoot as runOutcomeRepoId } from './chunk-BWPBB45M.js';
|
|
7
7
|
import './chunk-JFGYT6BI.js';
|
|
@@ -249,5 +249,5 @@ function turnRunId(sessionId, turnIndex) {
|
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
export { RUN_OUTCOME_SCHEMA, RunOutcomeRecorder, classifyEditKind, classifyInstructionKind, newOneShotRunId, shapeOfAction, turnRunId };
|
|
252
|
-
//# sourceMappingURL=run-outcome-
|
|
253
|
-
//# sourceMappingURL=run-outcome-
|
|
252
|
+
//# sourceMappingURL=run-outcome-QWLNBASF.js.map
|
|
253
|
+
//# sourceMappingURL=run-outcome-QWLNBASF.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/code/run-outcome.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAmCO,IAAM,kBAAA,GAAqB;AAsDlC,SAAS,IAAA,CAAK,WAAmB,KAAA,EAAuB;AACtD,EAAA,OAAO,UAAA,CAAW,QAAQ,CAAA,CAAE,MAAA,CAAO,CAAA,EAAG,SAAS,CAAA,CAAA,EAAI,KAAK,CAAA,C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CAAO,KAAA,CAAM,YAAA,EAAc,MAAA,EAAQ,MAAA,CAAO,KAAA,CAAM,gBAAA,EAAiB,GAAI;AAAA,KAChG,CAAA;AACD,IAAA,IAAA,CAAK,OAAA,CAAQ,OAAO,KAAK,CAAA;AACzB,IAAA,IAAI,IAAA,CAAK,YAAA,KAAiB,KAAA,EAAO,IAAA,CAAK,YAAA,GAAe,IAAA;AAAA,EACvD;AACF;AAGO,SAAS,eAAA,GAA0B;AACxC,EAAA,OAAO,CAAA,CAAA,EAAI,YAAY,CAAA,CAAA;AACzB;AAGO,SAAS,SAAA,CAAU,WAAmB,SAAA,EAA2B;AACtE,EAAA,OAAO,CAAA,EAAG,SAAS,CAAA,CAAA,EAAI,SAAS,CAAA,CAAA;AAClC","file":"run-outcome-OSIVMVT7.js","sourcesContent":["/**\n * `vibgrate.run-outcome/1` — the local, append-only record of what a `vg code`\n * run did: what was proposed, what the human decided, and how the run ended.\n *\n * CORRECTION (2026-07-30, maintainer): this module was originally justified by\n * two future consumers — the verify loop and \"Relay routing telemetry\" (using\n * edit-acceptance data to auto-pick a model per request). The second is now\n * confirmed void: Relay never re-picks a model — the user (or their chosen\n * Code Mode) selects one model for the whole session, and that has never been\n * a requirement for any product in this space. The verify loop, meanwhile, is\n * shipped separately via the extension's LSP round-trip and never depended on\n * this schema. See `docs/VG-RUN-OUTCOME-EVENTS-SPEC.md` for the full record —\n * **this producer currently has no live or committed consumer.**\n *\n * This module only produces; nothing reads or transmits the file yet, and\n * nothing here changes `vg code`'s stdout NDJSON protocol — it is a silent\n * observer wired at the `--stream-json` call site in `commands/code.ts`, built\n * and unit-tested independent of any process, model, or socket, the same way\n * `stream-json.ts` is.\n *\n * Privacy (spec's hard rule): no event carries source code, diffs, file\n * contents, prompts, or file paths. Instructions become a salted hash only;\n * files become a language/kind classification only.\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { createHash, randomUUID } from 'node:crypto';\nimport { installId } from '../engine/stats-share.js';\nimport { ensureVibgrateGitignore } from '../engine/artifacts.js';\nimport { repositoryIdFromRoot } from '../runtime/paths.js';\nimport type { MutatingAction, PatchFileAction } from './tools.js';\nimport type { AgentResult } from './agent.js';\nimport type { StreamJsonOut } from './stream-json.js';\n\nexport const RUN_OUTCOME_SCHEMA = 'vibgrate.run-outcome/1';\n\nexport type InstructionKind = 'upgrade' | 'fix-vuln' | 'refactor' | 'feature' | 'other';\nexport type EditKind = 'code' | 'manifest' | 'lockfile' | 'config' | 'docs' | 'test';\nexport type EditDecision = 'approved' | 'rejected' | 'auto-approved';\nexport type RunOutcome = 'done' | 'error' | 'cancelled';\n\ninterface Envelope {\n schema: typeof RUN_OUTCOME_SCHEMA;\n runId: string;\n ts: string;\n repoId: string;\n gitRef: string | null;\n route: { mode?: string; provider?: string; model?: string };\n securityTier: string;\n}\n\nexport type RunOutcomeEvent =\n | (Envelope & {\n event: 'run_started';\n instructionHash: string;\n instructionKind: InstructionKind;\n /** Absent (never 0/null-as-zero) — this producer does not trigger a rescan. */\n baseline: { driftScore: number | null; scoreMode: 'verified' | 'estimated' | null; advisories: number | null };\n })\n | (Envelope & {\n event: 'edit_proposed';\n editId: string;\n language: string | null;\n linesAdded: number;\n linesRemoved: number;\n kind: EditKind;\n })\n | (Envelope & { event: 'edit_decision'; editId: string; decision: EditDecision; latencyMs: number })\n | (Envelope & {\n event: 'run_completed';\n outcome: RunOutcome;\n edits: { proposed: number; approved: number; rejected: number; autoApproved: number };\n /** Same reasoning as `baseline` — this producer never triggers a rescan. */\n verify: null;\n /**\n * Last verify-step (the project's configured test/build command) result\n * observed this run. `null` = no verify step ran, never a false pass.\n */\n verifyOk: boolean | null;\n tokens: { input: number; output: number } | null;\n });\n\nexport interface RunOutcomeRoute {\n mode?: string;\n provider?: string;\n model?: string;\n}\n\nfunction hash(saltValue: string, value: string): string {\n return createHash('sha256').update(`${saltValue}|${value}`).digest('hex');\n}\n\n/**\n * Best-effort, best-guess classification of an instruction's purpose. A\n * heuristic, not a model call — good enough for routing-signal aggregation,\n * not claimed as precise. `fromFinding` is set when the instruction was\n * composed by \"Fix →\" (routeFix.ts), which already know their own\n * kind and skip guessing.\n */\nexport function classifyInstructionKind(\n instruction: string,\n fromFinding?: 'upgrade' | 'fix-vuln',\n): InstructionKind {\n if (fromFinding) return fromFinding;\n const s = instruction.toLowerCase();\n if (/\\bupgrade\\b/.test(s) || /\\bfrom\\s+\\S+\\s+to\\s+\\S+/.test(s)) return 'upgrade';\n if (/\\b(cve|vulnerab|advisor|security fix|exploit)\\b/.test(s)) return 'fix-vuln';\n if (/\\brefactor\\b/.test(s)) return 'refactor';\n if (/\\b(add|implement|build|create|feature)\\b/.test(s)) return 'feature';\n return 'other';\n}\n\nconst MANIFEST_BASENAMES = new Set([\n 'package.json', 'go.mod', 'cargo.toml', 'pyproject.toml', 'requirements.txt',\n 'gemfile', 'composer.json', 'pom.xml', 'build.gradle', 'build.gradle.kts',\n 'pubspec.yaml', 'mix.exs',\n]);\nconst LOCKFILE_BASENAMES = new Set([\n 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'cargo.lock', 'poetry.lock',\n 'gemfile.lock', 'composer.lock', 'go.sum', 'pubspec.lock', 'mix.lock',\n]);\nconst MANIFEST_EXTS = new Set(['.csproj', '.fsproj', '.vbproj']);\n\n/** Coarse per-file classification for `edit_proposed.kind` — filename-only, no content read. */\nexport function classifyEditKind(file: string): EditKind {\n const base = path.basename(file).toLowerCase();\n const ext = path.extname(base);\n if (MANIFEST_BASENAMES.has(base) || MANIFEST_EXTS.has(ext)) return 'manifest';\n if (LOCKFILE_BASENAMES.has(base)) return 'lockfile';\n if (ext === '.md' || ext === '.mdx' || file.split(/[\\\\/]/).includes('docs')) return 'docs';\n if (/\\.(test|spec)\\.[^.]+$/.test(base) || /(^|[\\\\/])(__tests__|tests|test|spec)([\\\\/]|$)/.test(file)) return 'test';\n if (base.startsWith('.') || /\\.config\\.[^.]+$/.test(base) || /\\.(ya?ml|toml|ini|env)$/.test(base)) return 'config';\n return 'code';\n}\n\n/** Language/extension label only — never a path. Empty extension → null. */\nfunction languageOf(file: string): string | null {\n const ext = path.extname(file).replace(/^\\./, '');\n return ext || null;\n}\n\n/** Count `+`/`-` content lines in a unified diff (excludes `+++`/`---` headers). */\nfunction diffLineCounts(diff: string): { added: number; removed: number } {\n let added = 0;\n let removed = 0;\n for (const line of diff.split('\\n')) {\n if (line.startsWith('+++') || line.startsWith('---')) continue;\n if (line.startsWith('+')) added++;\n else if (line.startsWith('-')) removed++;\n }\n return { added, removed };\n}\n\ninterface EditShape {\n language: string | null;\n linesAdded: number;\n linesRemoved: number;\n kind: EditKind;\n}\n\n/** Derive the `edit_proposed` shape from a `MutatingAction`, or null for non-edit actions (`run`/`tool`). */\nexport function shapeOfAction(action: MutatingAction): EditShape | null {\n switch (action.kind) {\n case 'edit': {\n const { added, removed } = diffLineCounts(action.diff);\n return { language: languageOf(action.file), linesAdded: added, linesRemoved: removed, kind: classifyEditKind(action.file) };\n }\n case 'create':\n return { language: languageOf(action.file), linesAdded: 0, linesRemoved: 0, kind: classifyEditKind(action.file) };\n case 'delete':\n return { language: languageOf(action.file), linesAdded: 0, linesRemoved: 0, kind: classifyEditKind(action.file) };\n case 'patch': {\n let added = 0;\n let removed = 0;\n const kinds = new Set<EditKind>();\n for (const f of action.files as PatchFileAction[]) {\n if (f.diff) {\n const c = diffLineCounts(f.diff);\n added += c.added;\n removed += c.removed;\n }\n kinds.add(classifyEditKind(f.file));\n }\n return { language: null, linesAdded: added, linesRemoved: removed, kind: kinds.size === 1 ? [...kinds][0]! : 'code' };\n }\n case 'run':\n case 'tool':\n return null; // not a file edit — out of scope for this schema\n }\n}\n\nfunction outcomeDir(root: string): string {\n return path.join(root, '.vibgrate');\n}\n\nfunction outcomePath(root: string): string {\n return path.join(outcomeDir(root), 'run-outcomes.jsonl');\n}\n\n/** Best-effort append — a read-only checkout just means no local record, never a thrown error. */\nfunction append(root: string, event: RunOutcomeEvent): void {\n try {\n fs.mkdirSync(outcomeDir(root), { recursive: true });\n // First writer into .vibgrate/ in this repo creates its .gitignore (create-once,\n // never overwritten) — protects this file even when `vg code` runs before any\n // `vg scan`/`vg build`/`vg install` has touched the repo.\n ensureVibgrateGitignore(root);\n fs.appendFileSync(outcomePath(root), `${JSON.stringify(event)}\\n`);\n } catch {\n /* best-effort only */\n }\n}\n\ninterface PendingEdit {\n runId: string;\n shape: EditShape;\n proposedAt: number;\n}\n\ninterface RunTally {\n proposed: number;\n approved: number;\n rejected: number;\n autoApproved: number;\n lastVerifyOk: boolean | null;\n}\n\n/**\n * Observes the same `StreamJsonOut` lines already flowing to the host over\n * stdout/stdin (via a transparent tee — see `wireRunOutcome`) and turns them\n * into the envelope above. One instance per `vg code` process; `beginRun` is\n * called once per turn (once for a one-shot run, once per turn in session\n * mode), so `runId` scoping is the caller's — this class never invents one.\n */\nexport class RunOutcomeRecorder {\n private currentRunId: string | null = null;\n private readonly tallies = new Map<string, RunTally>();\n private readonly pending = new Map<number, PendingEdit>();\n\n constructor(\n private readonly root: string,\n private readonly repoId: string,\n private readonly gitRef: string | null,\n private readonly route: RunOutcomeRoute,\n private readonly securityTier: string,\n private readonly auto: boolean,\n private readonly now: () => number = Date.now,\n /**\n * Salt for `instructionHash`. Defaults to the real per-install id\n * ({@link installId}) in production; tests should pass a fixed string so\n * they never touch the real machine's `~/.vibgrate/install-id`.\n */\n private readonly saltValue: string = installId(),\n ) {}\n\n private envelope(runId: string): Envelope {\n return {\n schema: RUN_OUTCOME_SCHEMA,\n runId,\n ts: new Date(this.now()).toISOString(),\n repoId: this.repoId,\n gitRef: this.gitRef,\n route: this.route,\n securityTier: this.securityTier,\n };\n }\n\n /** Start recording a new run/turn. Call before the instruction is handed to the agent. */\n beginRun(runId: string, instruction: string, fromFinding?: 'upgrade' | 'fix-vuln'): void {\n this.currentRunId = runId;\n this.tallies.set(runId, { proposed: 0, approved: 0, rejected: 0, autoApproved: 0, lastVerifyOk: null });\n append(this.root, {\n ...this.envelope(runId),\n event: 'run_started',\n instructionHash: hash(this.saltValue, instruction),\n instructionKind: classifyInstructionKind(instruction, fromFinding),\n baseline: { driftScore: null, scoreMode: null, advisories: null },\n });\n }\n\n /**\n * Feed one outgoing protocol line. Transparent — never mutates or drops\n * the line; the caller still writes it to the host exactly as before.\n */\n observe(line: StreamJsonOut): void {\n const runId = this.currentRunId;\n if (!runId) return;\n const tally = this.tallies.get(runId);\n if (!tally) return;\n\n if (line.event === 'approve-request') {\n const shape = shapeOfAction(line.action);\n if (!shape) return; // run/tool — not a file edit\n tally.proposed++;\n const editId = randomUUID();\n this.pending.set(line.id, { runId, shape, proposedAt: this.now() });\n append(this.root, { ...this.envelope(runId), event: 'edit_proposed', editId, ...shape });\n // Auto-approve resolves synchronously in StreamJsonSession before any\n // host round-trip — record that decision now; no host message arrives.\n if (this.auto) {\n tally.autoApproved++;\n append(this.root, { ...this.envelope(runId), event: 'edit_decision', editId, decision: 'auto-approved', latencyMs: 0 });\n this.pending.delete(line.id);\n } else {\n // Stash the editId against the wire id so `noteDecision` can find it.\n this.editIdByApproveId.set(line.id, editId);\n }\n return;\n }\n\n if (line.event === 'event' && line.type === 'verify') {\n tally.lastVerifyOk = line.passed;\n return;\n }\n\n if (line.event === 'done') {\n this.finish(runId, tally, 'done', line.result);\n return;\n }\n if (line.event === 'error') {\n this.finish(runId, tally, 'error', null);\n }\n }\n\n private readonly editIdByApproveId = new Map<number, string>();\n\n /**\n * A real (non-auto) approve/reject arrived from the host over stdin. `id`\n * is the same numeric id `StreamJsonSession` put on the `approve-request`\n * line — the natural join key, already unique for the process lifetime.\n */\n noteDecision(approveId: number, approved: boolean): void {\n const editId = this.editIdByApproveId.get(approveId);\n const pending = this.pending.get(approveId);\n if (!editId || !pending) return;\n this.editIdByApproveId.delete(approveId);\n this.pending.delete(approveId);\n const tally = this.tallies.get(pending.runId);\n if (tally) approved ? tally.approved++ : tally.rejected++;\n append(this.root, {\n ...this.envelope(pending.runId),\n event: 'edit_decision',\n editId,\n decision: approved ? 'approved' : 'rejected',\n latencyMs: Math.max(0, this.now() - pending.proposedAt),\n });\n }\n\n /** The host disconnected / turn was cancelled mid-approval — reject what's left, no hang. */\n cancelPending(): void {\n for (const id of [...this.pending.keys()]) this.noteDecision(id, false);\n }\n\n private finish(runId: string, tally: RunTally, outcome: RunOutcome, result: AgentResult | null): void {\n append(this.root, {\n ...this.envelope(runId),\n event: 'run_completed',\n outcome,\n edits: { proposed: tally.proposed, approved: tally.approved, rejected: tally.rejected, autoApproved: tally.autoApproved },\n verify: null,\n verifyOk: tally.lastVerifyOk,\n tokens: result ? { input: result.usage.promptTokens, output: result.usage.completionTokens } : null,\n });\n this.tallies.delete(runId);\n if (this.currentRunId === runId) this.currentRunId = null;\n }\n}\n\n/** Mint a runId for a one-shot `vg code` invocation (no session). */\nexport function newOneShotRunId(): string {\n return `r${randomUUID()}`;\n}\n\n/** Mint a runId for one turn of a `--session` run. */\nexport function turnRunId(sessionId: string, turnIndex: number): string {\n return `${sessionId}#${turnIndex}`;\n}\n\nexport { repositoryIdFromRoot as runOutcomeRepoId };\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/code/run-outcome.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAmCO,IAAM,kBAAA,GAAqB;AAsDlC,SAAS,IAAA,CAAK,WAAmB,KAAA,EAAuB;AACtD,EAAA,OAAO,UAAA,CAAW,QAAQ,CAAA,CAAE,MAAA,CAAO,CAAA,EAAG,SAAS,CAAA,CAAA,EAAI,KAAK,CAAA,CAAE,CAAA,CAAE,MAAA,CAAO,KAAK,CAAA;AAC1E;AASO,SAAS,uBAAA,CACd,aACA,WAAA,EACiB;AACjB,EAAA,IAAI,aAAa,OAAO,WAAA;AACxB,EAAA,MAAM,CAAA,GAAI,YAAY,WAAA,EAAY;AAClC,EAAA,IAAI,aAAA,CAAc,KAAK,CAAC,CAAA,IAAK,0BAA0B,IAAA,CAAK,CAAC,GAAG,OAAO,SAAA;AACvE,EAAA,IAAI,iDAAA,CAA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OAAO,CAAA,CAAA,EAAI,YAAY,CAAA,CAAA;AACzB;AAGO,SAAS,SAAA,CAAU,WAAmB,SAAA,EAA2B;AACtE,EAAA,OAAO,CAAA,EAAG,SAAS,CAAA,CAAA,EAAI,SAAS,CAAA,CAAA;AAClC","file":"run-outcome-QWLNBASF.js","sourcesContent":["/**\n * `vibgrate.run-outcome/1` — the local, append-only record of what a `vg code`\n * run did: what was proposed, what the human decided, and how the run ended.\n *\n * CORRECTION (2026-07-30, maintainer): this module was originally justified by\n * two future consumers — the verify loop and \"Relay routing telemetry\" (using\n * edit-acceptance data to auto-pick a model per request). The second is now\n * confirmed void: Relay never re-picks a model — the user (or their chosen\n * Code Mode) selects one model for the whole session, and that has never been\n * a requirement for any product in this space. The verify loop, meanwhile, is\n * shipped separately via the extension's LSP round-trip and never depended on\n * this schema. See `docs/VG-RUN-OUTCOME-EVENTS-SPEC.md` for the full record —\n * **this producer currently has no live or committed consumer.**\n *\n * This module only produces; nothing reads or transmits the file yet, and\n * nothing here changes `vg code`'s stdout NDJSON protocol — it is a silent\n * observer wired at the `--stream-json` call site in `commands/code.ts`, built\n * and unit-tested independent of any process, model, or socket, the same way\n * `stream-json.ts` is.\n *\n * Privacy (spec's hard rule): no event carries source code, diffs, file\n * contents, prompts, or file paths. Instructions become a salted hash only;\n * files become a language/kind classification only.\n */\n\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { createHash, randomUUID } from 'node:crypto';\nimport { installId } from '../engine/stats-share.js';\nimport { ensureVibgrateGitignore } from '../engine/artifacts.js';\nimport { repositoryIdFromRoot } from '../runtime/paths.js';\nimport type { MutatingAction, PatchFileAction } from './tools.js';\nimport type { AgentResult } from './agent.js';\nimport type { StreamJsonOut } from './stream-json.js';\n\nexport const RUN_OUTCOME_SCHEMA = 'vibgrate.run-outcome/1';\n\nexport type InstructionKind = 'upgrade' | 'fix-vuln' | 'refactor' | 'feature' | 'other';\nexport type EditKind = 'code' | 'manifest' | 'lockfile' | 'config' | 'docs' | 'test';\nexport type EditDecision = 'approved' | 'rejected' | 'auto-approved';\nexport type RunOutcome = 'done' | 'error' | 'cancelled';\n\ninterface Envelope {\n schema: typeof RUN_OUTCOME_SCHEMA;\n runId: string;\n ts: string;\n repoId: string;\n gitRef: string | null;\n route: { mode?: string; provider?: string; model?: string };\n securityTier: string;\n}\n\nexport type RunOutcomeEvent =\n | (Envelope & {\n event: 'run_started';\n instructionHash: string;\n instructionKind: InstructionKind;\n /** Absent (never 0/null-as-zero) — this producer does not trigger a rescan. */\n baseline: { driftScore: number | null; scoreMode: 'verified' | 'estimated' | null; advisories: number | null };\n })\n | (Envelope & {\n event: 'edit_proposed';\n editId: string;\n language: string | null;\n linesAdded: number;\n linesRemoved: number;\n kind: EditKind;\n })\n | (Envelope & { event: 'edit_decision'; editId: string; decision: EditDecision; latencyMs: number })\n | (Envelope & {\n event: 'run_completed';\n outcome: RunOutcome;\n edits: { proposed: number; approved: number; rejected: number; autoApproved: number };\n /** Same reasoning as `baseline` — this producer never triggers a rescan. */\n verify: null;\n /**\n * Last verify-step (the project's configured test/build command) result\n * observed this run. `null` = no verify step ran, never a false pass.\n */\n verifyOk: boolean | null;\n tokens: { input: number; output: number } | null;\n });\n\nexport interface RunOutcomeRoute {\n mode?: string;\n provider?: string;\n model?: string;\n}\n\nfunction hash(saltValue: string, value: string): string {\n return createHash('sha256').update(`${saltValue}|${value}`).digest('hex');\n}\n\n/**\n * Best-effort, best-guess classification of an instruction's purpose. A\n * heuristic, not a model call — good enough for routing-signal aggregation,\n * not claimed as precise. `fromFinding` is set when the instruction was\n * composed by \"Fix →\" (routeFix.ts), which already know their own\n * kind and skip guessing.\n */\nexport function classifyInstructionKind(\n instruction: string,\n fromFinding?: 'upgrade' | 'fix-vuln',\n): InstructionKind {\n if (fromFinding) return fromFinding;\n const s = instruction.toLowerCase();\n if (/\\bupgrade\\b/.test(s) || /\\bfrom\\s+\\S+\\s+to\\s+\\S+/.test(s)) return 'upgrade';\n if (/\\b(cve|vulnerab|advisor|security fix|exploit)\\b/.test(s)) return 'fix-vuln';\n if (/\\brefactor\\b/.test(s)) return 'refactor';\n if (/\\b(add|implement|build|create|feature)\\b/.test(s)) return 'feature';\n return 'other';\n}\n\nconst MANIFEST_BASENAMES = new Set([\n 'package.json', 'go.mod', 'cargo.toml', 'pyproject.toml', 'requirements.txt',\n 'gemfile', 'composer.json', 'pom.xml', 'build.gradle', 'build.gradle.kts',\n 'pubspec.yaml', 'mix.exs',\n]);\nconst LOCKFILE_BASENAMES = new Set([\n 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'cargo.lock', 'poetry.lock',\n 'gemfile.lock', 'composer.lock', 'go.sum', 'pubspec.lock', 'mix.lock',\n]);\nconst MANIFEST_EXTS = new Set(['.csproj', '.fsproj', '.vbproj']);\n\n/** Coarse per-file classification for `edit_proposed.kind` — filename-only, no content read. */\nexport function classifyEditKind(file: string): EditKind {\n const base = path.basename(file).toLowerCase();\n const ext = path.extname(base);\n if (MANIFEST_BASENAMES.has(base) || MANIFEST_EXTS.has(ext)) return 'manifest';\n if (LOCKFILE_BASENAMES.has(base)) return 'lockfile';\n if (ext === '.md' || ext === '.mdx' || file.split(/[\\\\/]/).includes('docs')) return 'docs';\n if (/\\.(test|spec)\\.[^.]+$/.test(base) || /(^|[\\\\/])(__tests__|tests|test|spec)([\\\\/]|$)/.test(file)) return 'test';\n if (base.startsWith('.') || /\\.config\\.[^.]+$/.test(base) || /\\.(ya?ml|toml|ini|env)$/.test(base)) return 'config';\n return 'code';\n}\n\n/** Language/extension label only — never a path. Empty extension → null. */\nfunction languageOf(file: string): string | null {\n const ext = path.extname(file).replace(/^\\./, '');\n return ext || null;\n}\n\n/** Count `+`/`-` content lines in a unified diff (excludes `+++`/`---` headers). */\nfunction diffLineCounts(diff: string): { added: number; removed: number } {\n let added = 0;\n let removed = 0;\n for (const line of diff.split('\\n')) {\n if (line.startsWith('+++') || line.startsWith('---')) continue;\n if (line.startsWith('+')) added++;\n else if (line.startsWith('-')) removed++;\n }\n return { added, removed };\n}\n\ninterface EditShape {\n language: string | null;\n linesAdded: number;\n linesRemoved: number;\n kind: EditKind;\n}\n\n/** Derive the `edit_proposed` shape from a `MutatingAction`, or null for non-edit actions (`run`/`tool`). */\nexport function shapeOfAction(action: MutatingAction): EditShape | null {\n switch (action.kind) {\n case 'edit': {\n const { added, removed } = diffLineCounts(action.diff);\n return { language: languageOf(action.file), linesAdded: added, linesRemoved: removed, kind: classifyEditKind(action.file) };\n }\n case 'create':\n return { language: languageOf(action.file), linesAdded: 0, linesRemoved: 0, kind: classifyEditKind(action.file) };\n case 'delete':\n return { language: languageOf(action.file), linesAdded: 0, linesRemoved: 0, kind: classifyEditKind(action.file) };\n case 'patch': {\n let added = 0;\n let removed = 0;\n const kinds = new Set<EditKind>();\n for (const f of action.files as PatchFileAction[]) {\n if (f.diff) {\n const c = diffLineCounts(f.diff);\n added += c.added;\n removed += c.removed;\n }\n kinds.add(classifyEditKind(f.file));\n }\n return { language: null, linesAdded: added, linesRemoved: removed, kind: kinds.size === 1 ? [...kinds][0]! : 'code' };\n }\n case 'run':\n case 'tool':\n return null; // not a file edit — out of scope for this schema\n }\n}\n\nfunction outcomeDir(root: string): string {\n return path.join(root, '.vibgrate');\n}\n\nfunction outcomePath(root: string): string {\n return path.join(outcomeDir(root), 'run-outcomes.jsonl');\n}\n\n/** Best-effort append — a read-only checkout just means no local record, never a thrown error. */\nfunction append(root: string, event: RunOutcomeEvent): void {\n try {\n fs.mkdirSync(outcomeDir(root), { recursive: true });\n // First writer into .vibgrate/ in this repo creates its .gitignore (create-once,\n // never overwritten) — protects this file even when `vg code` runs before any\n // `vg scan`/`vg build`/`vg install` has touched the repo.\n ensureVibgrateGitignore(root);\n fs.appendFileSync(outcomePath(root), `${JSON.stringify(event)}\\n`);\n } catch {\n /* best-effort only */\n }\n}\n\ninterface PendingEdit {\n runId: string;\n shape: EditShape;\n proposedAt: number;\n}\n\ninterface RunTally {\n proposed: number;\n approved: number;\n rejected: number;\n autoApproved: number;\n lastVerifyOk: boolean | null;\n}\n\n/**\n * Observes the same `StreamJsonOut` lines already flowing to the host over\n * stdout/stdin (via a transparent tee — see `wireRunOutcome`) and turns them\n * into the envelope above. One instance per `vg code` process; `beginRun` is\n * called once per turn (once for a one-shot run, once per turn in session\n * mode), so `runId` scoping is the caller's — this class never invents one.\n */\nexport class RunOutcomeRecorder {\n private currentRunId: string | null = null;\n private readonly tallies = new Map<string, RunTally>();\n private readonly pending = new Map<number, PendingEdit>();\n\n constructor(\n private readonly root: string,\n private readonly repoId: string,\n private readonly gitRef: string | null,\n private readonly route: RunOutcomeRoute,\n private readonly securityTier: string,\n private readonly auto: boolean,\n private readonly now: () => number = Date.now,\n /**\n * Salt for `instructionHash`. Defaults to the real per-install id\n * ({@link installId}) in production; tests should pass a fixed string so\n * they never touch the real machine's `~/.vibgrate/install-id`.\n */\n private readonly saltValue: string = installId(),\n ) {}\n\n private envelope(runId: string): Envelope {\n return {\n schema: RUN_OUTCOME_SCHEMA,\n runId,\n ts: new Date(this.now()).toISOString(),\n repoId: this.repoId,\n gitRef: this.gitRef,\n route: this.route,\n securityTier: this.securityTier,\n };\n }\n\n /** Start recording a new run/turn. Call before the instruction is handed to the agent. */\n beginRun(runId: string, instruction: string, fromFinding?: 'upgrade' | 'fix-vuln'): void {\n this.currentRunId = runId;\n this.tallies.set(runId, { proposed: 0, approved: 0, rejected: 0, autoApproved: 0, lastVerifyOk: null });\n append(this.root, {\n ...this.envelope(runId),\n event: 'run_started',\n instructionHash: hash(this.saltValue, instruction),\n instructionKind: classifyInstructionKind(instruction, fromFinding),\n baseline: { driftScore: null, scoreMode: null, advisories: null },\n });\n }\n\n /**\n * Feed one outgoing protocol line. Transparent — never mutates or drops\n * the line; the caller still writes it to the host exactly as before.\n */\n observe(line: StreamJsonOut): void {\n const runId = this.currentRunId;\n if (!runId) return;\n const tally = this.tallies.get(runId);\n if (!tally) return;\n\n if (line.event === 'approve-request') {\n const shape = shapeOfAction(line.action);\n if (!shape) return; // run/tool — not a file edit\n tally.proposed++;\n const editId = randomUUID();\n this.pending.set(line.id, { runId, shape, proposedAt: this.now() });\n append(this.root, { ...this.envelope(runId), event: 'edit_proposed', editId, ...shape });\n // Auto-approve resolves synchronously in StreamJsonSession before any\n // host round-trip — record that decision now; no host message arrives.\n if (this.auto) {\n tally.autoApproved++;\n append(this.root, { ...this.envelope(runId), event: 'edit_decision', editId, decision: 'auto-approved', latencyMs: 0 });\n this.pending.delete(line.id);\n } else {\n // Stash the editId against the wire id so `noteDecision` can find it.\n this.editIdByApproveId.set(line.id, editId);\n }\n return;\n }\n\n if (line.event === 'event' && line.type === 'verify') {\n tally.lastVerifyOk = line.passed;\n return;\n }\n\n if (line.event === 'done') {\n this.finish(runId, tally, 'done', line.result);\n return;\n }\n if (line.event === 'error') {\n this.finish(runId, tally, 'error', null);\n }\n }\n\n private readonly editIdByApproveId = new Map<number, string>();\n\n /**\n * A real (non-auto) approve/reject arrived from the host over stdin. `id`\n * is the same numeric id `StreamJsonSession` put on the `approve-request`\n * line — the natural join key, already unique for the process lifetime.\n */\n noteDecision(approveId: number, approved: boolean): void {\n const editId = this.editIdByApproveId.get(approveId);\n const pending = this.pending.get(approveId);\n if (!editId || !pending) return;\n this.editIdByApproveId.delete(approveId);\n this.pending.delete(approveId);\n const tally = this.tallies.get(pending.runId);\n if (tally) approved ? tally.approved++ : tally.rejected++;\n append(this.root, {\n ...this.envelope(pending.runId),\n event: 'edit_decision',\n editId,\n decision: approved ? 'approved' : 'rejected',\n latencyMs: Math.max(0, this.now() - pending.proposedAt),\n });\n }\n\n /** The host disconnected / turn was cancelled mid-approval — reject what's left, no hang. */\n cancelPending(): void {\n for (const id of [...this.pending.keys()]) this.noteDecision(id, false);\n }\n\n private finish(runId: string, tally: RunTally, outcome: RunOutcome, result: AgentResult | null): void {\n append(this.root, {\n ...this.envelope(runId),\n event: 'run_completed',\n outcome,\n edits: { proposed: tally.proposed, approved: tally.approved, rejected: tally.rejected, autoApproved: tally.autoApproved },\n verify: null,\n verifyOk: tally.lastVerifyOk,\n tokens: result ? { input: result.usage.promptTokens, output: result.usage.completionTokens } : null,\n });\n this.tallies.delete(runId);\n if (this.currentRunId === runId) this.currentRunId = null;\n }\n}\n\n/** Mint a runId for a one-shot `vg code` invocation (no session). */\nexport function newOneShotRunId(): string {\n return `r${randomUUID()}`;\n}\n\n/** Mint a runId for one turn of a `--session` run. */\nexport function turnRunId(sessionId: string, turnIndex: number): string {\n return `${sessionId}#${turnIndex}`;\n}\n\nexport { repositoryIdFromRoot as runOutcomeRepoId };\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { startCodeRuntimeSession } from './chunk-E6H2F2XF.js';
|
|
2
|
+
import './chunk-V2QK3IUY.js';
|
|
3
|
+
import './chunk-5I4VSBWQ.js';
|
|
4
|
+
import './chunk-IS7VTH2Q.js';
|
|
5
|
+
import './chunk-IZDH67DX.js';
|
|
6
|
+
import './chunk-3LOWJSAF.js';
|
|
7
|
+
import './chunk-RBIRXQR6.js';
|
|
8
|
+
import './chunk-5HYCB55P.js';
|
|
9
|
+
import './chunk-J7LKEB2R.js';
|
|
10
|
+
import './chunk-SDG242R4.js';
|
|
11
|
+
import './chunk-T6DRYOMT.js';
|
|
12
|
+
import './chunk-76TDXGGF.js';
|
|
13
|
+
import './chunk-TGDHOAXX.js';
|
|
14
|
+
import './chunk-ZKNB4YH4.js';
|
|
15
|
+
import './chunk-BWPBB45M.js';
|
|
16
|
+
import './chunk-JFGYT6BI.js';
|
|
17
|
+
import './chunk-BPF3YX2U.js';
|
|
18
|
+
import './chunk-Z6ZWNWWR.js';
|
|
19
|
+
//# sourceMappingURL=runtime-session-UQ7UVAPL.js.map
|
|
20
|
+
//# sourceMappingURL=runtime-session-UQ7UVAPL.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"runtime-session-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"runtime-session-UQ7UVAPL.js"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export { commitChanges, nodeCodeFs, runCodeSession, undoChanges } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { commitChanges, nodeCodeFs, runCodeSession, undoChanges } from './chunk-WIDZ5IE7.js';
|
|
2
|
+
import './chunk-G25STLE7.js';
|
|
3
3
|
import './chunk-REIGWTTH.js';
|
|
4
|
-
import './chunk-
|
|
4
|
+
import './chunk-MPP4S4OE.js';
|
|
5
5
|
import './chunk-3LSG7Z4I.js';
|
|
6
|
-
import './chunk-
|
|
6
|
+
import './chunk-SDG242R4.js';
|
|
7
7
|
import './chunk-ZKNB4YH4.js';
|
|
8
8
|
import './chunk-BWPBB45M.js';
|
|
9
9
|
import './chunk-JFGYT6BI.js';
|
|
10
10
|
import './chunk-BPF3YX2U.js';
|
|
11
11
|
import './chunk-Z6ZWNWWR.js';
|
|
12
|
-
//# sourceMappingURL=session-
|
|
13
|
-
//# sourceMappingURL=session-
|
|
12
|
+
//# sourceMappingURL=session-MG6BJVAG.js.map
|
|
13
|
+
//# sourceMappingURL=session-MG6BJVAG.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"session-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"session-MG6BJVAG.js"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { listSessions, loadLatestSession, loadSession, newSession, recordTask, saveSession, sessionsDir, setLatestSession, summarizeSession } from './chunk-7G5S5KZN.js';
|
|
2
|
+
import './chunk-Z6ZWNWWR.js';
|
|
3
|
+
//# sourceMappingURL=session-store-SQECEXUU.js.map
|
|
4
|
+
//# sourceMappingURL=session-store-SQECEXUU.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"session-store-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"session-store-SQECEXUU.js"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { runAgent } from './chunk-
|
|
1
|
+
import { runAgent } from './chunk-IRCYOTRG.js';
|
|
2
2
|
import './chunk-543E6WDJ.js';
|
|
3
|
-
import './chunk-
|
|
3
|
+
import './chunk-G25STLE7.js';
|
|
4
4
|
import './chunk-REIGWTTH.js';
|
|
5
|
-
import './chunk-
|
|
5
|
+
import './chunk-A43I2AJ4.js';
|
|
6
6
|
import './chunk-RBIRXQR6.js';
|
|
7
7
|
import './chunk-5HYCB55P.js';
|
|
8
|
-
import './chunk-
|
|
8
|
+
import './chunk-MPP4S4OE.js';
|
|
9
9
|
import './chunk-IPICO2RV.js';
|
|
10
|
-
import './chunk-
|
|
10
|
+
import './chunk-I6RBAIS3.js';
|
|
11
11
|
import './chunk-3LSG7Z4I.js';
|
|
12
12
|
import './chunk-J7LKEB2R.js';
|
|
13
|
-
import './chunk-
|
|
13
|
+
import './chunk-SDG242R4.js';
|
|
14
14
|
import './chunk-UTNNGKKX.js';
|
|
15
15
|
import './chunk-RXP66R2E.js';
|
|
16
16
|
import './chunk-ZKNB4YH4.js';
|
|
@@ -180,5 +180,5 @@ async function runCodeStreamJson(options) {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
export { StreamJsonSession, parseHostMessage, runCodeStreamJson, runCodeStreamJsonSession };
|
|
183
|
-
//# sourceMappingURL=stream-json-
|
|
184
|
-
//# sourceMappingURL=stream-json-
|
|
183
|
+
//# sourceMappingURL=stream-json-GM44SP7L.js.map
|
|
184
|
+
//# sourceMappingURL=stream-json-GM44SP7L.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/code/stream-json.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwDO,SAAS,iBAAiB,GAAA,EAAiC;AAChE,EAAA,IAAI,GAAA;AACJ,EAAA,IAAI;AACF,IAAA,GAAA,GAAM,IAAA,CAAK,MAAM,GAAG,C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AS,OAAA,CAAQ,OAAA;AAAA,MACjB,SAAS,OAAA,CAAQ;AAAA,KAClB,CAAA;AACD,IAAA,IAAA,CAAK,EAAE,KAAA,EAAO,MAAA,EAAQ,MAAA,EAAQ,CAAA;AAC9B,IAAA,OAAO,MAAA;AAAA,EACT,SAAS,CAAA,EAAG;AACV,IAAA,IAAA,CAAK,EAAE,KAAA,EAAO,OAAA,EAAS,OAAA,EAAU,CAAA,CAAY,SAAS,CAAA;AACtD,IAAA,OAAO,IAAA;AAAA,EACT,CAAA,SAAE;AACA,IAAA,OAAA,CAAQ,aAAA,EAAc;AAAA,EACxB;AACF","file":"stream-json-CFKBL3MR.js","sourcesContent":["/**\n * Machine-readable event protocol for `vg code --stream-json` (VG-CLI-CODE §18).\n *\n * A host UI (the VS Code VG Code panel) can't drive the agent through the human\n * TTY renderer, so this exposes the agent as a line protocol: every\n * {@link AgentEvent} is emitted as one NDJSON object on stdout, and each\n * approval / user question is a round-trip — an event out, a decision/answer\n * line in. This keeps the governance gate intact across the process boundary\n * (the host's Approve/Reject and question UI fulfil the same contracts the CLI\n * would — no quick-apply back-door), while the host stays a pure relay.\n *\n * Pure over an injected `emit` + the decision channel, so the protocol is\n * unit-tested without a process, model, or socket.\n */\n\nimport { runAgent, type AgentEvent, type AgentOptions, type AgentResult } from './agent.js';\nimport type { AskUserRequest, MutatingAction } from './tools.js';\n\n/** A single line written to the host. Discriminated by `event`. */\nexport type StreamJsonOut =\n | ({ event: 'event' } & AgentEvent)\n | { event: 'approve-request'; id: number; action: MutatingAction }\n /** Clarifying question for the human — host shows a prompt and answers via stdin. */\n | { event: 'user-question'; id: number; question: string; options?: string[] }\n | { event: 'done'; result: AgentResult }\n | { event: 'error'; message: string }\n /** Session mode only: the process is up and owns this session id. */\n | { event: 'session-start'; sessionId: string; resumed: boolean }\n /** Session mode only: the turn ended; send another `submit` or `end`. */\n | { event: 'idle'; turns: number }\n /** Outcome of a checkpoint restore the host asked for. */\n | {\n event: 'checkpoint-restored';\n commit: string;\n restored: string[];\n removed: string[];\n failed: string[];\n };\n\n/**\n * A line read from the host. Approvals and answers fulfil an open round-trip;\n * `submit` starts the next turn in a session; `cancel` stops the running turn\n * without killing the process; `end` closes the session.\n */\nexport type HostMessage =\n | { kind: 'approve'; id: number; approve: boolean }\n | { kind: 'answer'; id: number; answer: string }\n | { kind: 'submit'; instruction: string }\n | { kind: 'restore'; commit: string; files: string[] }\n | { kind: 'cancel' }\n | { kind: 'end' };\n\n/**\n * Parse one host line. Returns null for malformed input or an unknown shape, so\n * a garbled line is ignored rather than taking the session down.\n */\nexport function parseHostMessage(raw: string): HostMessage | null {\n let msg: Record<string, unknown>;\n try {\n msg = JSON.parse(raw) as Record<string, unknown>;\n } catch {\n return null;\n }\n if (!msg || typeof msg !== 'object') return null;\n if (typeof msg.approveId === 'number') {\n return { kind: 'approve', id: msg.approveId, approve: !!msg.approve };\n }\n if (typeof msg.answerId === 'number') {\n return { kind: 'answer', id: msg.answerId, answer: String(msg.answer ?? '') };\n }\n if (typeof msg.submit === 'string' && msg.submit.trim()) {\n return { kind: 'submit', instruction: msg.submit.trim() };\n }\n if (\n msg.restore &&\n typeof msg.restore === 'object' &&\n typeof (msg.restore as Record<string, unknown>).commit === 'string'\n ) {\n const r = msg.restore as { commit: string; files?: unknown };\n const files = Array.isArray(r.files) ? r.files.filter((f): f is string => typeof f === 'string') : [];\n if (files.length) return { kind: 'restore', commit: r.commit, files };\n return null;\n }\n if (msg.cancel === true) return { kind: 'cancel' };\n if (msg.end === true) return { kind: 'end' };\n return null;\n}\n\n/**\n * Owns the NDJSON protocol for one run: serializes agent events, and turns each\n * approval / user question into a host round-trip via {@link submitDecision} /\n * {@link submitAnswer}. Under `auto`, approvals resolve true immediately (still\n * announced, for the log); user questions get a default \"proceed\" answer.\n */\nexport class StreamJsonSession {\n private nextId = 1;\n private readonly pendingApprove = new Map<number, (approve: boolean) => void>();\n private readonly pendingAnswer = new Map<number, (answer: string) => void>();\n /** Cancellation for the turn currently running (session mode). */\n private turnSignal: { aborted: boolean } = { aborted: false };\n\n constructor(\n private readonly emit: (line: StreamJsonOut) => void,\n private readonly auto = false,\n ) {}\n\n /** The agent's onEvent → one NDJSON line per event. */\n readonly onEvent = (e: AgentEvent): void => {\n this.emit({ event: 'event', ...e });\n };\n\n /** The agent's approval gate → an approve-request the host answers. */\n readonly approve = (action: MutatingAction): Promise<boolean> => {\n const id = this.nextId++;\n if (this.auto) {\n this.emit({ event: 'approve-request', id, action });\n return Promise.resolve(true);\n }\n return new Promise<boolean>((resolve) => {\n this.pendingApprove.set(id, resolve);\n this.emit({ event: 'approve-request', id, action });\n });\n };\n\n /** Clarifying question → user-question the host answers with free text. */\n readonly askUser = (req: AskUserRequest): Promise<string> => {\n const id = this.nextId++;\n const question = req.question.trim();\n const options = req.options?.filter(Boolean);\n if (this.auto) {\n this.emit({ event: 'user-question', id, question, options });\n return Promise.resolve(\n 'Autonomous mode: no human. Proceed with safest defaults and state assumptions.',\n );\n }\n return new Promise<string>((resolve) => {\n this.pendingAnswer.set(id, resolve);\n this.emit({ event: 'user-question', id, question, options });\n });\n };\n\n /** Host → agent: resolve a pending approval. Unknown ids are ignored. */\n submitDecision(id: number, approve: boolean): void {\n const resolve = this.pendingApprove.get(id);\n if (resolve) {\n this.pendingApprove.delete(id);\n resolve(approve);\n }\n }\n\n /** Host → agent: resolve a pending user-question. Unknown ids are ignored. */\n submitAnswer(id: number, answer: string): void {\n const resolve = this.pendingAnswer.get(id);\n if (resolve) {\n this.pendingAnswer.delete(id);\n resolve(answer ?? '');\n }\n }\n\n /** Start a turn: fresh cancellation signal, handed to the agent loop. */\n beginTurn(): { aborted: boolean } {\n this.turnSignal = { aborted: false };\n return this.turnSignal;\n }\n\n /**\n * Host → agent: stop the running turn. Sets the cooperative signal *and*\n * rejects anything the turn is blocked on, so a turn waiting at an approval\n * gate unblocks instead of hanging until the process dies.\n */\n cancelTurn(): void {\n this.turnSignal.aborted = true;\n this.cancelPending();\n }\n\n /** Reject any still-pending approvals/questions (e.g. the host disconnected). */\n cancelPending(): void {\n for (const resolve of this.pendingApprove.values()) resolve(false);\n this.pendingApprove.clear();\n for (const resolve of this.pendingAnswer.values()) resolve('');\n this.pendingAnswer.clear();\n }\n}\n\nexport interface StreamJsonOptions extends Omit<AgentOptions, 'approve' | 'onEvent' | 'askUser'> {\n emit: (line: StreamJsonOut) => void;\n /** Register the stdin decision reader; the returned session accepts decisions. */\n bindDecisions?: (session: StreamJsonSession) => void;\n}\n\n/** One turn of a session: what the host asked, and how it ended. */\nexport interface StreamJsonTurn {\n instruction: string;\n result: AgentResult | null;\n}\n\nexport interface StreamJsonSessionRunOptions {\n emit: (line: StreamJsonOut) => void;\n /** Bound once for the whole session, not per turn. */\n bindDecisions?: (session: StreamJsonSession) => void;\n auto?: boolean;\n sessionId: string;\n /** True when this session was reloaded from disk (`--continue`). */\n resumed: boolean;\n /** Instruction for the first turn. Omit to wait for the host's first `submit`. */\n instruction?: string;\n /** Await the host's next instruction; resolve null to end the session. */\n nextTurn: () => Promise<string | null>;\n /**\n * Run one turn. Injected so the heavy agent wiring (graph, providers, MCP,\n * sandbox) is built once by the caller and reused across turns — the whole\n * point of session mode.\n */\n runTurn: (turn: {\n instruction: string;\n priorSummary?: string;\n signal: { aborted: boolean };\n session: StreamJsonSession;\n }) => Promise<AgentResult>;\n /**\n * Record a finished turn. Returns the recap to seed the next turn, so\n * continuity is the caller's policy (session store, summarizer) not ours.\n */\n onTurnEnd?: (turn: StreamJsonTurn) => string | undefined;\n}\n\n/**\n * Session mode for `vg code --stream-json --session`: hold the process open and\n * run turn after turn against warm state, instead of paying a cold start (graph\n * load, overlay rebuild, MCP connect, model warm-up) on every message.\n *\n * Each turn still emits exactly the frames a single-shot run does, so a host\n * that already speaks the one-shot protocol only needs to learn `idle`. A turn\n * that throws is reported and the session stays up — one bad task should not\n * cost the user their conversation.\n */\nexport async function runCodeStreamJsonSession(\n options: StreamJsonSessionRunOptions,\n): Promise<StreamJsonTurn[]> {\n const { emit, bindDecisions, auto, sessionId, resumed, nextTurn, runTurn, onTurnEnd } = options;\n const session = new StreamJsonSession(emit, !!auto);\n bindDecisions?.(session);\n emit({ event: 'session-start', sessionId, resumed });\n\n const turns: StreamJsonTurn[] = [];\n let priorSummary: string | undefined;\n let instruction = options.instruction?.trim() || (await nextTurn());\n\n while (instruction) {\n const signal = session.beginTurn();\n let turn: StreamJsonTurn;\n try {\n const result = await runTurn({ instruction, priorSummary, signal, session });\n emit({ event: 'done', result });\n turn = { instruction, result };\n } catch (e) {\n emit({ event: 'error', message: (e as Error).message });\n turn = { instruction, result: null };\n } finally {\n session.cancelPending();\n }\n turns.push(turn);\n priorSummary = onTurnEnd?.(turn) ?? priorSummary;\n emit({ event: 'idle', turns: turns.length });\n instruction = await nextTurn();\n }\n return turns;\n}\n\n/** Run the agent under the NDJSON protocol; always emits a terminal `done`/`error`. */\nexport async function runCodeStreamJson(options: StreamJsonOptions): Promise<AgentResult | null> {\n const { emit, bindDecisions, auto, ...agentOptions } = options;\n const session = new StreamJsonSession(emit, !!auto);\n bindDecisions?.(session);\n try {\n const result = await runAgent({\n ...agentOptions,\n auto,\n approve: session.approve,\n askUser: session.askUser,\n onEvent: session.onEvent,\n });\n emit({ event: 'done', result });\n return result;\n } catch (e) {\n emit({ event: 'error', message: (e as Error).message });\n return null;\n } finally {\n session.cancelPending();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/code/stream-json.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwDO,SAAS,iBAAiB,GAAA,EAAiC;AAChE,EAAA,IAAI,GAAA;AACJ,EAAA,IAAI;AACF,IAAA,GAAA,GAAM,IAAA,CAAK,MAAM,GAAG,CAAA;AAAA,EACtB,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,IAAI,CAAC,GAAA,IAAO,OAAO,GAAA,KAAQ,UAAU,OAAO,IAAA;AAC5C,EAAA,IAAI,OAAO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AAA;AAAA,EACT,SAAS,CAAA,EAAG;AACV,IAAA,IAAA,CAAK,EAAE,KAAA,EAAO,OAAA,EAAS,OAAA,EAAU,CAAA,CAAY,SAAS,CAAA;AACtD,IAAA,OAAO,IAAA;AAAA,EACT,CAAA,SAAE;AACA,IAAA,OAAA,CAAQ,aAAA,EAAc;AAAA,EACxB;AACF","file":"stream-json-GM44SP7L.js","sourcesContent":["/**\n * Machine-readable event protocol for `vg code --stream-json` (VG-CLI-CODE §18).\n *\n * A host UI (the VS Code VG Code panel) can't drive the agent through the human\n * TTY renderer, so this exposes the agent as a line protocol: every\n * {@link AgentEvent} is emitted as one NDJSON object on stdout, and each\n * approval / user question is a round-trip — an event out, a decision/answer\n * line in. This keeps the governance gate intact across the process boundary\n * (the host's Approve/Reject and question UI fulfil the same contracts the CLI\n * would — no quick-apply back-door), while the host stays a pure relay.\n *\n * Pure over an injected `emit` + the decision channel, so the protocol is\n * unit-tested without a process, model, or socket.\n */\n\nimport { runAgent, type AgentEvent, type AgentOptions, type AgentResult } from './agent.js';\nimport type { AskUserRequest, MutatingAction } from './tools.js';\n\n/** A single line written to the host. Discriminated by `event`. */\nexport type StreamJsonOut =\n | ({ event: 'event' } & AgentEvent)\n | { event: 'approve-request'; id: number; action: MutatingAction }\n /** Clarifying question for the human — host shows a prompt and answers via stdin. */\n | { event: 'user-question'; id: number; question: string; options?: string[] }\n | { event: 'done'; result: AgentResult }\n | { event: 'error'; message: string }\n /** Session mode only: the process is up and owns this session id. */\n | { event: 'session-start'; sessionId: string; resumed: boolean }\n /** Session mode only: the turn ended; send another `submit` or `end`. */\n | { event: 'idle'; turns: number }\n /** Outcome of a checkpoint restore the host asked for. */\n | {\n event: 'checkpoint-restored';\n commit: string;\n restored: string[];\n removed: string[];\n failed: string[];\n };\n\n/**\n * A line read from the host. Approvals and answers fulfil an open round-trip;\n * `submit` starts the next turn in a session; `cancel` stops the running turn\n * without killing the process; `end` closes the session.\n */\nexport type HostMessage =\n | { kind: 'approve'; id: number; approve: boolean }\n | { kind: 'answer'; id: number; answer: string }\n | { kind: 'submit'; instruction: string }\n | { kind: 'restore'; commit: string; files: string[] }\n | { kind: 'cancel' }\n | { kind: 'end' };\n\n/**\n * Parse one host line. Returns null for malformed input or an unknown shape, so\n * a garbled line is ignored rather than taking the session down.\n */\nexport function parseHostMessage(raw: string): HostMessage | null {\n let msg: Record<string, unknown>;\n try {\n msg = JSON.parse(raw) as Record<string, unknown>;\n } catch {\n return null;\n }\n if (!msg || typeof msg !== 'object') return null;\n if (typeof msg.approveId === 'number') {\n return { kind: 'approve', id: msg.approveId, approve: !!msg.approve };\n }\n if (typeof msg.answerId === 'number') {\n return { kind: 'answer', id: msg.answerId, answer: String(msg.answer ?? '') };\n }\n if (typeof msg.submit === 'string' && msg.submit.trim()) {\n return { kind: 'submit', instruction: msg.submit.trim() };\n }\n if (\n msg.restore &&\n typeof msg.restore === 'object' &&\n typeof (msg.restore as Record<string, unknown>).commit === 'string'\n ) {\n const r = msg.restore as { commit: string; files?: unknown };\n const files = Array.isArray(r.files) ? r.files.filter((f): f is string => typeof f === 'string') : [];\n if (files.length) return { kind: 'restore', commit: r.commit, files };\n return null;\n }\n if (msg.cancel === true) return { kind: 'cancel' };\n if (msg.end === true) return { kind: 'end' };\n return null;\n}\n\n/**\n * Owns the NDJSON protocol for one run: serializes agent events, and turns each\n * approval / user question into a host round-trip via {@link submitDecision} /\n * {@link submitAnswer}. Under `auto`, approvals resolve true immediately (still\n * announced, for the log); user questions get a default \"proceed\" answer.\n */\nexport class StreamJsonSession {\n private nextId = 1;\n private readonly pendingApprove = new Map<number, (approve: boolean) => void>();\n private readonly pendingAnswer = new Map<number, (answer: string) => void>();\n /** Cancellation for the turn currently running (session mode). */\n private turnSignal: { aborted: boolean } = { aborted: false };\n\n constructor(\n private readonly emit: (line: StreamJsonOut) => void,\n private readonly auto = false,\n ) {}\n\n /** The agent's onEvent → one NDJSON line per event. */\n readonly onEvent = (e: AgentEvent): void => {\n this.emit({ event: 'event', ...e });\n };\n\n /** The agent's approval gate → an approve-request the host answers. */\n readonly approve = (action: MutatingAction): Promise<boolean> => {\n const id = this.nextId++;\n if (this.auto) {\n this.emit({ event: 'approve-request', id, action });\n return Promise.resolve(true);\n }\n return new Promise<boolean>((resolve) => {\n this.pendingApprove.set(id, resolve);\n this.emit({ event: 'approve-request', id, action });\n });\n };\n\n /** Clarifying question → user-question the host answers with free text. */\n readonly askUser = (req: AskUserRequest): Promise<string> => {\n const id = this.nextId++;\n const question = req.question.trim();\n const options = req.options?.filter(Boolean);\n if (this.auto) {\n this.emit({ event: 'user-question', id, question, options });\n return Promise.resolve(\n 'Autonomous mode: no human. Proceed with safest defaults and state assumptions.',\n );\n }\n return new Promise<string>((resolve) => {\n this.pendingAnswer.set(id, resolve);\n this.emit({ event: 'user-question', id, question, options });\n });\n };\n\n /** Host → agent: resolve a pending approval. Unknown ids are ignored. */\n submitDecision(id: number, approve: boolean): void {\n const resolve = this.pendingApprove.get(id);\n if (resolve) {\n this.pendingApprove.delete(id);\n resolve(approve);\n }\n }\n\n /** Host → agent: resolve a pending user-question. Unknown ids are ignored. */\n submitAnswer(id: number, answer: string): void {\n const resolve = this.pendingAnswer.get(id);\n if (resolve) {\n this.pendingAnswer.delete(id);\n resolve(answer ?? '');\n }\n }\n\n /** Start a turn: fresh cancellation signal, handed to the agent loop. */\n beginTurn(): { aborted: boolean } {\n this.turnSignal = { aborted: false };\n return this.turnSignal;\n }\n\n /**\n * Host → agent: stop the running turn. Sets the cooperative signal *and*\n * rejects anything the turn is blocked on, so a turn waiting at an approval\n * gate unblocks instead of hanging until the process dies.\n */\n cancelTurn(): void {\n this.turnSignal.aborted = true;\n this.cancelPending();\n }\n\n /** Reject any still-pending approvals/questions (e.g. the host disconnected). */\n cancelPending(): void {\n for (const resolve of this.pendingApprove.values()) resolve(false);\n this.pendingApprove.clear();\n for (const resolve of this.pendingAnswer.values()) resolve('');\n this.pendingAnswer.clear();\n }\n}\n\nexport interface StreamJsonOptions extends Omit<AgentOptions, 'approve' | 'onEvent' | 'askUser'> {\n emit: (line: StreamJsonOut) => void;\n /** Register the stdin decision reader; the returned session accepts decisions. */\n bindDecisions?: (session: StreamJsonSession) => void;\n}\n\n/** One turn of a session: what the host asked, and how it ended. */\nexport interface StreamJsonTurn {\n instruction: string;\n result: AgentResult | null;\n}\n\nexport interface StreamJsonSessionRunOptions {\n emit: (line: StreamJsonOut) => void;\n /** Bound once for the whole session, not per turn. */\n bindDecisions?: (session: StreamJsonSession) => void;\n auto?: boolean;\n sessionId: string;\n /** True when this session was reloaded from disk (`--continue`). */\n resumed: boolean;\n /** Instruction for the first turn. Omit to wait for the host's first `submit`. */\n instruction?: string;\n /** Await the host's next instruction; resolve null to end the session. */\n nextTurn: () => Promise<string | null>;\n /**\n * Run one turn. Injected so the heavy agent wiring (graph, providers, MCP,\n * sandbox) is built once by the caller and reused across turns — the whole\n * point of session mode.\n */\n runTurn: (turn: {\n instruction: string;\n priorSummary?: string;\n signal: { aborted: boolean };\n session: StreamJsonSession;\n }) => Promise<AgentResult>;\n /**\n * Record a finished turn. Returns the recap to seed the next turn, so\n * continuity is the caller's policy (session store, summarizer) not ours.\n */\n onTurnEnd?: (turn: StreamJsonTurn) => string | undefined;\n}\n\n/**\n * Session mode for `vg code --stream-json --session`: hold the process open and\n * run turn after turn against warm state, instead of paying a cold start (graph\n * load, overlay rebuild, MCP connect, model warm-up) on every message.\n *\n * Each turn still emits exactly the frames a single-shot run does, so a host\n * that already speaks the one-shot protocol only needs to learn `idle`. A turn\n * that throws is reported and the session stays up — one bad task should not\n * cost the user their conversation.\n */\nexport async function runCodeStreamJsonSession(\n options: StreamJsonSessionRunOptions,\n): Promise<StreamJsonTurn[]> {\n const { emit, bindDecisions, auto, sessionId, resumed, nextTurn, runTurn, onTurnEnd } = options;\n const session = new StreamJsonSession(emit, !!auto);\n bindDecisions?.(session);\n emit({ event: 'session-start', sessionId, resumed });\n\n const turns: StreamJsonTurn[] = [];\n let priorSummary: string | undefined;\n let instruction = options.instruction?.trim() || (await nextTurn());\n\n while (instruction) {\n const signal = session.beginTurn();\n let turn: StreamJsonTurn;\n try {\n const result = await runTurn({ instruction, priorSummary, signal, session });\n emit({ event: 'done', result });\n turn = { instruction, result };\n } catch (e) {\n emit({ event: 'error', message: (e as Error).message });\n turn = { instruction, result: null };\n } finally {\n session.cancelPending();\n }\n turns.push(turn);\n priorSummary = onTurnEnd?.(turn) ?? priorSummary;\n emit({ event: 'idle', turns: turns.length });\n instruction = await nextTurn();\n }\n return turns;\n}\n\n/** Run the agent under the NDJSON protocol; always emits a terminal `done`/`error`. */\nexport async function runCodeStreamJson(options: StreamJsonOptions): Promise<AgentResult | null> {\n const { emit, bindDecisions, auto, ...agentOptions } = options;\n const session = new StreamJsonSession(emit, !!auto);\n bindDecisions?.(session);\n try {\n const result = await runAgent({\n ...agentOptions,\n auto,\n approve: session.approve,\n askUser: session.askUser,\n onEvent: session.onEvent,\n });\n emit({ event: 'done', result });\n return result;\n } catch (e) {\n emit({ event: 'error', message: (e as Error).message });\n return null;\n } finally {\n session.cancelPending();\n }\n}\n"]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { TOOLS } from './chunk-
|
|
1
|
+
import { TOOLS } from './chunk-7PVCHLR2.js';
|
|
2
2
|
import './chunk-XRN7DQGR.js';
|
|
3
3
|
import './chunk-HTLDXEHW.js';
|
|
4
4
|
import './chunk-CRAMOEBE.js';
|
|
5
|
-
import './chunk-
|
|
5
|
+
import './chunk-I6RBAIS3.js';
|
|
6
6
|
import './chunk-J7LKEB2R.js';
|
|
7
|
-
import './chunk-
|
|
7
|
+
import './chunk-SDG242R4.js';
|
|
8
8
|
import './chunk-CQDUBAQY.js';
|
|
9
9
|
import './chunk-OV4KGXPD.js';
|
|
10
10
|
import './chunk-RXP66R2E.js';
|
|
11
|
-
import './chunk-
|
|
11
|
+
import './chunk-TGDHOAXX.js';
|
|
12
12
|
import './chunk-ZKNB4YH4.js';
|
|
13
13
|
import './chunk-BWPBB45M.js';
|
|
14
14
|
import './chunk-JFGYT6BI.js';
|
|
@@ -73,5 +73,5 @@ function vgMcpToolNames() {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
export { VG_MCP_SERVER_ID, createVgBuiltinMcpTools, mergeExternalToolsets, vgMcpToolNames };
|
|
76
|
-
//# sourceMappingURL=vg-mcp-bridge-
|
|
77
|
-
//# sourceMappingURL=vg-mcp-bridge-
|
|
76
|
+
//# sourceMappingURL=vg-mcp-bridge-3WFC7LGE.js.map
|
|
77
|
+
//# sourceMappingURL=vg-mcp-bridge-3WFC7LGE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/code/vg-mcp-bridge.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAmBO,IAAM,gBAAA,GAAmB;AAChC,IAAM,EAAA,GAAK,QAAQ,gBAAgB,CAAA,EAAA,CAAA;AAiB5B,SAAS,wBAAwB,IAAA,EAA4C;AAClF,EAAA,MAAM,MAAA,uBAAa,GAAA,EAAoB;AACvC,EAAA,KAAA,MAAW,CAAA,IAAK,KAAA,EAAO,MAAA,CAAO,GAAA,CAAI,CAAA,EAAG,EAAE,CAAA,EAAG,CAAA,CAAE,IAAI,CAAA,CAAA,EAAI,CAAC,CAAA;AAErD,EAAA,MAAM,KAAA,GAAoB,KAAA,CAAM,GAAA,CAAI,CAAC,CAAA,MAAO;AAAA,IAC1C,IAAA,EAAM,CAAA,EAAG,EAAE,CAAA,EAAG,EAAE,IAAI,CAAA,CAAA;AAAA,IACpB,WAAA,EAAa,CAAA,CAAA,EAAI,gBAAgB,CAAA,EAAA,EAAK,EAAE,WAAW,CAAA,CAAA;AAAA,IACnD,UAAA,EAAY,CAAA,CAAE,WAAA,IAAe,OAAO,EAAE,WAAA,KAAgB,QAAA,GAAW,CAAA,CAAE,WAAA,GAAc,EAAE,IAAA,EAAM,QAAA,EAAU,UAAA,EAAY,EAAC;AAAE,GACpH,CAAE,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A,MACtE;AACA,MAAA,OAAO,EAAE,OAAA,EAAS,CAAA,sBAAA,EAAyB,KAAK,IAAI,CAAA,CAAA,EAAI,SAAS,KAAA,EAAM;AAAA,IACzE;AAAA,GACF;AACF;AAGO,SAAS,cAAA,GAA2B;AACzC,EAAA,OAAO,KAAA,CAAM,IAAI,CAAC,CAAA,KAAM,GAAG,EAAE,CAAA,EAAG,CAAA,CAAE,IAAI,CAAA,CAAE,CAAA;AAC1C","file":"vg-mcp-bridge-3WFC7LGE.js","sourcesContent":["/**\n * Always-on bridge from local `vg serve` (Vibgrate AI Context) tools into the\n * VG Code agent tool list.\n *\n * External project MCP servers (`.mcp.json`, etc.) remain optional. The tools\n * shipped by the installed `vg` CLI — `search_symbols`, `query_graph`,\n * `impact_of`, `library_docs`, … — are available on every run without spawning\n * a separate MCP process: same handlers as stdio `vg serve`, in-process over\n * the session graph.\n *\n * Namespaced as `mcp__vibgrate__<tool>` so they sit next to third-party\n * `mcp__<server>__*` tools without collisions.\n */\n\nimport { TOOLS, type VgTool } from '../mcp/tools.js';\nimport type { VgGraph } from '../schema.js';\nimport type { ToolCall, ToolSpec } from './types.js';\nimport type { ToolResult } from './tools.js';\n\nexport const VG_MCP_SERVER_ID = 'vibgrate' as const;\nconst NS = `mcp__${VG_MCP_SERVER_ID}__`;\n\nexport type ExternalToolset = {\n specs: ToolSpec[];\n owns: (name: string) => boolean;\n execute: (call: ToolCall, live?: { graph: VgGraph }) => Promise<ToolResult>;\n};\n\nexport interface VgBuiltinMcpOptions {\n /** Live graph accessor (session overlay may refresh symbols mid-run). */\n getGraph: () => VgGraph;\n root: string;\n /** Air-gap: no network in library/docs/embedder paths. */\n local?: boolean;\n}\n\n/** In-process toolset matching the local `vg serve` MCP surface. */\nexport function createVgBuiltinMcpTools(opts: VgBuiltinMcpOptions): ExternalToolset {\n const byName = new Map<string, VgTool>();\n for (const t of TOOLS) byName.set(`${NS}${t.name}`, t);\n\n const specs: ToolSpec[] = TOOLS.map((t) => ({\n name: `${NS}${t.name}`,\n description: `[${VG_MCP_SERVER_ID}] ${t.description}`,\n parameters: t.inputSchema && typeof t.inputSchema === 'object' ? t.inputSchema : { type: 'object', properties: {} },\n })).sort((a, b) => a.name.localeCompare(b.name));\n\n return {\n specs,\n owns: (name) => byName.has(name),\n async execute(call, live) {\n const tool = byName.get(call.name);\n if (!tool) return { content: `unknown MCP tool ${call.name}`, mutated: false };\n try {\n const graph = live?.graph ?? opts.getGraph();\n const raw = await tool.handler(graph, call.arguments ?? {}, {\n root: opts.root,\n local: opts.local,\n dedup: false,\n });\n const text = typeof raw === 'string' ? raw : JSON.stringify(raw, null, 2);\n return { content: text.slice(0, 12_000), mutated: false };\n } catch (e) {\n return { content: `MCP tool ${call.name} failed: ${(e as Error).message}`, mutated: false };\n }\n },\n };\n}\n\n/** Merge toolsets; later sets win on name clashes. */\nexport function mergeExternalToolsets(...sets: Array<ExternalToolset | undefined | null>): ExternalToolset | undefined {\n const active = sets.filter((s): s is ExternalToolset => !!s && s.specs.length > 0);\n if (active.length === 0) return undefined;\n if (active.length === 1) return active[0];\n\n const byName = new Map<string, { set: ExternalToolset; spec: ToolSpec }>();\n for (const set of active) {\n for (const spec of set.specs) byName.set(spec.name, { set, spec });\n }\n const specs = [...byName.values()].map((v) => v.spec).sort((a, b) => a.name.localeCompare(b.name));\n return {\n specs,\n owns: (name) => active.some((s) => s.owns(name)),\n async execute(call, live) {\n for (let i = active.length - 1; i >= 0; i--) {\n if (active[i]!.owns(call.name)) return active[i]!.execute(call, live);\n }\n return { content: `unknown external tool ${call.name}`, mutated: false };\n },\n };\n}\n\n/** Namespaced vibgrate tool names for tests / prompts. */\nexport function vgMcpToolNames(): string[] {\n return TOOLS.map((t) => `${NS}${t.name}`);\n}\n"]}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export { ActiveGraphCache, BranchGraphSession, DEFAULT_ACTIVE_GRAPH_IDLE_MS, VGD_PROTOCOL_VERSION, WorkspaceRegistry, parseRequest, startVgdServer } from './chunk-
|
|
1
|
+
export { ActiveGraphCache, BranchGraphSession, DEFAULT_ACTIVE_GRAPH_IDLE_MS, VGD_PROTOCOL_VERSION, WorkspaceRegistry, parseRequest, startVgdServer } from './chunk-V2QK3IUY.js';
|
|
2
2
|
export { FEDERATION_SCHEMA_VERSION, federationFromWorkspaceRoots, federationPath, highConfidenceBridges, loadFederation, loadOrDiscoverFederation, writeFederationFile } from './chunk-5I4VSBWQ.js';
|
|
3
3
|
export { createHostExecutionEnv, detectSandboxCapabilities, detectSecurityCapabilities, firejailArgv, resolveExecutionEnv, selectSandboxBackend } from './chunk-IS7VTH2Q.js';
|
|
4
4
|
export { MODEL_EXECUTION_PROFILE_SCHEMA_VERSION, defaultModelExecutionProfile, mergeModelExecutionProfile, resolveModelExecutionProfile } from './chunk-IZDH67DX.js';
|
|
5
|
-
import './chunk-
|
|
5
|
+
import './chunk-3LOWJSAF.js';
|
|
6
6
|
export { vgdIsRunning, vgdPidPath, vgdRequest, vgdSocketPath } from './chunk-RBIRXQR6.js';
|
|
7
7
|
import './chunk-5HYCB55P.js';
|
|
8
8
|
import './chunk-J7LKEB2R.js';
|
|
9
|
-
import './chunk-
|
|
10
|
-
import './chunk-
|
|
11
|
-
import './chunk-
|
|
12
|
-
import './chunk-
|
|
9
|
+
import './chunk-SDG242R4.js';
|
|
10
|
+
import './chunk-T6DRYOMT.js';
|
|
11
|
+
import './chunk-76TDXGGF.js';
|
|
12
|
+
import './chunk-TGDHOAXX.js';
|
|
13
13
|
import './chunk-ZKNB4YH4.js';
|
|
14
14
|
import './chunk-BWPBB45M.js';
|
|
15
15
|
import './chunk-JFGYT6BI.js';
|
|
16
16
|
export { activeGraphSlotKey, branchGraphSnapshotId, detectGitRef } from './chunk-BPF3YX2U.js';
|
|
17
17
|
import './chunk-Z6ZWNWWR.js';
|
|
18
|
-
//# sourceMappingURL=vgd-
|
|
19
|
-
//# sourceMappingURL=vgd-
|
|
18
|
+
//# sourceMappingURL=vgd-ZUSBEVUL.js.map
|
|
19
|
+
//# sourceMappingURL=vgd-ZUSBEVUL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"vgd-ZUSBEVUL.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibgrate/cli",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.801.1",
|
|
4
4
|
"description": "vg — local codebase intelligence CLI + MCP server for AI coding agents: deterministic code graph, drift reporting, and version-correct library docs (Apache-2.0)",
|
|
5
5
|
"//mcpName": "Official MCP registry ownership proof: the registry fetches the published npm package and requires this field to match the com.vibgrate/ai-context server entry (see docs/marketing/mcp-registry/README.md). Must ship in the published @vibgrate/cli package.json.",
|
|
6
6
|
"mcpName": "com.vibgrate/ai-context",
|
|
@@ -55,9 +55,11 @@
|
|
|
55
55
|
"bench:literal": "tsx bench/literal-search.bench.ts",
|
|
56
56
|
"bench:locate": "tsx bench/locate-quality.bench.ts",
|
|
57
57
|
"bench:semantic-ask": "tsx bench/semantic-ask.bench.ts",
|
|
58
|
+
"bench:ask": "tsx bench/ask-quality.bench.ts",
|
|
59
|
+
"bench:repos": "tsx bench/repo-harness/run.mjs",
|
|
58
60
|
"bench:lib-docs": "tsx bench/lib-docs-quality.bench.ts",
|
|
59
61
|
"bench:di": "tsx bench/di-quality.bench.ts",
|
|
60
|
-
"bench:layer-a": "pnpm run bench:locate && pnpm run bench:semantic-ask && pnpm run bench:lib-docs"
|
|
62
|
+
"bench:layer-a": "pnpm run bench:locate && pnpm run bench:semantic-ask && pnpm run bench:ask && pnpm run bench:lib-docs"
|
|
61
63
|
},
|
|
62
64
|
"keywords": [
|
|
63
65
|
"code-graph",
|