@blade-hq/agent-client 2610.0.0-beta.37 → 2610.0.0-beta.39

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/auth.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  export interface AuthOptions {
2
2
  token?: string | (() => string | null | undefined);
3
3
  }
4
- export declare function buildAuthHeaders(options: AuthOptions): Record<string, string>;
5
4
  export declare function buildSocketAuth(options: AuthOptions): {
6
5
  token: string;
7
6
  } | undefined;
package/dist/index.js CHANGED
@@ -214,6 +214,11 @@ var AuthResource = class {
214
214
  }
215
215
  };
216
216
 
217
+ // src/shared/type-guards.ts
218
+ function isRecord(value) {
219
+ return typeof value === "object" && value !== null && !Array.isArray(value);
220
+ }
221
+
217
222
  // src/resources/headless.ts
218
223
  var HeadlessError = class extends Error {
219
224
  constructor(message, detail) {
@@ -394,9 +399,6 @@ function errorMessageFromResult(result) {
394
399
  }
395
400
  return null;
396
401
  }
397
- function isRecord(value) {
398
- return typeof value === "object" && value !== null && !Array.isArray(value);
399
- }
400
402
  function ensureSocketConnected(socket, timeoutMs, detail) {
401
403
  if (socket.connected) {
402
404
  return Promise.resolve();
@@ -534,6 +536,8 @@ var SessionInfo = type({
534
536
  "daemon_id?": "string | null",
535
537
  "agent_runtime_id?": "string | null",
536
538
  "workspace_path?": "string | null",
539
+ "ba_version?": "string | null",
540
+ "sandbox_version?": "string | null",
537
541
  "match?": "unknown"
538
542
  });
539
543
 
@@ -1176,15 +1180,12 @@ function getContextGroupDisplayState(contexts) {
1176
1180
  }
1177
1181
 
1178
1182
  // src/shared/projection/context.ts
1179
- function isRecord2(value) {
1180
- return typeof value === "object" && value !== null && !Array.isArray(value);
1181
- }
1182
1183
  function buildContextTurn(entry, sequence) {
1183
- if (entry.kind !== "context" || !isRecord2(entry.source) || !isRecord2(entry.data)) {
1184
+ if (entry.kind !== "context" || !isRecord(entry.source) || !isRecord(entry.data)) {
1184
1185
  return null;
1185
1186
  }
1186
- const display = isRecord2(entry.data.display) ? entry.data.display : {};
1187
- const message = isRecord2(entry.message) ? entry.message : {};
1187
+ const display = isRecord(entry.data.display) ? entry.data.display : {};
1188
+ const message = isRecord(entry.message) ? entry.message : {};
1188
1189
  const context = contextProjectionData({
1189
1190
  context_kind: typeof entry.source.kind === "string" ? entry.source.kind : null,
1190
1191
  context_key: typeof entry.source.key === "string" ? entry.source.key : null,
@@ -1194,7 +1195,7 @@ function buildContextTurn(entry, sequence) {
1194
1195
  context_revision: typeof entry.data.revision === "string" ? entry.data.revision : null,
1195
1196
  display_title: typeof display.title === "string" ? display.title : null,
1196
1197
  display_summary: typeof display.summary === "string" ? display.summary : null,
1197
- sources: Array.isArray(display.sources) ? display.sources.filter(isRecord2) : []
1198
+ sources: Array.isArray(display.sources) ? display.sources.filter(isRecord) : []
1198
1199
  });
1199
1200
  if (!context) return null;
1200
1201
  const turnId = typeof entry.id === "string" && entry.id ? entry.id : `context-${sequence}`;
@@ -1493,7 +1494,7 @@ var ClientProjectionBuilder = class {
1493
1494
  return null;
1494
1495
  }
1495
1496
  onContextEntry(payload) {
1496
- if (!isRecord3(payload.entry)) return null;
1497
+ if (!isRecord(payload.entry)) return null;
1497
1498
  const turn = buildContextTurn(payload.entry, this.nextSeq());
1498
1499
  return turn ? [{ kind: "upsert", turn }] : null;
1499
1500
  }
@@ -1554,11 +1555,11 @@ var ClientProjectionBuilder = class {
1554
1555
  loopId,
1555
1556
  toolCallId: optStr(payload.tool_call_id) ?? void 0,
1556
1557
  toolName: toolNameFromPayload(payload) ?? void 0,
1557
- workspacePath: isRecord3(payload.workspace_change) ? optStr(payload.workspace_change.to) ?? void 0 : void 0
1558
+ workspacePath: isRecord(payload.workspace_change) ? optStr(payload.workspace_change.to) ?? void 0 : void 0
1558
1559
  }
1559
1560
  ];
1560
1561
  const change = payload.workspace_change;
1561
- if (isRecord3(change)) {
1562
+ if (isRecord(change)) {
1562
1563
  const source = optStr(change.source) ?? "";
1563
1564
  const projectName = optStr(change.project_name) ?? "";
1564
1565
  const fromPath = optStr(change.from) ?? "";
@@ -1654,7 +1655,7 @@ var ClientProjectionBuilder = class {
1654
1655
  const updates = this.collectLoopUpdates(loopId, parentLoopId);
1655
1656
  const entryId = typeof payload.entry_id === "string" ? payload.entry_id : "";
1656
1657
  if (!entryId) return updates;
1657
- const answerData = isRecord3(payload.answer_data) ? payload.answer_data : {};
1658
+ const answerData = isRecord(payload.answer_data) ? payload.answer_data : {};
1658
1659
  const answerTurn = {
1659
1660
  id: entryId,
1660
1661
  sequence: this.nextSeq(),
@@ -2081,9 +2082,6 @@ var ClientProjectionBuilder = class {
2081
2082
  return `${prefix}:${this.syntheticCounter}:${hex}`;
2082
2083
  }
2083
2084
  };
2084
- function isRecord3(value) {
2085
- return typeof value === "object" && value !== null && !Array.isArray(value);
2086
- }
2087
2085
  function optStr(value) {
2088
2086
  if (value == null || value === "") return null;
2089
2087
  return String(value);
@@ -2119,14 +2117,14 @@ function projectHistory(entries) {
2119
2117
  const kind = String(entry.kind ?? "");
2120
2118
  const loopId = String(entry.loop_name ?? "root");
2121
2119
  const id = String(entry.id ?? `history-${sequence + 1}`);
2122
- if (kind === "turn_timing" && isRecord4(entry.data)) {
2120
+ if (kind === "turn_timing" && isRecord(entry.data)) {
2123
2121
  const turnId = typeof entry.data.turn_id === "string" ? entry.data.turn_id : "";
2124
2122
  const duration = numberOrNull(entry.data.first_token_delivery_ms);
2125
2123
  const target = turnEntryAliases.get(turnId);
2126
2124
  if (target && duration !== null) target.first_token_delivery_ms = duration;
2127
2125
  continue;
2128
2126
  }
2129
- if (kind === "post_chat_followup" && isRecord4(entry.data)) {
2127
+ if (kind === "post_chat_followup" && isRecord(entry.data)) {
2130
2128
  const assistantEntryId = String(entry.data.assistant_entry_id ?? "");
2131
2129
  if (latestRootMessage?.role === "assistant" && latestRootMessage.turn_id === assistantEntryId) {
2132
2130
  const followup = normalizePostChatFollowup(entry.data, assistantEntryId);
@@ -2142,7 +2140,7 @@ function projectHistory(entries) {
2142
2140
  }
2143
2141
  continue;
2144
2142
  }
2145
- if (kind === "message" && isRecord4(entry.message)) {
2143
+ if (kind === "message" && isRecord(entry.message)) {
2146
2144
  const message = entry.message;
2147
2145
  const role = String(message.role ?? "");
2148
2146
  if (role === "tool") {
@@ -2177,7 +2175,7 @@ function projectHistory(entries) {
2177
2175
  blocks,
2178
2176
  tool_calls: toolCalls,
2179
2177
  model: stringOrNull(message.model),
2180
- usage: isRecord4(message._usage) ? { ...message._usage } : null,
2178
+ usage: isRecord(message._usage) ? { ...message._usage } : null,
2181
2179
  duration_ms: numberOrZero(message._duration_ms),
2182
2180
  first_token_ms: numberOrNull(message._first_token_ms),
2183
2181
  stream_duration_ms: numberOrNull(message._stream_duration_ms),
@@ -2188,7 +2186,7 @@ function projectHistory(entries) {
2188
2186
  parent_fork_tool_call_id: stringOrNull(message._parent_fork_tool_call_id)
2189
2187
  };
2190
2188
  const isNativeToolEntry = role === "assistant" && Array.isArray(message.tool_calls) && message.tool_calls.some(
2191
- (toolCall) => isRecord4(toolCall) && typeof toolCall.provider === "string"
2189
+ (toolCall) => isRecord(toolCall) && typeof toolCall.provider === "string"
2192
2190
  );
2193
2191
  const previousTurn = turns[turns.length - 1];
2194
2192
  if (role === "assistant" && previousTurn?.role === "assistant" && previousTurn.loop_id === loopId && nativeToolTurns.has(previousTurn)) {
@@ -2242,7 +2240,7 @@ function projectHistory(entries) {
2242
2240
  if (kind === "mode_change") {
2243
2241
  turns.push(markerTurn(id, ++sequence, loopId, "mode_change", entry.data ?? {}));
2244
2242
  } else if (kind === "workspace_change") {
2245
- const change = isRecord4(entry.data) ? entry.data : {};
2243
+ const change = isRecord(entry.data) ? entry.data : {};
2246
2244
  const source = stringOrNull(change.source) ?? "";
2247
2245
  const projectName = stringOrNull(change.project_name) ?? "";
2248
2246
  const fromPath = stringOrNull(change.from) ?? "";
@@ -2284,7 +2282,7 @@ function projectHistory(entries) {
2284
2282
  } else if (kind === "compaction" || kind === "tool_result_archive") {
2285
2283
  const data = entry.data ?? {};
2286
2284
  const compactionId = String(data.compaction_id ?? entry.id ?? `history-${sequence + 1}`);
2287
- let content = isRecord4(entry.message) ? entry.message.content : void 0;
2285
+ let content = isRecord(entry.message) ? entry.message.content : void 0;
2288
2286
  if (kind === "tool_result_archive") {
2289
2287
  const archivedCount = Array.isArray(data.archived_files) ? data.archived_files.length : 0;
2290
2288
  content = `<compaction-summary>
@@ -2292,18 +2290,24 @@ function projectHistory(entries) {
2292
2290
  </compaction-summary>`;
2293
2291
  }
2294
2292
  turns.push(
2295
- buildCompactionTurn(++sequence, compactionId, loopId, "completed", {
2296
- ...data,
2297
- content
2298
- })
2293
+ buildCompactionTurn(
2294
+ ++sequence,
2295
+ compactionId,
2296
+ loopId,
2297
+ data.status === "failed" ? "failed" : "completed",
2298
+ {
2299
+ ...data,
2300
+ content
2301
+ }
2302
+ )
2299
2303
  );
2300
2304
  } else if (kind === "child_pause") {
2301
2305
  const data = entry.data ?? {};
2302
- const sourceLoop = isRecord4(data.source_loop) ? data.source_loop : {};
2306
+ const sourceLoop = isRecord(data.source_loop) ? data.source_loop : {};
2303
2307
  const childLoopId = String(data.child_loop_name ?? sourceLoop.name ?? "");
2304
2308
  const childToolCallId = String(data.child_pause_tool_call_id ?? "");
2305
2309
  const parentToolCallId = String(data.parent_fork_tool_call_id ?? "");
2306
- const pauseToolData = isRecord4(data.pause_tool_data) ? data.pause_tool_data : {};
2310
+ const pauseToolData = isRecord(data.pause_tool_data) ? data.pause_tool_data : {};
2307
2311
  const description = String(sourceLoop.description ?? "");
2308
2312
  applyAskUserPauseToTurn(
2309
2313
  latestAssistantByLoop.get(childLoopId),
@@ -2391,15 +2395,15 @@ function parseToolArguments(value) {
2391
2395
  if (!value) return {};
2392
2396
  try {
2393
2397
  const parsed = JSON.parse(value);
2394
- return isRecord4(parsed) ? parsed : {};
2398
+ return isRecord(parsed) ? parsed : {};
2395
2399
  } catch {
2396
2400
  return {};
2397
2401
  }
2398
2402
  }
2399
2403
  function buildToolCalls(value) {
2400
2404
  if (!Array.isArray(value)) return [];
2401
- return value.filter(isRecord4).map((raw) => {
2402
- const fn = isRecord4(raw.function) ? raw.function : {};
2405
+ return value.filter(isRecord).map((raw) => {
2406
+ const fn = isRecord(raw.function) ? raw.function : {};
2403
2407
  const name = String(fn.name ?? "");
2404
2408
  return {
2405
2409
  id: String(raw.id ?? ""),
@@ -2420,7 +2424,7 @@ function buildBlocks(message, toolCalls) {
2420
2424
  blocks.push({ type: "text", content: displayContent });
2421
2425
  } else if (Array.isArray(stored)) {
2422
2426
  for (const raw of stored) {
2423
- if (!isRecord4(raw)) continue;
2427
+ if (!isRecord(raw)) continue;
2424
2428
  const type3 = String(raw.type ?? "");
2425
2429
  if (type3 === "thinking") blocks.push({ type: type3, content: raw.thinking ?? raw.content ?? "" });
2426
2430
  if (type3 === "text") blocks.push({ type: type3, content: raw.text ?? raw.content ?? "" });
@@ -2469,9 +2473,6 @@ function markerTurn(id, sequence, loopId, type3, content, toolCallId = null) {
2469
2473
  duration_ms: 0
2470
2474
  };
2471
2475
  }
2472
- function isRecord4(value) {
2473
- return typeof value === "object" && value !== null && !Array.isArray(value);
2474
- }
2475
2476
  function stringOrNull(value) {
2476
2477
  return typeof value === "string" ? value : null;
2477
2478
  }
@@ -3400,10 +3401,10 @@ function inferLoopStatusFromMessages(messages) {
3400
3401
  }
3401
3402
  function inferLoopStatusFromTurns(turns, messages) {
3402
3403
  const latestAgentNotification = [...turns].reverse().flatMap((turn) => turn.blocks).find((block) => {
3403
- if (block.type !== "system_notification" || !isRecord5(block.content)) return false;
3404
+ if (block.type !== "system_notification" || !isRecord(block.content)) return false;
3404
3405
  return block.content.notification_type === "agent:start" || block.content.notification_type === "agent:end";
3405
3406
  });
3406
- if (latestAgentNotification?.type === "system_notification" && isRecord5(latestAgentNotification.content)) {
3407
+ if (latestAgentNotification?.type === "system_notification" && isRecord(latestAgentNotification.content)) {
3407
3408
  const notificationType = latestAgentNotification.content.notification_type;
3408
3409
  const status = latestAgentNotification.content.status;
3409
3410
  if (notificationType === "agent:start" || status === "running") return "running";
@@ -3412,11 +3413,8 @@ function inferLoopStatusFromTurns(turns, messages) {
3412
3413
  }
3413
3414
  return inferLoopStatusFromMessages(messages);
3414
3415
  }
3415
- function isRecord5(value) {
3416
- return typeof value === "object" && value !== null && !Array.isArray(value);
3417
- }
3418
3416
  function toSelectionMap(value) {
3419
- if (!isRecord5(value)) return {};
3417
+ if (!isRecord(value)) return {};
3420
3418
  const entries = Object.entries(value).map(([questionKey, optionIndexes]) => {
3421
3419
  if (!Array.isArray(optionIndexes)) return null;
3422
3420
  const parsedIndexes = optionIndexes.map((item) => typeof item === "number" ? item : Number(item)).filter((item) => Number.isInteger(item));
@@ -3425,7 +3423,7 @@ function toSelectionMap(value) {
3425
3423
  return Object.fromEntries(entries);
3426
3424
  }
3427
3425
  function toCustomMap(value) {
3428
- if (!isRecord5(value)) return {};
3426
+ if (!isRecord(value)) return {};
3429
3427
  const entries = Object.entries(value).filter(([, text]) => typeof text === "string").map(([questionKey, text]) => [Number(questionKey), text]);
3430
3428
  return Object.fromEntries(entries);
3431
3429
  }
@@ -3434,7 +3432,7 @@ function extractAskAnswers(turns) {
3434
3432
  for (const turn of turns) {
3435
3433
  for (const block of turn.blocks) {
3436
3434
  if (block.type !== "ask_user_answer" || typeof block.tool_call_id !== "string") continue;
3437
- if (!isRecord5(block.content)) continue;
3435
+ if (!isRecord(block.content)) continue;
3438
3436
  const note = typeof block.content.note === "string" ? block.content.note.trim() : "";
3439
3437
  answers[block.tool_call_id] = {
3440
3438
  selections: toSelectionMap(block.content.selections),
@@ -3450,9 +3448,9 @@ function parentForkToolCallIdFromTurn(turn) {
3450
3448
  return turn.parent_fork_tool_call_id;
3451
3449
  }
3452
3450
  for (const block of turn.blocks) {
3453
- if (block.type !== "system_notification" || !isRecord5(block.content)) continue;
3451
+ if (block.type !== "system_notification" || !isRecord(block.content)) continue;
3454
3452
  const metadata = block.content.metadata;
3455
- if (!isRecord5(metadata)) continue;
3453
+ if (!isRecord(metadata)) continue;
3456
3454
  const parentId = metadata.parent_fork_tool_call_id;
3457
3455
  if (typeof parentId === "string" && parentId.length > 0) return parentId;
3458
3456
  }
@@ -3469,16 +3467,16 @@ function buildMessageContent2(turn) {
3469
3467
  }
3470
3468
  function workspaceNotificationContent(turn) {
3471
3469
  const block = turn.blocks.find(
3472
- (candidate) => candidate.type === "system_notification" && isRecord5(candidate.content) && candidate.content.notification_type === "workspace_change"
3470
+ (candidate) => candidate.type === "system_notification" && isRecord(candidate.content) && candidate.content.notification_type === "workspace_change"
3473
3471
  );
3474
- if (!block || !isRecord5(block.content)) return "";
3472
+ if (!block || !isRecord(block.content)) return "";
3475
3473
  const title = typeof block.content.title === "string" ? block.content.title.trim() : "";
3476
3474
  const detail = typeof block.content.detail === "string" ? block.content.detail.trim() : "";
3477
3475
  return [title ? `**${title}**` : "", detail].filter(Boolean).join("\n\n");
3478
3476
  }
3479
3477
  function askUserAnswerContent(turn) {
3480
3478
  const answerBlock = turn.blocks.find((block) => block.type === "ask_user_answer");
3481
- if (!answerBlock || !isRecord5(answerBlock.content)) return null;
3479
+ if (!answerBlock || !isRecord(answerBlock.content)) return null;
3482
3480
  const answer = answerBlock.content.answer;
3483
3481
  return typeof answer === "string" && answer.trim().length > 0 ? answer : null;
3484
3482
  }
@@ -3868,18 +3866,15 @@ function createClientRequestId() {
3868
3866
  return `${Date.now()}-${Math.random().toString(36).slice(2)}-${fallbackRequestCounter}`;
3869
3867
  }
3870
3868
  var OOM_KEYWORDS_RE = /(?:\b(?:exit_code|ExitedWith|exited with)|退出码)\D*(?<!\d)137(?!\d)/i;
3871
- function isRecord6(value) {
3872
- return typeof value === "object" && value !== null && !Array.isArray(value);
3873
- }
3874
3869
  function isOomText(value) {
3875
3870
  return typeof value === "string" && OOM_KEYWORDS_RE.test(value);
3876
3871
  }
3877
3872
  function parseJsonRecord(value) {
3878
- if (isRecord6(value)) return value;
3873
+ if (isRecord(value)) return value;
3879
3874
  if (typeof value !== "string") return null;
3880
3875
  try {
3881
3876
  const parsed = JSON.parse(value);
3882
- return isRecord6(parsed) ? parsed : null;
3877
+ return isRecord(parsed) ? parsed : null;
3883
3878
  } catch {
3884
3879
  return null;
3885
3880
  }
@@ -3927,7 +3922,7 @@ function extractTerminalChatEndStatus(events) {
3927
3922
  return null;
3928
3923
  }
3929
3924
  function isUiMetaLike(value) {
3930
- return isRecord6(value) && ("resourceHTML" in value || "resourceUri" in value || "resourceURI" in value);
3925
+ return isRecord(value) && ("resourceHTML" in value || "resourceUri" in value || "resourceURI" in value);
3931
3926
  }
3932
3927
  var AgentSession = class _AgentSession {
3933
3928
  sessionId;
@@ -4155,7 +4150,7 @@ var AgentSession = class _AgentSession {
4155
4150
  if (this.getAppContext) {
4156
4151
  try {
4157
4152
  const rawContext = await this.getAppContext();
4158
- if (!isRecord6(rawContext)) {
4153
+ if (!isRecord(rawContext)) {
4159
4154
  throw new Error("getContext \u5FC5\u987B\u8FD4\u56DE JSON \u5BF9\u8C61");
4160
4155
  }
4161
4156
  const serialized = JSON.stringify(rawContext);
@@ -4163,7 +4158,7 @@ var AgentSession = class _AgentSession {
4163
4158
  throw new Error("getContext \u5FC5\u987B\u8FD4\u56DE\u53EF\u5E8F\u5217\u5316\u7684 JSON \u5BF9\u8C61");
4164
4159
  }
4165
4160
  const normalized = JSON.parse(serialized);
4166
- if (!isRecord6(normalized)) {
4161
+ if (!isRecord(normalized)) {
4167
4162
  throw new Error("getContext \u5FC5\u987B\u8FD4\u56DE JSON \u5BF9\u8C61");
4168
4163
  }
4169
4164
  appContext = normalized;
@@ -4304,7 +4299,11 @@ ${text}` } : block
4304
4299
  }
4305
4300
  /** 停止当前回复。 */
4306
4301
  stop() {
4307
- return this.runtime.emitWithAck("chat:stop", { session_id: this.sessionId }, 35e3).then((response) => response ?? {});
4302
+ return this.runtime.emitWithAck("chat:stop", { session_id: this.sessionId }, 35e3).then((response) => {
4303
+ const result = response ?? {};
4304
+ if (result.status !== "accepted") this.manualCompactionPending = false;
4305
+ return result;
4306
+ });
4308
4307
  }
4309
4308
  /** 手动触发上下文压缩。 */
4310
4309
  compact() {
@@ -4324,8 +4323,10 @@ ${text}` } : block
4324
4323
  trigger: "manual"
4325
4324
  }
4326
4325
  }));
4327
- return this.runtime.emitWithAck("chat:compact", { session_id: this.sessionId }, 3e4).then((response) => response ?? {}).finally(() => {
4326
+ return this.runtime.emitWithAck("chat:compact", { session_id: this.sessionId }, 3e4).then((response) => response ?? {}).catch((error) => {
4328
4327
  this.manualCompactionPending = false;
4328
+ throw error;
4329
+ }).finally(() => {
4329
4330
  if (this.state.activeCompaction?.compaction_id === "pending-manual-compaction") {
4330
4331
  this.update((state) => ({ ...state, activeCompaction: null }));
4331
4332
  }
@@ -4496,6 +4497,11 @@ ${text}` } : block
4496
4497
  /** @internal 历史回放通道(event_format: raw)。 */
4497
4498
  _handleTurnEvents(events, replayed = false) {
4498
4499
  if (!events.length) return;
4500
+ if (events.some(
4501
+ (event) => event.type === "compaction:end" || event.type === "compaction:error" || event.type === "compaction:abort"
4502
+ )) {
4503
+ this.manualCompactionPending = false;
4504
+ }
4499
4505
  this.dispatchRawCommands(events);
4500
4506
  const terminalChatEndStatus = extractTerminalChatEndStatus(events);
4501
4507
  if (!terminalChatEndStatus && hasChatRunEvent(events) && this.state.status !== "waiting_for_input") {
@@ -4634,9 +4640,9 @@ ${text}` } : block
4634
4640
  detail,
4635
4641
  status,
4636
4642
  loopId,
4637
- metadata: isRecord6(notification.metadata) ? notification.metadata : void 0
4643
+ metadata: isRecord(notification.metadata) ? notification.metadata : void 0
4638
4644
  });
4639
- if (notificationType === "bg:started" && isRecord6(notification.metadata)) {
4645
+ if (notificationType === "bg:started" && isRecord(notification.metadata)) {
4640
4646
  const taskId = typeof notification.metadata.task_id === "string" ? notification.metadata.task_id : "";
4641
4647
  if (taskId) {
4642
4648
  this.emitter.emit("backgroundTask", {
@@ -4792,7 +4798,7 @@ ${text}` } : block
4792
4798
  title: ui.title ?? "\u5DE5\u5177\u9884\u89C8"
4793
4799
  });
4794
4800
  }
4795
- if (block.type === "system_notification" && isRecord6(block.content)) {
4801
+ if (block.type === "system_notification" && isRecord(block.content)) {
4796
4802
  this._handleSystemNotification(turn.loop_id, block.content);
4797
4803
  }
4798
4804
  }
@@ -5417,21 +5423,14 @@ function resolveAuthToken(options) {
5417
5423
  return token ? token : null;
5418
5424
  }
5419
5425
 
5420
- // src/version.ts
5421
- var SDK_NAME = "agent-client";
5422
- var SDK_VERSION = true ? "2610.0.0-beta.37" : "1.1.1";
5423
-
5424
5426
  // src/socket.ts
5425
- function withSdkIdentity(auth) {
5426
- return { ...auth ?? {}, sdk: SDK_NAME, sdk_version: SDK_VERSION };
5427
- }
5428
5427
  function createSocket(options) {
5429
5428
  const token = resolveAuthToken(options);
5430
5429
  return io(options.baseUrl, {
5431
5430
  path: options.path ?? "/socket.io",
5432
5431
  withCredentials: true,
5433
5432
  query: token ? { token } : void 0,
5434
- auth: typeof options.token === "function" ? (cb) => cb(withSdkIdentity(buildSocketAuth(options))) : withSdkIdentity(buildSocketAuth(options)),
5433
+ auth: typeof options.token === "function" ? (cb) => cb(buildSocketAuth(options) ?? {}) : buildSocketAuth(options) ?? {},
5435
5434
  autoConnect: false
5436
5435
  });
5437
5436
  }
@@ -5833,9 +5832,6 @@ function defaultDocumentBaseUrl() {
5833
5832
  if (typeof location !== "undefined" && location.origin) return `${location.origin}/`;
5834
5833
  return document.baseURI;
5835
5834
  }
5836
- function isRecord7(value) {
5837
- return typeof value === "object" && value !== null && !Array.isArray(value);
5838
- }
5839
5835
  function normalizeServiceUrl(value) {
5840
5836
  if (typeof value !== "string" || !value.trim()) return null;
5841
5837
  if (value.includes("?") || value.includes("#")) return null;
@@ -5849,7 +5845,7 @@ function normalizeServiceUrl(value) {
5849
5845
  }
5850
5846
  }
5851
5847
  function parsePlatformEndpoints(value) {
5852
- if (!isRecord7(value) || !isRecord7(value.services)) return null;
5848
+ if (!isRecord(value) || !isRecord(value.services)) return null;
5853
5849
  const services = {};
5854
5850
  for (const name of PLATFORM_SERVICE_NAMES) {
5855
5851
  if (!(name in value.services)) continue;
@@ -5897,6 +5893,10 @@ function resolveServiceUrl(endpoints, name, path = "") {
5897
5893
  return target.toString();
5898
5894
  }
5899
5895
 
5896
+ // src/version.ts
5897
+ var SDK_NAME = "agent-client";
5898
+ var SDK_VERSION = true ? "2610.0.0-beta.39" : "1.1.1";
5899
+
5900
5900
  // src/commands/protocol.ts
5901
5901
  function isCommandEnvelope(value) {
5902
5902
  if (typeof value !== "object" || value === null) return false;