@mainwave/cli 0.11.0 → 0.13.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/README.md +203 -16
- package/dist/adapters/claude-code.js +3 -3
- package/dist/adapters/claude-desktop.js +35 -1
- package/dist/adapters/codex-cli.js +16 -16
- package/dist/adapters/cursor.js +7 -2
- package/dist/adapters/kiro.js +13 -8
- package/dist/commands.js +219 -0
- package/dist/core/apply.js +47 -8
- package/dist/core/auth-commands.js +2 -1
- package/dist/core/codecs/kiro-hooks-json.js +1 -1
- package/dist/core/codex-trust.js +178 -0
- package/dist/core/doctor.js +144 -12
- package/dist/core/entry-script.js +2 -3
- package/dist/core/format.js +0 -1
- package/dist/core/hook-copies.js +157 -0
- package/dist/core/install-hooks.js +198 -15
- package/dist/core/interview.js +36 -16
- package/dist/core/markers.js +209 -44
- package/dist/core/redaction.js +188 -0
- package/dist/core/skills.js +3 -11
- package/dist/core/status.js +21 -1
- package/dist/core/store.js +254 -4
- package/dist/core/wizard.js +91 -6
- package/dist/main.js +173 -163
- package/hooks/codex-turns.mjs +584 -0
- package/hooks/kiro-otlp.mjs +10 -1
- package/hooks/mainwave-hook.mjs +27 -3
- package/hooks/marker-core.mjs +66 -8
- package/hooks/matchers.json +98 -1
- package/hooks/redaction-data.mjs +209 -0
- package/hooks/redaction-json.mjs +215 -0
- package/hooks/redaction-pattern.mjs +503 -0
- package/hooks/redaction.d.mts +84 -0
- package/hooks/redaction.mjs +701 -0
- package/hooks/vocabulary.mjs +41 -2
- package/package.json +3 -1
- package/skills/mainwave-instrument/SKILL.md +24 -6
- package/skills/mainwave-instrument/reference/frameworks.md +4 -2
- package/skills/mainwave-instrument/reference/troubleshooting.md +4 -0
- package/skills/mainwave-instrument-node/SKILL.md +83 -38
- package/skills/mainwave-instrument-node/reference/api.md +16 -16
- package/skills/mainwave-instrument-node/reference/frameworks.md +42 -27
- package/skills/mainwave-instrument-node/reference/troubleshooting.md +11 -7
|
@@ -1,13 +1,26 @@
|
|
|
1
|
+
import { promises as fs } from 'node:fs';
|
|
1
2
|
import { basename, dirname, isAbsolute, resolve } from 'node:path';
|
|
2
3
|
import { claudeConfigDir } from '../adapters/claude-code.js';
|
|
3
4
|
import { hasPath } from './detect.js';
|
|
4
5
|
import { activeHierarchy } from './effective-settings.js';
|
|
6
|
+
import { refreshFlatCopiesForOrgPacks } from './hook-copies.js';
|
|
5
7
|
import { isManagedLayer } from './layer-policy.js';
|
|
6
|
-
import { bootstrapGroup, buildHookGroups, DEFAULT_MARKER_TOOL, groupEvent, isBootstrapCommand, isDelivered, managedDeliversEntry, managedHooksDir, managedMarkerDeliveries, matchersForTool, packagedHooksDir, prepareMarkersFile, readPackagedMatchers, routeKeyOf, scanForMarkers, syncManagedHooks, syncOrgDelivered, userHookGroups, } from './markers.js';
|
|
8
|
+
import { BOOTSTRAP_KEY, bootstrapGroup, buildHookGroups, DEFAULT_MARKER_TOOL, groupEvent, isBootstrapCommand, installedHooksDir, isDelivered, managedDeliversEntry, managedHooksDir, managedMarkerDeliveries, managedRedactionPacks, managedRunsBootstrap, matchersForTool, ownedGroupsInDoc, packagedHooksDir, prepareMarkersFile, readEntryVersion, readPackagedMatchers, routeKeyOf, scanForMarkers, syncManagedHooks, syncOrgDelivered, userHookGroups, } from './markers.js';
|
|
9
|
+
import { REDACTION_PACKS } from '../../hooks/redaction.mjs';
|
|
7
10
|
import { applyUpdate } from './settings.js';
|
|
8
|
-
import { readSettings } from './store.js';
|
|
11
|
+
import { KEEP_ORG_PACKS, hasOrgEntry, readSettings, settingsPath, syncOrgRedaction, } from './store.js';
|
|
9
12
|
import { VERSION } from './version.js';
|
|
10
|
-
|
|
13
|
+
const ROUTES_BEFORE_RECORD = [
|
|
14
|
+
BOOTSTRAP_KEY,
|
|
15
|
+
'UserPromptSubmit',
|
|
16
|
+
'PostToolUse:gh',
|
|
17
|
+
'PostToolUse:glab',
|
|
18
|
+
'PostToolUse:bash',
|
|
19
|
+
'PostToolUse:git',
|
|
20
|
+
'PostToolUse:linear',
|
|
21
|
+
'PostToolUse:jira',
|
|
22
|
+
'StopFailure',
|
|
23
|
+
];
|
|
11
24
|
export const PAYLOAD_EVENTS = [
|
|
12
25
|
'SessionStart',
|
|
13
26
|
'UserPromptSubmit',
|
|
@@ -15,8 +28,11 @@ export const PAYLOAD_EVENTS = [
|
|
|
15
28
|
'StopFailure',
|
|
16
29
|
];
|
|
17
30
|
const payloadGroup = ({ event: _event, ...group }) => group;
|
|
18
|
-
export const managedPayloadHooks = (matchers) => {
|
|
19
|
-
const groups = [
|
|
31
|
+
export const managedPayloadHooks = (matchers, redactionPacks = []) => {
|
|
32
|
+
const groups = [
|
|
33
|
+
bootstrapGroup(redactionPacks),
|
|
34
|
+
...buildHookGroups(matchersForTool(matchers), 'claude-code'),
|
|
35
|
+
];
|
|
20
36
|
const under = (event) => groups.filter((g) => groupEvent(g) === event).map(payloadGroup);
|
|
21
37
|
return Object.fromEntries(PAYLOAD_EVENTS.map((e) => [e, under(e)]));
|
|
22
38
|
};
|
|
@@ -24,10 +40,15 @@ const defaultPaths = () => ({
|
|
|
24
40
|
srcDir: packagedHooksDir(),
|
|
25
41
|
destDir: managedHooksDir(),
|
|
26
42
|
});
|
|
27
|
-
export const installHooks = async (adapter, paths = defaultPaths()) => {
|
|
43
|
+
export const installHooks = async (adapter, paths = defaultPaths(), { redactionPacks } = {}) => {
|
|
28
44
|
const all = await readPackagedMatchers(paths.srcDir);
|
|
29
|
-
const updated = await syncManagedHooks(all, paths.srcDir, paths.destDir, paths.version ?? VERSION, paths.nodePath);
|
|
30
45
|
if (adapter === undefined) {
|
|
46
|
+
const held = redactionPacks !== undefined && (await readEntryVersion(paths.destDir)) === undefined
|
|
47
|
+
? 'config-dir'
|
|
48
|
+
: undefined;
|
|
49
|
+
const updated = held !== undefined
|
|
50
|
+
? []
|
|
51
|
+
: await syncManagedHooks(all, paths.srcDir, paths.destDir, paths.version ?? VERSION, paths.nodePath);
|
|
31
52
|
return {
|
|
32
53
|
updated,
|
|
33
54
|
destDir: paths.destDir,
|
|
@@ -35,16 +56,61 @@ export const installHooks = async (adapter, paths = defaultPaths()) => {
|
|
|
35
56
|
removedFromUser: 0,
|
|
36
57
|
addedToUser: 0,
|
|
37
58
|
userSettings: undefined,
|
|
59
|
+
...(held === undefined ? {} : { held }),
|
|
38
60
|
};
|
|
39
61
|
}
|
|
40
62
|
const scans = await scanForMarkers((await activeHierarchy(adapter)).filter(isManagedLayer));
|
|
63
|
+
const configDir = dirname(adapter.paths.global);
|
|
64
|
+
const orgPacks = managedRedactionPacks(scans);
|
|
65
|
+
const recorded = orgPacks !== undefined && orgPacks.length > 0 ? orgPacks : undefined;
|
|
66
|
+
const keep = recorded === undefined && !managedRunsBootstrap(scans);
|
|
67
|
+
const hasEntry = (await readEntryVersion(paths.destDir)) !== undefined;
|
|
68
|
+
if (redactionPacks !== undefined && recorded === undefined && !hasEntry) {
|
|
69
|
+
return {
|
|
70
|
+
updated: [],
|
|
71
|
+
destDir: paths.destDir,
|
|
72
|
+
managedDelivers: false,
|
|
73
|
+
removedFromUser: 0,
|
|
74
|
+
addedToUser: 0,
|
|
75
|
+
userSettings: undefined,
|
|
76
|
+
held: 'unreadable',
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const settingsFile = paths.settingsFile ?? settingsPath();
|
|
80
|
+
let sync = 'unchanged';
|
|
81
|
+
let recordProblem;
|
|
82
|
+
const hadRecord = keep && (await hasOrgEntry(configDir, settingsFile).catch(() => false));
|
|
83
|
+
try {
|
|
84
|
+
sync = await syncOrgRedaction(configDir, keep ? KEEP_ORG_PACKS : recorded, settingsFile);
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
if (!hasEntry)
|
|
88
|
+
throw err;
|
|
89
|
+
recordProblem = err instanceof Error ? err.message : String(err);
|
|
90
|
+
}
|
|
91
|
+
const flat = recorded === undefined || recordProblem !== undefined
|
|
92
|
+
? { flat: [] }
|
|
93
|
+
: await refreshFlatCopiesForOrgPacks(paths.flatDir ?? installedHooksDir(), paths.srcDir);
|
|
94
|
+
const orgRedaction = {
|
|
95
|
+
packs: recorded,
|
|
96
|
+
sync,
|
|
97
|
+
flat: flat.flat,
|
|
98
|
+
...(keep ? { kept: { hadRecord } } : {}),
|
|
99
|
+
...(recordProblem === undefined ? {} : { recordProblem }),
|
|
100
|
+
...(flat.failed !== undefined
|
|
101
|
+
? { flatProblem: flat.failed }
|
|
102
|
+
: flat.skipped !== undefined
|
|
103
|
+
? { flatProblem: flat.skipped.map((b) => `${b.script} ${b.reason}`).join('; ') }
|
|
104
|
+
: {}),
|
|
105
|
+
};
|
|
106
|
+
const updated = await syncManagedHooks(all, paths.srcDir, paths.destDir, paths.version ?? VERSION, paths.nodePath);
|
|
41
107
|
const delivered = managedMarkerDeliveries(scans);
|
|
42
|
-
await syncOrgDelivered(managedDeliversEntry(scans),
|
|
108
|
+
await syncOrgDelivered(managedDeliversEntry(scans), configDir, paths.destDir);
|
|
43
109
|
const managedDelivers = delivered.size > 0;
|
|
44
110
|
const stored = paths.stored ?? (await readSettings().catch(() => ({}))).hooks ?? {};
|
|
45
111
|
const userSettings = adapter.paths.global;
|
|
46
112
|
const disclosed = stored.events?.[adapter.name]?.[userSettings];
|
|
47
|
-
const disclosedRoutes = stored.routes?.[adapter.name]?.[userSettings];
|
|
113
|
+
const disclosedRoutes = stored.routes?.[adapter.name]?.[userSettings] ?? ROUTES_BEFORE_RECORD;
|
|
48
114
|
let removedFromUser = 0;
|
|
49
115
|
let addedToUser = 0;
|
|
50
116
|
if ((managedDelivers || disclosed !== undefined) && hasPath(userSettings)) {
|
|
@@ -53,10 +119,7 @@ export const installHooks = async (adapter, paths = defaultPaths()) => {
|
|
|
53
119
|
: userHookGroups(matchersForTool(all, DEFAULT_MARKER_TOOL), { markers: stored.markers?.[adapter.name] ?? true }, delivered, DEFAULT_MARKER_TOOL).filter((g) => disclosed.includes(groupEvent(g)) &&
|
|
54
120
|
g.hooks.every((h) => {
|
|
55
121
|
const key = routeKeyOf(h.command);
|
|
56
|
-
return
|
|
57
|
-
(disclosedRoutes === undefined
|
|
58
|
-
? !ROUTES_BEFORE_RECORD_EXCLUDES.includes(key)
|
|
59
|
-
: disclosedRoutes.includes(key)));
|
|
122
|
+
return key === undefined || disclosedRoutes.includes(key);
|
|
60
123
|
}));
|
|
61
124
|
const { update, plan } = await prepareMarkersFile(userSettings, adapter.codec, groups, 0o600, (ownership, group) => ownership === 'cli' &&
|
|
62
125
|
((!isBootstrapCommand(group.command) &&
|
|
@@ -75,27 +138,97 @@ export const installHooks = async (adapter, paths = defaultPaths()) => {
|
|
|
75
138
|
removedFromUser,
|
|
76
139
|
addedToUser,
|
|
77
140
|
userSettings,
|
|
141
|
+
orgRedaction,
|
|
78
142
|
};
|
|
79
143
|
};
|
|
144
|
+
export const installCodexHooks = async (adapter, paths = defaultPaths()) => {
|
|
145
|
+
const hooksFile = adapter.markers?.hooksFile;
|
|
146
|
+
if (hooksFile === undefined)
|
|
147
|
+
throw new Error(`${adapter.name} has no hooks file`);
|
|
148
|
+
const all = await readPackagedMatchers(paths.srcDir);
|
|
149
|
+
const updated = await syncManagedHooks(all, paths.srcDir, paths.destDir, paths.version ?? VERSION, paths.nodePath);
|
|
150
|
+
const stored = paths.stored ?? (await readSettings().catch(() => ({}))).hooks ?? {};
|
|
151
|
+
const disclosed = stored.events?.[adapter.name]?.[hooksFile.path];
|
|
152
|
+
if (disclosed === undefined || !hasPath(hooksFile.path)) {
|
|
153
|
+
return { updated, destDir: paths.destDir, addedToUser: 0, userSettings: undefined };
|
|
154
|
+
}
|
|
155
|
+
const disclosedRoutes = stored.routes?.[adapter.name]?.[hooksFile.path] ?? ROUTES_BEFORE_RECORD;
|
|
156
|
+
const wanted = userHookGroups(matchersForTool(all, adapter.markers?.runtimeTool ?? DEFAULT_MARKER_TOOL), { markers: stored.markers?.[adapter.name] ?? true }, new Set(), adapter.markers?.runtimeTool).filter((g) => disclosed.includes(groupEvent(g)) &&
|
|
157
|
+
g.hooks.every((h) => {
|
|
158
|
+
const key = routeKeyOf(h.command, adapter.markers?.runtimeTool);
|
|
159
|
+
return key === undefined || disclosedRoutes.includes(key);
|
|
160
|
+
}));
|
|
161
|
+
const body = await fs.readFile(hooksFile.path, 'utf8');
|
|
162
|
+
const present = new Set(ownedGroupsInDoc(hooksFile.codec.parse(body, hooksFile.path))
|
|
163
|
+
.filter((g) => g.ownership === 'cli')
|
|
164
|
+
.map((g) => routeKeyOf(g.command, adapter.markers?.runtimeTool)));
|
|
165
|
+
const missing = wanted.filter((g) => !present.has(routeKeyOf(g.hooks[0]?.command ?? '', adapter.markers?.runtimeTool)));
|
|
166
|
+
let addedToUser = 0;
|
|
167
|
+
if (missing.length > 0) {
|
|
168
|
+
const { update, plan } = await prepareMarkersFile(hooksFile.path, hooksFile.codec, missing, 0o600, () => false);
|
|
169
|
+
if (plan.changed) {
|
|
170
|
+
await applyUpdate(update);
|
|
171
|
+
addedToUser = plan.added.length;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return { updated, destDir: paths.destDir, addedToUser, userSettings: hooksFile.path };
|
|
175
|
+
};
|
|
176
|
+
export const runInstallCodexHooks = async (adapter, options = {}, paths) => {
|
|
177
|
+
let result;
|
|
178
|
+
try {
|
|
179
|
+
result = await installCodexHooks(adapter, paths);
|
|
180
|
+
}
|
|
181
|
+
catch (err) {
|
|
182
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
183
|
+
process.stderr.write(`mainwave-cli install-hooks: ${reason}\n`);
|
|
184
|
+
return 1;
|
|
185
|
+
}
|
|
186
|
+
if (options.quiet)
|
|
187
|
+
return 0;
|
|
188
|
+
console.log(result.updated.length > 0
|
|
189
|
+
? `Installed Mainwave hook scripts in ${result.destDir}: ${result.updated.join(', ')}`
|
|
190
|
+
: `Mainwave hook scripts in ${result.destDir} are already current.`);
|
|
191
|
+
if (result.addedToUser > 0) {
|
|
192
|
+
console.log(`Added ${result.addedToUser} Mainwave hook${result.addedToUser === 1 ? '' : 's'} to ${result.userSettings}. ` +
|
|
193
|
+
'Codex skips them until you approve them in /hooks.');
|
|
194
|
+
}
|
|
195
|
+
return 0;
|
|
196
|
+
};
|
|
80
197
|
export const runInstallHooks = async (adapter, options = {}, paths) => {
|
|
81
198
|
let result;
|
|
82
199
|
try {
|
|
83
|
-
result = await installHooks(adapter, paths);
|
|
200
|
+
result = await installHooks(adapter, paths, { redactionPacks: options.redactionPacks });
|
|
84
201
|
}
|
|
85
202
|
catch (err) {
|
|
86
203
|
const reason = err instanceof Error ? err.message : String(err);
|
|
87
204
|
process.stderr.write(`mainwave-cli install-hooks: ${reason}\n`);
|
|
88
205
|
return 1;
|
|
89
206
|
}
|
|
207
|
+
if (result.orgRedaction?.recordProblem !== undefined) {
|
|
208
|
+
process.stderr.write(`mainwave-cli install-hooks: ${result.orgRedaction.recordProblem}\n`);
|
|
209
|
+
}
|
|
90
210
|
if (options.quiet)
|
|
91
211
|
return 0;
|
|
92
212
|
const dest = result.destDir;
|
|
213
|
+
if (result.held === 'config-dir') {
|
|
214
|
+
console.log("CLAUDE_CODE_SUBPROCESS_ENV_SCRUB hid this session's CLAUDE_CONFIG_DIR and the hook input " +
|
|
215
|
+
"didn't name it, so your organization's redaction packs couldn't be recorded. No hooks were " +
|
|
216
|
+
'installed; the next session start that names its config dir installs them.');
|
|
217
|
+
return 0;
|
|
218
|
+
}
|
|
219
|
+
if (result.held === 'unreadable') {
|
|
220
|
+
console.log('--redaction-packs names packs, but no managed settings source this command reads names ' +
|
|
221
|
+
'them (it reads neither an OS-level policy nor a server-managed cache that has not been ' +
|
|
222
|
+
'written yet), so nothing was installed.');
|
|
223
|
+
return 0;
|
|
224
|
+
}
|
|
93
225
|
console.log(result.updated.length > 0
|
|
94
226
|
? `Installed Mainwave hook scripts in ${dest}: ${result.updated.join(', ')}`
|
|
95
227
|
: `Mainwave hook scripts in ${dest} are already current.`);
|
|
96
228
|
if (result.userSettings === undefined) {
|
|
97
229
|
console.log("CLAUDE_CODE_SUBPROCESS_ENV_SCRUB hid this session's CLAUDE_CONFIG_DIR and the hook input " +
|
|
98
|
-
"didn't name it, so no Claude config dir's settings were changed
|
|
230
|
+
"didn't name it, so no Claude config dir's settings were changed" +
|
|
231
|
+
(options.redactionPacks === undefined ? '.' : ', and no redaction packs were recorded.'));
|
|
99
232
|
}
|
|
100
233
|
else if (result.removedFromUser > 0 || result.addedToUser > 0) {
|
|
101
234
|
console.log(`Updated the Mainwave hooks in ${result.userSettings}` +
|
|
@@ -106,8 +239,58 @@ export const runInstallHooks = async (adapter, options = {}, paths) => {
|
|
|
106
239
|
else if (!result.managedDelivers) {
|
|
107
240
|
console.log('No managed settings deliver the Mainwave hooks, so your user settings were left as they are.');
|
|
108
241
|
}
|
|
242
|
+
if (result.orgRedaction !== undefined) {
|
|
243
|
+
for (const line of orgRedactionLines(result.orgRedaction, options.redactionPacks)) {
|
|
244
|
+
console.log(line);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
109
247
|
return 0;
|
|
110
248
|
};
|
|
249
|
+
const orgRedactionLines = (org, asked) => {
|
|
250
|
+
const out = [];
|
|
251
|
+
const known = REDACTION_PACKS;
|
|
252
|
+
if (org.packs === undefined) {
|
|
253
|
+
if (org.kept !== undefined) {
|
|
254
|
+
const tail = org.kept.hadRecord
|
|
255
|
+
? 'so the recorded packs were kept.'
|
|
256
|
+
: 'so no packs are recorded, so none apply.';
|
|
257
|
+
if (asked !== undefined) {
|
|
258
|
+
out.push('--redaction-packs names packs, but no managed settings source this command reads names ' +
|
|
259
|
+
`them, ${tail}`);
|
|
260
|
+
}
|
|
261
|
+
else if (org.kept.hadRecord) {
|
|
262
|
+
out.push(`No managed settings source this command reads runs the Mainwave bootstrap, ${tail}`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
else if (asked !== undefined) {
|
|
266
|
+
out.push("--redaction-packs is read from your organization's managed settings, which name none, " +
|
|
267
|
+
'so no redaction packs were recorded.');
|
|
268
|
+
}
|
|
269
|
+
if (org.sync === 'cleared') {
|
|
270
|
+
out.push("Your organization's managed settings no longer set redaction packs; cleared them.");
|
|
271
|
+
}
|
|
272
|
+
return out;
|
|
273
|
+
}
|
|
274
|
+
if (org.sync === 'set') {
|
|
275
|
+
out.push(`Recorded your organization's redaction packs: ${org.packs.join(', ')}.`);
|
|
276
|
+
}
|
|
277
|
+
if (asked !== undefined && asked.join(',') !== org.packs.join(',')) {
|
|
278
|
+
out.push(`Your organization's managed settings name ${org.packs.join(', ')}; those apply, not --redaction-packs.`);
|
|
279
|
+
}
|
|
280
|
+
const unknown = org.packs.filter((name) => !known.includes(name));
|
|
281
|
+
if (unknown.length > 0) {
|
|
282
|
+
out.push(`This release has no redaction pack ${unknown.join(', ')}, so the Mainwave hooks send nothing ` +
|
|
283
|
+
'until one that has them is installed.');
|
|
284
|
+
}
|
|
285
|
+
if (org.flat.length > 0) {
|
|
286
|
+
out.push('Refreshed the Cursor and Kiro hook copies so they apply the packs.');
|
|
287
|
+
}
|
|
288
|
+
if (org.flatProblem !== undefined) {
|
|
289
|
+
out.push(`The Cursor and Kiro hook copies predate redaction packs and were not refreshed (${org.flatProblem}); ` +
|
|
290
|
+
'they send spans without the packs until setup is re-run.');
|
|
291
|
+
}
|
|
292
|
+
return out;
|
|
293
|
+
};
|
|
111
294
|
const HOOK_INPUT_CAP = 1024 * 1024;
|
|
112
295
|
const HOOK_INPUT_WAIT_MS = 2000;
|
|
113
296
|
const TRUTHY = new Set(['1', 'true', 'yes', 'on']);
|
package/dist/core/interview.js
CHANGED
|
@@ -8,7 +8,7 @@ import { promptApiKey, promptCollectorUrl, promptUserEmail } from './prompts.js'
|
|
|
8
8
|
import { storedKeyFor } from './store.js';
|
|
9
9
|
import { say } from './ui.js';
|
|
10
10
|
import { resolveUseCase } from './use-case.js';
|
|
11
|
-
|
|
11
|
+
const DEFAULT_COLLECTOR_URL = 'https://collector.mainwave.com';
|
|
12
12
|
const missing = (what, flag) => new WizardAbort(`${what} is required in a non-interactive run — pass ${flag}`);
|
|
13
13
|
const resolveApiKey = async (input) => {
|
|
14
14
|
if (input.overrides.apiKey)
|
|
@@ -92,7 +92,7 @@ const resolveAdapterEmails = async (input, identityAdapters, general, toolEmail)
|
|
|
92
92
|
}
|
|
93
93
|
return Object.fromEntries(tools.map((a) => [a.name, chosen]));
|
|
94
94
|
};
|
|
95
|
-
|
|
95
|
+
const noIdentityWarning = (headerTools, nonOauth) => {
|
|
96
96
|
const names = [
|
|
97
97
|
...headerTools.map((a) => a.displayName),
|
|
98
98
|
...nonOauth.map(({ adapter, reason }) => `${adapter.displayName} (${reason})`),
|
|
@@ -154,6 +154,17 @@ const resolveUseCaseStep = async (input) => {
|
|
|
154
154
|
const sayCaptureNotice = (optIns, adapters, explicit) => {
|
|
155
155
|
const withoutPrompts = adapters.filter((a) => !effectiveOptIns(a, optIns, explicit).userPrompts);
|
|
156
156
|
const promptsAnywhere = withoutPrompts.length < adapters.length && optIns.userPrompts;
|
|
157
|
+
const sent = adapters.map((a) => effectiveOptIns(a, optIns, explicit));
|
|
158
|
+
const alwaysOnFor = (key) => {
|
|
159
|
+
if (optIns[key])
|
|
160
|
+
return undefined;
|
|
161
|
+
const names = adapters.filter((_, i) => sent[i][key]).map((a) => a.displayName);
|
|
162
|
+
return names.length > 0 ? names.join(', ') : undefined;
|
|
163
|
+
};
|
|
164
|
+
const detailsFixed = alwaysOnFor('toolDetails');
|
|
165
|
+
const contentFixed = alwaysOnFor('toolContent');
|
|
166
|
+
const toolDetails = optIns.toolDetails || detailsFixed !== undefined;
|
|
167
|
+
const toolContent = optIns.toolContent || contentFixed !== undefined;
|
|
157
168
|
const on = [
|
|
158
169
|
promptsAnywhere
|
|
159
170
|
? withoutPrompts.length > 0
|
|
@@ -164,30 +175,39 @@ const sayCaptureNotice = (optIns, adapters, explicit) => {
|
|
|
164
175
|
optIns.userPrompts && adapters.some((a) => a.name === 'claude-desktop')
|
|
165
176
|
? 'assistant responses'
|
|
166
177
|
: undefined,
|
|
167
|
-
|
|
168
|
-
|
|
178
|
+
toolDetails
|
|
179
|
+
? `shell commands and file paths${detailsFixed ? ` (${detailsFixed})` : ''}`
|
|
180
|
+
: undefined,
|
|
181
|
+
toolContent ? `tool result bodies${contentFixed ? ` (${contentFixed})` : ''}` : undefined,
|
|
182
|
+
optIns.userPrompts &&
|
|
183
|
+
optIns.toolDetails &&
|
|
184
|
+
optIns.toolContent &&
|
|
185
|
+
adapters.some((a) => a.name === 'claude-desktop')
|
|
186
|
+
? 'raw model request and response bodies, system prompts included (Claude Desktop)'
|
|
187
|
+
: undefined,
|
|
169
188
|
optIns.repository && adapters.some((a) => a.name === 'claude-code')
|
|
170
189
|
? 'repository names (Claude Code)'
|
|
171
190
|
: undefined,
|
|
172
191
|
].filter((s) => s !== undefined);
|
|
173
192
|
const codex = adapters.some((a) => a.name === 'codex');
|
|
174
|
-
const codexToolsOff = codex && !optIns.toolDetails && !optIns.toolContent;
|
|
175
193
|
if (on.length === 0) {
|
|
176
194
|
say(color.dim('Content capture is off — only metadata (tool names, tokens, cost) is sent.'));
|
|
177
195
|
}
|
|
178
196
|
else {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
197
|
+
const onlyFixed = !optIns.userPrompts &&
|
|
198
|
+
!optIns.repository &&
|
|
199
|
+
(!optIns.toolDetails || detailsFixed !== undefined) &&
|
|
200
|
+
(!optIns.toolContent || contentFixed !== undefined);
|
|
201
|
+
say(color.yellow(`Content capture is ON: ${on.join(', ')} will be sent to your collector.` +
|
|
202
|
+
(onlyFixed
|
|
203
|
+
? ''
|
|
204
|
+
: '\nTurn it off with `--opt-in none`, or pick what you want with\n' +
|
|
205
|
+
'`--opt-in prompts,tool-details,tool-content,repository`.')));
|
|
186
206
|
}
|
|
187
|
-
if (
|
|
188
|
-
say(color.yellow('Codex
|
|
189
|
-
'
|
|
190
|
-
'
|
|
207
|
+
if (codex) {
|
|
208
|
+
say(color.yellow('Codex sends its tool commands and results whatever `--opt-in` says: its config has\n' +
|
|
209
|
+
'no switch for them, so `--opt-in` changes only whether it sends prompt text.\n' +
|
|
210
|
+
'Codex caps each tool result at 2,048 bytes by default (`[otel.tool_result] max_bytes`).'));
|
|
191
211
|
}
|
|
192
212
|
};
|
|
193
213
|
export const resolveApiKeyForTest = resolveApiKey;
|