@lark-codem/codem-cli 0.1.281-dev.100104534209.0.gf5d08a3 → 0.1.281-dev.100104544976.0.ga915b98

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
- export function isOfficialCodemHost(hostname) {
61
+ function isOfficialCodemHost(hostname) {
62
62
  const host = hostname.toLowerCase();
63
63
  return host === PROD_ROUTER_HOST || host === BOE_ROUTER_HOST;
64
64
  }
@@ -34,8 +34,7 @@ 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
- 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)}};
37
+ return {url,headers:{'Content-Type':'application/json',Authorization:`Bearer sandbox_${env.CODEM_TOKEN}`,...ttEnvHeadersFor(url,env)}};
39
38
  }
40
39
 
41
40
  export async function reportWorkerRuntime(runtime,{env=process.env,args=process.argv.slice(2),signal,timeoutMS=750}={}) {
package/package.json CHANGED
@@ -1,16 +1,14 @@
1
1
  {
2
2
  "name": "@lark-codem/codem-cli",
3
- "version": "0.1.281-dev.100104534209.0.gf5d08a3",
3
+ "version": "0.1.281-dev.100104544976.0.ga915b98",
4
4
  "codemServiceManagementProtocol": 3,
5
5
  "codemProfileProtocol": 1,
6
- "codemAuthProtocol": 1,
7
6
  "type": "module",
8
7
  "description": "CodeM local CLI for Feishu-driven coding sessions",
9
8
  "license": "SEE LICENSE IN LICENSE",
10
9
  "files": [
11
10
  "bin",
12
11
  "profile",
13
- "auth",
14
12
  "LICENSE"
15
13
  ],
16
14
  "os": [
@@ -31,17 +29,17 @@
31
29
  "access": "public"
32
30
  },
33
31
  "dependencies": {
34
- "@lark-codem/codem-core": "0.8.98-dev.100104534209.0.g58a8322",
32
+ "@lark-codem/codem-core": "0.8.98-dev.100104544976.0.g41b6fb5",
35
33
  "zod": "3.25.76",
36
- "@lark-codem/lark-cli": "0.1.3"
34
+ "@lark-codem/lark-cli": "0.1.5"
37
35
  },
38
36
  "optionalDependencies": {
39
- "@lark-codem/codem-cli-darwin-arm64": "0.1.281-dev.100104534209.0.gf5d08a3",
40
- "@lark-codem/codem-cli-darwin-x64": "0.1.281-dev.100104534209.0.gf5d08a3",
41
- "@lark-codem/codem-cli-linux-arm64": "0.1.281-dev.100104534209.0.gf5d08a3",
42
- "@lark-codem/codem-cli-linux-x64": "0.1.281-dev.100104534209.0.gf5d08a3",
43
- "@lark-codem/codem-cli-win32-arm64": "0.1.281-dev.100104534209.0.gf5d08a3",
44
- "@lark-codem/codem-cli-win32-x64": "0.1.281-dev.100104534209.0.gf5d08a3"
37
+ "@lark-codem/codem-cli-darwin-arm64": "0.1.281-dev.100104544976.0.ga915b98",
38
+ "@lark-codem/codem-cli-darwin-x64": "0.1.281-dev.100104544976.0.ga915b98",
39
+ "@lark-codem/codem-cli-linux-arm64": "0.1.281-dev.100104544976.0.ga915b98",
40
+ "@lark-codem/codem-cli-linux-x64": "0.1.281-dev.100104544976.0.ga915b98",
41
+ "@lark-codem/codem-cli-win32-arm64": "0.1.281-dev.100104544976.0.ga915b98",
42
+ "@lark-codem/codem-cli-win32-x64": "0.1.281-dev.100104544976.0.ga915b98"
45
43
  },
46
44
  "engines": {
47
45
  "node": ">=18"
@@ -31,6 +31,7 @@ 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
- // Missing OAuth can reauthorize the existing device, never another kind.
34
+ // A missing OAuth record permits reauthorization with the existing device,
35
+ // never use of its stale plaintext mirror or another credential kind.
35
36
  || (error?.code === "credential_storage_missing" && error.kind === "oauth");
36
37
  }
@@ -44,8 +44,7 @@ export async function readProfileSnapshot(home) {
44
44
  return withCodeMConfigLock(join(home, "config.json"), () => readLockedProfileSnapshot(home));
45
45
  }
46
46
 
47
- // Internal callers must already hold the canonical profile config lock.
48
- export async function readLockedProfileSnapshot(home) {
47
+ async function readLockedProfileSnapshot(home) {
49
48
  const configPath = join(home, "config.json");
50
49
  const config = await readProfileObject(configPath);
51
50
  let metadata;
@@ -1,5 +1,3 @@
1
- import { realtimeLogID } from "./realtime-log-id.js";
2
- import { sandboxObservationContext, sandboxLogUploadAllowed } from "./sandbox-observability.js";
3
1
  import { workerRuntimeAttributes } from "./worker-runtime-observation.js";
4
2
  import { createHash, randomUUID } from "node:crypto";
5
3
  import os from "node:os";
@@ -65,6 +63,7 @@ const OBSERVATION_DIMENSIONS = {
65
63
  timing_origin: ["observed", "restored_unknown"]
66
64
  };
67
65
  const OBSERVATION_METRICS = {
66
+ history_recall: ["duration_ms", "hit_count", "message_count", "output_tokens_upper_bound"],
68
67
  host_identity_collection: ["duration_ms", "field_error_count"],
69
68
  host_identity_command: ["duration_ms", "timeout_ms"],
70
69
  host_session_attempt: ["elapsed_ms", "next_retry_ms", "consecutive_failures", "session_remaining_ms", ...TRUSTED_DEVICE_PHASES.map(phase => `${phase}_duration_ms`)],
@@ -80,46 +79,27 @@ const OBSERVATION_METRICS = {
80
79
  };
81
80
  const EXTRA_FIELDS = ["observation_id", "runtime_client_instance_id", "command_id", "delivery_id", "probe_id", "sync_id", "transport_request_id", "attempt_id"];
82
81
  const LIFECYCLE_EXTRA_FIELDS = [...EXTRA_FIELDS, "process_instance_id", "startup_id", "request_id", "event_id"];
83
- const UPLINK_BATCH_METRICS = [
84
- "message_count", "packet_bytes", "queue_wait_ms", "encode_ms", "ack_wait_ms",
85
- "batch_sequence", "pending_count", "pending_bytes"
86
- ];
87
- const UPLINK_DIAGNOSTIC_METRICS = new Map([
88
- ["uplink_queue_pressure", ["pending_count", "pending_bytes", "oldest_age_ms", "full_count", "batch_sequence", "ack_wait_ms"]],
89
- ["event_handoff_failed", UPLINK_BATCH_METRICS],
90
- ["uplink_batch_slow", UPLINK_BATCH_METRICS]
91
- ]);
92
82
  const STRING_FIELDS = new Set([
93
- "resource_id", "resource_env", "request_id", "command_id", "session_id", "task_id", "dispatch_id", "event_id", "sync_id", "attempt_id",
94
- "failure_stage", "first_route_id", "first_method", "first_reason", "late_outcome", "ipc_request_id",
95
- "lane", "target_kind", "frontier_did", "packet_kind", "packet_traceparent",
83
+ ...EXTRA_FIELDS, "command_type", "ack_status", "ack_outcome", "readback_scope", "timing_origin", "required_capability",
84
+ "request_id", "command_id", "session_id", "task_id", "dispatch_id", "event_id", "sync_id",
96
85
  "process_instance_id", "run_id", "stage", "phase", "status", "outcome", "reason", "action",
97
86
  "error_class", "error_code", "error_kind", "error_type", "code", "signal", "stop_reason",
98
87
  "first_error", "retry_source", "cleanup_result",
99
88
  "terminal_event", "event_type", "actor_type", "source", "trigger", "hook_id", "hook_event",
100
89
  "target_version", "cli_version", "core_version", "version", "previous_state", "state",
101
90
  "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",
102
- "operation_id", "entrypoint", "workflow_launch_id", "runtime_client_instance_id", "connection_instance_id", "lease_epoch",
103
- "load_id", "refresh_id", "registry_snapshot_id", "capability_key", "capability_type",
104
- "component_type", "publisher_type", "capability_source", "installation_mode",
105
- "capability_version", "project_key", "business_scene", "invocation_id", "result",
106
- "error_category", "runtime_scope", "refresh_trigger", "load_trigger", "stage_name",
107
- "operation_name", "invocation_source", "binding_state", "load_result"
91
+ "operation_id", "entrypoint", "workflow_launch_id"
108
92
  ]);
109
93
  const VALUE_FIELDS = new Set([
94
+ "truncated",
110
95
  "session_retained", "lease_valid_until_ms", "requested_valid_until_ms", "lease_remaining_ms", "wall_remaining_ms",
111
- "local_rpc_id", "batch_index", "rpc_error_code", "has_subscribers", "window_active",
112
96
  ...new Set(Object.values(OBSERVATION_METRICS).flat()),
113
97
  "pid", "exit_code", "duration_ms", "elapsed_ms", "wait_ms", "run_ms", "total_ms", "took_ms",
114
98
  "attempt", "attempts", "attempt_count", "retryable", "http_status", "errno", "active_task_count",
115
99
  "pending_event_count", "pending_command_ack_count", "next_retry_ms", "consecutive_failures",
116
- ...Array.from(UPLINK_DIAGNOSTIC_METRICS.values()).flat(), "transport_open",
117
100
  "outage_duration_ms", "startup_duration_ms", "failed_attempts", "active_runs", "completed",
118
101
  "delivered", "result_delivered", "queued_behind_existing", "expected", "timed_out",
119
102
  "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",
120
- "expected_count", "loaded_count", "loaded_capability_count", "failed_count", "skipped_count", "ready_count", "downloaded_count", "turn_id", "turn_index",
121
- "late_rpc_error_code", "lifecycle_wait_ms", "prepare_ms", "router_cred_ms", "meegle_init_ms", "spawn_init_ms", "budget_ms",
122
- "oauth_ms", "project_list_ms", "config_total_ms", "write_total_ms",
123
103
  ...LIFECYCLE_METRICS
124
104
  ]);
125
105
 
@@ -137,7 +117,7 @@ function optional(read) {
137
117
  }
138
118
 
139
119
  function metricProjection(event, fields = {}) {
140
- return { count: 1, ...Object.fromEntries((OBSERVATION_METRICS[event] ?? UPLINK_DIAGNOSTIC_METRICS.get(event) ?? [])
120
+ return { count: 1, ...Object.fromEntries((OBSERVATION_METRICS[event] ?? [])
141
121
  .filter(key => typeof fields?.[key] === "number" && Number.isFinite(fields[key]) && fields[key] >= 0)
142
122
  .map(key => [key, fields[key]])) };
143
123
  }
@@ -146,18 +126,11 @@ function extraProjection(fields = {}) {
146
126
  return Object.fromEntries(EXTRA_FIELDS.filter(key => token(fields?.[key])).map(key => [key, token(fields[key])]));
147
127
  }
148
128
 
149
- const REALTIME_IDS = new Set(["route_id", "question_id", "thread_id", "turn_id", "session_id", "event_id"]);
150
-
151
- function projectFields(input, fingerprintErrors = true, component) {
129
+ function projectFields(input, fingerprintErrors = true) {
152
130
  const result = {};
153
131
  for (const [key, value] of Object.entries(input ?? {}).slice(0, 100)) {
154
132
  const name = fieldName(key);
155
- if (name === "method" && typeof value === "string" && /^[a-z][a-z\d_.]*(?:\/[a-z][a-z\d_.]*){0,7}$/iu.test(value) && value.length <= 80) {
156
- result[name] = value;
157
- } else if (component === "realtime" && REALTIME_IDS.has(name)) {
158
- const id = realtimeLogID(value);
159
- if (id !== undefined) result[name] = id;
160
- } else if (STRING_FIELDS.has(name)) {
133
+ if (STRING_FIELDS.has(name)) {
161
134
  const safe = token(value);
162
135
  if (safe) result[name] = safe;
163
136
  } else if (VALUE_FIELDS.has(name) && (typeof value === "boolean" || (typeof value === "number" && Number.isFinite(value)))) {
@@ -208,92 +181,7 @@ function lifecycleErrorCode(fields) {
208
181
  return fields.outcome === "failed" || fields.outcome === "rejected" || fields.outcome === "conflicting" ? "unknown" : undefined;
209
182
  }
210
183
 
211
- const REALTIME_LOG_ONLY = new Set([
212
- "app_server_rpc", "app_server_rpc_unmatched", "app_server_rpc_late_reply", "app_server_host_attached",
213
- "app_server_host_failed", "app_server_host_reused_failed", "app_server_host_prepare", "artifact_operation_failed",
214
- "app_server_resume_binding_failed", "app_server_question", "hitl_answer",
215
- "downlink_admission", "rpc_reply", "uplink_commit", "uplink_transport", "subscription_query", "runtime_lease"
216
- ]);
217
-
218
- 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;
219
-
220
- const defaultRealtimeSink = {
221
- info(line) {
222
- const out = console;
223
- out.info(line);
224
- },
225
- warn(line) {
226
- const out = console;
227
- out.warn(line);
228
- },
229
- error(line) {
230
- const out = console;
231
- out.error(line);
232
- }
233
- };
234
-
235
- function serializeLocalValue(value, depth = 0) {
236
- if (value === null || value === undefined) return undefined;
237
- if (typeof value === "string") return value.length > 1024 ? `${value.slice(0, 1021)}...` : value;
238
- if (typeof value === "number") return Number.isFinite(value) ? value : undefined;
239
- if (typeof value === "boolean") return value;
240
- if (value instanceof Error) {
241
- const summary = {
242
- error_type: value.name || "Error",
243
- error_message: typeof value.message === "string" ? value.message.slice(0, 1024) : ""
244
- };
245
- if (value.code !== undefined) summary.error_code = String(value.code).slice(0, 128);
246
- if (value.errno !== undefined) summary.errno = value.errno;
247
- if (value.rpcError?.code !== undefined) summary.rpc_error_code = value.rpcError.code;
248
- return summary;
249
- }
250
- if (depth >= 3) return undefined;
251
- if (Array.isArray(value)) {
252
- return value.slice(0, 32).map(entry => serializeLocalValue(entry, depth + 1)).filter(entry => entry !== undefined);
253
- }
254
- if (typeof value === "object") {
255
- const out = {};
256
- for (const [key, entry] of Object.entries(value)) {
257
- if (entry === undefined || LOCAL_SENSITIVE_KEY.test(key)) continue;
258
- const serialized = serializeLocalValue(entry, depth + 1);
259
- if (serialized !== undefined) out[key] = serialized;
260
- }
261
- return out;
262
- }
263
- return undefined;
264
- }
265
-
266
- export function writeLocalRealtimeLog(level, event, fields = {}, { logger } = {}) {
267
- try {
268
- if (logger === null) return;
269
- if (!logger && process.env.NODE_TEST_CONTEXT && process.env.CODEM_REALTIME_LOCAL_LOG !== "1") return;
270
- const sink = logger ?? defaultRealtimeSink;
271
- const payload = serializeLocalValue(fields) ?? {};
272
- const line = `[codem][realtime][${event}] ${JSON.stringify(payload)}`;
273
- if (level === "info") {
274
- sink.info?.(line);
275
- } else if (level === "error" || level === "fatal") {
276
- (sink.error ?? sink.warn)?.call(sink, line);
277
- } else {
278
- sink.warn?.(line);
279
- }
280
- } catch { /* Local diagnostics must never affect business execution. */ }
281
- }
282
-
283
- export function writeLocalCoreStderr(pid, rawLine, { logger } = {}) {
284
- try {
285
- if (logger === null) return;
286
- if (!logger && process.env.NODE_TEST_CONTEXT && process.env.CODEM_REALTIME_LOCAL_LOG !== "1") return;
287
- const trimmed = String(rawLine ?? "").trim();
288
- if (!trimmed) return;
289
- const safe = trimmed.length > 2048 ? `${trimmed.slice(0, 2045)}...` : trimmed;
290
- const sink = logger ?? defaultRealtimeSink;
291
- sink.warn?.(`[codem][core-stderr][pid=${pid ?? "unknown"}] ${safe}`);
292
- } catch { /* Forwarding child stderr must never fail the host. */ }
293
- }
294
-
295
184
  function keepLegacyMetric(event, fields, role, severity) {
296
- if (REALTIME_LOG_ONLY.has(event)) return false;
297
185
  if (/^startup\.(?:main|update_check|daemon_service_reconcile|login_gate|login_handoff_to_linco)$/u.test(event) && severity === "info") return false;
298
186
  if (/(?:^|\.)drain_(?:started|completed)$/u.test(event) && severity === "info") return false;
299
187
  if (role === "daemon" && event === "runtime_capability_probe" && severity === "info") return false;
@@ -327,7 +215,6 @@ export class RuntimeLogReporter {
327
215
  #live = { queue: [], inflight: undefined, abort: undefined };
328
216
  #replay = { queue: [], inflight: undefined, abort: undefined };
329
217
  #identity = {};
330
- #resourceContext = {};
331
218
  #timer;
332
219
  #closed = false;
333
220
  #dropped = 0;
@@ -346,11 +233,10 @@ export class RuntimeLogReporter {
346
233
  #restoring;
347
234
  #savedDuringRestore = new Set();
348
235
 
349
- constructor({ role = "cli", version = "unknown", env = process.env, send = sendSlardarPcBatch, instanceId = randomUUID(), diagnosticId: supportId = diagnosticId(), platform = process.platform, osVersion = os.release(), crashDirectory } = {}) {
236
+ constructor({ role = "cli", version = "unknown", send = sendSlardarPcBatch, instanceId = randomUUID(), diagnosticId: supportId = diagnosticId(), platform = process.platform, osVersion = os.release(), crashDirectory } = {}) {
350
237
  this.#send = send;
351
238
  this.#crashDirectory = crashDirectory;
352
239
  this.#role = token(role) ?? "cli";
353
- this.#resourceContext = sandboxObservationContext(env, role);
354
240
  this.#version = token(version) ?? "unknown";
355
241
  this.#instanceId = instanceId;
356
242
  this.#diagnosticId = supportId;
@@ -432,35 +318,7 @@ export class RuntimeLogReporter {
432
318
 
433
319
  get pendingCount() { return this.#live.queue.length + this.#replay.queue.length; }
434
320
  get droppedCount() { return this.#dropped; }
435
-
436
- #header() {
437
- const identity = this.#identity;
438
- return { aid: SLARDAR_PC_AID, device_id: identity.deviceId ?? this.#instanceId,
439
- user_id: identity.userId ?? "0", parfait_version: SLARDAR_PC_REPORTER_VERSION,
440
- channel: identity.channel ?? "unknown", os: this.#platform, os_version: this.#osVersion };
441
- }
442
-
443
- recordMetric(name, category, metrics) {
444
- if (this.#closed) return false;
445
- if (this.#live.queue.length >= CAPACITY) {
446
- this.#dropped += 1;
447
- return false;
448
- }
449
- const identity = this.#identity;
450
- const record = {
451
- app_version: this.#version, app_minor_version: "", build_id: "",
452
- process_type: `codem-${this.#role}`, session_id: "", timestamp: Date.now(),
453
- log_type: "flexible", event_name: name,
454
- category: { reporter: "codem_js", runtime_role: this.#role,
455
- ...(identity.tenantId ? { tenant_id: identity.tenantId } : {}), ...category },
456
- metrics
457
- };
458
- this.#live.queue.push({ header: this.#header(), record, metricName: null, attempts: 0 });
459
- // Bursts need not wait for the periodic timer, and a slow collector still
460
- // has only one bounded in-flight upload.
461
- if (this.#live.queue.length >= BATCH_SIZE) void this.#flushLane(this.#live, REQUEST_TIMEOUT_MS);
462
- return true;
463
- }
321
+ get identityKey() { return JSON.stringify([this.#instanceId, this.#role, this.#identity.deviceId, this.#identity.userId, this.#identity.tenantId]); }
464
322
 
465
323
  record(level, component, event, fields = {}) {
466
324
  try {
@@ -471,17 +329,13 @@ export class RuntimeLogReporter {
471
329
 
472
330
  #logEntry(level, component, event, fields) {
473
331
  let safeFields;
474
- try { safeFields = projectFields(fields, true, component); } catch { safeFields = {}; }
332
+ try { safeFields = projectFields(fields); } catch { safeFields = {}; }
475
333
  if (OBSERVATION_EVENTS.has(event)) safeFields.observation_id = randomUUID();
476
334
  const severity = ["info", "warn", "error", "fatal"].includes(level) ? level : "info";
477
335
  // Keep arbitrary upstream error codes out of trusted-device metric dimensions.
478
336
  const trustedDevice = TRUSTED_DEVICE_EVENTS.has(event);
479
337
  const dimensions = trustedDevice ? {} : Object.fromEntries(["stage", "error_class", "error_code", "error_kind", "outcome"]
480
338
  .filter(key => safeFields[key]).map(key => [key, safeFields[key]]));
481
- if (UPLINK_DIAGNOSTIC_METRICS.has(event)) {
482
- if (safeFields.lane) dimensions.lane = safeFields.lane;
483
- if (safeFields.target_kind) dimensions.target_kind = safeFields.target_kind;
484
- }
485
339
  if (OBSERVATION_EVENTS.has(event)) {
486
340
  for (const [key, values] of Object.entries(trustedDevice ? TRUSTED_DEVICE_DIMENSIONS : OBSERVATION_DIMENSIONS)) {
487
341
  if (safeFields[key]) dimensions[key] = values.includes(safeFields[key]) ? safeFields[key] : "unknown";
@@ -543,7 +397,6 @@ export class RuntimeLogReporter {
543
397
  }
544
398
 
545
399
  #entry(severity, component, event, safeFields, identity, dimensions, includeLog) {
546
- safeFields = { ...this.#resourceContext, ...safeFields, ...(this.#resourceContext.resource_id ? { resource_id: this.#resourceContext.resource_id } : {}) };
547
400
  const category = {
548
401
  ...workerRuntimeAttributes(),
549
402
  client_kind: "cli", runtime_role: this.#role, reporter: "codem_js", log_schema: "1",
@@ -714,9 +567,9 @@ export function runtimeLogIdentityKey() { return active?.identityKey; }
714
567
 
715
568
  export function startRuntimeLogs({ role, version, env = process.env, send } = {}) {
716
569
  try {
717
- if (active || !sandboxLogUploadAllowed(env, role) || /^(1|true|yes)$/iu.test(env.CODEM_TELEMETRY_DISABLED ?? "") || env.NODE_TEST_CONTEXT) return;
570
+ if (active || /^(1|true|yes)$/iu.test(env.CODEM_TELEMETRY_DISABLED ?? "") || env.NODE_TEST_CONTEXT) return;
718
571
  const root = env.CODEM_HOME || env.LINCO_HOME || path.join(os.homedir(), ".codem");
719
- active = new RuntimeLogReporter({ role, version, env, send, crashDirectory: path.join(root, "runtime-crashes") });
572
+ active = new RuntimeLogReporter({ role, version, send, crashDirectory: path.join(root, "runtime-crashes") });
720
573
  } catch { /* Monitoring initialization never prevents a command from running. */ }
721
574
  }
722
575
 
@@ -742,10 +595,6 @@ export function flushRuntimeLogsInBackground() {
742
595
  if (active) setImmediate(() => { void active?.flush().catch(() => {}); }).unref?.();
743
596
  }
744
597
 
745
- export function recordRuntimeMetric(name, category, metrics) {
746
- try { return active?.recordMetric(name, category, metrics) ?? false; } catch { return false; }
747
- }
748
-
749
598
  export function persistRuntimeCrash(component, event, fields) {
750
599
  try { active?.persistCrash(component, event, fields); } catch { /* best effort */ }
751
600
  }
@@ -805,9 +654,9 @@ export function recordInteractiveProcessExit({ exitCode, signal }) {
805
654
  export function recordSelectedRuntimeLog(component, event, fields = {}) {
806
655
  try {
807
656
  const selectedEvent = event.replace(/^linco\./u, "");
808
- 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;
657
+ 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;
809
658
  const expected = optional(() => fields?.errorKind === "user_stop" || fields?.terminalError?.kind === "user_stop" || fields?.exitCode === 130 || fields?.signal === "SIGINT");
810
- 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";
659
+ const level = expected ? "info" : (fields?.status === "failed" || /(?:failed|error|exhausted|timeout)$/u.test(event)) ? "error" : /(?:suspect|dropped|missing|oversize)$/u.test(event) ? "warn" : "info";
811
660
  recordRuntimeLog(level, component, event, fields);
812
661
  } catch { /* best effort */ }
813
662
  }
package/auth/index.d.ts DELETED
@@ -1,19 +0,0 @@
1
- export interface UserAccessTokenIdentity {
2
- readonly userId: string
3
- readonly tenantId: string
4
- readonly serverOrigin: 'https://codem.feishu.cn' | 'https://codem.feishu-boe.cn'
5
- readonly revision: string
6
- }
7
- export interface UserAccessTokenProvider {
8
- getValidUserAccessToken(): Promise<{ readonly userAccessToken: string; readonly expiresAt: string }>
9
- dispose(): void
10
- }
11
- export class CodeMUserAccessTokenError extends Error {
12
- readonly code: string
13
- }
14
- export function createUserAccessTokenProvider(options: {
15
- readonly home: string
16
- readonly identity: UserAccessTokenIdentity
17
- readonly ttEnv: string | null
18
- readonly fetchImpl?: typeof fetch
19
- }): UserAccessTokenProvider