@ellipsis-dev/sdk 0.27.0 → 0.28.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.
@@ -1,4 +1,4 @@
1
- import { W as SessionRecord, a7 as CodexFileChangeItem, a as CodexEvent, a8 as CodexMcpToolCallItem, w as SdkRecord, J as Session, Q as SessionMessage, a4 as StreamFrame } from '../types-ClEF_IA9.js';
1
+ import { cp as SessionRecord, L as CodexFileChangeItem, J as CodexEvent, Y as CodexMcpToolCallItem, bK as SdkRecord, bW as Session, cj as SessionMessage, cO as StreamFrame } from '../types-B-jIFh4_.js';
2
2
 
3
3
  interface ChatToolNode {
4
4
  key: string;
@@ -100,6 +100,7 @@ interface TranscriptItem {
100
100
  input?: Record<string, unknown>;
101
101
  };
102
102
  loading?: boolean;
103
+ summary?: boolean;
103
104
  }
104
105
  declare function oneLine(text: string, max: number): string;
105
106
  declare function summarizeToolInput(name: string, input: unknown): string;
@@ -179,6 +180,8 @@ declare function cacheTierLabel(tier: unknown): string | null;
179
180
  declare function sandboxPhaseLabel(phase: unknown): string;
180
181
  declare function lifecycleText(recordType: string, payload: Record<string, unknown>): string | null;
181
182
 
183
+ declare function claudePayload(record: SessionRecord): SdkRecord | null;
184
+
182
185
  declare function isConversationOver(session: Session): boolean;
