@ellipsis-dev/sdk 0.18.0 → 0.20.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.
@@ -1062,6 +1062,156 @@ function lastLines(log, max) {
1062
1062
  return log.length <= max ? [...log] : log.slice(log.length - max);
1063
1063
  }
1064
1064
 
1065
+ // src/store/layout.ts
1066
+ var LIVE_GLYPH = "\u23FA";
1067
+ var USER_BAR = "\u2503";
1068
+ var BRANCH_GLYPH = "\u23BF";
1069
+ function gutterFor(item) {
1070
+ if (item.kind === "user") return USER_BAR;
1071
+ if (item.kind === "assistant") return "\u25CF";
1072
+ if (item.kind === "system" || item.kind === "notice") return "\u2726";
1073
+ return item.gutter ?? "";
1074
+ }
1075
+ var SANDBOX_RECORD_TYPES2 = /* @__PURE__ */ new Set([
1076
+ "sandbox_starting",
1077
+ "sandbox_phase",
1078
+ "sandbox_output",
1079
+ "sandbox_ready"
1080
+ ]);
1081
+ function chatTurnsToItems(turns) {
1082
+ const items = [];
1083
+ let wakeAt = -1;
1084
+ for (const turn of turns) {
1085
+ if (turn.role === "lifecycle") {
1086
+ for (const node of turn.nodes) {
1087
+ if (node.kind !== "lifecycle") continue;
1088
+ if (SANDBOX_RECORD_TYPES2.has(node.recordType)) continue;
1089
+ if (node.recordType === "session_resumed" && wakeAt >= 0) {
1090
+ items[wakeAt] = { ...items[wakeAt], text: "Session awake" };
1091
+ wakeAt = -1;
1092
+ continue;
1093
+ }
1094
+ const text = sessionLogText(node.recordType, node.payload ?? {});
1095
+ if (!text) continue;
1096
+ items.push({ key: node.key, kind: "notice", text, spaceBefore: true });
1097
+ wakeAt = text === "Waking the session\u2026" ? items.length - 1 : -1;
1098
+ }
1099
+ continue;
1100
+ }
1101
+ if (turn.role === "user") {
1102
+ for (const node of turn.nodes) {
1103
+ if (node.kind === "user") {
1104
+ items.push({
1105
+ key: node.key,
1106
+ kind: "user",
1107
+ text: node.text,
1108
+ spaceBefore: true
1109
+ });
1110
+ }
1111
+ }
1112
+ continue;
1113
+ }
1114
+ for (const node of turn.nodes) {
1115
+ if (node.kind === "assistant") {
1116
+ items.push({
1117
+ key: node.key,
1118
+ kind: "assistant",
1119
+ text: node.text,
1120
+ spaceBefore: true
1121
+ });
1122
+ } else if (node.kind === "thinking") {
1123
+ items.push({
1124
+ key: node.key,
1125
+ kind: "thinking",
1126
+ gutter: "\u273B",
1127
+ text: node.text,
1128
+ spaceBefore: true
1129
+ });
1130
+ } else if (node.kind === "tool") {
1131
+ const orphan = node.name === "tool" && node.input === null && node.startedAt === null;
1132
+ if (!orphan) {
1133
+ items.push({
1134
+ key: node.key,
1135
+ kind: "tool",
1136
+ gutter: "\u25CF",
1137
+ text: node.name,
1138
+ detail: node.summary ? `(${node.summary})` : void 0,
1139
+ spaceBefore: true,
1140
+ tool: { name: node.name, input: node.input ?? void 0 }
1141
+ });
1142
+ }
1143
+ if (node.result !== null) {
1144
+ items.push({
1145
+ key: `${node.key}:r`,
1146
+ kind: "tool_result",
1147
+ gutter: BRANCH_GLYPH,
1148
+ text: node.result || "(no output)",
1149
+ spaceBefore: false,
1150
+ isError: node.isError || void 0
1151
+ });
1152
+ }
1153
+ }
1154
+ }
1155
+ if (turn.isError) {
1156
+ items.push({
1157
+ key: `${turn.key}:err`,
1158
+ kind: "summary",
1159
+ text: "turn ended with an error",
1160
+ spaceBefore: true,
1161
+ isError: true
1162
+ });
1163
+ }
1164
+ }
1165
+ return items;
1166
+ }
1167
+ function isToolFold(item) {
1168
+ return item.key.startsWith("grp:");
1169
+ }
1170
+ function isToolActivity(item) {
1171
+ return item.kind === "tool" || item.kind === "tool_result" || isToolFold(item);
1172
+ }
1173
+ function isAgentSpeech(item) {
1174
+ return item.kind === "assistant" || item.kind === "thinking";
1175
+ }
1176
+ function layOutItems(items) {
1177
+ const out = [];
1178
+ let nestUnder = false;
1179
+ for (const item of items) {
1180
+ if (!isToolActivity(item)) {
1181
+ out.push({ item, nested: false, attach: false });
1182
+ nestUnder = isAgentSpeech(item);
1183
+ continue;
1184
+ }
1185
+ out.push({ item, nested: nestUnder, attach: nestUnder });
1186
+ }
1187
+ return out;
1188
+ }
1189
+ function foldGutter(nested) {
1190
+ return nested ? BRANCH_GLYPH : "\u25CF";
1191
+ }
1192
+ function tailLines(text, maxLines) {
1193
+ const lines = text.split("\n");
1194
+ if (lines.length <= maxLines) return { body: text, hidden: 0 };
1195
+ return {
1196
+ body: lines.slice(lines.length - maxLines).join("\n"),
1197
+ hidden: lines.length - maxLines
1198
+ };
1199
+ }
1200
+ function toolRunMembers(items) {
1201
+ const out = /* @__PURE__ */ new Map();
1202
+ let group = [];
1203
+ const flush = () => {
1204
+ if (group.length > 0) out.set(`grp:${group[0].key}`, group);
1205
+ group = [];
1206
+ };
1207
+ for (const item of items) {
1208
+ if (item.kind === "tool" || item.kind === "tool_result") group.push(item);
1209
+ else flush();
1210
+ }
1211
+ flush();
1212
+ return out;
1213
+ }
1214
+
1065
1215
  // src/store/index.ts
