anyray-connect 0.11.9 → 0.11.10
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 +1 -1
- package/dist/tools/codex.js +121 -103
- package/dist/tools/codex.js.map +1 -1
- package/dist/util/codexConfig.js +153 -0
- package/dist/util/codexConfig.js.map +1 -0
- package/dist/util/trimOutput.js +4 -4
- package/dist/util/trimOutput.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ How the key is sent depends on the auth mode:
|
|
|
49
49
|
| Tool | How |
|
|
50
50
|
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
51
51
|
| **Claude Code** | Automatic — writes the `env` block in `~/.claude/settings.json` (`ANTHROPIC_BASE_URL`, placeholder `ANTHROPIC_AUTH_TOKEN`, and `ANTHROPIC_CUSTOM_HEADERS` carrying `x-anyray-metadata`). With `--subscription`, no auth token is written: Claude Code keeps its seat (Pro/Max/Team/Enterprise) sign-in and the gateway passes the OAuth token through (`x-anyray-auth-mode: passthrough`), so spend stays on the subscription. |
|
|
52
|
-
| **Codex CLI** | Automatic — writes `~/.codex/
|
|
52
|
+
| **Codex CLI** | Automatic, always-on — writes the `anyray` provider as the default route (`model_provider = "anyray"`) into a managed block in `~/.codex/config.toml`, so plain `codex` routes through the gateway (no `--profile` needed). The block sits before your first `[table]` to keep TOML valid; your own keys/tables are preserved and the original is backed up to `config.toml.anyray-bak`. With `--subscription`, the provider sets `requires_openai_auth = true` and no static key: Codex attaches its ChatGPT sign-in itself, and the gateway passes the OAuth token through to the ChatGPT Codex backend (`x-anyray-custom-host`), so spend stays on the seat. |
|
|
53
53
|
| **Shell env** | Automatic — a managed, idempotent block in your shell profile with `OPENAI_BASE_URL` / `ANTHROPIC_BASE_URL` + placeholder keys (covers SDK jobs and scripts). |
|
|
54
54
|
| **Cursor / Windsurf** | Detect + print exact UI steps (their config is app state we don't script). |
|
|
55
55
|
|
package/dist/tools/codex.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Codex CLI adapter — fully automatic.
|
|
2
|
+
* Codex CLI adapter — fully automatic, always-on.
|
|
3
3
|
*
|
|
4
4
|
* Codex (OpenAI's CLI) reaches a backend through a `[model_providers.<id>]`
|
|
5
|
-
* entry. We register an `anyray` provider pointed at the gateway and
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* entry. We register an `anyray` provider pointed at the gateway and make it the
|
|
6
|
+
* DEFAULT (`model_provider = "anyray"` at the top level of `~/.codex/config.toml`),
|
|
7
|
+
* so plain `codex` routes through the gateway — symmetric with the Claude Code
|
|
8
|
+
* and Cursor adapters, which are likewise always-on. (Codex 0.139+ killed the
|
|
9
|
+
* legacy default-`profile` config and made named profiles strictly opt-in via
|
|
10
|
+
* `--profile`, so a profile file can't deliver always-on — the default route has
|
|
11
|
+
* to live in the base config.)
|
|
8
12
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* We own exactly the marked block (`# >>> anyray connect >>>` … `<<<`) and place
|
|
14
|
+
* it before the first `[table]` so its bare selector keys stay in top-level
|
|
15
|
+
* scope (TOML requires bare keys before tables). The dev's own keys/tables are
|
|
16
|
+
* preserved; a pre-existing top-level `model_provider` (and, when we pin one,
|
|
17
|
+
* `model`) is dropped so TOML sees no duplicate. We back up `config.toml` to
|
|
18
|
+
* `config.toml.anyray-bak` before the first change. Older connects wrote an
|
|
19
|
+
* opt-in `anyray.config.toml` profile and/or a legacy `[profiles.anyray]` block;
|
|
20
|
+
* apply removes/subsumes both.
|
|
15
21
|
*
|
|
16
22
|
* The only supported wire protocol is the OpenAI *Responses* API
|
|
17
23
|
* (`wire_api = "responses"`), so we target the gateway's `/v1/responses`. In
|
|
@@ -23,27 +29,23 @@
|
|
|
23
29
|
* Subscription mode (`authMode: 'subscription'`, ChatGPT Plus/Pro/Team seats):
|
|
24
30
|
* the provider sets `requires_openai_auth = true` and NO static Authorization
|
|
25
31
|
* header, so Codex attaches its own ChatGPT sign-in per request
|
|
26
|
-
* (`Authorization: Bearer <access token>` + `ChatGPT-Account-ID`)
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* backend still sees a genuine Codex request, and spend stays on the seat. No
|
|
32
|
-
* model line is written (the seat backend only accepts real Codex models), so
|
|
33
|
-
* the profile inherits the dev's working default model from `config.toml`.
|
|
32
|
+
* (`Authorization: Bearer <access token>` + `ChatGPT-Account-ID`). The gateway
|
|
33
|
+
* runs pass-through (`x-anyray-auth-mode: passthrough`) and re-targets the
|
|
34
|
+
* upstream at the ChatGPT Codex backend (`x-anyray-custom-host`), forwarding the
|
|
35
|
+
* account-id and Codex client headers (`x-anyray-forward-headers`) so the
|
|
36
|
+
* backend still sees a genuine Codex request, and spend stays on the seat.
|
|
34
37
|
*
|
|
35
|
-
* Set `ANYRAY_CODEX_MODEL` to pin a specific model id
|
|
36
|
-
*
|
|
38
|
+
* Set `ANYRAY_CODEX_MODEL` to pin a specific model id (placeholder or
|
|
39
|
+
* subscription); unset, the dev's existing default model is inherited and just
|
|
40
|
+
* flows through the gateway. In placeholder mode `ANYRAY_CODEX_PROVIDER` pins
|
|
41
|
+
* `x-anyray-provider`.
|
|
37
42
|
*/
|
|
38
43
|
import { homedir } from 'node:os';
|
|
39
44
|
import { join } from 'node:path';
|
|
40
|
-
import { writeFile, rm } from 'node:fs/promises';
|
|
45
|
+
import { readFile, writeFile, rm, copyFile } from 'node:fs/promises';
|
|
41
46
|
import { fileExists } from '../util/jsonFile.js';
|
|
42
|
-
import {
|
|
47
|
+
import { upsertManagedBlock, removeManagedBlock, } from '../util/codexConfig.js';
|
|
43
48
|
import { effectiveSubscription, metadataHeaderValue } from '../types.js';
|
|
44
|
-
/** Model Codex sends when ANYRAY_CODEX_MODEL is unset; the gateway's default
|
|
45
|
-
* routing decides the real model/provider, so this is just a required token. */
|
|
46
|
-
const DEFAULT_MODEL = 'anyray-default';
|
|
47
49
|
/** Default intent stamped on Codex traffic so it's filterable (intent:codex)
|
|
48
50
|
* and labelled in the console; override with ANYRAY_CODEX_INTENT(_LABEL) or the
|
|
49
51
|
* global --intent. */
|
|
@@ -59,15 +61,15 @@ const CHATGPT_CODEX_BACKEND = 'https://chatgpt.com/backend-api/codex';
|
|
|
59
61
|
const SUBSCRIPTION_FORWARD_HEADERS = 'chatgpt-account-id,originator,session_id,user-agent,x-codex-turn-metadata,x-codex-window-id,x-client-request-id';
|
|
60
62
|
/** `$CODEX_HOME` overrides the default `~/.codex` (Codex honors it too). */
|
|
61
63
|
const codexHome = () => process.env.CODEX_HOME?.trim() || join(homedir(), '.codex');
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
const configPath = () => join(codexHome(), 'config.toml');
|
|
65
|
+
const backupPath = () => `${configPath()}.anyray-bak`;
|
|
66
|
+
/** Opt-in profile file written by older (pre-always-on) connects — removed on
|
|
67
|
+
* apply/revert so it can't shadow or duplicate the default route. */
|
|
68
|
+
const legacyProfilePath = () => join(codexHome(), 'anyray.config.toml');
|
|
66
69
|
/**
|
|
67
70
|
* The `x-anyray-metadata` value for Codex: the resolved attribution (user/team/
|
|
68
71
|
* session/intent from CLI flags or env) plus a Codex-specific `intent` default
|
|
69
|
-
* so every Codex request is tagged even when the operator didn't pass one.
|
|
70
|
-
* header is static, so `session` is a stable grouping label, not per-conversation.
|
|
72
|
+
* so every Codex request is tagged even when the operator didn't pass one.
|
|
71
73
|
*/
|
|
72
74
|
const codexMetadata = (target) => metadataHeaderValue({
|
|
73
75
|
...target.metadata,
|
|
@@ -80,33 +82,26 @@ const codexMetadata = (target) => metadataHeaderValue({
|
|
|
80
82
|
});
|
|
81
83
|
/** Escape a string for a TOML basic (double-quoted) string. */
|
|
82
84
|
const tomlString = (value) => `"${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
|
|
83
|
-
/** The model
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return subscription ? undefined : DEFAULT_MODEL;
|
|
91
|
-
};
|
|
92
|
-
/** Full contents of the standalone profile file (flat top-level keys). */
|
|
93
|
-
const profileFile = (target) => {
|
|
85
|
+
/** The model to pin, or undefined to inherit the dev's existing default (which
|
|
86
|
+
* then just flows through the gateway). We never invent a default model now
|
|
87
|
+
* that the route is global — overriding the dev's working model would surprise
|
|
88
|
+
* them, and the ChatGPT seat backend only accepts real Codex models anyway. */
|
|
89
|
+
const resolveModel = () => process.env.ANYRAY_CODEX_MODEL?.trim() || undefined;
|
|
90
|
+
/** The managed block: top-level selector keys followed by the provider table. */
|
|
91
|
+
const blockLines = (target) => {
|
|
94
92
|
const meta = codexMetadata(target);
|
|
95
93
|
const subscription = effectiveSubscription(target, 'openai');
|
|
96
|
-
// Subscription traffic is ChatGPT-backend-only — the provider pin is not
|
|
97
|
-
//
|
|
98
|
-
// placeholder mode.
|
|
94
|
+
// Subscription traffic is ChatGPT-backend-only — the provider pin is not the
|
|
95
|
+
// operator's call there, so ANYRAY_CODEX_PROVIDER applies only to placeholder.
|
|
99
96
|
const provider = subscription
|
|
100
97
|
? 'openai'
|
|
101
98
|
: process.env.ANYRAY_CODEX_PROVIDER?.trim();
|
|
102
|
-
const model = resolveModel(
|
|
103
|
-
// Placeholder
|
|
104
|
-
//
|
|
105
|
-
//
|
|
99
|
+
const model = resolveModel();
|
|
100
|
+
// Placeholder: the dev's personal gateway key (from `--enroll`), else the
|
|
101
|
+
// shared placeholder, is the bearer. Subscription: the seat OAuth token owns
|
|
102
|
+
// Authorization, so the personal key rides x-anyray-api-key.
|
|
106
103
|
const headers = subscription
|
|
107
104
|
? [
|
|
108
|
-
// No static Authorization: requires_openai_auth makes Codex attach its
|
|
109
|
-
// ChatGPT sign-in (Bearer access token + ChatGPT-Account-ID) itself.
|
|
110
105
|
`"x-anyray-auth-mode" = "passthrough"`,
|
|
111
106
|
`"x-anyray-custom-host" = ${tomlString(CHATGPT_CODEX_BACKEND)}`,
|
|
112
107
|
`"x-anyray-forward-headers" = ${tomlString(SUBSCRIPTION_FORWARD_HEADERS)}`,
|
|
@@ -121,12 +116,11 @@ const profileFile = (target) => {
|
|
|
121
116
|
headers.push(`"x-anyray-metadata" = ${tomlString(meta)}`);
|
|
122
117
|
if (provider)
|
|
123
118
|
headers.push(`"x-anyray-provider" = ${tomlString(provider)}`);
|
|
124
|
-
|
|
125
|
-
'# Anyray
|
|
126
|
-
'# Managed by anyray-connect
|
|
127
|
-
'# Use with: codex --profile anyray',
|
|
128
|
-
...(model ? [`model = ${tomlString(model)}`] : []),
|
|
119
|
+
return [
|
|
120
|
+
'# Anyray always-on routing — plain `codex` routes through the gateway.',
|
|
121
|
+
'# Managed by anyray-connect (this block is owned by the tool).',
|
|
129
122
|
'model_provider = "anyray"',
|
|
123
|
+
...(model ? [`model = ${tomlString(model)}`] : []),
|
|
130
124
|
'',
|
|
131
125
|
'[model_providers.anyray]',
|
|
132
126
|
'name = "Anyray Gateway"',
|
|
@@ -135,8 +129,10 @@ const profileFile = (target) => {
|
|
|
135
129
|
...(subscription ? ['requires_openai_auth = true'] : []),
|
|
136
130
|
`http_headers = { ${headers.join(', ')} }`,
|
|
137
131
|
];
|
|
138
|
-
return lines.join('\n') + '\n';
|
|
139
132
|
};
|
|
133
|
+
/** Top-level bare keys our block sets — used to drop pre-existing copies so TOML
|
|
134
|
+
* never sees a duplicate key. We only own `model` when we actually pin one. */
|
|
135
|
+
const ownedKeys = () => resolveModel() ? ['model_provider', 'model'] : ['model_provider'];
|
|
140
136
|
export const codex = {
|
|
141
137
|
id: 'codex',
|
|
142
138
|
title: 'Codex CLI',
|
|
@@ -146,73 +142,95 @@ export const codex = {
|
|
|
146
142
|
const installed = await fileExists(home);
|
|
147
143
|
return {
|
|
148
144
|
installed,
|
|
149
|
-
detail: installed ?
|
|
145
|
+
detail: installed ? configPath() : `no ${home} directory`,
|
|
150
146
|
};
|
|
151
147
|
},
|
|
152
148
|
async apply(target, opts) {
|
|
153
|
-
const path =
|
|
149
|
+
const path = configPath();
|
|
154
150
|
const meta = codexMetadata(target);
|
|
155
151
|
const subscription = effectiveSubscription(target, 'openai');
|
|
156
|
-
const model = resolveModel(
|
|
152
|
+
const model = resolveModel();
|
|
157
153
|
const messages = [
|
|
158
|
-
`${path} ←
|
|
154
|
+
`${path} ← always-on default route (model_provider = anyray)`,
|
|
159
155
|
`Base URL: ${target.openaiBaseUrl}/responses (wire_api = responses)`,
|
|
156
|
+
'Plain `codex` now routes through the gateway — no --profile needed.',
|
|
160
157
|
subscription
|
|
161
158
|
? 'Subscription mode: Codex keeps your ChatGPT sign-in; its OAuth token passes through the gateway to the ChatGPT backend (never stored). Requires being signed in with ChatGPT, not an API key.'
|
|
162
|
-
: `
|
|
163
|
-
? ''
|
|
164
|
-
: '
|
|
165
|
-
|
|
166
|
-
?
|
|
167
|
-
|
|
168
|
-
]
|
|
169
|
-
: []),
|
|
159
|
+
: `Auth: ${target.clientKey
|
|
160
|
+
? 'personal gateway key (written to the config, not shown here)'
|
|
161
|
+
: 'placeholder token (gateway swaps in the server-held key)'}`,
|
|
162
|
+
model
|
|
163
|
+
? `Model: ${model} (pinned via ANYRAY_CODEX_MODEL)`
|
|
164
|
+
: 'Model: inherits your existing default (it just flows through the gateway).',
|
|
170
165
|
`Attribution: ${meta ?? '(none — pass --user)'}`,
|
|
171
|
-
'Run Codex through the gateway with: codex --profile anyray',
|
|
172
|
-
'(Plain `codex` keeps your existing default config.)',
|
|
173
166
|
];
|
|
174
167
|
if (opts.dryRun)
|
|
175
168
|
return { status: 'configured', messages };
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
//
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
169
|
+
const existed = await fileExists(path);
|
|
170
|
+
const current = existed ? await readFile(path, 'utf-8') : '';
|
|
171
|
+
// Back up the pristine config once, before our first change.
|
|
172
|
+
if (existed && !(await fileExists(backupPath()))) {
|
|
173
|
+
await copyFile(path, backupPath());
|
|
174
|
+
messages.push(`Backed up your original config to ${backupPath()}.`);
|
|
175
|
+
}
|
|
176
|
+
const next = upsertManagedBlock(current, blockLines(target), ownedKeys());
|
|
177
|
+
await writeFile(path, next);
|
|
178
|
+
const changedFiles = [path];
|
|
179
|
+
// Drop the redundant opt-in profile file an older connect may have written.
|
|
180
|
+
if (await fileExists(legacyProfilePath())) {
|
|
181
|
+
await rm(legacyProfilePath(), { force: true });
|
|
182
|
+
changedFiles.push(legacyProfilePath());
|
|
183
|
+
messages.push(`Removed the old opt-in profile ${legacyProfilePath()} (the default route replaces it).`);
|
|
184
|
+
}
|
|
185
|
+
return { status: 'configured', messages, changedFiles };
|
|
186
|
+
},
|
|
187
|
+
async pointsAt(origin) {
|
|
188
|
+
const path = configPath();
|
|
189
|
+
if (!(await fileExists(path)))
|
|
190
|
+
return false;
|
|
191
|
+
try {
|
|
192
|
+
const toml = await readFile(path, 'utf-8');
|
|
193
|
+
const base = `base_url = ${tomlString(`${origin}/v1`)}`;
|
|
194
|
+
// Only our managed provider block counts as pointing at the gateway.
|
|
195
|
+
return toml.includes('[model_providers.anyray]') && toml.includes(base);
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
return false;
|
|
183
199
|
}
|
|
184
|
-
return { status: 'configured', messages, changedFiles: [path] };
|
|
185
200
|
},
|
|
186
201
|
async revert(opts) {
|
|
187
|
-
const path =
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const hasLegacy = (await fileExists(base))
|
|
192
|
-
? await (async () => {
|
|
193
|
-
if (opts.dryRun) {
|
|
194
|
-
const { readFile } = await import('node:fs/promises');
|
|
195
|
-
return (await readFile(base, 'utf-8')).includes('# >>> anyray connect >>>');
|
|
196
|
-
}
|
|
197
|
-
return removeProfileBlock(base);
|
|
198
|
-
})()
|
|
199
|
-
: false;
|
|
200
|
-
if (!hasProfile && !hasLegacy) {
|
|
202
|
+
const path = configPath();
|
|
203
|
+
const hasConfig = await fileExists(path);
|
|
204
|
+
const hasLegacyProfile = await fileExists(legacyProfilePath());
|
|
205
|
+
if (!hasConfig && !hasLegacyProfile) {
|
|
201
206
|
return { status: 'not-found', messages: ['nothing to revert'] };
|
|
202
207
|
}
|
|
203
|
-
const changed = [];
|
|
204
208
|
const messages = [];
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
209
|
+
const changed = [];
|
|
210
|
+
if (hasConfig) {
|
|
211
|
+
const stripped = removeManagedBlock(await readFile(path, 'utf-8'));
|
|
212
|
+
if (stripped !== null) {
|
|
213
|
+
if (!opts.dryRun)
|
|
214
|
+
await writeFile(path, stripped);
|
|
215
|
+
changed.push(path);
|
|
216
|
+
messages.push(opts.dryRun
|
|
217
|
+
? `would remove the Anyray default route from ${path}`
|
|
218
|
+
: `removed the Anyray default route from ${path}`);
|
|
219
|
+
}
|
|
210
220
|
}
|
|
211
|
-
if (
|
|
212
|
-
|
|
221
|
+
if (hasLegacyProfile) {
|
|
222
|
+
if (!opts.dryRun)
|
|
223
|
+
await rm(legacyProfilePath(), { force: true });
|
|
224
|
+
changed.push(legacyProfilePath());
|
|
213
225
|
messages.push(opts.dryRun
|
|
214
|
-
? `would remove the
|
|
215
|
-
: `removed the
|
|
226
|
+
? `would remove the old opt-in profile ${legacyProfilePath()}`
|
|
227
|
+
: `removed the old opt-in profile ${legacyProfilePath()}`);
|
|
228
|
+
}
|
|
229
|
+
if (changed.length === 0) {
|
|
230
|
+
return { status: 'not-found', messages: ['nothing to revert'] };
|
|
231
|
+
}
|
|
232
|
+
if (await fileExists(backupPath())) {
|
|
233
|
+
messages.push(`Pre-Anyray backup at ${backupPath()} (restore for a full revert).`);
|
|
216
234
|
}
|
|
217
235
|
return { status: 'reverted', messages, changedFiles: changed };
|
|
218
236
|
},
|
package/dist/tools/codex.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex.js","sourceRoot":"","sources":["../../src/tools/codex.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"codex.js","sourceRoot":"","sources":["../../src/tools/codex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAQhC,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEzE;;uBAEuB;AACvB,MAAM,cAAc,GAAG,OAAO,CAAC;AAC/B,MAAM,oBAAoB,GAAG,WAAW,CAAC;AAEzC;iEACiE;AACjE,MAAM,qBAAqB,GAAG,uCAAuC,CAAC;AAEtE;;;+EAG+E;AAC/E,MAAM,4BAA4B,GAChC,iHAAiH,CAAC;AAEpH,4EAA4E;AAC5E,MAAM,SAAS,GAAG,GAAW,EAAE,CAC7B,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,CAAC;AAE9D,MAAM,UAAU,GAAG,GAAW,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,aAAa,CAAC,CAAC;AAClE,MAAM,UAAU,GAAG,GAAW,EAAE,CAAC,GAAG,UAAU,EAAE,aAAa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,MAAM,EAAE,CAAC,iBAAiB,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACjE,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;YAClC,QAAQ,CAAC,IAAI,CACX,IAAI,CAAC,MAAM;gBACT,CAAC,CAAC,uCAAuC,iBAAiB,EAAE,EAAE;gBAC9D,CAAC,CAAC,kCAAkC,iBAAiB,EAAE,EAAE,CAC5D,CAAC;QACJ,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,mBAAmB,CAAC,EAAE,CAAC;QAClE,CAAC;QACD,IAAI,MAAM,UAAU,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC;YACnC,QAAQ,CAAC,IAAI,CACX,wBAAwB,UAAU,EAAE,+BAA+B,CACpE,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC;IACjE,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manage the always-on Anyray "default route" inside Codex's base `config.toml`.
|
|
3
|
+
*
|
|
4
|
+
* Always-on means plain `codex` (no `--profile`) routes through the gateway, so
|
|
5
|
+
* we must set the top-level `model_provider = "anyray"` selector. TOML requires
|
|
6
|
+
* every bare key to appear BEFORE the first `[table]`, so we insert our managed
|
|
7
|
+
* block (selector keys + the `[model_providers.anyray]` table) immediately
|
|
8
|
+
* before the first table header in the file — or at EOF when there are none.
|
|
9
|
+
*
|
|
10
|
+
* We own exactly the region between the begin/end markers: re-applying replaces
|
|
11
|
+
* it, reverting removes it. These are the same markers `profile.ts` uses, so an
|
|
12
|
+
* upsert also subsumes (migrates) the legacy opt-in `[profiles.anyray]` block an
|
|
13
|
+
* older connect may have left here. To avoid a duplicate-key parse error we drop
|
|
14
|
+
* any pre-existing top-level key we own (e.g. `model_provider`) that lives
|
|
15
|
+
* OUTSIDE our block — taking over the default route is the whole point.
|
|
16
|
+
*
|
|
17
|
+
* These are pure string transforms (no I/O) so they're trivially testable; the
|
|
18
|
+
* adapter does the file read/write/backup around them.
|
|
19
|
+
*/
|
|
20
|
+
const BEGIN = '# >>> anyray connect >>>';
|
|
21
|
+
const END = '# <<< anyray connect <<<';
|
|
22
|
+
const escape = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
23
|
+
/** Remove every managed anyray block (and the blank line preceding each). */
|
|
24
|
+
const stripBlock = (content) => {
|
|
25
|
+
const pattern = new RegExp(`\\n*${escape(BEGIN)}[\\s\\S]*?${escape(END)}\\n?`, 'g');
|
|
26
|
+
return content.replace(pattern, '');
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The code-only prefix of a line: string contents and `#` comments removed, so
|
|
30
|
+
* the remaining `[`/`]` come only from array syntax. Good enough for tracking
|
|
31
|
+
* multi-line arrays; triple-quoted strings (vanishingly rare in a Codex config)
|
|
32
|
+
* are handled separately by the line scanner.
|
|
33
|
+
*/
|
|
34
|
+
const codePart = (s) => {
|
|
35
|
+
let out = '';
|
|
36
|
+
let inStr = false;
|
|
37
|
+
let quote = '';
|
|
38
|
+
for (let i = 0; i < s.length; i++) {
|
|
39
|
+
const c = s[i];
|
|
40
|
+
if (inStr) {
|
|
41
|
+
if (c === '\\' && quote === '"') {
|
|
42
|
+
i++; // skip the escaped char in a basic (double-quoted) string
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (c === quote)
|
|
46
|
+
inStr = false;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (c === '"' || c === "'") {
|
|
50
|
+
inStr = true;
|
|
51
|
+
quote = c;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (c === '#')
|
|
55
|
+
break; // rest of the line is a comment
|
|
56
|
+
out += c;
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
};
|
|
60
|
+
const occurrences = (s, sub) => s.split(sub).length - 1;
|
|
61
|
+
const bracketDelta = (code) => occurrences(code, '[') - occurrences(code, ']');
|
|
62
|
+
const unquote = (s) => s.replace(/^['"]|['"]$/g, '');
|
|
63
|
+
/**
|
|
64
|
+
* Classify each line at TOML statement position. A line is only a table header
|
|
65
|
+
* or a key assignment when we're not inside a multi-line array or string —
|
|
66
|
+
* otherwise it's continuation text. Returns one entry per input line.
|
|
67
|
+
*/
|
|
68
|
+
const scan = (lines) => {
|
|
69
|
+
const meta = [];
|
|
70
|
+
let arrayDepth = 0;
|
|
71
|
+
let inTriple = false;
|
|
72
|
+
let tripleDelim = '';
|
|
73
|
+
for (const line of lines) {
|
|
74
|
+
if (inTriple) {
|
|
75
|
+
if (occurrences(line, tripleDelim) % 2 === 1)
|
|
76
|
+
inTriple = false;
|
|
77
|
+
meta.push({ kind: 'other' });
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (arrayDepth > 0) {
|
|
81
|
+
arrayDepth = Math.max(0, arrayDepth + bracketDelta(codePart(line)));
|
|
82
|
+
meta.push({ kind: 'other' });
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const trimmed = line.trim();
|
|
86
|
+
if (trimmed === '' || trimmed.startsWith('#')) {
|
|
87
|
+
meta.push({ kind: 'other' });
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (trimmed.startsWith('[')) {
|
|
91
|
+
meta.push({ kind: 'table' });
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
// `key = value` (possibly opening a multi-line array or string).
|
|
95
|
+
const eq = line.indexOf('=');
|
|
96
|
+
const key = eq >= 0 ? unquote(line.slice(0, eq).trim()) : '';
|
|
97
|
+
meta.push({ kind: 'key', key });
|
|
98
|
+
const code = codePart(eq >= 0 ? line.slice(eq + 1) : line);
|
|
99
|
+
for (const d of ['"""', "'''"]) {
|
|
100
|
+
if (occurrences(code, d) % 2 === 1) {
|
|
101
|
+
inTriple = true;
|
|
102
|
+
tripleDelim = d;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (!inTriple)
|
|
106
|
+
arrayDepth = Math.max(0, arrayDepth + bracketDelta(code));
|
|
107
|
+
}
|
|
108
|
+
return meta;
|
|
109
|
+
};
|
|
110
|
+
/** Index of the first top-level `[table]` / `[[array]]` header, or -1 if none. */
|
|
111
|
+
const firstTableIndex = (meta) => meta.findIndex((m) => m.kind === 'table');
|
|
112
|
+
/** True when the file already carries our managed block. */
|
|
113
|
+
export const hasManagedBlock = (content) => content.includes(BEGIN);
|
|
114
|
+
/**
|
|
115
|
+
* Insert (or replace) the managed block carrying `blockLines`, placing it just
|
|
116
|
+
* before the first table header so its top-level selector keys stay in
|
|
117
|
+
* top-level scope. `ownedKeys` lists top-level bare keys we set inside the block
|
|
118
|
+
* (e.g. `model_provider`); any copy of one living outside the block, before the
|
|
119
|
+
* first table, is removed so TOML doesn't see a duplicate key.
|
|
120
|
+
*/
|
|
121
|
+
export const upsertManagedBlock = (content, blockLines, ownedKeys) => {
|
|
122
|
+
const stripped = stripBlock(content);
|
|
123
|
+
const lines = stripped.split('\n');
|
|
124
|
+
const meta = scan(lines);
|
|
125
|
+
const tableIdx = firstTableIndex(meta);
|
|
126
|
+
const owned = new Set(ownedKeys);
|
|
127
|
+
const cut = tableIdx === -1 ? lines.length : tableIdx;
|
|
128
|
+
const kept = [];
|
|
129
|
+
for (let i = 0; i < lines.length; i++) {
|
|
130
|
+
const m = meta[i];
|
|
131
|
+
if (i < cut && m.kind === 'key' && owned.has(m.key))
|
|
132
|
+
continue; // drop dup
|
|
133
|
+
kept.push(lines[i]);
|
|
134
|
+
}
|
|
135
|
+
// Recompute the boundary after removals, then split top-level keys from tables.
|
|
136
|
+
const keptMeta = scan(kept);
|
|
137
|
+
const boundary = firstTableIndex(keptMeta);
|
|
138
|
+
const head = (boundary === -1 ? kept : kept.slice(0, boundary)).join('\n');
|
|
139
|
+
const tail = boundary === -1 ? '' : kept.slice(boundary).join('\n');
|
|
140
|
+
const block = [BEGIN, ...blockLines, END].join('\n');
|
|
141
|
+
const parts = [head.replace(/\s*$/, ''), block, tail.replace(/^\s*/, '')]
|
|
142
|
+
.filter((p) => p.length > 0)
|
|
143
|
+
.join('\n\n');
|
|
144
|
+
return parts.replace(/\s*$/, '') + '\n';
|
|
145
|
+
};
|
|
146
|
+
/** Remove every managed block; returns null when there was nothing to remove. */
|
|
147
|
+
export const removeManagedBlock = (content) => {
|
|
148
|
+
if (!hasManagedBlock(content))
|
|
149
|
+
return null;
|
|
150
|
+
const next = stripBlock(content).replace(/\s*$/, '');
|
|
151
|
+
return next.length > 0 ? next + '\n' : '';
|
|
152
|
+
};
|
|
153
|
+
//# sourceMappingURL=codexConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codexConfig.js","sourceRoot":"","sources":["../../src/util/codexConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,KAAK,GAAG,0BAA0B,CAAC;AACzC,MAAM,GAAG,GAAG,0BAA0B,CAAC;AAEvC,MAAM,MAAM,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AAE/E,6EAA6E;AAC7E,MAAM,UAAU,GAAG,CAAC,OAAe,EAAU,EAAE;IAC7C,MAAM,OAAO,GAAG,IAAI,MAAM,CACxB,OAAO,MAAM,CAAC,KAAK,CAAC,aAAa,MAAM,CAAC,GAAG,CAAC,MAAM,EAClD,GAAG,CACJ,CAAC;IACF,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAU,EAAE;IACrC,IAAI,GAA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AEpE,MAAM,KAAK,GAAG,CAAC,KAAK,EAAE,GAAG,UAAU,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrD,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;SACtE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;SAC3B,IAAI,CAAC,MAAM,CAAC,CAAC;IAChB,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC;AAC1C,CAAC,CAAC;AAEF,iFAAiF;AACjF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAe,EAAiB,EAAE;IACnE,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3C,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACrD,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AAC5C,CAAC,CAAC"}
|
package/dist/util/trimOutput.js
CHANGED
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
* output, and search dumps) and elide the middle behind a CONTENT-FREE marker.
|
|
14
14
|
* No network, no model call, no stash — a `connect` hook can't reach the
|
|
15
15
|
* gateway's `/v1/retrieve`, so this trades reversibility for cache-safety and
|
|
16
|
-
* zero data exposure. Char-based (a ~
|
|
16
|
+
* zero data exposure. Char-based (a ~3.3 chars/token heuristic) to stay
|
|
17
17
|
* dependency-free and fast on the hot path.
|
|
18
18
|
*
|
|
19
19
|
* PRIVACY: nothing here logs or transmits the content; the marker carries only
|
|
20
20
|
* counts. The trimmed text is handed straight back to Claude Code.
|
|
21
21
|
*/
|
|
22
|
-
/** ~
|
|
23
|
-
const CHARS_PER_TOKEN =
|
|
22
|
+
/** ~3.3 chars per token — calibrated against BPE on English + code. */
|
|
23
|
+
const CHARS_PER_TOKEN = 3.3;
|
|
24
24
|
/** Generous upper bound on one elision marker's length (actual ~86 chars). Used
|
|
25
25
|
* to reserve budget so the trimmed total — kept content PLUS markers — stays
|
|
26
26
|
* under `maxChars`, not just the kept content. */
|
|
@@ -125,7 +125,7 @@ export const trimText = (input, opts = {}) => {
|
|
|
125
125
|
return passthrough(input);
|
|
126
126
|
// Net reduction: what the output actually shrank by (original minus the kept
|
|
127
127
|
// remainder, which already includes the re-sent markers). This keeps
|
|
128
|
-
// estTokensSaved === round(charsRemoved /
|
|
128
|
+
// estTokensSaved === round(charsRemoved / 3.3) and matches the gateway's
|
|
129
129
|
// server-side definition, so "saved" means the same thing everywhere.
|
|
130
130
|
const charsRemoved = len - text.length;
|
|
131
131
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trimOutput.js","sourceRoot":"","sources":["../../src/util/trimOutput.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AA4CH,
|
|
1
|
+
{"version":3,"file":"trimOutput.js","sourceRoot":"","sources":["../../src/util/trimOutput.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AA4CH,uEAAuE;AACvE,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B;;mDAEmD;AACnD,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B,MAAM,CAAC,MAAM,YAAY,GAA0B;IACjD,QAAQ,EAAE,MAAM;IAChB,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;IAChB,aAAa,EAAE,CAAC;CACjB,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,IAAY,EAAc,EAAE,CAAC,CAAC;IACjD,IAAI;IACJ,OAAO,EA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E,SAAS,EAAE,CAAC;IAC3C,CAAC;IACD,IAAI,QAAQ,KAAK,CAAC,IAAI,SAAS,GAAG,YAAY;QAAE,OAAO,KAAK,CAAC;IAC7D,OAAO,SAAS,GAAG,QAAQ,IAAI,QAAQ,CAAC;AAC1C,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anyray-connect",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.10",
|
|
4
4
|
"description": "Anyray connect — points local coding tools (Claude Code, Cursor, Windsurf, SDKs) at the Anyray gateway by writing their base URL + a placeholder key. The gateway stays the brain; this is just the on-ramp.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|