glimmervoid 0.0.0-stage → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +48 -0
- package/README.md +195 -2
- package/dist/bin/glimmervoid.js +275 -0
- package/dist/chunks/adapters-Dho1VSY5.js +2 -0
- package/dist/chunks/adapters-zPDx1Xox.js +575 -0
- package/dist/chunks/agent-api-cli-D0MmtEdz.js +71 -0
- package/dist/chunks/agent-api-core-Dz0r21y9.js +103 -0
- package/dist/chunks/agent-setup-cli-B5Atxr3F.js +139 -0
- package/dist/chunks/ascii-figure-core-pDAwtlKO.js +45 -0
- package/dist/chunks/child-process-safe-DRGsp0TE.js +69 -0
- package/dist/chunks/child-process-safe-DvQjXsgz.js +2 -0
- package/dist/chunks/config-path-core-DFt-TemS.js +38 -0
- package/dist/chunks/config-store-CC8T3okC.js +2 -0
- package/dist/chunks/config-store-mm7MgzoL.js +1412 -0
- package/dist/chunks/contracts-DGkKNh9W.js +3020 -0
- package/dist/chunks/grok-DuU8xVLZ.js +436 -0
- package/dist/chunks/hook-command-core-DclEoE9e.js +14 -0
- package/dist/chunks/hook-relay-core-BHfYFnYV.js +88 -0
- package/dist/chunks/hook-tools-pSJia7ks.js +74 -0
- package/dist/chunks/ingest-core-DWI1Mbu4.js +342 -0
- package/dist/chunks/ingest-editor-core-BuI1gMF_.js +445 -0
- package/dist/chunks/loopback-post-C7C22eYi.js +79 -0
- package/dist/chunks/main-CuIZQPhZ.js +43559 -0
- package/dist/chunks/node-pty-preflight-CK1knGIR.js +162 -0
- package/dist/chunks/pair-cli-w-gCAF-1.js +110 -0
- package/dist/chunks/path-doctor-C23VAqeu.js +63 -0
- package/dist/chunks/refocus-core-BKQKllq7.js +38 -0
- package/dist/chunks/relay-stdin-CpHvLu6M.js +20 -0
- package/dist/chunks/remote-config-C2ytQwrs.js +525 -0
- package/dist/chunks/rtk-hook-core-Bl6gYHPN.js +133 -0
- package/dist/chunks/rtk-resolver-CLo-gZzw.js +21 -0
- package/dist/chunks/rtk-resolver-CMQAidlI.js +2 -0
- package/dist/chunks/runtime-paths-Ci_ksSkj.js +75 -0
- package/dist/chunks/runtime-paths-JLrZ3wyi.js +2 -0
- package/dist/chunks/sandbox-deps-Dd5-kZnf.js +67 -0
- package/dist/chunks/session-Cez8aIWg.js +164 -0
- package/dist/chunks/spawn-command-Cc40FiZI.js +134 -0
- package/dist/chunks/visions-cli-BXQFIBCX.js +98 -0
- package/dist/chunks/visions-setup-CvVnOe1r.js +1753 -0
- package/dist/client/assets/favicon-CKygeLwW.svg +7 -0
- package/dist/client/assets/index-B1MFijjb.css +1 -0
- package/dist/client/assets/index-CU1iPPdn.js +249 -0
- package/dist/client/index.html +108 -0
- package/dist/package.json +3 -0
- package/dist/scripts/postinstall-path-check.js +36 -0
- package/dist/server/index.js +92 -0
- package/dist/session/command-hook-relay.js +16 -0
- package/dist/session/hook-relay.js +24 -0
- package/dist/session/hook-tool-relay.js +107 -0
- package/dist/session/statusline-relay.js +82 -0
- package/dist/session/visions-relay.js +627 -0
- package/dist/tools/vscode-visions/extension.js +289 -0
- package/dist/tools/vscode-visions/lsp-convert.js +80 -0
- package/dist/tools/vscode-visions/package.json +32 -0
- package/dist/tools/vscode-visions/visions-lsp-core.js +112 -0
- package/package.json +96 -4
- package/scripts/postinstall.mjs +4 -0
- package/scripts/prepare-build.js +38 -0
- package/scripts/recover-handoff.mjs +82 -0
|
@@ -0,0 +1,575 @@
|
|
|
1
|
+
import { o as relayPath } from "./runtime-paths-Ci_ksSkj.js";
|
|
2
|
+
import { _ as toolDetailFieldValue, c as PendingPromptQuestion, g as firstDetailLine, o as PROMPT_DETAIL_HIDDEN_CHARACTERS } from "./session-Cez8aIWg.js";
|
|
3
|
+
import { r as execFileSync } from "./child-process-safe-DRGsp0TE.js";
|
|
4
|
+
import { n as resolveAgentCommand, t as buildAgentSpawnCommand } from "./spawn-command-Cc40FiZI.js";
|
|
5
|
+
import { i as isSpinnerChar, n as classifyAgentTitle, r as isBrailleChar, s as buildAgentEnv, t as grok } from "./grok-DuU8xVLZ.js";
|
|
6
|
+
import { t as buildHookCommand } from "./hook-command-core-DclEoE9e.js";
|
|
7
|
+
import "./contracts-DGkKNh9W.js";
|
|
8
|
+
import { n as mergeCodexPreToolUse, t as HOOK_TOOLS } from "./hook-tools-pSJia7ks.js";
|
|
9
|
+
import fs from "node:fs";
|
|
10
|
+
//#region session/core/anti-slop-prompt.ts
|
|
11
|
+
var ANTI_SLOP_NOTE = [
|
|
12
|
+
"Code hygiene for this session:",
|
|
13
|
+
"Write comments only to explain why, never narration that restates the code (no Now-we, This-function, or Step-1 openers).",
|
|
14
|
+
"Do not leave debug statements (console.log, print, debugger) in committed code.",
|
|
15
|
+
"Never swallow exceptions: no empty catch blocks and no catch that only logs and continues.",
|
|
16
|
+
"No placeholder stubs or in-a-real-implementation hand-waving; implement the real thing or stop and ask.",
|
|
17
|
+
"Do not silence type or lint errors with as-any, ts-ignore, or eslint-disable; fix the cause.",
|
|
18
|
+
"Avoid speculative wrappers and single-use indirection. Prefer deleting code over adding it."
|
|
19
|
+
].join(" ");
|
|
20
|
+
function buildAntiSlopArgs(enabled) {
|
|
21
|
+
return enabled ? ["--append-system-prompt", ANTI_SLOP_NOTE] : [];
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region session/adapters/claude-code.ts
|
|
25
|
+
var ID$1 = "claude-code";
|
|
26
|
+
var COMMAND_NAME$1 = "claude";
|
|
27
|
+
var envProfile$2 = {
|
|
28
|
+
scrub: [
|
|
29
|
+
"CLAUDECODE",
|
|
30
|
+
"CLAUDE_CODE_SSE_PORT",
|
|
31
|
+
"CLAUDE_CODE_ENTRYPOINT",
|
|
32
|
+
"CLAUDE_CODE_CHILD_SESSION"
|
|
33
|
+
],
|
|
34
|
+
set: {
|
|
35
|
+
CLAUDE_CODE_NO_FLICKER: "1",
|
|
36
|
+
FORCE_HYPERLINK: "1"
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var KNOWN_IDLE_CODEPOINTS = /* @__PURE__ */ new Set([10035]);
|
|
40
|
+
function isKnownIdleChar(char) {
|
|
41
|
+
if (!char) return false;
|
|
42
|
+
return KNOWN_IDLE_CODEPOINTS.has(char.codePointAt(0) ?? 0);
|
|
43
|
+
}
|
|
44
|
+
var titleProfile$1 = {
|
|
45
|
+
isSpinnerChar,
|
|
46
|
+
isIdleChar: isKnownIdleChar,
|
|
47
|
+
dropsLeadingAscii: true,
|
|
48
|
+
unknownGlyphHint: "If this is a new idle glyph, add it to KNOWN_IDLE_CODEPOINTS.",
|
|
49
|
+
taskTitle: {
|
|
50
|
+
readsTranscriptTitle: true,
|
|
51
|
+
genericTitles: ["Claude Code"],
|
|
52
|
+
agentSuffix: null
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
function notificationType(payload) {
|
|
56
|
+
return String(payload && (payload.notification_type || payload.notificationType) || "").toLowerCase();
|
|
57
|
+
}
|
|
58
|
+
function mapHookConfidence$1(event, payload) {
|
|
59
|
+
if (String(event || "").toLowerCase() === "notification" && notificationType(payload) === "idle_prompt") return "low";
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
function mapHookPromptKind$1(event, payload) {
|
|
63
|
+
const e = String(event || "").toLowerCase();
|
|
64
|
+
if (e === "permissionrequest") {
|
|
65
|
+
if (String(payload?.tool_name || "") === "ExitPlanMode") return "plan";
|
|
66
|
+
return "permission";
|
|
67
|
+
}
|
|
68
|
+
if (e === "notification") {
|
|
69
|
+
const t = notificationType(payload);
|
|
70
|
+
if (t === "permission_prompt") return "permission";
|
|
71
|
+
if (t.startsWith("elicitation")) return "elicitation";
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
function mapHookPromptDetail(event, payload) {
|
|
76
|
+
if (String(event || "").toLowerCase() !== "permissionrequest") return null;
|
|
77
|
+
if (mapHookPromptKind$1(event, payload) !== "permission") return null;
|
|
78
|
+
const toolName = payload?.tool_name;
|
|
79
|
+
if (typeof toolName !== "string" || !toolName) return null;
|
|
80
|
+
const fieldValue = toolDetailFieldValue(toolName, payload?.tool_input);
|
|
81
|
+
const summary = fieldValue === null ? "" : firstDetailLine(fieldValue);
|
|
82
|
+
const isComplete = isWholeBashCommandShown(toolName, payload?.tool_input, fieldValue, summary);
|
|
83
|
+
return {
|
|
84
|
+
toolName: firstDetailLine(toolName),
|
|
85
|
+
summary,
|
|
86
|
+
isComplete,
|
|
87
|
+
question: answerableQuestionOf(toolName, payload?.tool_input)
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function isRecord(value) {
|
|
91
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
92
|
+
}
|
|
93
|
+
function answerableQuestionOf(toolName, toolInput) {
|
|
94
|
+
if (toolName !== "AskUserQuestion" || !isRecord(toolInput)) return null;
|
|
95
|
+
const questions = toolInput.questions;
|
|
96
|
+
if (!Array.isArray(questions) || questions.length !== 1) return null;
|
|
97
|
+
const [entry] = questions;
|
|
98
|
+
if (!isRecord(entry) || typeof entry.question !== "string" || !Array.isArray(entry.options)) return null;
|
|
99
|
+
const optionLabels = entry.options.flatMap((option) => isRecord(option) && typeof option.label === "string" ? [option.label] : []);
|
|
100
|
+
if (optionLabels.length !== entry.options.length) return null;
|
|
101
|
+
const parsedQuestion = PendingPromptQuestion.safeParse({
|
|
102
|
+
text: entry.question,
|
|
103
|
+
options: optionLabels,
|
|
104
|
+
multiSelect: entry.multiSelect === true
|
|
105
|
+
});
|
|
106
|
+
return parsedQuestion.success ? parsedQuestion.data : null;
|
|
107
|
+
}
|
|
108
|
+
var DISPLAY_IRRELEVANT_BASH_INPUT_KEYS = /* @__PURE__ */ new Set([
|
|
109
|
+
"command",
|
|
110
|
+
"description",
|
|
111
|
+
"timeout"
|
|
112
|
+
]);
|
|
113
|
+
function hasOnlyDisplayIrrelevantBashInputKeys(toolInput) {
|
|
114
|
+
if (!toolInput || typeof toolInput !== "object") return false;
|
|
115
|
+
return Reflect.ownKeys(toolInput).every((key) => typeof key === "string" && DISPLAY_IRRELEVANT_BASH_INPUT_KEYS.has(key));
|
|
116
|
+
}
|
|
117
|
+
function isWholeBashCommandShown(toolName, toolInput, fieldValue, summary) {
|
|
118
|
+
if (toolName !== "Bash" || fieldValue === null) return false;
|
|
119
|
+
if (!hasOnlyDisplayIrrelevantBashInputKeys(toolInput)) return false;
|
|
120
|
+
if (PROMPT_DETAIL_HIDDEN_CHARACTERS.test(fieldValue)) return false;
|
|
121
|
+
return summary === fieldValue;
|
|
122
|
+
}
|
|
123
|
+
function mapHookToSignal$1(event, payload) {
|
|
124
|
+
switch (String(event || "").toLowerCase()) {
|
|
125
|
+
case "sessionstart": return "session-start";
|
|
126
|
+
case "sessionend": return "session-end";
|
|
127
|
+
case "userpromptsubmit": return "resume";
|
|
128
|
+
case "stop": return "ready";
|
|
129
|
+
case "subagentstart": return "subagent-start";
|
|
130
|
+
case "subagentstop": return "subagent-stop";
|
|
131
|
+
case "taskcreated": return "task-created";
|
|
132
|
+
case "taskcompleted": return "task-completed";
|
|
133
|
+
case "teammateidle": return "teammate-idle";
|
|
134
|
+
case "permissionrequest": return "awaiting-input";
|
|
135
|
+
case "posttooluse": {
|
|
136
|
+
const tool = String(payload?.tool_name || "");
|
|
137
|
+
if (tool === "ScheduleWakeup") return "wakeup-scheduled";
|
|
138
|
+
if (tool === "CronCreate") return "cron-created";
|
|
139
|
+
if (tool === "CronDelete") return "cron-deleted";
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
case "notification": {
|
|
143
|
+
const t = notificationType(payload);
|
|
144
|
+
if (t === "idle_prompt") return "ready";
|
|
145
|
+
if (t === "permission_prompt" || t.startsWith("elicitation")) return "awaiting-input";
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
default: return null;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
var hooks$1 = {
|
|
152
|
+
mapSignal: mapHookToSignal$1,
|
|
153
|
+
mapConfidence: mapHookConfidence$1,
|
|
154
|
+
mapPromptKind: mapHookPromptKind$1,
|
|
155
|
+
mapPromptDetail: mapHookPromptDetail,
|
|
156
|
+
injection: { kind: "settings-file" }
|
|
157
|
+
};
|
|
158
|
+
function resolveCommand$1({ platform, execFile = execFileSync, pathExists = fs.existsSync } = {}) {
|
|
159
|
+
return resolveAgentCommand({
|
|
160
|
+
name: COMMAND_NAME$1,
|
|
161
|
+
platform: platform || process.platform,
|
|
162
|
+
execFile,
|
|
163
|
+
pathExists
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function buildSpawnCommand$1({ platform, resolved, settingsArgs: injectedSettingsArgs = [], agentArgs = [] }) {
|
|
167
|
+
return buildAgentSpawnCommand({
|
|
168
|
+
name: COMMAND_NAME$1,
|
|
169
|
+
platform,
|
|
170
|
+
resolved,
|
|
171
|
+
argGroups: [injectedSettingsArgs, agentArgs]
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
function buildEnv$1(baseEnv, extraEnv, options) {
|
|
175
|
+
return buildAgentEnv(baseEnv, extraEnv, envProfile$2, options);
|
|
176
|
+
}
|
|
177
|
+
var settingsArgs = (settingsPath) => ["--settings", settingsPath];
|
|
178
|
+
function buildArgs$1({ dangerouslySkipPermissions = false, resumeSessionId = null, extraArgs = [], antiSlopPrompt = false, initialPrompt = null } = {}) {
|
|
179
|
+
const args = dangerouslySkipPermissions ? ["--dangerously-skip-permissions"] : [];
|
|
180
|
+
if (resumeSessionId) args.push("--resume", resumeSessionId);
|
|
181
|
+
if (extraArgs.length > 0) args.push(...extraArgs);
|
|
182
|
+
args.push(...buildAntiSlopArgs(antiSlopPrompt));
|
|
183
|
+
if (initialPrompt != null) args.push(initialPrompt);
|
|
184
|
+
return args;
|
|
185
|
+
}
|
|
186
|
+
var claudeCode = {
|
|
187
|
+
id: ID$1,
|
|
188
|
+
label: "Claude Code",
|
|
189
|
+
usageVendor: "claude",
|
|
190
|
+
commandName: COMMAND_NAME$1,
|
|
191
|
+
envProfile: envProfile$2,
|
|
192
|
+
titleProfile: titleProfile$1,
|
|
193
|
+
hooks: hooks$1,
|
|
194
|
+
resolveCommand: resolveCommand$1,
|
|
195
|
+
buildSpawnCommand: buildSpawnCommand$1,
|
|
196
|
+
buildEnv: buildEnv$1,
|
|
197
|
+
buildArgs: buildArgs$1,
|
|
198
|
+
settingsArgs,
|
|
199
|
+
capabilities: {
|
|
200
|
+
hooks: true,
|
|
201
|
+
awaitingInput: true,
|
|
202
|
+
backgroundAgents: true,
|
|
203
|
+
resume: true,
|
|
204
|
+
statusLine: true,
|
|
205
|
+
rtk: true,
|
|
206
|
+
saneYolo: true,
|
|
207
|
+
antiSlop: true,
|
|
208
|
+
compactQuiet: true,
|
|
209
|
+
skipPermissionsFlag: true,
|
|
210
|
+
headless: true
|
|
211
|
+
},
|
|
212
|
+
isBrailleChar,
|
|
213
|
+
isSpinnerChar,
|
|
214
|
+
isKnownIdleChar,
|
|
215
|
+
mapHookToSignal: mapHookToSignal$1,
|
|
216
|
+
mapHookConfidence: mapHookConfidence$1,
|
|
217
|
+
mapHookPromptKind: mapHookPromptKind$1,
|
|
218
|
+
mapHookPromptDetail
|
|
219
|
+
};
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region session/adapters/codex.ts
|
|
222
|
+
var ID = "codex";
|
|
223
|
+
var COMMAND_NAME = "codex";
|
|
224
|
+
var RELAY_PATH = relayPath("hook-relay");
|
|
225
|
+
var HOOK_TOOL_RELAY_PATH = relayPath("hook-tool-relay");
|
|
226
|
+
var HOOK_EVENTS = [
|
|
227
|
+
"SessionStart",
|
|
228
|
+
"SessionEnd",
|
|
229
|
+
"UserPromptSubmit",
|
|
230
|
+
"Stop",
|
|
231
|
+
"PermissionRequest"
|
|
232
|
+
];
|
|
233
|
+
var envProfile$1 = {
|
|
234
|
+
scrub: [],
|
|
235
|
+
set: {}
|
|
236
|
+
};
|
|
237
|
+
var ACTION_REQUIRED_RE = /^\[\s*[.!]\s*\]\s*Action Required\b/;
|
|
238
|
+
function classifyActionRequired(title, cwdBasename) {
|
|
239
|
+
if (!ACTION_REQUIRED_RE.test(title)) return null;
|
|
240
|
+
return title.trimEnd().endsWith(cwdBasename) ? "awaiting-input" : "unknown";
|
|
241
|
+
}
|
|
242
|
+
function classifyTitle(title, { cwdBasename = null } = {}) {
|
|
243
|
+
return classifyAgentTitle(title, { cwdBasename }, {
|
|
244
|
+
isSpinnerChar: isBrailleChar,
|
|
245
|
+
classifyAgainstCwdBasename: classifyActionRequired
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
var titleProfile = {
|
|
249
|
+
classifyTitle,
|
|
250
|
+
quietUntilFirstPrompt: true,
|
|
251
|
+
taskTitle: {
|
|
252
|
+
readsTranscriptTitle: false,
|
|
253
|
+
genericTitles: [ID],
|
|
254
|
+
agentSuffix: ` - ${ID}`
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
function mapHookToSignal(event) {
|
|
258
|
+
switch (String(event || "").toLowerCase()) {
|
|
259
|
+
case "sessionstart": return "session-start";
|
|
260
|
+
case "sessionend": return "session-end";
|
|
261
|
+
case "userpromptsubmit": return "resume";
|
|
262
|
+
case "stop": return "ready";
|
|
263
|
+
case "permissionrequest": return "awaiting-input";
|
|
264
|
+
default: return null;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function mapHookConfidence() {
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
function mapHookPromptKind(event) {
|
|
271
|
+
return String(event || "").toLowerCase() === "permissionrequest" ? "permission" : null;
|
|
272
|
+
}
|
|
273
|
+
function sessionIdOf(payload) {
|
|
274
|
+
return payload?.session_id;
|
|
275
|
+
}
|
|
276
|
+
var TRUST_BYPASS_FLAG = "--dangerously-bypass-hook-trust";
|
|
277
|
+
var PROJECT_CONFIG_CANDIDATES = Object.freeze([Object.freeze({
|
|
278
|
+
relPath: ".codex/config.toml",
|
|
279
|
+
presenceIsHit: false
|
|
280
|
+
}), Object.freeze({
|
|
281
|
+
relPath: ".codex/hooks.json",
|
|
282
|
+
presenceIsHit: true
|
|
283
|
+
})]);
|
|
284
|
+
var HOOKS_DECLARATION_RE = /^[^\S\r\n]*(?:\[{1,2}[^\S\r\n]*["']?hooks\b|hooks[.\w"'-]*[^\S\r\n]*=|extends[^\S\r\n]*=)/m;
|
|
285
|
+
function mayContributeHooks(configText) {
|
|
286
|
+
if (typeof configText !== "string") return false;
|
|
287
|
+
return HOOKS_DECLARATION_RE.test(configText);
|
|
288
|
+
}
|
|
289
|
+
function buildHookArgs({ relayPath = RELAY_PATH, events = HOOK_EVENTS, bypassHookTrust = false, hookTools = [], hookToolRelayPath = HOOK_TOOL_RELAY_PATH } = {}) {
|
|
290
|
+
const args = bypassHookTrust ? [TRUST_BYPASS_FLAG] : [];
|
|
291
|
+
const preToolUseGroups = [];
|
|
292
|
+
for (const event of events) {
|
|
293
|
+
const command = buildHookCommand(relayPath, event);
|
|
294
|
+
if (!command) return null;
|
|
295
|
+
if (event === "PreToolUse") {
|
|
296
|
+
preToolUseGroups.push(`{hooks=[{type='command',command='${command}'}]}`);
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
args.push("-c", `hooks.${event}=[{hooks=[{type='command',command='${command}'}]}]`);
|
|
300
|
+
}
|
|
301
|
+
const groups = hookTools.flatMap((tool) => {
|
|
302
|
+
const group = HOOK_TOOLS[tool.id].codexGroup(tool, hookToolRelayPath);
|
|
303
|
+
return group ? [group] : [];
|
|
304
|
+
});
|
|
305
|
+
args.push(...mergeCodexPreToolUse([...preToolUseGroups, ...groups]));
|
|
306
|
+
return args;
|
|
307
|
+
}
|
|
308
|
+
var hooks = {
|
|
309
|
+
mapSignal: mapHookToSignal,
|
|
310
|
+
mapConfidence: mapHookConfidence,
|
|
311
|
+
mapPromptKind: mapHookPromptKind,
|
|
312
|
+
injection: {
|
|
313
|
+
kind: "argv-config",
|
|
314
|
+
relayPath: RELAY_PATH,
|
|
315
|
+
events: HOOK_EVENTS,
|
|
316
|
+
buildHookArgs,
|
|
317
|
+
projectConfigCandidates: PROJECT_CONFIG_CANDIDATES,
|
|
318
|
+
mayContributeHooks
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
function resolveCommand({ platform, execFile = execFileSync, pathExists = fs.existsSync } = {}) {
|
|
322
|
+
return resolveAgentCommand({
|
|
323
|
+
name: COMMAND_NAME,
|
|
324
|
+
platform: platform || process.platform,
|
|
325
|
+
execFile,
|
|
326
|
+
pathExists
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
function buildSpawnCommand({ platform, resolved, settingsArgs = [], agentArgs = [] }) {
|
|
330
|
+
return buildAgentSpawnCommand({
|
|
331
|
+
name: COMMAND_NAME,
|
|
332
|
+
platform,
|
|
333
|
+
resolved,
|
|
334
|
+
argGroups: [settingsArgs, agentArgs]
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
function buildEnv(baseEnv, extraEnv, options) {
|
|
338
|
+
return buildAgentEnv(baseEnv, extraEnv, envProfile$1, options);
|
|
339
|
+
}
|
|
340
|
+
var UPDATE_CHECK_ARGS = ["-c", "check_for_update_on_startup=false"];
|
|
341
|
+
var SKIP_PERMISSIONS_ARGS = [
|
|
342
|
+
"-a",
|
|
343
|
+
"never",
|
|
344
|
+
"-s",
|
|
345
|
+
"workspace-write"
|
|
346
|
+
];
|
|
347
|
+
function buildArgs({ dangerouslySkipPermissions = false, resumeSessionId = null, extraArgs = [], initialPrompt = null } = {}) {
|
|
348
|
+
const args = [...UPDATE_CHECK_ARGS];
|
|
349
|
+
if (resumeSessionId) args.push("resume", resumeSessionId);
|
|
350
|
+
if (dangerouslySkipPermissions) args.push(...SKIP_PERMISSIONS_ARGS);
|
|
351
|
+
if (extraArgs.length > 0) args.push(...extraArgs);
|
|
352
|
+
if (initialPrompt != null) args.push(initialPrompt);
|
|
353
|
+
return args;
|
|
354
|
+
}
|
|
355
|
+
var codex = {
|
|
356
|
+
id: ID,
|
|
357
|
+
label: "Codex CLI",
|
|
358
|
+
usageVendor: "codex",
|
|
359
|
+
commandName: COMMAND_NAME,
|
|
360
|
+
envProfile: envProfile$1,
|
|
361
|
+
titleProfile,
|
|
362
|
+
hooks,
|
|
363
|
+
resolveCommand,
|
|
364
|
+
buildSpawnCommand,
|
|
365
|
+
buildEnv,
|
|
366
|
+
buildArgs,
|
|
367
|
+
buildHookArgs,
|
|
368
|
+
buildHookCommand,
|
|
369
|
+
mayContributeHooks,
|
|
370
|
+
PROJECT_CONFIG_CANDIDATES,
|
|
371
|
+
classifyTitle,
|
|
372
|
+
mapHookToSignal,
|
|
373
|
+
mapHookConfidence,
|
|
374
|
+
mapHookPromptKind,
|
|
375
|
+
sessionIdOf,
|
|
376
|
+
HOOK_EVENTS,
|
|
377
|
+
RELAY_PATH,
|
|
378
|
+
HOOK_TOOL_RELAY_PATH,
|
|
379
|
+
TRUST_BYPASS_FLAG,
|
|
380
|
+
SKIP_PERMISSIONS_ARGS,
|
|
381
|
+
UPDATE_CHECK_ARGS,
|
|
382
|
+
capabilities: {
|
|
383
|
+
hooks: true,
|
|
384
|
+
awaitingInput: true,
|
|
385
|
+
backgroundAgents: false,
|
|
386
|
+
resume: true,
|
|
387
|
+
statusLine: false,
|
|
388
|
+
rtk: true,
|
|
389
|
+
saneYolo: true,
|
|
390
|
+
antiSlop: false,
|
|
391
|
+
compactQuiet: false,
|
|
392
|
+
skipPermissionsFlag: true,
|
|
393
|
+
headless: true
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
//#endregion
|
|
397
|
+
//#region session/adapters/custom.ts
|
|
398
|
+
var envProfile = {
|
|
399
|
+
scrub: [],
|
|
400
|
+
set: {}
|
|
401
|
+
};
|
|
402
|
+
var TITLE_ONLY_CAPABILITIES = Object.freeze({
|
|
403
|
+
hooks: false,
|
|
404
|
+
awaitingInput: false,
|
|
405
|
+
backgroundAgents: false,
|
|
406
|
+
resume: false,
|
|
407
|
+
statusLine: false,
|
|
408
|
+
rtk: false,
|
|
409
|
+
saneYolo: false,
|
|
410
|
+
antiSlop: false,
|
|
411
|
+
compactQuiet: false,
|
|
412
|
+
skipPermissionsFlag: false,
|
|
413
|
+
headless: false
|
|
414
|
+
});
|
|
415
|
+
function createCustomAdapter(declaration) {
|
|
416
|
+
const declaredArgs = Object.freeze([...declaration.args]);
|
|
417
|
+
const busyTitle = declaration.busyTitle?.trim() || null;
|
|
418
|
+
const idleTitle = declaration.idleTitle?.trim() || null;
|
|
419
|
+
function classifyTitle(title, { cwdBasename = null } = {}) {
|
|
420
|
+
return classifyAgentTitle(title, { cwdBasename }, {
|
|
421
|
+
isSpinnerChar,
|
|
422
|
+
busyTitle,
|
|
423
|
+
idleTitle
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
const titleProfile = {
|
|
427
|
+
classifyTitle,
|
|
428
|
+
taskTitle: {
|
|
429
|
+
readsTranscriptTitle: false,
|
|
430
|
+
genericTitles: [declaration.id],
|
|
431
|
+
agentSuffix: ` - ${declaration.id}`
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
function resolveCommand({ platform, execFile = execFileSync, pathExists = fs.existsSync } = {}) {
|
|
435
|
+
return resolveAgentCommand({
|
|
436
|
+
name: declaration.command,
|
|
437
|
+
platform: platform || process.platform,
|
|
438
|
+
execFile,
|
|
439
|
+
pathExists
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
function buildSpawnCommand({ platform, resolved, settingsArgs = [], agentArgs = [] }) {
|
|
443
|
+
return buildAgentSpawnCommand({
|
|
444
|
+
name: declaration.command,
|
|
445
|
+
platform,
|
|
446
|
+
resolved,
|
|
447
|
+
argGroups: [settingsArgs, agentArgs]
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
function buildEnv(baseEnv, extraEnv, options) {
|
|
451
|
+
return buildAgentEnv(baseEnv, extraEnv, envProfile, options);
|
|
452
|
+
}
|
|
453
|
+
function buildArgs({ initialPrompt = null } = {}) {
|
|
454
|
+
const args = [...declaredArgs];
|
|
455
|
+
if (initialPrompt != null) args.push(initialPrompt);
|
|
456
|
+
return args;
|
|
457
|
+
}
|
|
458
|
+
return {
|
|
459
|
+
id: declaration.id,
|
|
460
|
+
label: declaration.label,
|
|
461
|
+
usageVendor: declaration.id,
|
|
462
|
+
commandName: declaration.command,
|
|
463
|
+
envProfile,
|
|
464
|
+
titleProfile,
|
|
465
|
+
hooks: null,
|
|
466
|
+
capabilities: TITLE_ONLY_CAPABILITIES,
|
|
467
|
+
resolveCommand,
|
|
468
|
+
buildSpawnCommand,
|
|
469
|
+
buildEnv,
|
|
470
|
+
buildArgs
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
//#endregion
|
|
474
|
+
//#region session/adapters/index.ts
|
|
475
|
+
var DEFAULT_AGENT_ID = claudeCode.id;
|
|
476
|
+
var adapterEntries = [
|
|
477
|
+
[claudeCode.id, claudeCode],
|
|
478
|
+
[codex.id, codex],
|
|
479
|
+
[grok.id, grok]
|
|
480
|
+
];
|
|
481
|
+
var ADAPTERS = new Map(adapterEntries);
|
|
482
|
+
var customAdapters = /* @__PURE__ */ new Map();
|
|
483
|
+
var customAgentFingerprints = /* @__PURE__ */ new Map();
|
|
484
|
+
var resolvedCommands = /* @__PURE__ */ new Map();
|
|
485
|
+
function declarationFingerprint(declaration) {
|
|
486
|
+
return JSON.stringify([
|
|
487
|
+
declaration.command,
|
|
488
|
+
declaration.args,
|
|
489
|
+
declaration.idleTitle ?? null,
|
|
490
|
+
declaration.busyTitle ?? null
|
|
491
|
+
]);
|
|
492
|
+
}
|
|
493
|
+
function customAgentFingerprint(agentId) {
|
|
494
|
+
if (agentId == null) return null;
|
|
495
|
+
return customAgentFingerprints.get(agentId) ?? null;
|
|
496
|
+
}
|
|
497
|
+
function setCustomAgents(declared) {
|
|
498
|
+
const nextFingerprintById = /* @__PURE__ */ new Map();
|
|
499
|
+
for (const declaration of declared) nextFingerprintById.set(declaration.id, declarationFingerprint(declaration));
|
|
500
|
+
for (const [customId, previousFingerprint] of customAgentFingerprints) {
|
|
501
|
+
if (nextFingerprintById.get(customId) === previousFingerprint) continue;
|
|
502
|
+
resolvedCommands.delete(customId);
|
|
503
|
+
}
|
|
504
|
+
customAdapters.clear();
|
|
505
|
+
customAgentFingerprints.clear();
|
|
506
|
+
for (const declaration of declared) {
|
|
507
|
+
customAdapters.set(declaration.id, createCustomAdapter(declaration));
|
|
508
|
+
customAgentFingerprints.set(declaration.id, nextFingerprintById.get(declaration.id) ?? declarationFingerprint(declaration));
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
function hookProfileOf(adapter) {
|
|
512
|
+
if (!adapter.capabilities.hooks) return null;
|
|
513
|
+
return adapter.hooks;
|
|
514
|
+
}
|
|
515
|
+
function listAgentIds() {
|
|
516
|
+
return [...ADAPTERS.keys(), ...customAdapters.keys()];
|
|
517
|
+
}
|
|
518
|
+
function isKnownAgentId(agentId) {
|
|
519
|
+
if (typeof agentId !== "string") return false;
|
|
520
|
+
return ADAPTERS.has(agentId) || customAdapters.has(agentId);
|
|
521
|
+
}
|
|
522
|
+
function getAdapter(agentId) {
|
|
523
|
+
if (agentId == null) return ADAPTERS.get(DEFAULT_AGENT_ID) ?? null;
|
|
524
|
+
return ADAPTERS.get(agentId) ?? customAdapters.get(agentId) ?? null;
|
|
525
|
+
}
|
|
526
|
+
function resolveAdapter(agentId, { warn = console.warn, label = "" } = {}) {
|
|
527
|
+
const adapter = getAdapter(agentId);
|
|
528
|
+
if (adapter) return adapter;
|
|
529
|
+
warn(`[glimmervoid]${label ? ` ${label}:` : ""} unknown agent "${agentId}", falling back to ${DEFAULT_AGENT_ID}`);
|
|
530
|
+
return ADAPTERS.get(DEFAULT_AGENT_ID) ?? null;
|
|
531
|
+
}
|
|
532
|
+
function commandFor(adapterOrId, options) {
|
|
533
|
+
const adapter = typeof adapterOrId === "string" ? resolveAdapter(adapterOrId) : adapterOrId;
|
|
534
|
+
if (!adapter) throw new TypeError("default agent adapter is unavailable");
|
|
535
|
+
const cached = resolvedCommands.get(adapter.id);
|
|
536
|
+
if (cached) return cached;
|
|
537
|
+
const resolved = adapter.resolveCommand(options);
|
|
538
|
+
resolvedCommands.set(adapter.id, resolved);
|
|
539
|
+
return resolved;
|
|
540
|
+
}
|
|
541
|
+
function describeAgentResolvability(agentId) {
|
|
542
|
+
const adapter = getAdapter(agentId);
|
|
543
|
+
if (!adapter) return {
|
|
544
|
+
label: agentId,
|
|
545
|
+
path: null,
|
|
546
|
+
resolvable: false
|
|
547
|
+
};
|
|
548
|
+
const resolvedPath = commandFor(adapter)?.path ?? null;
|
|
549
|
+
return {
|
|
550
|
+
label: adapter.label || agentId,
|
|
551
|
+
path: resolvedPath,
|
|
552
|
+
resolvable: !!resolvedPath
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
function cachedAgentResolvability(agentId) {
|
|
556
|
+
const adapter = getAdapter(agentId);
|
|
557
|
+
if (!adapter) return {
|
|
558
|
+
label: agentId,
|
|
559
|
+
path: null,
|
|
560
|
+
resolvable: false
|
|
561
|
+
};
|
|
562
|
+
const cached = resolvedCommands.get(adapter.id);
|
|
563
|
+
if (!cached) return {
|
|
564
|
+
label: adapter.label || agentId,
|
|
565
|
+
path: null,
|
|
566
|
+
resolvable: null
|
|
567
|
+
};
|
|
568
|
+
return {
|
|
569
|
+
label: adapter.label || agentId,
|
|
570
|
+
path: cached.path ?? null,
|
|
571
|
+
resolvable: !!cached.path
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
//#endregion
|
|
575
|
+
export { describeAgentResolvability as a, isKnownAgentId as c, setCustomAgents as d, claudeCode as f, customAgentFingerprint as i, listAgentIds as l, cachedAgentResolvability as n, getAdapter as o, commandFor as r, hookProfileOf as s, DEFAULT_AGENT_ID as t, resolveAdapter as u };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { n as AGENT_URL_ENV } from "./session-Cez8aIWg.js";
|
|
2
|
+
import { i as resolveHookTarget } from "./hook-relay-core-BHfYFnYV.js";
|
|
3
|
+
import { a as isAgentApiVerb } from "./agent-api-core-Dz0r21y9.js";
|
|
4
|
+
//#region server/agent-api-cli.ts
|
|
5
|
+
var AGENT_PATH_PREFIX = "/agent/";
|
|
6
|
+
var BODY_BUILDERS = {
|
|
7
|
+
spawn: (rest) => {
|
|
8
|
+
const prompt = rest.join(" ").trim();
|
|
9
|
+
return prompt ? { prompt } : null;
|
|
10
|
+
},
|
|
11
|
+
attention: (rest) => {
|
|
12
|
+
const note = rest.join(" ").trim();
|
|
13
|
+
return note ? { note } : null;
|
|
14
|
+
},
|
|
15
|
+
board: () => ({})
|
|
16
|
+
};
|
|
17
|
+
function bodySaysOk(text) {
|
|
18
|
+
try {
|
|
19
|
+
const parsed = JSON.parse(text);
|
|
20
|
+
return typeof parsed === "object" && parsed !== null && parsed.ok === true;
|
|
21
|
+
} catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function verbEndpoint(rawUrl, verb) {
|
|
26
|
+
const target = resolveHookTarget(rawUrl, verb, AGENT_PATH_PREFIX);
|
|
27
|
+
if (!target.url) return { ok: false };
|
|
28
|
+
const endpoint = new URL(target.url);
|
|
29
|
+
const token = endpoint.searchParams.get("t") || "";
|
|
30
|
+
endpoint.search = "";
|
|
31
|
+
return {
|
|
32
|
+
ok: true,
|
|
33
|
+
endpoint,
|
|
34
|
+
token
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
async function runAgentApiCli(args) {
|
|
38
|
+
const verb = args[0];
|
|
39
|
+
if (!verb || !isAgentApiVerb(verb)) {
|
|
40
|
+
console.error(`glimmervoid: ${verb || "that"} is not an agent command`);
|
|
41
|
+
return 1;
|
|
42
|
+
}
|
|
43
|
+
const body = BODY_BUILDERS[verb](args.slice(1));
|
|
44
|
+
if (!body) {
|
|
45
|
+
console.error(`glimmervoid ${verb}: this command needs text, for example "glimmervoid ${verb} check the failing test"`);
|
|
46
|
+
return 1;
|
|
47
|
+
}
|
|
48
|
+
const rawUrl = process.env[AGENT_URL_ENV];
|
|
49
|
+
if (!rawUrl) {
|
|
50
|
+
console.error(`glimmervoid: ${AGENT_URL_ENV} is not set, so this is not a Glimmervoid session with the agent API turned on`);
|
|
51
|
+
return 1;
|
|
52
|
+
}
|
|
53
|
+
const target = verbEndpoint(rawUrl, verb);
|
|
54
|
+
if (!target.ok) {
|
|
55
|
+
console.error(`glimmervoid: ${AGENT_URL_ENV} must be a loopback http url under ${AGENT_PATH_PREFIX}, so nothing was sent`);
|
|
56
|
+
return 1;
|
|
57
|
+
}
|
|
58
|
+
const response = await fetch(target.endpoint, {
|
|
59
|
+
method: "POST",
|
|
60
|
+
headers: {
|
|
61
|
+
"content-type": "application/json",
|
|
62
|
+
authorization: `Bearer ${target.token}`
|
|
63
|
+
},
|
|
64
|
+
body: JSON.stringify(body)
|
|
65
|
+
});
|
|
66
|
+
const text = await response.text();
|
|
67
|
+
console.log(text);
|
|
68
|
+
return response.ok && bodySaysOk(text) ? 0 : 1;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { runAgentApiCli };
|