183
186
  interface SessionTranscriptSnapshot {
184
187
  session: Session | null;
@@ -215,4 +218,4 @@ declare class SessionTranscriptStore {
215
218
  ingest: (rawFrame: StreamFrame) => void;
216
219
  }
217
220
 
218
- export { BRANCH_GLYPH, type ChatNode, type ChatToolNode, type ChatTurn, type EntryBody, type EventToItemsOptions, type ItemKind, LIVE_GLYPH, type LedgerEntry, type PlacedItem, type RecordSlice, SESSION_WAKING, type SandboxLogKind, type SandboxLogLine, type SandboxState, type SessionTranscriptSnapshot, SessionTranscriptStore, StreamFrame, type TranscriptItem, USER_BAR, awaitingAgentPhase, cacheTierLabel, chatTurnsToItems, clampLines, codexChangedPaths, codexEventToItems, codexMcpToolName, collapseToolRuns, deliveredUnechoedSends, deriveSandboxState, emptySessionTranscriptSnapshot, entryBody, entrySeconds, eventToItems, foldCosts, foldGutter, foldRun, formatDuration, groupRecordsToChatTurns, gutterFor, hookPhrase, humanDuration, isConnectVisibleRecord, isConversationOver, isFoldable, isToolActivity, isToolFold, lastLines, layOutItems, lifecycleText, oneLine, pendingToolCalls, recordSlice, recordToItems, resultCostUsd, sandboxOutputLine, sandboxOutputLines, sandboxOutputStep, sandboxPhaseLabel, sandboxSummary, seedTranscriptStore, sessionLogText, splitLedger, startupHeadline, startupSettled, statusActivityText, summarizeToolInput, tailLines, toolResultText, toolRunMembers };
221
+ export { BRANCH_GLYPH, type ChatNode, type ChatToolNode, type ChatTurn, type EntryBody, type EventToItemsOptions, type ItemKind, LIVE_GLYPH, type LedgerEntry, type PlacedItem, type RecordSlice, SESSION_WAKING, type SandboxLogKind, type SandboxLogLine, type SandboxState, type SessionTranscriptSnapshot, SessionTranscriptStore, StreamFrame, type TranscriptItem, USER_BAR, awaitingAgentPhase, cacheTierLabel, chatTurnsToItems, clampLines, claudePayload, codexChangedPaths, codexEventToItems, codexMcpToolName, collapseToolRuns, deliveredUnechoedSends, deriveSandboxState, emptySessionTranscriptSnapshot, entryBody, entrySeconds, eventToItems, foldCosts, foldGutter, foldRun, formatDuration, groupRecordsToChatTurns, gutterFor, hookPhrase, humanDuration, isConnectVisibleRecord, isConversationOver, isFoldable, isToolActivity, isToolFold, lastLines, layOutItems, lifecycleText, oneLine, pendingToolCalls, recordSlice, recordToItems, resultCostUsd, sandboxOutputLine, sandboxOutputLines, sandboxOutputStep, sandboxPhaseLabel, sandboxSummary, seedTranscriptStore, sessionLogText, splitLedger, startupHeadline, startupSettled, statusActivityText, summarizeToolInput, tailLines, toolResultText, toolRunMembers };
@@ -1,6 +1,107 @@
1
1
  import {
2
2
  SESSION_STREAM_PROTOCOL_VERSION
3
- } from "../chunk-RMPAMUAE.js";
3
+ } from "../chunk-YJC53TA7.js";
4
+
5
+ // src/store/claude.ts
6
+ function claudePayload(record) {
7
+ if (record.kind === "claude_sdk") return record.payload;
8
+ if (record.kind !== "claude_code") return null;
9
+ const event = record.payload;
10
+ switch (event.type) {
11
+ case "assistant":
12
+ return {
13
+ ...event.message,
14
+ kind: "assistant",
15
+ message_id: event.message.id,
16
+ parent_tool_use_id: event.parent_tool_use_id
17
+ };
18
+ case "user":
19
+ return {
20
+ kind: "user",
21
+ content: event.message.content,
22
+ uuid: event.uuid,
23
+ parent_tool_use_id: event.parent_tool_use_id
24
+ };
25
+ case "system":
26
+ return {
27
+ kind: "system",
28
+ subtype: event.subtype,
29
+ data: event,
30
+ session_id: event.session_id,
31
+ uuid: event.uuid
32
+ };
33
+ case "result":
34
+ return {
35
+ ...event,
36
+ kind: "result",
37
+ cost_usd: event.total_cost_usd,
38
+ model_usage: event.modelUsage
39
+ };
40
+ case "rate_limit_event":
41
+ return {
42
+ kind: "rate_limit",
43
+ status: event.rate_limit_info.status,
44
+ rate_limit_type: event.rate_limit_info.rateLimitType,
45
+ resets_at: event.rate_limit_info.resetsAt,
46
+ utilization: event.rate_limit_info.utilization
47
+ };
48
+ default:
49
+ return null;
50
+ }
51
+ }
52
+
53
+ // src/store/codexAppServer.ts
54
+ function codexAppServerContent(event) {
55
+ if (event.method === "turn/completed") {
56
+ return { kind: "end", isError: event.params.turn.status !== "completed" };
57
+ }
58
+ if (event.method === "error") {
59
+ return event.params.willRetry ? null : { kind: "error", text: event.params.error.message };
60
+ }
61
+ if (event.method !== "item/completed") return null;
62
+ const item = event.params.item;
63
+ switch (item.type) {
64
+ case "agentMessage":
65
+ case "plan":
66
+ return { kind: "assistant", text: item.text };
67
+ case "reasoning":
68
+ return {
69
+ kind: "thinking",
70
+ text: (item.summary?.length ? item.summary : item.content ?? []).join(
71
+ "\n"
72
+ )
73
+ };
74
+ case "commandExecution":
75
+ return {
76
+ kind: "tool",
77
+ name: "Bash",
78
+ input: { command: item.command },
79
+ summary: item.command,
80
+ result: item.aggregatedOutput?.trim() || "(no output)",
81
+ isError: item.status === "failed" || item.status === "declined" || typeof item.exitCode === "number" && item.exitCode !== 0
82
+ };
83
+ case "fileChange":
84
+ return {
85
+ kind: "tool",
86
+ name: "Edit",
87
+ input: { changes: item.changes },
88
+ summary: item.changes.map((change) => change.path).join(", "),
89
+ result: item.changes.map((change) => change.diff).join("\n"),
90
+ isError: item.status === "failed" || item.status === "declined"
91
+ };
92
+ case "webSearch":
93
+ return {
94
+ kind: "tool",
95
+ name: "WebSearch",
96
+ input: { query: item.query },
97
+ summary: item.query,
98
+ result: null,
99
+ isError: false
100
+ };
101
+ default:
102
+ return null;
103
+ }
104
+ }
4
105
 
5
106
  // src/store/lifecycle.ts
