assistant-stream 0.3.11 → 0.3.12
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/core/AssistantStream.d.ts +1 -1
- package/dist/core/AssistantStream.d.ts.map +1 -1
- package/dist/core/AssistantStreamChunk.d.ts +2 -2
- package/dist/core/AssistantStreamChunk.d.ts.map +1 -1
- package/dist/core/accumulators/AssistantMessageStream.d.ts +2 -2
- package/dist/core/accumulators/AssistantMessageStream.d.ts.map +1 -1
- package/dist/core/accumulators/assistant-message-accumulator.d.ts +3 -3
- package/dist/core/accumulators/assistant-message-accumulator.d.ts.map +1 -1
- package/dist/core/modules/assistant-stream.d.ts +6 -6
- package/dist/core/modules/assistant-stream.d.ts.map +1 -1
- package/dist/core/modules/assistant-stream.js.map +1 -1
- package/dist/core/modules/text.d.ts +2 -2
- package/dist/core/modules/text.d.ts.map +1 -1
- package/dist/core/modules/tool-call.d.ts +5 -5
- package/dist/core/modules/tool-call.d.ts.map +1 -1
- package/dist/core/modules/tool-call.js.map +1 -1
- package/dist/core/object/ObjectStreamAccumulator.d.ts +2 -2
- package/dist/core/object/ObjectStreamAccumulator.d.ts.map +1 -1
- package/dist/core/object/ObjectStreamAccumulator.js +2 -2
- package/dist/core/object/ObjectStreamAccumulator.js.map +1 -1
- package/dist/core/object/ObjectStreamResponse.d.ts +1 -1
- package/dist/core/object/ObjectStreamResponse.d.ts.map +1 -1
- package/dist/core/object/createObjectStream.d.ts +2 -2
- package/dist/core/object/createObjectStream.d.ts.map +1 -1
- package/dist/core/object/types.d.ts +1 -1
- package/dist/core/object/types.d.ts.map +1 -1
- package/dist/core/serialization/PlainText.d.ts +2 -2
- package/dist/core/serialization/PlainText.d.ts.map +1 -1
- package/dist/core/serialization/PlainText.js +2 -1
- package/dist/core/serialization/PlainText.js.map +1 -1
- package/dist/core/serialization/assistant-transport/AssistantTransport.d.ts +2 -2
- package/dist/core/serialization/assistant-transport/AssistantTransport.d.ts.map +1 -1
- package/dist/core/serialization/data-stream/DataStream.d.ts +2 -2
- package/dist/core/serialization/data-stream/DataStream.d.ts.map +1 -1
- package/dist/core/serialization/data-stream/DataStream.js +1 -0
- package/dist/core/serialization/data-stream/DataStream.js.map +1 -1
- package/dist/core/serialization/data-stream/chunk-types.d.ts +2 -2
- package/dist/core/serialization/data-stream/chunk-types.d.ts.map +1 -1
- package/dist/core/serialization/data-stream/serialization.d.ts +1 -1
- package/dist/core/serialization/data-stream/serialization.d.ts.map +1 -1
- package/dist/core/serialization/ui-message-stream/UIMessageStream.d.ts +1 -1
- package/dist/core/serialization/ui-message-stream/UIMessageStream.d.ts.map +1 -1
- package/dist/core/serialization/ui-message-stream/UIMessageStream.js +1 -0
- package/dist/core/serialization/ui-message-stream/UIMessageStream.js.map +1 -1
- package/dist/core/tool/ToolCallReader.d.ts +4 -4
- package/dist/core/tool/ToolCallReader.d.ts.map +1 -1
- package/dist/core/tool/ToolExecutionStream.d.ts +3 -3
- package/dist/core/tool/ToolExecutionStream.d.ts.map +1 -1
- package/dist/core/tool/ToolExecutionStream.js.map +1 -1
- package/dist/core/tool/ToolResponse.d.ts +1 -1
- package/dist/core/tool/ToolResponse.d.ts.map +1 -1
- package/dist/core/tool/tool-types.d.ts +3 -3
- package/dist/core/tool/tool-types.d.ts.map +1 -1
- package/dist/core/tool/toolResultStream.d.ts +2 -2
- package/dist/core/tool/toolResultStream.d.ts.map +1 -1
- package/dist/core/utils/stream/AssistantMetaTransformStream.d.ts +1 -1
- package/dist/core/utils/stream/AssistantMetaTransformStream.d.ts.map +1 -1
- package/dist/core/utils/stream/AssistantMetaTransformStream.js.map +1 -1
- package/dist/core/utils/stream/AssistantTransformStream.d.ts +2 -2
- package/dist/core/utils/stream/AssistantTransformStream.d.ts.map +1 -1
- package/dist/core/utils/stream/merge.d.ts +1 -1
- package/dist/core/utils/stream/merge.d.ts.map +1 -1
- package/dist/core/utils/stream/path-utils.d.ts +1 -1
- package/dist/core/utils/stream/path-utils.d.ts.map +1 -1
- package/dist/core/utils/types.d.ts +1 -1
- package/dist/core/utils/types.d.ts.map +1 -1
- package/dist/utils/json/is-json.d.ts +1 -1
- package/dist/utils/json/is-json.d.ts.map +1 -1
- package/dist/utils/json/parse-partial-json-object.d.ts +1 -1
- package/dist/utils/json/parse-partial-json-object.d.ts.map +1 -1
- package/dist/utils/json/parse-partial-json-object.js +1 -1
- package/dist/utils/json/parse-partial-json-object.js.map +1 -1
- package/dist/utils/promiseWithResolvers.d.ts.map +1 -1
- package/dist/utils/promiseWithResolvers.js +1 -1
- package/dist/utils/promiseWithResolvers.js.map +1 -1
- package/package.json +4 -4
- package/src/core/AssistantStream.ts +1 -1
- package/src/core/AssistantStreamChunk.ts +2 -2
- package/src/core/accumulators/AssistantMessageStream.ts +2 -2
- package/src/core/accumulators/assistant-message-accumulator.ts +3 -3
- package/src/core/modules/assistant-stream.ts +6 -6
- package/src/core/modules/text.ts +3 -3
- package/src/core/modules/tool-call.ts +6 -6
- package/src/core/object/ObjectStream.test.ts +2 -2
- package/src/core/object/ObjectStreamAccumulator.ts +12 -4
- package/src/core/object/ObjectStreamResponse.ts +1 -1
- package/src/core/object/createObjectStream.ts +2 -2
- package/src/core/object/types.ts +1 -1
- package/src/core/serialization/PlainText.ts +4 -3
- package/src/core/serialization/assistant-transport/AssistantTransport.test.ts +1 -1
- package/src/core/serialization/assistant-transport/AssistantTransport.ts +2 -2
- package/src/core/serialization/data-stream/DataStream.ts +7 -6
- package/src/core/serialization/data-stream/chunk-types.ts +2 -2
- package/src/core/serialization/data-stream/serialization.ts +1 -1
- package/src/core/serialization/ui-message-stream/UIMessageStream.ts +4 -3
- package/src/core/tool/ToolCallReader.ts +4 -4
- package/src/core/tool/ToolExecutionStream.ts +8 -6
- package/src/core/tool/ToolResponse.ts +1 -1
- package/src/core/tool/schema-utils.test.ts +2 -2
- package/src/core/tool/tool-types.ts +3 -3
- package/src/core/tool/toolResultStream.test.ts +2 -2
- package/src/core/tool/toolResultStream.ts +4 -4
- package/src/core/utils/stream/AssistantMetaTransformStream.ts +4 -1
- package/src/core/utils/stream/AssistantTransformStream.ts +2 -2
- package/src/core/utils/stream/merge.ts +1 -1
- package/src/core/utils/stream/path-utils.ts +1 -1
- package/src/core/utils/types.ts +1 -1
- package/src/utils/json/is-json.ts +1 -1
- package/src/utils/json/parse-partial-json-object.ts +2 -2
- package/src/utils/promiseWithResolvers.ts +1 -1
|
@@ -3,15 +3,15 @@ import {
|
|
|
3
3
|
parsePartialJsonObject,
|
|
4
4
|
getPartialJsonObjectFieldState,
|
|
5
5
|
} from "../../utils/json/parse-partial-json-object";
|
|
6
|
-
import {
|
|
6
|
+
import type {
|
|
7
7
|
ToolCallArgsReader,
|
|
8
8
|
ToolCallReader,
|
|
9
9
|
ToolCallResponseReader,
|
|
10
10
|
} from "./tool-types";
|
|
11
|
-
import { DeepPartial, TypeAtPath, TypePath } from "./type-path-utils";
|
|
12
|
-
import { ToolResponse } from "./ToolResponse";
|
|
11
|
+
import type { DeepPartial, TypeAtPath, TypePath } from "./type-path-utils";
|
|
12
|
+
import type { ToolResponse } from "./ToolResponse";
|
|
13
13
|
import { asAsyncIterableStream } from "../../utils/AsyncIterableStream";
|
|
14
|
-
import {
|
|
14
|
+
import type {
|
|
15
15
|
AsyncIterableStream,
|
|
16
16
|
ReadonlyJSONObject,
|
|
17
17
|
ReadonlyJSONValue,
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import sjson from "secure-json-parse";
|
|
2
|
-
import { AssistantStreamChunk } from "../AssistantStreamChunk";
|
|
2
|
+
import type { AssistantStreamChunk } from "../AssistantStreamChunk";
|
|
3
3
|
import {
|
|
4
|
-
AssistantMetaStreamChunk,
|
|
4
|
+
type AssistantMetaStreamChunk,
|
|
5
5
|
AssistantMetaTransformStream,
|
|
6
6
|
} from "../utils/stream/AssistantMetaTransformStream";
|
|
7
7
|
import { PipeableTransformStream } from "../utils/stream/PipeableTransformStream";
|
|
8
|
-
import {
|
|
8
|
+
import type {
|
|
9
9
|
ReadonlyJSONObject,
|
|
10
10
|
ReadonlyJSONValue,
|
|
11
11
|
} from "../../utils/json/json-value";
|
|
12
12
|
import { ToolResponse } from "./ToolResponse";
|
|
13
13
|
import { withPromiseOrValue } from "../utils/withPromiseOrValue";
|
|
14
14
|
import { ToolCallReaderImpl } from "./ToolCallReader";
|
|
15
|
-
import { ToolCallReader } from "./tool-types";
|
|
15
|
+
import type { ToolCallReader } from "./tool-types";
|
|
16
16
|
|
|
17
17
|
type ToolCallback = (toolCall: {
|
|
18
18
|
toolCallId: string;
|
|
@@ -119,9 +119,11 @@ export class ToolExecutionStream extends PipeableTransformStream<
|
|
|
119
119
|
let isExecuting = false;
|
|
120
120
|
const promise = withPromiseOrValue(
|
|
121
121
|
() => {
|
|
122
|
-
let args;
|
|
122
|
+
let args: ReadonlyJSONObject;
|
|
123
123
|
try {
|
|
124
|
-
args = sjson.parse(
|
|
124
|
+
args = sjson.parse(
|
|
125
|
+
streamController.argsText,
|
|
126
|
+
) as ReadonlyJSONObject;
|
|
125
127
|
} catch (e) {
|
|
126
128
|
throw new Error(
|
|
127
129
|
`Function parameter parsing failed. ${JSON.stringify((e as Error).message)}`,
|
|
@@ -171,7 +171,7 @@ describe("toPartialJSONSchema", () => {
|
|
|
171
171
|
};
|
|
172
172
|
const result = toPartialJSONSchema(schema);
|
|
173
173
|
expect(result.required).toBeUndefined();
|
|
174
|
-
const address = result.properties
|
|
174
|
+
const address = result.properties!.address as Record<string, unknown>;
|
|
175
175
|
expect(address.required).toBeUndefined();
|
|
176
176
|
});
|
|
177
177
|
|
|
@@ -192,7 +192,7 @@ describe("toPartialJSONSchema", () => {
|
|
|
192
192
|
};
|
|
193
193
|
const result = toPartialJSONSchema(schema);
|
|
194
194
|
expect(result.required).toBeUndefined();
|
|
195
|
-
const tags = result.properties
|
|
195
|
+
const tags = result.properties!.tags as Record<string, unknown>;
|
|
196
196
|
const items = tags.items as Record<string, unknown>;
|
|
197
197
|
expect(items.required).toEqual(["label"]);
|
|
198
198
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { JSONSchema7 } from "json-schema";
|
|
2
|
-
import { DeepPartial, TypeAtPath, TypePath } from "./type-path-utils";
|
|
3
|
-
import { AsyncIterableStream } from "../../utils";
|
|
2
|
+
import type { DeepPartial, TypeAtPath, TypePath } from "./type-path-utils";
|
|
3
|
+
import type { AsyncIterableStream } from "../../utils";
|
|
4
4
|
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
5
|
-
import { ToolResponse } from "./ToolResponse";
|
|
5
|
+
import type { ToolResponse } from "./ToolResponse";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Interface for reading tool call arguments from a stream, which are
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
2
|
import { unstable_runPendingTools } from "./toolResultStream";
|
|
3
|
-
import { AssistantMessage, ToolCallPart } from "../utils/types";
|
|
4
|
-
import { Tool } from "./tool-types";
|
|
3
|
+
import type { AssistantMessage, ToolCallPart } from "../utils/types";
|
|
4
|
+
import type { Tool } from "./tool-types";
|
|
5
5
|
|
|
6
6
|
const createDelayedTool = (delay: number, result?: string): Tool => ({
|
|
7
7
|
parameters: { type: "object", properties: {} },
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Tool, ToolCallReader, ToolExecuteFunction } from "./tool-types";
|
|
2
|
-
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
1
|
+
import type { Tool, ToolCallReader, ToolExecuteFunction } from "./tool-types";
|
|
2
|
+
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
3
|
import { ToolResponse } from "./ToolResponse";
|
|
4
4
|
import { ToolExecutionStream } from "./ToolExecutionStream";
|
|
5
|
-
import { AssistantMessage } from "../utils/types";
|
|
6
|
-
import { ReadonlyJSONObject, ReadonlyJSONValue } from "../../utils";
|
|
5
|
+
import type { AssistantMessage } from "../utils/types";
|
|
6
|
+
import type { ReadonlyJSONObject, ReadonlyJSONValue } from "../../utils";
|
|
7
7
|
|
|
8
8
|
const isStandardSchemaV1 = (
|
|
9
9
|
schema: unknown,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AssistantStreamChunk } from "../../AssistantStreamChunk";
|
|
1
|
+
import type { AssistantStreamChunk } from "../../AssistantStreamChunk";
|
|
2
2
|
import {
|
|
3
|
-
AssistantStreamController,
|
|
3
|
+
type AssistantStreamController,
|
|
4
4
|
createAssistantStreamController,
|
|
5
5
|
} from "../../modules/assistant-stream";
|
|
6
6
|
|
package/src/core/utils/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import sjson from "secure-json-parse";
|
|
2
2
|
import { fixJson } from "./fix-json";
|
|
3
|
-
import { ReadonlyJSONObject } from "./json-value";
|
|
3
|
+
import type { ReadonlyJSONObject } from "./json-value";
|
|
4
4
|
|
|
5
5
|
const PARTIAL_JSON_OBJECT_META_SYMBOL = Symbol(
|
|
6
6
|
"aui.parse-partial-json-object.meta",
|
|
@@ -75,7 +75,7 @@ const getFieldState = (
|
|
|
75
75
|
const [field, ...restPath] = fieldPath as [string, ...string[]];
|
|
76
76
|
|
|
77
77
|
// 3) field doesn't yet exist in parent: return "partial"
|
|
78
|
-
if (!Object.
|
|
78
|
+
if (!Object.hasOwn(parent, field)) return "partial";
|
|
79
79
|
|
|
80
80
|
const [partialField, ...restPartialPath] = parentMeta.partialPath;
|
|
81
81
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const promiseWithResolvers =
|
|
1
|
+
export const promiseWithResolvers = <T>() => {
|
|
2
2
|
let resolve: ((value: T | PromiseLike<T>) => void) | undefined;
|
|
3
3
|
let reject: ((reason?: unknown) => void) | undefined;
|
|
4
4
|
const promise = new Promise<T>((res, rej) => {
|