@anuma/sdk 6.33.2 → 6.35.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/expo/index.cjs +1304 -300
- package/dist/expo/index.d.mts +278 -11
- package/dist/expo/index.d.ts +278 -11
- package/dist/expo/index.mjs +1297 -300
- package/dist/index.cjs +18 -6
- package/dist/index.mjs +18 -6
- package/dist/memory/context.d.mts +21 -1
- package/dist/memory/context.d.ts +21 -1
- package/dist/react/index.cjs +1385 -381
- package/dist/react/index.d.mts +311 -11
- package/dist/react/index.d.ts +311 -11
- package/dist/react/index.mjs +1378 -381
- package/dist/server/index.cjs +319 -99
- package/dist/server/index.d.mts +138 -11
- package/dist/server/index.d.ts +138 -11
- package/dist/server/index.mjs +316 -99
- package/dist/telemetry/index.d.mts +3 -4
- package/dist/telemetry/index.d.ts +3 -4
- package/dist/tools/selection/index.cjs +18 -6
- package/dist/tools/selection/index.mjs +18 -6
- package/package.json +1 -1
|
@@ -523,10 +523,9 @@ interface MetricsHooksOptions {
|
|
|
523
523
|
includeErrorMessages?: boolean;
|
|
524
524
|
}
|
|
525
525
|
/**
|
|
526
|
-
* Build {@link RunHooks} that report run lifecycle, model calls, and tool
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
* already swallows hook errors; we avoid double-logging here).
|
|
526
|
+
* Build {@link RunHooks} that report run lifecycle, model calls, and tool calls to `sink`; every run ends in exactly one `run.completed` or `run.failed`, and no message contents or tool arguments are emitted.
|
|
527
|
+
*
|
|
528
|
+
* @see TELEMETRY.md for event payloads and metric names.
|
|
530
529
|
*/
|
|
531
530
|
declare function createMetricsHooks(sink: TelemetrySink, opts?: MetricsHooksOptions): RunHooks;
|
|
532
531
|
|
|
@@ -523,10 +523,9 @@ interface MetricsHooksOptions {
|
|
|
523
523
|
includeErrorMessages?: boolean;
|
|
524
524
|
}
|
|
525
525
|
/**
|
|
526
|
-
* Build {@link RunHooks} that report run lifecycle, model calls, and tool
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
* already swallows hook errors; we avoid double-logging here).
|
|
526
|
+
* Build {@link RunHooks} that report run lifecycle, model calls, and tool calls to `sink`; every run ends in exactly one `run.completed` or `run.failed`, and no message contents or tool arguments are emitted.
|
|
527
|
+
*
|
|
528
|
+
* @see TELEMETRY.md for event payloads and metric names.
|
|
530
529
|
*/
|
|
531
530
|
declare function createMetricsHooks(sink: TelemetrySink, opts?: MetricsHooksOptions): RunHooks;
|
|
532
531
|
|
|
@@ -1058,7 +1058,7 @@ async function embedOne(text, options, outer) {
|
|
|
1058
1058
|
}
|
|
1059
1059
|
var DEFAULT_EMBEDDING_BATCH_SIZE = 100;
|
|
1060
1060
|
var DEFAULT_EMBEDDING_BATCH_CONCURRENCY = 3;
|
|
1061
|
-
async function generateEmbeddingsBatch(texts, headers, baseUrl, model, onUsage, maskInput, timeoutMs) {
|
|
1061
|
+
async function generateEmbeddingsBatch(texts, headers, baseUrl, model, onUsage, maskInput, timeoutMs, outer) {
|
|
1062
1062
|
const response = await withEmbeddingRetry(
|
|
1063
1063
|
() => withDeadline(
|
|
1064
1064
|
(signal) => postApiV1Embeddings({
|
|
@@ -1068,8 +1068,10 @@ async function generateEmbeddingsBatch(texts, headers, baseUrl, model, onUsage,
|
|
|
1068
1068
|
...signal && { signal }
|
|
1069
1069
|
}),
|
|
1070
1070
|
timeoutMs,
|
|
1071
|
-
"embedding batch request"
|
|
1072
|
-
|
|
1071
|
+
"embedding batch request",
|
|
1072
|
+
outer
|
|
1073
|
+
),
|
|
1074
|
+
outer
|
|
1073
1075
|
);
|
|
1074
1076
|
if (response.error) {
|
|
1075
1077
|
throw embeddingErrorFrom(response);
|
|
@@ -1087,6 +1089,11 @@ async function generateEmbeddingsBatch(texts, headers, baseUrl, model, onUsage,
|
|
|
1087
1089
|
}
|
|
1088
1090
|
async function generateEmbeddings(texts, options) {
|
|
1089
1091
|
if (texts.length === 0) return [];
|
|
1092
|
+
const total = options.totalTimeoutMs;
|
|
1093
|
+
if (total === void 0) return embedMany(texts, options, void 0);
|
|
1094
|
+
return withDeadline((signal) => embedMany(texts, options, signal), total, "embedding batch");
|
|
1095
|
+
}
|
|
1096
|
+
async function embedMany(texts, options, outer) {
|
|
1090
1097
|
const { baseUrl = BASE_URL, model, batchSize, cache } = options;
|
|
1091
1098
|
const timeoutMs = options.timeoutMs ?? DEFAULT_EMBEDDING_REQUEST_TIMEOUT_MS;
|
|
1092
1099
|
const chunkSize = batchSize ?? DEFAULT_EMBEDDING_BATCH_SIZE;
|
|
@@ -1107,7 +1114,8 @@ async function generateEmbeddings(texts, options) {
|
|
|
1107
1114
|
if (uncachedTexts.length === 0) {
|
|
1108
1115
|
return results;
|
|
1109
1116
|
}
|
|
1110
|
-
const headers = await resolveAuthHeaders(options);
|
|
1117
|
+
const headers = await resolveAuthHeaders(options, outer);
|
|
1118
|
+
if (outer?.aborted) throw outer.reason;
|
|
1111
1119
|
const embeddingModel = model ?? DEFAULT_API_EMBEDDING_MODEL;
|
|
1112
1120
|
let newEmbeddings;
|
|
1113
1121
|
if (uncachedTexts.length <= chunkSize) {
|
|
@@ -1118,7 +1126,8 @@ async function generateEmbeddings(texts, options) {
|
|
|
1118
1126
|
embeddingModel,
|
|
1119
1127
|
options.onUsage,
|
|
1120
1128
|
options.maskInput,
|
|
1121
|
-
timeoutMs
|
|
1129
|
+
timeoutMs,
|
|
1130
|
+
outer
|
|
1122
1131
|
);
|
|
1123
1132
|
} else {
|
|
1124
1133
|
const chunks = [];
|
|
@@ -1129,6 +1138,7 @@ async function generateEmbeddings(texts, options) {
|
|
|
1129
1138
|
let nextIndex = 0;
|
|
1130
1139
|
const worker = async () => {
|
|
1131
1140
|
while (nextIndex < chunks.length) {
|
|
1141
|
+
if (outer?.aborted) throw outer.reason;
|
|
1132
1142
|
const idx = nextIndex++;
|
|
1133
1143
|
allEmbeddings[idx] = await generateEmbeddingsBatch(
|
|
1134
1144
|
chunks[idx],
|
|
@@ -1137,7 +1147,8 @@ async function generateEmbeddings(texts, options) {
|
|
|
1137
1147
|
embeddingModel,
|
|
1138
1148
|
options.onUsage,
|
|
1139
1149
|
options.maskInput,
|
|
1140
|
-
timeoutMs
|
|
1150
|
+
timeoutMs,
|
|
1151
|
+
outer
|
|
1141
1152
|
);
|
|
1142
1153
|
}
|
|
1143
1154
|
};
|
|
@@ -1148,6 +1159,7 @@ async function generateEmbeddings(texts, options) {
|
|
|
1148
1159
|
await Promise.all(workers);
|
|
1149
1160
|
newEmbeddings = allEmbeddings.flat();
|
|
1150
1161
|
}
|
|
1162
|
+
if (outer?.aborted) throw outer.reason;
|
|
1151
1163
|
for (let i = 0; i < uncachedIndices.length; i++) {
|
|
1152
1164
|
const f32Embedding = Float32Array.from(newEmbeddings[i]);
|
|
1153
1165
|
results[uncachedIndices[i]] = Array.from(f32Embedding);
|
|
@@ -936,7 +936,7 @@ async function embedOne(text, options, outer) {
|
|
|
936
936
|
}
|
|
937
937
|
var DEFAULT_EMBEDDING_BATCH_SIZE = 100;
|
|
938
938
|
var DEFAULT_EMBEDDING_BATCH_CONCURRENCY = 3;
|
|
939
|
-
async function generateEmbeddingsBatch(texts, headers, baseUrl, model, onUsage, maskInput, timeoutMs) {
|
|
939
|
+
async function generateEmbeddingsBatch(texts, headers, baseUrl, model, onUsage, maskInput, timeoutMs, outer) {
|
|
940
940
|
const response = await withEmbeddingRetry(
|
|
941
941
|
() => withDeadline(
|
|
942
942
|
(signal) => postApiV1Embeddings({
|
|
@@ -946,8 +946,10 @@ async function generateEmbeddingsBatch(texts, headers, baseUrl, model, onUsage,
|
|
|
946
946
|
...signal && { signal }
|
|
947
947
|
}),
|
|
948
948
|
timeoutMs,
|
|
949
|
-
"embedding batch request"
|
|
950
|
-
|
|
949
|
+
"embedding batch request",
|
|
950
|
+
outer
|
|
951
|
+
),
|
|
952
|
+
outer
|
|
951
953
|
);
|
|
952
954
|
if (response.error) {
|
|
953
955
|
throw embeddingErrorFrom(response);
|
|
@@ -965,6 +967,11 @@ async function generateEmbeddingsBatch(texts, headers, baseUrl, model, onUsage,
|
|
|
965
967
|
}
|
|
966
968
|
async function generateEmbeddings(texts, options) {
|
|
967
969
|
if (texts.length === 0) return [];
|
|
970
|
+
const total = options.totalTimeoutMs;
|
|
971
|
+
if (total === void 0) return embedMany(texts, options, void 0);
|
|
972
|
+
return withDeadline((signal) => embedMany(texts, options, signal), total, "embedding batch");
|
|
973
|
+
}
|
|
974
|
+
async function embedMany(texts, options, outer) {
|
|
968
975
|
const { baseUrl = BASE_URL, model, batchSize, cache } = options;
|
|
969
976
|
const timeoutMs = options.timeoutMs ?? DEFAULT_EMBEDDING_REQUEST_TIMEOUT_MS;
|
|
970
977
|
const chunkSize = batchSize ?? DEFAULT_EMBEDDING_BATCH_SIZE;
|
|
@@ -985,7 +992,8 @@ async function generateEmbeddings(texts, options) {
|
|
|
985
992
|
if (uncachedTexts.length === 0) {
|
|
986
993
|
return results;
|
|
987
994
|
}
|
|
988
|
-
const headers = await resolveAuthHeaders(options);
|
|
995
|
+
const headers = await resolveAuthHeaders(options, outer);
|
|
996
|
+
if (outer?.aborted) throw outer.reason;
|
|
989
997
|
const embeddingModel = model ?? DEFAULT_API_EMBEDDING_MODEL;
|
|
990
998
|
let newEmbeddings;
|
|
991
999
|
if (uncachedTexts.length <= chunkSize) {
|
|
@@ -996,7 +1004,8 @@ async function generateEmbeddings(texts, options) {
|
|
|
996
1004
|
embeddingModel,
|
|
997
1005
|
options.onUsage,
|
|
998
1006
|
options.maskInput,
|
|
999
|
-
timeoutMs
|
|
1007
|
+
timeoutMs,
|
|
1008
|
+
outer
|
|
1000
1009
|
);
|
|
1001
1010
|
} else {
|
|
1002
1011
|
const chunks = [];
|
|
@@ -1007,6 +1016,7 @@ async function generateEmbeddings(texts, options) {
|
|
|
1007
1016
|
let nextIndex = 0;
|
|
1008
1017
|
const worker = async () => {
|
|
1009
1018
|
while (nextIndex < chunks.length) {
|
|
1019
|
+
if (outer?.aborted) throw outer.reason;
|
|
1010
1020
|
const idx = nextIndex++;
|
|
1011
1021
|
allEmbeddings[idx] = await generateEmbeddingsBatch(
|
|
1012
1022
|
chunks[idx],
|
|
@@ -1015,7 +1025,8 @@ async function generateEmbeddings(texts, options) {
|
|
|
1015
1025
|
embeddingModel,
|
|
1016
1026
|
options.onUsage,
|
|
1017
1027
|
options.maskInput,
|
|
1018
|
-
timeoutMs
|
|
1028
|
+
timeoutMs,
|
|
1029
|
+
outer
|
|
1019
1030
|
);
|
|
1020
1031
|
}
|
|
1021
1032
|
};
|
|
@@ -1026,6 +1037,7 @@ async function generateEmbeddings(texts, options) {
|
|
|
1026
1037
|
await Promise.all(workers);
|
|
1027
1038
|
newEmbeddings = allEmbeddings.flat();
|
|
1028
1039
|
}
|
|
1040
|
+
if (outer?.aborted) throw outer.reason;
|
|
1029
1041
|
for (let i = 0; i < uncachedIndices.length; i++) {
|
|
1030
1042
|
const f32Embedding = Float32Array.from(newEmbeddings[i]);
|
|
1031
1043
|
results[uncachedIndices[i]] = Array.from(f32Embedding);
|