@pellux/goodvibes-agent 1.0.3 → 1.0.4
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/CHANGELOG.md +6 -0
- package/README.md +2 -2
- package/dist/package/main.js +378 -92
- package/docs/README.md +2 -2
- package/docs/getting-started.md +2 -2
- package/docs/tools-and-commands.md +5 -3
- package/package.json +1 -1
- package/src/tools/agent-harness-keybinding-metadata.ts +262 -0
- package/src/tools/agent-harness-tool.ts +51 -50
- package/src/version.ts +1 -1
package/dist/package/main.js
CHANGED
|
@@ -816566,7 +816566,7 @@ var createStyledCell = (char, overrides = {}) => ({
|
|
|
816566
816566
|
// src/version.ts
|
|
816567
816567
|
import { readFileSync } from "fs";
|
|
816568
816568
|
import { join } from "path";
|
|
816569
|
-
var _version = "1.0.
|
|
816569
|
+
var _version = "1.0.4";
|
|
816570
816570
|
var _sdkVersion = "0.33.35";
|
|
816571
816571
|
try {
|
|
816572
816572
|
const pkg = JSON.parse(readFileSync(join(import.meta.dir, "..", "package.json"), "utf-8"));
|
|
@@ -821197,7 +821197,7 @@ var INBOUND_EVENT_SURFACE_KINDS = new Set([
|
|
|
821197
821197
|
]);
|
|
821198
821198
|
// src/runtime/onboarding/apply.ts
|
|
821199
821199
|
init_config8();
|
|
821200
|
-
import { existsSync as
|
|
821200
|
+
import { existsSync as existsSync85, readFileSync as readFileSync91, rmSync as rmSync10 } from "fs";
|
|
821201
821201
|
|
|
821202
821202
|
// src/agent/runtime-profile.ts
|
|
821203
821203
|
import { existsSync as existsSync43, mkdirSync as mkdirSync32, readFileSync as readFileSync48, readdirSync as readdirSync15, rmSync as rmSync5, statSync as statSync13, writeFileSync as writeFileSync29 } from "fs";
|
|
@@ -879718,7 +879718,19 @@ function describeHarnessCliCommand(args2) {
|
|
|
879718
879718
|
};
|
|
879719
879719
|
}
|
|
879720
879720
|
|
|
879721
|
-
// src/tools/agent-harness-
|
|
879721
|
+
// src/tools/agent-harness-keybinding-metadata.ts
|
|
879722
|
+
import { existsSync as existsSync82, mkdirSync as mkdirSync67, readFileSync as readFileSync89, writeFileSync as writeFileSync58 } from "fs";
|
|
879723
|
+
import { dirname as dirname66 } from "path";
|
|
879724
|
+
var FIXED_SHORTCUTS = [
|
|
879725
|
+
{ key: "Enter", description: "Send prompt" },
|
|
879726
|
+
{ key: "Shift+Enter / Ctrl+J", description: "Insert newline" },
|
|
879727
|
+
{ key: "Up / Down", description: "Navigate input history, lists, and scrollable overlays" },
|
|
879728
|
+
{ key: "Tab", description: "Autocomplete slash command or file mention" },
|
|
879729
|
+
{ key: "Esc", description: "Close overlays, pickers, and transient input modes" },
|
|
879730
|
+
{ key: "? / F1", description: "Toggle help overlay" },
|
|
879731
|
+
{ key: "F2 / /shortcuts", description: "Open keyboard shortcut reference" },
|
|
879732
|
+
{ key: "/keybindings", description: "List configurable keybindings and config path" }
|
|
879733
|
+
];
|
|
879722
879734
|
function readString51(value) {
|
|
879723
879735
|
return typeof value === "string" ? value.trim() : "";
|
|
879724
879736
|
}
|
|
@@ -879728,6 +879740,237 @@ function readLimit6(value, fallback) {
|
|
|
879728
879740
|
return fallback;
|
|
879729
879741
|
return Math.max(1, Math.min(500, Math.trunc(parsed)));
|
|
879730
879742
|
}
|
|
879743
|
+
function readFieldMap(value) {
|
|
879744
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
879745
|
+
return {};
|
|
879746
|
+
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, typeof entry === "string" ? entry : String(entry)]));
|
|
879747
|
+
}
|
|
879748
|
+
function requireKeybindingsManager2(context) {
|
|
879749
|
+
const manager5 = context.workspace.keybindingsManager;
|
|
879750
|
+
if (!manager5)
|
|
879751
|
+
throw new Error("workspace.keybindingsManager is unavailable in this Agent runtime");
|
|
879752
|
+
return manager5;
|
|
879753
|
+
}
|
|
879754
|
+
function isKeyAction2(action2) {
|
|
879755
|
+
return Object.hasOwn(ACTION_DESCRIPTIONS, action2);
|
|
879756
|
+
}
|
|
879757
|
+
function actionFromArgs(args2) {
|
|
879758
|
+
const action2 = readString51(args2.actionId || args2.key || args2.query);
|
|
879759
|
+
return action2 && isKeyAction2(action2) ? action2 : null;
|
|
879760
|
+
}
|
|
879761
|
+
function readBoolean15(value) {
|
|
879762
|
+
if (typeof value === "boolean")
|
|
879763
|
+
return value;
|
|
879764
|
+
if (typeof value !== "string")
|
|
879765
|
+
return;
|
|
879766
|
+
const normalized = value.trim().toLowerCase();
|
|
879767
|
+
if (["true", "yes", "y", "1", "on"].includes(normalized))
|
|
879768
|
+
return true;
|
|
879769
|
+
if (["false", "no", "n", "0", "off"].includes(normalized))
|
|
879770
|
+
return false;
|
|
879771
|
+
return;
|
|
879772
|
+
}
|
|
879773
|
+
function normalizeCombo(value) {
|
|
879774
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
879775
|
+
return null;
|
|
879776
|
+
const raw = value;
|
|
879777
|
+
const key = readString51(raw.key);
|
|
879778
|
+
if (!key)
|
|
879779
|
+
return null;
|
|
879780
|
+
const combo = { key };
|
|
879781
|
+
const ctrl = readBoolean15(raw.ctrl);
|
|
879782
|
+
const shift = readBoolean15(raw.shift);
|
|
879783
|
+
const alt = readBoolean15(raw.alt);
|
|
879784
|
+
if (ctrl !== undefined)
|
|
879785
|
+
combo.ctrl = ctrl;
|
|
879786
|
+
if (shift !== undefined)
|
|
879787
|
+
combo.shift = shift;
|
|
879788
|
+
if (alt !== undefined)
|
|
879789
|
+
combo.alt = alt;
|
|
879790
|
+
return combo;
|
|
879791
|
+
}
|
|
879792
|
+
function parseComboLabel(value) {
|
|
879793
|
+
const parts2 = value.split("+").map((part) => part.trim()).filter(Boolean);
|
|
879794
|
+
if (parts2.length === 0)
|
|
879795
|
+
return null;
|
|
879796
|
+
const key = parts2.at(-1);
|
|
879797
|
+
if (!key)
|
|
879798
|
+
return null;
|
|
879799
|
+
const combo = { key: key.length === 1 ? key.toLowerCase() : key.toLowerCase() };
|
|
879800
|
+
for (const part of parts2.slice(0, -1)) {
|
|
879801
|
+
const normalized = part.toLowerCase();
|
|
879802
|
+
if (normalized === "ctrl" || normalized === "control")
|
|
879803
|
+
combo.ctrl = true;
|
|
879804
|
+
else if (normalized === "shift")
|
|
879805
|
+
combo.shift = true;
|
|
879806
|
+
else if (normalized === "alt" || normalized === "option")
|
|
879807
|
+
combo.alt = true;
|
|
879808
|
+
else
|
|
879809
|
+
return null;
|
|
879810
|
+
}
|
|
879811
|
+
return combo;
|
|
879812
|
+
}
|
|
879813
|
+
function combosFromArgs(args2) {
|
|
879814
|
+
if (Array.isArray(args2.combos)) {
|
|
879815
|
+
const combos = args2.combos.map(normalizeCombo);
|
|
879816
|
+
if (combos.every((combo2) => combo2 !== null))
|
|
879817
|
+
return combos;
|
|
879818
|
+
throw new Error("set_keybinding combos must be objects with key and optional boolean ctrl/shift/alt fields.");
|
|
879819
|
+
}
|
|
879820
|
+
const combo = normalizeCombo(args2.combo);
|
|
879821
|
+
if (combo)
|
|
879822
|
+
return [combo];
|
|
879823
|
+
const fields = readFieldMap(args2.fields);
|
|
879824
|
+
const fieldCombo = normalizeCombo(fields);
|
|
879825
|
+
if (fieldCombo)
|
|
879826
|
+
return [fieldCombo];
|
|
879827
|
+
const labelCombo = parseComboLabel(readString51(args2.value));
|
|
879828
|
+
if (labelCombo)
|
|
879829
|
+
return [labelCombo];
|
|
879830
|
+
throw new Error('set_keybinding requires combo, combos, fields.key, or a value such as "Ctrl+G".');
|
|
879831
|
+
}
|
|
879832
|
+
function comboFingerprint(combo) {
|
|
879833
|
+
return `${combo.key}:${combo.ctrl ? 1 : 0}:${combo.shift ? 1 : 0}:${combo.alt ? 1 : 0}`;
|
|
879834
|
+
}
|
|
879835
|
+
function combosEqual(left, right) {
|
|
879836
|
+
if (left.length !== right.length)
|
|
879837
|
+
return false;
|
|
879838
|
+
return left.every((combo, index) => comboFingerprint(combo) === comboFingerprint(right[index]));
|
|
879839
|
+
}
|
|
879840
|
+
function describeCombo(manager5, combo) {
|
|
879841
|
+
return {
|
|
879842
|
+
key: combo.key,
|
|
879843
|
+
ctrl: combo.ctrl === true,
|
|
879844
|
+
shift: combo.shift === true,
|
|
879845
|
+
alt: combo.alt === true,
|
|
879846
|
+
label: manager5.formatCombo(combo)
|
|
879847
|
+
};
|
|
879848
|
+
}
|
|
879849
|
+
function bindingMatches(entry, query2) {
|
|
879850
|
+
if (!query2)
|
|
879851
|
+
return true;
|
|
879852
|
+
const haystack = [
|
|
879853
|
+
entry.action,
|
|
879854
|
+
entry.description,
|
|
879855
|
+
...entry.combos.map((combo) => comboFingerprint(combo))
|
|
879856
|
+
].join(`
|
|
879857
|
+
`).toLowerCase();
|
|
879858
|
+
return haystack.includes(query2.toLowerCase());
|
|
879859
|
+
}
|
|
879860
|
+
function describeBinding(manager5, action2, combos) {
|
|
879861
|
+
const defaults3 = DEFAULT_KEYBINDINGS[action2];
|
|
879862
|
+
const customized = !combosEqual(combos, defaults3);
|
|
879863
|
+
return {
|
|
879864
|
+
action: action2,
|
|
879865
|
+
description: ACTION_DESCRIPTIONS[action2],
|
|
879866
|
+
bindings: combos.map((combo) => describeCombo(manager5, combo)),
|
|
879867
|
+
labels: combos.map((combo) => manager5.formatCombo(combo)),
|
|
879868
|
+
defaultBindings: defaults3.map((combo) => describeCombo(manager5, combo)),
|
|
879869
|
+
customized,
|
|
879870
|
+
source: customized ? "custom" : "default"
|
|
879871
|
+
};
|
|
879872
|
+
}
|
|
879873
|
+
function readOverrideFile(configPath) {
|
|
879874
|
+
if (!existsSync82(configPath))
|
|
879875
|
+
return {};
|
|
879876
|
+
const parsed = JSON.parse(readFileSync89(configPath, "utf-8"));
|
|
879877
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
879878
|
+
throw new Error(`Keybindings config ${configPath} must contain a JSON object.`);
|
|
879879
|
+
}
|
|
879880
|
+
return parsed;
|
|
879881
|
+
}
|
|
879882
|
+
function writeOverrideFile(configPath, overrides) {
|
|
879883
|
+
mkdirSync67(dirname66(configPath), { recursive: true });
|
|
879884
|
+
writeFileSync58(configPath, `${JSON.stringify(overrides, null, 2)}
|
|
879885
|
+
`, "utf-8");
|
|
879886
|
+
}
|
|
879887
|
+
function totalHarnessKeybindings(context) {
|
|
879888
|
+
return context.workspace.keybindingsManager?.getAll().length ?? 0;
|
|
879889
|
+
}
|
|
879890
|
+
function totalHarnessShortcuts(context) {
|
|
879891
|
+
return totalHarnessKeybindings(context) + FIXED_SHORTCUTS.length;
|
|
879892
|
+
}
|
|
879893
|
+
function listHarnessShortcuts(context, args2) {
|
|
879894
|
+
const keybindings = listHarnessKeybindings(context, args2);
|
|
879895
|
+
const query2 = readString51(args2.query).toLowerCase();
|
|
879896
|
+
const fixed = FIXED_SHORTCUTS.filter((shortcut) => !query2 || `${shortcut.key}
|
|
879897
|
+
${shortcut.description}`.toLowerCase().includes(query2)).slice(0, readLimit6(args2.limit, 200)).map((shortcut) => ({ ...shortcut, source: "fixed", userEditable: false }));
|
|
879898
|
+
return {
|
|
879899
|
+
configPath: keybindings.configPath,
|
|
879900
|
+
fixedShortcuts: fixed,
|
|
879901
|
+
configurableKeybindings: keybindings.keybindings,
|
|
879902
|
+
returned: fixed.length + Number(keybindings.returned ?? 0),
|
|
879903
|
+
total: totalHarnessShortcuts(context),
|
|
879904
|
+
policy: "Fixed shortcuts are runtime/editor controls. Configurable keybindings can be changed with set_keybinding/reset_keybinding."
|
|
879905
|
+
};
|
|
879906
|
+
}
|
|
879907
|
+
function listHarnessKeybindings(context, args2) {
|
|
879908
|
+
const manager5 = requireKeybindingsManager2(context);
|
|
879909
|
+
const query2 = readString51(args2.query);
|
|
879910
|
+
const entries = manager5.getAll().filter((entry) => bindingMatches(entry, query2)).slice(0, readLimit6(args2.limit, 200)).map((entry) => describeBinding(manager5, entry.action, entry.combos));
|
|
879911
|
+
return {
|
|
879912
|
+
configPath: manager5.getConfigPath(),
|
|
879913
|
+
keybindings: entries,
|
|
879914
|
+
returned: entries.length,
|
|
879915
|
+
total: manager5.getAll().length,
|
|
879916
|
+
policy: "Reads the live resolved keybindings. set_keybinding/reset_keybinding write the same keybindings.json file the user can edit and reload the runtime manager."
|
|
879917
|
+
};
|
|
879918
|
+
}
|
|
879919
|
+
function describeHarnessKeybinding(context, args2) {
|
|
879920
|
+
const manager5 = requireKeybindingsManager2(context);
|
|
879921
|
+
const action2 = actionFromArgs(args2);
|
|
879922
|
+
if (!action2)
|
|
879923
|
+
return null;
|
|
879924
|
+
const entry = manager5.getAll().find((candidate) => candidate.action === action2);
|
|
879925
|
+
return entry ? {
|
|
879926
|
+
configPath: manager5.getConfigPath(),
|
|
879927
|
+
...describeBinding(manager5, entry.action, entry.combos)
|
|
879928
|
+
} : null;
|
|
879929
|
+
}
|
|
879930
|
+
function setHarnessKeybinding(context, args2) {
|
|
879931
|
+
const manager5 = requireKeybindingsManager2(context);
|
|
879932
|
+
const action2 = actionFromArgs(args2);
|
|
879933
|
+
if (!action2)
|
|
879934
|
+
throw new Error("set_keybinding requires a valid keybinding action id.");
|
|
879935
|
+
const combos = combosFromArgs(args2);
|
|
879936
|
+
const configPath = manager5.getConfigPath();
|
|
879937
|
+
const overrides = readOverrideFile(configPath);
|
|
879938
|
+
overrides[action2] = combos.length === 1 ? combos[0] : combos;
|
|
879939
|
+
writeOverrideFile(configPath, overrides);
|
|
879940
|
+
manager5.loadFromDisk();
|
|
879941
|
+
return {
|
|
879942
|
+
status: "updated",
|
|
879943
|
+
configPath,
|
|
879944
|
+
keybinding: describeHarnessKeybinding(context, { actionId: action2 })
|
|
879945
|
+
};
|
|
879946
|
+
}
|
|
879947
|
+
function resetHarnessKeybinding(context, args2) {
|
|
879948
|
+
const manager5 = requireKeybindingsManager2(context);
|
|
879949
|
+
const action2 = actionFromArgs(args2);
|
|
879950
|
+
if (!action2)
|
|
879951
|
+
throw new Error("reset_keybinding requires a valid keybinding action id.");
|
|
879952
|
+
const configPath = manager5.getConfigPath();
|
|
879953
|
+
const overrides = readOverrideFile(configPath);
|
|
879954
|
+
delete overrides[action2];
|
|
879955
|
+
writeOverrideFile(configPath, overrides);
|
|
879956
|
+
manager5.loadFromDisk();
|
|
879957
|
+
return {
|
|
879958
|
+
status: "reset",
|
|
879959
|
+
configPath,
|
|
879960
|
+
keybinding: describeHarnessKeybinding(context, { actionId: action2 })
|
|
879961
|
+
};
|
|
879962
|
+
}
|
|
879963
|
+
|
|
879964
|
+
// src/tools/agent-harness-panel-metadata.ts
|
|
879965
|
+
function readString52(value) {
|
|
879966
|
+
return typeof value === "string" ? value.trim() : "";
|
|
879967
|
+
}
|
|
879968
|
+
function readLimit7(value, fallback) {
|
|
879969
|
+
const parsed = typeof value === "string" && value.trim() ? Number(value) : value;
|
|
879970
|
+
if (typeof parsed !== "number" || !Number.isFinite(parsed))
|
|
879971
|
+
return fallback;
|
|
879972
|
+
return Math.max(1, Math.min(500, Math.trunc(parsed)));
|
|
879973
|
+
}
|
|
879731
879974
|
function panelManager(context) {
|
|
879732
879975
|
return context.workspace.panelManager ?? null;
|
|
879733
879976
|
}
|
|
@@ -879777,16 +880020,16 @@ function listHarnessPanels(context, args2) {
|
|
|
879777
880020
|
const manager5 = panelManager(context);
|
|
879778
880021
|
if (!manager5)
|
|
879779
880022
|
return [];
|
|
879780
|
-
const query2 =
|
|
879781
|
-
const category =
|
|
879782
|
-
const limit3 =
|
|
880023
|
+
const query2 = readString52(args2.query);
|
|
880024
|
+
const category = readString52(args2.category);
|
|
880025
|
+
const limit3 = readLimit7(args2.limit, 200);
|
|
879783
880026
|
return manager5.getRegisteredTypes().map((registration) => describePanelRegistration(context, registration)).filter((panel) => !category || panel.category === category).filter((panel) => panelMatches(panel, query2)).sort((a4, b3) => String(a4.id).localeCompare(String(b3.id))).slice(0, limit3);
|
|
879784
880027
|
}
|
|
879785
880028
|
function describeHarnessPanel(context, args2) {
|
|
879786
880029
|
const manager5 = panelManager(context);
|
|
879787
880030
|
if (!manager5)
|
|
879788
880031
|
return null;
|
|
879789
|
-
const panelId =
|
|
880032
|
+
const panelId = readString52(args2.panelId || args2.query);
|
|
879790
880033
|
if (!panelId)
|
|
879791
880034
|
return null;
|
|
879792
880035
|
const registration = manager5.getRegisteredTypes().find((panel) => panel.id === panelId || panel.name.toLowerCase() === panelId.toLowerCase());
|
|
@@ -879797,11 +880040,11 @@ function openHarnessPanel(context, args2) {
|
|
|
879797
880040
|
if (!panel) {
|
|
879798
880041
|
return {
|
|
879799
880042
|
status: "unknown_panel",
|
|
879800
|
-
panelId:
|
|
880043
|
+
panelId: readString52(args2.panelId || args2.query) || "<missing>",
|
|
879801
880044
|
availablePanels: listHarnessPanels(context, { limit: 50 }).map((entry) => entry.id)
|
|
879802
880045
|
};
|
|
879803
880046
|
}
|
|
879804
|
-
const requestedPane =
|
|
880047
|
+
const requestedPane = readString52(args2.pane);
|
|
879805
880048
|
const pane = requestedPane === "bottom" || requestedPane === "top" ? requestedPane : undefined;
|
|
879806
880049
|
if (!context.showPanel) {
|
|
879807
880050
|
return {
|
|
@@ -879826,10 +880069,10 @@ function output6(value) {
|
|
|
879826
880069
|
function error51(message) {
|
|
879827
880070
|
return { success: false, error: message };
|
|
879828
880071
|
}
|
|
879829
|
-
function
|
|
880072
|
+
function readString53(value) {
|
|
879830
880073
|
return typeof value === "string" ? value.trim() : "";
|
|
879831
880074
|
}
|
|
879832
|
-
function
|
|
880075
|
+
function readFieldMap2(value) {
|
|
879833
880076
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
879834
880077
|
return {};
|
|
879835
880078
|
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, typeof entry === "string" ? entry : String(entry)]));
|
|
@@ -879852,11 +880095,11 @@ function describeEditor(editor) {
|
|
|
879852
880095
|
};
|
|
879853
880096
|
}
|
|
879854
880097
|
function readRecordId(args2) {
|
|
879855
|
-
const fields =
|
|
879856
|
-
return
|
|
880098
|
+
const fields = readFieldMap2(args2.fields);
|
|
880099
|
+
return readString53(args2.recordId ?? args2.id ?? fields.recordId ?? fields.id);
|
|
879857
880100
|
}
|
|
879858
880101
|
function requireConfirmed(args2, label) {
|
|
879859
|
-
if (!
|
|
880102
|
+
if (!readString53(args2.explicitUserRequest))
|
|
879860
880103
|
return `${label} requires explicitUserRequest with the user's exact request or a short faithful summary.`;
|
|
879861
880104
|
if (args2.confirm !== true)
|
|
879862
880105
|
return `${label} requires confirm:true after an explicit user request.`;
|
|
@@ -879866,7 +880109,7 @@ function fieldReader(editor, fields) {
|
|
|
879866
880109
|
return (id) => fields[id] ?? editor.fields.find((field) => field.id === id)?.value ?? "";
|
|
879867
880110
|
}
|
|
879868
880111
|
function hasExecutionFields(args2) {
|
|
879869
|
-
return Object.keys(
|
|
880112
|
+
return Object.keys(readFieldMap2(args2.fields)).some((key) => key !== "id" && key !== "recordId");
|
|
879870
880113
|
}
|
|
879871
880114
|
function missingRequiredFields(editor, fields) {
|
|
879872
880115
|
const read = fieldReader(editor, fields);
|
|
@@ -879977,14 +880220,14 @@ function localRegistryArgsFromEditor(editor, fields, id) {
|
|
|
879977
880220
|
return { domain: "routine", action: editor.mode === "update" ? "update" : "create", id, name: read("name"), description: read("description"), steps: read("steps"), tags: splitList5(read("tags")), triggers: splitList5(read("triggers")), requiresEnv: splitList5(read("requiresEnv")), requiresCommands: splitList5(read("requiresCommands")), enabled: isAffirmative15(read("enabled")), provenance: editor.recordId ? "agent-harness-local-operation" : "agent-harness-note-promotion" };
|
|
879978
880221
|
}
|
|
879979
880222
|
function localRegistryArgsForTarget(target, args2, recordId) {
|
|
879980
|
-
const fields =
|
|
880223
|
+
const fields = readFieldMap2(args2.fields);
|
|
879981
880224
|
const base2 = { domain: target.domain, action: target.action, ...recordId ? { id: recordId } : {} };
|
|
879982
880225
|
const edit = target.action === "update" ? localRegistryArgsFromEditor({ kind: target.domain, mode: "update", recordId, title: "", selectedFieldIndex: 0, message: "", fields: [] }, fields, recordId) : {};
|
|
879983
880226
|
return {
|
|
879984
880227
|
...base2,
|
|
879985
880228
|
...edit,
|
|
879986
880229
|
...target.action === "stale" && fields.reason ? { reason: fields.reason } : {},
|
|
879987
|
-
...target.action === "delete" ? { confirm: args2.confirm, explicitUserRequest:
|
|
880230
|
+
...target.action === "delete" ? { confirm: args2.confirm, explicitUserRequest: readString53(args2.explicitUserRequest) } : {}
|
|
879988
880231
|
};
|
|
879989
880232
|
}
|
|
879990
880233
|
async function executeTool(toolRegistry, name51, toolArgs) {
|
|
@@ -880024,12 +880267,12 @@ async function runLocalWorkspaceAction(deps, action2, args2) {
|
|
|
880024
880267
|
if (confirmationError2)
|
|
880025
880268
|
return error51(confirmationError2);
|
|
880026
880269
|
if (editor) {
|
|
880027
|
-
const fields =
|
|
880270
|
+
const fields = readFieldMap2(args2.fields);
|
|
880028
880271
|
const missing = missingRequiredFields(editor, fields);
|
|
880029
880272
|
if (missing.length > 0)
|
|
880030
880273
|
return output6({ status: "missing_required_fields", missing, action: action2.id, editor: describeEditor(editor) });
|
|
880031
880274
|
if (editor.kind === "knowledge-url")
|
|
880032
|
-
return executeTool(deps.toolRegistry, "agent_knowledge_ingest", { sourceKind: "url", url: fieldReader(editor, fields)("url"), tags: splitList5(fieldReader(editor, fields)("tags")), folderPath: fieldReader(editor, fields)("folder"), confirm: args2.confirm, explicitUserRequest:
|
|
880275
|
+
return executeTool(deps.toolRegistry, "agent_knowledge_ingest", { sourceKind: "url", url: fieldReader(editor, fields)("url"), tags: splitList5(fieldReader(editor, fields)("tags")), folderPath: fieldReader(editor, fields)("folder"), confirm: args2.confirm, explicitUserRequest: readString53(args2.explicitUserRequest) });
|
|
880033
880276
|
return executeTool(deps.toolRegistry, "agent_local_registry", localRegistryArgsFromEditor(editor, fields, recordId));
|
|
880034
880277
|
}
|
|
880035
880278
|
if (!target)
|
|
@@ -880038,19 +880281,19 @@ async function runLocalWorkspaceAction(deps, action2, args2) {
|
|
|
880038
880281
|
}
|
|
880039
880282
|
|
|
880040
880283
|
// src/tools/agent-harness-model-tool-catalog.ts
|
|
880041
|
-
function
|
|
880284
|
+
function readString54(value) {
|
|
880042
880285
|
return typeof value === "string" ? value.trim() : "";
|
|
880043
880286
|
}
|
|
880044
|
-
function
|
|
880287
|
+
function readLimit8(value, fallback) {
|
|
880045
880288
|
const parsed = typeof value === "string" && value.trim() ? Number(value) : value;
|
|
880046
880289
|
if (typeof parsed !== "number" || !Number.isFinite(parsed))
|
|
880047
880290
|
return fallback;
|
|
880048
880291
|
return Math.max(1, Math.min(500, Math.trunc(parsed)));
|
|
880049
880292
|
}
|
|
880050
880293
|
function listHarnessModelTools(toolRegistry, args2) {
|
|
880051
|
-
const query2 =
|
|
880294
|
+
const query2 = readString54(args2.query).toLowerCase();
|
|
880052
880295
|
const includeParameters = args2.includeParameters === true;
|
|
880053
|
-
const limit3 =
|
|
880296
|
+
const limit3 = readLimit8(args2.limit, 200);
|
|
880054
880297
|
return toolRegistry.getToolDefinitions().filter((tool2) => !query2 || [tool2.name, tool2.description, ...tool2.sideEffects ?? []].join(`
|
|
880055
880298
|
`).toLowerCase().includes(query2)).sort((a4, b3) => a4.name.localeCompare(b3.name)).slice(0, limit3).map((tool2) => ({
|
|
880056
880299
|
name: tool2.name,
|
|
@@ -880071,6 +880314,11 @@ var MODES = [
|
|
|
880071
880314
|
"panels",
|
|
880072
880315
|
"panel",
|
|
880073
880316
|
"open_panel",
|
|
880317
|
+
"shortcuts",
|
|
880318
|
+
"keybindings",
|
|
880319
|
+
"keybinding",
|
|
880320
|
+
"set_keybinding",
|
|
880321
|
+
"reset_keybinding",
|
|
880074
880322
|
"commands",
|
|
880075
880323
|
"command",
|
|
880076
880324
|
"run_command",
|
|
@@ -880089,10 +880337,10 @@ var MODES = [
|
|
|
880089
880337
|
function isMode(value) {
|
|
880090
880338
|
return typeof value === "string" && MODES.includes(value);
|
|
880091
880339
|
}
|
|
880092
|
-
function
|
|
880340
|
+
function readString55(value) {
|
|
880093
880341
|
return typeof value === "string" ? value.trim() : "";
|
|
880094
880342
|
}
|
|
880095
|
-
function
|
|
880343
|
+
function readLimit9(value, fallback) {
|
|
880096
880344
|
const parsed = typeof value === "string" && value.trim() ? Number(value) : value;
|
|
880097
880345
|
if (typeof parsed !== "number" || !Number.isFinite(parsed))
|
|
880098
880346
|
return fallback;
|
|
@@ -880103,7 +880351,7 @@ function readStringArray12(value) {
|
|
|
880103
880351
|
return [];
|
|
880104
880352
|
return value.map((entry) => typeof entry === "string" ? entry : String(entry));
|
|
880105
880353
|
}
|
|
880106
|
-
function
|
|
880354
|
+
function readFieldMap3(value) {
|
|
880107
880355
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
880108
880356
|
return {};
|
|
880109
880357
|
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, typeof entry === "string" ? entry : String(entry)]));
|
|
@@ -880117,6 +880365,12 @@ function output7(value) {
|
|
|
880117
880365
|
function error52(message) {
|
|
880118
880366
|
return { success: false, error: message };
|
|
880119
880367
|
}
|
|
880368
|
+
var KEY_COMBO_PARAMETER_SCHEMA = {
|
|
880369
|
+
type: "object",
|
|
880370
|
+
properties: { key: { type: "string" }, ctrl: { type: "boolean" }, shift: { type: "boolean" }, alt: { type: "boolean" } },
|
|
880371
|
+
required: ["key"],
|
|
880372
|
+
additionalProperties: false
|
|
880373
|
+
};
|
|
880120
880374
|
function commandMatches(command8, query2) {
|
|
880121
880375
|
if (!query2)
|
|
880122
880376
|
return true;
|
|
@@ -880172,8 +880426,8 @@ function describeWorkspaceEditor(editor) {
|
|
|
880172
880426
|
};
|
|
880173
880427
|
}
|
|
880174
880428
|
function selectedRoutineFromArgs(snapshot, args2) {
|
|
880175
|
-
const fields =
|
|
880176
|
-
const routineId =
|
|
880429
|
+
const fields = readFieldMap3(args2.fields);
|
|
880430
|
+
const routineId = readString55(args2.recordId) || readString55(fields.routineId) || readString55(fields.id);
|
|
880177
880431
|
if (!routineId)
|
|
880178
880432
|
return null;
|
|
880179
880433
|
return snapshot.localRoutines.find((routine) => routine.id === routineId || routine.name.toLowerCase() === routineId.toLowerCase()) ?? null;
|
|
@@ -880241,17 +880495,17 @@ function localEditorModelExecution(editorKind) {
|
|
|
880241
880495
|
return "Use the command field, editor schema, or a first-class Agent model tool when available.";
|
|
880242
880496
|
}
|
|
880243
880497
|
function listWorkspaceActions(deps, args2) {
|
|
880244
|
-
const query2 =
|
|
880245
|
-
const categoryId =
|
|
880246
|
-
const limit3 =
|
|
880498
|
+
const query2 = readString55(args2.query);
|
|
880499
|
+
const categoryId = readString55(args2.categoryId || args2.category);
|
|
880500
|
+
const limit3 = readLimit9(args2.limit, 200);
|
|
880247
880501
|
const includeEditor = args2.includeParameters === true;
|
|
880248
880502
|
const editorContext = includeEditor ? buildWorkspaceEditorContext(deps.commandContext, args2) : null;
|
|
880249
880503
|
const source = query2 ? searchAgentWorkspaceActions(AGENT_WORKSPACE_CATEGORIES, query2).map((result2) => ({ category: result2.category, action: result2.action })) : allWorkspaceActions();
|
|
880250
880504
|
return source.filter((entry) => !categoryId || entry.category.id === categoryId).slice(0, limit3).map((entry) => describeWorkspaceAction(entry.category, entry.action, { includeEditor, editorContext }));
|
|
880251
880505
|
}
|
|
880252
880506
|
function findWorkspaceAction(args2) {
|
|
880253
|
-
const actionId =
|
|
880254
|
-
const categoryId =
|
|
880507
|
+
const actionId = readString55(args2.actionId || args2.query);
|
|
880508
|
+
const categoryId = readString55(args2.categoryId || args2.category);
|
|
880255
880509
|
if (!actionId)
|
|
880256
880510
|
return null;
|
|
880257
880511
|
return allWorkspaceActions().find((entry) => {
|
|
@@ -880261,12 +880515,12 @@ function findWorkspaceAction(args2) {
|
|
|
880261
880515
|
}) ?? null;
|
|
880262
880516
|
}
|
|
880263
880517
|
function listCommands(commandRegistry, args2) {
|
|
880264
|
-
const query2 =
|
|
880265
|
-
const limit3 =
|
|
880518
|
+
const query2 = readString55(args2.query);
|
|
880519
|
+
const limit3 = readLimit9(args2.limit, 200);
|
|
880266
880520
|
return commandRegistry.list().filter((command8) => commandMatches(command8, query2)).sort((a4, b3) => a4.name.localeCompare(b3.name)).slice(0, limit3).map(describeCommand);
|
|
880267
880521
|
}
|
|
880268
880522
|
function requireConfirmedAction(args2, action2) {
|
|
880269
|
-
const explicitUserRequest =
|
|
880523
|
+
const explicitUserRequest = readString55(args2.explicitUserRequest);
|
|
880270
880524
|
if (!explicitUserRequest)
|
|
880271
880525
|
return `${action2} requires explicitUserRequest with the user's exact request or a short faithful summary.`;
|
|
880272
880526
|
if (args2.confirm !== true)
|
|
@@ -880274,7 +880528,7 @@ function requireConfirmedAction(args2, action2) {
|
|
|
880274
880528
|
return null;
|
|
880275
880529
|
}
|
|
880276
880530
|
function commandFromArgs(args2) {
|
|
880277
|
-
const rawCommand =
|
|
880531
|
+
const rawCommand = readString55(args2.command);
|
|
880278
880532
|
if (rawCommand) {
|
|
880279
880533
|
const parsed = parseSlashCommand(rawCommand);
|
|
880280
880534
|
if (!parsed.name)
|
|
@@ -880284,7 +880538,7 @@ function commandFromArgs(args2) {
|
|
|
880284
880538
|
args: parsed.args
|
|
880285
880539
|
};
|
|
880286
880540
|
}
|
|
880287
|
-
const commandName =
|
|
880541
|
+
const commandName = readString55(args2.commandName).replace(/^\//, "");
|
|
880288
880542
|
if (!commandName)
|
|
880289
880543
|
return null;
|
|
880290
880544
|
const commandArgs = readStringArray12(args2.args);
|
|
@@ -880334,7 +880588,7 @@ function missingRequiredEditorFields(editor, fields) {
|
|
|
880334
880588
|
return editor.fields.filter((field) => field.required && !readField(field.id).trim()).map((field) => field.id);
|
|
880335
880589
|
}
|
|
880336
880590
|
async function runWorkspaceEditorAction(deps, action2, editor, args2) {
|
|
880337
|
-
const fields =
|
|
880591
|
+
const fields = readFieldMap3(args2.fields);
|
|
880338
880592
|
const missing = missingRequiredEditorFields(editor, fields);
|
|
880339
880593
|
if (missing.length > 0) {
|
|
880340
880594
|
return output7({
|
|
@@ -880472,8 +880726,8 @@ function createAgentHarnessTool(deps) {
|
|
|
880472
880726
|
name: "agent_harness",
|
|
880473
880727
|
description: [
|
|
880474
880728
|
"Discover and operate the GoodVibes Agent harness from the main conversation.",
|
|
880475
|
-
"Use this tool to inspect Agent workspace actions, built-in panels, top-level CLI mirrors, slash commands with policy metadata, model tools, connected-host capabilities, and Agent settings, or to invoke a workspace action/command through the same in-process command registry the user uses in the TUI.",
|
|
880476
|
-
"Discovery modes are read-only. Setting writes, resets, slash command invocation, and workspace action invocation require confirm:true plus explicitUserRequest.",
|
|
880729
|
+
"Use this tool to inspect Agent workspace actions, built-in panels, top-level CLI mirrors, keybindings, slash commands with policy metadata, model tools, connected-host capabilities, and Agent settings, or to invoke a workspace action/command through the same in-process command registry the user uses in the TUI.",
|
|
880730
|
+
"Discovery modes are read-only. Setting/keybinding writes, resets, slash command invocation, and workspace action invocation require confirm:true plus explicitUserRequest.",
|
|
880477
880731
|
"This tool preserves Agent product boundaries: connected-host lifecycle and listener posture stay externally owned, connected-host mode reports allowed and blocked route families, and secret-backed settings store raw values through the secret manager while config receives only a secret reference."
|
|
880478
880732
|
].join(" "),
|
|
880479
880733
|
parameters: {
|
|
@@ -880515,13 +880769,22 @@ function createAgentHarnessTool(deps) {
|
|
|
880515
880769
|
},
|
|
880516
880770
|
actionId: {
|
|
880517
880771
|
type: "string",
|
|
880518
|
-
description: "Agent workspace action id for workspace_action or run_workspace_action."
|
|
880772
|
+
description: "Agent workspace action id for workspace_action or run_workspace_action, or keybinding action id for keybinding/set_keybinding/reset_keybinding."
|
|
880519
880773
|
},
|
|
880520
880774
|
fields: {
|
|
880521
880775
|
type: "object",
|
|
880522
880776
|
additionalProperties: { type: "string" },
|
|
880523
880777
|
description: "Field values for run_workspace_action when the workspace action opens an editor form."
|
|
880524
880778
|
},
|
|
880779
|
+
combo: {
|
|
880780
|
+
...KEY_COMBO_PARAMETER_SCHEMA,
|
|
880781
|
+
description: 'Single key combo for set_keybinding, for example { "key": "g", "ctrl": true }.'
|
|
880782
|
+
},
|
|
880783
|
+
combos: {
|
|
880784
|
+
type: "array",
|
|
880785
|
+
items: KEY_COMBO_PARAMETER_SCHEMA,
|
|
880786
|
+
description: "Multiple key combos for set_keybinding."
|
|
880787
|
+
},
|
|
880525
880788
|
recordId: {
|
|
880526
880789
|
type: "string",
|
|
880527
880790
|
description: "Selected Agent-local record id for selection-based local workspace operations."
|
|
@@ -880588,6 +880851,8 @@ function createAgentHarnessTool(deps) {
|
|
|
880588
880851
|
cliCommands: totalHarnessCliCommands(),
|
|
880589
880852
|
blockedCliCommandTokens: blockedHarnessCliCommandTokens(),
|
|
880590
880853
|
panels: totalHarnessPanels(deps.commandContext),
|
|
880854
|
+
shortcuts: totalHarnessShortcuts(deps.commandContext),
|
|
880855
|
+
keybindings: totalHarnessKeybindings(deps.commandContext),
|
|
880591
880856
|
commands: deps.commandRegistry.list().length,
|
|
880592
880857
|
settings: deps.commandContext.platform.configManager.getSchema().length,
|
|
880593
880858
|
workspaceCategories: AGENT_WORKSPACE_CATEGORIES.length,
|
|
@@ -880596,6 +880861,7 @@ function createAgentHarnessTool(deps) {
|
|
|
880596
880861
|
modelAccess: {
|
|
880597
880862
|
cliCommands: 'Use mode:"cli_commands" and mode:"cli_command" to inspect package CLI mirrors and their preferred in-process model routes. CLI modes are discovery-only.',
|
|
880598
880863
|
panels: 'Use mode:"panels" and mode:"panel" to inspect built-in panel catalog/open state; use mode:"open_panel" with confirm:true plus explicitUserRequest to route a visible panel/workspace change.',
|
|
880864
|
+
shortcuts: 'Use mode:"shortcuts" to inspect fixed shortcuts plus configurable keybindings. Use mode:"set_keybinding" and mode:"reset_keybinding" with confirm:true plus explicitUserRequest to edit the same config file the user edits.',
|
|
880599
880865
|
slashCommands: 'Use mode:"commands" and mode:"command" to inspect; use mode:"run_command" with confirm:true plus explicitUserRequest to execute.',
|
|
880600
880866
|
workspace: 'Use mode:"workspace_actions" to list and mode:"workspace_action" for editor schemas; set includeParameters:true on workspace_actions to inline editor schemas.',
|
|
880601
880867
|
settings: 'Use mode:"settings", mode:"get_setting", mode:"set_setting", and mode:"reset_setting".',
|
|
@@ -880630,7 +880896,7 @@ function createAgentHarnessTool(deps) {
|
|
|
880630
880896
|
}
|
|
880631
880897
|
if (args2.mode === "panel") {
|
|
880632
880898
|
const panel = describeHarnessPanel(deps.commandContext, args2);
|
|
880633
|
-
return panel ? output7(panel) : error52(`Unknown panel ${
|
|
880899
|
+
return panel ? output7(panel) : error52(`Unknown panel ${readString55(args2.panelId || args2.query) || "<missing>"}.`);
|
|
880634
880900
|
}
|
|
880635
880901
|
if (args2.mode === "open_panel") {
|
|
880636
880902
|
const confirmationError2 = requireConfirmedAction(args2, "Panel routing");
|
|
@@ -880638,12 +880904,32 @@ function createAgentHarnessTool(deps) {
|
|
|
880638
880904
|
return error52(confirmationError2);
|
|
880639
880905
|
return output7(openHarnessPanel(deps.commandContext, args2));
|
|
880640
880906
|
}
|
|
880907
|
+
if (args2.mode === "shortcuts")
|
|
880908
|
+
return output7(listHarnessShortcuts(deps.commandContext, args2));
|
|
880909
|
+
if (args2.mode === "keybindings")
|
|
880910
|
+
return output7(listHarnessKeybindings(deps.commandContext, args2));
|
|
880911
|
+
if (args2.mode === "keybinding") {
|
|
880912
|
+
const binding = describeHarnessKeybinding(deps.commandContext, args2);
|
|
880913
|
+
return binding ? output7(binding) : error52(`Unknown keybinding action ${readString55(args2.actionId || args2.key || args2.query) || "<missing>"}.`);
|
|
880914
|
+
}
|
|
880915
|
+
if (args2.mode === "set_keybinding") {
|
|
880916
|
+
const confirmationError2 = requireConfirmedAction(args2, "Keybinding mutation");
|
|
880917
|
+
if (confirmationError2)
|
|
880918
|
+
return error52(confirmationError2);
|
|
880919
|
+
return output7(setHarnessKeybinding(deps.commandContext, args2));
|
|
880920
|
+
}
|
|
880921
|
+
if (args2.mode === "reset_keybinding") {
|
|
880922
|
+
const confirmationError2 = requireConfirmedAction(args2, "Keybinding reset");
|
|
880923
|
+
if (confirmationError2)
|
|
880924
|
+
return error52(confirmationError2);
|
|
880925
|
+
return output7(resetHarnessKeybinding(deps.commandContext, args2));
|
|
880926
|
+
}
|
|
880641
880927
|
if (args2.mode === "commands") {
|
|
880642
880928
|
const commands3 = listCommands(deps.commandRegistry, args2);
|
|
880643
880929
|
return output7({ commands: commands3, returned: commands3.length, total: deps.commandRegistry.list().length });
|
|
880644
880930
|
}
|
|
880645
880931
|
if (args2.mode === "command") {
|
|
880646
|
-
const name51 =
|
|
880932
|
+
const name51 = readString55(args2.commandName).replace(/^\//, "");
|
|
880647
880933
|
const command8 = name51 ? deps.commandRegistry.get(name51) : null;
|
|
880648
880934
|
return command8 ? output7(describeCommand(command8)) : error52(`Unknown slash command /${name51 || "<missing>"}.`);
|
|
880649
880935
|
}
|
|
@@ -880651,16 +880937,16 @@ function createAgentHarnessTool(deps) {
|
|
|
880651
880937
|
return runCommand2(deps, args2);
|
|
880652
880938
|
if (args2.mode === "settings") {
|
|
880653
880939
|
const settings = listHarnessSettings(deps.commandContext.platform.configManager, {
|
|
880654
|
-
category:
|
|
880655
|
-
prefix:
|
|
880656
|
-
query:
|
|
880940
|
+
category: readString55(args2.category) || undefined,
|
|
880941
|
+
prefix: readString55(args2.prefix) || undefined,
|
|
880942
|
+
query: readString55(args2.query) || undefined,
|
|
880657
880943
|
includeHidden: args2.includeHidden === true,
|
|
880658
|
-
limit:
|
|
880944
|
+
limit: readLimit9(args2.limit, 100)
|
|
880659
880945
|
});
|
|
880660
880946
|
return output7({ settings, returned: settings.length, policy: settingsPolicySummary() });
|
|
880661
880947
|
}
|
|
880662
880948
|
if (args2.mode === "get_setting") {
|
|
880663
|
-
const key =
|
|
880949
|
+
const key = readString55(args2.key);
|
|
880664
880950
|
const setting = getHarnessSetting(deps.commandContext.platform.configManager, key);
|
|
880665
880951
|
return setting ? output7(setting) : error52(`Unknown setting ${key || "<missing>"}.`);
|
|
880666
880952
|
}
|
|
@@ -880670,7 +880956,7 @@ function createAgentHarnessTool(deps) {
|
|
|
880670
880956
|
return error52(confirmationError2);
|
|
880671
880957
|
if (args2.value === undefined)
|
|
880672
880958
|
return error52("set_setting requires value.");
|
|
880673
|
-
const key =
|
|
880959
|
+
const key = readString55(args2.key);
|
|
880674
880960
|
const result2 = await setHarnessSetting(deps.commandContext.platform.configManager, deps.commandContext.platform.secretsManager, key, args2.value);
|
|
880675
880961
|
return output7(result2);
|
|
880676
880962
|
}
|
|
@@ -880678,7 +880964,7 @@ function createAgentHarnessTool(deps) {
|
|
|
880678
880964
|
const confirmationError2 = requireConfirmedAction(args2, "Setting reset");
|
|
880679
880965
|
if (confirmationError2)
|
|
880680
880966
|
return error52(confirmationError2);
|
|
880681
|
-
const key =
|
|
880967
|
+
const key = readString55(args2.key);
|
|
880682
880968
|
const result2 = await resetHarnessSetting(deps.commandContext.platform.configManager, deps.commandContext.platform.secretsManager, key);
|
|
880683
880969
|
return output7(result2);
|
|
880684
880970
|
}
|
|
@@ -880695,7 +880981,7 @@ function createAgentHarnessTool(deps) {
|
|
|
880695
880981
|
if (args2.mode === "workspace_action") {
|
|
880696
880982
|
const found = findWorkspaceAction(args2);
|
|
880697
880983
|
const editorContext = buildWorkspaceEditorContext(deps.commandContext, args2);
|
|
880698
|
-
return found ? output7(describeWorkspaceAction(found.category, found.action, { includeEditor: true, editorContext })) : error52(`Unknown Agent workspace action ${
|
|
880984
|
+
return found ? output7(describeWorkspaceAction(found.category, found.action, { includeEditor: true, editorContext })) : error52(`Unknown Agent workspace action ${readString55(args2.actionId || args2.query) || "<missing>"}.`);
|
|
880699
880985
|
}
|
|
880700
880986
|
if (args2.mode === "run_workspace_action")
|
|
880701
880987
|
return runWorkspaceAction(deps, args2);
|
|
@@ -882518,7 +882804,7 @@ function mergeFeatureFlagConfigValue(config6, key, value) {
|
|
|
882518
882804
|
|
|
882519
882805
|
// src/runtime/onboarding/verify.ts
|
|
882520
882806
|
init_config8();
|
|
882521
|
-
import { existsSync as
|
|
882807
|
+
import { existsSync as existsSync83 } from "fs";
|
|
882522
882808
|
import { join as join98 } from "path";
|
|
882523
882809
|
function getNow(deps) {
|
|
882524
882810
|
return deps.clock?.() ?? Date.now();
|
|
@@ -882600,7 +882886,7 @@ function verifyAuthOperation(_deps, operation) {
|
|
|
882600
882886
|
}
|
|
882601
882887
|
function verifyCreateAgentProfileOperation(deps, operation) {
|
|
882602
882888
|
const resolution2 = resolveAgentRuntimeProfileHome(deps.shellPaths.homeDirectory, operation.name);
|
|
882603
|
-
const ok3 =
|
|
882889
|
+
const ok3 = existsSync83(join98(resolution2.homeDirectory, "profile.json"));
|
|
882604
882890
|
return {
|
|
882605
882891
|
id: `agent-profile:${resolution2.id}`,
|
|
882606
882892
|
status: ok3 ? "pass" : "fail",
|
|
@@ -882698,22 +882984,22 @@ async function verifyOnboardingRequest(deps, request2) {
|
|
|
882698
882984
|
}
|
|
882699
882985
|
|
|
882700
882986
|
// src/runtime/onboarding/apply-file-helpers.ts
|
|
882701
|
-
import { existsSync as
|
|
882702
|
-
import { dirname as
|
|
882987
|
+
import { existsSync as existsSync84, mkdirSync as mkdirSync68, readFileSync as readFileSync90, unlinkSync as unlinkSync11, writeFileSync as writeFileSync59 } from "fs";
|
|
882988
|
+
import { dirname as dirname67 } from "path";
|
|
882703
882989
|
function isPlainObject3(value) {
|
|
882704
882990
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
882705
882991
|
}
|
|
882706
882992
|
function readJsonObject(path7) {
|
|
882707
|
-
if (!
|
|
882993
|
+
if (!existsSync84(path7))
|
|
882708
882994
|
return {};
|
|
882709
|
-
const parsed = JSON.parse(
|
|
882995
|
+
const parsed = JSON.parse(readFileSync90(path7, "utf-8"));
|
|
882710
882996
|
if (!isPlainObject3(parsed))
|
|
882711
882997
|
throw new Error(`Expected an object JSON payload at ${path7}.`);
|
|
882712
882998
|
return parsed;
|
|
882713
882999
|
}
|
|
882714
883000
|
function writeJsonObject(path7, payload) {
|
|
882715
|
-
|
|
882716
|
-
|
|
883001
|
+
mkdirSync68(dirname67(path7), { recursive: true });
|
|
883002
|
+
writeFileSync59(path7, `${JSON.stringify(payload, null, 2)}
|
|
882717
883003
|
`, "utf-8");
|
|
882718
883004
|
}
|
|
882719
883005
|
function setNestedValue(root, key, value) {
|
|
@@ -882734,16 +883020,16 @@ function setNestedValue(root, key, value) {
|
|
|
882734
883020
|
}
|
|
882735
883021
|
function restoreFile(path7, previous, reload) {
|
|
882736
883022
|
if (previous === null) {
|
|
882737
|
-
if (
|
|
883023
|
+
if (existsSync84(path7))
|
|
882738
883024
|
unlinkSync11(path7);
|
|
882739
883025
|
} else {
|
|
882740
|
-
|
|
882741
|
-
|
|
883026
|
+
mkdirSync68(dirname67(path7), { recursive: true });
|
|
883027
|
+
writeFileSync59(path7, previous, "utf-8");
|
|
882742
883028
|
}
|
|
882743
883029
|
reload?.();
|
|
882744
883030
|
}
|
|
882745
883031
|
function snapshotFileRollback(path7, reload) {
|
|
882746
|
-
const previous =
|
|
883032
|
+
const previous = existsSync84(path7) ? readFileSync90(path7, "utf-8") : null;
|
|
882747
883033
|
return () => restoreFile(path7, previous, reload);
|
|
882748
883034
|
}
|
|
882749
883035
|
async function runRollbacks(rollbacks) {
|
|
@@ -882862,7 +883148,7 @@ function validateCreateAgentProfileOperation(deps, operation) {
|
|
|
882862
883148
|
if (name51.length === 0)
|
|
882863
883149
|
throw new Error("Agent profile name is required.");
|
|
882864
883150
|
const resolution2 = resolveAgentRuntimeProfileHome(deps.shellPaths.homeDirectory, name51);
|
|
882865
|
-
if (
|
|
883151
|
+
if (existsSync85(resolution2.homeDirectory)) {
|
|
882866
883152
|
throw new Error(`Agent profile already exists: ${resolution2.id}`);
|
|
882867
883153
|
}
|
|
882868
883154
|
const templateId = operation.templateId?.trim();
|
|
@@ -882874,7 +883160,7 @@ function validateSelectAgentProfileOperation(deps, operation) {
|
|
|
882874
883160
|
if (name51.length === 0)
|
|
882875
883161
|
throw new Error("Agent profile name is required.");
|
|
882876
883162
|
const resolution2 = resolveAgentRuntimeProfileHome(deps.shellPaths.homeDirectory, name51);
|
|
882877
|
-
if (!
|
|
883163
|
+
if (!existsSync85(resolution2.homeDirectory)) {
|
|
882878
883164
|
throw new Error(`Agent profile does not exist: ${resolution2.id}`);
|
|
882879
883165
|
}
|
|
882880
883166
|
}
|
|
@@ -882982,7 +883268,7 @@ async function buildSecretRollbackAction(deps, operation) {
|
|
|
882982
883268
|
throw new Error(`Secret storage locations for ${scope} scope are unavailable.`);
|
|
882983
883269
|
const snapshots = locations.map((location) => ({
|
|
882984
883270
|
path: location.path,
|
|
882985
|
-
previous:
|
|
883271
|
+
previous: existsSync85(location.path) ? readFileSync91(location.path, "utf-8") : null
|
|
882986
883272
|
}));
|
|
882987
883273
|
return () => {
|
|
882988
883274
|
for (const snapshot of snapshots)
|
|
@@ -883016,7 +883302,7 @@ async function buildRollbackAction(deps, operation) {
|
|
|
883016
883302
|
if (operation.kind === "create-agent-profile") {
|
|
883017
883303
|
const resolution2 = resolveAgentRuntimeProfileHome(deps.shellPaths.homeDirectory, operation.name);
|
|
883018
883304
|
return () => {
|
|
883019
|
-
if (
|
|
883305
|
+
if (existsSync85(resolution2.homeDirectory))
|
|
883020
883306
|
rmSync10(resolution2.homeDirectory, { recursive: true, force: true });
|
|
883021
883307
|
};
|
|
883022
883308
|
}
|
|
@@ -883352,8 +883638,8 @@ async function applyOnboardingRequest(deps, request2) {
|
|
|
883352
883638
|
};
|
|
883353
883639
|
}
|
|
883354
883640
|
// src/runtime/onboarding/markers.ts
|
|
883355
|
-
import { existsSync as
|
|
883356
|
-
import { dirname as
|
|
883641
|
+
import { existsSync as existsSync86, mkdirSync as mkdirSync69, readFileSync as readFileSync92, writeFileSync as writeFileSync60 } from "fs";
|
|
883642
|
+
import { dirname as dirname68 } from "path";
|
|
883357
883643
|
var ONBOARDING_CHECK_MARKER_FILE = "onboarding-checked.json";
|
|
883358
883644
|
function resolveMarkerPath(shellPaths3, scope) {
|
|
883359
883645
|
return scope === "project" ? shellPaths3.resolveProjectPath(GOODVIBES_AGENT_SURFACE_ROOT, ONBOARDING_CHECK_MARKER_FILE) : shellPaths3.resolveUserPath(GOODVIBES_AGENT_SURFACE_ROOT, ONBOARDING_CHECK_MARKER_FILE);
|
|
@@ -883396,10 +883682,10 @@ function getOnboardingCheckMarkerPath(shellPaths3, scope = "user") {
|
|
|
883396
883682
|
}
|
|
883397
883683
|
function readOnboardingCheckMarker(shellPaths3, scope = "user") {
|
|
883398
883684
|
const path7 = resolveMarkerPath(shellPaths3, scope);
|
|
883399
|
-
if (!
|
|
883685
|
+
if (!existsSync86(path7))
|
|
883400
883686
|
return buildMissingMarkerState(scope, path7);
|
|
883401
883687
|
try {
|
|
883402
|
-
const parsed = JSON.parse(
|
|
883688
|
+
const parsed = JSON.parse(readFileSync92(path7, "utf-8"));
|
|
883403
883689
|
if (!isCheckMarkerPayload(parsed)) {
|
|
883404
883690
|
return buildParseErrorState(scope, path7, "Invalid onboarding check marker payload.");
|
|
883405
883691
|
}
|
|
@@ -883435,13 +883721,13 @@ function writeOnboardingCheckMarker(shellPaths3, options = {}) {
|
|
|
883435
883721
|
...options.mode ? { mode: options.mode } : {},
|
|
883436
883722
|
...options.workspaceRoot ? { workspaceRoot: options.workspaceRoot } : {}
|
|
883437
883723
|
};
|
|
883438
|
-
|
|
883439
|
-
|
|
883724
|
+
mkdirSync69(dirname68(path7), { recursive: true });
|
|
883725
|
+
writeFileSync60(path7, `${JSON.stringify(payload, null, 2)}
|
|
883440
883726
|
`, "utf-8");
|
|
883441
883727
|
return readOnboardingCheckMarker(shellPaths3, scope);
|
|
883442
883728
|
}
|
|
883443
883729
|
// src/input/handler-content-actions.ts
|
|
883444
|
-
import { existsSync as
|
|
883730
|
+
import { existsSync as existsSync87, lstatSync as lstatSync3, readFileSync as readFileSync93, readdirSync as readdirSync22 } from "fs";
|
|
883445
883731
|
import { basename as basename6, relative as relative15 } from "path";
|
|
883446
883732
|
var MARKER_REGEX = /\[(TEXT|IMAGE): [^\]]+\]/g;
|
|
883447
883733
|
var IMAGE_PREFIXES = [
|
|
@@ -883501,7 +883787,7 @@ function readContextFileBlock(reference, projectRoot) {
|
|
|
883501
883787
|
logger.debug("expandPrompt: context reference rejected", { reference, error: summarizeError(error53) });
|
|
883502
883788
|
return null;
|
|
883503
883789
|
}
|
|
883504
|
-
if (!
|
|
883790
|
+
if (!existsSync87(resolvedPath3))
|
|
883505
883791
|
return null;
|
|
883506
883792
|
const stat6 = lstatSync3(resolvedPath3);
|
|
883507
883793
|
const label = escapeContextAttribute(relative15(projectRoot, resolvedPath3) || basename6(resolvedPath3));
|
|
@@ -883520,14 +883806,14 @@ function readContextFileBlock(reference, projectRoot) {
|
|
|
883520
883806
|
if (stat6.size > MAX_CONTEXT_FILE_BYTES) {
|
|
883521
883807
|
return [
|
|
883522
883808
|
`<context-file path="${label}" truncated="true" bytes="${stat6.size}">`,
|
|
883523
|
-
|
|
883809
|
+
readFileSync93(resolvedPath3, "utf-8").slice(0, MAX_CONTEXT_FILE_BYTES),
|
|
883524
883810
|
"</context-file>"
|
|
883525
883811
|
].join(`
|
|
883526
883812
|
`);
|
|
883527
883813
|
}
|
|
883528
883814
|
return [
|
|
883529
883815
|
`<context-file path="${label}" bytes="${stat6.size}">`,
|
|
883530
|
-
|
|
883816
|
+
readFileSync93(resolvedPath3, "utf-8"),
|
|
883531
883817
|
"</context-file>"
|
|
883532
883818
|
].join(`
|
|
883533
883819
|
`);
|
|
@@ -883584,8 +883870,8 @@ function registerPaste(state4, content, projectRoot) {
|
|
|
883584
883870
|
if (IMAGE_EXTENSIONS2.some((ext) => trimmed2.toLowerCase().endsWith(ext))) {
|
|
883585
883871
|
try {
|
|
883586
883872
|
const resolvedPath3 = resolveAndValidatePath(trimmed2, projectRoot);
|
|
883587
|
-
if (
|
|
883588
|
-
const data =
|
|
883873
|
+
if (existsSync87(resolvedPath3)) {
|
|
883874
|
+
const data = readFileSync93(resolvedPath3);
|
|
883589
883875
|
const base644 = data.toString("base64");
|
|
883590
883876
|
const ext = trimmed2.slice(trimmed2.lastIndexOf("."));
|
|
883591
883877
|
const mediaType = mediaTypeFromExt(ext);
|
|
@@ -883635,7 +883921,7 @@ function expandPrompt(pasteRegistry, imageRegistry, text, projectRoot) {
|
|
|
883635
883921
|
const filePath = injectMatch[1];
|
|
883636
883922
|
try {
|
|
883637
883923
|
const resolvedPath3 = resolveAndValidatePath(filePath, projectRoot);
|
|
883638
|
-
const content =
|
|
883924
|
+
const content = readFileSync93(resolvedPath3, "utf-8");
|
|
883639
883925
|
expanded = expanded.slice(0, injectMatch.index) + content + expanded.slice(injectMatch.index + injectMatch[0].length);
|
|
883640
883926
|
injectRegex.lastIndex = injectMatch.index + content.length;
|
|
883641
883927
|
} catch (err2) {
|
|
@@ -892908,7 +893194,7 @@ function handleProfilePickerToken(state4, token) {
|
|
|
892908
893194
|
}
|
|
892909
893195
|
|
|
892910
893196
|
// src/input/handler-picker-routes.ts
|
|
892911
|
-
import { readFileSync as
|
|
893197
|
+
import { readFileSync as readFileSync94 } from "fs";
|
|
892912
893198
|
|
|
892913
893199
|
// src/renderer/model-picker-overlay.ts
|
|
892914
893200
|
var MODEL_PICKER_CHROME_LINES = 7;
|
|
@@ -893200,7 +893486,7 @@ function handleFilePickerToken(state4, token) {
|
|
|
893200
893486
|
throw new Error("working directory is unavailable");
|
|
893201
893487
|
}
|
|
893202
893488
|
const resolvedPath3 = resolveAndValidatePath(selected, projectRoot);
|
|
893203
|
-
const data =
|
|
893489
|
+
const data = readFileSync94(resolvedPath3);
|
|
893204
893490
|
const base644 = data.toString("base64");
|
|
893205
893491
|
const mediaType = state4.mediaTypeFromExt(ext);
|
|
893206
893492
|
const filename = selected.split("/").pop() ?? selected;
|
|
@@ -898914,7 +899200,7 @@ function wireShellUiOpeners(options) {
|
|
|
898914
899200
|
}
|
|
898915
899201
|
|
|
898916
899202
|
// src/cli/entrypoint.ts
|
|
898917
|
-
import { existsSync as
|
|
899203
|
+
import { existsSync as existsSync89 } from "fs";
|
|
898918
899204
|
import { join as join101 } from "path";
|
|
898919
899205
|
// src/cli/status.ts
|
|
898920
899206
|
function yesNo3(value) {
|
|
@@ -899160,12 +899446,12 @@ function renderOnboardingCliStatus(options) {
|
|
|
899160
899446
|
`);
|
|
899161
899447
|
}
|
|
899162
899448
|
// src/cli/external-runtime.ts
|
|
899163
|
-
import { existsSync as
|
|
899449
|
+
import { existsSync as existsSync88, readFileSync as readFileSync95 } from "fs";
|
|
899164
899450
|
import { join as join100 } from "path";
|
|
899165
899451
|
function isRecord43(value) {
|
|
899166
899452
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
899167
899453
|
}
|
|
899168
|
-
function
|
|
899454
|
+
function readString56(record2, key) {
|
|
899169
899455
|
const value = record2?.[key];
|
|
899170
899456
|
return typeof value === "string" ? value : null;
|
|
899171
899457
|
}
|
|
@@ -899176,10 +899462,10 @@ function resolveBaseUrl2(configManager) {
|
|
|
899176
899462
|
}
|
|
899177
899463
|
function readOperatorToken2(homeDirectory) {
|
|
899178
899464
|
const path7 = join100(homeDirectory, ".goodvibes", "daemon", "operator-tokens.json");
|
|
899179
|
-
if (!
|
|
899465
|
+
if (!existsSync88(path7))
|
|
899180
899466
|
return { token: null, path: path7 };
|
|
899181
899467
|
try {
|
|
899182
|
-
const parsed = JSON.parse(
|
|
899468
|
+
const parsed = JSON.parse(readFileSync95(path7, "utf-8"));
|
|
899183
899469
|
const token = isRecord43(parsed) && typeof parsed.token === "string" ? parsed.token : null;
|
|
899184
899470
|
return { token, path: path7 };
|
|
899185
899471
|
} catch {
|
|
@@ -899216,7 +899502,7 @@ async function inspectCliExternalRuntime(options) {
|
|
|
899216
899502
|
try {
|
|
899217
899503
|
const status = await fetchJson2(`${baseUrl}/status`, token.token, timeoutMs);
|
|
899218
899504
|
const statusRecord = isRecord43(status.body) ? status.body : {};
|
|
899219
|
-
const version6 =
|
|
899505
|
+
const version6 = readString56(statusRecord, "version") ?? "unknown";
|
|
899220
899506
|
const compatible = status.ok && version6 === SDK_VERSION;
|
|
899221
899507
|
if (!status.ok) {
|
|
899222
899508
|
return {
|
|
@@ -899671,11 +899957,11 @@ async function prepareShellCliRuntime(argv, roots, binary2 = "goodvibes-agent")
|
|
|
899671
899957
|
onboardingMarkers,
|
|
899672
899958
|
auth: {
|
|
899673
899959
|
userStorePath,
|
|
899674
|
-
userStorePresent:
|
|
899960
|
+
userStorePresent: existsSync89(userStorePath),
|
|
899675
899961
|
bootstrapCredentialPath,
|
|
899676
|
-
bootstrapCredentialPresent:
|
|
899962
|
+
bootstrapCredentialPresent: existsSync89(bootstrapCredentialPath),
|
|
899677
899963
|
operatorTokenPath,
|
|
899678
|
-
operatorTokenPresent:
|
|
899964
|
+
operatorTokenPresent: existsSync89(operatorTokenPath)
|
|
899679
899965
|
},
|
|
899680
899966
|
service,
|
|
899681
899967
|
externalRuntime,
|