@codelia/runtime 0.1.91 → 0.1.93
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/{chunk-X4222JDX.js → chunk-K42SQONI.js} +265 -36
- package/dist/{chunk-EC2N4PCP.js → chunk-OQGZHVYU.js} +781 -627
- package/dist/index.cjs +1036 -661
- package/dist/index.js +2 -2
- package/dist/sdk.cjs +1036 -661
- package/dist/sdk.d.cts +2 -0
- package/dist/sdk.d.ts +2 -0
- package/dist/sdk.js +2 -2
- package/dist/subagents/child-entry.cjs +273 -20
- package/dist/subagents/child-entry.js +1 -1
- package/package.json +12 -12
package/dist/sdk.d.cts
CHANGED
|
@@ -668,6 +668,8 @@ type RuntimeConfigProvider = {
|
|
|
668
668
|
resolveExecutionEnvironmentConfig?: (workingDir?: string) => Promise<ResolvedExecutionEnvironmentConfig>;
|
|
669
669
|
resolveTuiConfig?: (workingDir?: string) => Promise<{
|
|
670
670
|
theme?: string;
|
|
671
|
+
color_scheme?: "dark" | "light";
|
|
672
|
+
image_protocol?: "halfblocks" | "kitty";
|
|
671
673
|
}>;
|
|
672
674
|
updateModel?: (workingDir: string | undefined, model: {
|
|
673
675
|
provider: string;
|
package/dist/sdk.d.ts
CHANGED
|
@@ -668,6 +668,8 @@ type RuntimeConfigProvider = {
|
|
|
668
668
|
resolveExecutionEnvironmentConfig?: (workingDir?: string) => Promise<ResolvedExecutionEnvironmentConfig>;
|
|
669
669
|
resolveTuiConfig?: (workingDir?: string) => Promise<{
|
|
670
670
|
theme?: string;
|
|
671
|
+
color_scheme?: "dark" | "light";
|
|
672
|
+
image_protocol?: "halfblocks" | "kitty";
|
|
671
673
|
}>;
|
|
672
674
|
updateModel?: (workingDir: string | undefined, model: {
|
|
673
675
|
provider: string;
|
package/dist/sdk.js
CHANGED
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
mcpEntryMatchesServer,
|
|
7
7
|
resolveMcpServerBinding,
|
|
8
8
|
startRuntime
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-OQGZHVYU.js";
|
|
10
10
|
import {
|
|
11
11
|
createLinuxMxcShellBackend,
|
|
12
12
|
createMacMxcShellBackend
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-K42SQONI.js";
|
|
14
14
|
|
|
15
15
|
// src/permissions/brokered-mutation.ts
|
|
16
16
|
var runBrokeredMutation = async (request, adapter, signal) => {
|
|
@@ -47,6 +47,37 @@ var resolveConfigPath = () => {
|
|
|
47
47
|
return storage.resolvePaths().configFile;
|
|
48
48
|
};
|
|
49
49
|
var resolveProjectConfigPath = (workingDir) => import_node_path.default.resolve(workingDir, ".codelia", "config.json");
|
|
50
|
+
var resolveDistinctProjectConfigPath = (workingDir) => {
|
|
51
|
+
if (!workingDir) return null;
|
|
52
|
+
const projectPath = resolveProjectConfigPath(workingDir);
|
|
53
|
+
return (0, import_storage.isSameConfigFilePath)(resolveConfigPath(), projectPath) ? null : projectPath;
|
|
54
|
+
};
|
|
55
|
+
var loadConfigLayers = async (workingDir) => {
|
|
56
|
+
const configPath = resolveConfigPath();
|
|
57
|
+
let globalConfig = null;
|
|
58
|
+
try {
|
|
59
|
+
globalConfig = await (0, import_config_loader.loadConfig)(configPath);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
62
|
+
throw new Error(`Failed to load config.json: ${message}`);
|
|
63
|
+
}
|
|
64
|
+
let projectConfig = null;
|
|
65
|
+
const projectPath = resolveDistinctProjectConfigPath(workingDir);
|
|
66
|
+
if (projectPath) {
|
|
67
|
+
try {
|
|
68
|
+
projectConfig = await (0, import_config_loader.loadConfig)(projectPath);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
71
|
+
throw new Error(`Failed to load project config.json: ${message}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return { globalConfig, projectConfig };
|
|
75
|
+
};
|
|
76
|
+
var resolveAuthOAuthBrowser = async (workingDir) => {
|
|
77
|
+
const { globalConfig, projectConfig } = await loadConfigLayers(workingDir);
|
|
78
|
+
const effective = import_config.configRegistry.resolve([globalConfig, projectConfig]);
|
|
79
|
+
return effective.auth?.oauth_browser;
|
|
80
|
+
};
|
|
50
81
|
var normalizeModelLevel = (value) => value.trim().toLowerCase();
|
|
51
82
|
var resolveReasoningEffort = (value) => {
|
|
52
83
|
return resolveModelLevelOption(value, "model.reasoning", {
|
|
@@ -100,6 +131,7 @@ var serializeMessage = (msg) => ({
|
|
|
100
131
|
`,
|
|
101
132
|
label: describeRpcMessage(msg)
|
|
102
133
|
});
|
|
134
|
+
var transportBackpressureEvents = 0;
|
|
103
135
|
var send = (msg) => {
|
|
104
136
|
const { payload, label } = serializeMessage(msg);
|
|
105
137
|
const writable = process.stdout.write(payload, (error) => {
|
|
@@ -108,6 +140,7 @@ var send = (msg) => {
|
|
|
108
140
|
}
|
|
109
141
|
});
|
|
110
142
|
if (!writable) {
|
|
143
|
+
transportBackpressureEvents += 1;
|
|
111
144
|
(0, import_logger.debugLog)(`transport.backpressure label=${label} bytes=${payload.length}`);
|
|
112
145
|
}
|
|
113
146
|
};
|
|
@@ -126,8 +159,18 @@ var schemaFor = (method, slot) => {
|
|
|
126
159
|
throw new Error(`${method} is a notification without a result`);
|
|
127
160
|
return spec.result;
|
|
128
161
|
};
|
|
162
|
+
var cachedProtocolAssertRaw;
|
|
163
|
+
var cachedProtocolAssertEnabled = false;
|
|
164
|
+
var isProtocolAssertEnabled = () => {
|
|
165
|
+
const raw = process.env.CODELIA_TEST_PROTOCOL_ASSERT;
|
|
166
|
+
if (raw !== cachedProtocolAssertRaw) {
|
|
167
|
+
cachedProtocolAssertRaw = raw;
|
|
168
|
+
cachedProtocolAssertEnabled = raw === "1";
|
|
169
|
+
}
|
|
170
|
+
return cachedProtocolAssertEnabled;
|
|
171
|
+
};
|
|
129
172
|
var assertOutgoing = (method, slot, value) => {
|
|
130
|
-
if (
|
|
173
|
+
if (!isProtocolAssertEnabled()) return;
|
|
131
174
|
const result = schemaFor(method, slot).safeParse(value);
|
|
132
175
|
if (!result.success)
|
|
133
176
|
throw new Error(
|
|
@@ -241,14 +284,14 @@ var readBrowserMode = (value) => {
|
|
|
241
284
|
return null;
|
|
242
285
|
};
|
|
243
286
|
var hasSshSession = (env) => !!env.SSH_CONNECTION || !!env.SSH_CLIENT || !!env.SSH_TTY;
|
|
244
|
-
var resolveOAuthBrowserMode = (env = process.env) => {
|
|
245
|
-
const configured = readBrowserMode(
|
|
287
|
+
var resolveOAuthBrowserMode = (configuredMode, env = process.env) => {
|
|
288
|
+
const configured = readBrowserMode(configuredMode);
|
|
246
289
|
if (configured) {
|
|
247
290
|
return configured;
|
|
248
291
|
}
|
|
249
292
|
return hasSshSession(env) ? "manual" : "auto";
|
|
250
293
|
};
|
|
251
|
-
var shouldAutoOpenOAuthBrowser = (env = process.env) => resolveOAuthBrowserMode(env) === "auto";
|
|
294
|
+
var shouldAutoOpenOAuthBrowser = (configuredMode, env = process.env) => resolveOAuthBrowserMode(configuredMode, env) === "auto";
|
|
252
295
|
var parseCallbackParams = (input) => {
|
|
253
296
|
const trimmed = input.trim();
|
|
254
297
|
if (!trimmed) {
|
|
@@ -421,7 +464,7 @@ var OPENAI_OAUTH_ORIGINATOR = "codelia";
|
|
|
421
464
|
var OPENAI_OAUTH_USER_AGENT = "codelia-cli";
|
|
422
465
|
var HTML_SUCCESS = "<!doctype html><html><head><title>codelia - Authorization successful</title></head><body><h2>Authorization successful</h2><p>You can close this window.</p></body></html>";
|
|
423
466
|
var HTML_ERROR = (message) => `<!doctype html><html><head><title>codelia - Authorization failed</title></head><body><h2>Authorization failed</h2><pre>${message}</pre></body></html>`;
|
|
424
|
-
var clientId = () =>
|
|
467
|
+
var clientId = () => DEFAULT_CLIENT_ID;
|
|
425
468
|
var oauthPort = () => readPositiveIntEnv("CODELIA_OPENAI_OAUTH_PORT", DEFAULT_PORT);
|
|
426
469
|
var buildAuthorizeUrl = (redirectUri, pkce, state) => {
|
|
427
470
|
const params = new URLSearchParams({
|
|
@@ -645,11 +688,8 @@ var DEFAULT_CLIENT_ID2 = "app_EMoamEEZ73f0CkXaXp7hrann";
|
|
|
645
688
|
var ISSUER2 = "https://auth.openai.com";
|
|
646
689
|
var DEFAULT_TIMEOUT_MS = 15 * 60 * 1e3;
|
|
647
690
|
var DEFAULT_INTERVAL_SECONDS = 5;
|
|
648
|
-
var clientId2 = () =>
|
|
649
|
-
var deviceCodeTimeoutMs = () =>
|
|
650
|
-
"CODELIA_OPENAI_DEVICE_CODE_TIMEOUT_MS",
|
|
651
|
-
DEFAULT_TIMEOUT_MS
|
|
652
|
-
);
|
|
691
|
+
var clientId2 = () => DEFAULT_CLIENT_ID2;
|
|
692
|
+
var deviceCodeTimeoutMs = () => DEFAULT_TIMEOUT_MS;
|
|
653
693
|
var cancelledError = () => new Error("device code login cancelled");
|
|
654
694
|
var sleep = (ms, signal) => new Promise((resolve, reject) => {
|
|
655
695
|
if (signal?.aborted) {
|
|
@@ -1318,7 +1358,10 @@ var AuthResolver = class _AuthResolver {
|
|
|
1318
1358
|
if (!supportsPick || !supportsPrompt) {
|
|
1319
1359
|
throw new Error("UI does not support auth prompts");
|
|
1320
1360
|
}
|
|
1321
|
-
const
|
|
1361
|
+
const configuredBrowser = await resolveAuthOAuthBrowser(
|
|
1362
|
+
this.state.runtimeWorkingDir ?? void 0
|
|
1363
|
+
).catch(() => void 0);
|
|
1364
|
+
const prefersDeviceCode = resolveOAuthBrowserMode(configuredBrowser) === "manual";
|
|
1322
1365
|
const pick = await requestUiPick(this.state, {
|
|
1323
1366
|
title: "How would you like to connect OpenAI?",
|
|
1324
1367
|
items: prefersDeviceCode ? [
|
|
@@ -1377,7 +1420,10 @@ var AuthResolver = class _AuthResolver {
|
|
|
1377
1420
|
throw new Error("UI does not support device code confirmation");
|
|
1378
1421
|
}
|
|
1379
1422
|
const session = await createOpenAiDeviceCodeSession();
|
|
1380
|
-
const
|
|
1423
|
+
const configuredBrowser = await resolveAuthOAuthBrowser(
|
|
1424
|
+
this.state.runtimeWorkingDir ?? void 0
|
|
1425
|
+
).catch(() => void 0);
|
|
1426
|
+
const shouldAutoOpen = shouldAutoOpenOAuthBrowser(configuredBrowser);
|
|
1381
1427
|
const confirm = await requestUiConfirm(this.state, {
|
|
1382
1428
|
title: "OpenAI device code",
|
|
1383
1429
|
message: [
|
|
@@ -1420,7 +1466,10 @@ var AuthResolver = class _AuthResolver {
|
|
|
1420
1466
|
if (!supportsConfirm) {
|
|
1421
1467
|
throw new Error("UI does not support OAuth confirmation");
|
|
1422
1468
|
}
|
|
1423
|
-
const
|
|
1469
|
+
const configuredBrowser = await resolveAuthOAuthBrowser(
|
|
1470
|
+
this.state.runtimeWorkingDir ?? void 0
|
|
1471
|
+
).catch(() => void 0);
|
|
1472
|
+
const shouldAutoOpen = shouldAutoOpenOAuthBrowser(configuredBrowser);
|
|
1424
1473
|
const canPasteCallback = !shouldAutoOpen && supportsPrompt;
|
|
1425
1474
|
const session = await createOAuthSession({
|
|
1426
1475
|
callbackMode: canPasteCallback ? "paste" : "server"
|
|
@@ -1506,6 +1555,7 @@ var AuthResolver = class _AuthResolver {
|
|
|
1506
1555
|
|
|
1507
1556
|
// src/model-factory.ts
|
|
1508
1557
|
var import_core6 = require("@codelia/core");
|
|
1558
|
+
var import_logger5 = require("@codelia/logger");
|
|
1509
1559
|
var import_model_metadata = require("@codelia/model-metadata");
|
|
1510
1560
|
var import_storage4 = require("@codelia/storage");
|
|
1511
1561
|
|
|
@@ -2030,17 +2080,12 @@ var requireApiKeyAuth = (provider, auth) => {
|
|
|
2030
2080
|
}
|
|
2031
2081
|
return auth.api_key;
|
|
2032
2082
|
};
|
|
2033
|
-
var envTruthy = (value) => {
|
|
2034
|
-
if (!value) return false;
|
|
2035
|
-
const normalized = value.trim().toLowerCase();
|
|
2036
|
-
return normalized === "1" || normalized === "true";
|
|
2037
|
-
};
|
|
2038
2083
|
var buildOpenAiClientOptions = (getOpenAiAccessToken, auth, log2) => {
|
|
2039
2084
|
if (auth.method === "api_key") {
|
|
2040
2085
|
return { apiKey: auth.api_key };
|
|
2041
2086
|
}
|
|
2042
2087
|
let accountId = auth.oauth.account_id;
|
|
2043
|
-
const enableDebugHttp =
|
|
2088
|
+
const enableDebugHttp = (0, import_logger5.isDebugEnabled)();
|
|
2044
2089
|
const apiKey = async () => {
|
|
2045
2090
|
if (!getOpenAiAccessToken) {
|
|
2046
2091
|
throw new Error("OpenAI OAuth token refresh is unavailable");
|
|
@@ -2630,6 +2675,213 @@ var defaultSandboxMode = Object.freeze({
|
|
|
2630
2675
|
source: "fallback"
|
|
2631
2676
|
});
|
|
2632
2677
|
|
|
2678
|
+
// src/telemetry.ts
|
|
2679
|
+
var MAX_RECENT_CALLS = 64;
|
|
2680
|
+
var MAX_RECENT_TOOLS = 64;
|
|
2681
|
+
var cloneModelUsage = (entry) => ({
|
|
2682
|
+
...entry
|
|
2683
|
+
});
|
|
2684
|
+
var createEmptyTelemetrySummary = () => ({
|
|
2685
|
+
total_calls: 0,
|
|
2686
|
+
total_tokens: 0,
|
|
2687
|
+
total_input_tokens: 0,
|
|
2688
|
+
total_output_tokens: 0,
|
|
2689
|
+
total_output_reasoning_tokens: 0,
|
|
2690
|
+
total_cached_input_tokens: 0,
|
|
2691
|
+
total_cache_creation_tokens: 0,
|
|
2692
|
+
total_input_image_tokens: 0,
|
|
2693
|
+
cache_hit_calls: 0,
|
|
2694
|
+
cache_miss_calls: 0,
|
|
2695
|
+
cache_unknown_calls: 0,
|
|
2696
|
+
total_cost_usd: null,
|
|
2697
|
+
retry_count: 0,
|
|
2698
|
+
retry_wait_ms: 0,
|
|
2699
|
+
tool_calls: 0,
|
|
2700
|
+
tool_errors: 0,
|
|
2701
|
+
tool_exec_ms: 0,
|
|
2702
|
+
tool_approval_wait_ms: 0,
|
|
2703
|
+
compaction_count: 0,
|
|
2704
|
+
compaction_duration_ms: 0,
|
|
2705
|
+
by_model: {}
|
|
2706
|
+
});
|
|
2707
|
+
var cloneTelemetrySummary = (summary) => ({
|
|
2708
|
+
...summary,
|
|
2709
|
+
by_model: Object.fromEntries(
|
|
2710
|
+
Object.entries(summary.by_model).map(([model, entry]) => [
|
|
2711
|
+
model,
|
|
2712
|
+
cloneModelUsage(entry)
|
|
2713
|
+
])
|
|
2714
|
+
)
|
|
2715
|
+
});
|
|
2716
|
+
var applyCallToSummary = (summary, call) => {
|
|
2717
|
+
const usage = call.usage ?? null;
|
|
2718
|
+
const inputTokens = usage?.input_tokens ?? 0;
|
|
2719
|
+
const outputTokens = usage?.output_tokens ?? 0;
|
|
2720
|
+
const reasoningTokens = usage?.output_reasoning_tokens ?? 0;
|
|
2721
|
+
const cachedTokens = usage?.input_cached_tokens ?? 0;
|
|
2722
|
+
const cacheCreationTokens = usage?.input_cache_creation_tokens ?? 0;
|
|
2723
|
+
const imageTokens = usage?.input_image_tokens ?? 0;
|
|
2724
|
+
const totalTokens = usage?.total_tokens ?? 0;
|
|
2725
|
+
const hitState = call.cache?.hit_state ?? (typeof usage?.input_cached_tokens === "number" ? cachedTokens > 0 ? "hit" : "miss" : "unknown");
|
|
2726
|
+
const validCost = typeof call.cost_usd === "number" && Number.isFinite(call.cost_usd) && call.cost_usd >= 0 ? call.cost_usd : null;
|
|
2727
|
+
summary.total_calls += 1;
|
|
2728
|
+
summary.total_tokens += totalTokens;
|
|
2729
|
+
summary.total_input_tokens += inputTokens;
|
|
2730
|
+
summary.total_output_tokens += outputTokens;
|
|
2731
|
+
summary.total_output_reasoning_tokens += reasoningTokens;
|
|
2732
|
+
summary.total_cached_input_tokens += cachedTokens;
|
|
2733
|
+
summary.total_cache_creation_tokens += cacheCreationTokens;
|
|
2734
|
+
summary.total_input_image_tokens += imageTokens;
|
|
2735
|
+
if (hitState === "hit") summary.cache_hit_calls += 1;
|
|
2736
|
+
else if (hitState === "miss") summary.cache_miss_calls += 1;
|
|
2737
|
+
else summary.cache_unknown_calls += 1;
|
|
2738
|
+
if (validCost !== null) {
|
|
2739
|
+
summary.total_cost_usd = (summary.total_cost_usd ?? 0) + validCost;
|
|
2740
|
+
}
|
|
2741
|
+
const modelKey = call.model ?? "unknown";
|
|
2742
|
+
const existing = summary.by_model[modelKey];
|
|
2743
|
+
if (!existing) {
|
|
2744
|
+
summary.by_model[modelKey] = {
|
|
2745
|
+
calls: 1,
|
|
2746
|
+
input_tokens: inputTokens,
|
|
2747
|
+
output_tokens: outputTokens,
|
|
2748
|
+
output_reasoning_tokens: reasoningTokens,
|
|
2749
|
+
cached_input_tokens: cachedTokens,
|
|
2750
|
+
cache_creation_tokens: cacheCreationTokens,
|
|
2751
|
+
input_image_tokens: imageTokens,
|
|
2752
|
+
cache_hit_calls: hitState === "hit" ? 1 : 0,
|
|
2753
|
+
cache_miss_calls: hitState === "miss" ? 1 : 0,
|
|
2754
|
+
cache_unknown_calls: hitState === "unknown" ? 1 : 0,
|
|
2755
|
+
total_tokens: totalTokens,
|
|
2756
|
+
cost_usd: validCost
|
|
2757
|
+
};
|
|
2758
|
+
} else {
|
|
2759
|
+
existing.calls += 1;
|
|
2760
|
+
existing.input_tokens += inputTokens;
|
|
2761
|
+
existing.output_tokens += outputTokens;
|
|
2762
|
+
existing.output_reasoning_tokens += reasoningTokens;
|
|
2763
|
+
existing.cached_input_tokens += cachedTokens;
|
|
2764
|
+
existing.cache_creation_tokens += cacheCreationTokens;
|
|
2765
|
+
existing.input_image_tokens += imageTokens;
|
|
2766
|
+
if (hitState === "hit") existing.cache_hit_calls += 1;
|
|
2767
|
+
else if (hitState === "miss") existing.cache_miss_calls += 1;
|
|
2768
|
+
else existing.cache_unknown_calls += 1;
|
|
2769
|
+
existing.total_tokens += totalTokens;
|
|
2770
|
+
if (validCost !== null) {
|
|
2771
|
+
existing.cost_usd = (existing.cost_usd ?? 0) + validCost;
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2774
|
+
};
|
|
2775
|
+
var applyToolToSummary = (summary, record) => {
|
|
2776
|
+
summary.tool_calls += 1;
|
|
2777
|
+
if (record.status === "error") {
|
|
2778
|
+
summary.tool_errors += 1;
|
|
2779
|
+
}
|
|
2780
|
+
summary.tool_exec_ms += Math.max(
|
|
2781
|
+
0,
|
|
2782
|
+
record.exec_duration_ms ?? record.duration_ms
|
|
2783
|
+
);
|
|
2784
|
+
summary.tool_approval_wait_ms += Math.max(0, record.approval_wait_ms ?? 0);
|
|
2785
|
+
};
|
|
2786
|
+
var applyRetryToSummary = (summary, delayMs) => {
|
|
2787
|
+
summary.retry_count += 1;
|
|
2788
|
+
summary.retry_wait_ms += Math.max(0, Math.round(delayMs));
|
|
2789
|
+
};
|
|
2790
|
+
var applyCompactionToSummary = (summary, durationMs) => {
|
|
2791
|
+
summary.compaction_count += 1;
|
|
2792
|
+
summary.compaction_duration_ms += Math.max(0, durationMs);
|
|
2793
|
+
};
|
|
2794
|
+
var RuntimeTelemetryStore = class {
|
|
2795
|
+
sessionSummary = createEmptyTelemetrySummary();
|
|
2796
|
+
currentRunId = null;
|
|
2797
|
+
currentRunSummary = null;
|
|
2798
|
+
recentCalls = [];
|
|
2799
|
+
recentTools = [];
|
|
2800
|
+
startupPhases = [];
|
|
2801
|
+
agentInitPhases = [];
|
|
2802
|
+
resetSession() {
|
|
2803
|
+
this.sessionSummary = createEmptyTelemetrySummary();
|
|
2804
|
+
this.currentRunId = null;
|
|
2805
|
+
this.currentRunSummary = null;
|
|
2806
|
+
this.recentCalls.length = 0;
|
|
2807
|
+
this.recentTools.length = 0;
|
|
2808
|
+
}
|
|
2809
|
+
beginRun(runId) {
|
|
2810
|
+
this.currentRunId = runId;
|
|
2811
|
+
this.currentRunSummary = createEmptyTelemetrySummary();
|
|
2812
|
+
}
|
|
2813
|
+
recordLlmCall(call) {
|
|
2814
|
+
applyCallToSummary(this.sessionSummary, call);
|
|
2815
|
+
if (this.currentRunId === call.run_id && this.currentRunSummary) {
|
|
2816
|
+
applyCallToSummary(this.currentRunSummary, call);
|
|
2817
|
+
}
|
|
2818
|
+
const { session: _session, ...callRecord } = call;
|
|
2819
|
+
this.recentCalls.push(callRecord);
|
|
2820
|
+
if (this.recentCalls.length > MAX_RECENT_CALLS) {
|
|
2821
|
+
this.recentCalls.shift();
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
recordToolComplete(record) {
|
|
2825
|
+
applyToolToSummary(this.sessionSummary, record);
|
|
2826
|
+
if (this.currentRunId === record.run_id && this.currentRunSummary) {
|
|
2827
|
+
applyToolToSummary(this.currentRunSummary, record);
|
|
2828
|
+
}
|
|
2829
|
+
this.recentTools.push(record);
|
|
2830
|
+
if (this.recentTools.length > MAX_RECENT_TOOLS) {
|
|
2831
|
+
this.recentTools.shift();
|
|
2832
|
+
}
|
|
2833
|
+
}
|
|
2834
|
+
recordRetry(runId, delayMs) {
|
|
2835
|
+
applyRetryToSummary(this.sessionSummary, delayMs);
|
|
2836
|
+
if (this.currentRunId === runId && this.currentRunSummary) {
|
|
2837
|
+
applyRetryToSummary(this.currentRunSummary, delayMs);
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
recordRetryWait(runId, waitMs) {
|
|
2841
|
+
const rounded = Math.max(0, Math.round(waitMs));
|
|
2842
|
+
this.sessionSummary.retry_wait_ms += rounded;
|
|
2843
|
+
if (this.currentRunId === runId && this.currentRunSummary) {
|
|
2844
|
+
this.currentRunSummary.retry_wait_ms += rounded;
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
recordCompaction(runId, durationMs) {
|
|
2848
|
+
applyCompactionToSummary(this.sessionSummary, durationMs);
|
|
2849
|
+
if (this.currentRunId === runId && this.currentRunSummary) {
|
|
2850
|
+
applyCompactionToSummary(this.currentRunSummary, durationMs);
|
|
2851
|
+
}
|
|
2852
|
+
}
|
|
2853
|
+
recordStartupPhase(name, durationMs) {
|
|
2854
|
+
this.startupPhases.push({
|
|
2855
|
+
name,
|
|
2856
|
+
duration_ms: Math.max(0, Math.round(durationMs))
|
|
2857
|
+
});
|
|
2858
|
+
}
|
|
2859
|
+
setAgentInitPhases(phases) {
|
|
2860
|
+
this.agentInitPhases = phases.map((phase) => ({
|
|
2861
|
+
name: phase.name,
|
|
2862
|
+
duration_ms: Math.max(0, Math.round(phase.duration_ms))
|
|
2863
|
+
}));
|
|
2864
|
+
}
|
|
2865
|
+
getSessionSummary() {
|
|
2866
|
+
return cloneTelemetrySummary(this.sessionSummary);
|
|
2867
|
+
}
|
|
2868
|
+
getRunSummary() {
|
|
2869
|
+
return this.currentRunSummary ? cloneTelemetrySummary(this.currentRunSummary) : null;
|
|
2870
|
+
}
|
|
2871
|
+
getRecentCalls() {
|
|
2872
|
+
return this.recentCalls.slice();
|
|
2873
|
+
}
|
|
2874
|
+
getRecentTools() {
|
|
2875
|
+
return this.recentTools.slice();
|
|
2876
|
+
}
|
|
2877
|
+
getStartupPhases() {
|
|
2878
|
+
return this.startupPhases.slice();
|
|
2879
|
+
}
|
|
2880
|
+
getAgentInitPhases() {
|
|
2881
|
+
return this.agentInitPhases.slice();
|
|
2882
|
+
}
|
|
2883
|
+
};
|
|
2884
|
+
|
|
2633
2885
|
// src/runtime-state.ts
|
|
2634
2886
|
var RuntimeState = class {
|
|
2635
2887
|
attachments;
|
|
@@ -2762,6 +3014,7 @@ var RuntimeState = class {
|
|
|
2762
3014
|
set sessionId(value) {
|
|
2763
3015
|
if (value === this.boundSessionId) return;
|
|
2764
3016
|
this.boundSessionId = value;
|
|
3017
|
+
this.telemetry.resetSession();
|
|
2765
3018
|
this.receiptOwner.abort();
|
|
2766
3019
|
this.receiptOwner = new AbortController();
|
|
2767
3020
|
this.signalApprovalChange();
|
|
@@ -2825,7 +3078,7 @@ var RuntimeState = class {
|
|
|
2825
3078
|
currentModelName = null;
|
|
2826
3079
|
currentModelSource = null;
|
|
2827
3080
|
sessionModelOverride = null;
|
|
2828
|
-
|
|
3081
|
+
telemetry = new RuntimeTelemetryStore();
|
|
2829
3082
|
setRuntimeEnvironment(options) {
|
|
2830
3083
|
this.effectiveEnvironment = resolveRuntimeEnvironment(options);
|
|
2831
3084
|
const value = this.effectiveEnvironment.workspace.sandboxMode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codelia/runtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.93",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
"typecheck": "tsc --noEmit"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@codelia/config": "0.1.
|
|
33
|
-
"@codelia/config-loader": "0.1.
|
|
34
|
-
"@codelia/core": "0.1.
|
|
35
|
-
"@codelia/logger": "0.1.
|
|
36
|
-
"@codelia/model-metadata": "0.1.
|
|
37
|
-
"@codelia/protocol": "0.1.
|
|
38
|
-
"@codelia/shared-types": "0.1.
|
|
39
|
-
"@codelia/storage": "0.1.
|
|
32
|
+
"@codelia/config": "0.1.93",
|
|
33
|
+
"@codelia/config-loader": "0.1.93",
|
|
34
|
+
"@codelia/core": "0.1.93",
|
|
35
|
+
"@codelia/logger": "0.1.93",
|
|
36
|
+
"@codelia/model-metadata": "0.1.93",
|
|
37
|
+
"@codelia/protocol": "0.1.93",
|
|
38
|
+
"@codelia/shared-types": "0.1.93",
|
|
39
|
+
"@codelia/storage": "0.1.93",
|
|
40
40
|
"@google/genai": "2.32.0",
|
|
41
41
|
"eventsource-parser": "^3.0.6",
|
|
42
42
|
"image-size": "^2.0.2",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"zod": "^4.3.5"
|
|
45
45
|
},
|
|
46
46
|
"optionalDependencies": {
|
|
47
|
-
"@codelia/tui-darwin-arm64": "0.1.
|
|
48
|
-
"@codelia/tui-linux-arm64": "0.1.
|
|
49
|
-
"@codelia/tui-linux-x64": "0.1.
|
|
47
|
+
"@codelia/tui-darwin-arm64": "0.1.93",
|
|
48
|
+
"@codelia/tui-linux-arm64": "0.1.93",
|
|
49
|
+
"@codelia/tui-linux-x64": "0.1.93"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|