@ellipsis-dev/sdk 0.35.0 → 0.37.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/index.d.ts +56 -175
- package/dist/index.js +38 -82
- package/dist/store/index.d.ts +14 -25
- package/dist/store/index.js +228 -284
- package/dist/stream/index.d.ts +2 -3
- package/dist/stream/index.js +11 -22
- package/dist/{types-BrLpRRde.d.ts → types-BXbnHOQe.d.ts} +844 -1555
- package/package.json +1 -1
- package/schema/collection_frames.schema.json +87 -211
- package/schema/frames.schema.json +842 -1496
- package/schema/lifecycle.schema.json +389 -150
- package/schema/openapi.v1.json +761 -1619
package/dist/stream/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cr as Session, d1 as StreamFrame } from '../types-BXbnHOQe.js';
|
|
2
2
|
|
|
3
3
|
declare const WS_CLOSE_NORMAL = 1000;
|
|
4
4
|
declare const WS_CLOSE_GOING_AWAY = 1001;
|
|
@@ -8,8 +8,7 @@ declare const WS_CLOSE_OVER_CAPACITY = 1013;
|
|
|
8
8
|
declare function sessionStatusWord(session: Session): string;
|
|
9
9
|
type StreamOutcome = {
|
|
10
10
|
type: 'done';
|
|
11
|
-
|
|
12
|
-
reason: string | null;
|
|
11
|
+
session: Session;
|
|
13
12
|
} | {
|
|
14
13
|
type: 'error';
|
|
15
14
|
message: string;
|
package/dist/stream/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var WS_CLOSE_AUTH_FAILED = 1008;
|
|
|
5
5
|
var WS_CLOSE_SERVER_ERROR = 1011;
|
|
6
6
|
var WS_CLOSE_OVER_CAPACITY = 1013;
|
|
7
7
|
function sessionStatusWord(session) {
|
|
8
|
-
return session.
|
|
8
|
+
return session.status;
|
|
9
9
|
}
|
|
10
10
|
var StreamUnavailableError = class extends Error {
|
|
11
11
|
constructor(message) {
|
|
@@ -85,20 +85,12 @@ function connectOnce(sock, emit, signal) {
|
|
|
85
85
|
} catch {
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
|
-
if (!frame || ![
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
"session",
|
|
92
|
-
"delta",
|
|
93
|
-
"heartbeat",
|
|
94
|
-
"done",
|
|
95
|
-
"error"
|
|
96
|
-
].includes(frame.type))
|
|
88
|
+
if (!frame || !["session", "records", "delta", "heartbeat", "error"].includes(
|
|
89
|
+
frame.type
|
|
90
|
+
))
|
|
97
91
|
return;
|
|
98
92
|
emit(frame);
|
|
99
|
-
if (frame.type === "
|
|
100
|
-
finish({ kind: "done" });
|
|
101
|
-
} else if (frame.type === "error") {
|
|
93
|
+
if (frame.type === "error") {
|
|
102
94
|
finish({
|
|
103
95
|
kind: "frameError",
|
|
104
96
|
message: frame.message ?? "stream error"
|
|
@@ -127,22 +119,19 @@ async function streamSession(opts) {
|
|
|
127
119
|
let afterSeq = opts.afterSeq ?? 0;
|
|
128
120
|
let everReceivedFrame = false;
|
|
129
121
|
let attempt = 0;
|
|
130
|
-
let
|
|
131
|
-
let lastReason = null;
|
|
122
|
+
let lastSession = null;
|
|
132
123
|
const emit = (frame) => {
|
|
133
124
|
everReceivedFrame = true;
|
|
134
125
|
attempt = 0;
|
|
135
|
-
if (frame.type === "
|
|
126
|
+
if (frame.type === "records") {
|
|
136
127
|
const records = frame.records;
|
|
137
128
|
for (const record of records) {
|
|
138
129
|
if (typeof record.feed_seq === "number") {
|
|
139
130
|
afterSeq = Math.max(afterSeq, record.feed_seq);
|
|
140
131
|
}
|
|
141
132
|
}
|
|
142
|
-
} else if (frame.type === "
|
|
143
|
-
|
|
144
|
-
lastStatusWord = sessionStatusWord(session);
|
|
145
|
-
lastReason = session.turn?.reason ?? null;
|
|
133
|
+
} else if (frame.type === "session") {
|
|
134
|
+
lastSession = frame.session;
|
|
146
135
|
}
|
|
147
136
|
opts.onFrame(frame);
|
|
148
137
|
};
|
|
@@ -162,8 +151,8 @@ async function streamSession(opts) {
|
|
|
162
151
|
err: err instanceof Error ? err : new Error(String(err))
|
|
163
152
|
};
|
|
164
153
|
}
|
|
165
|
-
if (res.kind === "
|
|
166
|
-
return { type: "done",
|
|
154
|
+
if (res.kind === "closed" && res.code === WS_CLOSE_NORMAL && lastSession?.status === "closed") {
|
|
155
|
+
return { type: "done", session: lastSession };
|
|
167
156
|
}
|
|
168
157
|
if (res.kind === "frameError")
|
|
169
158
|
return { type: "error", message: res.message };
|