@lark-codem/codem-cli 0.1.279-dev.100104396969.0.g5dfd2fe → 0.1.279-dev.100104426629.0.g15d5eaa

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/bin/tt-env.js CHANGED
@@ -58,7 +58,7 @@ export function resolveTtEnvLane(env = process.env) {
58
58
  return parseTtEnvLane(env?.[CODEM_X_TT_ENV]);
59
59
  }
60
60
 
61
- function isOfficialCodemHost(hostname) {
61
+ export function isOfficialCodemHost(hostname) {
62
62
  const host = hostname.toLowerCase();
63
63
  return host === PROD_ROUTER_HOST || host === BOE_ROUTER_HOST;
64
64
  }
@@ -34,7 +34,8 @@ export function workerRuntimeTelemetryTarget({env=process.env,args=process.argv.
34
34
  if (!['http:','https:'].includes(url.protocol) || url.username || url.password) return null;
35
35
  url.pathname=`${url.pathname.replace(/\/+$/,'') || '/goapi/codem'}/sandbox/telemetry/workflow_metrics`;
36
36
  url.search='';url.hash='';
37
- return {url,headers:{'Content-Type':'application/json',Authorization:`Bearer sandbox_${env.CODEM_TOKEN}`,...ttEnvHeadersFor(url,env)}};
37
+ const bearer=env.CODEM_TOKEN.startsWith('codem_resource.')?env.CODEM_TOKEN:`sandbox_${env.CODEM_TOKEN}`;
38
+ return {url,headers:{'Content-Type':'application/json',Authorization:`Bearer ${bearer}`,...ttEnvHeadersFor(url,env)}};
38
39
  }
39
40
 
40
41
  export async function reportWorkerRuntime(runtime,{env=process.env,args=process.argv.slice(2),signal,timeoutMS=750}={}) {
package/package.json CHANGED
@@ -1,14 +1,16 @@
1
1
  {
2
2
  "name": "@lark-codem/codem-cli",
3
- "version": "0.1.279-dev.100104396969.0.g5dfd2fe",
3
+ "version": "0.1.279-dev.100104426629.0.g15d5eaa",
4
4
  "codemServiceManagementProtocol": 3,
5
5
  "codemProfileProtocol": 1,
6
+ "codemAuthProtocol": 1,
6
7
  "type": "module",
7
8
  "description": "CodeM local CLI for Feishu-driven coding sessions",
8
9
  "license": "SEE LICENSE IN LICENSE",
9
10
  "files": [
10
11
  "bin",
11
12
  "profile",
13
+ "auth",
12
14
  "LICENSE"
13
15
  ],
14
16
  "os": [
@@ -29,17 +31,17 @@
29
31
  "access": "public"
30
32
  },
31
33
  "dependencies": {
32
- "@lark-codem/codem-core": "0.8.96-dev.100104396969.0.g1b41401",
34
+ "@lark-codem/codem-core": "0.8.96-dev.100104426629.0.gaf9fb25",
33
35
  "zod": "3.25.76",
34
- "@lark-codem/lark-cli": "0.1.5"
36
+ "@lark-codem/lark-cli": "0.1.3"
35
37
  },
36
38
  "optionalDependencies": {
37
- "@lark-codem/codem-cli-darwin-arm64": "0.1.279-dev.100104396969.0.g5dfd2fe",
38
- "@lark-codem/codem-cli-darwin-x64": "0.1.279-dev.100104396969.0.g5dfd2fe",
39
- "@lark-codem/codem-cli-linux-arm64": "0.1.279-dev.100104396969.0.g5dfd2fe",
40
- "@lark-codem/codem-cli-linux-x64": "0.1.279-dev.100104396969.0.g5dfd2fe",
41
- "@lark-codem/codem-cli-win32-arm64": "0.1.279-dev.100104396969.0.g5dfd2fe",
42
- "@lark-codem/codem-cli-win32-x64": "0.1.279-dev.100104396969.0.g5dfd2fe"
39
+ "@lark-codem/codem-cli-darwin-arm64": "0.1.279-dev.100104426629.0.g15d5eaa",
40
+ "@lark-codem/codem-cli-darwin-x64": "0.1.279-dev.100104426629.0.g15d5eaa",
41
+ "@lark-codem/codem-cli-linux-arm64": "0.1.279-dev.100104426629.0.g15d5eaa",
42
+ "@lark-codem/codem-cli-linux-x64": "0.1.279-dev.100104426629.0.g15d5eaa",
43
+ "@lark-codem/codem-cli-win32-arm64": "0.1.279-dev.100104426629.0.g15d5eaa",
44
+ "@lark-codem/codem-cli-win32-x64": "0.1.279-dev.100104426629.0.g15d5eaa"
43
45
  },
44
46
  "engines": {
45
47
  "node": ">=18"
@@ -31,7 +31,6 @@ export class CredentialStorageError extends Error {
31
31
  export function isRecoverableCredentialState(error) {
32
32
  return error?.code === "credential_storage_rotation_pending"
33
33
  || error?.code === "credential_storage_rotation_unknown"
34
- // A missing OAuth record permits reauthorization with the existing device,
35
- // never use of its stale plaintext mirror or another credential kind.
34
+ // Missing OAuth can reauthorize the existing device, never another kind.
36
35
  || (error?.code === "credential_storage_missing" && error.kind === "oauth");
37
36
  }
@@ -44,7 +44,8 @@ export async function readProfileSnapshot(home) {
44
44
  return withCodeMConfigLock(join(home, "config.json"), () => readLockedProfileSnapshot(home));
45
45
  }
46
46
 
47
- async function readLockedProfileSnapshot(home) {
47
+ // Internal callers must already hold the canonical profile config lock.
48
+ export async function readLockedProfileSnapshot(home) {
48
49
  const configPath = join(home, "config.json");
49
50
  const config = await readProfileObject(configPath);
50
51
  let metadata;
@@ -0,0 +1,9 @@
1
+ // Base bounds the JSON encoding of RPC IDs at 1024 bytes. Printable route
2
+ // keys include Go QueryEscape's percent escapes and plus sign. Only record
3
+ // identifier characters; never truncate two different IDs to the same value.
4
+ export function realtimeLogID(value) {
5
+ if (Number.isSafeInteger(value)) return value;
6
+ if (typeof value === "string" && value.length <= 1022 &&
7
+ /^[\p{L}\p{N}_.:%~+-]+$/u.test(value) && Buffer.byteLength(value) <= 1022) return value;
8
+ return undefined;
9
+ }
@@ -1,3 +1,4 @@
1
+ import { realtimeLogID } from "./realtime-log-id.js";
1
2
  import { workerRuntimeAttributes } from "./worker-runtime-observation.js";
2
3
  import { createHash, randomUUID } from "node:crypto";
3
4
  import os from "node:os";
@@ -78,26 +79,46 @@ const OBSERVATION_METRICS = {
78
79
  };
79
80
  const EXTRA_FIELDS = ["observation_id", "runtime_client_instance_id", "command_id", "delivery_id", "probe_id", "sync_id", "transport_request_id", "attempt_id"];
80
81
  const LIFECYCLE_EXTRA_FIELDS = [...EXTRA_FIELDS, "process_instance_id", "startup_id", "request_id", "event_id"];
82
+ const UPLINK_BATCH_METRICS = [
83
+ "message_count", "packet_bytes", "queue_wait_ms", "encode_ms", "ack_wait_ms",
84
+ "batch_sequence", "pending_count", "pending_bytes"
85
+ ];
86
+ const UPLINK_DIAGNOSTIC_METRICS = new Map([
87
+ ["uplink_queue_pressure", ["pending_count", "pending_bytes", "oldest_age_ms", "full_count", "batch_sequence", "ack_wait_ms"]],
88
+ ["event_handoff_failed", UPLINK_BATCH_METRICS],
89
+ ["uplink_batch_slow", UPLINK_BATCH_METRICS]
90
+ ]);
81
91
  const STRING_FIELDS = new Set([
82
- ...EXTRA_FIELDS, "command_type", "ack_status", "ack_outcome", "readback_scope", "timing_origin", "required_capability",
83
- "request_id", "command_id", "session_id", "task_id", "dispatch_id", "event_id", "sync_id",
92
+ "request_id", "command_id", "session_id", "task_id", "dispatch_id", "event_id", "sync_id", "attempt_id",
93
+ "failure_stage", "first_route_id", "first_method", "first_reason", "late_outcome", "ipc_request_id",
94
+ "lane", "target_kind", "frontier_did", "packet_kind", "packet_traceparent",
84
95
  "process_instance_id", "run_id", "stage", "phase", "status", "outcome", "reason", "action",
85
96
  "error_class", "error_code", "error_kind", "error_type", "code", "signal", "stop_reason",
86
97
  "first_error", "retry_source", "cleanup_result",
87
98
  "terminal_event", "event_type", "actor_type", "source", "trigger", "hook_id", "hook_event",
88
99
  "target_version", "cli_version", "core_version", "version", "previous_state", "state",
89
100
  "failure_kind", "failure_impact", "failure_type", "failure_subtype", "failure_code", "failure_status", "delay_source", "mode", "provider", "name", "termination", "interaction_id", "interaction_kind", "owner_state", "artifact_id", "resource_type", "delivery_mode", "host", "scheme", "tool_call_id", "tool_name", "background_task_id", "model", "artifact_kind", "codem_user_id", "device_id", "operation", "foreground_error_code",
90
- "operation_id", "entrypoint", "workflow_launch_id"
101
+ "operation_id", "entrypoint", "workflow_launch_id", "runtime_client_instance_id", "connection_instance_id", "lease_epoch",
102
+ "load_id", "refresh_id", "registry_snapshot_id", "capability_key", "capability_type",
103
+ "component_type", "publisher_type", "capability_source", "installation_mode",
104
+ "capability_version", "project_key", "business_scene", "invocation_id", "result",
105
+ "error_category", "runtime_scope", "refresh_trigger", "load_trigger", "stage_name",
106
+ "operation_name", "invocation_source", "binding_state", "load_result"
91
107
  ]);
92
108
  const VALUE_FIELDS = new Set([
93
109
  "session_retained", "lease_valid_until_ms", "requested_valid_until_ms", "lease_remaining_ms", "wall_remaining_ms",
110
+ "local_rpc_id", "batch_index", "rpc_error_code", "has_subscribers", "window_active",
94
111
  ...new Set(Object.values(OBSERVATION_METRICS).flat()),
95
112
  "pid", "exit_code", "duration_ms", "elapsed_ms", "wait_ms", "run_ms", "total_ms", "took_ms",
96
113
  "attempt", "attempts", "attempt_count", "retryable", "http_status", "errno", "active_task_count",
97
114
  "pending_event_count", "pending_command_ack_count", "next_retry_ms", "consecutive_failures",
115
+ ...Array.from(UPLINK_DIAGNOSTIC_METRICS.values()).flat(), "transport_open",
98
116
  "outage_duration_ms", "startup_duration_ms", "failed_attempts", "active_runs", "completed",
99
117
  "delivered", "result_delivered", "queued_behind_existing", "expected", "timed_out",
100
118
  "force_exit_ms", "teardown_ceiling_ms", "recovered", "count", "ms_since_process_start", "owner_pid", "consumed", "delivery_attempt", "ack_deadline_ms", "command_to_bridge_ms", "size_bytes", "source_size_bytes", "processed_bytes", "before", "after", "omitted_detail_count", "opened", "selected", "foreground",
119
+ "expected_count", "loaded_count", "loaded_capability_count", "failed_count", "skipped_count", "ready_count", "downloaded_count", "turn_id", "turn_index",
120
+ "late_rpc_error_code", "lifecycle_wait_ms", "prepare_ms", "router_cred_ms", "meegle_init_ms", "spawn_init_ms", "budget_ms",
121
+ "oauth_ms", "project_list_ms", "config_total_ms", "write_total_ms",
101
122
  ...LIFECYCLE_METRICS
102
123
  ]);
103
124
 
@@ -115,7 +136,7 @@ function optional(read) {
115
136
  }
116
137
 
117
138
  function metricProjection(event, fields = {}) {
118
- return { count: 1, ...Object.fromEntries((OBSERVATION_METRICS[event] ?? [])
139
+ return { count: 1, ...Object.fromEntries((OBSERVATION_METRICS[event] ?? UPLINK_DIAGNOSTIC_METRICS.get(event) ?? [])
119
140
  .filter(key => typeof fields?.[key] === "number" && Number.isFinite(fields[key]) && fields[key] >= 0)
120
141
  .map(key => [key, fields[key]])) };
121
142
  }
@@ -124,11 +145,18 @@ function extraProjection(fields = {}) {
124
145
  return Object.fromEntries(EXTRA_FIELDS.filter(key => token(fields?.[key])).map(key => [key, token(fields[key])]));
125
146
  }
126
147
 
127
- function projectFields(input, fingerprintErrors = true) {
148
+ const REALTIME_IDS = new Set(["route_id", "question_id", "thread_id", "turn_id", "session_id", "event_id"]);
149
+
150
+ function projectFields(input, fingerprintErrors = true, component) {
128
151
  const result = {};
129
152
  for (const [key, value] of Object.entries(input ?? {}).slice(0, 100)) {
130
153
  const name = fieldName(key);
131
- if (STRING_FIELDS.has(name)) {
154
+ if (name === "method" && typeof value === "string" && /^[a-z][a-z\d_.]*(?:\/[a-z][a-z\d_.]*){0,7}$/iu.test(value) && value.length <= 80) {
155
+ result[name] = value;
156
+ } else if (component === "realtime" && REALTIME_IDS.has(name)) {
157
+ const id = realtimeLogID(value);
158
+ if (id !== undefined) result[name] = id;
159
+ } else if (STRING_FIELDS.has(name)) {
132
160
  const safe = token(value);
133
161
  if (safe) result[name] = safe;
134
162
  } else if (VALUE_FIELDS.has(name) && (typeof value === "boolean" || (typeof value === "number" && Number.isFinite(value)))) {
@@ -179,7 +207,92 @@ function lifecycleErrorCode(fields) {
179
207
  return fields.outcome === "failed" || fields.outcome === "rejected" || fields.outcome === "conflicting" ? "unknown" : undefined;
180
208
  }
181
209
 
210
+ const REALTIME_LOG_ONLY = new Set([
211
+ "app_server_rpc", "app_server_rpc_unmatched", "app_server_rpc_late_reply", "app_server_host_attached",
212
+ "app_server_host_failed", "app_server_host_reused_failed", "app_server_host_prepare", "artifact_operation_failed",
213
+ "app_server_resume_binding_failed", "app_server_question", "hitl_answer",
214
+ "downlink_admission", "rpc_reply", "uplink_commit", "uplink_transport", "subscription_query", "runtime_lease"
215
+ ]);
216
+
217
+ const LOCAL_SENSITIVE_KEY = /^(?:oauth|authorization|token|secret|password|apikey|api_key|ak|access_key|secret_key|refresh_token|access_token|user_access_token|uat|rt|device_secret|device_secret_plaintext)$/iu;
218
+
219
+ const defaultRealtimeSink = {
220
+ info(line) {
221
+ const out = console;
222
+ out.info(line);
223
+ },
224
+ warn(line) {
225
+ const out = console;
226
+ out.warn(line);
227
+ },
228
+ error(line) {
229
+ const out = console;
230
+ out.error(line);
231
+ }
232
+ };
233
+
234
+ function serializeLocalValue(value, depth = 0) {
235
+ if (value === null || value === undefined) return undefined;
236
+ if (typeof value === "string") return value.length > 1024 ? `${value.slice(0, 1021)}...` : value;
237
+ if (typeof value === "number") return Number.isFinite(value) ? value : undefined;
238
+ if (typeof value === "boolean") return value;
239
+ if (value instanceof Error) {
240
+ const summary = {
241
+ error_type: value.name || "Error",
242
+ error_message: typeof value.message === "string" ? value.message.slice(0, 1024) : ""
243
+ };
244
+ if (value.code !== undefined) summary.error_code = String(value.code).slice(0, 128);
245
+ if (value.errno !== undefined) summary.errno = value.errno;
246
+ if (value.rpcError?.code !== undefined) summary.rpc_error_code = value.rpcError.code;
247
+ return summary;
248
+ }
249
+ if (depth >= 3) return undefined;
250
+ if (Array.isArray(value)) {
251
+ return value.slice(0, 32).map(entry => serializeLocalValue(entry, depth + 1)).filter(entry => entry !== undefined);
252
+ }
253
+ if (typeof value === "object") {
254
+ const out = {};
255
+ for (const [key, entry] of Object.entries(value)) {
256
+ if (entry === undefined || LOCAL_SENSITIVE_KEY.test(key)) continue;
257
+ const serialized = serializeLocalValue(entry, depth + 1);
258
+ if (serialized !== undefined) out[key] = serialized;
259
+ }
260
+ return out;
261
+ }
262
+ return undefined;
263
+ }
264
+
265
+ export function writeLocalRealtimeLog(level, event, fields = {}, { logger } = {}) {
266
+ try {
267
+ if (logger === null) return;
268
+ if (!logger && process.env.NODE_TEST_CONTEXT && process.env.CODEM_REALTIME_LOCAL_LOG !== "1") return;
269
+ const sink = logger ?? defaultRealtimeSink;
270
+ const payload = serializeLocalValue(fields) ?? {};
271
+ const line = `[codem][realtime][${event}] ${JSON.stringify(payload)}`;
272
+ if (level === "info") {
273
+ sink.info?.(line);
274
+ } else if (level === "error" || level === "fatal") {
275
+ (sink.error ?? sink.warn)?.call(sink, line);
276
+ } else {
277
+ sink.warn?.(line);
278
+ }
279
+ } catch { /* Local diagnostics must never affect business execution. */ }
280
+ }
281
+
282
+ export function writeLocalCoreStderr(pid, rawLine, { logger } = {}) {
283
+ try {
284
+ if (logger === null) return;
285
+ if (!logger && process.env.NODE_TEST_CONTEXT && process.env.CODEM_REALTIME_LOCAL_LOG !== "1") return;
286
+ const trimmed = String(rawLine ?? "").trim();
287
+ if (!trimmed) return;
288
+ const safe = trimmed.length > 2048 ? `${trimmed.slice(0, 2045)}...` : trimmed;
289
+ const sink = logger ?? defaultRealtimeSink;
290
+ sink.warn?.(`[codem][core-stderr][pid=${pid ?? "unknown"}] ${safe}`);
291
+ } catch { /* Forwarding child stderr must never fail the host. */ }
292
+ }
293
+
182
294
  function keepLegacyMetric(event, fields, role, severity) {
295
+ if (REALTIME_LOG_ONLY.has(event)) return false;
183
296
  if (/^startup\.(?:main|update_check|daemon_service_reconcile|login_gate|login_handoff_to_linco)$/u.test(event) && severity === "info") return false;
184
297
  if (/(?:^|\.)drain_(?:started|completed)$/u.test(event) && severity === "info") return false;
185
298
  if (role === "daemon" && event === "runtime_capability_probe" && severity === "info") return false;
@@ -316,7 +429,35 @@ export class RuntimeLogReporter {
316
429
 
317
430
  get pendingCount() { return this.#live.queue.length + this.#replay.queue.length; }
318
431
  get droppedCount() { return this.#dropped; }
319
- get identityKey() { return JSON.stringify([this.#instanceId, this.#role, this.#identity.deviceId, this.#identity.userId, this.#identity.tenantId]); }
432
+
433
+ #header() {
434
+ const identity = this.#identity;
435
+ return { aid: SLARDAR_PC_AID, device_id: identity.deviceId ?? this.#instanceId,
436
+ user_id: identity.userId ?? "0", parfait_version: SLARDAR_PC_REPORTER_VERSION,
437
+ channel: identity.channel ?? "unknown", os: this.#platform, os_version: this.#osVersion };
438
+ }
439
+
440
+ recordMetric(name, category, metrics) {
441
+ if (this.#closed) return false;
442
+ if (this.#live.queue.length >= CAPACITY) {
443
+ this.#dropped += 1;
444
+ return false;
445
+ }
446
+ const identity = this.#identity;
447
+ const record = {
448
+ app_version: this.#version, app_minor_version: "", build_id: "",
449
+ process_type: `codem-${this.#role}`, session_id: "", timestamp: Date.now(),
450
+ log_type: "flexible", event_name: name,
451
+ category: { reporter: "codem_js", runtime_role: this.#role,
452
+ ...(identity.tenantId ? { tenant_id: identity.tenantId } : {}), ...category },
453
+ metrics
454
+ };
455
+ this.#live.queue.push({ header: this.#header(), record, metricName: null, attempts: 0 });
456
+ // Bursts need not wait for the periodic timer, and a slow collector still
457
+ // has only one bounded in-flight upload.
458
+ if (this.#live.queue.length >= BATCH_SIZE) void this.#flushLane(this.#live, REQUEST_TIMEOUT_MS);
459
+ return true;
460
+ }
320
461
 
321
462
  record(level, component, event, fields = {}) {
322
463
  try {
@@ -327,13 +468,17 @@ export class RuntimeLogReporter {
327
468
 
328
469
  #logEntry(level, component, event, fields) {
329
470
  let safeFields;
330
- try { safeFields = projectFields(fields); } catch { safeFields = {}; }
471
+ try { safeFields = projectFields(fields, true, component); } catch { safeFields = {}; }
331
472
  if (OBSERVATION_EVENTS.has(event)) safeFields.observation_id = randomUUID();
332
473
  const severity = ["info", "warn", "error", "fatal"].includes(level) ? level : "info";
333
474
  // Keep arbitrary upstream error codes out of trusted-device metric dimensions.
334
475
  const trustedDevice = TRUSTED_DEVICE_EVENTS.has(event);
335
476
  const dimensions = trustedDevice ? {} : Object.fromEntries(["stage", "error_class", "error_code", "error_kind", "outcome"]
336
477
  .filter(key => safeFields[key]).map(key => [key, safeFields[key]]));
478
+ if (UPLINK_DIAGNOSTIC_METRICS.has(event)) {
479
+ if (safeFields.lane) dimensions.lane = safeFields.lane;
480
+ if (safeFields.target_kind) dimensions.target_kind = safeFields.target_kind;
481
+ }
337
482
  if (OBSERVATION_EVENTS.has(event)) {
338
483
  for (const [key, values] of Object.entries(trustedDevice ? TRUSTED_DEVICE_DIMENSIONS : OBSERVATION_DIMENSIONS)) {
339
484
  if (safeFields[key]) dimensions[key] = values.includes(safeFields[key]) ? safeFields[key] : "unknown";
@@ -593,6 +738,10 @@ export function flushRuntimeLogsInBackground() {
593
738
  if (active) setImmediate(() => { void active?.flush().catch(() => {}); }).unref?.();
594
739
  }
595
740
 
741
+ export function recordRuntimeMetric(name, category, metrics) {
742
+ try { return active?.recordMetric(name, category, metrics) ?? false; } catch { return false; }
743
+ }
744
+
596
745
  export function persistRuntimeCrash(component, event, fields) {
597
746
  try { active?.persistCrash(component, event, fields); } catch { /* best effort */ }
598
747
  }
@@ -652,9 +801,9 @@ export function recordInteractiveProcessExit({ exitCode, signal }) {
652
801
  export function recordSelectedRuntimeLog(component, event, fields = {}) {
653
802
  try {
654
803
  const selectedEvent = event.replace(/^linco\./u, "");
655
- if (!/^(?:startup\.(?:main|update_check|daemon_service_reconcile|login_gate|login_handoff_to_linco)|oauth\.refresh\.(?:relogin_suspect|persist_failed|persisted)|managed_config\.(?:member_refresh_failed|sandbox_refresh_failed|sandbox_fetch_recovered|sandbox_fetch_exhausted|refreshed|resource_failed)|(?:agent|command)\.(?:start|interactive_start|success|error|spawn_error|resolve_error|exit_drain_timeout|cancelled_before_spawn|artifact_oversize|artifact_missing|artifact_dropped|artifact_route_selected|artifact_image_upload|artifact_file_upload|artifact_local_register)|router\.credentials\.(?:ensured|refresh_failed)|config-lock\.release_failed|binary\.heal_chmod_failed|project\.(?:inject_error|state)|(?:permission_ask|user_question|plan)\.report_failed|process_tree\.(?:force_kill|force_kill_failed)|artifact\.(?:oversize|missing|dropped)|runtime_post\.daemon\.device_rebind_[a-z_]+)$/u.test(selectedEvent)) return;
804
+ if (!/^(?:startup\.(?:main|update_check|daemon_service_reconcile|login_gate|login_handoff_to_linco)|oauth\.refresh\.(?:relogin_suspect|persist_failed|persisted)|managed_config\.(?:member_refresh_failed|sandbox_refresh_failed|sandbox_fetch_recovered|sandbox_fetch_exhausted|refreshed|resource_failed)|capability\.(?:load\.lifecycle|operation|resource\.lifecycle|runtime\.timing|registry\.(?:snapshot|binding)|invocation|skill\.activation)|(?:agent|command)\.(?:start|interactive_start|success|error|spawn_error|resolve_error|exit_drain_timeout|cancelled_before_spawn|artifact_oversize|artifact_missing|artifact_dropped|artifact_route_selected|artifact_image_upload|artifact_file_upload|artifact_local_register)|router\.credentials\.(?:ensured|refresh_failed)|config-lock\.release_failed|binary\.heal_chmod_failed|project\.(?:inject_error|state)|(?:permission_ask|user_question|plan)\.report_failed|process_tree\.(?:force_kill|force_kill_failed)|artifact\.(?:oversize|missing|dropped)|runtime_post\.daemon\.device_rebind_[a-z_]+)$/u.test(selectedEvent)) return;
656
805
  const expected = optional(() => fields?.errorKind === "user_stop" || fields?.terminalError?.kind === "user_stop" || fields?.exitCode === 130 || fields?.signal === "SIGINT");
657
- const level = expected ? "info" : (fields?.status === "failed" || /(?:failed|error|exhausted|timeout)$/u.test(event)) ? "error" : /(?:suspect|dropped|missing|oversize)$/u.test(event) ? "warn" : "info";
806
+ const level = expected ? "info" : (fields?.status === "failed" || ["failed", "timeout"].includes(fields?.result) || /(?:failed|error|exhausted|timeout)$/u.test(event)) ? "error" : /(?:suspect|dropped|missing|oversize)$/u.test(event) ? "warn" : "info";
658
807
  recordRuntimeLog(level, component, event, fields);
659
808
  } catch { /* best effort */ }
660
809
  }