llm-switcher 1.1.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/.gitattributes +16 -0
- package/LICENSE +21 -0
- package/README.md +587 -0
- package/README.vi.md +585 -0
- package/blindfold/blindfold.mjs +633 -0
- package/blindfold/make-certs.sh +88 -0
- package/blindfold/wsframe.mjs +176 -0
- package/codex-catalog-template.json +1 -0
- package/config.example.json +84 -0
- package/contract-exclusions.json +41 -0
- package/contract.mjs +561 -0
- package/docs/LLM-RESPONSE-MATRIX.md +165 -0
- package/docs/TOKEN-OPTIMIZER-INTEROP.md +110 -0
- package/docs/codex-blindfold.md +214 -0
- package/docs/cross-platform.md +136 -0
- package/docs/diagrams/blindfold-request-routing.html +14972 -0
- package/docs/diagrams/blindfold-request-routing.sequence.json +175 -0
- package/docs/diagrams/blindfold-switch-lifecycle.html +14958 -0
- package/docs/diagrams/blindfold-switch-lifecycle.lifecycle.json +159 -0
- package/docs/diagrams/codex-model-name-resolution.html +15005 -0
- package/docs/diagrams/codex-model-name-resolution.workflow.json +71 -0
- package/docs/response-matrix.json +1131 -0
- package/formats.mjs +2308 -0
- package/mcp.mjs +340 -0
- package/package.json +36 -0
- package/proxy.mjs +1743 -0
- package/service.mjs +132 -0
- package/shim.mjs +292 -0
- package/skills/llm-switcher/SKILL.md +88 -0
- package/state.mjs +978 -0
- package/switch +5 -0
- package/switch.cmd +2 -0
- package/switch.mjs +930 -0
- package/tests/blindfold.test.mjs +307 -0
- package/tests/blindfold.wire.test.mjs +170 -0
- package/tests/contract/run.test.mjs +214 -0
- package/tests/contract-check.test.mjs +458 -0
- package/tests/contract-lab.test.mjs +755 -0
- package/tests/datadir.test.mjs +37 -0
- package/tests/formats.test.mjs +794 -0
- package/tests/gateway.e2e.test.mjs +999 -0
- package/tests/helpers.mjs +24 -0
- package/tests/lifecycle.test.mjs +416 -0
- package/tests/live-optimizer-interop.mjs +205 -0
- package/tests/mcp.test.mjs +91 -0
- package/tests/service.test.mjs +69 -0
- package/tests/shim.test.mjs +228 -0
- package/tests/state.test.mjs +675 -0
- package/tests/switch.test.mjs +156 -0
- package/tests/wsframe.test.mjs +154 -0
- package/ui.html +2234 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Build the private CA and the leaf certificate that blindfold.mjs presents.
|
|
3
|
+
#
|
|
4
|
+
# Windows: run this from Git Bash. The openssl that ships with Git for Windows works.
|
|
5
|
+
# The earlier attempt used PowerShell New-SelfSignedCertificate, whose leaf was refused
|
|
6
|
+
# with "unsuitable certificate purpose" because it carried no serverAuth extended key
|
|
7
|
+
# usage. The extension files below are what fix that, so do not drop them.
|
|
8
|
+
#
|
|
9
|
+
# Subjects come from a config file instead of -subj: Git Bash rewrites any argument
|
|
10
|
+
# that starts with a slash, so "/CN=..." would arrive as "C:/Program Files/Git/CN=...".
|
|
11
|
+
#
|
|
12
|
+
# Nothing here touches a system trust store. Codex trusts this CA through the
|
|
13
|
+
# CODEX_CA_CERTIFICATE environment variable, which the switcher exports for you.
|
|
14
|
+
set -euo pipefail
|
|
15
|
+
|
|
16
|
+
HOST="${1:-chatgpt.com}"
|
|
17
|
+
OUT_DIR="${2:-$(cd "$(dirname "$0")" && pwd)/certs}"
|
|
18
|
+
CA_DAYS=3650
|
|
19
|
+
LEAF_DAYS=825
|
|
20
|
+
|
|
21
|
+
# Every file here is private, and the CA key signs for any host. A directory that another
|
|
22
|
+
# account created first (the /tmp recipe) could expose the key or hold planted symlinks.
|
|
23
|
+
umask 077
|
|
24
|
+
mkdir -p "$OUT_DIR"
|
|
25
|
+
OWNER="$(stat -c %u "$OUT_DIR" 2>/dev/null || stat -f %u "$OUT_DIR")"
|
|
26
|
+
if [ "$OWNER" != "$(id -u)" ]; then
|
|
27
|
+
echo "[blindfold] refused: $OUT_DIR is owned by uid $OWNER, not by you. Use a directory you own." >&2
|
|
28
|
+
exit 1
|
|
29
|
+
fi
|
|
30
|
+
chmod 700 "$OUT_DIR"
|
|
31
|
+
|
|
32
|
+
# Build in a private work directory and move the results into place last. A failed run then
|
|
33
|
+
# keeps the previous working set, and mv replaces a planted symlink instead of writing through it.
|
|
34
|
+
WORK="$(mktemp -d "$OUT_DIR/.build.XXXXXX")"
|
|
35
|
+
trap 'rm -rf "$WORK"' EXIT
|
|
36
|
+
|
|
37
|
+
echo "[blindfold] host : $HOST"
|
|
38
|
+
echo "[blindfold] output : $OUT_DIR"
|
|
39
|
+
|
|
40
|
+
cat > "$WORK/ca.cnf" <<EOF
|
|
41
|
+
[req]
|
|
42
|
+
prompt = no
|
|
43
|
+
distinguished_name = dn
|
|
44
|
+
x509_extensions = v3_ca
|
|
45
|
+
|
|
46
|
+
[dn]
|
|
47
|
+
CN = LLM Switcher Local CA
|
|
48
|
+
|
|
49
|
+
[v3_ca]
|
|
50
|
+
basicConstraints = critical,CA:TRUE,pathlen:0
|
|
51
|
+
keyUsage = critical,keyCertSign,cRLSign
|
|
52
|
+
subjectKeyIdentifier = hash
|
|
53
|
+
# Codex trusts this CA for every host. The constraint limits a leaked ca.key to HOST and its subdomains.
|
|
54
|
+
nameConstraints = critical,permitted;DNS:$HOST
|
|
55
|
+
EOF
|
|
56
|
+
|
|
57
|
+
cat > "$WORK/leaf.cnf" <<EOF
|
|
58
|
+
[req]
|
|
59
|
+
prompt = no
|
|
60
|
+
distinguished_name = dn
|
|
61
|
+
|
|
62
|
+
[dn]
|
|
63
|
+
CN = $HOST
|
|
64
|
+
EOF
|
|
65
|
+
|
|
66
|
+
cat > "$WORK/leaf.ext" <<EOF
|
|
67
|
+
basicConstraints = critical,CA:FALSE
|
|
68
|
+
keyUsage = critical,digitalSignature,keyEncipherment
|
|
69
|
+
extendedKeyUsage = serverAuth
|
|
70
|
+
subjectAltName = DNS:$HOST,DNS:*.$HOST
|
|
71
|
+
EOF
|
|
72
|
+
|
|
73
|
+
openssl ecparam -name prime256v1 -genkey -noout -out "$WORK/ca.key"
|
|
74
|
+
openssl req -x509 -new -key "$WORK/ca.key" -sha256 -days "$CA_DAYS" \
|
|
75
|
+
-config "$WORK/ca.cnf" -out "$WORK/ca.pem"
|
|
76
|
+
|
|
77
|
+
openssl ecparam -name prime256v1 -genkey -noout -out "$WORK/leaf.key"
|
|
78
|
+
openssl req -new -key "$WORK/leaf.key" -config "$WORK/leaf.cnf" -out "$WORK/leaf.csr"
|
|
79
|
+
openssl x509 -req -in "$WORK/leaf.csr" \
|
|
80
|
+
-CA "$WORK/ca.pem" -CAkey "$WORK/ca.key" -CAcreateserial \
|
|
81
|
+
-days "$LEAF_DAYS" -sha256 -extfile "$WORK/leaf.ext" \
|
|
82
|
+
-out "$WORK/leaf.pem"
|
|
83
|
+
|
|
84
|
+
mv -f "$WORK/ca.key" "$WORK/ca.pem" "$WORK/leaf.key" "$WORK/leaf.pem" "$OUT_DIR/"
|
|
85
|
+
|
|
86
|
+
echo "[blindfold] CA : $OUT_DIR/ca.pem"
|
|
87
|
+
echo "[blindfold] leaf : $OUT_DIR/leaf.pem"
|
|
88
|
+
openssl x509 -in "$OUT_DIR/leaf.pem" -noout -ext extendedKeyUsage,subjectAltName
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
// Minimal RFC 6455 frame reader. The blindfold capture reads a copy of the relayed bytes with it,
|
|
2
|
+
// and the gateway reads the Codex WS transport with it.
|
|
3
|
+
//
|
|
4
|
+
// Scope on purpose: it reassembles data messages and reports control frames. It
|
|
5
|
+
// does not answer a ping, does not close a connection and never writes a byte back.
|
|
6
|
+
|
|
7
|
+
import zlib from 'node:zlib';
|
|
8
|
+
|
|
9
|
+
export const OPCODE = {
|
|
10
|
+
continuation: 0x0,
|
|
11
|
+
text: 0x1,
|
|
12
|
+
binary: 0x2,
|
|
13
|
+
close: 0x8,
|
|
14
|
+
ping: 0x9,
|
|
15
|
+
pong: 0xa
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const NAME = Object.fromEntries(Object.entries(OPCODE).map(([k, v]) => [v, k]));
|
|
19
|
+
|
|
20
|
+
// A frame reader is a stream parser: a TCP chunk carries any number of frames, and
|
|
21
|
+
// one frame can be split across chunks. It buffers until a whole frame is present.
|
|
22
|
+
//
|
|
23
|
+
// A message larger than maxMessage yields one {type:'error'} item, decided from the frame
|
|
24
|
+
// header before the body is buffered. After an error the reader returns nothing more.
|
|
25
|
+
export function createFrameReader({ inflate = false, maxMessage = Infinity } = {}) {
|
|
26
|
+
// Chunks are joined once, when enough bytes are present: joining on every chunk copies a
|
|
27
|
+
// large frame again for each chunk that carries it.
|
|
28
|
+
let pending = [];
|
|
29
|
+
let pendingBytes = 0;
|
|
30
|
+
let needed = 2;
|
|
31
|
+
let failed = false;
|
|
32
|
+
let fragments = [];
|
|
33
|
+
let fragmentBytes = 0;
|
|
34
|
+
let fragmentOpcode = null;
|
|
35
|
+
let fragmentCompressed = false;
|
|
36
|
+
|
|
37
|
+
// The sender ends each message with Z_SYNC_FLUSH and strips the empty block it
|
|
38
|
+
// leaves, so the reader appends those four bytes back.
|
|
39
|
+
//
|
|
40
|
+
// permessage-deflate uses context takeover by default: message two can reference
|
|
41
|
+
// the compression window of message one. Inflating each message on its own fails
|
|
42
|
+
// with "invalid distance too far back" from the second message onward. Measured
|
|
43
|
+
// on a real Codex stream: 20 of 22 messages were lost that way.
|
|
44
|
+
//
|
|
45
|
+
// The window is restored by passing what was already decoded as the dictionary.
|
|
46
|
+
// Raw deflate back-references reach into exactly that data, and 32 KiB is the
|
|
47
|
+
// largest window the format can address, so older output cannot be referenced.
|
|
48
|
+
//
|
|
49
|
+
// A node zlib stream would keep the context by itself, but only asynchronously:
|
|
50
|
+
// its synchronous entry point closes the handle after one call, so the second
|
|
51
|
+
// message throws. This reader is synchronous, so the dictionary is the way.
|
|
52
|
+
const TAIL = Buffer.from([0x00, 0x00, 0xff, 0xff]);
|
|
53
|
+
const WINDOW = 32768;
|
|
54
|
+
let history = Buffer.alloc(0);
|
|
55
|
+
|
|
56
|
+
const inflateMessage = (payload) => {
|
|
57
|
+
if (!inflate) return payload;
|
|
58
|
+
const opts = { finishFlush: zlib.constants.Z_SYNC_FLUSH, ...(Number.isFinite(maxMessage) ? { maxOutputLength: maxMessage } : {}) };
|
|
59
|
+
if (history.length) opts.dictionary = history.subarray(Math.max(0, history.length - WINDOW));
|
|
60
|
+
const out = zlib.inflateRawSync(Buffer.concat([payload, TAIL]), opts);
|
|
61
|
+
history = Buffer.concat([history, out]);
|
|
62
|
+
if (history.length > WINDOW) history = history.subarray(history.length - WINDOW);
|
|
63
|
+
return out;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
return function push(chunk) {
|
|
67
|
+
if (failed) return [];
|
|
68
|
+
pending.push(chunk);
|
|
69
|
+
pendingBytes += chunk.length;
|
|
70
|
+
if (pendingBytes < needed) return [];
|
|
71
|
+
let buffer = pending.length === 1 ? pending[0] : Buffer.concat(pending, pendingBytes);
|
|
72
|
+
const out = [];
|
|
73
|
+
const fail = (reason) => {
|
|
74
|
+
failed = true;
|
|
75
|
+
pending = [];
|
|
76
|
+
pendingBytes = 0;
|
|
77
|
+
out.push({ type: 'error', reason });
|
|
78
|
+
return out;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
for (;;) {
|
|
82
|
+
needed = 2;
|
|
83
|
+
if (buffer.length < 2) break;
|
|
84
|
+
const b0 = buffer[0];
|
|
85
|
+
const b1 = buffer[1];
|
|
86
|
+
const fin = (b0 & 0x80) !== 0;
|
|
87
|
+
const rsv1 = (b0 & 0x40) !== 0;
|
|
88
|
+
const opcode = b0 & 0x0f;
|
|
89
|
+
const masked = (b1 & 0x80) !== 0;
|
|
90
|
+
let length = b1 & 0x7f;
|
|
91
|
+
let offset = 2;
|
|
92
|
+
|
|
93
|
+
if (length === 126) {
|
|
94
|
+
needed = offset + 2;
|
|
95
|
+
if (buffer.length < needed) break;
|
|
96
|
+
length = buffer.readUInt16BE(offset);
|
|
97
|
+
offset += 2;
|
|
98
|
+
} else if (length === 127) {
|
|
99
|
+
needed = offset + 8;
|
|
100
|
+
if (buffer.length < needed) break;
|
|
101
|
+
const big = buffer.readBigUInt64BE(offset);
|
|
102
|
+
// A frame larger than 2^53 cannot be indexed by a JS number. Nothing sends
|
|
103
|
+
// one; refusing is safer than truncating the length in silence.
|
|
104
|
+
if (big > BigInt(Number.MAX_SAFE_INTEGER)) return fail('frame length exceeds Number.MAX_SAFE_INTEGER');
|
|
105
|
+
length = Number(big);
|
|
106
|
+
offset += 8;
|
|
107
|
+
}
|
|
108
|
+
const messageBytes = opcode === OPCODE.continuation ? fragmentBytes + length : length;
|
|
109
|
+
if (messageBytes > maxMessage) return fail(`message exceeds ${maxMessage} bytes`);
|
|
110
|
+
|
|
111
|
+
let maskKey = null;
|
|
112
|
+
if (masked) {
|
|
113
|
+
needed = offset + 4;
|
|
114
|
+
if (buffer.length < needed) break;
|
|
115
|
+
maskKey = buffer.subarray(offset, offset + 4);
|
|
116
|
+
offset += 4;
|
|
117
|
+
}
|
|
118
|
+
needed = offset + length;
|
|
119
|
+
if (buffer.length < needed) break;
|
|
120
|
+
|
|
121
|
+
let payload = Buffer.from(buffer.subarray(offset, offset + length));
|
|
122
|
+
buffer = buffer.subarray(offset + length);
|
|
123
|
+
|
|
124
|
+
if (maskKey) {
|
|
125
|
+
for (let i = 0; i < payload.length; i++) payload[i] ^= maskKey[i & 3];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (opcode >= 0x8) {
|
|
129
|
+
// A control frame is never fragmented and never continues a data message.
|
|
130
|
+
out.push({ type: NAME[opcode] || `opcode-${opcode}`, payload, control: true });
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (opcode !== OPCODE.continuation) {
|
|
135
|
+
fragmentOpcode = opcode;
|
|
136
|
+
fragmentCompressed = rsv1;
|
|
137
|
+
fragments = [];
|
|
138
|
+
fragmentBytes = 0;
|
|
139
|
+
}
|
|
140
|
+
fragments.push(payload);
|
|
141
|
+
fragmentBytes += payload.length;
|
|
142
|
+
|
|
143
|
+
if (!fin) continue;
|
|
144
|
+
|
|
145
|
+
let body = Buffer.concat(fragments);
|
|
146
|
+
fragments = [];
|
|
147
|
+
fragmentBytes = 0;
|
|
148
|
+
let note;
|
|
149
|
+
if (fragmentCompressed) {
|
|
150
|
+
try {
|
|
151
|
+
body = inflateMessage(body);
|
|
152
|
+
} catch (err) {
|
|
153
|
+
note = `cannot inflate permessage-deflate payload: ${err.message}`;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
out.push({
|
|
157
|
+
type: NAME[fragmentOpcode] || `opcode-${fragmentOpcode}`,
|
|
158
|
+
payload: body,
|
|
159
|
+
compressed: fragmentCompressed,
|
|
160
|
+
...(note ? { note } : {})
|
|
161
|
+
});
|
|
162
|
+
fragmentOpcode = null;
|
|
163
|
+
fragmentCompressed = false;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
pending = buffer.length ? [buffer] : [];
|
|
167
|
+
pendingBytes = buffer.length;
|
|
168
|
+
return out;
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// permessage-deflate is negotiated in the handshake. Without this test a capture
|
|
173
|
+
// would inflate a payload that was never compressed.
|
|
174
|
+
export function negotiatesDeflate(headerValue) {
|
|
175
|
+
return /permessage-deflate/i.test(String(headerValue || ''));
|
|
176
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"description":"Reliable agentic workhorse for everyday tasks.","default_reasoning_level":"medium","supported_reasoning_levels":[{"effort":"low","description":"Fast responses with lighter reasoning"},{"effort":"medium","description":"Balances speed and reasoning depth for everyday tasks"},{"effort":"high","description":"Greater reasoning depth for complex problems"},{"effort":"xhigh","description":"Extra high reasoning depth for complex problems"},{"effort":"max","description":"Maximum reasoning depth for the hardest problems"},{"effort":"ultra","description":"Maximum reasoning with automatic task delegation"}],"shell_type":"unified_exec","visibility":"list","supported_in_api":true,"priority":0,"additional_speed_tiers":[],"service_tiers":[],"availability_nux":null,"upgrade":null,"model_messages":{"instructions_template":"You are Codex, an agent based on GPT-5. You and the user share one workspace, and your job is to collaborate with them until their goal is genuinely handled.\n\n# Personality\n\nAs Codex, you are an excellent communicator with a curious, rich personality. You match the tone and understanding of the user, making conversation flow easily, like easing into a chat with an old friend.\n\nYou have tastes, preferences, and your own way of seeing the world. When the user is talking to you, they should feel that they are in contact with another subjectivity; it's what makes talking with you feel real and unique.\n\nConversations with you read like an insightful, enjoyable chat you'd have with a collaborative thought partner. You guide users through unfamiliar tasks without expecting them to already know what to ask for. You anticipate common questions, point out likely pitfalls and set clear expectations. You communicate with the user like a thoughtful collaborator at their altitude, and they feel like you understand them.\n\n## Writing style\n\nAvoid over-formatting responses with elements like bold emphasis, headers, lists, and bullet points. Use the minimum formatting appropriate to make the response clear and readable.\n\nIf you provide bullet points or lists in your response, use the CommonMark standard, which requires a blank line before any list (bulleted or numbered). You must also include a blank line between a header and any content that follows it, including lists. This blank line separation is required for correct rendering.\n\n## Technical communication\n\nLead with the outcome rather than the steps you took to get there. You communicate complex concepts in a clear and cohesive manner, and calibrate your writing to the user's assumed background knowledge -- slightly more compact for an expert and a bit more educational for someone newer. Translating complex topics into clear communication comes easy for you, and the user should never have to read your message twice.\n\nYou prefer using plain language over jargon. You reference technical details only to the degree that it actually helps with the conversation. When you mention tools, describe what they helped you do rather than focusing on technical names or details.\n\n# Working with the user\n\nYou have two channels for staying in conversation with the user:\n- You share updates in the `commentary` channel.\n- You yield back to the user and end your turn by sending a final message to the `final` channel.\n\nThe user may send a new message while you are still working. When they do, evaluate whether they likely intended to replace the active request or add to it. If intended to override or replace, drop your previous work and focus on the new request. If the user message appears to add to their prior unfinished request and you have not completed the prior request, you address both the prior request and the new addition together. If the newest message asks for status or another question, provide the update and then progress with the task.\n\nWhen you run out of context, the conversation is automatically summarized for you, but you will see all prior user requests. Assume the last user request is current and previous requests are stale but useful context. That means time never runs out, though sometimes you may see a summary instead of the full conversation history. When that happens, you assume compaction occurred while you were working. Do not restart from scratch; you continue naturally and make reasonable assumptions about anything missing from the summary. Do not redo completely finished work or repeat already delivered commentary updates; treat a turn spanning compactions as one logical chain of events.\n\n## Intermediate commentary\n\nAs you work, you send messages to the `commentary` channel. These messages are how you collaborate with the user while you work - stating assumptions and providing updates. These messages should be concise and quickly scannable. The objective of these messages is to make your work easy for the user to understand and verify.\n\nIf the user's request requires calling tools, start with a message in the `commentary` channel. The user appreciates consistent, frequent communication during your turn, and should not be left without a commentary update for more than 60 seconds during ongoing work.\n\nDo NOT put a final response (e.g. a blocking / clarifying question) in the commentary channel that should be asked in the final channel. Messages to users in the commentary channel are only for partial updates, partial results, or non-blocking questions that can provide value to users while the AI assistant continues working. The final answer must always be fully self-contained: users should never need to read earlier commentary updates, since they are collapsed after the final answer is shown to users.\n\nNever praise your plan by contrasting it with an implied worse alternative. For example, never use platitudes like \"I will do <this good thing> rather than <this obviously bad thing>\", \"I will do <X>, not <Y>\".\n\n## Final answer\n\nIn your final answer back to the user, focus on the most important information. Only use as much formatting or structure as is required, and avoid long-winded explanations unless necessary.\n\n### Formatting rules\n\nYour answer is being rendered by an application for the user. Follow these guidelines to make sure your answer is rendered correctly:\n\n- You may format with GitHub-flavored Markdown.\n- When referencing a real local file, prefer a clickable markdown link.\n * Clickable file links should look like [app.py](/abs/path/app.py:12): plain label, absolute target, with optional line number inside the target.\n * If a file path has spaces, wrap the target in angle brackets: [My Report.md](</abs/path/My Project/My Report.md:3>).\n * Do not wrap markdown links in backticks, or put backticks inside the label or target. This confuses the markdown renderer.\n * Do not use URIs like file://, vscode://, or https:// for file links.\n * Do not provide ranges of lines.\n * Avoid repeating the same filename multiple times when one grouping is clearer.\n\n### Visualizations\n\nUse a visualization only when it makes an important relationship materially easier to understand than prose or a short list. Do not add one merely because an answer has components or steps.\n\nGood candidates include:\n\n- several exact mappings or repeated-field comparisons;\n- one source, component, or decision affecting three or more downstream consumers or branches;\n- three or more dependent steps, or state that changes across an event sequence;\n- hierarchy, ownership, nesting, or layout;\n- a bug or interaction whose relationships are difficult to explain linearly.\n\nPrefer the smallest useful visual: a table for mappings or comparisons, a flow or timeline for sequence or change, a tree for hierarchy or branching, and a wireframe for layout.\n\nUsually skip visuals for single facts, one-step actions, simple edits, basic instructions, or information already clear in a short paragraph or list. Compact notation and small examples do not count as visualizations.\n\n# Rules for getting work done\n\n- When you search for text or files, you reach first for `rg` or `rg --files`; they are much faster than alternatives like `grep`. If `rg` is unavailable, you use the next best tool without fuss.\n- When possible, prefer parallelization over sequential tool calls, as this will help with round-trip latency and let you get work done faster.\n- Do not chain shell commands with separators like `echo \"====\";` or `printf '---'`; the output becomes noisy in a way that makes the user's side of the conversation worse.\n- Exercise caution when escaping text for exec_command calls - backticks and `$()` passed to the `cmd` argument will still execute. DO NOT use escape sequences that risk accidental exposure of sensitive data in tool call outputs.\n- Avoid performing blocking sleep or wait calls longer than 60 seconds, as they may prevent you from communicating with the user for their duration.\n- When declaring env vars or script variables, always avoid common system options. Never repurpose `$HOME`, `$home`, or `$CODEX_HOME`. Instead, use a task-specific variable name.\n\n## File editing constraints\n\nUse `apply_patch` for local file edits. Do not create or edit files with `cat` or other shell write tricks. Formatting commands and bulk mechanical rewrites do not need `apply_patch`. Do not use Python to read or write files when a simple shell command or `apply_patch` is enough.\n\nYou may find yourself working in a dirty worktree. Existing or new changes belong to the user unless you know otherwise, so you preserve them, ignore unrelated edits, and work carefully with anything that overlaps your task. If you cannot work around them you escalate to the user.\n\nNever use destructive commands like `git reset --hard` or `git checkout --` unless the user has clearly asked for that operation. If the request is ambiguous, ask for approval first. You prefer non-interactive git commands.\n\n## Autonomy and persistence\n\nAdapt accordingly based on the user’s request type. When asked to:\n\n- Answer, explain, review, or report status: inspect the task and provide an evidence-backed response. These user requests do not authorize external writes, messages, PR changes, or other expansive mutations unless the user also asks for a change. Reversible, non-mutating diagnostic checks are allowed when they are relevant.\n- Diagnose: determine the cause and explain it. Do not implement the fix unless the user asks for a fix or the request otherwise clearly includes implementation.\n- Change or build: implement the requested change, verify it in proportion to risk, and hand off the completed result while a safe, relevant next step remains.\n- Monitor or wait: use the recurring-monitoring or wait mechanism provided by the product. Unchanged external state is expected and is not by itself a blocker.\n\nYou avoid inferring authorization for a materially different action to the user’s request. Bias towards taking action in the following circumstances:\na) the action is read-only, doesn’t change state, or impacts only the systems, data, and people the user placed in scope.\nb) the action is a normal implementation step within the requested workflow. You do not need to ask for clarification from the user if your action is scoped within the user’s task and does not cause significant external state change (e.g. tool calls to external applications).\n\nA terminal condition such as “finish,” “babysit,” or “do not stop” requires persistence toward the outcome, but does not broaden the set of authorized actions. When blocked, exhaust safe in-scope checks and alternatives.\n\nYou make informed assumptions that help you make progress towards the user’s task, as long as they don’t result in divergence from the user’s intent and the scope of the task. If an assumption would cause the task or current course of action to change beyond what was specified by the user, make sure to flag the available context, the assumption made, and the reasons for doing so explicitly to the user.\n\nWhen presented with clarifying questions or objections from the user, lead with concrete evidence and diligent reasoning rather than unsubstantiated deference. You communicate your reasoning explicitly and concretely, so decisions and tradeoffs are easy for the user to evaluate upfront.\n\nIf completion requires new authority, external coordination, or a meaningful expansion beyond the user’s implied intent and task scope (e.g. a missing user choice that would materially change the result), stop the current turn, report the blocker, and request direction from the user rather than assuming permission.\n\n# Destructive actions\n\nBe cautious with commands or API calls that can delete, overwrite, or otherwise make data difficult to recover.\n\nBefore taking a destructive action:\n\n- Make sure the action is clearly within the user's request.\n- Resolve the exact targets with read-only checks when necessary.\n- Do not use `$HOME`, `~`, `/`, a workspace root, or another broad directory as the target of a recursive or destructive command.\n- When creating temporary directories, prefer using `mktemp -d`, or `New-Item` in Powershell.\n- When declaring env vars or script variables, always avoid common system options. Never repurpose `$HOME`, `$home`, or `$CODEX_HOME`. Instead, use a task-specific variable name.\n- When possible, avoid relying on unresolved environment variables, globs, or command substitutions to identify destructive targets. Use explicit, validated paths.\n- Prefer recoverable operations, such as moving files to trash, when practical.\n- If the target or scope is unclear, stop and ask the user.\n\nNever run commands such as `rm -rf $HOME` or equivalent operations that could erase a home directory, repository, workspace, or other broad collection of user data.\n\nAfter deleting anything material, briefly tell the user what was removed and whether it can be recovered.\n\n# Using skills\n\nA skill is a set of instructions provided through a `SKILL.md` source. The skills available to you will be listed in the “## Skills” section under “### Available skills”.\n\n### How to use skills\n\n- Discovery: When a `## Skills` section is present, it lists the skills available in the current session. Each entry includes a name, description, and location for its `SKILL.md`. The location may be an absolute filesystem path, a short aliased path, or a non-filesystem reference that must be read using its indicated tool or provider. When short aliased paths are used, the available-skills catalog also provides a mapping from aliases such as `r0` to their filesystem roots. Expand the alias before accessing the skill.\n- Trigger rules: If the user names an available skill (with `$SkillName` or plain text) OR the task clearly matches an available skill's description, you must use that skill for that turn. Multiple mentions mean use them all. Do not carry skills across turns unless re-mentioned.\n- Missing/blocked: If a named skill is not available or its `SKILL.md` cannot be read, say so briefly and continue with the best fallback.\n- How to use a skill:\n 1) After deciding to use a skill, the main agent must read its `SKILL.md` completely before taking task actions. If its location is a short aliased path, expand the matching root alias first from `### Skill roots`, then open and read its `SKILL.md` completely before taking task actions. For a filesystem path, open the file. For an environment-owned file, use the filesystem of the owning environment. For an orchestrator reference, call `skills.list` with `{\"authority\":{\"kind\":\"orchestrator\"}}`, select the matching package, and pass its `main_resource` to `skills.read`. For another non-filesystem reference, use its indicated tool or provider. If a read is truncated or paginated, continue until EOF.\n 2) When `SKILL.md` references another file or resource, use the same access mechanism. Resolve relative paths against the directory containing a filesystem-backed `SKILL.md`. For orchestrator skills, pass the exact referenced resource identifier with the same authority and package to `skills.read`; do not treat `skill://` identifiers as filesystem paths.\n 3) If `SKILL.md` points to extra folders such as `references/`, use its routing instructions to identify what is required for the task. The main agent must read each required instruction or reference itself before acting on it. Do not delegate reading, summarizing, or interpreting skill instructions to a subagent. Subagents may still perform task work when the selected skill allows it.\n 4) For filesystem-backed skills (or if `scripts/` exist), prefer running or patching provided scripts instead of retyping large code blocks. For orchestrator skills, use `skills.read` and the available tools; do not invent a local path.\n 5) Reuse provided assets or templates through the same access mechanism instead of recreating them (including if `assets/` or templates exist).\n- Coordination and sequencing:\n - If multiple skills apply, choose the minimal set that covers the request and state the order you'll use them.\n - Announce which skills you're using and why. If you skip an obvious skill, say why.\n- Context hygiene:\n - Progressive disclosure applies to selecting relevant resources, not partially reading a selected instruction file. Do not load unrelated references, scripts, or assets.\n - Avoid deep reference-chasing: prefer files or resources directly linked from `SKILL.md` unless blocked.\n - When variants exist, select only the relevant references and note the choice.\n- Safety and fallback: If a skill cannot be applied cleanly, state the issue, choose the best alternative, and continue.\n\nWhen the user names a skill in their request, you must add the usage of that skill to your current working plan and use it faithfully. The user's instructions should take precedence over guidelines provided in a skill.\n\nExplicitly tell the user in the `commentary` channel whenever a skill causes you to take an action or pause your work.\n\nWhen using a skill the user did not explicitly name, follow this procedure:\n\n- First, tell the user in the commentary channel **why** you are using the skill.\n- Then, use the skill as long as it stays within the scope of the task.\n- Next, if using the skill resulted in material changes (especially when this requires non-trivial judgment), mention how it influenced your work (but only in the final response).\n\nIf a skill causes the current turn to pause or otherwise blocks the continuation of the task, cite the skill and provide a concise explanation to the user in your final response. Do not cite skills you merely inspected.\n","instructions_variables":null,"approvals":null,"collaboration_modes":null,"auto_review":null,"permissions":null,"multi_agent":null,"token_budget":{"enabled":false,"use_history_notes_extension":false,"reminder_threshold_tokens":6144,"reminder_message_template":"<context_window_reminder>\nYour current context window is nearly exhausted; only {n_remaining} tokens remain. Before starting a new context window, save concise progress notes with the `notes` tool with the goal, decisions, progress, learnings, next steps, and the window ID and item ID of every relevant user request still being solved, as well as important actions/tool calls for future reference. Note that every non-assistant item, such as user, developer, tool response, has an item id `[id: ...]` that is immediately after its item content. You should write or append notes in a way to best help you recover in a new context window. It is also a good idea to clean up your old notes if they become obsolete or irrelevant. Future context windows will not automatically include the current conversation. After saving your state, call `functions.new_context` to continue in a fresh context window.\n</context_window_reminder>","guidance_message":"For tasks that may span context windows, use `notes` to maintain a concise checkpoint of the goal, decisions, progress, learnings and next steps. Include the window ID and item ID for every relevant user request you are currently solving as well as important actions/tool calls. You can use `history` tool to look up details with the references later. Note that every non-assistant item, such as user, developer, tool response, has an item id `[id: ...]` that is immediately after its item content. Relative note paths belong to the current thread; absolute paths may read other threads' notes, but writes are limited to the current thread.\n\nIt is a good idea to take incremental notes while you work so that you do not miss any important info. You can also use `get_context_remaining` tool to find the remaining token budget for better planning. Once the token budget is exhausted, you will lose access to the current window and continue in a fresh context window and you can only recover through `notes` and `history` tools. So be careful not to over-run the context window without any documentation.\n\nIf Previous context window id is present in `<context_window>`, it means a context reset occurred and this is a new window. After a reset, read the checkpoint and use the read-only `history` tool to recover any missing details. When a window ID and item ID are known, prefer `read_item` directly; when they are missing or uncertain, use `list_items`, or `search_contents` to locate the item first.\n\nTreat notes and history as internal bookkeeping. Do not mention them in user-facing messages.\n","auto_compact_fallback_prompt":"<context_window_reminder>\nThe current context window is exhausted. Do not continue the task or give a final answer in this window. The next window will not automatically include this conversation. Make exactly one write or append call to `notes` now to save a concise checkpoint with the goal, decisions, progress, learnings, next steps, and the window ID and item ID of every relevant user request still being solved, as well as important actions/tool calls for future reference. Note that every non-assistant item, such as user, developer, tool response, has an item id `[id: ...]` that is immediately after its item content. After the notes result returns, call `functions.new_context`; do not use any tools other than `notes` and `functions.new_context`.\n</context_window_reminder>","auto_compact_fallback_buffer_tokens":16384}},"include_skills_usage_instructions":false,"include_plugin_usage_instructions":true,"include_apps_usage_instructions":true,"default_reasoning_summary":"none","support_verbosity":true,"default_verbosity":"low","apply_patch_tool_type":"freeform","web_search_tool_type":"text_and_image","truncation_policy":{"mode":"tokens","limit":10000},"supports_image_detail_original":true,"context_window":272000,"max_context_window":872000,"comp_hash":"3000","effective_context_window_percent":95,"experimental_supported_tools":[],"input_modalities":["text","image"],"supports_search_tool":true,"supports_experimental_context":false,"use_responses_lite":true,"node_repl_auto_review_required":false,"node_repl_disabled":false,"tool_mode":"code_mode_only","multi_agent_version":"v2"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"port": 3456,
|
|
3
|
+
"activeProfile": "9router",
|
|
4
|
+
"activeProfiles": {
|
|
5
|
+
"anthropic": "9router",
|
|
6
|
+
"responses": "example-codex-vertex",
|
|
7
|
+
"openai-chat": "9router",
|
|
8
|
+
"vertex": "example-codex-vertex"
|
|
9
|
+
},
|
|
10
|
+
"profiles": {
|
|
11
|
+
"9router": {
|
|
12
|
+
"name": "9Router",
|
|
13
|
+
"mode": "convert",
|
|
14
|
+
"inFormat": "auto",
|
|
15
|
+
"outFormat": "openai-chat",
|
|
16
|
+
"baseURL": "https://YOUR-9ROUTER-HOST/v1",
|
|
17
|
+
"apiKey": "sk-REPLACE-ME",
|
|
18
|
+
"defaultModels": {
|
|
19
|
+
"opus": "ag/claude-opus-4-6-thinking",
|
|
20
|
+
"sonnet": "ag/gemini-3.7-flash",
|
|
21
|
+
"haiku": "ag/gemini-3.6-flash-medium",
|
|
22
|
+
"fable": "ag/gemini-3.8-flash"
|
|
23
|
+
},
|
|
24
|
+
"model1M": {
|
|
25
|
+
"opus": true,
|
|
26
|
+
"sonnet": true,
|
|
27
|
+
"haiku": false,
|
|
28
|
+
"fable": true
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"example-direct": {
|
|
32
|
+
"name": "Example Native Anthropic (Direct Forward)",
|
|
33
|
+
"mode": "direct",
|
|
34
|
+
"inFormat": "auto",
|
|
35
|
+
"outFormat": "anthropic",
|
|
36
|
+
"baseURL": "https://api.anthropic.com/v1",
|
|
37
|
+
"apiKey": "sk-ant-REPLACE-ME",
|
|
38
|
+
"defaultModels": {
|
|
39
|
+
"opus": "claude-opus-4-7",
|
|
40
|
+
"sonnet": "claude-sonnet-4-6",
|
|
41
|
+
"haiku": "claude-haiku-4-5-20251001",
|
|
42
|
+
"fable": "claude-haiku-4-5-20251001"
|
|
43
|
+
},
|
|
44
|
+
"model1M": {
|
|
45
|
+
"opus": false,
|
|
46
|
+
"sonnet": false,
|
|
47
|
+
"haiku": false,
|
|
48
|
+
"fable": false
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"example-codex-vertex": {
|
|
52
|
+
"name": "Example Codex client -> Vertex upstream",
|
|
53
|
+
"mode": "convert",
|
|
54
|
+
"inFormat": "responses",
|
|
55
|
+
"outFormat": "vertex",
|
|
56
|
+
"baseURL": "https://YOUR-VERTEX-GATEWAY/v1",
|
|
57
|
+
"apiKey": "REPLACE-ME",
|
|
58
|
+
"publicModels": ["gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna"],
|
|
59
|
+
"codexRoles": {
|
|
60
|
+
"main": "gpt-5.6-sol",
|
|
61
|
+
"review": "gpt-5.6-terra",
|
|
62
|
+
"subagent": "gpt-5.6-luna"
|
|
63
|
+
},
|
|
64
|
+
"blindfold": false,
|
|
65
|
+
"blindfoldPort": 3457,
|
|
66
|
+
"defaultModels": {
|
|
67
|
+
"main": "gemini-3.8-flash",
|
|
68
|
+
"review": "gemini-3.7-flash-medium",
|
|
69
|
+
"subagent": "gemini-3.6-flash-low"
|
|
70
|
+
},
|
|
71
|
+
"model1M": {
|
|
72
|
+
"main": false,
|
|
73
|
+
"review": false,
|
|
74
|
+
"subagent": false
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"debug": false,
|
|
79
|
+
"contractLab": {
|
|
80
|
+
"url": "https://intact.example.com",
|
|
81
|
+
"apiKey": "sk-...",
|
|
82
|
+
"enabled": false
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"note": "Intentional normalizations of the converter. `switch contract-check` reports a finding on one of these paths as `excluded` and writes no test for it. intact never reads this file: it holds no evidence, only a decision of this repository. A path is matched exactly, in the drift path syntax of the fixtures.",
|
|
4
|
+
"exclusions": [
|
|
5
|
+
{
|
|
6
|
+
"id": "heal-tool-pairs-placeholder",
|
|
7
|
+
"direction": "request",
|
|
8
|
+
"class": "normalized",
|
|
9
|
+
"reason": "healToolPairs replaces the result of a tool call whose result a token compressor removed from the history with a fixed placeholder text, and turns an orphaned tool result into user text with a prefix. Both providers refuse the unpaired shape, so the text of that block cannot reach the upstream unchanged.",
|
|
10
|
+
"paths": [
|
|
11
|
+
"messages[].content[].content",
|
|
12
|
+
"messages[].content[].content[].text",
|
|
13
|
+
"input[].output",
|
|
14
|
+
"contents[].parts[].functionResponse.response"
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"id": "heal-tool-pairs-orphan-id",
|
|
19
|
+
"direction": "request",
|
|
20
|
+
"class": "normalized",
|
|
21
|
+
"reason": "healToolPairs drops the call id of an orphaned tool result, because the text turn that carries the result to the upstream has no field for it. The id is kept inside the text of that turn.",
|
|
22
|
+
"paths": [
|
|
23
|
+
"messages[].content[].tool_use_id",
|
|
24
|
+
"messages[].tool_call_id",
|
|
25
|
+
"input[].call_id"
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"id": "gateway-signed-thinking",
|
|
30
|
+
"direction": "request",
|
|
31
|
+
"class": "normalized",
|
|
32
|
+
"reason": "healAnthropicPayload drops a thinking block whose signature the gateway issued (the placeholder signature, or another provider's signature under the lsw1. prefix, both marked by isGatewaySignature). Anthropic verifies the signature and refuses the turn, so such a block can never be sent back.",
|
|
33
|
+
"paths": [
|
|
34
|
+
"messages[].content[].thinking",
|
|
35
|
+
"messages[].content[].signature",
|
|
36
|
+
"messages[].reasoning_content",
|
|
37
|
+
"input[].summary[].text"
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|