@theokit/sdk 5.10.0 → 5.11.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/CHANGELOG.md +59 -0
- package/dist/{agent-TLRURB7W.cjs → agent-5DOR5T3E.cjs} +7 -6
- package/dist/{agent-TLRURB7W.cjs.map → agent-5DOR5T3E.cjs.map} +1 -1
- package/dist/{agent-XTLAVVYC.js → agent-GWKRARAL.js} +6 -5
- package/dist/{agent-XTLAVVYC.js.map → agent-GWKRARAL.js.map} +1 -1
- package/dist/{chunk-RTE2DD4S.js → chunk-4PHSVR2R.js} +50 -32
- package/dist/chunk-4PHSVR2R.js.map +1 -0
- package/dist/{chunk-PCLRIQPX.cjs → chunk-5H2GJXGC.cjs} +4 -4
- package/dist/{chunk-PCLRIQPX.cjs.map → chunk-5H2GJXGC.cjs.map} +1 -1
- package/dist/{chunk-CVEQ5366.cjs → chunk-5OHB5HJF.cjs} +90 -72
- package/dist/chunk-5OHB5HJF.cjs.map +1 -0
- package/dist/{chunk-EVH3OUMY.js → chunk-74OA5DIM.js} +189 -43
- package/dist/chunk-74OA5DIM.js.map +1 -0
- package/dist/{chunk-EXI7EHDN.js → chunk-7Y23B7XX.js} +3 -3
- package/dist/{chunk-EXI7EHDN.js.map → chunk-7Y23B7XX.js.map} +1 -1
- package/dist/{chunk-QY3CIMUV.cjs → chunk-BZKF7TXX.cjs} +192 -44
- package/dist/chunk-BZKF7TXX.cjs.map +1 -0
- package/dist/chunk-LZJXEPEQ.js +58 -0
- package/dist/chunk-LZJXEPEQ.js.map +1 -0
- package/dist/{chunk-FR6COQXZ.cjs → chunk-N7ZIPW2N.cjs} +3 -3
- package/dist/{chunk-FR6COQXZ.cjs.map → chunk-N7ZIPW2N.cjs.map} +1 -1
- package/dist/chunk-NWS2CS3Y.cjs +61 -0
- package/dist/chunk-NWS2CS3Y.cjs.map +1 -0
- package/dist/{chunk-523O5UYB.js → chunk-Z5BAFHPU.js} +3 -3
- package/dist/{chunk-523O5UYB.js.map → chunk-Z5BAFHPU.js.map} +1 -1
- package/dist/{compact-session-4QHBBGEY.cjs → compact-session-2AETONOS.cjs} +12 -12
- package/dist/{compact-session-4QHBBGEY.cjs.map → compact-session-2AETONOS.cjs.map} +1 -1
- package/dist/{compact-session-PVAWTKKL.js → compact-session-F2UDGZCN.js} +3 -3
- package/dist/{compact-session-PVAWTKKL.js.map → compact-session-F2UDGZCN.js.map} +1 -1
- package/dist/cron.cjs +6 -5
- package/dist/cron.js +5 -4
- package/dist/eval.cjs +5 -4
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +4 -3
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +38 -128
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -104
- package/dist/index.js.map +1 -1
- package/dist/{inject-session-O24XGRR6.js → inject-session-E5UDFVLI.js} +3 -3
- package/dist/{inject-session-O24XGRR6.js.map → inject-session-E5UDFVLI.js.map} +1 -1
- package/dist/{inject-session-OMLFL2V3.cjs → inject-session-W4UKACYJ.cjs} +4 -4
- package/dist/{inject-session-OMLFL2V3.cjs.map → inject-session-W4UKACYJ.cjs.map} +1 -1
- package/dist/internal/budget/normalize-usage.d.ts +81 -0
- package/dist/internal/llm/anthropic-shared.d.ts +6 -0
- package/dist/internal/llm/openai.d.ts +3 -5
- package/dist/internal/llm/openrouter-system.d.ts +1 -0
- package/dist/internal/llm/types.d.ts +10 -5
- package/dist/models.cjs +5 -50
- package/dist/models.cjs.map +1 -1
- package/dist/models.js +3 -51
- package/dist/models.js.map +1 -1
- package/docs/error-codes.md +3 -2
- package/package.json +1 -1
- package/dist/chunk-CVEQ5366.cjs.map +0 -1
- package/dist/chunk-EVH3OUMY.js.map +0 -1
- package/dist/chunk-QY3CIMUV.cjs.map +0 -1
- package/dist/chunk-RTE2DD4S.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -8,12 +8,12 @@ import { Workflow, agentStep } from './chunk-MU7IAA7G.js';
|
|
|
8
8
|
export { Workflow, agentStep, fn } from './chunk-MU7IAA7G.js';
|
|
9
9
|
import './chunk-HV4V63CO.js';
|
|
10
10
|
import './chunk-HY66GLM6.js';
|
|
11
|
-
export { Cron } from './chunk-
|
|
12
|
-
import { MEMORY_EMBEDDING_ADAPTERS, resolveSessionDir, DEFAULT_AGENTIC_MODEL_ID, Agent } from './chunk-
|
|
13
|
-
export { Agent, AgentBuilder, Tool, ToolError, UsageAccumulator, computeCost, getPricingEntry, managedSettingsPathFor, readManagedSettings } from './chunk-
|
|
11
|
+
export { Cron } from './chunk-Z5BAFHPU.js';
|
|
12
|
+
import { MEMORY_EMBEDDING_ADAPTERS, resolveSessionDir, DEFAULT_AGENTIC_MODEL_ID, Agent } from './chunk-4PHSVR2R.js';
|
|
13
|
+
export { Agent, AgentBuilder, Tool, ToolError, UsageAccumulator, computeCost, getPricingEntry, managedSettingsPathFor, readManagedSettings } from './chunk-4PHSVR2R.js';
|
|
14
14
|
import { configure, submit, list, get, cancel, subscribe } from './chunk-XKMVJ443.js';
|
|
15
15
|
export { emitRunEvent } from './chunk-XKMVJ443.js';
|
|
16
|
-
import './chunk-
|
|
16
|
+
import './chunk-7Y23B7XX.js';
|
|
17
17
|
import './chunk-K2BQQ445.js';
|
|
18
18
|
import './chunk-DPY2M74T.js';
|
|
19
19
|
import './chunk-ZHWKT2NI.js';
|
|
@@ -23,7 +23,8 @@ import './chunk-H73MEMQB.js';
|
|
|
23
23
|
import './chunk-OR6XIWLB.js';
|
|
24
24
|
import { resolveMemoryRoot, readFactsFromMarkdown } from './chunk-X3LOJJMO.js';
|
|
25
25
|
import { FsSessionStore } from './chunk-IZDDSLL2.js';
|
|
26
|
-
import { discoverProviderPlugins, shouldUseFixtureMode, isFixtureApiKey, httpRequest, mapOllamaTransportError, readErrorResponseBody, mapOllamaHttpError } from './chunk-
|
|
26
|
+
import { discoverProviderPlugins, shouldUseFixtureMode, isFixtureApiKey, httpRequest, mapOllamaTransportError, readErrorResponseBody, mapOllamaHttpError } from './chunk-74OA5DIM.js';
|
|
27
|
+
export { inferApiMode, normalizeUsage } from './chunk-74OA5DIM.js';
|
|
27
28
|
import './chunk-SUVCHX4L.js';
|
|
28
29
|
import './chunk-2XC6KDJM.js';
|
|
29
30
|
import './chunk-TE6XVTOA.js';
|
|
@@ -62,6 +63,7 @@ import { CLAUDE_DIR_NAME, THEOKIT_DIR_LITERAL } from './chunk-X7EUUHXU.js';
|
|
|
62
63
|
import './chunk-MQGSOKR3.js';
|
|
63
64
|
import { estimateTokens, CHARS_PER_TOKEN } from './chunk-GMRFAX4I.js';
|
|
64
65
|
export { estimateTokens } from './chunk-GMRFAX4I.js';
|
|
66
|
+
import './chunk-LZJXEPEQ.js';
|
|
65
67
|
import { parseModelId } from './chunk-R7WIIPUR.js';
|
|
66
68
|
import './chunk-I2ORT6QD.js';
|
|
67
69
|
import { registerBuiltins, listProviders, getCatalogCapabilities, getProviderProfile } from './chunk-SVCPJRUB.js';
|
|
@@ -409,103 +411,6 @@ async function dispatchExceed(opts, window, spentUsd, limitUsd, mode) {
|
|
|
409
411
|
}
|
|
410
412
|
}
|
|
411
413
|
|
|
412
|
-
// src/internal/budget/normalize-usage.ts
|
|
413
|
-
function int(v) {
|
|
414
|
-
if (typeof v === "number") return Number.isFinite(v) ? Math.max(0, Math.trunc(v)) : 0;
|
|
415
|
-
if (typeof v === "string") {
|
|
416
|
-
const n = Number.parseInt(v, 10);
|
|
417
|
-
return Number.isFinite(n) ? Math.max(0, n) : 0;
|
|
418
|
-
}
|
|
419
|
-
return 0;
|
|
420
|
-
}
|
|
421
|
-
function buildTotal(buckets) {
|
|
422
|
-
return buckets.inputTokens + buckets.outputTokens + buckets.cacheReadTokens + buckets.cacheWriteTokens;
|
|
423
|
-
}
|
|
424
|
-
function omitUndefined(usage) {
|
|
425
|
-
return {
|
|
426
|
-
inputTokens: usage.inputTokens,
|
|
427
|
-
outputTokens: usage.outputTokens,
|
|
428
|
-
...usage.cacheReadTokens > 0 ? { cacheReadTokens: usage.cacheReadTokens } : {},
|
|
429
|
-
...usage.cacheWriteTokens > 0 ? { cacheWriteTokens: usage.cacheWriteTokens } : {},
|
|
430
|
-
...usage.reasoningTokens > 0 ? { reasoningTokens: usage.reasoningTokens } : {},
|
|
431
|
-
totalTokens: usage.totalTokens
|
|
432
|
-
};
|
|
433
|
-
}
|
|
434
|
-
function inferApiMode(provider) {
|
|
435
|
-
const p = provider.toLowerCase();
|
|
436
|
-
if (p === "anthropic" || p === "claude" || p === "bedrock_anthropic") {
|
|
437
|
-
return "anthropic_messages";
|
|
438
|
-
}
|
|
439
|
-
if (p === "openai-codex" || p === "codex") return "openai_responses";
|
|
440
|
-
return "openai_chat_completions";
|
|
441
|
-
}
|
|
442
|
-
function normalizeUsage(rawUsage, opts) {
|
|
443
|
-
if (rawUsage === null || rawUsage === void 0) {
|
|
444
|
-
return { inputTokens: 0, outputTokens: 0, totalTokens: 0 };
|
|
445
|
-
}
|
|
446
|
-
if (typeof rawUsage !== "object") {
|
|
447
|
-
return { inputTokens: 0, outputTokens: 0, totalTokens: 0 };
|
|
448
|
-
}
|
|
449
|
-
const raw = rawUsage;
|
|
450
|
-
const mode = opts.apiMode ?? inferApiMode(opts.provider);
|
|
451
|
-
if (mode === "anthropic_messages") return normalizeAnthropic(raw);
|
|
452
|
-
if (mode === "openai_responses") return normalizeOpenAIResponses(raw);
|
|
453
|
-
return normalizeOpenAIChat(raw);
|
|
454
|
-
}
|
|
455
|
-
function normalizeAnthropic(raw) {
|
|
456
|
-
const inputTokens = int(raw.input_tokens);
|
|
457
|
-
const outputTokens = int(raw.output_tokens);
|
|
458
|
-
const cacheReadTokens = int(raw.cache_read_input_tokens);
|
|
459
|
-
const cacheWriteTokens = int(raw.cache_creation_input_tokens);
|
|
460
|
-
const usage = {
|
|
461
|
-
inputTokens,
|
|
462
|
-
outputTokens,
|
|
463
|
-
cacheReadTokens,
|
|
464
|
-
cacheWriteTokens,
|
|
465
|
-
reasoningTokens: 0,
|
|
466
|
-
totalTokens: buildTotal({ inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens })
|
|
467
|
-
};
|
|
468
|
-
return omitUndefined(usage);
|
|
469
|
-
}
|
|
470
|
-
function normalizeOpenAIResponses(raw) {
|
|
471
|
-
const inputTotal = int(raw.input_tokens);
|
|
472
|
-
const outputTokens = int(raw.output_tokens);
|
|
473
|
-
const inputDetails = raw.input_tokens_details ?? {};
|
|
474
|
-
const outputDetails = raw.output_tokens_details ?? {};
|
|
475
|
-
const cacheReadTokens = int(inputDetails.cached_tokens);
|
|
476
|
-
const cacheWriteTokens = int(inputDetails.cache_creation_tokens);
|
|
477
|
-
const reasoningTokens = int(outputDetails.reasoning_tokens);
|
|
478
|
-
const inputTokens = Math.max(0, inputTotal - cacheReadTokens - cacheWriteTokens);
|
|
479
|
-
const usage = {
|
|
480
|
-
inputTokens,
|
|
481
|
-
outputTokens,
|
|
482
|
-
cacheReadTokens,
|
|
483
|
-
cacheWriteTokens,
|
|
484
|
-
reasoningTokens,
|
|
485
|
-
totalTokens: buildTotal({ inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens })
|
|
486
|
-
};
|
|
487
|
-
return omitUndefined(usage);
|
|
488
|
-
}
|
|
489
|
-
function normalizeOpenAIChat(raw) {
|
|
490
|
-
const promptTotal = int(raw.prompt_tokens);
|
|
491
|
-
const outputTokens = int(raw.completion_tokens);
|
|
492
|
-
const promptDetails = raw.prompt_tokens_details ?? {};
|
|
493
|
-
const completionDetails = raw.completion_tokens_details ?? {};
|
|
494
|
-
const cacheReadTokens = int(promptDetails.cached_tokens) || int(raw.cache_read_input_tokens);
|
|
495
|
-
const cacheWriteTokens = int(promptDetails.cache_write_tokens) || int(raw.cache_creation_input_tokens);
|
|
496
|
-
const reasoningTokens = int(completionDetails.reasoning_tokens);
|
|
497
|
-
const inputTokens = Math.max(0, promptTotal - cacheReadTokens - cacheWriteTokens);
|
|
498
|
-
const usage = {
|
|
499
|
-
inputTokens,
|
|
500
|
-
outputTokens,
|
|
501
|
-
cacheReadTokens,
|
|
502
|
-
cacheWriteTokens,
|
|
503
|
-
reasoningTokens,
|
|
504
|
-
totalTokens: buildTotal({ inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens })
|
|
505
|
-
};
|
|
506
|
-
return omitUndefined(usage);
|
|
507
|
-
}
|
|
508
|
-
|
|
509
414
|
// src/budget.ts
|
|
510
415
|
var Budget = class {
|
|
511
416
|
// D375 — static class with private constructor.
|
|
@@ -2024,7 +1929,7 @@ function isBuiltAgent(m) {
|
|
|
2024
1929
|
return typeof m.send === "function";
|
|
2025
1930
|
}
|
|
2026
1931
|
async function materialize(def, index) {
|
|
2027
|
-
const { Agent: Agent2 } = await import('./agent-
|
|
1932
|
+
const { Agent: Agent2 } = await import('./agent-GWKRARAL.js');
|
|
2028
1933
|
return Agent2.create({
|
|
2029
1934
|
// `AgentDefinition.model` admits the sentinel `'inherit'`, which is not a model id. Inheriting
|
|
2030
1935
|
// here means "declare nothing and let the default apply" — forwarding the literal would create
|
|
@@ -2558,6 +2463,6 @@ function recordWiring(input) {
|
|
|
2558
2463
|
return record;
|
|
2559
2464
|
}
|
|
2560
2465
|
|
|
2561
|
-
export { AgentFactory, Budget, EventBus, JobQueue, LayerOrderError, LiveSessionError, Memory, NoopMemoryProvider, PermissionEngine, PermissionPlugin, Plugin, Provider, RetentionPolicyError, SOVEREIGN_ENV_KEYS, Security, Skill, SkillReadTool, Squad, Task, Theokit, TokenLimiter, UngatedCapabilityError, UnicodeNormalizer, applyMode, applySecurityFloor, auditEnvReachability, chargeAndCheckThresholds, createCounterBudgetTracker, createTokenLimiter, createUnicodeNormalizer, decideApproval, describeAction, describeCredential, effectiveToolNames, evaluateBlastRadius, extractRawId, foldLayers, guardSessionDestruction,
|
|
2466
|
+
export { AgentFactory, Budget, EventBus, JobQueue, LayerOrderError, LiveSessionError, Memory, NoopMemoryProvider, PermissionEngine, PermissionPlugin, Plugin, Provider, RetentionPolicyError, SOVEREIGN_ENV_KEYS, Security, Skill, SkillReadTool, Squad, Task, Theokit, TokenLimiter, UngatedCapabilityError, UnicodeNormalizer, applyMode, applySecurityFloor, auditEnvReachability, chargeAndCheckThresholds, createCounterBudgetTracker, createTokenLimiter, createUnicodeNormalizer, decideApproval, describeAction, describeCredential, effectiveToolNames, evaluateBlastRadius, extractRawId, foldLayers, guardSessionDestruction, isInside, loadProjectEnv, migrateSqliteToLance2 as migrateSqliteToLance, mkMemoryId, normalizeSchema, parsePermissionRules, permissionFloorReason, planReaping, preflightCheck, readSessionMessages2 as readSessionMessages, recordWiring, resolveTrustPosture, runGoalLoop, scopedConversationId, sessionScopePrefix, toShareGptTrajectory, verifyLayerOrdering, withBlastRadius };
|
|
2562
2467
|
//# sourceMappingURL=index.js.map
|
|
2563
2468
|
//# sourceMappingURL=index.js.map
|