@ellipsis-dev/sdk 0.19.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.
- package/dist/store/index.d.ts +29 -8
- package/dist/store/index.js +163 -1
- package/package.json +1 -1
package/dist/store/index.d.ts
CHANGED
|
@@ -82,13 +82,6 @@ declare function deriveSandboxState(records: readonly RecordSlice[], minFeedSeq:
|
|
|
82
82
|
declare function sandboxSummary(sandbox: SandboxState | null): string;
|
|
83
83
|
declare function lastLines(log: readonly SandboxLogLine[], max: number): SandboxLogLine[];
|
|
84
84
|
|
|
85
|
-
declare function sandboxOutputStep(payload: Record<string, unknown>): string;
|
|
86
|
-
declare function sandboxOutputLines(payload: Record<string, unknown>): string[];
|
|
87
|
-
declare function sandboxOutputLine(payload: Record<string, unknown>): string | null;
|
|
88
|
-
declare function cacheTierLabel(tier: unknown): string | null;
|
|
89
|
-
declare function sandboxPhaseLabel(phase: unknown): string;
|
|
90
|
-
declare function lifecycleText(recordType: string, payload: Record<string, unknown>): string | null;
|
|
91
|
-
|
|
92
85
|
type ItemKind = 'assistant' | 'thinking' | 'tool' | 'tool_result' | 'summary' | 'system' | 'user' | 'notice' | 'error';
|
|
93
86
|
interface TranscriptItem {
|
|
94
87
|
key: string;
|
|
@@ -129,6 +122,34 @@ declare function foldCosts(events: SdkRecord[]): {
|
|
|
129
122
|
};
|
|
130
123
|
declare function statusActivityText(status: string): string | null;
|
|
131
124
|
|
|
125
|
+
declare const LIVE_GLYPH = "\u23FA";
|
|
126
|
+
declare const USER_BAR = "\u2503";
|
|
127
|
+
declare const BRANCH_GLYPH = "\u23BF";
|
|
128
|
+
declare function gutterFor(item: TranscriptItem): string;
|
|
129
|
+
declare function chatTurnsToItems(turns: readonly ChatTurn[]): TranscriptItem[];
|
|
130
|
+
declare function isToolFold(item: TranscriptItem): boolean;
|
|
131
|
+
declare function isToolActivity(item: TranscriptItem): boolean;
|
|
132
|
+
declare function isAgentSpeech(item: TranscriptItem): boolean;
|
|
133
|
+
type PlacedItem = {
|
|
134
|
+
item: TranscriptItem;
|
|
135
|
+
nested: boolean;
|
|
136
|
+
attach: boolean;
|
|
137
|
+
};
|
|
138
|
+
declare function layOutItems(items: readonly TranscriptItem[]): PlacedItem[];
|
|
139
|
+
declare function foldGutter(nested: boolean): string;
|
|
140
|
+
declare function tailLines(text: string, maxLines: number): {
|
|
141
|
+
body: string;
|
|
142
|
+
hidden: number;
|
|
143
|
+
};
|
|
144
|
+
declare function toolRunMembers(items: readonly TranscriptItem[]): Map<string, TranscriptItem[]>;
|
|
145
|
+
|
|
146
|
+
declare function sandboxOutputStep(payload: Record<string, unknown>): string;
|
|
147
|
+
declare function sandboxOutputLines(payload: Record<string, unknown>): string[];
|
|
148
|
+
declare function sandboxOutputLine(payload: Record<string, unknown>): string | null;
|
|
149
|
+
declare function cacheTierLabel(tier: unknown): string | null;
|
|
150
|
+
declare function sandboxPhaseLabel(phase: unknown): string;
|
|
151
|
+
declare function lifecycleText(recordType: string, payload: Record<string, unknown>): string | null;
|
|
152
|
+
|
|
132
153
|
declare function isConversationOver(session: Session): boolean;
|
|
133
154
|
interface SessionTranscriptSnapshot {
|
|
134
155
|
session: Session | null;
|
|
@@ -165,4 +186,4 @@ declare class SessionTranscriptStore {
|
|
|
165
186
|
ingest: (rawFrame: StreamFrame) => void;
|
|
166
187
|
}
|
|
167
188
|
|
|
168
|
-
export { type ChatNode, type ChatToolNode, type ChatTurn, type EventToItemsOptions, type ItemKind, type RecordSlice, type SandboxLogKind, type SandboxLogLine, type SandboxState, type SessionTranscriptSnapshot, SessionTranscriptStore, StreamFrame, type TranscriptItem, awaitingAgentPhase, cacheTierLabel, clampLines, codexChangedPaths, codexEventToItems, codexMcpToolName, collapseToolRuns, deliveredUnechoedSends, deriveSandboxState, emptySessionTranscriptSnapshot, eventToItems, foldCosts, formatDuration, groupRecordsToChatTurns, hookPhrase, humanDuration, isConnectVisibleRecord, isConversationOver, lastLines, lifecycleText, oneLine, pendingToolCalls, recordSlice, recordToItems, resultCostUsd, sandboxOutputLine, sandboxOutputLines, sandboxOutputStep, sandboxPhaseLabel, sandboxSummary, seedTranscriptStore, sessionLogText, statusActivityText, summarizeToolInput, toolResultText };
|
|
189
|
+
export { BRANCH_GLYPH, type ChatNode, type ChatToolNode, type ChatTurn, type EventToItemsOptions, type ItemKind, LIVE_GLYPH, type PlacedItem, type RecordSlice, 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, eventToItems, foldCosts, foldGutter, formatDuration, groupRecordsToChatTurns, gutterFor, hookPhrase, humanDuration, isAgentSpeech, isConnectVisibleRecord, isConversationOver, isToolActivity, isToolFold, lastLines, layOutItems, lifecycleText, oneLine, pendingToolCalls, recordSlice, recordToItems, resultCostUsd, sandboxOutputLine, sandboxOutputLines, sandboxOutputStep, sandboxPhaseLabel, sandboxSummary, seedTranscriptStore, sessionLogText, statusActivityText, summarizeToolInput, tailLines, toolResultText, toolRunMembers };
|
package/dist/store/index.js
CHANGED
|
@@ -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
|
-
|
|
1464
|
+
tailLines,
|
|
1465
|
+
toolResultText,
|
|
1466
|
+
toolRunMembers
|
|
1305
1467
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ellipsis-dev/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "TypeScript SDK for the Ellipsis agents platform: /v1 REST types + client, the session stream WebSocket client, and the session transcript store.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|