@engenty/wizards-runtime 0.20.4 → 0.20.6
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/apps/runtime/dist/agents/subscription.js +19 -11
- package/apps/runtime/dist/cli/ollama.js +7 -76
- package/apps/runtime/dist/cli/setup.js +5 -4
- package/apps/runtime/dist/decision-model.js +1 -4
- package/apps/runtime/dist/docs/dev/licensing.md +7 -2
- package/apps/runtime/dist/docs/user-guide/command-line.md +2 -2
- package/apps/runtime/dist/engine/device.js +3 -2
- package/apps/runtime/dist/harness/antigravity.js +11 -7
- package/apps/runtime/dist/harness/apple.js +4 -3
- package/apps/runtime/dist/harness/clients.js +108 -0
- package/apps/runtime/dist/harness/index.js +29 -30
- package/apps/runtime/dist/harness/model.js +32 -270
- package/apps/runtime/dist/harness/prompt.js +6 -120
- package/apps/runtime/dist/harness/types.js +3 -2
- package/apps/runtime/dist/local-models.js +17 -37
- package/apps/runtime/dist/models.js +8 -5
- package/apps/runtime/dist/motion-graphics/step.js +2 -2
- package/apps/runtime/dist/routes/studio.js +1 -1
- package/apps/runtime/dist/services/work-ai.js +2 -2
- package/apps/web/dist/assets/{AboutDialog-CQvfeGqA.js → AboutDialog-BRUwrfQH.js} +1 -1
- package/apps/web/dist/assets/{CapabilitiesPage-DJRpCw2_.js → CapabilitiesPage-C30knXsS.js} +1 -1
- package/apps/web/dist/assets/{ChangelogDialog-F7gj0WCW.js → ChangelogDialog-BkZQOAdl.js} +1 -1
- package/apps/web/dist/assets/{ConnectorsSection-dXmTJOrm.js → ConnectorsSection-CmXQD7zu.js} +1 -1
- package/apps/web/dist/assets/{EditorPage-DNox0Po-.js → EditorPage-LEbyNWmG.js} +1 -1
- package/apps/web/dist/assets/{NewWizardChannels-BugegWm1.js → NewWizardChannels-CSn-9zHr.js} +1 -1
- package/apps/web/dist/assets/{NewWizardPage-Df359wgE.js → NewWizardPage-B4wPfClS.js} +1 -1
- package/apps/web/dist/assets/{ProtocolSection-B1tcJgJl.js → ProtocolSection-s4mEL_pu.js} +1 -1
- package/apps/web/dist/assets/{ReadOnly-DxC8kALr.js → ReadOnly-CO3ndR23.js} +1 -1
- package/apps/web/dist/assets/{Results-D6ecFiSB.js → Results-CC1-mElv.js} +1 -1
- package/apps/web/dist/assets/{RunDrawer-oPFk8yHt.js → RunDrawer-DkmSXhad.js} +1 -1
- package/apps/web/dist/assets/{SettingsPage-DueaPjW3.js → SettingsPage-DKs_fkNL.js} +2 -2
- package/apps/web/dist/assets/{SetupPage-k61GmbIs.js → SetupPage-RvmKCzF2.js} +1 -1
- package/apps/web/dist/assets/{SpacePage-z66Mza2y.js → SpacePage-aZqYFttF.js} +1 -1
- package/apps/web/dist/assets/{StudioHome-q1f_vqAI.js → StudioHome-Doua9Lyl.js} +1 -1
- package/apps/web/dist/assets/{TableEditor-Dfu5Qa-O.js → TableEditor-Dbq3HZZS.js} +1 -1
- package/apps/web/dist/assets/{UpdateCheck-y1StF2CW.js → UpdateCheck-B7etUbUf.js} +2 -2
- package/apps/web/dist/assets/changelog-BW79cVbx.js +1 -0
- package/apps/web/dist/assets/{host-Bh_WJbQv.js → host-BXSxBoOH.js} +3 -3
- package/apps/web/dist/assets/{index-CgSUfzBq.js → index-kDKA6ddy.js} +3 -3
- package/apps/web/dist/assets/{oss-credits-C4SGbRkz.js → oss-credits-B3PXhamW.js} +1 -1
- package/apps/web/dist/index.html +4 -4
- package/bin/bot-tunnel.mjs +375 -0
- package/bin/bot.mjs +1133 -125
- package/node_modules/@engenty/local-models/dist/clients/chat.d.ts +89 -0
- package/node_modules/@engenty/local-models/dist/clients/chat.js +22 -0
- package/node_modules/@engenty/local-models/dist/clients/claude.d.ts +32 -0
- package/node_modules/@engenty/local-models/dist/clients/claude.js +238 -0
- package/node_modules/@engenty/local-models/dist/clients/client.d.ts +29 -0
- package/node_modules/@engenty/local-models/dist/clients/client.js +2 -0
- package/node_modules/@engenty/local-models/dist/clients/codex.d.ts +35 -0
- package/node_modules/@engenty/local-models/dist/clients/codex.js +253 -0
- package/node_modules/@engenty/local-models/dist/clients/cursor.d.ts +33 -0
- package/node_modules/@engenty/local-models/dist/clients/cursor.js +180 -0
- package/node_modules/@engenty/local-models/dist/clients/detect.d.ts +18 -0
- package/node_modules/@engenty/local-models/dist/clients/detect.js +34 -0
- package/node_modules/@engenty/local-models/dist/clients/env.d.ts +66 -0
- package/{apps/runtime/dist/harness → node_modules/@engenty/local-models/dist/clients}/env.js +62 -31
- package/node_modules/@engenty/local-models/dist/clients/failure.d.ts +26 -0
- package/node_modules/@engenty/local-models/dist/clients/failure.js +35 -0
- package/node_modules/@engenty/local-models/dist/clients/index.d.ts +14 -0
- package/node_modules/@engenty/local-models/dist/clients/index.js +16 -0
- package/node_modules/@engenty/local-models/dist/clients/model.d.ts +126 -0
- package/node_modules/@engenty/local-models/dist/clients/model.js +225 -0
- package/node_modules/@engenty/local-models/dist/clients/prompt.d.ts +36 -0
- package/node_modules/@engenty/local-models/dist/clients/prompt.js +123 -0
- package/node_modules/@engenty/local-models/dist/clients/run.d.ts +15 -0
- package/node_modules/@engenty/local-models/dist/clients/run.js +41 -0
- package/node_modules/@engenty/local-models/dist/index.d.ts +3 -0
- package/node_modules/@engenty/local-models/dist/index.js +3 -0
- package/node_modules/@engenty/local-models/dist/ollama/api.d.ts +70 -0
- package/node_modules/@engenty/local-models/dist/ollama/api.js +164 -0
- package/node_modules/@engenty/local-models/dist/ollama/index.d.ts +2 -0
- package/node_modules/@engenty/local-models/dist/ollama/index.js +2 -0
- package/node_modules/@engenty/local-models/dist/ollama/model.d.ts +52 -0
- package/node_modules/@engenty/local-models/dist/ollama/model.js +302 -0
- package/node_modules/@engenty/local-models/dist/probe.d.ts +54 -0
- package/node_modules/@engenty/local-models/dist/probe.js +190 -0
- package/node_modules/@engenty/local-models/package.json +12 -0
- package/package.json +3 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/plugin.json +1 -1
- package/apps/runtime/dist/agents/chat-clients.js +0 -344
- package/apps/runtime/dist/harness/claude.js +0 -141
- package/apps/runtime/dist/harness/codex.js +0 -222
- package/apps/runtime/dist/harness/cursor.js +0 -89
- package/apps/web/dist/assets/changelog-DoEmFdnI.js +0 -1
|
@@ -1,344 +0,0 @@
|
|
|
1
|
-
import { CLAUDE_BIN } from "../harness/claude.js";
|
|
2
|
-
import { CODEX_BIN } from "../harness/codex.js";
|
|
3
|
-
import { CURSOR_BIN } from "../harness/cursor.js";
|
|
4
|
-
export const SUBSCRIPTION_CLIENTS = ["claude", "codex", "cursor"];
|
|
5
|
-
/** The environment variable Codex reads this server's bearer key from. */
|
|
6
|
-
export const CODEX_KEY_VAR = "WIZARDS_MCP_KEY";
|
|
7
|
-
function parse(line) {
|
|
8
|
-
try {
|
|
9
|
-
return JSON.parse(line);
|
|
10
|
-
}
|
|
11
|
-
catch {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
const record = (v) => v && typeof v === "object" ? v : {};
|
|
16
|
-
/** How many issues a tool's answer names; nothing where the answer does not speak of them. */
|
|
17
|
-
function issuesIn(text) {
|
|
18
|
-
if (typeof text !== "string" || !text.includes('"issues"')) {
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
const issues = parse(text)?.issues;
|
|
22
|
-
return Array.isArray(issues) ? issues.length : undefined;
|
|
23
|
-
}
|
|
24
|
-
const claude = {
|
|
25
|
-
id: "claude",
|
|
26
|
-
name: "Claude Code",
|
|
27
|
-
bin: CLAUDE_BIN,
|
|
28
|
-
args: (call) => [
|
|
29
|
-
// The message comes on stdin, so pictures can go with it.
|
|
30
|
-
"-p",
|
|
31
|
-
"--input-format",
|
|
32
|
-
"stream-json",
|
|
33
|
-
"--output-format",
|
|
34
|
-
"stream-json",
|
|
35
|
-
"--verbose",
|
|
36
|
-
// Names a tool as it starts and streams the thinking; whole messages still follow.
|
|
37
|
-
"--include-partial-messages",
|
|
38
|
-
// No built-in tools: `--allowedTools` alone would not take them away.
|
|
39
|
-
"--tools",
|
|
40
|
-
"",
|
|
41
|
-
"--strict-mcp-config",
|
|
42
|
-
...(call.bare
|
|
43
|
-
? []
|
|
44
|
-
: ["--mcp-config", call.mcpConfigFile ?? "", "--allowedTools", "mcp__wizards"]),
|
|
45
|
-
"--disable-slash-commands",
|
|
46
|
-
"--setting-sources",
|
|
47
|
-
"",
|
|
48
|
-
"--append-system-prompt",
|
|
49
|
-
call.system,
|
|
50
|
-
...(call.model ? ["--model", call.model] : []),
|
|
51
|
-
...(call.session ? ["--resume", call.session] : []),
|
|
52
|
-
],
|
|
53
|
-
stdin: (call) => `${JSON.stringify({
|
|
54
|
-
type: "user",
|
|
55
|
-
message: {
|
|
56
|
-
role: "user",
|
|
57
|
-
content: [
|
|
58
|
-
{ type: "text", text: call.message },
|
|
59
|
-
...call.images.map((i) => ({
|
|
60
|
-
type: "image",
|
|
61
|
-
source: { type: "base64", media_type: i.mime, data: i.base64 },
|
|
62
|
-
})),
|
|
63
|
-
],
|
|
64
|
-
},
|
|
65
|
-
})}\n`,
|
|
66
|
-
events(line) {
|
|
67
|
-
const event = parse(line);
|
|
68
|
-
if (!event) {
|
|
69
|
-
return [];
|
|
70
|
-
}
|
|
71
|
-
if (event.type === "stream_event") {
|
|
72
|
-
const e = event.event ?? {};
|
|
73
|
-
if (e.type === "content_block_start" && e.content_block?.type === "tool_use") {
|
|
74
|
-
return [
|
|
75
|
-
{ kind: "tool", name: String(e.content_block.name ?? ""), args: {}, started: false },
|
|
76
|
-
];
|
|
77
|
-
}
|
|
78
|
-
if (e.type === "content_block_start" && e.content_block?.type === "thinking") {
|
|
79
|
-
return [{ kind: "thinkingStart" }];
|
|
80
|
-
}
|
|
81
|
-
if (e.type === "content_block_delta" && e.delta?.type === "thinking_delta") {
|
|
82
|
-
return [{ kind: "thinking", text: e.delta.thinking ?? "" }];
|
|
83
|
-
}
|
|
84
|
-
if (e.type === "content_block_delta" && e.delta?.type === "text_delta") {
|
|
85
|
-
return [{ kind: "writing", text: String(e.delta.text ?? "") }];
|
|
86
|
-
}
|
|
87
|
-
return [];
|
|
88
|
-
}
|
|
89
|
-
if (event.type === "user") {
|
|
90
|
-
const out = [];
|
|
91
|
-
for (const block of event.message?.content ?? []) {
|
|
92
|
-
if (block.type === "tool_result") {
|
|
93
|
-
const text = Array.isArray(block.content)
|
|
94
|
-
? block.content.find((c) => c.type === "text")?.text
|
|
95
|
-
: block.content;
|
|
96
|
-
out.push({ kind: "toolDone", issues: issuesIn(text) });
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return out;
|
|
100
|
-
}
|
|
101
|
-
if (event.type === "assistant") {
|
|
102
|
-
const out = [];
|
|
103
|
-
for (const block of event.message?.content ?? []) {
|
|
104
|
-
if (block.type === "text" && block.text) {
|
|
105
|
-
out.push({ kind: "text", text: block.text });
|
|
106
|
-
}
|
|
107
|
-
else if (block.type === "tool_use") {
|
|
108
|
-
out.push({
|
|
109
|
-
kind: "tool",
|
|
110
|
-
name: String(block.name ?? ""),
|
|
111
|
-
args: record(block.input),
|
|
112
|
-
started: true,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return out;
|
|
117
|
-
}
|
|
118
|
-
if (event.type === "result") {
|
|
119
|
-
const out = [];
|
|
120
|
-
if (event.session_id) {
|
|
121
|
-
out.push({ kind: "session", id: String(event.session_id) });
|
|
122
|
-
}
|
|
123
|
-
if (event.is_error) {
|
|
124
|
-
out.push({ kind: "failure", detail: String(event.result ?? "error") });
|
|
125
|
-
}
|
|
126
|
-
else if (typeof event.result === "string") {
|
|
127
|
-
out.push({ kind: "result", text: event.result });
|
|
128
|
-
}
|
|
129
|
-
return out;
|
|
130
|
-
}
|
|
131
|
-
return [];
|
|
132
|
-
},
|
|
133
|
-
signedOut: (detail) => /authenticat|log ?in|oauth|credential/i.test(detail),
|
|
134
|
-
};
|
|
135
|
-
/** The Codex features that bring tools of their own; the chat works through MCP only. */
|
|
136
|
-
const CODEX_TOOLS_OFF = [
|
|
137
|
-
"shell_tool",
|
|
138
|
-
"unified_exec",
|
|
139
|
-
"apps",
|
|
140
|
-
"plugins",
|
|
141
|
-
"browser_use",
|
|
142
|
-
"in_app_browser",
|
|
143
|
-
"computer_use",
|
|
144
|
-
"image_generation",
|
|
145
|
-
"multi_agent",
|
|
146
|
-
"goals",
|
|
147
|
-
"sleep_tool",
|
|
148
|
-
"tool_suggest",
|
|
149
|
-
"skill_search",
|
|
150
|
-
"memories",
|
|
151
|
-
];
|
|
152
|
-
const codex = {
|
|
153
|
-
id: "codex",
|
|
154
|
-
name: "Codex",
|
|
155
|
-
bin: CODEX_BIN,
|
|
156
|
-
args(call) {
|
|
157
|
-
const options = [
|
|
158
|
-
"--json",
|
|
159
|
-
"--skip-git-repo-check",
|
|
160
|
-
...(call.model ? ["-m", call.model] : []),
|
|
161
|
-
// Only this server's tools: none of the person's own MCP servers start.
|
|
162
|
-
"--ignore-user-config",
|
|
163
|
-
"-c",
|
|
164
|
-
'sandbox_mode="read-only"',
|
|
165
|
-
"-c",
|
|
166
|
-
'approval_policy="never"',
|
|
167
|
-
"-c",
|
|
168
|
-
'web_search="disabled"',
|
|
169
|
-
// `-c features.…` rather than `--disable`: a feature a later Codex drops is only ignored.
|
|
170
|
-
...CODEX_TOOLS_OFF.flatMap((f) => ["-c", `features.${f}=false`]),
|
|
171
|
-
// A JSON string is a TOML basic string: the instructions travel as one config value.
|
|
172
|
-
"-c",
|
|
173
|
-
`developer_instructions=${JSON.stringify(call.system)}`,
|
|
174
|
-
...(call.bare
|
|
175
|
-
? []
|
|
176
|
-
: [
|
|
177
|
-
"-c",
|
|
178
|
-
`mcp_servers.wizards.url=${JSON.stringify(call.mcpUrl)}`,
|
|
179
|
-
// The key comes from the environment, not the command line, where any process could read it.
|
|
180
|
-
"-c",
|
|
181
|
-
`mcp_servers.wizards.bearer_token_env_var="${CODEX_KEY_VAR}"`,
|
|
182
|
-
"-c",
|
|
183
|
-
"mcp_servers.wizards.startup_timeout_sec=30",
|
|
184
|
-
"-c",
|
|
185
|
-
"mcp_servers.wizards.tool_timeout_sec=600",
|
|
186
|
-
// The tools are this server's own: they run without the client asking anyone.
|
|
187
|
-
"-c",
|
|
188
|
-
'mcp_servers.wizards.default_tools_approval_mode="approve"',
|
|
189
|
-
]),
|
|
190
|
-
];
|
|
191
|
-
// `-i` takes several files, so the pictures come last, after the prompt ("-" = stdin).
|
|
192
|
-
const images = call.images.flatMap((i) => ["-i", i.file]);
|
|
193
|
-
return call.session
|
|
194
|
-
? ["exec", "resume", call.session, "-", ...options, ...images]
|
|
195
|
-
: ["exec", "-", ...options, ...images];
|
|
196
|
-
},
|
|
197
|
-
stdin: (call) => call.message,
|
|
198
|
-
events(line) {
|
|
199
|
-
const event = parse(line);
|
|
200
|
-
if (!event) {
|
|
201
|
-
return [];
|
|
202
|
-
}
|
|
203
|
-
const item = event.item ?? {};
|
|
204
|
-
if (event.type === "thread.started" && event.thread_id) {
|
|
205
|
-
return [{ kind: "session", id: String(event.thread_id) }];
|
|
206
|
-
}
|
|
207
|
-
if (item.type === "mcp_tool_call" && event.type === "item.started") {
|
|
208
|
-
return [
|
|
209
|
-
{
|
|
210
|
-
kind: "tool",
|
|
211
|
-
name: String(item.tool ?? ""),
|
|
212
|
-
args: record(item.arguments),
|
|
213
|
-
started: true,
|
|
214
|
-
},
|
|
215
|
-
];
|
|
216
|
-
}
|
|
217
|
-
if (item.type === "mcp_tool_call" && event.type === "item.completed") {
|
|
218
|
-
const text = (item.result?.content ?? []).find((c) => c.type === "text");
|
|
219
|
-
return [{ kind: "toolDone", issues: issuesIn(text?.text) }];
|
|
220
|
-
}
|
|
221
|
-
if (event.type === "item.completed" && item.type === "agent_message" && item.text?.trim()) {
|
|
222
|
-
// A message can end in a line break; the turn puts one blank line between messages.
|
|
223
|
-
return [{ kind: "text", text: String(item.text).trim() }];
|
|
224
|
-
}
|
|
225
|
-
if (event.type === "item.completed" && item.type === "reasoning" && item.text) {
|
|
226
|
-
return [
|
|
227
|
-
{ kind: "thinkingStart" },
|
|
228
|
-
{ kind: "thinking", text: String(item.text), whole: true },
|
|
229
|
-
];
|
|
230
|
-
}
|
|
231
|
-
if (event.type === "turn.failed") {
|
|
232
|
-
const error = event.error;
|
|
233
|
-
return [
|
|
234
|
-
{
|
|
235
|
-
kind: "failure",
|
|
236
|
-
detail: typeof error === "string" ? error : String(error?.message ?? "error"),
|
|
237
|
-
},
|
|
238
|
-
];
|
|
239
|
-
}
|
|
240
|
-
// A top-level `error` is often a retry ("Reconnecting... 1/5"); turn.failed ends the turn.
|
|
241
|
-
return [];
|
|
242
|
-
},
|
|
243
|
-
signedOut: (detail) => /\b401\b|unauthori[sz]ed|not logged in|codex login|authenticat|log ?in/i.test(detail),
|
|
244
|
-
};
|
|
245
|
-
const cursor = {
|
|
246
|
-
id: "cursor",
|
|
247
|
-
name: "Cursor Agent",
|
|
248
|
-
bin: CURSOR_BIN,
|
|
249
|
-
// The workspace (call.dir) holds the instructions as AGENTS.md, the MCP server and the
|
|
250
|
-
// permissions in .cursor/: see cursorWorkspace().
|
|
251
|
-
args: (call) => [
|
|
252
|
-
"-p",
|
|
253
|
-
"--output-format",
|
|
254
|
-
"stream-json",
|
|
255
|
-
"--workspace",
|
|
256
|
-
call.dir,
|
|
257
|
-
...(call.bare ? [] : ["--approve-mcps"]),
|
|
258
|
-
...(call.model && call.model !== "auto" ? ["--model", call.model] : []),
|
|
259
|
-
...(call.session ? ["--resume", call.session] : []),
|
|
260
|
-
],
|
|
261
|
-
stdin: (call) => call.message,
|
|
262
|
-
events(line) {
|
|
263
|
-
const event = parse(line);
|
|
264
|
-
if (!event) {
|
|
265
|
-
return [];
|
|
266
|
-
}
|
|
267
|
-
const out = [];
|
|
268
|
-
if (event.type === "system" && event.session_id) {
|
|
269
|
-
out.push({ kind: "session", id: String(event.session_id) });
|
|
270
|
-
}
|
|
271
|
-
else if (event.type === "assistant") {
|
|
272
|
-
for (const block of event.message?.content ?? []) {
|
|
273
|
-
if (block.type === "text" && block.text) {
|
|
274
|
-
out.push({ kind: "text", text: block.text });
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
else if (event.type === "tool_call" && event.subtype === "started") {
|
|
279
|
-
const call = record(event.tool_call);
|
|
280
|
-
// The call as its protobuf JSON: { mcpToolCall: { args: { toolName, args, … } } }.
|
|
281
|
-
const mcp = record(record(call.mcpToolCall).args);
|
|
282
|
-
if (mcp.toolName || mcp.name) {
|
|
283
|
-
out.push({
|
|
284
|
-
kind: "tool",
|
|
285
|
-
name: String(mcp.toolName ?? mcp.name),
|
|
286
|
-
args: record(mcp.args),
|
|
287
|
-
started: true,
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
else if (event.type === "tool_call" && event.subtype === "completed") {
|
|
292
|
-
const call = record(record(event.tool_call).mcpToolCall);
|
|
293
|
-
const mcp = record(call.args);
|
|
294
|
-
if (mcp.toolName || mcp.name) {
|
|
295
|
-
const content = record(record(call.result).success).content;
|
|
296
|
-
const first = Array.isArray(content) ? record(content[0]) : {};
|
|
297
|
-
out.push({ kind: "toolDone", issues: issuesIn(record(first.text).text ?? first.text) });
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
else if (event.type === "thinking" && event.subtype === "delta") {
|
|
301
|
-
out.push({ kind: "thinking", text: String(event.text ?? "") });
|
|
302
|
-
}
|
|
303
|
-
else if (event.type === "result") {
|
|
304
|
-
if (event.session_id) {
|
|
305
|
-
out.push({ kind: "session", id: String(event.session_id) });
|
|
306
|
-
}
|
|
307
|
-
if (event.is_error) {
|
|
308
|
-
out.push({ kind: "failure", detail: String(event.result ?? "error") });
|
|
309
|
-
}
|
|
310
|
-
else if (typeof event.result === "string") {
|
|
311
|
-
out.push({ kind: "result", text: event.result });
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
return out;
|
|
315
|
-
},
|
|
316
|
-
signedOut: (detail) => /authenticat|log ?in|CURSOR_API_KEY|unauthori[sz]ed|\b401\b/i.test(detail),
|
|
317
|
-
};
|
|
318
|
-
export const CHAT_CLIENTS = { claude, codex, cursor };
|
|
319
|
-
/**
|
|
320
|
-
* Cursor Agent's workspace files: the instructions, this server as its MCP server, and the
|
|
321
|
-
* permissions. The CLI also loads the servers of ~/.cursor/mcp.json and `--approve-mcps`
|
|
322
|
-
* approves them all, so each of those is denied by name; a deny wins over an allow.
|
|
323
|
-
*/
|
|
324
|
-
export function cursorWorkspace(input) {
|
|
325
|
-
return {
|
|
326
|
-
"AGENTS.md": input.system,
|
|
327
|
-
".cursor/mcp.json": JSON.stringify({
|
|
328
|
-
mcpServers: {
|
|
329
|
-
wizards: { url: input.mcpUrl, headers: { Authorization: `Bearer ${input.key}` } },
|
|
330
|
-
},
|
|
331
|
-
}),
|
|
332
|
-
".cursor/cli.json": JSON.stringify({
|
|
333
|
-
permissions: {
|
|
334
|
-
allow: ["Mcp(wizards:*)"],
|
|
335
|
-
deny: [
|
|
336
|
-
"Shell(*)",
|
|
337
|
-
"Read(**)",
|
|
338
|
-
"Write(**)",
|
|
339
|
-
...input.ownServers.filter((s) => s !== "wizards").map((s) => `Mcp(${s}:*)`),
|
|
340
|
-
],
|
|
341
|
-
},
|
|
342
|
-
}),
|
|
343
|
-
};
|
|
344
|
-
}
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { note } from "@engenty/wizards-shared/run";
|
|
2
|
-
import { probeVersion, resolveEnv, run } from "./env.js";
|
|
3
|
-
import { failureOf, HarnessModel, lastJson, runClient, } from "./model.js";
|
|
4
|
-
/**
|
|
5
|
-
* Claude Code: `claude -p` answers on the person's sign-in — the client's keychain, or the key
|
|
6
|
-
* or token their login shell sets. Tools go over MCP; structured output is validated by the
|
|
7
|
-
* client (`--json-schema`); web search is its own tool.
|
|
8
|
-
*/
|
|
9
|
-
export const CLAUDE_BIN = process.env.CLAUDE_BIN?.trim() || "claude";
|
|
10
|
-
const CLASSES = {
|
|
11
|
-
classifier: "haiku",
|
|
12
|
-
low: "sonnet",
|
|
13
|
-
standard: "opus",
|
|
14
|
-
high: "opus",
|
|
15
|
-
};
|
|
16
|
-
const spec = {
|
|
17
|
-
id: "claude",
|
|
18
|
-
passThrough: /^(ANTHROPIC_|CLAUDE_CODE_OAUTH_TOKEN$|CLAUDE_CODE_USE_|CLAUDE_CONFIG_DIR$|AWS_(PROFILE|REGION|DEFAULT_REGION|ACCESS_KEY_ID|SECRET_ACCESS_KEY|SESSION_TOKEN)$|GOOGLE_APPLICATION_CREDENTIALS$|CLOUD_ML_REGION$)/,
|
|
19
|
-
keyVars: ["ANTHROPIC_API_KEY", "ANTHROPIC_AUTH_TOKEN"],
|
|
20
|
-
async auth(env) {
|
|
21
|
-
try {
|
|
22
|
-
const { stdout } = await run(CLAUDE_BIN, ["auth", "status", "--json"], {
|
|
23
|
-
timeout: 15_000,
|
|
24
|
-
env,
|
|
25
|
-
});
|
|
26
|
-
const status = JSON.parse(stdout.trim());
|
|
27
|
-
if (!status.loggedIn) {
|
|
28
|
-
return "none";
|
|
29
|
-
}
|
|
30
|
-
return status.authMethod === "api_key" ? "api_key" : "subscription";
|
|
31
|
-
}
|
|
32
|
-
catch {
|
|
33
|
-
return "none";
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
export async function claudeEnv() {
|
|
38
|
-
return (await resolveEnv(spec)).env;
|
|
39
|
-
}
|
|
40
|
-
/** The client's result as the model call wants it: text (or the structured output as JSON) and usage. */
|
|
41
|
-
export function claudeAnswer(event) {
|
|
42
|
-
const u = event.usage ?? {};
|
|
43
|
-
const cacheRead = u.cache_read_input_tokens ?? 0;
|
|
44
|
-
const cacheWrite = u.cache_creation_input_tokens ?? 0;
|
|
45
|
-
return {
|
|
46
|
-
text: event.structured_output !== undefined
|
|
47
|
-
? JSON.stringify(event.structured_output)
|
|
48
|
-
: typeof event.result === "string"
|
|
49
|
-
? event.result
|
|
50
|
-
: JSON.stringify(event.result ?? ""),
|
|
51
|
-
usage: {
|
|
52
|
-
input: (u.input_tokens ?? 0) + cacheRead + cacheWrite,
|
|
53
|
-
cacheRead,
|
|
54
|
-
cacheWrite,
|
|
55
|
-
output: u.output_tokens ?? 0,
|
|
56
|
-
},
|
|
57
|
-
meta: { costUsd: event.total_cost_usd ?? 0, turns: event.num_turns ?? 1 },
|
|
58
|
-
sessionId: event.session_id,
|
|
59
|
-
stopReason: event.stop_reason,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
class ClaudeCodeModel extends HarnessModel {
|
|
63
|
-
provider = "claude-code";
|
|
64
|
-
nativeSchema = true;
|
|
65
|
-
async invoke(call) {
|
|
66
|
-
const builtin = [];
|
|
67
|
-
if (call.files.length) {
|
|
68
|
-
builtin.push("Read");
|
|
69
|
-
}
|
|
70
|
-
if (call.webSearch) {
|
|
71
|
-
builtin.push("WebSearch");
|
|
72
|
-
}
|
|
73
|
-
const args = [
|
|
74
|
-
"-p",
|
|
75
|
-
"--output-format",
|
|
76
|
-
"json",
|
|
77
|
-
"--model",
|
|
78
|
-
this.modelId,
|
|
79
|
-
"--tools",
|
|
80
|
-
builtin.join(","),
|
|
81
|
-
"--strict-mcp-config",
|
|
82
|
-
"--setting-sources",
|
|
83
|
-
"",
|
|
84
|
-
"--disable-slash-commands",
|
|
85
|
-
"--no-session-persistence",
|
|
86
|
-
];
|
|
87
|
-
if (call.system) {
|
|
88
|
-
args.push("--system-prompt", call.system);
|
|
89
|
-
}
|
|
90
|
-
if (call.effort) {
|
|
91
|
-
args.push("--effort", call.effort);
|
|
92
|
-
}
|
|
93
|
-
if (call.schema) {
|
|
94
|
-
// The CLI checks the schema with no dialects loaded: one that names its own is refused.
|
|
95
|
-
const { $schema: _dialect, ...schema } = call.schema;
|
|
96
|
-
args.push("--json-schema", JSON.stringify(schema));
|
|
97
|
-
}
|
|
98
|
-
if (call.bridgeUrl) {
|
|
99
|
-
args.push("--mcp-config", JSON.stringify({ mcpServers: { step: { type: "http", url: call.bridgeUrl } } }));
|
|
100
|
-
}
|
|
101
|
-
const allowed = [...builtin, ...(call.bridgeUrl ? ["mcp__step"] : [])];
|
|
102
|
-
if (allowed.length) {
|
|
103
|
-
args.push("--allowedTools", allowed.join(","));
|
|
104
|
-
}
|
|
105
|
-
if (call.files.length) {
|
|
106
|
-
args.push("--add-dir", call.dir);
|
|
107
|
-
}
|
|
108
|
-
const { stdout, stderr, code } = await runClient(CLAUDE_BIN, args, {
|
|
109
|
-
cwd: call.dir,
|
|
110
|
-
env: await claudeEnv(),
|
|
111
|
-
signal: call.signal,
|
|
112
|
-
stdin: call.prompt,
|
|
113
|
-
});
|
|
114
|
-
const event = lastJson(stdout);
|
|
115
|
-
if (!event) {
|
|
116
|
-
throw failureOf(this.harness, stderr.trim() || `exit ${code}`);
|
|
117
|
-
}
|
|
118
|
-
if (event.is_error) {
|
|
119
|
-
// A failed run carries no result, only why (subtype) and sometimes what (errors).
|
|
120
|
-
const why = [
|
|
121
|
-
typeof event.result === "string" ? event.result : "",
|
|
122
|
-
event.subtype ?? "",
|
|
123
|
-
...(event.errors ?? []).map((e) => (typeof e === "string" ? e : JSON.stringify(e))),
|
|
124
|
-
event.num_turns ? `after ${event.num_turns} turns` : "",
|
|
125
|
-
].filter(Boolean);
|
|
126
|
-
console.warn("[claude] the client failed:", JSON.stringify(event).slice(0, 2000));
|
|
127
|
-
throw failureOf(this.harness, why.join(" – ") || "error");
|
|
128
|
-
}
|
|
129
|
-
return claudeAnswer(event);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
export const claude = {
|
|
133
|
-
...spec,
|
|
134
|
-
name: "Claude Code",
|
|
135
|
-
bin: CLAUDE_BIN,
|
|
136
|
-
classes: CLASSES,
|
|
137
|
-
version: (env) => probeVersion(CLAUDE_BIN, env, (stdout) => stdout.trim().split(/\s+/)[0] || stdout.trim()),
|
|
138
|
-
login: { args: ["auth", "login"], interactive: false },
|
|
139
|
-
model: (alias, effort) => new ClaudeCodeModel(claude, alias || "sonnet", effort),
|
|
140
|
-
exhausted: note("anthropicAccountClaudeCode"),
|
|
141
|
-
};
|