@mainwave/cli 0.0.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 +202 -0
- package/README.md +65 -0
- package/dist/adapters/claude-code.js +183 -0
- package/dist/adapters/claude-code.js.map +1 -0
- package/dist/adapters/codex-cli.js +185 -0
- package/dist/adapters/codex-cli.js.map +1 -0
- package/dist/adapters/copilot-chat.js +218 -0
- package/dist/adapters/copilot-chat.js.map +1 -0
- package/dist/adapters/copilot-cli.js +145 -0
- package/dist/adapters/copilot-cli.js.map +1 -0
- package/dist/adapters/index.js +12 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/types.js +2 -0
- package/dist/adapters/types.js.map +1 -0
- package/dist/cli.js +5 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/codecs/env-file.js +110 -0
- package/dist/core/codecs/env-file.js.map +1 -0
- package/dist/core/codecs/json-env.js +61 -0
- package/dist/core/codecs/json-env.js.map +1 -0
- package/dist/core/codecs/json-flat.js +94 -0
- package/dist/core/codecs/json-flat.js.map +1 -0
- package/dist/core/codecs/jsonc-settings.js +155 -0
- package/dist/core/codecs/jsonc-settings.js.map +1 -0
- package/dist/core/codecs/toml-otel.js +405 -0
- package/dist/core/codecs/toml-otel.js.map +1 -0
- package/dist/core/codecs/types.js +2 -0
- package/dist/core/codecs/types.js.map +1 -0
- package/dist/core/doctor.js +334 -0
- package/dist/core/doctor.js.map +1 -0
- package/dist/core/edit.js +125 -0
- package/dist/core/edit.js.map +1 -0
- package/dist/core/effective-settings.js +68 -0
- package/dist/core/effective-settings.js.map +1 -0
- package/dist/core/env-command.js +37 -0
- package/dist/core/env-command.js.map +1 -0
- package/dist/core/errors.js +18 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/format.js +92 -0
- package/dist/core/format.js.map +1 -0
- package/dist/core/post-setup.js +83 -0
- package/dist/core/post-setup.js.map +1 -0
- package/dist/core/prompts.js +88 -0
- package/dist/core/prompts.js.map +1 -0
- package/dist/core/settings.js +83 -0
- package/dist/core/settings.js.map +1 -0
- package/dist/core/status.js +196 -0
- package/dist/core/status.js.map +1 -0
- package/dist/core/tty.js +11 -0
- package/dist/core/tty.js.map +1 -0
- package/dist/core/validate.js +41 -0
- package/dist/core/validate.js.map +1 -0
- package/dist/core/wizard.js +184 -0
- package/dist/core/wizard.js.map +1 -0
- package/dist/main.js +140 -0
- package/dist/main.js.map +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# @mainwave/cli
|
|
2
|
+
|
|
3
|
+
Setup wizard for connecting third-party coding tools to [Mainwave AI](https://mainwave.com).
|
|
4
|
+
|
|
5
|
+
Installs as the `mainwave-cli` command.
|
|
6
|
+
|
|
7
|
+
## Use
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx @mainwave/cli setup claude-code
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The wizard collects a use-case id, collector URL, API key, and sensitive-data
|
|
14
|
+
opt-ins, then writes a Claude-Code-shaped `env` block to `.claude/settings.json`
|
|
15
|
+
and validates that the configuration authenticates against the configured
|
|
16
|
+
collector.
|
|
17
|
+
|
|
18
|
+
To inspect the current state without changing anything:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npx @mainwave/cli doctor claude-code # static report
|
|
22
|
+
npx @mainwave/cli doctor claude-code --validate # also check auth against collector
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`doctor` walks the full Claude Code settings hierarchy (managed → project-local
|
|
26
|
+
→ project → user), prints the effective env block tagged by source, and runs
|
|
27
|
+
health checks for known gotchas (kill-switches in shell env, missing trace
|
|
28
|
+
beta flag, managed-tier overrides).
|
|
29
|
+
|
|
30
|
+
Run `mainwave-cli --help` for the full command list and the coding tools currently supported.
|
|
31
|
+
|
|
32
|
+
## Develop
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
make install # pnpm install
|
|
36
|
+
make ready # format-check + lint + typecheck + tests
|
|
37
|
+
make build # tsc → dist/
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Node 20+ is required at runtime.
|
|
41
|
+
|
|
42
|
+
### Try it locally
|
|
43
|
+
|
|
44
|
+
Two ways to run the wizard against your dev collector before publishing.
|
|
45
|
+
|
|
46
|
+
**Symlink onto your PATH (best for iteration):**
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
cd clients/cli
|
|
50
|
+
pnpm build
|
|
51
|
+
pnpm link --global # one-time; exposes `mainwave-cli` globally
|
|
52
|
+
cd ~/some-other-folder
|
|
53
|
+
mainwave-cli setup claude-code
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Subsequent edits only need `pnpm build` — the symlink keeps pointing at `dist/`, so the rebuild is picked up automatically. Remove with `pnpm rm -g @mainwave/cli`.
|
|
57
|
+
|
|
58
|
+
**Direct invocation, no install:**
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
cd clients/cli && pnpm build
|
|
62
|
+
node /full/path/to/clients/cli/dist/cli.js setup claude-code
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Works from any cwd; no global state.
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { jsonEnvCodec } from '../core/codecs/json-env.js';
|
|
4
|
+
const MANAGED_ENV_KEYS = [
|
|
5
|
+
'CLAUDE_CODE_ENABLE_TELEMETRY',
|
|
6
|
+
// Without this beta flag traces are silently dropped (only metrics + logs flow).
|
|
7
|
+
// See clients/cli/docs/claude-code-telemetry-env.md.
|
|
8
|
+
'CLAUDE_CODE_ENHANCED_TELEMETRY_BETA',
|
|
9
|
+
'OTEL_TRACES_EXPORTER',
|
|
10
|
+
'OTEL_METRICS_EXPORTER',
|
|
11
|
+
'OTEL_LOGS_EXPORTER',
|
|
12
|
+
'OTEL_EXPORTER_OTLP_PROTOCOL',
|
|
13
|
+
'OTEL_EXPORTER_OTLP_ENDPOINT',
|
|
14
|
+
'OTEL_EXPORTER_OTLP_HEADERS',
|
|
15
|
+
'OTEL_RESOURCE_ATTRIBUTES',
|
|
16
|
+
'OTEL_LOG_USER_PROMPTS',
|
|
17
|
+
'OTEL_LOG_TOOL_DETAILS',
|
|
18
|
+
'OTEL_LOG_TOOL_CONTENT',
|
|
19
|
+
];
|
|
20
|
+
const buildResourceAttrs = (ucid) => {
|
|
21
|
+
const deploymentEnv = process.env.MAINWAVE_DEPLOYMENT_ENV ?? 'production';
|
|
22
|
+
return [
|
|
23
|
+
`mainwave.ucid=${ucid}`,
|
|
24
|
+
'mainwave.ucid_source=explicit',
|
|
25
|
+
'mainwave.source=coding_agent.claude_code',
|
|
26
|
+
'service.name=claude-code',
|
|
27
|
+
`deployment.environment=${deploymentEnv}`,
|
|
28
|
+
].join(',');
|
|
29
|
+
};
|
|
30
|
+
const findKvPair = (blob, targetKey, caseInsensitive) => {
|
|
31
|
+
for (const pair of blob.split(',')) {
|
|
32
|
+
const eq = pair.indexOf('=');
|
|
33
|
+
if (eq < 0)
|
|
34
|
+
continue;
|
|
35
|
+
const key = pair.slice(0, eq).trim();
|
|
36
|
+
const matches = caseInsensitive
|
|
37
|
+
? key.toLowerCase() === targetKey.toLowerCase()
|
|
38
|
+
: key === targetKey;
|
|
39
|
+
if (matches)
|
|
40
|
+
return pair.slice(eq + 1).trim();
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
43
|
+
};
|
|
44
|
+
const parseBearerToken = (header) => {
|
|
45
|
+
const auth = findKvPair(header, 'authorization', true);
|
|
46
|
+
if (!auth)
|
|
47
|
+
return undefined;
|
|
48
|
+
if (!auth.toLowerCase().startsWith('bearer '))
|
|
49
|
+
return undefined;
|
|
50
|
+
return auth.slice('bearer '.length).trim() || undefined;
|
|
51
|
+
};
|
|
52
|
+
const parseEnv = (env) => {
|
|
53
|
+
const hasAnyManaged = MANAGED_ENV_KEYS.some((k) => k in env);
|
|
54
|
+
if (!hasAnyManaged)
|
|
55
|
+
return {};
|
|
56
|
+
const out = {};
|
|
57
|
+
const url = env.OTEL_EXPORTER_OTLP_ENDPOINT;
|
|
58
|
+
if (url)
|
|
59
|
+
out.collectorUrl = url;
|
|
60
|
+
const headers = env.OTEL_EXPORTER_OTLP_HEADERS;
|
|
61
|
+
if (headers) {
|
|
62
|
+
const apiKey = parseBearerToken(headers);
|
|
63
|
+
if (apiKey)
|
|
64
|
+
out.apiKey = apiKey;
|
|
65
|
+
}
|
|
66
|
+
const attrs = env.OTEL_RESOURCE_ATTRIBUTES;
|
|
67
|
+
if (attrs) {
|
|
68
|
+
const ucid = findKvPair(attrs, 'mainwave.ucid', false);
|
|
69
|
+
if (ucid)
|
|
70
|
+
out.ucid = ucid;
|
|
71
|
+
}
|
|
72
|
+
out.optIns = {
|
|
73
|
+
userPrompts: env.OTEL_LOG_USER_PROMPTS === '1',
|
|
74
|
+
toolDetails: env.OTEL_LOG_TOOL_DETAILS === '1',
|
|
75
|
+
toolContent: env.OTEL_LOG_TOOL_CONTENT === '1',
|
|
76
|
+
};
|
|
77
|
+
return out;
|
|
78
|
+
};
|
|
79
|
+
const buildEnv = ({ ucid, collectorUrl, apiKey, optIns, }) => {
|
|
80
|
+
const env = {
|
|
81
|
+
CLAUDE_CODE_ENABLE_TELEMETRY: '1',
|
|
82
|
+
CLAUDE_CODE_ENHANCED_TELEMETRY_BETA: '1',
|
|
83
|
+
OTEL_TRACES_EXPORTER: 'otlp',
|
|
84
|
+
OTEL_METRICS_EXPORTER: 'otlp',
|
|
85
|
+
OTEL_LOGS_EXPORTER: 'otlp',
|
|
86
|
+
OTEL_EXPORTER_OTLP_PROTOCOL: 'http/protobuf',
|
|
87
|
+
OTEL_EXPORTER_OTLP_ENDPOINT: collectorUrl,
|
|
88
|
+
OTEL_EXPORTER_OTLP_HEADERS: `Authorization=Bearer ${apiKey}`,
|
|
89
|
+
OTEL_RESOURCE_ATTRIBUTES: buildResourceAttrs(ucid),
|
|
90
|
+
};
|
|
91
|
+
if (optIns.userPrompts)
|
|
92
|
+
env.OTEL_LOG_USER_PROMPTS = '1';
|
|
93
|
+
if (optIns.toolDetails)
|
|
94
|
+
env.OTEL_LOG_TOOL_DETAILS = '1';
|
|
95
|
+
if (optIns.toolContent)
|
|
96
|
+
env.OTEL_LOG_TOOL_CONTENT = '1';
|
|
97
|
+
return env;
|
|
98
|
+
};
|
|
99
|
+
const collectChecks = (env) => {
|
|
100
|
+
const issues = [];
|
|
101
|
+
if (env.CLAUDE_CODE_ENABLE_TELEMETRY !== '1') {
|
|
102
|
+
issues.push({
|
|
103
|
+
level: 'error',
|
|
104
|
+
message: 'CLAUDE_CODE_ENABLE_TELEMETRY is not set to 1 — telemetry will not initialize.',
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
if (env.CLAUDE_CODE_ENHANCED_TELEMETRY_BETA !== '1') {
|
|
108
|
+
issues.push({
|
|
109
|
+
level: 'warn',
|
|
110
|
+
message: 'CLAUDE_CODE_ENHANCED_TELEMETRY_BETA is not set to 1 — only metrics + logs flow; spans will be silently dropped. Re-run `mainwave-cli setup` to refresh.',
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
if (env.OTEL_LOG_RAW_API_BODIES) {
|
|
114
|
+
issues.push({
|
|
115
|
+
level: 'warn',
|
|
116
|
+
message: 'OTEL_LOG_RAW_API_BODIES is set — full request/response bodies (including system prompts) will be sent. Highest-risk var on the surface.',
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
if (!env.CLAUDE_CODE_OTEL_FLUSH_TIMEOUT_MS && !process.env.CLAUDE_CODE_OTEL_FLUSH_TIMEOUT_MS) {
|
|
120
|
+
issues.push({
|
|
121
|
+
level: 'info',
|
|
122
|
+
message: 'CLAUDE_CODE_OTEL_FLUSH_TIMEOUT_MS is unset — for `claude -p` runs, set it to 10000 in your shell.',
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return issues;
|
|
126
|
+
};
|
|
127
|
+
// Per https://code.claude.com/docs/en/settings — file-based managed sources.
|
|
128
|
+
// Server-managed, MDM/OS-policy, and Windows HKCU registry tiers are not
|
|
129
|
+
// introspected (would require `defaults read` / `reg query` invocations).
|
|
130
|
+
const managedSettingsDir = (() => {
|
|
131
|
+
if (process.platform === 'darwin')
|
|
132
|
+
return '/Library/Application Support/ClaudeCode';
|
|
133
|
+
if (process.platform === 'win32')
|
|
134
|
+
return 'C:\\Program Files\\ClaudeCode';
|
|
135
|
+
return '/etc/claude-code';
|
|
136
|
+
})();
|
|
137
|
+
const HIERARCHY = [
|
|
138
|
+
{
|
|
139
|
+
id: 'managed',
|
|
140
|
+
label: 'Managed (org policy)',
|
|
141
|
+
path: join(managedSettingsDir, 'managed-settings.json'),
|
|
142
|
+
kind: 'file',
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
id: 'managed-dropin',
|
|
146
|
+
label: 'Managed drop-in',
|
|
147
|
+
path: join(managedSettingsDir, 'managed-settings.d'),
|
|
148
|
+
kind: 'dir',
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
id: 'projectLocal',
|
|
152
|
+
label: 'Project (local, gitignored)',
|
|
153
|
+
path: join('.claude', 'settings.local.json'),
|
|
154
|
+
kind: 'file',
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
id: 'project',
|
|
158
|
+
label: 'Project (shared)',
|
|
159
|
+
path: join('.claude', 'settings.json'),
|
|
160
|
+
kind: 'file',
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
id: 'user',
|
|
164
|
+
label: 'User (global)',
|
|
165
|
+
path: join(homedir(), '.claude', 'settings.json'),
|
|
166
|
+
kind: 'file',
|
|
167
|
+
},
|
|
168
|
+
];
|
|
169
|
+
export const claudeCode = {
|
|
170
|
+
name: 'claude-code',
|
|
171
|
+
displayName: 'Claude Code',
|
|
172
|
+
paths: {
|
|
173
|
+
local: join('.claude', 'settings.json'),
|
|
174
|
+
global: join(homedir(), '.claude', 'settings.json'),
|
|
175
|
+
},
|
|
176
|
+
codec: jsonEnvCodec,
|
|
177
|
+
managedEnvKeys: MANAGED_ENV_KEYS,
|
|
178
|
+
hierarchy: HIERARCHY,
|
|
179
|
+
buildEnv,
|
|
180
|
+
parseEnv,
|
|
181
|
+
collectChecks,
|
|
182
|
+
};
|
|
183
|
+
//# sourceMappingURL=claude-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-code.js","sourceRoot":"","sources":["../../src/adapters/claude-code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAIzD,MAAM,gBAAgB,GAAG;IACvB,8BAA8B;IAC9B,iFAAiF;IACjF,qDAAqD;IACrD,qCAAqC;IACrC,sBAAsB;IACtB,uBAAuB;IACvB,oBAAoB;IACpB,6BAA6B;IAC7B,6BAA6B;IAC7B,4BAA4B;IAC5B,0BAA0B;IAC1B,uBAAuB;IACvB,uBAAuB;IACvB,uBAAuB;CACf,CAAA;AAEV,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAU,EAAE;IAClD,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,YAAY,CAAA;IACzE,OAAO;QACL,iBAAiB,IAAI,EAAE;QACvB,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AI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,eAAe,CAAC;KACpD;IACD,KAAK,EAAE,YAAY;IACnB,cAAc,EAAE,gBAAgB;IAChC,SAAS,EAAE,SAAS;IACpB,QAAQ;IACR,QAAQ;IACR,aAAa;CACd,CAAA"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { tomlOtelCodec } from '../core/codecs/toml-otel.js';
|
|
4
|
+
/**
|
|
5
|
+
* Codex CLI's OTEL config is structured TOML, not env vars in a JSON `env`
|
|
6
|
+
* block. The wizard's flat env record uses dotted TOML paths as keys
|
|
7
|
+
* (e.g. `otel.exporter.otlp-http.endpoint`); the TOML codec un-flattens
|
|
8
|
+
* those into nested `[otel.*]` tables on serialize.
|
|
9
|
+
*
|
|
10
|
+
* Tenancy attributes ship as HTTP headers (`X-Mainwave-*`), not via
|
|
11
|
+
* `OTEL_RESOURCE_ATTRIBUTES`. The collector promotes them to `mainwave.*`
|
|
12
|
+
* resource attributes before processor dispatch, keeping all setup in a
|
|
13
|
+
* single config file rather than requiring a wrapper script.
|
|
14
|
+
*
|
|
15
|
+
* Codex CLI 0.130+ silently drops `otel` keys from project-local
|
|
16
|
+
* `.codex/config.toml` (see PROJECT_LOCAL_CONFIG_DENYLIST in
|
|
17
|
+
* codex-rs/config/src/loader/mod.rs). The reasoning upstream: project-local
|
|
18
|
+
* config comes from repository contents and should not get to choose where
|
|
19
|
+
* credentials are sent. The wizard still offers the local scope but labels
|
|
20
|
+
* it with `localScopeWarning`, defaults to global, and `collectFileChecks`
|
|
21
|
+
* warns at doctor time when a stale local file with otel keys exists.
|
|
22
|
+
*/
|
|
23
|
+
const SOURCE_VALUE = 'coding_agent.codex_cli';
|
|
24
|
+
const SIGNAL_BLOCKS = ['exporter', 'trace_exporter', 'metrics_exporter'];
|
|
25
|
+
const SIGNAL_PATH = {
|
|
26
|
+
exporter: '/v1/logs',
|
|
27
|
+
trace_exporter: '/v1/traces',
|
|
28
|
+
metrics_exporter: '/v1/metrics',
|
|
29
|
+
};
|
|
30
|
+
const HEADER_NAMES = ['Authorization', 'X-Mainwave-UCID', 'X-Mainwave-Source'];
|
|
31
|
+
const endpointKey = (block) => `otel.${block}.otlp-http.endpoint`;
|
|
32
|
+
const protocolKey = (block) => `otel.${block}.otlp-http.protocol`;
|
|
33
|
+
const headerKey = (block, name) => `otel.${block}.otlp-http.headers.${name}`;
|
|
34
|
+
/** Every key buildEnv can emit — settings.ts clears these on re-run to remove opted-out keys. */
|
|
35
|
+
const MANAGED_ENV_KEYS = [
|
|
36
|
+
'otel.log_user_prompt',
|
|
37
|
+
...SIGNAL_BLOCKS.flatMap((b) => [
|
|
38
|
+
endpointKey(b),
|
|
39
|
+
protocolKey(b),
|
|
40
|
+
...HEADER_NAMES.map((h) => headerKey(b, h)),
|
|
41
|
+
]),
|
|
42
|
+
];
|
|
43
|
+
const stripTrailingSlash = (url) => url.replace(/\/+$/, '');
|
|
44
|
+
const buildEnv = ({ ucid, collectorUrl, apiKey, optIns, }) => {
|
|
45
|
+
const base = stripTrailingSlash(collectorUrl);
|
|
46
|
+
const out = {};
|
|
47
|
+
if (optIns.userPrompts)
|
|
48
|
+
out['otel.log_user_prompt'] = 'true';
|
|
49
|
+
for (const block of SIGNAL_BLOCKS) {
|
|
50
|
+
out[endpointKey(block)] = `${base}${SIGNAL_PATH[block]}`;
|
|
51
|
+
out[protocolKey(block)] = 'binary';
|
|
52
|
+
out[headerKey(block, 'Authorization')] = `Bearer ${apiKey}`;
|
|
53
|
+
out[headerKey(block, 'X-Mainwave-UCID')] = ucid;
|
|
54
|
+
out[headerKey(block, 'X-Mainwave-Source')] = SOURCE_VALUE;
|
|
55
|
+
}
|
|
56
|
+
return out;
|
|
57
|
+
};
|
|
58
|
+
const stripSignalPath = (endpoint) => {
|
|
59
|
+
for (const block of SIGNAL_BLOCKS) {
|
|
60
|
+
const suffix = SIGNAL_PATH[block];
|
|
61
|
+
if (endpoint.endsWith(suffix))
|
|
62
|
+
return endpoint.slice(0, -suffix.length);
|
|
63
|
+
}
|
|
64
|
+
return undefined;
|
|
65
|
+
};
|
|
66
|
+
const parseBearer = (header) => {
|
|
67
|
+
if (!header.toLowerCase().startsWith('bearer '))
|
|
68
|
+
return undefined;
|
|
69
|
+
return header.slice('bearer '.length).trim() || undefined;
|
|
70
|
+
};
|
|
71
|
+
const parseEnv = (env) => {
|
|
72
|
+
const hasAnyManaged = MANAGED_ENV_KEYS.some((k) => k in env);
|
|
73
|
+
if (!hasAnyManaged)
|
|
74
|
+
return {};
|
|
75
|
+
const out = {};
|
|
76
|
+
const logsEndpoint = env[endpointKey('exporter')];
|
|
77
|
+
if (logsEndpoint) {
|
|
78
|
+
const base = stripSignalPath(logsEndpoint);
|
|
79
|
+
if (base)
|
|
80
|
+
out.collectorUrl = base;
|
|
81
|
+
}
|
|
82
|
+
const auth = env[headerKey('exporter', 'Authorization')];
|
|
83
|
+
if (auth) {
|
|
84
|
+
const token = parseBearer(auth);
|
|
85
|
+
if (token)
|
|
86
|
+
out.apiKey = token;
|
|
87
|
+
}
|
|
88
|
+
const ucid = env[headerKey('exporter', 'X-Mainwave-UCID')];
|
|
89
|
+
if (ucid)
|
|
90
|
+
out.ucid = ucid;
|
|
91
|
+
out.optIns = {
|
|
92
|
+
userPrompts: env['otel.log_user_prompt'] === 'true',
|
|
93
|
+
toolDetails: false,
|
|
94
|
+
toolContent: false,
|
|
95
|
+
};
|
|
96
|
+
return out;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Project Codex's TOML-keyed paths onto the generic shape the doctor's
|
|
100
|
+
* adapter-agnostic checks expect. Codex carries the UCID as an HTTP header
|
|
101
|
+
* (`X-Mainwave-UCID`) rather than via `OTEL_RESOURCE_ATTRIBUTES`, so the
|
|
102
|
+
* legacy default-projection in `doctor.ts` would always report "missing
|
|
103
|
+
* mainwave.ucid" for Codex setups. We take the first value seen across the
|
|
104
|
+
* three signal blocks (logs/traces/metrics) — they're identical by
|
|
105
|
+
* construction, but this is robust to partial configs.
|
|
106
|
+
*/
|
|
107
|
+
const normalizeForGenericChecks = (env) => {
|
|
108
|
+
let endpoint;
|
|
109
|
+
let auth;
|
|
110
|
+
let ucid;
|
|
111
|
+
for (const block of SIGNAL_BLOCKS) {
|
|
112
|
+
endpoint ??= env[endpointKey(block)];
|
|
113
|
+
auth ??= env[headerKey(block, 'Authorization')];
|
|
114
|
+
ucid ??= env[headerKey(block, 'X-Mainwave-UCID')];
|
|
115
|
+
}
|
|
116
|
+
return { endpoint, auth, ucid };
|
|
117
|
+
};
|
|
118
|
+
const collectFileChecks = (scans) => {
|
|
119
|
+
const issues = [];
|
|
120
|
+
for (const scan of scans) {
|
|
121
|
+
if (scan.layer.id !== 'projectLocal')
|
|
122
|
+
continue;
|
|
123
|
+
if (scan.status !== 'present')
|
|
124
|
+
continue;
|
|
125
|
+
const hasOtelKey = Object.keys(scan.env).some((k) => k === 'otel' || k.startsWith('otel.'));
|
|
126
|
+
if (!hasOtelKey)
|
|
127
|
+
continue;
|
|
128
|
+
issues.push({
|
|
129
|
+
level: 'warn',
|
|
130
|
+
message: `Project-local config at ${scan.path} contains otel keys, but Codex CLI 0.130+ ` +
|
|
131
|
+
`silently drops them (security policy: project-local config can't choose where ` +
|
|
132
|
+
`credentials are sent). Re-run \`mainwave-cli setup codex\` and pick global, ` +
|
|
133
|
+
`then remove the otel block from this file.`,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return issues;
|
|
137
|
+
};
|
|
138
|
+
const collectChecks = (env) => {
|
|
139
|
+
const issues = [];
|
|
140
|
+
if (!env[endpointKey('metrics_exporter')]) {
|
|
141
|
+
issues.push({
|
|
142
|
+
level: 'warn',
|
|
143
|
+
message: 'No [otel.metrics_exporter.otlp-http] block found — Codex defaults `metrics_exporter` to Statsig, ' +
|
|
144
|
+
'which ships metrics to https://ab.chatgpt.com. Re-run setup or set `[otel] metrics_exporter = "none"`.',
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
issues.push({
|
|
148
|
+
level: 'warn',
|
|
149
|
+
message: 'Codex ships full tool stdout in `codex.tool_result.output` by default and exposes no opt-out flag. ' +
|
|
150
|
+
'If your workflow runs commands over sensitive files, scrub at the collector or avoid Codex for those flows.',
|
|
151
|
+
});
|
|
152
|
+
return issues;
|
|
153
|
+
};
|
|
154
|
+
const HIERARCHY = [
|
|
155
|
+
{
|
|
156
|
+
id: 'projectLocal',
|
|
157
|
+
label: 'Project (local)',
|
|
158
|
+
path: join('.codex', 'config.toml'),
|
|
159
|
+
kind: 'file',
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
id: 'user',
|
|
163
|
+
label: 'User (global)',
|
|
164
|
+
path: join(homedir(), '.codex', 'config.toml'),
|
|
165
|
+
kind: 'file',
|
|
166
|
+
},
|
|
167
|
+
];
|
|
168
|
+
export const codexCli = {
|
|
169
|
+
name: 'codex',
|
|
170
|
+
displayName: 'Codex CLI',
|
|
171
|
+
paths: {
|
|
172
|
+
local: join('.codex', 'config.toml'),
|
|
173
|
+
global: join(homedir(), '.codex', 'config.toml'),
|
|
174
|
+
},
|
|
175
|
+
localScopeWarning: 'ignored by Codex 0.130+ (otel keys are dropped from project-local config)',
|
|
176
|
+
codec: tomlOtelCodec,
|
|
177
|
+
managedEnvKeys: MANAGED_ENV_KEYS,
|
|
178
|
+
hierarchy: HIERARCHY,
|
|
179
|
+
buildEnv,
|
|
180
|
+
parseEnv,
|
|
181
|
+
collectChecks,
|
|
182
|
+
collectFileChecks,
|
|
183
|
+
normalizeForGenericChecks,
|
|
184
|
+
};
|
|
185
|
+
//# sourceMappingURL=codex-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-cli.js","sourceRoot":"","sources":["../../src/adapters/codex-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO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