1066
1216
  var TERMINAL_SESSION_STATUSES = /* @__PURE__ */ new Set([
1067
1217
  "completed",
@@ -1266,9 +1416,13 @@ var SessionTranscriptStore = class {
1266
1416
  };
1267
1417
  };
1268
1418
  export {
1419
+ BRANCH_GLYPH,
1420
+ LIVE_GLYPH,
1269
1421
  SessionTranscriptStore,
1422
+ USER_BAR,
1270
1423
  awaitingAgentPhase,
1271
1424
  cacheTierLabel,
1425
+ chatTurnsToItems,
1272
1426
  clampLines,
1273
1427
  codexChangedPaths,
1274
1428
  codexEventToItems,
@@ -1279,13 +1433,19 @@ export {
1279
1433
  emptySessionTranscriptSnapshot,
1280
1434
  eventToItems,
1281
1435
  foldCosts,
1436
+ foldGutter,
1282
1437
  formatDuration,
1283
1438
  groupRecordsToChatTurns,
1439
+ gutterFor,
1284
1440
  hookPhrase,
1285
1441
  humanDuration,
1442
+ isAgentSpeech,
1286
1443
  isConnectVisibleRecord,
1287
1444
  isConversationOver,
1445
+ isToolActivity,
1446
+ isToolFold,
1288
1447
  lastLines,
1448
+ layOutItems,
1289
1449
  lifecycleText,
1290
1450
  oneLine,
1291
1451
  pendingToolCalls,
@@ -1301,5 +1461,7 @@ export {
1301
1461
  sessionLogText,
1302
1462
  statusActivityText,
1303
1463
  summarizeToolInput,
1304
- toolResultText
1464
+ tailLines,
1465
+ toolResultText,
1466
+ toolRunMembers
1305
1467
  };
@@ -1,4 +1,4 @@
1
- import { a7 as StreamFrame, K as Session } from '../types-BLSh1Px1.js';
1
+ import { a7 as StreamFrame, K as Session } from '../types-D2YZTvgg.js';
2
2
 
3
3
  declare const SESSION_STREAM_PROTOCOL_VERSION = 3;
4
4
  declare const WS_CLOSE_NORMAL = 1000;