lody 0.85.0 → 0.86.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,6 +40,7 @@ import os__default from "node:os";
40
40
  import process$1 from "node:process";
41
41
  import { isIPv4, isIPv6 } from "net";
42
42
  import { R as RequestError, a as CreateElicitationResponse, n as ndJsonStream, b as agent$1, m as methods } from "./chunks/acp-CrvzLY5A.js";
43
+ import { L as LODY_EXTENSION_METHODS } from "./chunks/methods-CvEDMahD.js";
43
44
  import { p as packageJson } from "./chunks/package-CNW89xCh.js";
44
45
  import { s as string, b as boolean, c as array } from "./chunks/schemas-Du3qLZPS.js";
45
46
  import { WritableStream, ReadableStream as ReadableStream$1 } from "node:stream/web";
@@ -59120,8 +59121,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
59120
59121
  }
59121
59122
  return null;
59122
59123
  }
59123
- const GOAL_EXTENSION_VERSION = 1;
59124
- const GOAL_CONTROL_METHOD = "_session/goal";
59124
+ const GOAL_CONTROL_METHOD = LODY_EXTENSION_METHODS.sessionGoal;
59125
59125
  const GOAL_ACTIONS = [
59126
59126
  "set",
59127
59127
  "clear"
@@ -59137,8 +59137,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
59137
59137
  }
59138
59138
  return {
59139
59139
  objective: argument,
59140
- status: "active",
59141
- controlMethod: GOAL_CONTROL_METHOD
59140
+ status: "active"
59142
59141
  };
59143
59142
  }
59144
59143
  function parseGoalRequest(params) {
@@ -59173,8 +59172,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
59173
59172
  status: "active",
59174
59173
  iterations: message.value.iterations,
59175
59174
  lastReason: message.value.last_reason ?? null,
59176
- createdAt: message.value.set_at,
59177
- controlMethod: GOAL_CONTROL_METHOD
59175
+ createdAtEpochSeconds: Math.floor(message.value.set_at / 1e3)
59178
59176
  };
59179
59177
  }
59180
59178
  const MAX_TITLE_LENGTH = 256;
@@ -59405,8 +59403,14 @@ ${promptText}
59405
59403
  function questionCustomFieldKey(index) {
59406
59404
  return `question_${index}_custom`;
59407
59405
  }
59408
- const OPTION_META_KEY = "_claude/askUserQuestionOption";
59409
- const CUSTOM_ANSWER_META_KEY = "_askUserQuestionCustomAnswer";
59406
+ const lodyElicitationMeta = (meta) => ({
59407
+ lody: {
59408
+ elicitation: {
59409
+ version: 1,
59410
+ ...meta
59411
+ }
59412
+ }
59413
+ });
59410
59414
  function askUserQuestionsToCreateRequest(questions, sessionId, toolCallId) {
59411
59415
  const single = questions.length === 1;
59412
59416
  const properties = {};
@@ -59420,11 +59424,9 @@ ${promptText}
59420
59424
  enumOption.description = option.description;
59421
59425
  }
59422
59426
  if (option.preview) {
59423
- enumOption._meta = {
59424
- [OPTION_META_KEY]: {
59425
- preview: option.preview
59426
- }
59427
- };
59427
+ enumOption._meta = lodyElicitationMeta({
59428
+ preview: option.preview
59429
+ });
59428
59430
  }
59429
59431
  return enumOption;
59430
59432
  });
@@ -59447,12 +59449,9 @@ ${promptText}
59447
59449
  type: "string",
59448
59450
  title: "Other",
59449
59451
  description: "Type your own answer instead of choosing an option above (optional).",
59450
- _meta: {
59451
- [CUSTOM_ANSWER_META_KEY]: {
59452
- questionId: questionFieldKey(index),
59453
- isCustomAnswer: true
59454
- }
59455
- }
59452
+ _meta: lodyElicitationMeta({
59453
+ customAnswerFor: questionFieldKey(index)
59454
+ })
59456
59455
  };
59457
59456
  });
59458
59457
  const requestedSchema = {
@@ -61375,10 +61374,6 @@ ${content.text}
61375
61374
  }
61376
61375
  logger.error(`Unexpected case: ${valueAsString}`);
61377
61376
  }
61378
- const EXT_METHOD_NAME = {
61379
- usage_update: "acp_ext:session_usage_update",
61380
- rate_limits: "acp_ext:session_rate_limits"
61381
- };
61382
61377
  const KEYCHAIN_TIMEOUT_MS = 5e3;
61383
61378
  const KEYCHAIN_BACKOFF_MS = 6e4;
61384
61379
  const defaultDeps = {
@@ -61406,26 +61401,39 @@ ${content.text}
61406
61401
  }
61407
61402
  const apiResponse = await deps.fetchApi(accessToken);
