ai 3.0.4 → 3.0.6
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.mts +998 -0
- package/dist/index.d.ts +15 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -12
- package/prompts/dist/index.d.mts +242 -0
- package/prompts/dist/index.js.map +1 -1
- package/prompts/dist/index.mjs.map +1 -1
- package/react/dist/index.d.mts +475 -0
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs.map +1 -1
- package/react/dist/index.server.d.mts +15 -0
- package/rsc/dist/index.d.ts +167 -0
- package/rsc/dist/index.mjs +18 -0
- package/rsc/dist/{rsc-client.d.ts → rsc-client.d.mts} +1 -1
- package/rsc/dist/rsc-client.mjs +1 -1
- package/rsc/dist/rsc-client.mjs.map +1 -1
- package/rsc/dist/{rsc-server.d.ts → rsc-server.d.mts} +0 -1
- package/rsc/dist/rsc-server.mjs +62 -18
- package/rsc/dist/rsc-server.mjs.map +1 -1
- package/rsc/dist/rsc-shared.mjs +1 -0
- package/rsc/dist/rsc-shared.mjs.map +1 -1
- package/solid/dist/index.d.mts +347 -0
- package/solid/dist/index.js.map +1 -1
- package/solid/dist/index.mjs.map +1 -1
- package/svelte/dist/index.d.mts +344 -0
- package/svelte/dist/index.js.map +1 -1
- package/svelte/dist/index.mjs.map +1 -1
- package/vue/dist/index.d.mts +341 -0
- package/vue/dist/index.js.map +1 -1
- package/vue/dist/index.mjs.map +1 -1
- package/rsc/dist/rsc-types.d.ts +0 -6
- package/rsc/dist/rsc-types.mjs +0 -1
- package/rsc/dist/rsc-types.mjs.map +0 -1
- /package/rsc/dist/{rsc-shared.d.ts → rsc-shared.d.mts} +0 -0
@@ -1 +1 @@
|
|
1
|
-
export { useAIState, useActions, useStreamableValue, useSyncUIState, useUIState } from './rsc-shared';
|
1
|
+
export { useAIState, useActions, useStreamableValue, useSyncUIState, useUIState } from './rsc-shared.mjs';
|
package/rsc/dist/rsc-client.mjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../rsc-client.ts"],"sourcesContent":["export {\n useStreamableValue,\n useUIState,\n useAIState,\n useActions,\n useSyncUIState,\n} from './rsc-shared';\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
|
1
|
+
{"version":3,"sources":["../rsc-client.ts"],"sourcesContent":["export {\n useStreamableValue,\n useUIState,\n useAIState,\n useActions,\n useSyncUIState,\n} from './rsc-shared.mjs';\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
|
@@ -2,7 +2,6 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
3
3
|
import OpenAI from 'openai';
|
4
4
|
import { z } from 'zod';
|
5
|
-
import './rsc-shared';
|
6
5
|
|
7
6
|
type AIAction<T = any, R = any> = (...args: T[]) => Promise<R>;
|
8
7
|
type AIActions<T = any, R = any> = Record<string, AIAction<T, R>>;
|
package/rsc/dist/rsc-server.mjs
CHANGED
@@ -745,7 +745,7 @@ function createFunctionCallTransformer(callbacks) {
|
|
745
745
|
type: "function",
|
746
746
|
func: {
|
747
747
|
name: tool.function.name,
|
748
|
-
arguments: tool.function.arguments
|
748
|
+
arguments: JSON.parse(tool.function.arguments)
|
749
749
|
}
|
750
750
|
});
|
751
751
|
}
|
@@ -842,6 +842,7 @@ function createFunctionCallTransformer(callbacks) {
|
|
842
842
|
|
843
843
|
// rsc/constants.ts
|
844
844
|
var STREAMABLE_VALUE_TYPE = Symbol.for("ui.streamable.value");
|
845
|
+
var DEV_DEFAULT_STREAMABLE_WARNING_TIME = 15 * 1e3;
|
845
846
|
|
846
847
|
// rsc/streamable.tsx
|
847
848
|
import { Fragment as Fragment2, jsxs as jsxs2 } from "react/jsx-runtime";
|
@@ -849,27 +850,39 @@ function createStreamableUI(initialValue) {
|
|
849
850
|
let currentValue = initialValue;
|
850
851
|
let closed = false;
|
851
852
|
let { row, resolve, reject } = createSuspensedChunk(initialValue);
|
852
|
-
function assertStream() {
|
853
|
+
function assertStream(method) {
|
853
854
|
if (closed) {
|
854
|
-
throw new Error("UI stream is already closed.");
|
855
|
+
throw new Error(method + ": UI stream is already closed.");
|
855
856
|
}
|
856
857
|
}
|
858
|
+
let warningTimeout;
|
859
|
+
function warnUnclosedStream() {
|
860
|
+
if (process.env.NODE_ENV === "development") {
|
861
|
+
if (warningTimeout) {
|
862
|
+
clearTimeout(warningTimeout);
|
863
|
+
}
|
864
|
+
warningTimeout = setTimeout(() => {
|
865
|
+
console.warn(
|
866
|
+
"The streamable UI has been slow to update. This may be a bug or a performance issue or you forgot to call `.done()`."
|
867
|
+
);
|
868
|
+
}, DEV_DEFAULT_STREAMABLE_WARNING_TIME);
|
869
|
+
}
|
870
|
+
}
|
871
|
+
warnUnclosedStream();
|
857
872
|
return {
|
858
873
|
value: row,
|
859
874
|
update(value) {
|
860
|
-
assertStream();
|
875
|
+
assertStream(".update()");
|
861
876
|
const resolvable = createResolvablePromise();
|
862
|
-
|
877
|
+
currentValue = value;
|
878
|
+
resolve({ value: currentValue, done: false, next: resolvable.promise });
|
863
879
|
resolve = resolvable.resolve;
|
864
880
|
reject = resolvable.reject;
|
865
|
-
|
881
|
+
warnUnclosedStream();
|
866
882
|
},
|
867
883
|
append(value) {
|
868
|
-
assertStream();
|
884
|
+
assertStream(".append()");
|
869
885
|
const resolvable = createResolvablePromise();
|
870
|
-
resolve({ value, done: false, next: resolvable.promise });
|
871
|
-
resolve = resolvable.resolve;
|
872
|
-
reject = resolvable.reject;
|
873
886
|
if (typeof currentValue === "string" && typeof value === "string") {
|
874
887
|
currentValue += value;
|
875
888
|
} else {
|
@@ -878,14 +891,24 @@ function createStreamableUI(initialValue) {
|
|
878
891
|
value
|
879
892
|
] });
|
880
893
|
}
|
894
|
+
resolve({ value: currentValue, done: false, next: resolvable.promise });
|
895
|
+
resolve = resolvable.resolve;
|
896
|
+
reject = resolvable.reject;
|
897
|
+
warnUnclosedStream();
|
881
898
|
},
|
882
899
|
error(error) {
|
883
|
-
assertStream();
|
900
|
+
assertStream(".error()");
|
901
|
+
if (warningTimeout) {
|
902
|
+
clearTimeout(warningTimeout);
|
903
|
+
}
|
884
904
|
closed = true;
|
885
905
|
reject(error);
|
886
906
|
},
|
887
907
|
done(...args) {
|
888
|
-
assertStream();
|
908
|
+
assertStream(".done()");
|
909
|
+
if (warningTimeout) {
|
910
|
+
clearTimeout(warningTimeout);
|
911
|
+
}
|
889
912
|
closed = true;
|
890
913
|
if (args.length) {
|
891
914
|
resolve({ value: args[0], done: true });
|
@@ -898,11 +921,25 @@ function createStreamableUI(initialValue) {
|
|
898
921
|
function createStreamableValue(initialValue) {
|
899
922
|
let closed = false;
|
900
923
|
let { promise, resolve, reject } = createResolvablePromise();
|
901
|
-
function assertStream() {
|
924
|
+
function assertStream(method) {
|
902
925
|
if (closed) {
|
903
|
-
throw new Error("Value stream is already closed.");
|
926
|
+
throw new Error(method + ": Value stream is already closed.");
|
904
927
|
}
|
905
928
|
}
|
929
|
+
let warningTimeout;
|
930
|
+
function warnUnclosedStream() {
|
931
|
+
if (process.env.NODE_ENV === "development") {
|
932
|
+
if (warningTimeout) {
|
933
|
+
clearTimeout(warningTimeout);
|
934
|
+
}
|
935
|
+
warningTimeout = setTimeout(() => {
|
936
|
+
console.warn(
|
937
|
+
"The streamable UI has been slow to update. This may be a bug or a performance issue or you forgot to call `.done()`."
|
938
|
+
);
|
939
|
+
}, DEV_DEFAULT_STREAMABLE_WARNING_TIME);
|
940
|
+
}
|
941
|
+
}
|
942
|
+
warnUnclosedStream();
|
906
943
|
function createWrapped(val, initial) {
|
907
944
|
if (initial) {
|
908
945
|
return {
|
@@ -919,21 +956,28 @@ function createStreamableValue(initialValue) {
|
|
919
956
|
return {
|
920
957
|
value: createWrapped(initialValue, true),
|
921
958
|
update(value) {
|
922
|
-
assertStream();
|
959
|
+
assertStream(".update()");
|
923
960
|
const resolvePrevious = resolve;
|
924
961
|
const resolvable = createResolvablePromise();
|
925
962
|
promise = resolvable.promise;
|
926
963
|
resolve = resolvable.resolve;
|
927
964
|
reject = resolvable.reject;
|
928
965
|
resolvePrevious(createWrapped(value));
|
966
|
+
warnUnclosedStream();
|
929
967
|
},
|
930
968
|
error(error) {
|
931
|
-
assertStream();
|
969
|
+
assertStream(".error()");
|
970
|
+
if (warningTimeout) {
|
971
|
+
clearTimeout(warningTimeout);
|
972
|
+
}
|
932
973
|
closed = true;
|
933
974
|
reject(error);
|
934
975
|
},
|
935
976
|
done(...args) {
|
936
|
-
assertStream();
|
977
|
+
assertStream(".done()");
|
978
|
+
if (warningTimeout) {
|
979
|
+
clearTimeout(warningTimeout);
|
980
|
+
}
|
937
981
|
closed = true;
|
938
982
|
if (args.length) {
|
939
983
|
resolve({ curr: args[0] });
|
@@ -1075,7 +1119,7 @@ function render(options) {
|
|
1075
1119
|
|
1076
1120
|
// rsc/provider.tsx
|
1077
1121
|
import * as React2 from "react";
|
1078
|
-
import { InternalAIProvider } from "./rsc-shared";
|
1122
|
+
import { InternalAIProvider } from "./rsc-shared.mjs";
|
1079
1123
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
1080
1124
|
async function innerAction({
|
1081
1125
|
action,
|