6
107
  function sandboxOutputStep(payload) {
@@ -202,11 +303,11 @@ function eventToItems(event, keyBase, options = {}) {
202
303
  return items;
203
304
  }
204
305
  if (event.kind === "rate_limit") return items;
205
- const blocks = blocksOf(event.content);
306
+ const blocks = blocksOf(event.content ?? []);
206
307
  if (event.kind === "user") {
207
308
  for (const block of blocks) {
208
309
  if (block.type === "tool_result") {
209
- const body = toolResultText(block.content);
310
+ const body = toolResultText(block.content ?? null);
210
311
  push({
211
312
  kind: "tool_result",
212
313
  gutter: "\u23BF",
@@ -234,14 +335,14 @@ function eventToItems(event, keyBase, options = {}) {
234
335
  spaceBefore: true
235
336
  });
236
337
  } else if (block.type === "tool_use" || block.type === "server_tool_use") {
237
- const summary = summarizeToolInput(block.name, block.input);
338
+ const summary = summarizeToolInput(block.name, block.input ?? {});
238
339
  push({
239
340
  kind: "tool",
240
341
  gutter: "\u25CF",
241
342
  text: block.name,
242
343
  detail: summary ? `(${summary})` : void 0,
243
344
  spaceBefore: true,
244
- tool: { name: block.name, input: block.input }
345
+ tool: { name: block.name, input: block.input ?? {} }
245
346
  });
246
347
  } else if (block.type === "text" && block.text.trim()) {
247
348
  push({ kind: "assistant", text: block.text.trim(), spaceBefore: true });
@@ -276,7 +377,7 @@ function codexEventToItems(event, keyBase) {
276
377
  const item = event.item;
277
378
  switch (item.type) {
278
379
  case "agent_message": {
279
- const text = item.text.trim();
380
+ const text = (item.text ?? "").trim();
280
381
  if (text) push({ kind: "assistant", text, spaceBefore: true });
281
382
  break;
282
383
  }
@@ -289,7 +390,7 @@ function codexEventToItems(event, keyBase) {
289
390
  }
290
391
  case "command_execution": {
291
392
  const c = item;
292
- const summary = oneLine(c.command, 100);
393
+ const summary = oneLine(c.command ?? "", 100);
293
394
  push({
294
395
  kind: "tool",
295
396
  gutter: "\u25CF",
@@ -361,12 +462,61 @@ function codexMcpToolName(item) {
361
462
  return item.server && item.tool ? `mcp__${item.server}__${item.tool}` : item.tool ?? "mcp_tool_call";
362
463
  }
363
464
  function recordToItems(record, keyBase, options = {}) {
364
- switch (record.record_format) {
365
- case "claude_sdk@1":
366
- return eventToItems(record.payload, keyBase, options);
367
- case "codex_jsonl@1":
465
+ switch (record.kind) {
466
+ case "claude_sdk":
467
+ case "claude_code": {
468
+ const payload = claudePayload(record);
469
+ return payload ? eventToItems(payload, keyBase, options) : [];
470
+ }
471
+ case "codex":
368
472
  return codexEventToItems(record.payload, keyBase);
369
- case "ellipsis_lifecycle@1": {
473
+ case "codex_app_server": {
474
+ const content = codexAppServerContent(record.payload);
475
+ if (!content) return [];
476
+ if (content.kind === "end") {
477
+ return content.isError ? [
478
+ {
479
+ key: keyBase,
480
+ kind: "summary",
481
+ text: "turn ended with an error",
482
+ isError: true,
483
+ spaceBefore: true
484
+ }
485
+ ] : [];
486
+ }
487
+ if (content.kind === "tool") {
488
+ const summary = oneLine(content.summary, 100);
489
+ return [
490
+ {
491
+ key: `${keyBase}:0`,
492
+ kind: "tool",
493
+ gutter: "\u25CF",
494
+ text: content.name,
495
+ detail: summary ? `(${summary})` : void 0,
496
+ spaceBefore: true,
497
+ tool: { name: content.name, input: content.input ?? void 0 }
498
+ },
499
+ {
500
+ key: `${keyBase}:1`,
501
+ kind: "tool_result",
502
+ gutter: "\u23BF",
503
+ text: content.result || "(completed)",
504
+ isError: content.isError,
505
+ spaceBefore: false
506
+ }
507
+ ];
508
+ }
509
+ return content.text.trim() ? [
510
+ {
511
+ key: keyBase,
512
+ kind: content.kind,
513
+ text: content.text.trim(),
514
+ isError: content.kind === "error",
515
+ spaceBefore: true
516
+ }
517
+ ] : [];
518
+ }
519
+ case "platform": {
370
520
  const text = lifecycleText(record.record_type, record.payload);
371
521
  return text ? [{ key: keyBase, kind: "notice", text, spaceBefore: true }] : [];
372
522
  }
@@ -408,9 +558,11 @@ function foldLabel(group, settled) {
408
558
  return `Ran ${n} tool call${plural} (${shown})`;
409
559
  }
410
560
  function foldRun(group, loading) {
561
+ const thinkingOnly = group.every((i) => i.kind === "thinking");
411
562
  return {
412
563
  key: `grp:${group[0].key}`,
413
- kind: "notice",
564
+ kind: thinkingOnly ? "thinking" : "notice",
565
+ ...thinkingOnly ? { gutter: "\u273B" } : {},
414
566
  text: foldLabel(group, !loading),
415
567
  spaceBefore: true,
416
568
  ...loading ? { loading } : {}
@@ -511,7 +663,7 @@ function groupRecordsToChatTurns(records) {
511
663
  return turns[openIdx];
512
664
  };
513
665
  for (const record of records) {
514
- if (record.record_format === "ellipsis_lifecycle@1") {
666
+ if (record.kind === "platform") {
515
667
  const messageId = typeof record.payload.message_id === "string" ? record.payload.message_id : null;
516
668
  if (record.record_type === "message_received" && messageId) {
517
669
  const body = typeof record.payload.body === "string" ? record.payload.body : "";
@@ -606,7 +758,7 @@ function groupRecordsToChatTurns(records) {
606
758
  });
607
759
  continue;
608
760
  }
609
- if (record.record_format === "codex_jsonl@1") {
761
+ if (record.kind === "codex") {
610
762
  codexEventIntoTurns(record, record.payload, {
611
763
  openAgentTurn,
612
764
  closeTurn: (completedAt, isError) => {
@@ -620,7 +772,40 @@ function groupRecordsToChatTurns(records) {
620
772
  });
621
773
  continue;
622
774
  }
623
- const data = record.payload;
775
+ if (record.kind === "codex_app_server") {
776
+ const content = codexAppServerContent(record.payload);
777
+ if (!content) continue;
778
+ if (content.kind === "end") {
779
+ if (openIdx >= 0) {
780
+ turns[openIdx].completedAt = record.created_at;
781
+ if (content.isError) turns[openIdx].isError = true;
782
+ openIdx = -1;
783
+ }
784
+ } else if (content.kind === "tool") {
785
+ openAgentTurn(record).nodes.push({
786
+ key: nextKey(record.id),
787
+ kind: "tool",
788
+ name: content.name,
789
+ input: content.input,
790
+ summary: oneLine(content.summary, 100),
791
+ result: content.result,
792
+ isError: content.isError,
793
+ startedAt: record.created_at,
794
+ completedAt: record.created_at
795
+ });
796
+ } else if (content.text.trim()) {
797
+ const turn2 = openAgentTurn(record);
798
+ if (content.kind === "error") turn2.isError = true;
799
+ turn2.nodes.push({
800
+ key: nextKey(record.id),
801
+ kind: content.kind === "error" ? "assistant" : content.kind,
802
+ text: content.text.trim()
803
+ });
804
+ }
805
+ continue;
806
+ }
807
+ const data = claudePayload(record);
808
+ if (!data) continue;
624
809
  if (data.kind === "system") {
625
810
  if (isInitEvent(data)) {
626
811
  initCount += 1;
@@ -666,7 +851,7 @@ function groupRecordsToChatTurns(records) {
666
851
  }
667
852
  for (const block of content) {
668
853
  if (block.type !== "tool_result") continue;
669
- const body = toolResultText(block.content) || "(no output)";
854
+ const body = toolResultText(block.content ?? null) || "(no output)";
670
855
  const useId = block.tool_use_id;
671
856
  const node = toolNodeByUseId.get(useId);
672
857
  if (node) {
@@ -696,7 +881,7 @@ function groupRecordsToChatTurns(records) {
696
881
  if (data.usage && typeof data.usage.output_tokens === "number") {
697
882
  turn.tokens = (turn.tokens ?? 0) + data.usage.output_tokens;
698
883
  }
699
- for (const block of data.content) {
884
+ for (const block of data.content ?? []) {
700
885
  if (block.type === "thinking" && block.thinking.trim()) {
701
886
  turn.nodes.push({
702
887
  key: nextKey(record.id),
@@ -708,7 +893,7 @@ function groupRecordsToChatTurns(records) {
708
893
  key: nextKey(record.id),
709
894
  kind: "tool",
710
895
  name: block.name,
711
- input: block.input,
896
+ input: block.input ?? null,
712
897
  summary: summarizeToolInput(block.name, block.input),
713
898
  result: null,
714
899
  isError: false,
@@ -747,7 +932,7 @@ function codexEventIntoTurns(record, event, ops) {
747
932
  const turn = () => ops.openAgentTurn(record);
748
933
  switch (item.type) {
749
934
  case "agent_message": {
750
- const text = item.text.trim();
935
+ const text = (item.text ?? "").trim();
751
936
  if (text)
752
937
  turn().nodes.push({
753
938
  key: ops.nextKey(record.id),
@@ -774,7 +959,7 @@ function codexEventIntoTurns(record, event, ops) {
774
959
  kind: "tool",
775
960
  name: "Bash",
776
961
  input: { command: c.command },
777
- summary: oneLine(c.command, 100),
962
+ summary: oneLine(c.command ?? "", 100),
778
963
  result: (c.aggregated_output ?? "").trim() || "(no output)",
779
964
  isError: typeof c.exit_code === "number" && c.exit_code !== 0,
780
965
  startedAt: record.created_at,
@@ -1343,12 +1528,19 @@ function entryBody(entry, {
1343
1528
  const key = `grp:thought:${entry.key}`;
1344
1529
  if (thoughts.length) members.set(key, thoughts);
1345
1530
  if (live && liveText === "") {
1346
- items.push({ key, kind: "notice", text: "Thinking", spaceBefore: true });
1531
+ items.push({
1532
+ key,
1533
+ kind: "thinking",
1534
+ text: "Thinking",
1535
+ summary: true,
1536
+ spaceBefore: true
1537
+ });
1347
1538
  } else if (!live && thoughts.length) {
1348
1539
  items.push({
1349
1540
  key,
1350
- kind: "notice",
1541
+ kind: "thinking",
1351
1542
  text: `Thought for ${humanDuration(entrySeconds(entry, now))}`,
1543
+ summary: true,
1352
1544
  spaceBefore: true
1353
1545
  });
1354
1546
  }
@@ -1459,6 +1651,7 @@ var SessionTranscriptStore = class {
1459
1651
  // Fold one lifecycle record into the inbox projection; returns whether the
1460
1652
  // pending view changed. Unknown fields/types are ignored (§3.6).
1461
1653
  applyMessageRecord = (record) => {
1654
+ if (record.kind !== "platform") return false;
1462
1655
  const payload = record.payload;
1463
1656
  const messageId = typeof payload.message_id === "string" ? payload.message_id : null;
1464
1657
  switch (record.record_type) {
@@ -1591,6 +1784,7 @@ export {
1591
1784
  cacheTierLabel,
1592
1785
  chatTurnsToItems,
1593
1786
  clampLines,
1787
+ claudePayload,
1594
1788
  codexChangedPaths,
1595
1789
  codexEventToItems,
1596
1790
  codexMcpToolName,
@@ -1,6 +1,6 @@
1
- import { a4 as StreamFrame, J as Session } from '../types-ClEF_IA9.js';
1
+ import { cO as StreamFrame, bW as Session } from '../types-B-jIFh4_.js';
2
2
 
3
- declare const SESSION_STREAM_PROTOCOL_VERSION = 3;
3
+ declare const SESSION_STREAM_PROTOCOL_VERSION = 4;
4
4
  declare const WS_CLOSE_NORMAL = 1000;
5
5
  declare const WS_CLOSE_GOING_AWAY = 1001;
6
6
  declare const WS_CLOSE_UNSUPPORTED_PROTOCOL_VERSION = 1002;
@@ -15,7 +15,7 @@ import {
15
15
  sessionStatusWord,
16
16
  streamQuery,
17
17
  streamSession
18
- } from "../chunk-RMPAMUAE.js";
18
+ } from "../chunk-YJC53TA7.js";
19
19
  export {
20
20
  SESSION_STREAM_PROTOCOL_VERSION,
21
21
  StreamAuthError,