@usewhisper/sdk 3.1.0 → 3.2.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/index.d.mts +31 -13
- package/index.d.ts +31 -13
- package/index.js +57 -12
- package/index.mjs +57 -12
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -215,6 +215,7 @@ interface RuntimeClientOptions {
|
|
|
215
215
|
compatMode?: CompatMode;
|
|
216
216
|
timeouts?: Partial<TimeoutBudgets>;
|
|
217
217
|
retryPolicy?: RetryPolicy;
|
|
218
|
+
fetchImpl?: typeof fetch;
|
|
218
219
|
}
|
|
219
220
|
interface RuntimeResponse<T> {
|
|
220
221
|
data: T;
|
|
@@ -325,6 +326,7 @@ declare class RuntimeClient {
|
|
|
325
326
|
private readonly diagnostics;
|
|
326
327
|
private readonly inFlight;
|
|
327
328
|
private readonly sendApiKeyHeader;
|
|
329
|
+
private readonly fetchImpl;
|
|
328
330
|
constructor(options: RuntimeClientOptions, diagnostics?: DiagnosticsStore);
|
|
329
331
|
getDiagnosticsStore(): DiagnosticsStore;
|
|
330
332
|
getCompatMode(): CompatMode;
|
|
@@ -414,11 +416,13 @@ interface MemoryWriteAck$1 {
|
|
|
414
416
|
success: boolean;
|
|
415
417
|
mode?: "async" | "sync";
|
|
416
418
|
trace_id?: string;
|
|
419
|
+
memory_id?: string;
|
|
417
420
|
job_id?: string;
|
|
418
421
|
status_url?: string;
|
|
419
422
|
accepted_at?: string;
|
|
420
423
|
visibility_sla_ms?: number;
|
|
421
424
|
pending_visibility?: boolean;
|
|
425
|
+
semantic_status?: "pending" | "ready";
|
|
422
426
|
queued?: boolean;
|
|
423
427
|
event_id?: string;
|
|
424
428
|
created?: number;
|
|
@@ -619,6 +623,7 @@ interface WhisperClientConfig {
|
|
|
619
623
|
baseUrl?: string;
|
|
620
624
|
project?: string;
|
|
621
625
|
compatMode?: CompatMode;
|
|
626
|
+
fetch?: typeof fetch;
|
|
622
627
|
timeouts?: Partial<TimeoutBudgets>;
|
|
623
628
|
retryPolicy?: RetryPolicy;
|
|
624
629
|
cache?: {
|
|
@@ -1036,6 +1041,9 @@ interface CanonicalSourceCreateParams {
|
|
|
1036
1041
|
name?: string;
|
|
1037
1042
|
auto_index?: boolean;
|
|
1038
1043
|
metadata?: Record<string, string>;
|
|
1044
|
+
ingestion_profile?: "auto" | "repo" | "web_docs" | "pdf_layout" | "video_transcript" | "plain_text";
|
|
1045
|
+
strategy_override?: "fixed" | "recursive" | "semantic" | "hierarchical" | "adaptive";
|
|
1046
|
+
profile_config?: Record<string, any>;
|
|
1039
1047
|
owner?: string;
|
|
1040
1048
|
repo?: string;
|
|
1041
1049
|
branch?: string;
|
|
@@ -1147,6 +1155,20 @@ interface MemoryWriteAck {
|
|
|
1147
1155
|
pending_visibility?: boolean;
|
|
1148
1156
|
[key: string]: any;
|
|
1149
1157
|
}
|
|
1158
|
+
interface MemoryWriteResult {
|
|
1159
|
+
id: string;
|
|
1160
|
+
success: boolean;
|
|
1161
|
+
path: "sota" | "legacy";
|
|
1162
|
+
fallback_used: boolean;
|
|
1163
|
+
mode?: "async" | "sync";
|
|
1164
|
+
memory_id?: string;
|
|
1165
|
+
job_id?: string;
|
|
1166
|
+
status_url?: string;
|
|
1167
|
+
accepted_at?: string;
|
|
1168
|
+
visibility_sla_ms?: number;
|
|
1169
|
+
pending_visibility?: boolean;
|
|
1170
|
+
semantic_status?: "pending" | "ready";
|
|
1171
|
+
}
|
|
1150
1172
|
type WhisperErrorCode = "INVALID_API_KEY" | "PROJECT_NOT_FOUND" | "PROJECT_AMBIGUOUS" | "RATE_LIMITED" | "TEMPORARY_UNAVAILABLE" | "NETWORK_ERROR" | "TIMEOUT" | "REQUEST_FAILED" | "MISSING_PROJECT";
|
|
1151
1173
|
declare class WhisperError extends Error {
|
|
1152
1174
|
code: WhisperErrorCode;
|
|
@@ -1214,6 +1236,9 @@ declare class WhisperContext {
|
|
|
1214
1236
|
allow_stt_fallback?: boolean;
|
|
1215
1237
|
max_duration_minutes?: number;
|
|
1216
1238
|
name?: string;
|
|
1239
|
+
ingestion_profile?: "auto" | "repo" | "web_docs" | "pdf_layout" | "video_transcript" | "plain_text";
|
|
1240
|
+
strategy_override?: "fixed" | "recursive" | "semantic" | "hierarchical" | "adaptive";
|
|
1241
|
+
profile_config?: Record<string, any>;
|
|
1217
1242
|
}): Promise<{
|
|
1218
1243
|
source_id: string;
|
|
1219
1244
|
sync_job_id?: string | null;
|
|
@@ -1227,6 +1252,9 @@ declare class WhisperContext {
|
|
|
1227
1252
|
content: string;
|
|
1228
1253
|
metadata?: Record<string, any>;
|
|
1229
1254
|
file_path?: string;
|
|
1255
|
+
ingestion_profile?: "auto" | "repo" | "web_docs" | "pdf_layout" | "video_transcript" | "plain_text";
|
|
1256
|
+
strategy_override?: "fixed" | "recursive" | "semantic" | "hierarchical" | "adaptive";
|
|
1257
|
+
profile_config?: Record<string, any>;
|
|
1230
1258
|
}>): Promise<{
|
|
1231
1259
|
ingested: number;
|
|
1232
1260
|
}>;
|
|
@@ -1251,12 +1279,7 @@ declare class WhisperContext {
|
|
|
1251
1279
|
async?: boolean;
|
|
1252
1280
|
write_mode?: "async" | "sync";
|
|
1253
1281
|
allow_legacy_fallback?: boolean;
|
|
1254
|
-
}): Promise<
|
|
1255
|
-
id: string;
|
|
1256
|
-
success: boolean;
|
|
1257
|
-
path: "sota" | "legacy";
|
|
1258
|
-
fallback_used: boolean;
|
|
1259
|
-
}>;
|
|
1282
|
+
}): Promise<MemoryWriteResult>;
|
|
1260
1283
|
addMemoriesBulk(params: {
|
|
1261
1284
|
project?: string;
|
|
1262
1285
|
memories: Array<{
|
|
@@ -1645,12 +1668,7 @@ declare class WhisperContext {
|
|
|
1645
1668
|
getStatus: (sourceId: string) => Promise<VideoIngestionStatus>;
|
|
1646
1669
|
};
|
|
1647
1670
|
readonly memory: {
|
|
1648
|
-
add: (params: Parameters<WhisperContext["addMemory"]>[0]) => Promise<
|
|
1649
|
-
id: string;
|
|
1650
|
-
success: boolean;
|
|
1651
|
-
path: "sota" | "legacy";
|
|
1652
|
-
fallback_used: boolean;
|
|
1653
|
-
}>;
|
|
1671
|
+
add: (params: Parameters<WhisperContext["addMemory"]>[0]) => Promise<MemoryWriteResult>;
|
|
1654
1672
|
addBulk: (params: Parameters<WhisperContext["addMemoriesBulk"]>[0]) => Promise<any>;
|
|
1655
1673
|
extract: (params: Parameters<WhisperContext["extractMemories"]>[0]) => Promise<MemoryExtractionResult>;
|
|
1656
1674
|
extractSession: (params: Parameters<WhisperContext["extractSessionMemories"]>[0]) => Promise<{
|
|
@@ -1784,4 +1802,4 @@ declare class WhisperContext {
|
|
|
1784
1802
|
};
|
|
1785
1803
|
}
|
|
1786
1804
|
|
|
1787
|
-
export { type CanonicalSourceCreateParams, type CanonicalSourceCreateResult, type CanonicalSourceType, type ExtractedMemory, LangChainMemoryAdapter, LangGraphCheckpointAdapter, type Memory, type MemoryExtractionResult, type MemoryKind, type MemoryLatencyBreakdown, type MemorySearchResponse, type MemoryWriteAck, type Project, type QueryParams, type QueryResult, type Source, type VideoIngestionStatus, type VideoSourceMetadata, Whisper, WhisperAgentMiddleware, WhisperClient, type WhisperConfig, WhisperContext, Whisper as WhisperDefault, WhisperError, type WhisperErrorCode, WhisperClient as WhisperRuntimeClient, createAgentMiddleware, createLangChainMemoryAdapter, createLangGraphCheckpointAdapter, WhisperContext as default, memoryGraphToMermaid };
|
|
1805
|
+
export { type CanonicalSourceCreateParams, type CanonicalSourceCreateResult, type CanonicalSourceType, type ExtractedMemory, LangChainMemoryAdapter, LangGraphCheckpointAdapter, type Memory, type MemoryExtractionResult, type MemoryKind, type MemoryLatencyBreakdown, type MemorySearchResponse, type MemoryWriteAck, type MemoryWriteResult, type Project, type QueryParams, type QueryResult, type Source, type VideoIngestionStatus, type VideoSourceMetadata, Whisper, WhisperAgentMiddleware, WhisperClient, type WhisperConfig, WhisperContext, Whisper as WhisperDefault, WhisperError, type WhisperErrorCode, WhisperClient as WhisperRuntimeClient, createAgentMiddleware, createLangChainMemoryAdapter, createLangGraphCheckpointAdapter, WhisperContext as default, memoryGraphToMermaid };
|
package/index.d.ts
CHANGED
|
@@ -215,6 +215,7 @@ interface RuntimeClientOptions {
|
|
|
215
215
|
compatMode?: CompatMode;
|
|
216
216
|
timeouts?: Partial<TimeoutBudgets>;
|
|
217
217
|
retryPolicy?: RetryPolicy;
|
|
218
|
+
fetchImpl?: typeof fetch;
|
|
218
219
|
}
|
|
219
220
|
interface RuntimeResponse<T> {
|
|
220
221
|
data: T;
|
|
@@ -325,6 +326,7 @@ declare class RuntimeClient {
|
|
|
325
326
|
private readonly diagnostics;
|
|
326
327
|
private readonly inFlight;
|
|
327
328
|
private readonly sendApiKeyHeader;
|
|
329
|
+
private readonly fetchImpl;
|
|
328
330
|
constructor(options: RuntimeClientOptions, diagnostics?: DiagnosticsStore);
|
|
329
331
|
getDiagnosticsStore(): DiagnosticsStore;
|
|
330
332
|
getCompatMode(): CompatMode;
|
|
@@ -414,11 +416,13 @@ interface MemoryWriteAck$1 {
|
|
|
414
416
|
success: boolean;
|
|
415
417
|
mode?: "async" | "sync";
|
|
416
418
|
trace_id?: string;
|
|
419
|
+
memory_id?: string;
|
|
417
420
|
job_id?: string;
|
|
418
421
|
status_url?: string;
|
|
419
422
|
accepted_at?: string;
|
|
420
423
|
visibility_sla_ms?: number;
|
|
421
424
|
pending_visibility?: boolean;
|
|
425
|
+
semantic_status?: "pending" | "ready";
|
|
422
426
|
queued?: boolean;
|
|
423
427
|
event_id?: string;
|
|
424
428
|
created?: number;
|
|
@@ -619,6 +623,7 @@ interface WhisperClientConfig {
|
|
|
619
623
|
baseUrl?: string;
|
|
620
624
|
project?: string;
|
|
621
625
|
compatMode?: CompatMode;
|
|
626
|
+
fetch?: typeof fetch;
|
|
622
627
|
timeouts?: Partial<TimeoutBudgets>;
|
|
623
628
|
retryPolicy?: RetryPolicy;
|
|
624
629
|
cache?: {
|
|
@@ -1036,6 +1041,9 @@ interface CanonicalSourceCreateParams {
|
|
|
1036
1041
|
name?: string;
|
|
1037
1042
|
auto_index?: boolean;
|
|
1038
1043
|
metadata?: Record<string, string>;
|
|
1044
|
+
ingestion_profile?: "auto" | "repo" | "web_docs" | "pdf_layout" | "video_transcript" | "plain_text";
|
|
1045
|
+
strategy_override?: "fixed" | "recursive" | "semantic" | "hierarchical" | "adaptive";
|
|
1046
|
+
profile_config?: Record<string, any>;
|
|
1039
1047
|
owner?: string;
|
|
1040
1048
|
repo?: string;
|
|
1041
1049
|
branch?: string;
|
|
@@ -1147,6 +1155,20 @@ interface MemoryWriteAck {
|
|
|
1147
1155
|
pending_visibility?: boolean;
|
|
1148
1156
|
[key: string]: any;
|
|
1149
1157
|
}
|
|
1158
|
+
interface MemoryWriteResult {
|
|
1159
|
+
id: string;
|
|
1160
|
+
success: boolean;
|
|
1161
|
+
path: "sota" | "legacy";
|
|
1162
|
+
fallback_used: boolean;
|
|
1163
|
+
mode?: "async" | "sync";
|
|
1164
|
+
memory_id?: string;
|
|
1165
|
+
job_id?: string;
|
|
1166
|
+
status_url?: string;
|
|
1167
|
+
accepted_at?: string;
|
|
1168
|
+
visibility_sla_ms?: number;
|
|
1169
|
+
pending_visibility?: boolean;
|
|
1170
|
+
semantic_status?: "pending" | "ready";
|
|
1171
|
+
}
|
|
1150
1172
|
type WhisperErrorCode = "INVALID_API_KEY" | "PROJECT_NOT_FOUND" | "PROJECT_AMBIGUOUS" | "RATE_LIMITED" | "TEMPORARY_UNAVAILABLE" | "NETWORK_ERROR" | "TIMEOUT" | "REQUEST_FAILED" | "MISSING_PROJECT";
|
|
1151
1173
|
declare class WhisperError extends Error {
|
|
1152
1174
|
code: WhisperErrorCode;
|
|
@@ -1214,6 +1236,9 @@ declare class WhisperContext {
|
|
|
1214
1236
|
allow_stt_fallback?: boolean;
|
|
1215
1237
|
max_duration_minutes?: number;
|
|
1216
1238
|
name?: string;
|
|
1239
|
+
ingestion_profile?: "auto" | "repo" | "web_docs" | "pdf_layout" | "video_transcript" | "plain_text";
|
|
1240
|
+
strategy_override?: "fixed" | "recursive" | "semantic" | "hierarchical" | "adaptive";
|
|
1241
|
+
profile_config?: Record<string, any>;
|
|
1217
1242
|
}): Promise<{
|
|
1218
1243
|
source_id: string;
|
|
1219
1244
|
sync_job_id?: string | null;
|
|
@@ -1227,6 +1252,9 @@ declare class WhisperContext {
|
|
|
1227
1252
|
content: string;
|
|
1228
1253
|
metadata?: Record<string, any>;
|
|
1229
1254
|
file_path?: string;
|
|
1255
|
+
ingestion_profile?: "auto" | "repo" | "web_docs" | "pdf_layout" | "video_transcript" | "plain_text";
|
|
1256
|
+
strategy_override?: "fixed" | "recursive" | "semantic" | "hierarchical" | "adaptive";
|
|
1257
|
+
profile_config?: Record<string, any>;
|
|
1230
1258
|
}>): Promise<{
|
|
1231
1259
|
ingested: number;
|
|
1232
1260
|
}>;
|
|
@@ -1251,12 +1279,7 @@ declare class WhisperContext {
|
|
|
1251
1279
|
async?: boolean;
|
|
1252
1280
|
write_mode?: "async" | "sync";
|
|
1253
1281
|
allow_legacy_fallback?: boolean;
|
|
1254
|
-
}): Promise<
|
|
1255
|
-
id: string;
|
|
1256
|
-
success: boolean;
|
|
1257
|
-
path: "sota" | "legacy";
|
|
1258
|
-
fallback_used: boolean;
|
|
1259
|
-
}>;
|
|
1282
|
+
}): Promise<MemoryWriteResult>;
|
|
1260
1283
|
addMemoriesBulk(params: {
|
|
1261
1284
|
project?: string;
|
|
1262
1285
|
memories: Array<{
|
|
@@ -1645,12 +1668,7 @@ declare class WhisperContext {
|
|
|
1645
1668
|
getStatus: (sourceId: string) => Promise<VideoIngestionStatus>;
|
|
1646
1669
|
};
|
|
1647
1670
|
readonly memory: {
|
|
1648
|
-
add: (params: Parameters<WhisperContext["addMemory"]>[0]) => Promise<
|
|
1649
|
-
id: string;
|
|
1650
|
-
success: boolean;
|
|
1651
|
-
path: "sota" | "legacy";
|
|
1652
|
-
fallback_used: boolean;
|
|
1653
|
-
}>;
|
|
1671
|
+
add: (params: Parameters<WhisperContext["addMemory"]>[0]) => Promise<MemoryWriteResult>;
|
|
1654
1672
|
addBulk: (params: Parameters<WhisperContext["addMemoriesBulk"]>[0]) => Promise<any>;
|
|
1655
1673
|
extract: (params: Parameters<WhisperContext["extractMemories"]>[0]) => Promise<MemoryExtractionResult>;
|
|
1656
1674
|
extractSession: (params: Parameters<WhisperContext["extractSessionMemories"]>[0]) => Promise<{
|
|
@@ -1784,4 +1802,4 @@ declare class WhisperContext {
|
|
|
1784
1802
|
};
|
|
1785
1803
|
}
|
|
1786
1804
|
|
|
1787
|
-
export { type CanonicalSourceCreateParams, type CanonicalSourceCreateResult, type CanonicalSourceType, type ExtractedMemory, LangChainMemoryAdapter, LangGraphCheckpointAdapter, type Memory, type MemoryExtractionResult, type MemoryKind, type MemoryLatencyBreakdown, type MemorySearchResponse, type MemoryWriteAck, type Project, type QueryParams, type QueryResult, type Source, type VideoIngestionStatus, type VideoSourceMetadata, Whisper, WhisperAgentMiddleware, WhisperClient, type WhisperConfig, WhisperContext, Whisper as WhisperDefault, WhisperError, type WhisperErrorCode, WhisperClient as WhisperRuntimeClient, createAgentMiddleware, createLangChainMemoryAdapter, createLangGraphCheckpointAdapter, WhisperContext as default, memoryGraphToMermaid };
|
|
1805
|
+
export { type CanonicalSourceCreateParams, type CanonicalSourceCreateResult, type CanonicalSourceType, type ExtractedMemory, LangChainMemoryAdapter, LangGraphCheckpointAdapter, type Memory, type MemoryExtractionResult, type MemoryKind, type MemoryLatencyBreakdown, type MemorySearchResponse, type MemoryWriteAck, type MemoryWriteResult, type Project, type QueryParams, type QueryResult, type Source, type VideoIngestionStatus, type VideoSourceMetadata, Whisper, WhisperAgentMiddleware, WhisperClient, type WhisperConfig, WhisperContext, Whisper as WhisperDefault, WhisperError, type WhisperErrorCode, WhisperClient as WhisperRuntimeClient, createAgentMiddleware, createLangChainMemoryAdapter, createLangGraphCheckpointAdapter, WhisperContext as default, memoryGraphToMermaid };
|
package/index.js
CHANGED
|
@@ -184,6 +184,7 @@ var RuntimeClient = class {
|
|
|
184
184
|
diagnostics;
|
|
185
185
|
inFlight = /* @__PURE__ */ new Map();
|
|
186
186
|
sendApiKeyHeader;
|
|
187
|
+
fetchImpl;
|
|
187
188
|
constructor(options, diagnostics) {
|
|
188
189
|
if (!options.apiKey) {
|
|
189
190
|
throw new RuntimeClientError({
|
|
@@ -208,6 +209,7 @@ var RuntimeClient = class {
|
|
|
208
209
|
...options.timeouts || {}
|
|
209
210
|
};
|
|
210
211
|
this.sendApiKeyHeader = process.env.WHISPER_SEND_X_API_KEY === "1";
|
|
212
|
+
this.fetchImpl = options.fetchImpl || fetch;
|
|
211
213
|
this.diagnostics = diagnostics || new DiagnosticsStore(1e3);
|
|
212
214
|
}
|
|
213
215
|
getDiagnosticsStore() {
|
|
@@ -328,7 +330,7 @@ var RuntimeClient = class {
|
|
|
328
330
|
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
329
331
|
try {
|
|
330
332
|
const attachApiKeyHeader = this.shouldAttachApiKeyHeader(normalizedEndpoint);
|
|
331
|
-
const response = await
|
|
333
|
+
const response = await this.fetchImpl(`${this.baseUrl}${normalizedEndpoint}`, {
|
|
332
334
|
method,
|
|
333
335
|
signal: controller.signal,
|
|
334
336
|
keepalive: method !== "GET",
|
|
@@ -1037,7 +1039,7 @@ var MemoryModule = class {
|
|
|
1037
1039
|
async add(params) {
|
|
1038
1040
|
const project = this.resolveProject(params.project);
|
|
1039
1041
|
const queueEnabled = this.options.queueEnabled !== false;
|
|
1040
|
-
const useQueue = queueEnabled && params.write_mode
|
|
1042
|
+
const useQueue = queueEnabled && (params.write_mode === "async" || params.async === true);
|
|
1041
1043
|
if (useQueue) {
|
|
1042
1044
|
const queued = await this.queue.enqueue({
|
|
1043
1045
|
project,
|
|
@@ -1082,14 +1084,18 @@ var MemoryModule = class {
|
|
|
1082
1084
|
metadata: params.metadata,
|
|
1083
1085
|
document_date: params.document_date,
|
|
1084
1086
|
event_date: params.event_date,
|
|
1085
|
-
write_mode: "sync"
|
|
1087
|
+
write_mode: params.write_mode === "async" || params.async === true ? "async" : "sync"
|
|
1086
1088
|
}
|
|
1087
1089
|
});
|
|
1088
1090
|
this.invalidate(project, params.user_id, params.session_id);
|
|
1089
1091
|
return {
|
|
1090
1092
|
success: true,
|
|
1091
1093
|
mode: "sync",
|
|
1092
|
-
trace_id: response.traceId
|
|
1094
|
+
trace_id: response.trace_id || response.traceId,
|
|
1095
|
+
memory_id: response.memory_id || response.memory?.id,
|
|
1096
|
+
semantic_status: response.semantic_status || response.memory?.semantic_status,
|
|
1097
|
+
pending_visibility: Boolean(response.pending_visibility),
|
|
1098
|
+
visibility_sla_ms: response.visibility_sla_ms
|
|
1093
1099
|
};
|
|
1094
1100
|
} catch (error) {
|
|
1095
1101
|
if (this.client.getCompatMode() !== "fallback" || !isEndpointNotFound(error)) {
|
|
@@ -1127,7 +1133,7 @@ var MemoryModule = class {
|
|
|
1127
1133
|
});
|
|
1128
1134
|
}
|
|
1129
1135
|
const queueEnabled = this.options.queueEnabled !== false;
|
|
1130
|
-
const useQueue = queueEnabled && params.write_mode
|
|
1136
|
+
const useQueue = queueEnabled && (params.write_mode === "async" || params.async === true);
|
|
1131
1137
|
if (useQueue) {
|
|
1132
1138
|
const queued = await Promise.all(
|
|
1133
1139
|
params.memories.map(
|
|
@@ -1171,7 +1177,7 @@ var MemoryModule = class {
|
|
|
1171
1177
|
...memory,
|
|
1172
1178
|
memory_type: toSotaType(memory.memory_type)
|
|
1173
1179
|
})),
|
|
1174
|
-
write_mode: "sync"
|
|
1180
|
+
write_mode: params.write_mode === "async" || params.async === true ? "async" : "sync"
|
|
1175
1181
|
}
|
|
1176
1182
|
});
|
|
1177
1183
|
for (const memory of params.memories) {
|
|
@@ -1604,7 +1610,8 @@ var WhisperClient = class _WhisperClient {
|
|
|
1604
1610
|
baseUrl: config.baseUrl,
|
|
1605
1611
|
compatMode: config.compatMode || "fallback",
|
|
1606
1612
|
timeouts: config.timeouts,
|
|
1607
|
-
retryPolicy: config.retryPolicy
|
|
1613
|
+
retryPolicy: config.retryPolicy,
|
|
1614
|
+
fetchImpl: config.fetch
|
|
1608
1615
|
},
|
|
1609
1616
|
this.diagnosticsStore
|
|
1610
1617
|
);
|
|
@@ -2668,6 +2675,9 @@ var WhisperContext = class _WhisperContext {
|
|
|
2668
2675
|
if (params.auth_ref) config.auth_ref = params.auth_ref;
|
|
2669
2676
|
}
|
|
2670
2677
|
if (params.metadata) config.metadata = params.metadata;
|
|
2678
|
+
if (params.ingestion_profile) config.ingestion_profile = params.ingestion_profile;
|
|
2679
|
+
if (params.strategy_override) config.strategy_override = params.strategy_override;
|
|
2680
|
+
if (params.profile_config) config.profile_config = params.profile_config;
|
|
2671
2681
|
config.auto_index = params.auto_index ?? true;
|
|
2672
2682
|
const created = await this.addSource(project, {
|
|
2673
2683
|
name: params.name || `${params.type}-source-${Date.now()}`,
|
|
@@ -2749,15 +2759,42 @@ var WhisperContext = class _WhisperContext {
|
|
|
2749
2759
|
importance: params.importance,
|
|
2750
2760
|
metadata: params.metadata,
|
|
2751
2761
|
async: params.async,
|
|
2752
|
-
write_mode: params.write_mode
|
|
2762
|
+
write_mode: params.write_mode || (params.async === true ? "async" : "sync")
|
|
2753
2763
|
})
|
|
2754
2764
|
});
|
|
2755
|
-
const
|
|
2765
|
+
const mode = direct?.mode === "async" ? "async" : direct?.mode === "sync" ? "sync" : void 0;
|
|
2766
|
+
const memoryId = direct?.memory?.id || direct?.memory_id || (mode !== "async" ? direct?.id : void 0);
|
|
2767
|
+
const jobId = direct?.job_id || (mode === "async" ? direct?.id : void 0);
|
|
2768
|
+
const id2 = memoryId || jobId || "";
|
|
2756
2769
|
if (id2) {
|
|
2757
|
-
return {
|
|
2770
|
+
return {
|
|
2771
|
+
id: id2,
|
|
2772
|
+
success: true,
|
|
2773
|
+
path: "sota",
|
|
2774
|
+
fallback_used: false,
|
|
2775
|
+
mode,
|
|
2776
|
+
...memoryId ? { memory_id: memoryId } : {},
|
|
2777
|
+
...jobId ? { job_id: jobId } : {},
|
|
2778
|
+
...direct?.status_url ? { status_url: direct.status_url } : {},
|
|
2779
|
+
...direct?.accepted_at ? { accepted_at: direct.accepted_at } : {},
|
|
2780
|
+
...direct?.visibility_sla_ms ? { visibility_sla_ms: direct.visibility_sla_ms } : {},
|
|
2781
|
+
...direct?.pending_visibility !== void 0 ? { pending_visibility: Boolean(direct.pending_visibility) } : {},
|
|
2782
|
+
...direct?.semantic_status ? { semantic_status: direct.semantic_status } : {}
|
|
2783
|
+
};
|
|
2758
2784
|
}
|
|
2759
2785
|
if (direct?.success === true) {
|
|
2760
|
-
return {
|
|
2786
|
+
return {
|
|
2787
|
+
id: "",
|
|
2788
|
+
success: true,
|
|
2789
|
+
path: "sota",
|
|
2790
|
+
fallback_used: false,
|
|
2791
|
+
mode,
|
|
2792
|
+
...direct?.status_url ? { status_url: direct.status_url } : {},
|
|
2793
|
+
...direct?.accepted_at ? { accepted_at: direct.accepted_at } : {},
|
|
2794
|
+
...direct?.visibility_sla_ms ? { visibility_sla_ms: direct.visibility_sla_ms } : {},
|
|
2795
|
+
...direct?.pending_visibility !== void 0 ? { pending_visibility: Boolean(direct.pending_visibility) } : {},
|
|
2796
|
+
...direct?.semantic_status ? { semantic_status: direct.semantic_status } : {}
|
|
2797
|
+
};
|
|
2761
2798
|
}
|
|
2762
2799
|
} catch (error) {
|
|
2763
2800
|
if (params.allow_legacy_fallback === false) {
|
|
@@ -2785,7 +2822,15 @@ var WhisperContext = class _WhisperContext {
|
|
|
2785
2822
|
message: "Memory create succeeded but no memory id was returned by the API"
|
|
2786
2823
|
});
|
|
2787
2824
|
}
|
|
2788
|
-
return {
|
|
2825
|
+
return {
|
|
2826
|
+
id,
|
|
2827
|
+
success: true,
|
|
2828
|
+
path: "legacy",
|
|
2829
|
+
fallback_used: true,
|
|
2830
|
+
mode: "sync",
|
|
2831
|
+
memory_id: id,
|
|
2832
|
+
semantic_status: "ready"
|
|
2833
|
+
};
|
|
2789
2834
|
});
|
|
2790
2835
|
}
|
|
2791
2836
|
async addMemoriesBulk(params) {
|
package/index.mjs
CHANGED
|
@@ -135,6 +135,7 @@ var RuntimeClient = class {
|
|
|
135
135
|
diagnostics;
|
|
136
136
|
inFlight = /* @__PURE__ */ new Map();
|
|
137
137
|
sendApiKeyHeader;
|
|
138
|
+
fetchImpl;
|
|
138
139
|
constructor(options, diagnostics) {
|
|
139
140
|
if (!options.apiKey) {
|
|
140
141
|
throw new RuntimeClientError({
|
|
@@ -159,6 +160,7 @@ var RuntimeClient = class {
|
|
|
159
160
|
...options.timeouts || {}
|
|
160
161
|
};
|
|
161
162
|
this.sendApiKeyHeader = process.env.WHISPER_SEND_X_API_KEY === "1";
|
|
163
|
+
this.fetchImpl = options.fetchImpl || fetch;
|
|
162
164
|
this.diagnostics = diagnostics || new DiagnosticsStore(1e3);
|
|
163
165
|
}
|
|
164
166
|
getDiagnosticsStore() {
|
|
@@ -279,7 +281,7 @@ var RuntimeClient = class {
|
|
|
279
281
|
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
280
282
|
try {
|
|
281
283
|
const attachApiKeyHeader = this.shouldAttachApiKeyHeader(normalizedEndpoint);
|
|
282
|
-
const response = await
|
|
284
|
+
const response = await this.fetchImpl(`${this.baseUrl}${normalizedEndpoint}`, {
|
|
283
285
|
method,
|
|
284
286
|
signal: controller.signal,
|
|
285
287
|
keepalive: method !== "GET",
|
|
@@ -988,7 +990,7 @@ var MemoryModule = class {
|
|
|
988
990
|
async add(params) {
|
|
989
991
|
const project = this.resolveProject(params.project);
|
|
990
992
|
const queueEnabled = this.options.queueEnabled !== false;
|
|
991
|
-
const useQueue = queueEnabled && params.write_mode
|
|
993
|
+
const useQueue = queueEnabled && (params.write_mode === "async" || params.async === true);
|
|
992
994
|
if (useQueue) {
|
|
993
995
|
const queued = await this.queue.enqueue({
|
|
994
996
|
project,
|
|
@@ -1033,14 +1035,18 @@ var MemoryModule = class {
|
|
|
1033
1035
|
metadata: params.metadata,
|
|
1034
1036
|
document_date: params.document_date,
|
|
1035
1037
|
event_date: params.event_date,
|
|
1036
|
-
write_mode: "sync"
|
|
1038
|
+
write_mode: params.write_mode === "async" || params.async === true ? "async" : "sync"
|
|
1037
1039
|
}
|
|
1038
1040
|
});
|
|
1039
1041
|
this.invalidate(project, params.user_id, params.session_id);
|
|
1040
1042
|
return {
|
|
1041
1043
|
success: true,
|
|
1042
1044
|
mode: "sync",
|
|
1043
|
-
trace_id: response.traceId
|
|
1045
|
+
trace_id: response.trace_id || response.traceId,
|
|
1046
|
+
memory_id: response.memory_id || response.memory?.id,
|
|
1047
|
+
semantic_status: response.semantic_status || response.memory?.semantic_status,
|
|
1048
|
+
pending_visibility: Boolean(response.pending_visibility),
|
|
1049
|
+
visibility_sla_ms: response.visibility_sla_ms
|
|
1044
1050
|
};
|
|
1045
1051
|
} catch (error) {
|
|
1046
1052
|
if (this.client.getCompatMode() !== "fallback" || !isEndpointNotFound(error)) {
|
|
@@ -1078,7 +1084,7 @@ var MemoryModule = class {
|
|
|
1078
1084
|
});
|
|
1079
1085
|
}
|
|
1080
1086
|
const queueEnabled = this.options.queueEnabled !== false;
|
|
1081
|
-
const useQueue = queueEnabled && params.write_mode
|
|
1087
|
+
const useQueue = queueEnabled && (params.write_mode === "async" || params.async === true);
|
|
1082
1088
|
if (useQueue) {
|
|
1083
1089
|
const queued = await Promise.all(
|
|
1084
1090
|
params.memories.map(
|
|
@@ -1122,7 +1128,7 @@ var MemoryModule = class {
|
|
|
1122
1128
|
...memory,
|
|
1123
1129
|
memory_type: toSotaType(memory.memory_type)
|
|
1124
1130
|
})),
|
|
1125
|
-
write_mode: "sync"
|
|
1131
|
+
write_mode: params.write_mode === "async" || params.async === true ? "async" : "sync"
|
|
1126
1132
|
}
|
|
1127
1133
|
});
|
|
1128
1134
|
for (const memory of params.memories) {
|
|
@@ -1555,7 +1561,8 @@ var WhisperClient = class _WhisperClient {
|
|
|
1555
1561
|
baseUrl: config.baseUrl,
|
|
1556
1562
|
compatMode: config.compatMode || "fallback",
|
|
1557
1563
|
timeouts: config.timeouts,
|
|
1558
|
-
retryPolicy: config.retryPolicy
|
|
1564
|
+
retryPolicy: config.retryPolicy,
|
|
1565
|
+
fetchImpl: config.fetch
|
|
1559
1566
|
},
|
|
1560
1567
|
this.diagnosticsStore
|
|
1561
1568
|
);
|
|
@@ -2619,6 +2626,9 @@ var WhisperContext = class _WhisperContext {
|
|
|
2619
2626
|
if (params.auth_ref) config.auth_ref = params.auth_ref;
|
|
2620
2627
|
}
|
|
2621
2628
|
if (params.metadata) config.metadata = params.metadata;
|
|
2629
|
+
if (params.ingestion_profile) config.ingestion_profile = params.ingestion_profile;
|
|
2630
|
+
if (params.strategy_override) config.strategy_override = params.strategy_override;
|
|
2631
|
+
if (params.profile_config) config.profile_config = params.profile_config;
|
|
2622
2632
|
config.auto_index = params.auto_index ?? true;
|
|
2623
2633
|
const created = await this.addSource(project, {
|
|
2624
2634
|
name: params.name || `${params.type}-source-${Date.now()}`,
|
|
@@ -2700,15 +2710,42 @@ var WhisperContext = class _WhisperContext {
|
|
|
2700
2710
|
importance: params.importance,
|
|
2701
2711
|
metadata: params.metadata,
|
|
2702
2712
|
async: params.async,
|
|
2703
|
-
write_mode: params.write_mode
|
|
2713
|
+
write_mode: params.write_mode || (params.async === true ? "async" : "sync")
|
|
2704
2714
|
})
|
|
2705
2715
|
});
|
|
2706
|
-
const
|
|
2716
|
+
const mode = direct?.mode === "async" ? "async" : direct?.mode === "sync" ? "sync" : void 0;
|
|
2717
|
+
const memoryId = direct?.memory?.id || direct?.memory_id || (mode !== "async" ? direct?.id : void 0);
|
|
2718
|
+
const jobId = direct?.job_id || (mode === "async" ? direct?.id : void 0);
|
|
2719
|
+
const id2 = memoryId || jobId || "";
|
|
2707
2720
|
if (id2) {
|
|
2708
|
-
return {
|
|
2721
|
+
return {
|
|
2722
|
+
id: id2,
|
|
2723
|
+
success: true,
|
|
2724
|
+
path: "sota",
|
|
2725
|
+
fallback_used: false,
|
|
2726
|
+
mode,
|
|
2727
|
+
...memoryId ? { memory_id: memoryId } : {},
|
|
2728
|
+
...jobId ? { job_id: jobId } : {},
|
|
2729
|
+
...direct?.status_url ? { status_url: direct.status_url } : {},
|
|
2730
|
+
...direct?.accepted_at ? { accepted_at: direct.accepted_at } : {},
|
|
2731
|
+
...direct?.visibility_sla_ms ? { visibility_sla_ms: direct.visibility_sla_ms } : {},
|
|
2732
|
+
...direct?.pending_visibility !== void 0 ? { pending_visibility: Boolean(direct.pending_visibility) } : {},
|
|
2733
|
+
...direct?.semantic_status ? { semantic_status: direct.semantic_status } : {}
|
|
2734
|
+
};
|
|
2709
2735
|
}
|
|
2710
2736
|
if (direct?.success === true) {
|
|
2711
|
-
return {
|
|
2737
|
+
return {
|
|
2738
|
+
id: "",
|
|
2739
|
+
success: true,
|
|
2740
|
+
path: "sota",
|
|
2741
|
+
fallback_used: false,
|
|
2742
|
+
mode,
|
|
2743
|
+
...direct?.status_url ? { status_url: direct.status_url } : {},
|
|
2744
|
+
...direct?.accepted_at ? { accepted_at: direct.accepted_at } : {},
|
|
2745
|
+
...direct?.visibility_sla_ms ? { visibility_sla_ms: direct.visibility_sla_ms } : {},
|
|
2746
|
+
...direct?.pending_visibility !== void 0 ? { pending_visibility: Boolean(direct.pending_visibility) } : {},
|
|
2747
|
+
...direct?.semantic_status ? { semantic_status: direct.semantic_status } : {}
|
|
2748
|
+
};
|
|
2712
2749
|
}
|
|
2713
2750
|
} catch (error) {
|
|
2714
2751
|
if (params.allow_legacy_fallback === false) {
|
|
@@ -2736,7 +2773,15 @@ var WhisperContext = class _WhisperContext {
|
|
|
2736
2773
|
message: "Memory create succeeded but no memory id was returned by the API"
|
|
2737
2774
|
});
|
|
2738
2775
|
}
|
|
2739
|
-
return {
|
|
2776
|
+
return {
|
|
2777
|
+
id,
|
|
2778
|
+
success: true,
|
|
2779
|
+
path: "legacy",
|
|
2780
|
+
fallback_used: true,
|
|
2781
|
+
mode: "sync",
|
|
2782
|
+
memory_id: id,
|
|
2783
|
+
semantic_status: "ready"
|
|
2784
|
+
};
|
|
2740
2785
|
});
|
|
2741
2786
|
}
|
|
2742
2787
|
async addMemoriesBulk(params) {
|