@theokit/sdk 4.25.0 → 4.27.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/dist/{judge-call-7CF7D334.cjs → chunk-4GTXATWK.cjs} +37 -3
- package/dist/chunk-4GTXATWK.cjs.map +1 -0
- package/dist/{chunk-F3XVLFLM.js → chunk-6M76Z3AI.js} +5 -5
- package/dist/{chunk-F3XVLFLM.js.map → chunk-6M76Z3AI.js.map} +1 -1
- package/dist/{judge-call-VIMNK5TA.js → chunk-CR3DGWUQ.js} +37 -4
- package/dist/chunk-CR3DGWUQ.js.map +1 -0
- package/dist/{chunk-4HKMQEPX.js → chunk-OX772BEW.js} +3 -3
- package/dist/{chunk-4HKMQEPX.js.map → chunk-OX772BEW.js.map} +1 -1
- package/dist/{chunk-CJ6YJ2L3.cjs → chunk-TMNS2LOS.cjs} +7 -7
- package/dist/{chunk-CJ6YJ2L3.cjs.map → chunk-TMNS2LOS.cjs.map} +1 -1
- package/dist/{chunk-7RMWOMDB.cjs → chunk-WBBYSW3Q.cjs} +5 -5
- package/dist/{chunk-7RMWOMDB.cjs.map → chunk-WBBYSW3Q.cjs.map} +1 -1
- package/dist/{cron-B_NkE_VM.d.ts → cron-DPUZzncH.d.ts} +35 -2
- package/dist/{cron-x3muPNgg.d.cts → cron-DzZ9TMa2.d.cts} +35 -2
- package/dist/cron.cjs +3 -3
- package/dist/cron.d.cts +1 -1
- package/dist/cron.d.ts +1 -1
- package/dist/cron.js +2 -2
- package/dist/eval.cjs +2 -2
- package/dist/eval.js +1 -1
- package/dist/index.cjs +27 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -36
- package/dist/index.d.ts +30 -36
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/internal/judge/judge-call.d.ts +32 -19
- package/dist/internal/runtime/lifecycle/run-until.d.ts +1 -2
- package/dist/internal/runtime/lifecycle/wrap-completion-check-run.d.ts +1 -1
- package/dist/judge-call-2FULQ6KL.cjs +22 -0
- package/dist/judge-call-2FULQ6KL.cjs.map +1 -0
- package/dist/judge-call-D7R3ZTZS.js +5 -0
- package/dist/judge-call-D7R3ZTZS.js.map +1 -0
- package/dist/{run-until-2PX4QBHZ.js → run-until-K7IO7ZPQ.js} +11 -2
- package/dist/run-until-K7IO7ZPQ.js.map +1 -0
- package/dist/{run-until-DB3LVGZS.cjs → run-until-ZD4PRLNJ.cjs} +11 -2
- package/dist/run-until-ZD4PRLNJ.cjs.map +1 -0
- package/dist/types/goal-events.d.ts +34 -1
- package/package.json +1 -1
- package/dist/internal/judge/types.d.ts +0 -17
- package/dist/judge-call-7CF7D334.cjs.map +0 -1
- package/dist/judge-call-VIMNK5TA.js.map +0 -1
- package/dist/run-until-2PX4QBHZ.js.map +0 -1
- package/dist/run-until-DB3LVGZS.cjs.map +0 -1
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkA44COQJJ_cjs = require('./chunk-A44COQJJ.cjs');
|
|
4
|
+
|
|
3
5
|
// src/internal/judge/parse-verdict.ts
|
|
4
6
|
var DONE_PREFIX = "DONE:";
|
|
5
7
|
var CONTINUE_PREFIX = "CONTINUE:";
|
|
6
8
|
var SKIPPED_PREFIX = "SKIPPED:";
|
|
9
|
+
var BLOCKED_PREFIX = "BLOCKED:";
|
|
7
10
|
function parseVerdict(text) {
|
|
8
11
|
const trimmed = text.trim();
|
|
9
12
|
if (trimmed.startsWith(DONE_PREFIX)) {
|
|
@@ -20,6 +23,13 @@ function parseVerdict(text) {
|
|
|
20
23
|
parseFailed: false
|
|
21
24
|
};
|
|
22
25
|
}
|
|
26
|
+
if (trimmed.startsWith(BLOCKED_PREFIX)) {
|
|
27
|
+
return {
|
|
28
|
+
verdict: "blocked",
|
|
29
|
+
reason: trimmed.slice(BLOCKED_PREFIX.length).trim(),
|
|
30
|
+
parseFailed: false
|
|
31
|
+
};
|
|
32
|
+
}
|
|
23
33
|
if (trimmed.startsWith(SKIPPED_PREFIX)) {
|
|
24
34
|
return {
|
|
25
35
|
verdict: "skipped",
|
|
@@ -35,6 +45,25 @@ function parseVerdict(text) {
|
|
|
35
45
|
}
|
|
36
46
|
|
|
37
47
|
// src/internal/judge/judge-call.ts
|
|
48
|
+
var JudgeCredentialError = class extends chunkA44COQJJ_cjs.TheokitAgentError {
|
|
49
|
+
constructor(httpStatus, judgeModel, cause) {
|
|
50
|
+
super(
|
|
51
|
+
`judge unavailable: model "${judgeModel}" returned ${String(httpStatus)}. Pass \`judgeModel\`/\`apiKey\` that resolve for this provider, or omit \`judgeModel\` to derive it from the agent being driven.`,
|
|
52
|
+
{ code: "judge_credential", cause, isRetryable: false }
|
|
53
|
+
);
|
|
54
|
+
this.httpStatus = httpStatus;
|
|
55
|
+
this.judgeModel = judgeModel;
|
|
56
|
+
}
|
|
57
|
+
httpStatus;
|
|
58
|
+
judgeModel;
|
|
59
|
+
name = "JudgeCredentialError";
|
|
60
|
+
};
|
|
61
|
+
function statusHttpDe(err) {
|
|
62
|
+
const s = err.status ?? err.statusCode;
|
|
63
|
+
if (typeof s === "number") return s;
|
|
64
|
+
const m = /\b(401|403|404)\b/.exec(err instanceof Error ? err.message : String(err));
|
|
65
|
+
return m?.[1] !== void 0 ? Number(m[1]) : void 0;
|
|
66
|
+
}
|
|
38
67
|
async function judgeCallImpl(ctx, options, deps) {
|
|
39
68
|
const prompt = composeJudgePrompt(ctx);
|
|
40
69
|
const apiKey = options?.apiKey ?? process.env.OPENROUTER_API_KEY;
|
|
@@ -45,7 +74,7 @@ async function judgeCallImpl(ctx, options, deps) {
|
|
|
45
74
|
parseFailed: true
|
|
46
75
|
};
|
|
47
76
|
}
|
|
48
|
-
const judgeModel = options?.judgeModel ?? "openai/gpt-4o-mini";
|
|
77
|
+
const judgeModel = options?.judgeModel ?? options?.agentModel ?? "openai/gpt-4o-mini";
|
|
49
78
|
let auxAgent;
|
|
50
79
|
try {
|
|
51
80
|
auxAgent = await deps.create({
|
|
@@ -59,6 +88,10 @@ async function judgeCallImpl(ctx, options, deps) {
|
|
|
59
88
|
const result = await run.wait();
|
|
60
89
|
return parseVerdict(result.result ?? "");
|
|
61
90
|
} catch (err) {
|
|
91
|
+
const status = statusHttpDe(err);
|
|
92
|
+
if (status === 401 || status === 403 || status === 404) {
|
|
93
|
+
throw new JudgeCredentialError(status, judgeModel, err);
|
|
94
|
+
}
|
|
62
95
|
return {
|
|
63
96
|
verdict: "continue",
|
|
64
97
|
reason: `judge call failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
@@ -89,7 +122,8 @@ Respond with EXACTLY one of:
|
|
|
89
122
|
Be strict. If unclear, prefer CONTINUE.`;
|
|
90
123
|
}
|
|
91
124
|
|
|
125
|
+
exports.JudgeCredentialError = JudgeCredentialError;
|
|
92
126
|
exports.composeJudgePrompt = composeJudgePrompt;
|
|
93
127
|
exports.judgeCallImpl = judgeCallImpl;
|
|
94
|
-
//# sourceMappingURL=
|
|
95
|
-
//# sourceMappingURL=
|
|
128
|
+
//# sourceMappingURL=chunk-4GTXATWK.cjs.map
|
|
129
|
+
//# sourceMappingURL=chunk-4GTXATWK.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/internal/judge/parse-verdict.ts","../src/internal/judge/judge-call.ts"],"names":["TheokitAgentError"],"mappings":";;;;;AAaA,IAAM,WAAA,GAAc,OAAA;AACpB,IAAM,eAAA,GAAkB,WAAA;AACxB,IAAM,cAAA,GAAiB,UAAA;AAEvB,IAAM,cAAA,GAAiB,UAAA;AAEhB,SAAS,aAAa,IAAA,EAA2B;AACtD,EAAA,MAAM,OAAA,GAAU,KAAK,IAAA,EAAK;AAE1B,EAAA,IAAI,OAAA,CAAQ,UAAA,CAAW,WAAW,CAAA,EAAG;AACnC,IAAA,OAAO;AAAA,MACL,OAAA,EAAS,MAAA;AAAA,MACT,QAAQ,OAAA,CAAQ,KAAA,CAAM,WAAA,CAAY,MAAM,EA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;AAAA;AAAA;AAAA;;AAAA,uCAAA,CAAA;AAQvC","file":"chunk-4GTXATWK.cjs","sourcesContent":["/**\n * Pure verdict parser (T2.1, ADRs D120-D121).\n *\n * Strict prefix matching against `DONE:`, `CONTINUE:`, `SKIPPED:`. Reason\n * is the suffix, trimmed. Anything else is fail-safe: verdict = `continue`,\n * `parseFailed: true` — caller's max-consecutive-failure cap stops the\n * loop after N flakes.\n *\n * @internal\n */\n\nimport type { JudgeResult } from \"../../types/goal-events.js\";\n\nconst DONE_PREFIX = \"DONE:\";\nconst CONTINUE_PREFIX = \"CONTINUE:\";\nconst SKIPPED_PREFIX = \"SKIPPED:\";\n/** M80 — o judge agora pode declarar impossibilidade, não só \"continue\". */\nconst BLOCKED_PREFIX = \"BLOCKED:\";\n\nexport function parseVerdict(text: string): JudgeResult {\n const trimmed = text.trim();\n\n if (trimmed.startsWith(DONE_PREFIX)) {\n return {\n verdict: \"done\",\n reason: trimmed.slice(DONE_PREFIX.length).trim(),\n parseFailed: false,\n };\n }\n if (trimmed.startsWith(CONTINUE_PREFIX)) {\n return {\n verdict: \"continue\",\n reason: trimmed.slice(CONTINUE_PREFIX.length).trim(),\n parseFailed: false,\n };\n }\n if (trimmed.startsWith(BLOCKED_PREFIX)) {\n return {\n verdict: \"blocked\",\n reason: trimmed.slice(BLOCKED_PREFIX.length).trim(),\n parseFailed: false,\n };\n }\n if (trimmed.startsWith(SKIPPED_PREFIX)) {\n return {\n verdict: \"skipped\",\n reason: trimmed.slice(SKIPPED_PREFIX.length).trim(),\n parseFailed: false,\n };\n }\n\n // Fail-safe: ADR D121 — prefer \"continue\" so we don't stop prematurely.\n // The runUntil loop counts consecutive parseFailed responses and bails\n // after `maxConsecutiveJudgeFailures` (default 3).\n return {\n verdict: \"continue\",\n reason: `judge response malformed: \"${trimmed.slice(0, 100)}\"`,\n parseFailed: true,\n };\n}\n","import { TheokitAgentError } from \"../../errors.js\";\n/**\n * Judge call primitive (T2.2, ADRs D119-D121).\n *\n * Instantiates a short-lived auxiliary agent that evaluates whether a\n * goal is satisfied. The auxiliary judge runs with `tools: []` and a\n * cheap model (default `openai/gpt-4o-mini`) — see ADR D119. The judge\n * model needs only API access; we read `OPENROUTER_API_KEY` directly\n * from the environment (EC-A — single source of truth) and let the\n * caller override via {@link JudgeOptions.apiKey} for Anthropic or\n * direct-OpenAI environments.\n *\n * NOTE: judge aux agents created from inside a `forkAgent` context will\n * inherit the parent fork's whitelist via AsyncLocalStorage (EC-J).\n * `tools: []` keeps this benign today; future callers that add tools to\n * a judge should be aware.\n *\n * @internal\n */\n\nimport type { AgentOptions, SDKAgent } from \"../../types/agent.js\";\nimport type { JudgeResult } from \"../../types/goal-events.js\";\nimport { parseVerdict } from \"./parse-verdict.js\";\n\n/** Inputs to the judge — pure data. */\nexport interface JudgeContext {\n goal: string;\n lastResponse: string;\n subgoals?: string[];\n}\n\n/** Caller-supplied tuning knobs for the judge call. */\nexport interface JudgeOptions {\n /**\n * Judge model identifier. Quando ausente, DERIVA de {@link agentModel} — e só cai no literal\n * `\"openai/gpt-4o-mini\"` se nem esse for informado.\n *\n * M80 — o default fixo era provider-cego: ele só resolve em OpenRouter. Com chave Anthropic dá\n * 404, com bearer OAuth dá 401, e em ambos o goal queimava 3 turnos inteiros antes de falhar com\n * razão enganosa. O agent-builder já contornava isso derivando por conta própria; o conhecimento\n * pertence aqui.\n */\n judgeModel?: string;\n /**\n * M80 — o modelo do agente CONDUZIDO. É a base da derivação: um judge que roda no mesmo modelo do\n * chat funciona onde o chat funciona.\n */\n agentModel?: string;\n /** Override env. Default `process.env.OPENROUTER_API_KEY` (EC-A). */\n apiKey?: string;\n}\n\n/**\n * M80 — a credencial ou o modelo do judge não servem: 401/404.\n *\n * Falha RÁPIDA por design. `rules/error-handling.md § 2` separa recuperável de irrecuperável, e um\n * modelo inexistente não passa a existir no retry — dobrar isso em `{parseFailed: true}` fazia o loop\n * tentar três vezes e reportar \"failed\" por limite de falhas consecutivas, escondendo que a causa era\n * credencial. Falha lenta e opaca trocada por rápida e clara.\n *\n * Falha de PARSE e erro de rede continuam dobrados: são recuperáveis, e o loop já decide por falhas\n * consecutivas.\n */\nexport class JudgeCredentialError extends TheokitAgentError {\n override readonly name = \"JudgeCredentialError\";\n\n constructor(\n readonly httpStatus: number,\n readonly judgeModel: string,\n cause: unknown,\n ) {\n super(\n `judge unavailable: model \"${judgeModel}\" returned ${String(httpStatus)}. ` +\n \"Pass `judgeModel`/`apiKey` that resolve for this provider, or omit `judgeModel` to derive \" +\n \"it from the agent being driven.\",\n { code: \"judge_credential\", cause, isRetryable: false },\n );\n }\n}\n\n/** Extrai o status HTTP de um erro de provider, quando ele o carrega. */\nfunction statusHttpDe(err: unknown): number | undefined {\n const s =\n (err as { status?: unknown; statusCode?: unknown }).status ??\n (err as { statusCode?: unknown }).statusCode;\n if (typeof s === \"number\") return s;\n const m = /\\b(401|403|404)\\b/.exec(err instanceof Error ? err.message : String(err));\n return m?.[1] !== undefined ? Number(m[1]) : undefined;\n}\n\n/** Dependencies injected so `judge-call.ts` stays free of `Agent` import. */\nexport interface JudgeDeps {\n create: (options: AgentOptions) => Promise<SDKAgent>;\n}\n\n/**\n * Run the judge auxiliary agent and parse the verdict. Always returns a\n * `JudgeResult` — failures are folded into `{ parseFailed: true,\n * verdict: \"continue\" }` so the loop can decide based on consecutive\n * failures (ADR D121).\n *\n * @internal\n */\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: judge call must (1) check env or override, (2) catch errors as fail-safe, (3) ensure aux dispose runs once regardless of outcome — three concerns linearly arranged, harm clarity to extract.\nexport async function judgeCallImpl(\n ctx: JudgeContext,\n options: JudgeOptions | undefined,\n deps: JudgeDeps,\n): Promise<JudgeResult> {\n const prompt = composeJudgePrompt(ctx);\n // EC-A: single env source — OpenRouter only. No multi-provider fallback.\n const apiKey = options?.apiKey ?? process.env.OPENROUTER_API_KEY;\n if (apiKey === undefined) {\n return {\n verdict: \"continue\",\n reason:\n \"judge unavailable: OPENROUTER_API_KEY missing and no override passed via options.apiKey\",\n parseFailed: true,\n };\n }\n\n // M80 — precedência: explícito > modelo do agente conduzido > o literal histórico. O literal só\n // sobrevive como último recurso, para não quebrar quem nunca passou nenhum dos dois.\n const judgeModel = options?.judgeModel ?? options?.agentModel ?? \"openai/gpt-4o-mini\";\n let auxAgent: SDKAgent | undefined;\n try {\n auxAgent = await deps.create({\n apiKey,\n model: { id: judgeModel },\n tools: [],\n local: {},\n metadata: { forkOrigin: \"judge\" },\n } as AgentOptions);\n const run = await auxAgent.send(prompt);\n const result = await run.wait();\n return parseVerdict(result.result ?? \"\");\n } catch (err) {\n // M80 — 401/403/404 são de credencial/modelo: irrecuperáveis, falham rápido e tipado. Todo o\n // resto (rede, timeout, 5xx) segue dobrado, porque É recuperável e o loop já decide por falhas\n // consecutivas.\n const status = statusHttpDe(err);\n if (status === 401 || status === 403 || status === 404) {\n throw new JudgeCredentialError(status, judgeModel, err);\n }\n return {\n verdict: \"continue\",\n reason: `judge call failed: ${err instanceof Error ? err.message : String(err)}`,\n parseFailed: true,\n };\n } finally {\n if (auxAgent !== undefined) {\n try {\n await auxAgent.dispose();\n } catch {\n // dispose errors are non-fatal; judge result is already prepared\n }\n }\n }\n}\n\n/**\n * Build the strict-format prompt the judge expects.\n *\n * @internal\n */\nexport function composeJudgePrompt(ctx: JudgeContext): string {\n const subgoals =\n ctx.subgoals !== undefined && ctx.subgoals.length > 0 ? ctx.subgoals.join(\", \") : \"(none)\";\n return `You are a goal judge. Determine if this goal is satisfied.\n\nGoal: ${ctx.goal}\nSubgoals: ${subgoals}\nLast agent response: ${ctx.lastResponse}\n\nRespond with EXACTLY one of:\n- DONE: <reason>\n- CONTINUE: <what's left>\n- SKIPPED: <why not applicable>\n\nBe strict. If unclear, prefer CONTINUE.`;\n}\n"]}
|
|
@@ -9145,9 +9145,9 @@ async function localAgentUsePersonality(args) {
|
|
|
9145
9145
|
// src/internal/local-agent/local-agent-runtime-extensions.ts
|
|
9146
9146
|
function localAgentRunUntil(agent, goal, options) {
|
|
9147
9147
|
async function* wrap() {
|
|
9148
|
-
const { runUntilImpl } = await import('./run-until-
|
|
9148
|
+
const { runUntilImpl } = await import('./run-until-K7IO7ZPQ.js');
|
|
9149
9149
|
const buildDeps = async () => {
|
|
9150
|
-
const { judgeCallImpl } = await import('./judge-call-
|
|
9150
|
+
const { judgeCallImpl } = await import('./judge-call-D7R3ZTZS.js');
|
|
9151
9151
|
const { getAgentFacade } = await import('./agent-factory-registry-ZVTABLEY.js');
|
|
9152
9152
|
const create = getAgentFacade().create;
|
|
9153
9153
|
return {
|
|
@@ -9555,7 +9555,7 @@ async function executeSendLocked(inputs, message, options) {
|
|
|
9555
9555
|
function buildCompletionCheckDeps() {
|
|
9556
9556
|
return {
|
|
9557
9557
|
judge: async (ctx, opts) => {
|
|
9558
|
-
const { judgeCallImpl } = await import('./judge-call-
|
|
9558
|
+
const { judgeCallImpl } = await import('./judge-call-D7R3ZTZS.js');
|
|
9559
9559
|
const { getAgentFacade } = await import('./agent-factory-registry-ZVTABLEY.js');
|
|
9560
9560
|
return judgeCallImpl(ctx, opts, { create: getAgentFacade().create });
|
|
9561
9561
|
}
|
|
@@ -10569,5 +10569,5 @@ async function abrirStoreLocal(reg) {
|
|
|
10569
10569
|
}
|
|
10570
10570
|
|
|
10571
10571
|
export { Agent, AgentBuilder, DEFAULT_AGENTIC_MODEL_ID, MEMORY_EMBEDDING_ADAPTERS, Tool, ToolError, UsageAccumulator, computeCost, generateCronId, getPricingEntry, httpRequest, isFixtureApiKey, openRouterMemoryEmbeddingProviderAdapter, resolveApiKey, shouldUseFixtureMode };
|
|
10572
|
-
//# sourceMappingURL=chunk-
|
|
10573
|
-
//# sourceMappingURL=chunk-
|
|
10572
|
+
//# sourceMappingURL=chunk-6M76Z3AI.js.map
|
|
10573
|
+
//# sourceMappingURL=chunk-6M76Z3AI.js.map
|