@orq-ai/node 3.9.4 → 3.9.5
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/README.md +2 -5
- package/bin/mcp-server.js +560 -866
- package/bin/mcp-server.js.map +36 -36
- package/docs/sdks/knowledge/README.md +77 -0
- package/examples/README.md +26 -0
- package/examples/contactsCreate.example.ts +40 -0
- package/examples/package-lock.json +626 -0
- package/examples/package.json +18 -0
- package/funcs/deploymentsStream.js +7 -7
- package/funcs/deploymentsStream.js.map +1 -1
- package/funcs/{knowledgeBasesChunkText.d.ts → knowledgeCreate.d.ts} +3 -6
- package/funcs/knowledgeCreate.d.ts.map +1 -0
- package/funcs/{knowledgeBasesChunkText.js → knowledgeCreate.js} +7 -10
- package/funcs/knowledgeCreate.js.map +1 -0
- package/jsr.json +1 -1
- package/lib/config.d.ts +3 -3
- package/lib/config.js +3 -3
- package/lib/event-streams.d.ts +4 -10
- package/lib/event-streams.d.ts.map +1 -1
- package/lib/event-streams.js +110 -194
- package/lib/event-streams.js.map +1 -1
- package/lib/matchers.d.ts.map +1 -1
- package/lib/matchers.js +1 -4
- package/lib/matchers.js.map +1 -1
- package/mcp-server/mcp-server.js +1 -1
- package/mcp-server/server.js +3 -3
- package/mcp-server/server.js.map +1 -1
- package/mcp-server/tools/knowledgeCreate.d.ts +8 -0
- package/mcp-server/tools/knowledgeCreate.d.ts.map +1 -0
- package/mcp-server/tools/{knowledgeBasesChunkText.js → knowledgeCreate.js} +8 -10
- package/mcp-server/tools/knowledgeCreate.js.map +1 -0
- package/models/operations/createcontact.js +2 -2
- package/models/operations/createdataset.js +2 -2
- package/models/operations/createdatasetitem.js +2 -2
- package/models/operations/createdatasource.js +2 -2
- package/models/operations/createeval.js +16 -16
- package/models/operations/createknowledge.d.ts +426 -0
- package/models/operations/createknowledge.d.ts.map +1 -0
- package/models/operations/createknowledge.js +431 -0
- package/models/operations/createknowledge.js.map +1 -0
- package/models/operations/fileget.js +2 -2
- package/models/operations/filelist.js +2 -2
- package/models/operations/fileupload.js +2 -2
- package/models/operations/getevals.js +28 -28
- package/models/operations/index.d.ts +1 -1
- package/models/operations/index.d.ts.map +1 -1
- package/models/operations/index.js +1 -1
- package/models/operations/index.js.map +1 -1
- package/models/operations/listcontacts.js +2 -2
- package/models/operations/listdatasetdatapoints.js +2 -2
- package/models/operations/listdatasets.js +2 -2
- package/models/operations/listdatasources.js +2 -2
- package/models/operations/retrievecontact.js +2 -2
- package/models/operations/retrievedatapoint.js +2 -2
- package/models/operations/retrievedataset.js +2 -2
- package/models/operations/retrievedatasource.js +2 -2
- package/models/operations/updatecontact.js +2 -2
- package/models/operations/updatedatapoint.js +2 -2
- package/models/operations/updatedataset.js +2 -2
- package/models/operations/updatedatasource.js +2 -2
- package/models/operations/updateeval.js +16 -16
- package/models/operations/updateknowledge.d.ts +106 -106
- package/models/operations/updateknowledge.d.ts.map +1 -1
- package/models/operations/updateknowledge.js +125 -129
- package/models/operations/updateknowledge.js.map +1 -1
- package/package.json +1 -1
- package/packages/orq-rc/examples/README.md +26 -0
- package/packages/orq-rc/examples/contactsCreate.example.ts +40 -0
- package/packages/orq-rc/examples/package-lock.json +626 -0
- package/packages/orq-rc/examples/package.json +18 -0
- package/packages/orq-rc/jsr.json +1 -1
- package/packages/orq-rc/package-lock.json +2 -2
- package/packages/orq-rc/package.json +1 -1
- package/packages/orq-rc/src/funcs/deploymentsStream.ts +7 -8
- package/packages/orq-rc/src/lib/config.ts +3 -3
- package/packages/orq-rc/src/lib/event-streams.ts +114 -231
- package/packages/orq-rc/src/lib/matchers.ts +1 -4
- package/packages/orq-rc/src/mcp-server/mcp-server.ts +1 -1
- package/packages/orq-rc/src/mcp-server/server.ts +1 -1
- package/packages/orq-rc/src/models/operations/createcontact.ts +2 -2
- package/packages/orq-rc/src/models/operations/createdataset.ts +2 -2
- package/packages/orq-rc/src/models/operations/createdatasetitem.ts +2 -2
- package/packages/orq-rc/src/models/operations/createdatasource.ts +2 -2
- package/packages/orq-rc/src/models/operations/createeval.ts +16 -16
- package/packages/orq-rc/src/models/operations/fileget.ts +2 -2
- package/packages/orq-rc/src/models/operations/filelist.ts +2 -2
- package/packages/orq-rc/src/models/operations/fileupload.ts +2 -2
- package/packages/orq-rc/src/models/operations/getevals.ts +28 -28
- package/packages/orq-rc/src/models/operations/listcontacts.ts +2 -2
- package/packages/orq-rc/src/models/operations/listdatasetdatapoints.ts +2 -2
- package/packages/orq-rc/src/models/operations/listdatasets.ts +2 -2
- package/packages/orq-rc/src/models/operations/listdatasources.ts +2 -2
- package/packages/orq-rc/src/models/operations/retrievecontact.ts +2 -2
- package/packages/orq-rc/src/models/operations/retrievedatapoint.ts +2 -2
- package/packages/orq-rc/src/models/operations/retrievedataset.ts +2 -2
- package/packages/orq-rc/src/models/operations/retrievedatasource.ts +2 -2
- package/packages/orq-rc/src/models/operations/updatecontact.ts +2 -2
- package/packages/orq-rc/src/models/operations/updatedatapoint.ts +2 -2
- package/packages/orq-rc/src/models/operations/updatedataset.ts +2 -2
- package/packages/orq-rc/src/models/operations/updatedatasource.ts +2 -2
- package/packages/orq-rc/src/models/operations/updateeval.ts +16 -16
- package/sdk/knowledge.d.ts +4 -0
- package/sdk/knowledge.d.ts.map +1 -1
- package/sdk/knowledge.js +7 -0
- package/sdk/knowledge.js.map +1 -1
- package/sdk/sdk.d.ts +0 -3
- package/sdk/sdk.d.ts.map +1 -1
- package/sdk/sdk.js +0 -4
- package/sdk/sdk.js.map +1 -1
- package/src/funcs/deploymentsStream.ts +7 -8
- package/src/funcs/{knowledgeBasesChunkText.ts → knowledgeCreate.ts} +11 -13
- package/src/lib/config.ts +3 -3
- package/src/lib/event-streams.ts +114 -231
- package/src/lib/matchers.ts +1 -4
- package/src/mcp-server/mcp-server.ts +1 -1
- package/src/mcp-server/server.ts +3 -3
- package/src/mcp-server/tools/knowledgeCreate.ts +35 -0
- package/src/models/operations/createcontact.ts +2 -2
- package/src/models/operations/createdataset.ts +2 -2
- package/src/models/operations/createdatasetitem.ts +2 -2
- package/src/models/operations/createdatasource.ts +2 -2
- package/src/models/operations/createeval.ts +16 -16
- package/src/models/operations/createknowledge.ts +846 -0
- package/src/models/operations/fileget.ts +2 -2
- package/src/models/operations/filelist.ts +2 -2
- package/src/models/operations/fileupload.ts +2 -2
- package/src/models/operations/getevals.ts +28 -28
- package/src/models/operations/index.ts +1 -1
- package/src/models/operations/listcontacts.ts +2 -2
- package/src/models/operations/listdatasetdatapoints.ts +2 -2
- package/src/models/operations/listdatasets.ts +2 -2
- package/src/models/operations/listdatasources.ts +2 -2
- package/src/models/operations/retrievecontact.ts +2 -2
- package/src/models/operations/retrievedatapoint.ts +2 -2
- package/src/models/operations/retrievedataset.ts +2 -2
- package/src/models/operations/retrievedatasource.ts +2 -2
- package/src/models/operations/updatecontact.ts +2 -2
- package/src/models/operations/updatedatapoint.ts +2 -2
- package/src/models/operations/updatedataset.ts +2 -2
- package/src/models/operations/updatedatasource.ts +2 -2
- package/src/models/operations/updateeval.ts +16 -16
- package/src/models/operations/updateknowledge.ts +266 -206
- package/src/sdk/knowledge.ts +15 -0
- package/src/sdk/sdk.ts +0 -6
- package/docs/sdks/knowledgebases/README.md +0 -94
- package/funcs/knowledgeBasesChunkText.d.ts.map +0 -1
- package/funcs/knowledgeBasesChunkText.js.map +0 -1
- package/mcp-server/tools/knowledgeBasesChunkText.d.ts +0 -8
- package/mcp-server/tools/knowledgeBasesChunkText.d.ts.map +0 -1
- package/mcp-server/tools/knowledgeBasesChunkText.js.map +0 -1
- package/models/operations/chunktext.d.ts +0 -961
- package/models/operations/chunktext.d.ts.map +0 -1
- package/models/operations/chunktext.js +0 -883
- package/models/operations/chunktext.js.map +0 -1
- package/sdk/knowledgebases.d.ts +0 -12
- package/sdk/knowledgebases.d.ts.map +0 -1
- package/sdk/knowledgebases.js +0 -22
- package/sdk/knowledgebases.js.map +0 -1
- package/src/mcp-server/tools/knowledgeBasesChunkText.ts +0 -37
- package/src/models/operations/chunktext.ts +0 -1629
- package/src/sdk/knowledgebases.ts +0 -27
|
@@ -162,16 +162,15 @@ async function $do(
|
|
|
162
162
|
M.sse(
|
|
163
163
|
200,
|
|
164
164
|
z.instanceof(ReadableStream<Uint8Array>).transform(stream => {
|
|
165
|
-
return new EventStream({
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
165
|
+
return new EventStream(stream, rawEvent => {
|
|
166
|
+
if (rawEvent.data === "[DONE]") return { done: true };
|
|
167
|
+
return {
|
|
168
|
+
value: operations.DeploymentStreamResponseBody$inboundSchema.parse(
|
|
169
|
+
rawEvent,
|
|
170
|
+
),
|
|
171
|
+
};
|
|
172
172
|
});
|
|
173
173
|
}),
|
|
174
|
-
{ sseSentinel: "[DONE]" },
|
|
175
174
|
),
|
|
176
175
|
M.fail("4XX"),
|
|
177
176
|
M.fail("5XX"),
|
|
@@ -68,7 +68,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
|
|
|
68
68
|
export const SDK_METADATA = {
|
|
69
69
|
language: "typescript",
|
|
70
70
|
openapiDocVersion: "2.0",
|
|
71
|
-
sdkVersion: "3.10.0-rc.
|
|
72
|
-
genVersion: "2.
|
|
73
|
-
userAgent: "speakeasy-sdk/typescript 3.10.0-rc.
|
|
71
|
+
sdkVersion: "3.10.0-rc.2",
|
|
72
|
+
genVersion: "2.652.0",
|
|
73
|
+
userAgent: "speakeasy-sdk/typescript 3.10.0-rc.2 2.652.0 2.0 @orq-ai/node",
|
|
74
74
|
} as const;
|
|
@@ -5,260 +5,143 @@
|
|
|
5
5
|
export type ServerEvent<T> = {
|
|
6
6
|
data?: T | undefined;
|
|
7
7
|
event?: string | undefined;
|
|
8
|
-
retry?: number | undefined;
|
|
9
8
|
id?: string | undefined;
|
|
9
|
+
retry?: number | undefined;
|
|
10
10
|
};
|
|
11
|
-
const LF = 0x0a;
|
|
12
|
-
const CR = 0x0d;
|
|
13
|
-
const NEWLINE_CHARS = new Set([LF, CR]);
|
|
14
|
-
const MESSAGE_BOUNDARIES = [
|
|
15
|
-
new Uint8Array([CR, LF, CR, LF]),
|
|
16
|
-
new Uint8Array([CR, CR]),
|
|
17
|
-
new Uint8Array([LF, LF]),
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
export class EventStream<Event extends ServerEvent<unknown>> {
|
|
21
|
-
private readonly stream: ReadableStream<Uint8Array>;
|
|
22
|
-
private readonly decoder: (rawEvent: ServerEvent<string>) => Event;
|
|
23
|
-
|
|
24
|
-
constructor(init: {
|
|
25
|
-
stream: ReadableStream<Uint8Array>;
|
|
26
|
-
decoder: (rawEvent: ServerEvent<string>) => Event;
|
|
27
|
-
}) {
|
|
28
|
-
this.stream = init.stream;
|
|
29
|
-
this.decoder = init.decoder;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async *[Symbol.asyncIterator](): AsyncGenerator<Event, void, unknown> {
|
|
33
|
-
const reader = this.stream.getReader();
|
|
34
|
-
let buffer = new Uint8Array([]);
|
|
35
|
-
let position = 0;
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
while (true) {
|
|
39
|
-
const { done, value } = await reader.read();
|
|
40
|
-
if (done) {
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const newBuffer = new Uint8Array(buffer.length + value.length);
|
|
45
|
-
newBuffer.set(buffer);
|
|
46
|
-
newBuffer.set(value, buffer.length);
|
|
47
|
-
buffer = newBuffer;
|
|
48
|
-
|
|
49
|
-
for (let i = position; i < buffer.length; i++) {
|
|
50
|
-
const boundary = findBoundary(buffer, i);
|
|
51
|
-
if (boundary == null) {
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
11
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
12
|
+
export class EventStream<T extends ServerEvent<unknown>>
|
|
13
|
+
extends ReadableStream<T>
|
|
14
|
+
{
|
|
15
|
+
constructor(
|
|
16
|
+
stream: ReadableStream<Uint8Array>,
|
|
17
|
+
parse: (x: ServerEvent<string>) => IteratorResult<T, undefined>,
|
|
18
|
+
) {
|
|
19
|
+
const reader = stream.getReader();
|
|
20
|
+
let buffer: Uint8Array = new Uint8Array();
|
|
21
|
+
super({
|
|
22
|
+
async pull(controller) {
|
|
23
|
+
try {
|
|
24
|
+
const r = await reader.read();
|
|
25
|
+
if (r.done) return controller.close();
|
|
26
|
+
buffer = concatBuffer(buffer, r.value);
|
|
27
|
+
for (const { chunk, remainder } of chunks(buffer)) {
|
|
28
|
+
buffer = remainder;
|
|
29
|
+
const item = parseChunk(chunk, parse);
|
|
30
|
+
if (item?.value) controller.enqueue(item.value);
|
|
31
|
+
if (item?.done) {
|
|
32
|
+
await reader.cancel("done");
|
|
33
|
+
return controller.close();
|
|
34
|
+
}
|
|
60
35
|
}
|
|
36
|
+
} catch (e) {
|
|
37
|
+
await reader.cancel(e);
|
|
38
|
+
controller.error(e);
|
|
61
39
|
}
|
|
40
|
+
},
|
|
41
|
+
cancel: reason => reader.cancel(reason),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
62
44
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
if (
|
|
72
|
-
|
|
45
|
+
// Polyfill for older browsers
|
|
46
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<T, void, unknown> {
|
|
47
|
+
const fn = (ReadableStream.prototype as any)[Symbol.asyncIterator];
|
|
48
|
+
if (typeof fn === "function") return fn.call(this);
|
|
49
|
+
const reader = this.getReader();
|
|
50
|
+
return {
|
|
51
|
+
next: async () => {
|
|
52
|
+
const r = await reader.read();
|
|
53
|
+
if (r.done) {
|
|
54
|
+
reader.releaseLock();
|
|
55
|
+
return { done: true, value: undefined };
|
|
73
56
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
57
|
+
return { done: false, value: r.value };
|
|
58
|
+
},
|
|
59
|
+
throw: async (e) => {
|
|
60
|
+
await reader.cancel(e);
|
|
61
|
+
reader.releaseLock();
|
|
62
|
+
return { done: true, value: undefined };
|
|
63
|
+
},
|
|
64
|
+
return: async () => {
|
|
65
|
+
await reader.cancel("done");
|
|
66
|
+
reader.releaseLock();
|
|
67
|
+
return { done: true, value: undefined };
|
|
68
|
+
},
|
|
69
|
+
[Symbol.asyncIterator]() {
|
|
70
|
+
return this;
|
|
71
|
+
},
|
|
72
|
+
};
|
|
84
73
|
}
|
|
85
74
|
}
|
|
86
75
|
|
|
87
|
-
function
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (
|
|
94
|
-
char1 == null
|
|
95
|
-
|| char2 == null
|
|
96
|
-
|| !NEWLINE_CHARS.has(char1)
|
|
97
|
-
|| !NEWLINE_CHARS.has(char2)
|
|
98
|
-
) {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
76
|
+
function concatBuffer(a: Uint8Array, b: Uint8Array): Uint8Array {
|
|
77
|
+
const c = new Uint8Array(a.length + b.length);
|
|
78
|
+
c.set(a, 0);
|
|
79
|
+
c.set(b, a.length);
|
|
80
|
+
return c;
|
|
81
|
+
}
|
|
101
82
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
83
|
+
/** Finds the first (CR,LF,CR,LF) or (CR,CR) or (LF,LF) */
|
|
84
|
+
function findBoundary(
|
|
85
|
+
buf: Uint8Array,
|
|
86
|
+
): { index: number; length: number } | null {
|
|
87
|
+
const len = buf.length;
|
|
88
|
+
for (let i = 0; i < len; i++) {
|
|
89
|
+
if (
|
|
90
|
+
i <= len - 4
|
|
91
|
+
&& buf[i] === 13 && buf[i + 1] === 10 && buf[i + 2] === 13
|
|
92
|
+
&& buf[i + 3] === 10
|
|
93
|
+
) {
|
|
94
|
+
return { index: i, length: 4 };
|
|
95
|
+
}
|
|
96
|
+
if (i <= len - 2 && buf[i] === 13 && buf[i + 1] === 13) {
|
|
97
|
+
return { index: i, length: 2 };
|
|
98
|
+
}
|
|
99
|
+
if (i <= len - 2 && buf[i] === 10 && buf[i + 1] === 10) {
|
|
100
|
+
return { index: i, length: 2 };
|
|
106
101
|
}
|
|
107
102
|
}
|
|
108
|
-
|
|
109
103
|
return null;
|
|
110
104
|
}
|
|
111
105
|
|
|
112
|
-
function
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
for (let i = 0; i < sequence.length; i++) {
|
|
122
|
-
if (buffer[position + i] !== sequence[i]) {
|
|
123
|
-
return null;
|
|
106
|
+
function* chunks(
|
|
107
|
+
remainder: Uint8Array,
|
|
108
|
+
): Generator<{ chunk: Uint8Array; remainder: Uint8Array }> {
|
|
109
|
+
while (true) {
|
|
110
|
+
const match = findBoundary(remainder);
|
|
111
|
+
if (!match) {
|
|
112
|
+
yield { chunk: new Uint8Array(), remainder };
|
|
113
|
+
return;
|
|
124
114
|
}
|
|
115
|
+
const chunk = remainder.slice(0, match.index);
|
|
116
|
+
remainder = remainder.slice(match.index + match.length);
|
|
117
|
+
yield { chunk, remainder };
|
|
125
118
|
}
|
|
126
|
-
|
|
127
|
-
return sequence;
|
|
128
119
|
}
|
|
129
120
|
|
|
130
|
-
function
|
|
121
|
+
function parseChunk<T extends ServerEvent<unknown>>(
|
|
131
122
|
chunk: Uint8Array,
|
|
132
|
-
|
|
123
|
+
parse: (x: ServerEvent<string>) => IteratorResult<T, undefined>,
|
|
133
124
|
) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const raw = td.decode(chunk);
|
|
140
|
-
const lines = raw.split(/\r?\n|\r/g);
|
|
141
|
-
let publish = false;
|
|
142
|
-
const rawEvent: ServerEvent<string> = {};
|
|
143
|
-
|
|
125
|
+
const text = new TextDecoder().decode(chunk);
|
|
126
|
+
const lines = text.split(/\r\n|\r|\n/);
|
|
127
|
+
const dataLines: string[] = [];
|
|
128
|
+
const ret: ServerEvent<string> = {};
|
|
129
|
+
let ignore = true;
|
|
144
130
|
for (const line of lines) {
|
|
145
|
-
if (!line)
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
if (
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
let value = delim > 0 ? line.substring(delim + 1) : "";
|
|
157
|
-
if (value.charAt(0) === " ") {
|
|
158
|
-
value = value.substring(1);
|
|
131
|
+
if (!line || line.startsWith(":")) continue;
|
|
132
|
+
ignore = false;
|
|
133
|
+
const i = line.indexOf(":");
|
|
134
|
+
const field = line.slice(0, i);
|
|
135
|
+
const value = line[i + 1] === " " ? line.slice(i + 2) : line.slice(i + 1);
|
|
136
|
+
if (field === "data") dataLines.push(value);
|
|
137
|
+
else if (field === "event") ret.event = value;
|
|
138
|
+
else if (field === "id") ret.id = value;
|
|
139
|
+
else if (field === "retry") {
|
|
140
|
+
const n = Number(value);
|
|
141
|
+
if (!isNaN(n)) ret.retry = n;
|
|
159
142
|
}
|
|
160
|
-
|
|
161
|
-
switch (field) {
|
|
162
|
-
case "event": {
|
|
163
|
-
publish = true;
|
|
164
|
-
rawEvent.event = value;
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
case "data": {
|
|
168
|
-
publish = true;
|
|
169
|
-
rawEvent.data ??= "";
|
|
170
|
-
rawEvent.data += value + "\n";
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
case "id": {
|
|
174
|
-
publish = true;
|
|
175
|
-
rawEvent.id = value;
|
|
176
|
-
break;
|
|
177
|
-
}
|
|
178
|
-
case "retry": {
|
|
179
|
-
const r = parseInt(value, 10);
|
|
180
|
-
if (!Number.isNaN(r)) {
|
|
181
|
-
publish = true;
|
|
182
|
-
rawEvent.retry = r;
|
|
183
|
-
}
|
|
184
|
-
break;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
if (!publish) {
|
|
190
|
-
return null;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
if (rawEvent.data != null) {
|
|
194
|
-
rawEvent.data = rawEvent.data.slice(0, -1);
|
|
195
143
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
export function discardSentinel(
|
|
201
|
-
stream: ReadableStream<Uint8Array>,
|
|
202
|
-
sentinel: string,
|
|
203
|
-
): ReadableStream<Uint8Array> {
|
|
204
|
-
return new ReadableStream<Uint8Array>({
|
|
205
|
-
async start(controller) {
|
|
206
|
-
let buffer = new Uint8Array([]);
|
|
207
|
-
let position = 0;
|
|
208
|
-
let done = false;
|
|
209
|
-
let discard = false;
|
|
210
|
-
const rdr = stream.getReader();
|
|
211
|
-
try {
|
|
212
|
-
while (!done) {
|
|
213
|
-
const result = await rdr.read();
|
|
214
|
-
const value = result.value;
|
|
215
|
-
done = done || result.done;
|
|
216
|
-
// We keep consuming from the source to its completion so it can
|
|
217
|
-
// flush all its contents and release resources.
|
|
218
|
-
if (discard) {
|
|
219
|
-
continue;
|
|
220
|
-
}
|
|
221
|
-
if (typeof value === "undefined") {
|
|
222
|
-
continue;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
const newBuffer = new Uint8Array(buffer.length + value.length);
|
|
226
|
-
newBuffer.set(buffer);
|
|
227
|
-
newBuffer.set(value, buffer.length);
|
|
228
|
-
buffer = newBuffer;
|
|
229
|
-
|
|
230
|
-
for (let i = position; i < buffer.length; i++) {
|
|
231
|
-
const boundary = findBoundary(buffer, i);
|
|
232
|
-
if (boundary == null) {
|
|
233
|
-
continue;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
const start = position;
|
|
237
|
-
const chunk = buffer.slice(start, i);
|
|
238
|
-
position = i + boundary.length;
|
|
239
|
-
const event = parseEvent(chunk, id);
|
|
240
|
-
if (event?.data === sentinel) {
|
|
241
|
-
controller.enqueue(buffer.slice(0, start));
|
|
242
|
-
discard = true;
|
|
243
|
-
} else {
|
|
244
|
-
controller.enqueue(buffer.slice(0, position));
|
|
245
|
-
buffer = buffer.slice(position);
|
|
246
|
-
position = 0;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
} catch (e) {
|
|
251
|
-
controller.error(e);
|
|
252
|
-
} finally {
|
|
253
|
-
// If the source stream terminates, flush its contents and terminate.
|
|
254
|
-
// If the sentinel event was found, flush everything up to its start.
|
|
255
|
-
controller.close();
|
|
256
|
-
rdr.releaseLock();
|
|
257
|
-
}
|
|
258
|
-
},
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
function id<T>(v: T): T {
|
|
263
|
-
return v;
|
|
144
|
+
if (ignore) return;
|
|
145
|
+
if (dataLines.length) ret.data = dataLines.join("\n");
|
|
146
|
+
return parse(ret);
|
|
264
147
|
}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
import { APIError } from "../models/errors/apierror.js";
|
|
6
6
|
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
7
7
|
import { ERR, OK, Result } from "../types/fp.js";
|
|
8
|
-
import { discardSentinel } from "./event-streams.js";
|
|
9
8
|
import { matchResponse, matchStatusCode, StatusCodePredicate } from "./http.js";
|
|
10
9
|
import { isPlainObject } from "./is-plain-object.js";
|
|
11
10
|
|
|
@@ -238,9 +237,7 @@ export function match<T, E>(
|
|
|
238
237
|
raw = body;
|
|
239
238
|
break;
|
|
240
239
|
case "sse":
|
|
241
|
-
raw = response.body
|
|
242
|
-
? discardSentinel(response.body, matcher.sseSentinel)
|
|
243
|
-
: response.body;
|
|
240
|
+
raw = response.body;
|
|
244
241
|
break;
|
|
245
242
|
case "nil":
|
|
246
243
|
body = await response.text();
|
|
@@ -182,7 +182,7 @@ export const CreateContactResponseBody$inboundSchema: z.ZodType<
|
|
|
182
182
|
created: z.string().datetime({ offset: true }).transform(v => new Date(v))
|
|
183
183
|
.optional(),
|
|
184
184
|
updated: z.string().datetime({ offset: true }).default(
|
|
185
|
-
"2025-07-
|
|
185
|
+
"2025-07-08T10:06:05.308Z",
|
|
186
186
|
).transform(v => new Date(v)),
|
|
187
187
|
}).transform((v) => {
|
|
188
188
|
return remap$(v, {
|
|
@@ -223,7 +223,7 @@ export const CreateContactResponseBody$outboundSchema: z.ZodType<
|
|
|
223
223
|
tags: z.array(z.string()).optional(),
|
|
224
224
|
metadata: z.record(z.any()).optional(),
|
|
225
225
|
created: z.date().transform(v => v.toISOString()).optional(),
|
|
226
|
-
updated: z.date().default(() => new Date("2025-07-
|
|
226
|
+
updated: z.date().default(() => new Date("2025-07-08T10:06:05.308Z"))
|
|
227
227
|
.transform(v => v.toISOString()),
|
|
228
228
|
}).transform((v) => {
|
|
229
229
|
return remap$(v, {
|
|
@@ -211,7 +211,7 @@ export const CreateDatasetResponseBody$inboundSchema: z.ZodType<
|
|
|
211
211
|
created: z.string().datetime({ offset: true }).transform(v => new Date(v))
|
|
212
212
|
.optional(),
|
|
213
213
|
updated: z.string().datetime({ offset: true }).default(
|
|
214
|
-
"2025-07-
|
|
214
|
+
"2025-07-08T10:06:05.308Z",
|
|
215
215
|
).transform(v => new Date(v)),
|
|
216
216
|
}).transform((v) => {
|
|
217
217
|
return remap$(v, {
|
|
@@ -251,7 +251,7 @@ export const CreateDatasetResponseBody$outboundSchema: z.ZodType<
|
|
|
251
251
|
updatedById: z.string().optional(),
|
|
252
252
|
metadata: z.lazy(() => CreateDatasetMetadata$outboundSchema),
|
|
253
253
|
created: z.date().transform(v => v.toISOString()).optional(),
|
|
254
|
-
updated: z.date().default(() => new Date("2025-07-
|
|
254
|
+
updated: z.date().default(() => new Date("2025-07-08T10:06:05.308Z"))
|
|
255
255
|
.transform(v => v.toISOString()),
|
|
256
256
|
}).transform((v) => {
|
|
257
257
|
return remap$(v, {
|
|
@@ -5111,7 +5111,7 @@ export const CreateDatasetItemResponseBody$inboundSchema: z.ZodType<
|
|
|
5111
5111
|
created: z.string().datetime({ offset: true }).transform(v => new Date(v))
|
|
5112
5112
|
.optional(),
|
|
5113
5113
|
updated: z.string().datetime({ offset: true }).default(
|
|
5114
|
-
"2025-07-
|
|
5114
|
+
"2025-07-08T10:06:05.308Z",
|
|
5115
5115
|
).transform(v => new Date(v)),
|
|
5116
5116
|
}).transform((v) => {
|
|
5117
5117
|
return remap$(v, {
|
|
@@ -5175,7 +5175,7 @@ export const CreateDatasetItemResponseBody$outboundSchema: z.ZodType<
|
|
|
5175
5175
|
createdById: z.string().optional(),
|
|
5176
5176
|
updatedById: z.string().optional(),
|
|
5177
5177
|
created: z.date().transform(v => v.toISOString()).optional(),
|
|
5178
|
-
updated: z.date().default(() => new Date("2025-07-
|
|
5178
|
+
updated: z.date().default(() => new Date("2025-07-08T10:06:05.308Z"))
|
|
5179
5179
|
.transform(v => v.toISOString()),
|
|
5180
5180
|
}).transform((v) => {
|
|
5181
5181
|
return remap$(v, {
|
|
@@ -751,7 +751,7 @@ export const CreateDatasourceResponseBody$inboundSchema: z.ZodType<
|
|
|
751
751
|
z.ZodTypeDef,
|
|
752
752
|
unknown
|
|
753
753
|
> = z.object({
|
|
754
|
-
_id: z.string().default("
|
|
754
|
+
_id: z.string().default("01JZMR03EGA03VCJ8PX3ZNZVQJ"),
|
|
755
755
|
display_name: z.string(),
|
|
756
756
|
description: z.string().optional(),
|
|
757
757
|
status: CreateDatasourceStatus$inboundSchema,
|
|
@@ -795,7 +795,7 @@ export const CreateDatasourceResponseBody$outboundSchema: z.ZodType<
|
|
|
795
795
|
z.ZodTypeDef,
|
|
796
796
|
CreateDatasourceResponseBody
|
|
797
797
|
> = z.object({
|
|
798
|
-
id: z.string().default("
|
|
798
|
+
id: z.string().default("01JZMR03EGA03VCJ8PX3ZNZVQJ"),
|
|
799
799
|
displayName: z.string(),
|
|
800
800
|
description: z.string().optional(),
|
|
801
801
|
status: CreateDatasourceStatus$outboundSchema,
|
|
@@ -2399,8 +2399,8 @@ export const ResponseBodyPython$inboundSchema: z.ZodType<
|
|
|
2399
2399
|
> = z.object({
|
|
2400
2400
|
_id: z.string(),
|
|
2401
2401
|
description: z.string(),
|
|
2402
|
-
created: z.string().default("2025-07-
|
|
2403
|
-
updated: z.string().default("2025-07-
|
|
2402
|
+
created: z.string().default("2025-07-08T10:06:07.416Z"),
|
|
2403
|
+
updated: z.string().default("2025-07-08T10:06:07.416Z"),
|
|
2404
2404
|
guardrail_config: z.union([
|
|
2405
2405
|
z.lazy(() =>
|
|
2406
2406
|
CreateEvalGuardrailConfigEvalsResponse200ApplicationJSONResponseBodyNumber$inboundSchema
|
|
@@ -2442,8 +2442,8 @@ export const ResponseBodyPython$outboundSchema: z.ZodType<
|
|
|
2442
2442
|
> = z.object({
|
|
2443
2443
|
id: z.string(),
|
|
2444
2444
|
description: z.string(),
|
|
2445
|
-
created: z.string().default("2025-07-
|
|
2446
|
-
updated: z.string().default("2025-07-
|
|
2445
|
+
created: z.string().default("2025-07-08T10:06:07.416Z"),
|
|
2446
|
+
updated: z.string().default("2025-07-08T10:06:07.416Z"),
|
|
2447
2447
|
guardrailConfig: z.union([
|
|
2448
2448
|
z.lazy(() =>
|
|
2449
2449
|
CreateEvalGuardrailConfigEvalsResponse200ApplicationJSONResponseBodyNumber$outboundSchema
|
|
@@ -2856,8 +2856,8 @@ export const ResponseBodyHTTP$inboundSchema: z.ZodType<
|
|
|
2856
2856
|
> = z.object({
|
|
2857
2857
|
_id: z.string(),
|
|
2858
2858
|
description: z.string(),
|
|
2859
|
-
created: z.string().default("2025-07-
|
|
2860
|
-
updated: z.string().default("2025-07-
|
|
2859
|
+
created: z.string().default("2025-07-08T10:06:07.416Z"),
|
|
2860
|
+
updated: z.string().default("2025-07-08T10:06:07.416Z"),
|
|
2861
2861
|
guardrail_config: z.union([
|
|
2862
2862
|
z.lazy(() =>
|
|
2863
2863
|
CreateEvalGuardrailConfigEvalsResponse200ApplicationJSONNumber$inboundSchema
|
|
@@ -2905,8 +2905,8 @@ export const ResponseBodyHTTP$outboundSchema: z.ZodType<
|
|
|
2905
2905
|
> = z.object({
|
|
2906
2906
|
id: z.string(),
|
|
2907
2907
|
description: z.string(),
|
|
2908
|
-
created: z.string().default("2025-07-
|
|
2909
|
-
updated: z.string().default("2025-07-
|
|
2908
|
+
created: z.string().default("2025-07-08T10:06:07.416Z"),
|
|
2909
|
+
updated: z.string().default("2025-07-08T10:06:07.416Z"),
|
|
2910
2910
|
guardrailConfig: z.union([
|
|
2911
2911
|
z.lazy(() =>
|
|
2912
2912
|
CreateEvalGuardrailConfigEvalsResponse200ApplicationJSONNumber$outboundSchema
|
|
@@ -3283,8 +3283,8 @@ export const ResponseBodyJSON$inboundSchema: z.ZodType<
|
|
|
3283
3283
|
> = z.object({
|
|
3284
3284
|
_id: z.string(),
|
|
3285
3285
|
description: z.string(),
|
|
3286
|
-
created: z.string().default("2025-07-
|
|
3287
|
-
updated: z.string().default("2025-07-
|
|
3286
|
+
created: z.string().default("2025-07-08T10:06:07.416Z"),
|
|
3287
|
+
updated: z.string().default("2025-07-08T10:06:07.416Z"),
|
|
3288
3288
|
guardrail_config: z.union([
|
|
3289
3289
|
z.lazy(() => CreateEvalGuardrailConfigEvalsResponse200Number$inboundSchema),
|
|
3290
3290
|
z.lazy(() =>
|
|
@@ -3324,8 +3324,8 @@ export const ResponseBodyJSON$outboundSchema: z.ZodType<
|
|
|
3324
3324
|
> = z.object({
|
|
3325
3325
|
id: z.string(),
|
|
3326
3326
|
description: z.string(),
|
|
3327
|
-
created: z.string().default("2025-07-
|
|
3328
|
-
updated: z.string().default("2025-07-
|
|
3327
|
+
created: z.string().default("2025-07-08T10:06:07.416Z"),
|
|
3328
|
+
updated: z.string().default("2025-07-08T10:06:07.416Z"),
|
|
3329
3329
|
guardrailConfig: z.union([
|
|
3330
3330
|
z.lazy(() =>
|
|
3331
3331
|
CreateEvalGuardrailConfigEvalsResponse200Number$outboundSchema
|
|
@@ -3680,8 +3680,8 @@ export const ResponseBodyLLM$inboundSchema: z.ZodType<
|
|
|
3680
3680
|
> = z.object({
|
|
3681
3681
|
_id: z.string(),
|
|
3682
3682
|
description: z.string(),
|
|
3683
|
-
created: z.string().default("2025-07-
|
|
3684
|
-
updated: z.string().default("2025-07-
|
|
3683
|
+
created: z.string().default("2025-07-08T10:06:07.416Z"),
|
|
3684
|
+
updated: z.string().default("2025-07-08T10:06:07.416Z"),
|
|
3685
3685
|
guardrail_config: z.union([
|
|
3686
3686
|
z.lazy(() => CreateEvalGuardrailConfigEvalsResponseNumber$inboundSchema),
|
|
3687
3687
|
z.lazy(() => CreateEvalGuardrailConfigEvalsResponseBoolean$inboundSchema),
|
|
@@ -3721,8 +3721,8 @@ export const ResponseBodyLLM$outboundSchema: z.ZodType<
|
|
|
3721
3721
|
> = z.object({
|
|
3722
3722
|
id: z.string(),
|
|
3723
3723
|
description: z.string(),
|
|
3724
|
-
created: z.string().default("2025-07-
|
|
3725
|
-
updated: z.string().default("2025-07-
|
|
3724
|
+
created: z.string().default("2025-07-08T10:06:07.416Z"),
|
|
3725
|
+
updated: z.string().default("2025-07-08T10:06:07.416Z"),
|
|
3726
3726
|
guardrailConfig: z.union([
|
|
3727
3727
|
z.lazy(() => CreateEvalGuardrailConfigEvalsResponseNumber$outboundSchema),
|
|
3728
3728
|
z.lazy(() => CreateEvalGuardrailConfigEvalsResponseBoolean$outboundSchema),
|
|
@@ -146,7 +146,7 @@ export const FileGetResponseBody$inboundSchema: z.ZodType<
|
|
|
146
146
|
file_name: z.string(),
|
|
147
147
|
workspace_id: z.string(),
|
|
148
148
|
created: z.string().datetime({ offset: true }).default(
|
|
149
|
-
"2025-07-
|
|
149
|
+
"2025-07-08T10:06:08.258Z",
|
|
150
150
|
).transform(v => new Date(v)),
|
|
151
151
|
}).transform((v) => {
|
|
152
152
|
return remap$(v, {
|
|
@@ -180,7 +180,7 @@ export const FileGetResponseBody$outboundSchema: z.ZodType<
|
|
|
180
180
|
bytes: z.number(),
|
|
181
181
|
fileName: z.string(),
|
|
182
182
|
workspaceId: z.string(),
|
|
183
|
-
created: z.date().default(() => new Date("2025-07-
|
|
183
|
+
created: z.date().default(() => new Date("2025-07-08T10:06:08.258Z"))
|
|
184
184
|
.transform(v => v.toISOString()),
|
|
185
185
|
}).transform((v) => {
|
|
186
186
|
return remap$(v, {
|
|
@@ -196,7 +196,7 @@ export const FileListData$inboundSchema: z.ZodType<
|
|
|
196
196
|
file_name: z.string(),
|
|
197
197
|
workspace_id: z.string(),
|
|
198
198
|
created: z.string().datetime({ offset: true }).default(
|
|
199
|
-
"2025-07-
|
|
199
|
+
"2025-07-08T10:06:08.258Z",
|
|
200
200
|
).transform(v => new Date(v)),
|
|
201
201
|
}).transform((v) => {
|
|
202
202
|
return remap$(v, {
|
|
@@ -230,7 +230,7 @@ export const FileListData$outboundSchema: z.ZodType<
|
|
|
230
230
|
bytes: z.number(),
|
|
231
231
|
fileName: z.string(),
|
|
232
232
|
workspaceId: z.string(),
|
|
233
|
-
created: z.date().default(() => new Date("2025-07-
|
|
233
|
+
created: z.date().default(() => new Date("2025-07-08T10:06:08.258Z"))
|
|
234
234
|
.transform(v => v.toISOString()),
|
|
235
235
|
}).transform((v) => {
|
|
236
236
|
return remap$(v, {
|
|
@@ -250,7 +250,7 @@ export const FileUploadResponseBody$inboundSchema: z.ZodType<
|
|
|
250
250
|
file_name: z.string(),
|
|
251
251
|
workspace_id: z.string(),
|
|
252
252
|
created: z.string().datetime({ offset: true }).default(
|
|
253
|
-
"2025-07-
|
|
253
|
+
"2025-07-08T10:06:08.258Z",
|
|
254
254
|
).transform(v => new Date(v)),
|
|
255
255
|
}).transform((v) => {
|
|
256
256
|
return remap$(v, {
|
|
@@ -284,7 +284,7 @@ export const FileUploadResponseBody$outboundSchema: z.ZodType<
|
|
|
284
284
|
bytes: z.number(),
|
|
285
285
|
fileName: z.string(),
|
|
286
286
|
workspaceId: z.string(),
|
|
287
|
-
created: z.date().default(() => new Date("2025-07-
|
|
287
|
+
created: z.date().default(() => new Date("2025-07-08T10:06:08.258Z"))
|
|
288
288
|
.transform(v => v.toISOString()),
|
|
289
289
|
}).transform((v) => {
|
|
290
290
|
return remap$(v, {
|