@rubytech/create-realagent 1.0.603 → 1.0.605
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/package.json +1 -1
- package/payload/platform/lib/anthropic-key/dist/index.d.ts.map +1 -1
- package/payload/platform/lib/anthropic-key/dist/index.js +2 -1
- package/payload/platform/lib/anthropic-key/dist/index.js.map +1 -1
- package/payload/platform/lib/models/dist/index.d.ts +7 -0
- package/payload/platform/lib/models/dist/index.d.ts.map +1 -0
- package/payload/platform/lib/models/dist/index.js +20 -0
- package/payload/platform/lib/models/dist/index.js.map +1 -0
- package/payload/platform/lib/models/src/index.ts +18 -0
- package/payload/platform/lib/models/tsconfig.json +8 -0
- package/payload/platform/package.json +2 -2
- package/payload/platform/plugins/admin/PLUGIN.md +1 -0
- package/payload/platform/plugins/admin/mcp/dist/index.js +275 -1
- package/payload/platform/plugins/admin/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/admin/skills/onboarding/skill.md +11 -6
- package/payload/platform/plugins/admin/skills/plugin-management/skill.md +1 -1
- package/payload/platform/plugins/admin/skills/public-agent-manager/skill.md +7 -7
- package/payload/platform/plugins/cloudflare/mcp/dist/index.js +15 -41
- package/payload/platform/plugins/cloudflare/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/docs/references/internals.md +1 -1
- package/payload/platform/plugins/email/mcp/dist/lib/screening.d.ts.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/lib/screening.js +2 -1
- package/payload/platform/plugins/email/mcp/dist/lib/screening.js.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/scripts/email-auto-respond.js +2 -1
- package/payload/platform/plugins/email/mcp/dist/scripts/email-auto-respond.js.map +1 -1
- package/payload/platform/plugins/memory/PLUGIN.md +1 -1
- package/payload/platform/plugins/memory/mcp/dist/lib/llm-ranker.d.ts.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/lib/llm-ranker.js +2 -1
- package/payload/platform/plugins/memory/mcp/dist/lib/llm-ranker.js.map +1 -1
- package/payload/platform/templates/account.json +1 -1
- package/payload/platform/templates/agents/admin/IDENTITY.md +16 -2
- package/payload/platform/templates/agents/public/config.json +1 -1
- package/payload/platform/templates/specialists/agents/research-assistant.md +1 -1
- package/payload/premium-plugins/real-agency/agents/buyer-enquiry/template.json +1 -1
- package/payload/premium-plugins/real-agency/agents/compliance.md +1 -1
- package/payload/server/server.js +67 -16
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAmEH,wBAAgB,OAAO,IAAI,MAAM,GAAG,IAAI,CAiDvC;AAMD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAiB1C;AAMD,wBAAgB,MAAM,IAAI,OAAO,CAEhC;AAUD,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,GAAG,OAAO,CAAC;AAEjF,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAsB,WAAW,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAsFtE;AAOD,wBAAgB,WAAW,IAAI,MAAM,CAEpC"}
|
|
@@ -15,6 +15,7 @@ exports.writeKey = writeKey;
|
|
|
15
15
|
exports.hasKey = hasKey;
|
|
16
16
|
exports.validateKey = validateKey;
|
|
17
17
|
exports.keyFilePath = keyFilePath;
|
|
18
|
+
const index_js_1 = require("../../models/dist/index.js");
|
|
18
19
|
const node_fs_1 = require("node:fs");
|
|
19
20
|
const node_path_1 = require("node:path");
|
|
20
21
|
const node_os_1 = require("node:os");
|
|
@@ -142,7 +143,7 @@ async function validateKey(key) {
|
|
|
142
143
|
"anthropic-version": "2023-06-01",
|
|
143
144
|
},
|
|
144
145
|
body: JSON.stringify({
|
|
145
|
-
model:
|
|
146
|
+
model: index_js_1.HAIKU_MODEL,
|
|
146
147
|
max_tokens: 1,
|
|
147
148
|
messages: [{ role: "user", content: "hi" }],
|
|
148
149
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AAmEH,0BAiDC;AAMD,4BAiBC;AAMD,wBAEC;AAiBD,kCAsFC;AAOD,kCAEC;AAjQD,yDAAyD;AACzD,qCAKiB;AACjB,yCAAmD;AACnD,qCAAkC;AAElC,8EAA8E;AAC9E,iCAAiC;AACjC,EAAE;AACF,yEAAyE;AACzE,gDAAgD;AAChD,qEAAqE;AACrE,yEAAyE;AACzE,kEAAkE;AAClE,8EAA8E;AAE9E,IAAI,iBAAiB,GAAkB,IAAI,CAAC;AAE5C,SAAS,kBAAkB;IACzB,IAAI,iBAAiB;QAAE,OAAO,iBAAiB,CAAC;IAEhD,IAAI,aAAa,GAAG,OAAO,CAAC,CAAC,kBAAkB;IAC/C,MAAM,YAAY,GAChB,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;IAE9D,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,SAAS,GAAG,IAAA,gBAAI,EAAC,YAAY,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;QAC7D,IAAI,CAAC,IAAA,oBAAU,EAAC,SAAS,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CACb,2BAA2B,SAAS,oCAAoC,CACzE,CAAC;QACJ,CAAC;QACD,IAAI,CAAC;Y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AC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;QACnC,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC7D,OAAO,CAAC,KAAK,CACX,qDAAqD,OAAO,QAAQ,GAAG,EAAE,CAC1E,CAAC;QACF,OAAO;YACL,MAAM,EAAE,OAAO;YACf,OAAO,EAAE,sCAAsC,GAAG,+BAA+B;SAClF,CAAC;IACJ,CAAC;AACH,CAAC;AAED,8EAA8E;AAC9E,kEAAkE;AAClE,yEAAyE;AACzE,8EAA8E;AAE9E,SAAgB,WAAW;IACzB,OAAO,kBAAkB,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const OPUS_MODEL = "claude-opus-4-7";
|
|
2
|
+
export declare const SONNET_MODEL = "claude-sonnet-4-6";
|
|
3
|
+
export declare const HAIKU_MODEL = "claude-haiku-4-5";
|
|
4
|
+
export declare const MODEL_CONTEXT_WINDOW: Record<string, number>;
|
|
5
|
+
/** Look up context window size; defaults to 200k for unknown models. */
|
|
6
|
+
export declare function contextWindow(model: string): number;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,oBAAoB,CAAC;AAC5C,eAAO,MAAM,YAAY,sBAAsB,CAAC;AAChD,eAAO,MAAM,WAAW,qBAAqB,CAAC;AAE9C,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAIvD,CAAC;AAEF,wEAAwE;AACxE,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Canonical Anthropic model IDs — single source of truth.
|
|
3
|
+
// Templates, docs, and skills reference these values as strings;
|
|
4
|
+
// all TypeScript consumers import from here.
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MODEL_CONTEXT_WINDOW = exports.HAIKU_MODEL = exports.SONNET_MODEL = exports.OPUS_MODEL = void 0;
|
|
7
|
+
exports.contextWindow = contextWindow;
|
|
8
|
+
exports.OPUS_MODEL = "claude-opus-4-7";
|
|
9
|
+
exports.SONNET_MODEL = "claude-sonnet-4-6";
|
|
10
|
+
exports.HAIKU_MODEL = "claude-haiku-4-5";
|
|
11
|
+
exports.MODEL_CONTEXT_WINDOW = {
|
|
12
|
+
[exports.OPUS_MODEL]: 200_000,
|
|
13
|
+
[exports.SONNET_MODEL]: 200_000,
|
|
14
|
+
[exports.HAIKU_MODEL]: 200_000,
|
|
15
|
+
};
|
|
16
|
+
/** Look up context window size; defaults to 200k for unknown models. */
|
|
17
|
+
function contextWindow(model) {
|
|
18
|
+
return exports.MODEL_CONTEXT_WINDOW[model] ?? 200_000;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,0DAA0D;AAC1D,iEAAiE;AACjE,6CAA6C;;;AAa7C,sCAEC;AAbY,QAAA,UAAU,GAAG,iBAAiB,CAAC;AAC/B,QAAA,YAAY,GAAG,mBAAmB,CAAC;AACnC,QAAA,WAAW,GAAG,kBAAkB,CAAC;AAEjC,QAAA,oBAAoB,GAA2B;IAC1D,CAAC,kBAAU,CAAC,EAAE,OAAO;IACrB,CAAC,oBAAY,CAAC,EAAE,OAAO;IACvB,CAAC,mBAAW,CAAC,EAAE,OAAO;CACvB,CAAC;AAEF,wEAAwE;AACxE,SAAgB,aAAa,CAAC,KAAa;IACzC,OAAO,4BAAoB,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Canonical Anthropic model IDs — single source of truth.
|
|
2
|
+
// Templates, docs, and skills reference these values as strings;
|
|
3
|
+
// all TypeScript consumers import from here.
|
|
4
|
+
|
|
5
|
+
export const OPUS_MODEL = "claude-opus-4-7";
|
|
6
|
+
export const SONNET_MODEL = "claude-sonnet-4-6";
|
|
7
|
+
export const HAIKU_MODEL = "claude-haiku-4-5";
|
|
8
|
+
|
|
9
|
+
export const MODEL_CONTEXT_WINDOW: Record<string, number> = {
|
|
10
|
+
[OPUS_MODEL]: 200_000,
|
|
11
|
+
[SONNET_MODEL]: 200_000,
|
|
12
|
+
[HAIKU_MODEL]: 200_000,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** Look up context window size; defaults to 200k for unknown models. */
|
|
16
|
+
export function contextWindow(model: string): number {
|
|
17
|
+
return MODEL_CONTEXT_WINDOW[model] ?? 200_000;
|
|
18
|
+
}
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
"plugins/*/mcp"
|
|
7
7
|
],
|
|
8
8
|
"scripts": {
|
|
9
|
-
"build": "tsc -p lib/anthropic-key/tsconfig.json && tsc -p lib/mcp-stderr-tee/tsconfig.json && tsc -p lib/screening-patterns/tsconfig.json && NODE_OPTIONS='--max-old-space-size=8192' tsc -b plugins/*/mcp/tsconfig.json",
|
|
10
|
-
"build:lib": "tsc -p lib/anthropic-key/tsconfig.json && tsc -p lib/mcp-stderr-tee/tsconfig.json && tsc -p lib/screening-patterns/tsconfig.json",
|
|
9
|
+
"build": "tsc -p lib/models/tsconfig.json && tsc -p lib/anthropic-key/tsconfig.json && tsc -p lib/mcp-stderr-tee/tsconfig.json && tsc -p lib/screening-patterns/tsconfig.json && NODE_OPTIONS='--max-old-space-size=8192' tsc -b plugins/*/mcp/tsconfig.json",
|
|
10
|
+
"build:lib": "tsc -p lib/models/tsconfig.json && tsc -p lib/anthropic-key/tsconfig.json && tsc -p lib/mcp-stderr-tee/tsconfig.json && tsc -p lib/screening-patterns/tsconfig.json",
|
|
11
11
|
"build:memory": "tsc -p plugins/memory/mcp/tsconfig.json",
|
|
12
12
|
"build:contacts": "tsc -p plugins/contacts/mcp/tsconfig.json",
|
|
13
13
|
"build:telegram": "tsc -p plugins/telegram/mcp/tsconfig.json",
|
|
@@ -7,7 +7,7 @@ import { readFile, writeFile } from "node:fs/promises";
|
|
|
7
7
|
import { resolve, join } from "node:path";
|
|
8
8
|
import { execFileSync } from "node:child_process";
|
|
9
9
|
import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
10
|
-
import { writeKey, validateKey, keyFilePath } from "../../../../lib/anthropic-key/dist/index.js";
|
|
10
|
+
import { writeKey, validateKey, hasKey, keyFilePath } from "../../../../lib/anthropic-key/dist/index.js";
|
|
11
11
|
import { createHash, randomInt, randomUUID } from "node:crypto";
|
|
12
12
|
import { createConnection } from "node:net";
|
|
13
13
|
import { homedir, hostname as osHostname } from "node:os";
|
|
@@ -1268,6 +1268,280 @@ server.tool("api-key-verify", "Verify the stored Anthropic API key works by maki
|
|
|
1268
1268
|
};
|
|
1269
1269
|
});
|
|
1270
1270
|
// ===================================================================
|
|
1271
|
+
// Anthropic setup — deterministic state machine
|
|
1272
|
+
// ===================================================================
|
|
1273
|
+
/*
|
|
1274
|
+
* anthropic-setup state machine (action-relay pattern)
|
|
1275
|
+
*
|
|
1276
|
+
* Call 1: anthropic-setup({})
|
|
1277
|
+
* ├─ key stored + valid? → { status: "complete" }
|
|
1278
|
+
* ├─ key stored + billing → { status: "awaiting_credits" }
|
|
1279
|
+
* ├─ key stored + error → { status: "error" }
|
|
1280
|
+
* └─ no key → { status: "awaiting_signin", action }
|
|
1281
|
+
*
|
|
1282
|
+
* Call 2: anthropic-setup({ consoleResult: "..." })
|
|
1283
|
+
* ├─ no_session → { status: "awaiting_signin" }
|
|
1284
|
+
* ├─ no_org → { status: "error" }
|
|
1285
|
+
* ├─ no_credits → { status: "awaiting_credits" }
|
|
1286
|
+
* ├─ success → writeKey → validateKey → { status: "complete" }
|
|
1287
|
+
* └─ *_failed → { status: "error" }
|
|
1288
|
+
*/
|
|
1289
|
+
const CONSOLE_BASE = "https://platform.claude.com";
|
|
1290
|
+
/**
|
|
1291
|
+
* JavaScript expression for browser_evaluate that runs the complete
|
|
1292
|
+
* Console API pipeline in one call: check session → find API org →
|
|
1293
|
+
* check credits → create key. Returns a structured JSON result.
|
|
1294
|
+
*/
|
|
1295
|
+
function consoleEvaluateExpression(keyName) {
|
|
1296
|
+
return `(async () => {
|
|
1297
|
+
try {
|
|
1298
|
+
const orgsRes = await fetch("/api/organizations", { credentials: "include" });
|
|
1299
|
+
if (orgsRes.status === 401 || orgsRes.status === 403) {
|
|
1300
|
+
return JSON.stringify({ status: "no_session" });
|
|
1301
|
+
}
|
|
1302
|
+
if (!orgsRes.ok) {
|
|
1303
|
+
return JSON.stringify({ status: "fetch_error", error: "organizations: " + orgsRes.status });
|
|
1304
|
+
}
|
|
1305
|
+
const orgs = await orgsRes.json();
|
|
1306
|
+
const apiOrg = orgs.find(o => o.capabilities && o.capabilities.includes("api"));
|
|
1307
|
+
if (!apiOrg) {
|
|
1308
|
+
return JSON.stringify({ status: "no_org" });
|
|
1309
|
+
}
|
|
1310
|
+
const creditsRes = await fetch("/api/organizations/" + apiOrg.uuid + "/prepaid/credits", { credentials: "include" });
|
|
1311
|
+
if (!creditsRes.ok) {
|
|
1312
|
+
return JSON.stringify({ status: "fetch_error", error: "credits: " + creditsRes.status });
|
|
1313
|
+
}
|
|
1314
|
+
const credits = await creditsRes.json();
|
|
1315
|
+
if (typeof credits.amount === "number" && credits.amount <= 0) {
|
|
1316
|
+
return JSON.stringify({ status: "no_credits", orgId: apiOrg.uuid, orgName: apiOrg.name, creditUrl: "${CONSOLE_BASE}/settings/billing" });
|
|
1317
|
+
}
|
|
1318
|
+
const createRes = await fetch("/api/console/organizations/" + apiOrg.uuid + "/workspaces/default/api_keys", {
|
|
1319
|
+
method: "POST",
|
|
1320
|
+
credentials: "include",
|
|
1321
|
+
headers: { "content-type": "application/json" },
|
|
1322
|
+
body: JSON.stringify({ name: ${JSON.stringify(keyName)} })
|
|
1323
|
+
});
|
|
1324
|
+
if (!createRes.ok) {
|
|
1325
|
+
return JSON.stringify({ status: "create_failed", error: "key creation: " + createRes.status });
|
|
1326
|
+
}
|
|
1327
|
+
const keyData = await createRes.json();
|
|
1328
|
+
if (!keyData.raw_key) {
|
|
1329
|
+
return JSON.stringify({ status: "create_failed", error: "no raw_key in response" });
|
|
1330
|
+
}
|
|
1331
|
+
return JSON.stringify({
|
|
1332
|
+
status: "success",
|
|
1333
|
+
key: keyData.raw_key,
|
|
1334
|
+
keyId: keyData.id,
|
|
1335
|
+
keyHint: keyData.partial_key_hint,
|
|
1336
|
+
orgName: apiOrg.name,
|
|
1337
|
+
credits: credits.amount
|
|
1338
|
+
});
|
|
1339
|
+
} catch (err) {
|
|
1340
|
+
return JSON.stringify({ status: "fetch_error", error: String(err) });
|
|
1341
|
+
}
|
|
1342
|
+
})()`;
|
|
1343
|
+
}
|
|
1344
|
+
function anthropicResult(r) {
|
|
1345
|
+
return {
|
|
1346
|
+
content: [{ type: "text", text: JSON.stringify(r, null, 2) }],
|
|
1347
|
+
...(r.status === "error" ? { isError: true } : {}),
|
|
1348
|
+
};
|
|
1349
|
+
}
|
|
1350
|
+
server.tool("anthropic-setup", "Deterministic state machine for Anthropic API key acquisition. " +
|
|
1351
|
+
"Checks current state, advances as far as possible, and returns a structured JSON result. " +
|
|
1352
|
+
"On first call (no consoleResult): checks if a valid key is already stored. If not, returns " +
|
|
1353
|
+
"status 'awaiting_signin' with a browser_evaluate action — the agent must open the browser to " +
|
|
1354
|
+
"platform.claude.com, run the action's expression via browser_evaluate, and pass the string " +
|
|
1355
|
+
"result back as consoleResult on the next call. " +
|
|
1356
|
+
"On second call (with consoleResult): parses the Console API result, stores the key, " +
|
|
1357
|
+
"verifies it, and returns status 'complete'. " +
|
|
1358
|
+
"Statuses: complete (key stored and verified), awaiting_signin (user must sign in to Console), " +
|
|
1359
|
+
"awaiting_credits (signed in but no credits — user must add credits), error (fatal — relay message).", {
|
|
1360
|
+
consoleResult: z.string().optional().describe("JSON string result from running the browser_evaluate action returned by a prior call. " +
|
|
1361
|
+
"Omit on the first call."),
|
|
1362
|
+
}, async ({ consoleResult }) => {
|
|
1363
|
+
const log = (msg) => console.error(`[anthropic-setup] ${msg}`);
|
|
1364
|
+
// ── Phase 1: check stored key ──────────────────────────────
|
|
1365
|
+
if (!consoleResult) {
|
|
1366
|
+
log("checking stored key");
|
|
1367
|
+
if (hasKey()) {
|
|
1368
|
+
const verification = await validateKey();
|
|
1369
|
+
log(`stored key verification: ${verification.status}`);
|
|
1370
|
+
switch (verification.status) {
|
|
1371
|
+
case "valid":
|
|
1372
|
+
log("key valid, returning complete");
|
|
1373
|
+
return anthropicResult({
|
|
1374
|
+
status: "complete",
|
|
1375
|
+
message: `API key is stored and working. Key file: ${keyFilePath()}.`,
|
|
1376
|
+
});
|
|
1377
|
+
case "billing":
|
|
1378
|
+
log("key valid but billing issue");
|
|
1379
|
+
return anthropicResult({
|
|
1380
|
+
status: "awaiting_credits",
|
|
1381
|
+
message: "API key is stored and valid, but your account has insufficient credits. " +
|
|
1382
|
+
`Add credits at ${CONSOLE_BASE}/settings/billing, then call this tool again.`,
|
|
1383
|
+
data: { url: `${CONSOLE_BASE}/settings/billing` },
|
|
1384
|
+
});
|
|
1385
|
+
case "auth_error":
|
|
1386
|
+
log("stored key rejected (invalid or revoked)");
|
|
1387
|
+
return anthropicResult({
|
|
1388
|
+
status: "error",
|
|
1389
|
+
message: "The stored API key was rejected (invalid or revoked). " +
|
|
1390
|
+
"A new key is needed. Delete the stored key and call this tool again to create a fresh one.",
|
|
1391
|
+
});
|
|
1392
|
+
case "missing":
|
|
1393
|
+
// hasKey() returned true but readKey() returned null — shouldn't happen
|
|
1394
|
+
log("hasKey true but validate returned missing — proceeding to setup");
|
|
1395
|
+
break;
|
|
1396
|
+
case "error":
|
|
1397
|
+
log(`verification failed: ${verification.message}`);
|
|
1398
|
+
return anthropicResult({
|
|
1399
|
+
status: "error",
|
|
1400
|
+
message: `Could not verify the stored key: ${verification.message}. ` +
|
|
1401
|
+
"This may be a network issue or Anthropic outage. Try again later.",
|
|
1402
|
+
});
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
else {
|
|
1406
|
+
log("no key stored");
|
|
1407
|
+
}
|
|
1408
|
+
// No valid key — return action for Console API calls
|
|
1409
|
+
const expression = consoleEvaluateExpression(BRAND_NAME);
|
|
1410
|
+
log("returning awaiting_signin with browser_evaluate action");
|
|
1411
|
+
return anthropicResult({
|
|
1412
|
+
status: "awaiting_signin",
|
|
1413
|
+
message: "No valid API key stored. Open the browser to the Anthropic Console " +
|
|
1414
|
+
`(${CONSOLE_BASE}) and sign in. This is a separate service from Claude — ` +
|
|
1415
|
+
"you may need to sign in again even if you used the same credentials earlier. " +
|
|
1416
|
+
"Once signed in, run the browser_evaluate action below, then call this tool " +
|
|
1417
|
+
"again with the result as consoleResult.",
|
|
1418
|
+
data: {
|
|
1419
|
+
url: CONSOLE_BASE,
|
|
1420
|
+
action: {
|
|
1421
|
+
tool: "browser_evaluate",
|
|
1422
|
+
params: { expression },
|
|
1423
|
+
},
|
|
1424
|
+
},
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
// ── Phase 2: process Console API result ────────────────────
|
|
1428
|
+
log("processing consoleResult");
|
|
1429
|
+
let parsed;
|
|
1430
|
+
try {
|
|
1431
|
+
parsed = JSON.parse(consoleResult);
|
|
1432
|
+
}
|
|
1433
|
+
catch {
|
|
1434
|
+
log(`consoleResult parse failed: ${consoleResult.slice(0, 200)}`);
|
|
1435
|
+
return anthropicResult({
|
|
1436
|
+
status: "error",
|
|
1437
|
+
message: "Failed to parse the browser result. The Console session may have " +
|
|
1438
|
+
"been lost or the browser encountered an error. Please try again — " +
|
|
1439
|
+
"open the browser to platform.claude.com, sign in, and re-run the action.",
|
|
1440
|
+
});
|
|
1441
|
+
}
|
|
1442
|
+
log(`console result status: ${parsed.status}`);
|
|
1443
|
+
switch (parsed.status) {
|
|
1444
|
+
case "no_session":
|
|
1445
|
+
log("no Console session — user needs to sign in");
|
|
1446
|
+
return anthropicResult({
|
|
1447
|
+
status: "awaiting_signin",
|
|
1448
|
+
message: "Not signed in to the Anthropic Console. Please sign in at " +
|
|
1449
|
+
`${CONSOLE_BASE} and then call this tool again.`,
|
|
1450
|
+
data: { url: CONSOLE_BASE },
|
|
1451
|
+
});
|
|
1452
|
+
case "no_org":
|
|
1453
|
+
log("no API organization found");
|
|
1454
|
+
return anthropicResult({
|
|
1455
|
+
status: "error",
|
|
1456
|
+
message: "No API organization found in your Anthropic account. " +
|
|
1457
|
+
"You may be signed in to a Claude consumer account instead of the API Console. " +
|
|
1458
|
+
`Sign in at ${CONSOLE_BASE} with an account that has API access.`,
|
|
1459
|
+
});
|
|
1460
|
+
case "no_credits":
|
|
1461
|
+
log(`no credits — org: ${parsed.orgName ?? "unknown"}`);
|
|
1462
|
+
return anthropicResult({
|
|
1463
|
+
status: "awaiting_credits",
|
|
1464
|
+
message: `Your API organization (${parsed.orgName ?? "unknown"}) has no credits. ` +
|
|
1465
|
+
`Add credits at ${parsed.creditUrl ?? CONSOLE_BASE + "/settings/billing"}, ` +
|
|
1466
|
+
"then call this tool again.",
|
|
1467
|
+
data: { url: parsed.creditUrl ?? `${CONSOLE_BASE}/settings/billing` },
|
|
1468
|
+
});
|
|
1469
|
+
case "create_failed":
|
|
1470
|
+
log(`key creation failed: ${parsed.error ?? "unknown"}`);
|
|
1471
|
+
return anthropicResult({
|
|
1472
|
+
status: "error",
|
|
1473
|
+
message: `Failed to create API key: ${parsed.error ?? "unknown error"}. ` +
|
|
1474
|
+
"This may be a permissions issue or a temporary Console error. Try again.",
|
|
1475
|
+
});
|
|
1476
|
+
case "fetch_error":
|
|
1477
|
+
log(`fetch error: ${parsed.error ?? "unknown"}`);
|
|
1478
|
+
return anthropicResult({
|
|
1479
|
+
status: "error",
|
|
1480
|
+
message: `Console API error: ${parsed.error ?? "unknown"}. ` +
|
|
1481
|
+
"The Console may be temporarily unavailable. Try again.",
|
|
1482
|
+
});
|
|
1483
|
+
case "success": {
|
|
1484
|
+
if (!parsed.key) {
|
|
1485
|
+
log("success status but no key in result");
|
|
1486
|
+
return anthropicResult({
|
|
1487
|
+
status: "error",
|
|
1488
|
+
message: "Key creation succeeded but the key was not returned. " +
|
|
1489
|
+
"This is unexpected. Please try again.",
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
log(`key created: ${parsed.keyId ?? "unknown"} (hint: ${parsed.keyHint ?? "n/a"}) — org: ${parsed.orgName ?? "unknown"}`);
|
|
1493
|
+
// Store the key — persist AFTER confirmation (sprint learning: Task 201)
|
|
1494
|
+
try {
|
|
1495
|
+
writeKey(parsed.key);
|
|
1496
|
+
log("key stored");
|
|
1497
|
+
}
|
|
1498
|
+
catch (err) {
|
|
1499
|
+
log(`key storage failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
1500
|
+
return anthropicResult({
|
|
1501
|
+
status: "error",
|
|
1502
|
+
message: `Key was created in the Console but could not be stored locally: ` +
|
|
1503
|
+
`${err instanceof Error ? err.message : String(err)}`,
|
|
1504
|
+
});
|
|
1505
|
+
}
|
|
1506
|
+
// Verify the stored key
|
|
1507
|
+
const verification = await validateKey();
|
|
1508
|
+
log(`post-store verification: ${verification.status}`);
|
|
1509
|
+
switch (verification.status) {
|
|
1510
|
+
case "valid":
|
|
1511
|
+
log("key stored and verified");
|
|
1512
|
+
return anthropicResult({
|
|
1513
|
+
status: "complete",
|
|
1514
|
+
message: `API key created, stored at ${keyFilePath()}, and verified. ` +
|
|
1515
|
+
`Organization: ${parsed.orgName ?? "unknown"}. ` +
|
|
1516
|
+
`Credits: $${((parsed.credits ?? 0) / 100).toFixed(2)}.`,
|
|
1517
|
+
});
|
|
1518
|
+
case "billing":
|
|
1519
|
+
log("key stored but billing issue on verification");
|
|
1520
|
+
return anthropicResult({
|
|
1521
|
+
status: "awaiting_credits",
|
|
1522
|
+
message: "API key created and stored, but your account has insufficient credits. " +
|
|
1523
|
+
`Add credits at ${CONSOLE_BASE}/settings/billing, then verify the key with api-key-verify.`,
|
|
1524
|
+
data: { url: `${CONSOLE_BASE}/settings/billing` },
|
|
1525
|
+
});
|
|
1526
|
+
default:
|
|
1527
|
+
log(`unexpected verification status after store: ${verification.status} — ${verification.message}`);
|
|
1528
|
+
return anthropicResult({
|
|
1529
|
+
status: "error",
|
|
1530
|
+
message: `Key was stored but verification returned: ${verification.status}. ` +
|
|
1531
|
+
`${verification.message}. Try running api-key-verify manually.`,
|
|
1532
|
+
});
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
default:
|
|
1536
|
+
log(`unknown console result status: ${parsed.status}`);
|
|
1537
|
+
return anthropicResult({
|
|
1538
|
+
status: "error",
|
|
1539
|
+
message: `Unexpected result from Console: status "${parsed.status}". ` +
|
|
1540
|
+
"Please try again.",
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1544
|
+
// ===================================================================
|
|
1271
1545
|
// Onboarding tools
|
|
1272
1546
|
// ===================================================================
|
|
1273
1547
|
server.tool("onboarding-get", "Read the current onboarding state from the graph. Returns which setup steps " +
|