61408
61403
  if (!apiResponse) {
61409
- const failureResult = {
61410
- planName,
61411
- fiveHour: null,
61412
- sevenDay: null,
61413
- fiveHourResetAt: null,
61414
- sevenDayResetAt: null,
61415
- apiUnavailable: true
61416
- };
61417
- return failureResult;
61404
+ return null;
61418
61405
  }
61419
61406
  const fiveHour = parseUtilization(apiResponse.five_hour?.utilization);
61420
61407
  const sevenDay = parseUtilization(apiResponse.seven_day?.utilization);
61421
61408
  const fiveHourResetAt = parseDate(apiResponse.five_hour?.resets_at);
61422
61409
  const sevenDayResetAt = parseDate(apiResponse.seven_day?.resets_at);
61410
+ const windows = [];
61411
+ if (fiveHour !== null) {
61412
+ windows.push({
61413
+ usedPercent: fiveHour,
61414
+ windowDurationSeconds: 5 * 60 * 60,
61415
+ resetsAtEpochSeconds: fiveHourResetAt
61416
+ });
61417
+ }
61418
+ if (sevenDay !== null) {
61419
+ windows.push({
61420
+ usedPercent: sevenDay,
61421
+ windowDurationSeconds: 7 * 24 * 60 * 60,
61422
+ resetsAtEpochSeconds: sevenDayResetAt
61423
+ });
61424
+ }
61423
61425
  const result = {
61424
- planName,
61425
- fiveHour: fiveHour !== null ? fiveHour / 100 : null,
61426
- sevenDay: sevenDay !== null ? sevenDay / 100 : null,
61427
- fiveHourResetAt,
61428
- sevenDayResetAt
61426
+ rateLimits: [
61427
+ {
61428
+ limitId: "claude",
61429
+ scope: {
61430
+ providerId: "claude"
61431
+ },
61432
+ planName,
61433
+ windows
61434
+ }
61435
+ ],
61436
+ fetchedAtEpochSeconds: Math.floor(now / 1e3)
61429
61437
  };
61430
61438
  return result;
61431
61439
  } catch {
@@ -61558,7 +61566,7 @@ ${content.text}
61558
61566
  if (isNaN(date.getTime())) {
61559
61567
  return null;
61560
61568
  }
61561
- return date.getTime();
61569
+ return Math.floor(date.getTime() / 1e3);
61562
61570
  }
61563
61571
  function fetchUsageApi(accessToken) {
61564
61572
  return new Promise((resolve2) => {
@@ -61610,12 +61618,137 @@ ${content.text}
61610
61618
  cache_read_input_tokens: 0,
61611
61619
  cache_creation_input_tokens: 0
61612
61620
  });
61621
+ function claudeTaskStatus(message) {
61622
+ if (message.subtype === "task_started" || message.subtype === "task_progress") {
61623
+ return "in_progress";
61624
+ }
61625
+ const status = (message.patch?.status ?? message.status)?.toLowerCase();
61626
+ if ([
61627
+ "completed",
61628
+ "complete",
61629
+ "succeeded",
61630
+ "success"
61631
+ ].includes(status ?? "")) {
61632
+ return "completed";
61633
+ }
61634
+ if ([
61635
+ "failed",
61636
+ "killed",
61637
+ "cancelled",
61638
+ "canceled",
61639
+ "stopped",
61640
+ "error"
61641
+ ].includes(status ?? "")) {
61642
+ return "failed";
61643
+ }
61644
+ return status === "pending" ? "pending" : "in_progress";
61645
+ }
61646
+ function cleanTaskText(value, maxLength = 2e3) {
61647
+ const text = value?.trim();
61648
+ if (!text) return void 0;
61649
+ return text.length <= maxLength ? text : `${text.slice(0, maxLength - 1)}\u2026`;
61650
+ }
61651
+ function createClaudeTaskLifecycleUpdate(message, isSubagent) {
61652
+ const actor = cleanTaskText(message.subagent_type ?? message.workflow_name ?? message.task_type ?? "Claude task", 160) ?? "Claude task";
61653
+ const description = cleanTaskText(message.description ?? message.prompt);
61654
+ const summary = cleanTaskText(message.summary);
61655
+ const error = cleanTaskText(message.patch?.error);
61656
+ const lastToolName = cleanTaskText(message.last_tool_name, 160);
61657
+ const usage = message.usage ? {
61658
+ ...message.usage.total_tokens !== void 0 ? {
61659
+ totalTokens: message.usage.total_tokens
61660
+ } : {},
61661
+ ...message.usage.tool_uses !== void 0 ? {
61662
+ toolUses: message.usage.tool_uses
61663
+ } : {},
61664
+ ...message.usage.duration_ms !== void 0 ? {
61665
+ durationMs: message.usage.duration_ms
61666
+ } : {}
61667
+ } : void 0;
61668
+ const task = {
61669
+ version: 1,
61670
+ taskId: message.task_id,
61671
+ kind: isSubagent ? "subagent" : "background",
61672
+ status: claudeTaskStatus(message),
61673
+ actor,
61674
+ ...description ? {
61675
+ description
61676
+ } : {},
61677
+ ...message.tool_use_id ? {
61678
+ parentToolCallId: message.tool_use_id
61679
+ } : {},
61680
+ ...summary ? {
61681
+ summary
61682
+ } : {},
61683
+ ...error ? {
61684
+ error
61685
+ } : {},
61686
+ ...lastToolName ? {
61687
+ lastToolName
61688
+ } : {},
61689
+ ...usage ? {
61690
+ usage
61691
+ } : {},
61692
+ ...message.skip_transcript !== void 0 ? {
61693
+ skipTranscript: message.skip_transcript
61694
+ } : {}
61695
+ };
61696
+ const update = {
61697
+ toolCallId: `task:${message.task_id}`,
61698
+ title: description ? `${actor}: ${cleanTaskText(description, 160)}` : actor,
61699
+ kind: "think",
61700
+ status: task.status,
61701
+ _meta: {
61702
+ lody: {
61703
+ task
61704
+ }
61705
+ }
61706
+ };
61707
+ return message.subtype === "task_started" ? {
61708
+ sessionUpdate: "tool_call",
61709
+ ...update
61710
+ } : {
61711
+ sessionUpdate: "tool_call_update",
61712
+ ...update
61713
+ };
61714
+ }
61613
61715
  const DEFAULT_CONTEXT_WINDOW = 2e5;
61614
- const CLAUDE_TASK_LIFECYCLE_METHOD = "_claude/taskLifecycle";
61615
- const CLAUDE_STEER_APPLIED_METHOD = "_claude/steerApplied";
61716
+ const CLAUDE_STEER_APPLIED_METHOD = LODY_EXTENSION_METHODS.sessionSteerApplied;
61717
+ const CLAUDE_LODY_CAPABILITIES = {
61718
+ usage: {
61719
+ version: 1
61720
+ },
61721
+ rateLimits: {
61722
+ version: 1,
61723
+ query: true
61724
+ },
61725
+ forkAtTurn: {
61726
+ version: 1
61727
+ },
61728
+ steering: {
61729
+ version: 1,
61730
+ transport: "prompt",
61731
+ upstreamTurn: "handoff",
61732
+ configPolicy: "apply"
61733
+ },
61734
+ tasks: {
61735
+ version: 1,
61736
+ background: true
61737
+ },
61738
+ subagents: {
61739
+ version: 1,
61740
+ lifecycle: true
61741
+ },
61742
+ goal: {
61743
+ version: 1,
61744
+ actions: GOAL_ACTIONS
61745
+ },
61746
+ compaction: {
61747
+ version: 1
61748
+ }
61749
+ };
61616
61750
  const DEFAULT_FORCE_CANCEL_GRACE_MS = 3e4;
61617
61751
  const TURN_NO_RESULT_MESSAGE = "The turn ended without a result: the agent went idle while this prompt was still in flight (e.g. the model stream dropped mid-turn). Any partial output may be incomplete; please retry.";
61618
- const STEER_METHOD = "_session/steering";
61619
61752
  function getLodyForkTurnId(meta) {
61620
61753
  if (!meta || typeof meta !== "object") return void 0;
61621
61754
  const lody = meta.lody;
@@ -61627,34 +61760,38 @@ ${content.text}
61627
61760
  return version === 1 && typeof turnId === "string" && turnId.length > 0 ? turnId : void 0;
61628
61761
  }
61629
61762
  const STEER_PRIORITY = "now";
61630
- function parseSteerRequest(params) {
61631
- if (!params || typeof params !== "object") {
61632
- throw RequestError.invalidParams(void 0, "steer params must be an object");
61763
+ function parseRateLimitsGetRequest(params) {
61764
+ if (!params || typeof params !== "object" || Array.isArray(params)) {
61765
+ throw RequestError.invalidParams(void 0, "rate limit params must be an object");
61633
61766
  }
61634
- const { sessionId, prompt, _meta } = params;
61635
- if (typeof sessionId !== "string" || sessionId.length === 0) {
61636
- throw RequestError.invalidParams(void 0, "steer params require a non-empty sessionId");
61637
- }
61638
- if (!Array.isArray(prompt) || prompt.length === 0) {
61639
- throw RequestError.invalidParams(void 0, "steer params require a non-empty prompt array");
61640
- }
61641
- const steering = _meta && typeof _meta === "object" ? _meta.steering : void 0;
61642
- const idleBehavior = steering && typeof steering === "object" ? steering.idleBehavior : void 0;
61643
- if (idleBehavior !== void 0 && idleBehavior !== "promptRequired") {
61644
- throw RequestError.invalidParams(void 0, "unsupported steering idleBehavior");
61767
+ const { sessionId, accountId, modelId } = params;
61768
+ for (const [name, value] of Object.entries({
61769
+ sessionId,
61770
+ accountId,
61771
+ modelId
61772
+ })) {
61773
+ if (value !== void 0 && typeof value !== "string") {
61774
+ throw RequestError.invalidParams(void 0, `${name} must be a string`);
61775
+ }
61645
61776
  }
61646
61777
  return {
61647
- sessionId,
61648
- prompt,
61649
- _meta
61778
+ ...typeof sessionId === "string" ? {
61779
+ sessionId
61780
+ } : {},
61781
+ ...typeof accountId === "string" ? {
61782
+ accountId
61783
+ } : {},
61784
+ ...typeof modelId === "string" ? {
61785
+ modelId
61786
+ } : {}
61650
61787
  };
61651
61788
  }
61652
61789
  function getClientSteerId(meta) {
61653
- const claudeCode = meta?.claudeCode;
61654
- if (typeof claudeCode !== "object" || claudeCode === null) {
61790
+ const lody = meta?.lody;
61791
+ if (typeof lody !== "object" || lody === null) {
61655
61792
  return void 0;
61656
61793
  }
61657
- const steer = claudeCode.steer;
61794
+ const steer = lody.steer;
61658
61795
  if (typeof steer !== "object" || steer === null) {
61659
61796
  return void 0;
61660
61797
  }
@@ -62164,18 +62301,7 @@ ${content.text}
62164
62301
  protocolVersion: 1,
62165
62302
  agentCapabilities: {
62166
62303
  _meta: {
62167
- claudeCode: {
62168
- promptQueueing: true,
62169
- steer: {
62170
- version: 1,
62171
- appliedNotification: CLAUDE_STEER_APPLIED_METHOD
62172
- }
62173
- },
62174
- lody: {
62175
- forkAtTurn: {
62176
- version: 1
62177
- }
62178
- }
62304
+ lody: CLAUDE_LODY_CAPABILITIES
62179
62305
  },
62180
62306
  promptCapabilities: {
62181
62307
  image: true,
@@ -62212,20 +62338,16 @@ ${content.text}
62212
62338
  ] : []
62213
62339
  ],
62214
62340
  _meta: {
62215
- ...airSessionFailureCapabilityMeta(AGENT_FILE_CHANGE_REPORT_CAPABILITY),
62216
- steering: {
62217
- supported: true
62218
- },
62219
- goal: {
62220
- version: GOAL_EXTENSION_VERSION,
62221
- controlMethod: GOAL_CONTROL_METHOD,
62222
- actions: [
62223
- ...GOAL_ACTIONS
62224
- ]
62225
- }
62341
+ ...airSessionFailureCapabilityMeta(AGENT_FILE_CHANGE_REPORT_CAPABILITY)
62226
62342
  }
62227
62343
  };
62228
62344
  }
62345
+ async getRateLimits(_request) {
62346
+ return await getUsage() ?? {
62347
+ rateLimits: [],
62348
+ fetchedAtEpochSeconds: Math.floor(Date.now() / 1e3)
62349
+ };
62350
+ }
62229
62351
  async newSession(params) {
62230
62352
  if (this.providerUpdate) await this.providerUpdate;
62231
62353
  const response = await this.createSession(params, {
@@ -62479,13 +62601,9 @@ ${content.text}
62479
62601
  const steering = await this.steer({
62480
62602
  sessionId: params.sessionId,
62481
62603
  prompt,
62482
- _meta: {
62483
- steering: {
62484
- idleBehavior: "promptRequired"
62485
- }
62486
- }
62604
+ steerId: randomUUID$1()
62487
62605
  });
62488
- if (steering.outcome === "promptRequired") {
62606
+ if (steering.outcome === "failed") {
62489
62607
  await this.prompt({
62490
62608
  sessionId: params.sessionId,
62491
62609
  prompt
@@ -62503,7 +62621,9 @@ ${content.text}
62503
62621
  update: {
62504
62622
  sessionUpdate: "session_info_update",
62505
62623
  _meta: {
62506
- goal
62624
+ lody: {
62625
+ goal
62626
+ }
62507
62627
  }
62508
62628
  }
62509
62629
  });
@@ -62555,26 +62675,15 @@ ${content.text}
62555
62675
  }
62556
62676
  const turnInFlight = (session.turnQueue ?? []).find((turn) => !turn.settled);
62557
62677
  if (!turnInFlight) {
62558
- const promptRequest2 = {
62559
- sessionId,
62560
- prompt: params.prompt
62561
- };
62562
- if (params._meta?.steering?.idleBehavior === "promptRequired") {
62563
- return {
62564
- outcome: "promptRequired",
62565
- reason: "noRunningTurn"
62566
- };
62567
- }
62568
- this.prompt(promptRequest2).catch((error) => {
62569
- this.logger.error(`Session ${sessionId}: steered new turn failed: ${error}`);
62570
- });
62571
62678
  return {
62572
- outcome: "startedNewTurn"
62679
+ outcome: "failed"
62573
62680
  };
62574
62681
  }
62575
62682
  const promptRequest = {
62576
62683
  sessionId,
62577
- prompt: params.prompt
62684
+ prompt: [
62685
+ ...params.prompt
62686
+ ]
62578
62687
  };
62579
62688
  const userMessage = promptToClaude(promptRequest);
62580
62689
  const steeredUuid = randomUUID$1();
@@ -62616,7 +62725,7 @@ ${content.text}
62616
62725
  let lastAssistantWasUsageLimit = false;
62617
62726
  let lastAssistantFailureTitle;
62618
62727
  let lastRefusalExplanation = null;
62619
- let compactionInProgress = false;
62728
+ let compactionInProgress = null;
62620
62729
  let currentStreamMessageId;
62621
62730
  const streamedBlocks = [];
62622
62731
  const streamedToolInputs = /* @__PURE__ */ new Map();
@@ -62678,7 +62787,7 @@ ${content.text}
62678
62787
  lastAssistantWasUsageLimit = false;
62679
62788
  lastAssistantFailureTitle = void 0;
62680
62789
  lastRefusalExplanation = null;
62681
- compactionInProgress = false;
62790
+ compactionInProgress = null;
62682
62791
  stopReason = "end_turn";
62683
62792
  session.accumulatedUsage = {
62684
62793
  inputTokens: 0,
@@ -62876,15 +62985,11 @@ ${content.text}
62876
62985
  }
62877
62986
  };
62878
62987
  const emitTaskLifecycle = async (message) => {
62879
- const extNotification = this.client.extNotification?.bind(this.client);
62880
- if (!extNotification) {
62881
- return;
62882
- }
62883
62988
  const acpSessionId = "session_id" in message && typeof message.session_id === "string" ? message.session_id : params.sessionId;
62884
- await extNotification(CLAUDE_TASK_LIFECYCLE_METHOD, {
62885
- sessionId: params.sessionId,
62886
- acpSessionId,
62887
- message
62989
+ const isSubagent = !!message.subagent_type || session.liveBackgroundTasks.get(message.task_id)?.isSubagent;
62990
+ await sendUpdate({
62991
+ sessionId: acpSessionId,
62992
+ update: createClaudeTaskLifecycleUpdate(message, isSubagent === true)
62888
62993
  });
62889
62994
  };
62890
62995
  let cancelController = session.cancelController;
@@ -63050,41 +63155,73 @@ ${content.text}
63050
63155
  break;
63051
63156
  case "status": {
63052
63157
  if (message.status === "compacting") {
63053
- compactionInProgress = true;
63158
+ const id2 = `context-compaction:${randomUUID$1()}`;
63159
+ compactionInProgress = {
63160
+ id: id2
63161
+ };
63162
+ const activity = {
63163
+ version: 1,
63164
+ kind: "context_compaction",
63165
+ automatic: false,
63166
+ ...lastAssistantTotalUsage === null ? {} : {
63167
+ usedTokensBefore: lastAssistantTotalUsage
63168
+ }
63169
+ };
63054
63170
  await sendUpdate({
63055
63171
  sessionId: message.session_id,
63056
63172
  update: {
63057
- sessionUpdate: "agent_message_chunk",
63058
- content: {
63059
- type: "text",
63060
- text: "Compacting..."
63173
+ sessionUpdate: "tool_call",
63174
+ toolCallId: id2,
63175
+ title: "Compacting context",
63176
+ kind: "think",
63177
+ status: "in_progress",
63178
+ _meta: {
63179
+ lody: {
63180
+ activity
63181
+ }
63061
63182
  }
63062
63183
  }
63063
63184
  });
63064
63185
  } else if (message.compact_result === "success" && compactionInProgress) {
63065
- compactionInProgress = false;
63066
63186
  await sendUpdate({
63067
63187
  sessionId: message.session_id,
63068
63188
  update: {
63069
- sessionUpdate: "agent_message_chunk",
63070
- content: {
63071
- type: "text",
63072
- text: "\n\nCompacting completed."
63189
+ sessionUpdate: "tool_call_update",
63190
+ toolCallId: compactionInProgress.id,
63191
+ title: "Context compacted",
63192
+ status: "completed",
63193
+ _meta: {
63194
+ lody: {
63195
+ activity: {
63196
+ version: 1,
63197
+ kind: "context_compaction",
63198
+ automatic: false
63199
+ }
63200
+ }
63073
63201
  }
63074
63202
  }
63075
63203
  });
63076
63204
  } else if (message.compact_result === "failed" && compactionInProgress) {
63077
- compactionInProgress = false;
63078
- const reason = message.compact_error ? `: ${message.compact_error}` : ".";
63205
+ const { id: id2 } = compactionInProgress;
63206
+ compactionInProgress = null;
63079
63207
  await sendUpdate({
63080
63208
  sessionId: message.session_id,
63081
63209
  update: {
63082
- sessionUpdate: "agent_message_chunk",
63083
- content: {
63084
- type: "text",
63085
- text: `
63086
-
63087
- Compacting failed${reason}`
63210
+ sessionUpdate: "tool_call_update",
63211
+ toolCallId: id2,
63212
+ title: "Context compaction failed",
63213
+ status: "failed",
63214
+ _meta: {
63215
+ lody: {
63216
+ activity: {
63217
+ version: 1,
63218
+ kind: "context_compaction",
63219
+ automatic: false,
63220
+ ...message.compact_error ? {
63221
+ failureReason: message.compact_error
63222
+ } : {}
63223
+ }
63224
+ }
63088
63225
  }
63089
63226
  }
63090
63227
  });
@@ -63095,6 +63232,29 @@ Compacting failed${reason}`
63095
63232
  const usedTokens = await fetchContextUsedTokens(session.query, this.logger);
63096
63233
  lastAssistantUsage = null;
63097
63234
  lastAssistantTotalUsage = usedTokens ?? 0;
63235
+ const compaction = compactionInProgress;
63236
+ const id2 = compaction?.id ?? `context-compaction:${randomUUID$1()}`;
63237
+ await sendUpdate({
63238
+ sessionId: message.session_id,
63239
+ update: {
63240
+ sessionUpdate: compaction ? "tool_call_update" : "tool_call",
63241
+ toolCallId: id2,
63242
+ title: "Context compacted",
63243
+ kind: "think",
63244
+ status: "completed",
63245
+ _meta: {
63246
+ lody: {
63247
+ activity: {
63248
+ version: 1,
63249
+ kind: "context_compaction",
63250
+ automatic: compaction === null,
63251
+ usedTokensAfter: lastAssistantTotalUsage
63252
+ }
63253
+ }
63254
+ }
63255
+ }
63256
+ });
63257
+ compactionInProgress = null;
63098
63258
  await sendUpdate({
63099
63259
  sessionId: message.session_id,
63100
63260
  update: {
@@ -63181,6 +63341,9 @@ Compacting failed${reason}`
63181
63341
  content
63182
63342
  },
63183
63343
  _meta: {
63344
+ lody: {
63345
+ toolName: "memory_recall"
63346
+ },
63184
63347
  claudeCode: {
63185
63348
  toolName: "memory_recall",
63186
63349
  toolResponse: {
@@ -63228,6 +63391,9 @@ Compacting failed${reason}`
63228
63391
  }
63229
63392
  ],
63230
63393
  _meta: {
63394
+ lody: {
63395
+ toolName: message.tool_name
63396
+ },
63231
63397
  claudeCode: {
63232
63398
  toolName: message.tool_name,
63233
63399
  ...parentToolUseId ? {
@@ -63454,6 +63620,7 @@ ${explanation}` : fallbackSummary;
63454
63620
  };
63455
63621
  }
63456
63622
  const usages = {
63623
+ sessionId: params.sessionId,
63457
63624
  usage: {
63458
63625
  inputTokens: message.usage.input_tokens,
63459
63626
  outputTokens: message.usage.output_tokens,
@@ -63462,10 +63629,10 @@ ${explanation}` : fallbackSummary;
63462
63629
  },
63463
63630
  modelUsage
63464
63631
  };
63465
- await extNotification(EXT_METHOD_NAME.usage_update, usages);
63632
+ await extNotification(LODY_EXTENSION_METHODS.sessionUsageUpdate, usages);
63466
63633
  const limits = await getUsage();
63467
- if (limits && !limits.apiUnavailable) {
63468
- await extNotification(EXT_METHOD_NAME.rate_limits, limits);
63634
+ if (limits) {
63635
+ await extNotification(LODY_EXTENSION_METHODS.rateLimitsUpdate, limits);
63469
63636
  }
63470
63637
  }
63471
63638
  if (isAutonomousResult) {
@@ -63816,6 +63983,9 @@ ${explanation}` : fallbackSummary;
63816
63983
  toolCallId,
63817
63984
  status: "in_progress",
63818
63985
  _meta: {
63986
+ lody: {
63987
+ toolName: message.tool_name
63988
+ },
63819
63989
  claudeCode: {
63820
63990
  toolName: message.tool_name,
63821
63991
  toolResponse: {
@@ -63840,10 +64010,7 @@ ${explanation}` : fallbackSummary;
63840
64010
  update: {
63841
64011
  sessionUpdate: "usage_update",
63842
64012
  used: lastAssistantTotalUsage,
63843
- size: session.contextWindowSize,
63844
- _meta: {
63845
- "_claude/rateLimit": message.rate_limit_info
63846
- }
64013
+ size: session.contextWindowSize
63847
64014
  }
63848
64015
  });
63849
64016
  }
@@ -64370,14 +64537,17 @@ ${explanation}` : fallbackSummary;
64370
64537
  input: toolInput,
64371
64538
  id: toolUseID
64372
64539
  }, supportsTerminalOutput, session?.cwd),
64373
- ...parentToolUseId ? {
64374
- _meta: {
64375
- claudeCode: {
64376
- toolName,
64540
+ _meta: {
64541
+ lody: {
64542
+ toolName
64543
+ },
64544
+ claudeCode: {
64545
+ toolName,
64546
+ ...parentToolUseId ? {
64377
64547
  parentToolUseId
64378
- }
64548
+ } : {}
64379
64549
  }
64380
- } : {}
64550
+ }
64381
64551
  }
64382
64552
  }, toolName, signal, parentToolUseId);
64383
64553
  if (signal.aborted || response2.outcome?.outcome === "cancelled") {
@@ -64460,14 +64630,17 @@ ${explanation}` : fallbackSummary;
64460
64630
  input: toolInput,
64461
64631
  id: toolUseID
64462
64632
  }, supportsTerminalOutput, session?.cwd),
64463
- ...parentToolUseId ? {
64464
- _meta: {
64465
- claudeCode: {
64466
- toolName,
64633
+ _meta: {
64634
+ lody: {
64635
+ toolName
64636
+ },
64637
+ claudeCode: {
64638
+ toolName,
64639
+ ...parentToolUseId ? {
64467
64640
  parentToolUseId
64468
- }
64641
+ } : {}
64469
64642
  }
64470
- } : {}
64643
+ }
64471
64644
  }
64472
64645
  }, toolName, signal, parentToolUseId);
64473
64646
  if (signal.aborted || response.outcome?.outcome === "cancelled") {
@@ -65971,12 +66144,18 @@ ${chunk.resource.text}
65971
66144
  addCandidates(os$2.homedir());
65972
66145
  return candidates.find((candidate) => existsSync$1(candidate));
65973
66146
  }
66147
+ function toolMetaFromToolUse(toolUse, cwd2) {
66148
+ return {
66149
+ lody: {
66150
+ toolName: toolUse.name
66151
+ },
66152
+ claudeCode: claudeCodeMetaFromToolUse(toolUse, cwd2)
66153
+ };
66154
+ }
65974
66155
  function toolCallNotification(toolUse, rawInput, supportsTerminalOutput, cwd2, refine = false) {
65975
66156
  if (refine) {
65976
66157
  return {
65977
- _meta: {
65978
- claudeCode: claudeCodeMetaFromToolUse(toolUse, cwd2)
65979
- },
66158
+ _meta: toolMetaFromToolUse(toolUse, cwd2),
65980
66159
  toolCallId: toolUse.id,
65981
66160
  sessionUpdate: "tool_call_update",
65982
66161
  rawInput,
@@ -65985,7 +66164,7 @@ ${chunk.resource.text}
65985
66164
  }
65986
66165
  return {
65987
66166
  _meta: {
65988
- claudeCode: claudeCodeMetaFromToolUse(toolUse, cwd2),
66167
+ ...toolMetaFromToolUse(toolUse, cwd2),
65989
66168
  ...toolUse.name === "Bash" && supportsTerminalOutput ? {
65990
66169
  terminal_info: {
65991
66170
  terminal_id: toolUse.id
@@ -66144,6 +66323,9 @@ ${chunk.resource.text}
66144
66323
  const editDiff = toolName === "Edit" || toolName === "Write" ? toolUpdateFromDiffToolResponse(toolResponse) : {};
66145
66324
  const update2 = {
66146
66325
  _meta: {
66326
+ lody: {
66327
+ toolName
66328
+ },
66147
66329
  claudeCode: {
66148
66330
  toolResponse,
66149
66331
  toolName
@@ -66151,6 +66333,7 @@ ${chunk.resource.text}
66151
66333
  },
66152
66334
  toolCallId: toolUseId,
66153
66335
  sessionUpdate: "tool_call_update",
66336
+ rawOutput: toolResponse,
66154
66337
  ...editDiff
66155
66338
  };
66156
66339
  await client.sessionUpdate({
@@ -66212,6 +66395,9 @@ ${chunk.resource.text}
66212
66395
  sessionId,
66213
66396
  update: {
66214
66397
  _meta: {
66398
+ lody: {
66399
+ toolName: toolUse.name
66400
+ },
66215
66401
  claudeCode: {
66216
66402
  toolName: toolUse.name,
66217
66403
  ...nonExecution ?? {},
@@ -66276,6 +66462,9 @@ ${chunk.resource.text}
66276
66462
  }
66277
66463
  update = {
66278
66464
  _meta: {
66465
+ lody: {
66466
+ toolName: toolUse.name
66467
+ },
66279
66468
  claudeCode: {
66280
66469
  toolName: toolUse.name,
66281
66470
  ...nonExecution ?? {}
@@ -66451,9 +66640,7 @@ ${chunk.resource.text}
66451
66640
  let agent2;
66452
66641
  const connection2 = agent$1({
66453
66642
  name: "claude-code-acp"
66454
- }).onRequest(methods.agent.initialize, (ctx) => agent2.initialize(ctx.params)).onRequest(methods.agent.session.new, (ctx) => agent2.newSession(ctx.params)).onRequest(methods.agent.session.load, (ctx) => agent2.loadSession(ctx.params)).onRequest(methods.agent.session.fork, (ctx) => agent2.unstable_forkSession(ctx.params)).onRequest(methods.agent.session.list, (ctx) => agent2.listSessions(ctx.params)).onRequest(methods.agent.session.delete, (ctx) => agent2.deleteSession(ctx.params)).onRequest(methods.agent.session.resume, (ctx) => agent2.resumeSession(ctx.params)).onRequest(methods.agent.session.close, (ctx) => agent2.closeSession(ctx.params)).onRequest(methods.agent.session.setMode, (ctx) => agent2.setSessionMode(ctx.params)).onRequest(methods.agent.session.setConfigOption, (ctx) => agent2.setSessionConfigOption(ctx.params)).onRequest(methods.agent.authenticate, (ctx) => agent2.authenticate(ctx.params)).onRequest(methods.agent.providers.list, (ctx) => agent2.unstable_listProviders(ctx.params)).onRequest(methods.agent.providers.set, (ctx) => agent2.unstable_setProvider(ctx.params)).onRequest(methods.agent.providers.disable, (ctx) => agent2.unstable_disableProvider(ctx.params)).onRequest(methods.agent.logout, (ctx) => agent2.logout(ctx.params)).onRequest(methods.agent.session.prompt, (ctx) => runPromptWithCancellation(agent2, ctx.params, ctx.signal)).onNotification(methods.agent.session.cancel, (ctx) => agent2.cancel(ctx.params)).onRequest(STEER_METHOD, {
66455
- parse: parseSteerRequest
66456
- }, (ctx) => agent2.steer(ctx.params)).onRequest(GOAL_CONTROL_METHOD, {
66643
+ }).onRequest(methods.agent.initialize, (ctx) => agent2.initialize(ctx.params)).onRequest(methods.agent.session.new, (ctx) => agent2.newSession(ctx.params)).onRequest(methods.agent.session.load, (ctx) => agent2.loadSession(ctx.params)).onRequest(methods.agent.session.fork, (ctx) => agent2.unstable_forkSession(ctx.params)).onRequest(methods.agent.session.list, (ctx) => agent2.listSessions(ctx.params)).onRequest(methods.agent.session.delete, (ctx) => agent2.deleteSession(ctx.params)).onRequest(methods.agent.session.resume, (ctx) => agent2.resumeSession(ctx.params)).onRequest(methods.agent.session.close, (ctx) => agent2.closeSession(ctx.params)).onRequest(methods.agent.session.setMode, (ctx) => agent2.setSessionMode(ctx.params)).onRequest(methods.agent.session.setConfigOption, (ctx) => agent2.setSessionConfigOption(ctx.params)).onRequest(methods.agent.authenticate, (ctx) => agent2.authenticate(ctx.params)).onRequest(methods.agent.providers.list, (ctx) => agent2.unstable_listProviders(ctx.params)).onRequest(methods.agent.providers.set, (ctx) => agent2.unstable_setProvider(ctx.params)).onRequest(methods.agent.providers.disable, (ctx) => agent2.unstable_disableProvider(ctx.params)).onRequest(methods.agent.logout, (ctx) => agent2.logout(ctx.params)).onRequest(LODY_EXTENSION_METHODS.rateLimitsGet, parseRateLimitsGetRequest, (ctx) => agent2.getRateLimits(ctx.params)).onRequest(methods.agent.session.prompt, (ctx) => runPromptWithCancellation(agent2, ctx.params, ctx.signal)).onNotification(methods.agent.session.cancel, (ctx) => agent2.cancel(ctx.params)).onRequest(GOAL_CONTROL_METHOD, {
66457
66644
  parse: parseGoalRequest
66458
66645
  }, (ctx) => agent2.goal(ctx.params)).connect(stream);
66459
66646
  agent2 = new ClaudeAcpAgent(new ClientConnection(connection2.client), logger);