@maximem/synap-js-sdk 0.5.10 → 0.5.11
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/{chunk-BWMPKLFG.js → chunk-4GE7SORD.js} +17 -1
- package/dist/chunk-4GE7SORD.js.map +1 -0
- package/dist/{chunk-I7TWR4S6.js → chunk-LJ66WCV3.js} +2 -2
- package/dist/{chunk-RE4DDIWO.cjs → chunk-QHPVLTQ7.cjs} +6 -6
- package/dist/{chunk-RE4DDIWO.cjs.map → chunk-QHPVLTQ7.cjs.map} +1 -1
- package/dist/{chunk-T372OL3Q.cjs → chunk-UXNVTP4D.cjs} +33 -17
- package/dist/chunk-UXNVTP4D.cjs.map +1 -0
- package/dist/{errors-Bdayqlzy.d.cts → errors-BvUA5EW8.d.cts} +14 -2
- package/dist/{errors-Bdayqlzy.d.ts → errors-BvUA5EW8.d.ts} +14 -2
- package/dist/grpc/index.cjs +7 -7
- package/dist/grpc/index.d.cts +1 -1
- package/dist/grpc/index.d.ts +1 -1
- package/dist/grpc/index.js +3 -3
- package/dist/index.cjs +112 -106
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -5
- package/dist/index.d.ts +9 -5
- package/dist/index.js +20 -14
- package/dist/index.js.map +1 -1
- package/dist/stream-client-5GYUWETN.cjs +16 -0
- package/dist/{stream-client-L6OQPZN7.cjs.map → stream-client-5GYUWETN.cjs.map} +1 -1
- package/dist/{stream-client-3WHXGW4U.js → stream-client-ZBCKRU7S.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-BWMPKLFG.js.map +0 -1
- package/dist/chunk-T372OL3Q.cjs.map +0 -1
- package/dist/stream-client-L6OQPZN7.cjs +0 -16
- /package/dist/{chunk-I7TWR4S6.js.map → chunk-LJ66WCV3.js.map} +0 -0
- /package/dist/{stream-client-3WHXGW4U.js.map → stream-client-ZBCKRU7S.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -39,7 +39,8 @@ var _chunkZKOJDUN4cjs = require('./chunk-ZKOJDUN4.cjs');
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
|
|
43
|
+
var _chunkUXNVTP4Dcjs = require('./chunk-UXNVTP4D.cjs');
|
|
43
44
|
|
|
44
45
|
// src/transport/endpoints.ts
|
|
45
46
|
var ENDPOINTS = {
|
|
@@ -102,7 +103,7 @@ function shouldRetry(input) {
|
|
|
102
103
|
if (attempt >= policy.maxAttempts) {
|
|
103
104
|
return { retry: false, delaySeconds: 0, reason: "max_attempts_exhausted" };
|
|
104
105
|
}
|
|
105
|
-
if (!
|
|
106
|
+
if (!_chunkUXNVTP4Dcjs.isSynapError.call(void 0, error) || !error.transient) {
|
|
106
107
|
return { retry: false, delaySeconds: 0, reason: "not_transient" };
|
|
107
108
|
}
|
|
108
109
|
const idempotent = _nullishCoalesce(input.idempotent, () => ( IDEMPOTENT_METHODS.has(method.toUpperCase())));
|
|
@@ -120,7 +121,7 @@ function shouldRetry(input) {
|
|
|
120
121
|
};
|
|
121
122
|
}
|
|
122
123
|
function backoffDelay(error, attempt, policy) {
|
|
123
|
-
if (error instanceof
|
|
124
|
+
if (error instanceof _chunkUXNVTP4Dcjs.RateLimitError && error.retryAfterSeconds != null) {
|
|
124
125
|
return Math.min(error.retryAfterSeconds, policy.backoffMax);
|
|
125
126
|
}
|
|
126
127
|
const exponential = policy.backoffBase * 2 ** (attempt - 1);
|
|
@@ -194,9 +195,7 @@ var B2C_ISOLATION = "equals_customer";
|
|
|
194
195
|
function checkCustomerId(isolation, customerId, where, instanceId) {
|
|
195
196
|
if (customerId === void 0 || customerId === null || customerId === "") return;
|
|
196
197
|
if (isolation !== B2C_ISOLATION) return;
|
|
197
|
-
throw new (0,
|
|
198
|
-
`${where}: customer_id is not accepted on this instance${instanceId ? ` (${instanceId})` : ""}, which is B2C (user_context_isolation='${B2C_ISOLATION}'). Send user_id only; it is the whole identity, and the server files and reads your data under it. Received customer_id=${JSON.stringify(customerId)}.`
|
|
199
|
-
);
|
|
198
|
+
throw new (0, _chunkUXNVTP4Dcjs.CustomerIdNotAcceptedError)(where, String(customerId), instanceId);
|
|
200
199
|
}
|
|
201
200
|
|
|
202
201
|
// src/transport/http.ts
|
|
@@ -278,8 +277,13 @@ var HttpTransport = (_class2 = class {
|
|
|
278
277
|
async ready() {
|
|
279
278
|
if (this.identityResolver !== void 0) await this.identityResolver();
|
|
280
279
|
}
|
|
281
|
-
/**
|
|
282
|
-
|
|
280
|
+
/**
|
|
281
|
+
* Refuse a customer_id on a B2C instance, at the call site. Resolves identity
|
|
282
|
+
* first: the isolation comes from whoami, so on the first call of a client
|
|
283
|
+
* that skipped initialize() the check would otherwise see nothing and pass.
|
|
284
|
+
*/
|
|
285
|
+
async checkCustomerId(customerId, where) {
|
|
286
|
+
await this.ready();
|
|
283
287
|
checkCustomerId(
|
|
284
288
|
this.userContextIsolation,
|
|
285
289
|
customerId,
|
|
@@ -307,7 +311,7 @@ var HttpTransport = (_class2 = class {
|
|
|
307
311
|
}
|
|
308
312
|
async request(name, options = {}) {
|
|
309
313
|
const spec = ENDPOINTS[name];
|
|
310
|
-
const correlationId = _nullishCoalesce(options.correlationId, () => (
|
|
314
|
+
const correlationId = _nullishCoalesce(options.correlationId, () => ( _chunkUXNVTP4Dcjs.newCorrelationId.call(void 0, )));
|
|
311
315
|
const idempotent = _nullishCoalesce(options.idempotent, () => ( spec.idempotent));
|
|
312
316
|
if (name !== "whoami") await this.ready();
|
|
313
317
|
let attempt = 0;
|
|
@@ -330,7 +334,7 @@ var HttpTransport = (_class2 = class {
|
|
|
330
334
|
await sleep(decision.delaySeconds * 1e3, options.signal);
|
|
331
335
|
}
|
|
332
336
|
}
|
|
333
|
-
throw _nullishCoalesce(_optionalChain([last, 'optionalAccess', _9 => _9.error]), () => ( new (0,
|
|
337
|
+
throw _nullishCoalesce(_optionalChain([last, 'optionalAccess', _9 => _9.error]), () => ( new (0, _chunkUXNVTP4Dcjs.SynapError)("Request failed with no recorded error")));
|
|
334
338
|
}
|
|
335
339
|
async attempt(name, options, correlationId) {
|
|
336
340
|
const spec = ENDPOINTS[name];
|
|
@@ -363,7 +367,7 @@ var HttpTransport = (_class2 = class {
|
|
|
363
367
|
try {
|
|
364
368
|
return JSON.parse(text);
|
|
365
369
|
} catch (e3) {
|
|
366
|
-
throw new (0,
|
|
370
|
+
throw new (0, _chunkUXNVTP4Dcjs.SynapError)(`Malformed JSON in response from ${url}`, { correlationId });
|
|
367
371
|
}
|
|
368
372
|
}
|
|
369
373
|
buildUrl(path, query) {
|
|
@@ -397,14 +401,14 @@ var HttpTransport = (_class2 = class {
|
|
|
397
401
|
}
|
|
398
402
|
}, _class2);
|
|
399
403
|
function isOutcomeUnknown(error) {
|
|
400
|
-
if (error instanceof
|
|
401
|
-
if (error instanceof
|
|
402
|
-
if (error instanceof
|
|
403
|
-
if (error instanceof
|
|
404
|
-
if (error instanceof
|
|
405
|
-
if (error instanceof
|
|
406
|
-
if (error instanceof
|
|
407
|
-
if (error instanceof
|
|
404
|
+
if (error instanceof _chunkUXNVTP4Dcjs.RateLimitError) return false;
|
|
405
|
+
if (error instanceof _chunkUXNVTP4Dcjs.ServiceUnavailableError) return false;
|
|
406
|
+
if (error instanceof _chunkUXNVTP4Dcjs.AuthenticationError) return false;
|
|
407
|
+
if (error instanceof _chunkUXNVTP4Dcjs.InvalidInputError) return false;
|
|
408
|
+
if (error instanceof _chunkUXNVTP4Dcjs.ConflictError) return false;
|
|
409
|
+
if (error instanceof _chunkUXNVTP4Dcjs.InsufficientCreditsError) return false;
|
|
410
|
+
if (error instanceof _chunkUXNVTP4Dcjs.ContextNotFoundError) return false;
|
|
411
|
+
if (error instanceof _chunkUXNVTP4Dcjs.NetworkTimeoutError) return true;
|
|
408
412
|
if (isConnectionRefusal(error)) return false;
|
|
409
413
|
return true;
|
|
410
414
|
}
|
|
@@ -413,12 +417,12 @@ function isConnectionRefusal(error) {
|
|
|
413
417
|
return code === "ECONNREFUSED" || code === "ENOTFOUND" || code === "EAI_AGAIN" || code === "ECONNRESET" || code === "EHOSTUNREACH";
|
|
414
418
|
}
|
|
415
419
|
function toTransportError(error, correlationId) {
|
|
416
|
-
if (error instanceof
|
|
420
|
+
if (error instanceof _chunkUXNVTP4Dcjs.SynapError) return error;
|
|
417
421
|
const name = _optionalChain([error, 'optionalAccess', _13 => _13.name]);
|
|
418
422
|
if (name === "AbortError" || name === "TimeoutError") {
|
|
419
|
-
return new (0,
|
|
423
|
+
return new (0, _chunkUXNVTP4Dcjs.NetworkTimeoutError)("Request timed out", { correlationId, cause: error });
|
|
420
424
|
}
|
|
421
|
-
return new (0,
|
|
425
|
+
return new (0, _chunkUXNVTP4Dcjs.ServiceUnavailableError)(
|
|
422
426
|
`Network request failed: ${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _14 => _14.message]), () => ( String(error)))}`,
|
|
423
427
|
{ correlationId, cause: error }
|
|
424
428
|
);
|
|
@@ -448,15 +452,15 @@ async function toHttpError(response, correlationId) {
|
|
|
448
452
|
switch (response.status) {
|
|
449
453
|
case 400:
|
|
450
454
|
case 422:
|
|
451
|
-
return new (0,
|
|
455
|
+
return new (0, _chunkUXNVTP4Dcjs.InvalidInputError)(message, opts);
|
|
452
456
|
case 401:
|
|
453
457
|
case 403:
|
|
454
|
-
return new (0,
|
|
458
|
+
return new (0, _chunkUXNVTP4Dcjs.AuthenticationError)(message, opts);
|
|
455
459
|
case 404:
|
|
456
|
-
return new (0,
|
|
460
|
+
return new (0, _chunkUXNVTP4Dcjs.ContextNotFoundError)(message, opts);
|
|
457
461
|
case 402: {
|
|
458
462
|
const credit = creditPayload(parsed, detailObject);
|
|
459
|
-
return new (0,
|
|
463
|
+
return new (0, _chunkUXNVTP4Dcjs.InsufficientCreditsError)(message, {
|
|
460
464
|
...opts,
|
|
461
465
|
balanceCredits: numberOrNull(credit["balance_credits"]),
|
|
462
466
|
requiredCredits: _nullishCoalesce(numberOrNull(credit["minimum_required_credits"]), () => ( numberOrNull(credit["required_credits"]))),
|
|
@@ -468,14 +472,14 @@ async function toHttpError(response, correlationId) {
|
|
|
468
472
|
}
|
|
469
473
|
case 409:
|
|
470
474
|
if (detailObject !== null && detailObject["code"] === "transcript_conflict") {
|
|
471
|
-
return new (0,
|
|
475
|
+
return new (0, _chunkUXNVTP4Dcjs.TranscriptConflictError)(message, opts);
|
|
472
476
|
}
|
|
473
|
-
return new (0,
|
|
477
|
+
return new (0, _chunkUXNVTP4Dcjs.ConflictError)(message, opts);
|
|
474
478
|
case 429: {
|
|
475
479
|
const header = response.headers.get("retry-after");
|
|
476
480
|
const retryAfter = header !== null && header.trim() !== "" ? Number(header) : null;
|
|
477
481
|
const credit = creditPayload(parsed, detailObject);
|
|
478
|
-
return new (0,
|
|
482
|
+
return new (0, _chunkUXNVTP4Dcjs.RateLimitError)(message, {
|
|
479
483
|
...opts,
|
|
480
484
|
retryAfterSeconds: retryAfter !== null && Number.isFinite(retryAfter) ? retryAfter : null,
|
|
481
485
|
reason: creditReason(credit),
|
|
@@ -484,12 +488,12 @@ async function toHttpError(response, correlationId) {
|
|
|
484
488
|
});
|
|
485
489
|
}
|
|
486
490
|
case 503:
|
|
487
|
-
return new (0,
|
|
491
|
+
return new (0, _chunkUXNVTP4Dcjs.ServiceUnavailableError)(message, opts);
|
|
488
492
|
case 504:
|
|
489
|
-
return new (0,
|
|
493
|
+
return new (0, _chunkUXNVTP4Dcjs.AgentUnavailableError)(message, opts);
|
|
490
494
|
default:
|
|
491
|
-
if (response.status >= 500) return new (0,
|
|
492
|
-
return new (0,
|
|
495
|
+
if (response.status >= 500) return new (0, _chunkUXNVTP4Dcjs.ServiceUnavailableError)(message, opts);
|
|
496
|
+
return new (0, _chunkUXNVTP4Dcjs.SynapError)(message, opts);
|
|
493
497
|
}
|
|
494
498
|
}
|
|
495
499
|
function numberOrNull(v) {
|
|
@@ -502,7 +506,7 @@ function withTimeout(ms, external) {
|
|
|
502
506
|
const controller = new AbortController();
|
|
503
507
|
const onExternalAbort = () => controller.abort(_optionalChain([external, 'optionalAccess', _15 => _15.reason]));
|
|
504
508
|
const timer = setTimeout(() => {
|
|
505
|
-
controller.abort(new (0,
|
|
509
|
+
controller.abort(new (0, _chunkUXNVTP4Dcjs.NetworkTimeoutError)(`Timed out after ${ms}ms`));
|
|
506
510
|
}, ms);
|
|
507
511
|
_optionalChain([timer, 'access', _16 => _16.unref, 'optionalCall', _17 => _17()]);
|
|
508
512
|
if (external) {
|
|
@@ -636,10 +640,10 @@ function buildFetchRequest(scope, options) {
|
|
|
636
640
|
const responseShape = responseShapeOf(options);
|
|
637
641
|
const { mode, precisionLevel } = retrievalOptionsOf(options);
|
|
638
642
|
if (searchQuery !== void 0 && !Array.isArray(searchQuery)) {
|
|
639
|
-
throw new (0,
|
|
643
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("search_query must be an array when provided");
|
|
640
644
|
}
|
|
641
645
|
if (options.types !== void 0 && !Array.isArray(options.types)) {
|
|
642
|
-
throw new (0,
|
|
646
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("types must be an array when provided");
|
|
643
647
|
}
|
|
644
648
|
const body = {
|
|
645
649
|
conversation_id: _nullishCoalesce(conversationId, () => ( null)),
|
|
@@ -662,20 +666,20 @@ function buildFetchRequest(scope, options) {
|
|
|
662
666
|
switch (scope) {
|
|
663
667
|
case "user":
|
|
664
668
|
{
|
|
665
|
-
if (!userId) throw new (0,
|
|
669
|
+
if (!userId) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("user_id is required");
|
|
666
670
|
body["user_id"] = userId;
|
|
667
671
|
const contextMode = _nullishCoalesce(opt(options, "context_mode", "contextMode"), () => ( "in-conversation"));
|
|
668
672
|
if (!VALID_CONTEXT_MODES.includes(contextMode)) {
|
|
669
|
-
throw new (0,
|
|
673
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)(
|
|
670
674
|
`Invalid context_mode '${contextMode}'. Must be one of: ${VALID_CONTEXT_MODES.join(", ")}`
|
|
671
675
|
);
|
|
672
676
|
}
|
|
673
677
|
const lastN = _nullishCoalesce(opt(options, "last_n_conversations", "lastNConversations"), () => ( 1));
|
|
674
678
|
if (!Number.isInteger(lastN)) {
|
|
675
|
-
throw new (0,
|
|
679
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("last_n_conversations must be an integer");
|
|
676
680
|
}
|
|
677
681
|
if (lastN < 0 || lastN > 20) {
|
|
678
|
-
throw new (0,
|
|
682
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("last_n_conversations must be between 0 and 20");
|
|
679
683
|
}
|
|
680
684
|
if (contextMode === "conversation-summary") {
|
|
681
685
|
body["context_mode"] = contextMode;
|
|
@@ -687,11 +691,11 @@ function buildFetchRequest(scope, options) {
|
|
|
687
691
|
}
|
|
688
692
|
break;
|
|
689
693
|
case "customer":
|
|
690
|
-
if (!customerId) throw new (0,
|
|
694
|
+
if (!customerId) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("customer_id is required");
|
|
691
695
|
body["customer_id"] = customerId;
|
|
692
696
|
break;
|
|
693
697
|
case "conversation":
|
|
694
|
-
if (!conversationId) throw new (0,
|
|
698
|
+
if (!conversationId) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("conversation_id is required");
|
|
695
699
|
if (userId !== void 0) body["user_id"] = userId;
|
|
696
700
|
if (customerId !== void 0) body["customer_id"] = customerId;
|
|
697
701
|
break;
|
|
@@ -704,7 +708,7 @@ var VALID_CONTEXT_MODES = ["in-conversation", "conversation-summary"];
|
|
|
704
708
|
function responseShapeOf(options) {
|
|
705
709
|
const shape = _nullishCoalesce(opt(options, "response_shape", "responseShape"), () => ( "by_type"));
|
|
706
710
|
if (!RESPONSE_SHAPES.includes(shape)) {
|
|
707
|
-
throw new (0,
|
|
711
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)(
|
|
708
712
|
`Invalid response_shape '${shape}'. Must be one of: ${RESPONSE_SHAPES.join(", ")}`
|
|
709
713
|
);
|
|
710
714
|
}
|
|
@@ -715,13 +719,13 @@ var VALID_PRECISION = ["high", "medium"];
|
|
|
715
719
|
function retrievalOptionsOf(options) {
|
|
716
720
|
const mode = _nullishCoalesce(options.mode, () => ( "fast"));
|
|
717
721
|
if (!VALID_MODES.includes(mode)) {
|
|
718
|
-
throw new (0,
|
|
722
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)(
|
|
719
723
|
`Invalid mode '${mode}'. Must be one of: ${VALID_MODES.join(", ")}`
|
|
720
724
|
);
|
|
721
725
|
}
|
|
722
726
|
const precisionLevel = _nullishCoalesce(opt(options, "precision_level", "precisionLevel"), () => ( "high"));
|
|
723
727
|
if (!VALID_PRECISION.includes(precisionLevel)) {
|
|
724
|
-
throw new (0,
|
|
728
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)(
|
|
725
729
|
`Invalid precision_level '${precisionLevel}'. Must be one of: ${VALID_PRECISION.join(", ")}`
|
|
726
730
|
);
|
|
727
731
|
}
|
|
@@ -730,7 +734,7 @@ function retrievalOptionsOf(options) {
|
|
|
730
734
|
async function fetchContext(transport, scope, options = {}, hooks = {}) {
|
|
731
735
|
const startedAt = Date.now();
|
|
732
736
|
await _optionalChain([transport, 'access', _25 => _25.ready, 'optionalCall', _26 => _26()]);
|
|
733
|
-
transport.checkCustomerId(
|
|
737
|
+
await transport.checkCustomerId(
|
|
734
738
|
opt(options, "customer_id", "customerId"),
|
|
735
739
|
`${scope}.context.fetch`
|
|
736
740
|
);
|
|
@@ -1017,17 +1021,17 @@ function isoOrNull(v) {
|
|
|
1017
1021
|
return v instanceof Date ? v.toISOString() : v;
|
|
1018
1022
|
}
|
|
1019
1023
|
function buildCreateBody(options) {
|
|
1020
|
-
if (!options.document) throw new (0,
|
|
1024
|
+
if (!options.document) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("document is required");
|
|
1021
1025
|
const o2 = options;
|
|
1022
1026
|
const documentType = _nullishCoalesce(either(o2, "document_type", "documentType"), () => ( DEFAULT_DOCUMENT_TYPE));
|
|
1023
1027
|
const mode = _nullishCoalesce(options.mode, () => ( DEFAULT_INGEST_MODE));
|
|
1024
1028
|
if (!DOCUMENT_TYPES.includes(documentType)) {
|
|
1025
|
-
throw new (0,
|
|
1029
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)(
|
|
1026
1030
|
`Invalid document_type '${documentType}'. Expected one of: ${DOCUMENT_TYPES.join(", ")}`
|
|
1027
1031
|
);
|
|
1028
1032
|
}
|
|
1029
1033
|
if (!INGEST_MODES.includes(mode)) {
|
|
1030
|
-
throw new (0,
|
|
1034
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)(
|
|
1031
1035
|
`Invalid mode '${mode}'. Expected one of: ${INGEST_MODES.join(", ")}`
|
|
1032
1036
|
);
|
|
1033
1037
|
}
|
|
@@ -1054,13 +1058,13 @@ var FORGET_DESCRIPTION_MAX = 500;
|
|
|
1054
1058
|
function buildForgetBody(options) {
|
|
1055
1059
|
const description = options.description;
|
|
1056
1060
|
if (typeof description !== "string" || description.length < FORGET_DESCRIPTION_MIN || description.length > FORGET_DESCRIPTION_MAX) {
|
|
1057
|
-
throw new (0,
|
|
1061
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)(
|
|
1058
1062
|
`description must be between ${FORGET_DESCRIPTION_MIN} and ${FORGET_DESCRIPTION_MAX} characters`
|
|
1059
1063
|
);
|
|
1060
1064
|
}
|
|
1061
1065
|
const mode = _nullishCoalesce(options.mode, () => ( "preview"));
|
|
1062
1066
|
if (!FORGET_MODES.includes(mode)) {
|
|
1063
|
-
throw new (0,
|
|
1067
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)(
|
|
1064
1068
|
`Invalid mode '${mode}'. Expected one of: ${FORGET_MODES.join(", ")}`
|
|
1065
1069
|
);
|
|
1066
1070
|
}
|
|
@@ -1078,13 +1082,13 @@ function createMemoriesInterface(transport, onForgotten) {
|
|
|
1078
1082
|
return {
|
|
1079
1083
|
async create(options) {
|
|
1080
1084
|
const o2 = options;
|
|
1081
|
-
transport.checkCustomerId(_nullishCoalesce(o2["customer_id"], () => ( o2["customerId"])), "memories.create");
|
|
1085
|
+
await transport.checkCustomerId(_nullishCoalesce(o2["customer_id"], () => ( o2["customerId"])), "memories.create");
|
|
1082
1086
|
return transport.request("memories_create", { body: buildCreateBody(options) });
|
|
1083
1087
|
},
|
|
1084
1088
|
async batch_create(options) {
|
|
1085
1089
|
const docs = options.documents;
|
|
1086
1090
|
if (!Array.isArray(docs) || docs.length === 0) {
|
|
1087
|
-
throw new (0,
|
|
1091
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("documents must be a non-empty array");
|
|
1088
1092
|
}
|
|
1089
1093
|
const failFast = _nullishCoalesce(_nullishCoalesce(options.fail_fast, () => ( options.failFast)), () => ( false));
|
|
1090
1094
|
return transport.request("memories_batch", {
|
|
@@ -1094,15 +1098,15 @@ function createMemoriesInterface(transport, onForgotten) {
|
|
|
1094
1098
|
async create_from_file(options) {
|
|
1095
1099
|
const userId = _nullishCoalesce(options.user_id, () => ( options.userId));
|
|
1096
1100
|
const customerId = _nullishCoalesce(options.customer_id, () => ( options.customerId));
|
|
1097
|
-
if (!userId) throw new (0,
|
|
1098
|
-
transport.checkCustomerId(customerId, "memories.create_from_file");
|
|
1101
|
+
if (!userId) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("user_id is required");
|
|
1102
|
+
await transport.checkCustomerId(customerId, "memories.create_from_file");
|
|
1099
1103
|
const filePath = _nullishCoalesce(options.file_path, () => ( options.filePath));
|
|
1100
1104
|
const sources = [filePath, options.file, options.text].filter((v) => v !== void 0);
|
|
1101
1105
|
if (sources.length === 0) {
|
|
1102
|
-
throw new (0,
|
|
1106
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("One of file_path, file, or text must be provided.");
|
|
1103
1107
|
}
|
|
1104
1108
|
if (sources.length > 1) {
|
|
1105
|
-
throw new (0,
|
|
1109
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)(
|
|
1106
1110
|
"Provide exactly one of file_path, file, or text, not several."
|
|
1107
1111
|
);
|
|
1108
1112
|
}
|
|
@@ -1133,13 +1137,13 @@ function createMemoriesInterface(transport, onForgotten) {
|
|
|
1133
1137
|
});
|
|
1134
1138
|
},
|
|
1135
1139
|
async get(memoryId) {
|
|
1136
|
-
if (!memoryId) throw new (0,
|
|
1140
|
+
if (!memoryId) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("memory_id is required");
|
|
1137
1141
|
return transport.request("memories_get", { pathParams: { memory_id: memoryId } });
|
|
1138
1142
|
},
|
|
1139
1143
|
async update(options) {
|
|
1140
1144
|
const memoryId = _nullishCoalesce(options.memory_id, () => ( options.memoryId));
|
|
1141
|
-
if (!memoryId) throw new (0,
|
|
1142
|
-
if (!options.document) throw new (0,
|
|
1145
|
+
if (!memoryId) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("memory_id is required");
|
|
1146
|
+
if (!options.document) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("document is required");
|
|
1143
1147
|
const body = {
|
|
1144
1148
|
document: options.document,
|
|
1145
1149
|
merge_strategy: _nullishCoalesce(_nullishCoalesce(options.merge_strategy, () => ( options.mergeStrategy)), () => ( "smart-merge"))
|
|
@@ -1154,7 +1158,7 @@ function createMemoriesInterface(transport, onForgotten) {
|
|
|
1154
1158
|
},
|
|
1155
1159
|
async delete(memoryId) {
|
|
1156
1160
|
if (!memoryId) {
|
|
1157
|
-
throw new (0,
|
|
1161
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)(
|
|
1158
1162
|
"memory_id is required. Deleting by user is no longer supported: the previous implementation tracked ids in process memory, so it silently deleted nothing in any serverless or multi-process deployment while reporting success."
|
|
1159
1163
|
);
|
|
1160
1164
|
}
|
|
@@ -1162,7 +1166,7 @@ function createMemoriesInterface(transport, onForgotten) {
|
|
|
1162
1166
|
},
|
|
1163
1167
|
async forget(options) {
|
|
1164
1168
|
const o2 = options;
|
|
1165
|
-
transport.checkCustomerId(_nullishCoalesce(o2["customer_id"], () => ( o2["customerId"])), "memories.forget");
|
|
1169
|
+
await transport.checkCustomerId(_nullishCoalesce(o2["customer_id"], () => ( o2["customerId"])), "memories.forget");
|
|
1166
1170
|
const body = buildForgetBody(options);
|
|
1167
1171
|
const result = await transport.request("memories_forget", { body });
|
|
1168
1172
|
const removed = !!_optionalChain([result, 'optionalAccess', _38 => _38.deleted_ids, 'optionalAccess', _39 => _39.length]) || _optionalChain([result, 'optionalAccess', _40 => _40.status]) === "deleted" || _optionalChain([result, 'optionalAccess', _41 => _41.status]) === "partial";
|
|
@@ -1178,13 +1182,13 @@ function createMemoriesInterface(transport, onForgotten) {
|
|
|
1178
1182
|
return result;
|
|
1179
1183
|
},
|
|
1180
1184
|
async status(ingestionId) {
|
|
1181
|
-
if (!ingestionId) throw new (0,
|
|
1185
|
+
if (!ingestionId) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("ingestion_id is required");
|
|
1182
1186
|
return transport.request("memories_status", {
|
|
1183
1187
|
pathParams: { ingestion_id: ingestionId }
|
|
1184
1188
|
});
|
|
1185
1189
|
},
|
|
1186
1190
|
async wait_for_completion(ingestionId, options = {}) {
|
|
1187
|
-
if (!ingestionId) throw new (0,
|
|
1191
|
+
if (!ingestionId) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("ingestion_id is required");
|
|
1188
1192
|
const timeoutMs = (_nullishCoalesce(_nullishCoalesce(options.timeout_seconds, () => ( options.timeoutSeconds)), () => ( 300))) * 1e3;
|
|
1189
1193
|
const pollMs = (_nullishCoalesce(_nullishCoalesce(options.poll_interval_seconds, () => ( options.pollIntervalSeconds)), () => ( 2))) * 1e3;
|
|
1190
1194
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -1222,13 +1226,13 @@ var UUID_RE = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9
|
|
|
1222
1226
|
function validateConversationId(conversationId) {
|
|
1223
1227
|
if (conversationId === void 0 || conversationId === null || conversationId === "") return;
|
|
1224
1228
|
if (typeof conversationId !== "string" || !UUID_RE.test(conversationId)) {
|
|
1225
|
-
throw new (0,
|
|
1229
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidConversationIdError)(`Invalid conversation ID: ${String(conversationId)}`);
|
|
1226
1230
|
}
|
|
1227
1231
|
}
|
|
1228
1232
|
function validateInstanceId(instanceId) {
|
|
1229
1233
|
if (instanceId === void 0 || instanceId === null || instanceId === "") return;
|
|
1230
1234
|
if (typeof instanceId !== "string" || !INSTANCE_ID_RE.test(instanceId)) {
|
|
1231
|
-
throw new (0,
|
|
1235
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInstanceIdError)(`Invalid instance ID: ${String(instanceId)}`);
|
|
1232
1236
|
}
|
|
1233
1237
|
}
|
|
1234
1238
|
|
|
@@ -1278,13 +1282,13 @@ function buildRecordMessageBody(options) {
|
|
|
1278
1282
|
const conversationId = either2(o2, "conversation_id", "conversationId");
|
|
1279
1283
|
const userId = either2(o2, "user_id", "userId");
|
|
1280
1284
|
const customerId = either2(o2, "customer_id", "customerId");
|
|
1281
|
-
if (!conversationId) throw new (0,
|
|
1285
|
+
if (!conversationId) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("conversation_id is required");
|
|
1282
1286
|
validateConversationId(conversationId);
|
|
1283
|
-
if (!options.role) throw new (0,
|
|
1287
|
+
if (!options.role) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("role is required");
|
|
1284
1288
|
if (options.content === void 0 || options.content === null) {
|
|
1285
|
-
throw new (0,
|
|
1289
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("content is required");
|
|
1286
1290
|
}
|
|
1287
|
-
if (!userId) throw new (0,
|
|
1291
|
+
if (!userId) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("user_id is required");
|
|
1288
1292
|
const body = {
|
|
1289
1293
|
conversation_id: conversationId,
|
|
1290
1294
|
role: options.role,
|
|
@@ -1304,10 +1308,10 @@ function buildIngestTranscriptBody(options) {
|
|
|
1304
1308
|
const o2 = options;
|
|
1305
1309
|
const conversationId = either2(o2, "conversation_id", "conversationId");
|
|
1306
1310
|
const userId = either2(o2, "user_id", "userId");
|
|
1307
|
-
if (!conversationId) throw new (0,
|
|
1308
|
-
if (!userId) throw new (0,
|
|
1311
|
+
if (!conversationId) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("conversation_id is required");
|
|
1312
|
+
if (!userId) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("user_id is required");
|
|
1309
1313
|
if (options.transcript === void 0 || options.transcript === null) {
|
|
1310
|
-
throw new (0,
|
|
1314
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("transcript is required");
|
|
1311
1315
|
}
|
|
1312
1316
|
const body = {
|
|
1313
1317
|
conversation_id: conversationId,
|
|
@@ -1331,7 +1335,7 @@ function buildIngestTranscriptBody(options) {
|
|
|
1331
1335
|
function buildCompactBody(options) {
|
|
1332
1336
|
const o2 = options;
|
|
1333
1337
|
const conversationId = either2(o2, "conversation_id", "conversationId");
|
|
1334
|
-
if (!conversationId) throw new (0,
|
|
1338
|
+
if (!conversationId) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("conversation_id is required");
|
|
1335
1339
|
validateConversationId(conversationId);
|
|
1336
1340
|
const body = { conversation_id: conversationId, force: _nullishCoalesce(options.force, () => ( false)) };
|
|
1337
1341
|
const strategy = _nullishCoalesce(options.strategy, () => ( either2(o2, "compaction_level", "compactionLevel")));
|
|
@@ -1427,13 +1431,13 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
|
|
|
1427
1431
|
};
|
|
1428
1432
|
const convId = (v) => {
|
|
1429
1433
|
const id = typeof v === "string" ? v : _nullishCoalesce(v.conversation_id, () => ( v.conversationId));
|
|
1430
|
-
if (!id) throw new (0,
|
|
1434
|
+
if (!id) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("conversation_id is required");
|
|
1431
1435
|
validateConversationId(id);
|
|
1432
1436
|
return id;
|
|
1433
1437
|
};
|
|
1434
1438
|
return {
|
|
1435
1439
|
async record_message(options) {
|
|
1436
|
-
transport.checkCustomerId(
|
|
1440
|
+
await transport.checkCustomerId(
|
|
1437
1441
|
_nullishCoalesce(options["customer_id"], () => ( options["customerId"])),
|
|
1438
1442
|
"conversation.record_message"
|
|
1439
1443
|
);
|
|
@@ -1461,11 +1465,11 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
|
|
|
1461
1465
|
},
|
|
1462
1466
|
async record_messages_batch(messages) {
|
|
1463
1467
|
if (!Array.isArray(messages) || messages.length === 0) {
|
|
1464
|
-
throw new (0,
|
|
1468
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("messages must be a non-empty array");
|
|
1465
1469
|
}
|
|
1466
1470
|
for (const m of messages) {
|
|
1467
1471
|
const mo = m;
|
|
1468
|
-
transport.checkCustomerId(
|
|
1472
|
+
await transport.checkCustomerId(
|
|
1469
1473
|
_nullishCoalesce(mo["customer_id"], () => ( mo["customerId"])),
|
|
1470
1474
|
"conversation.record_messages_batch"
|
|
1471
1475
|
);
|
|
@@ -1572,8 +1576,8 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
|
|
|
1572
1576
|
* Returns an idempotent unsubscribe thunk, matching Python.
|
|
1573
1577
|
*/
|
|
1574
1578
|
subscribe_to_compaction_updates(conversationId, callback) {
|
|
1575
|
-
if (!conversationId) throw new (0,
|
|
1576
|
-
if (typeof callback !== "function") throw new (0,
|
|
1579
|
+
if (!conversationId) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("conversation_id is required");
|
|
1580
|
+
if (typeof callback !== "function") throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("callback is required");
|
|
1577
1581
|
return subscribers.add(conversationId, callback);
|
|
1578
1582
|
},
|
|
1579
1583
|
/** Remove subscribers for one conversation, or all of them. Returns the count removed. */
|
|
@@ -1589,7 +1593,7 @@ function createUserNamespace(transport, hooks = {}) {
|
|
|
1589
1593
|
return {
|
|
1590
1594
|
async get_profile(options) {
|
|
1591
1595
|
const userId = typeof options === "string" ? options : _nullishCoalesce(options.user_id, () => ( options.userId));
|
|
1592
|
-
if (!userId) throw new (0,
|
|
1596
|
+
if (!userId) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("user_id is required");
|
|
1593
1597
|
const customerId = typeof options === "string" ? void 0 : _nullishCoalesce(options.customer_id, () => ( options.customerId));
|
|
1594
1598
|
return transport.request("user_profile", {
|
|
1595
1599
|
pathParams: { user_id: userId },
|
|
@@ -1638,7 +1642,7 @@ function createCreditsNamespace(transport) {
|
|
|
1638
1642
|
});
|
|
1639
1643
|
},
|
|
1640
1644
|
async redeem(code) {
|
|
1641
|
-
if (!code) throw new (0,
|
|
1645
|
+
if (!code) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("code is required");
|
|
1642
1646
|
return transport.request("credits_redeem", { body: { code } });
|
|
1643
1647
|
}
|
|
1644
1648
|
};
|
|
@@ -1649,11 +1653,11 @@ function createCacheNamespace(cache) {
|
|
|
1649
1653
|
return {
|
|
1650
1654
|
clear: () => cache.clear(),
|
|
1651
1655
|
clear_user: (userId) => {
|
|
1652
|
-
if (!userId) throw new (0,
|
|
1656
|
+
if (!userId) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("user_id is required");
|
|
1653
1657
|
cache.dropEntity(userId);
|
|
1654
1658
|
},
|
|
1655
1659
|
clear_customer: (customerId) => {
|
|
1656
|
-
if (!customerId) throw new (0,
|
|
1660
|
+
if (!customerId) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("customer_id is required");
|
|
1657
1661
|
cache.dropEntity(customerId);
|
|
1658
1662
|
},
|
|
1659
1663
|
stats: () => ({ bundles: cache.size, items: cache.itemCount })
|
|
@@ -1753,7 +1757,7 @@ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () =>
|
|
|
1753
1757
|
function ensureSession(conversationId, userId, customerId) {
|
|
1754
1758
|
if (!conversationId || !userId || client === null) return;
|
|
1755
1759
|
if (openSessions.has(conversationId)) return;
|
|
1756
|
-
const sessionId =
|
|
1760
|
+
const sessionId = _chunkUXNVTP4Dcjs.newCorrelationId.call(void 0, );
|
|
1757
1761
|
try {
|
|
1758
1762
|
client.sendSessionControl({
|
|
1759
1763
|
action: "start",
|
|
@@ -1769,13 +1773,13 @@ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () =>
|
|
|
1769
1773
|
const namespace = {
|
|
1770
1774
|
async listen(options = {}) {
|
|
1771
1775
|
if (client !== null) {
|
|
1772
|
-
throw new (0,
|
|
1776
|
+
throw new (0, _chunkUXNVTP4Dcjs.ListeningAlreadyActiveError)("Listening is already active on this instance");
|
|
1773
1777
|
}
|
|
1774
1778
|
try {
|
|
1775
1779
|
_optionalChain([onListen, 'optionalCall', _57 => _57()]);
|
|
1776
1780
|
} catch (e10) {
|
|
1777
1781
|
}
|
|
1778
|
-
const { GrpcStreamClient } = await Promise.resolve().then(() => _interopRequireWildcard(require("./stream-client-
|
|
1782
|
+
const { GrpcStreamClient } = await Promise.resolve().then(() => _interopRequireWildcard(require("./stream-client-5GYUWETN.cjs")));
|
|
1779
1783
|
const onContext = _nullishCoalesce(options.on_context, () => ( options.onContext));
|
|
1780
1784
|
const onDisconnect = _nullishCoalesce(options.on_disconnect, () => ( options.onDisconnect));
|
|
1781
1785
|
const onReconnect = _nullishCoalesce(options.on_reconnect, () => ( options.onReconnect));
|
|
@@ -1808,8 +1812,8 @@ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () =>
|
|
|
1808
1812
|
try {
|
|
1809
1813
|
await created.connect();
|
|
1810
1814
|
} catch (error) {
|
|
1811
|
-
if (error instanceof
|
|
1812
|
-
throw new (0,
|
|
1815
|
+
if (error instanceof _chunkUXNVTP4Dcjs.SynapError) throw error;
|
|
1816
|
+
throw new (0, _chunkUXNVTP4Dcjs.SynapError)(
|
|
1813
1817
|
`Could not open the Synap anticipation stream: ${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _62 => _62.message]), () => ( String(error)))}`,
|
|
1814
1818
|
{ cause: error }
|
|
1815
1819
|
);
|
|
@@ -1839,13 +1843,13 @@ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () =>
|
|
|
1839
1843
|
}
|
|
1840
1844
|
},
|
|
1841
1845
|
async send_message(options) {
|
|
1842
|
-
if (client === null) throw new (0,
|
|
1846
|
+
if (client === null) throw new (0, _chunkUXNVTP4Dcjs.ListeningNotActiveError)("Listening is not active");
|
|
1843
1847
|
if (options.content === void 0) {
|
|
1844
|
-
throw new (0,
|
|
1848
|
+
throw new (0, _chunkUXNVTP4Dcjs.ListeningNotActiveError)("content is required");
|
|
1845
1849
|
}
|
|
1846
1850
|
const eventType = _nullishCoalesce(_nullishCoalesce(options.event_type, () => ( options.eventType)), () => ( "user_message"));
|
|
1847
1851
|
if (!KNOWN_EVENT_TYPES.has(eventType)) {
|
|
1848
|
-
throw new (0,
|
|
1852
|
+
throw new (0, _chunkUXNVTP4Dcjs.SynapError)(
|
|
1849
1853
|
`unknown event_type '${eventType}'. Expected one of: ` + [...KNOWN_EVENT_TYPES].sort().join(", ")
|
|
1850
1854
|
);
|
|
1851
1855
|
}
|
|
@@ -1919,7 +1923,7 @@ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () =>
|
|
|
1919
1923
|
});
|
|
1920
1924
|
},
|
|
1921
1925
|
async record_thinking(options) {
|
|
1922
|
-
if (client === null) throw new (0,
|
|
1926
|
+
if (client === null) throw new (0, _chunkUXNVTP4Dcjs.ListeningNotActiveError)("Listening is not active");
|
|
1923
1927
|
const conversationId = _nullishCoalesce(_nullishCoalesce(options.conversation_id, () => ( options.conversationId)), () => ( ""));
|
|
1924
1928
|
ensureSession(
|
|
1925
1929
|
conversationId,
|
|
@@ -1954,7 +1958,7 @@ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () =>
|
|
|
1954
1958
|
}
|
|
1955
1959
|
|
|
1956
1960
|
// src/version.ts
|
|
1957
|
-
var SDK_VERSION = "0.5.
|
|
1961
|
+
var SDK_VERSION = "0.5.11";
|
|
1958
1962
|
|
|
1959
1963
|
// src/registry.ts
|
|
1960
1964
|
var instances = /* @__PURE__ */ new Map();
|
|
@@ -3617,7 +3621,7 @@ function buildTool(target, options = {}, onWarning = () => {
|
|
|
3617
3621
|
const scope = String(_nullishCoalesce(options.scope, () => ( "user"))).toLowerCase();
|
|
3618
3622
|
if (!VALID_SCOPES.includes(scope)) {
|
|
3619
3623
|
const sorted = [...VALID_SCOPES].sort();
|
|
3620
|
-
throw new (0,
|
|
3624
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)(
|
|
3621
3625
|
`scope must be one of ['${sorted.join("', '")}'], got '${String(options.scope)}'`
|
|
3622
3626
|
);
|
|
3623
3627
|
}
|
|
@@ -3625,10 +3629,10 @@ function buildTool(target, options = {}, onWarning = () => {
|
|
|
3625
3629
|
const customerId = _nullishCoalesce(options.customer_id, () => ( options.customerId));
|
|
3626
3630
|
const conversationId = _nullishCoalesce(options.conversation_id, () => ( options.conversationId));
|
|
3627
3631
|
if (scope === "user" && (userId === void 0 || userId === "")) {
|
|
3628
|
-
throw new (0,
|
|
3632
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("scope='user' requires user_id");
|
|
3629
3633
|
}
|
|
3630
3634
|
if (scope === "customer" && (customerId === void 0 || customerId === "")) {
|
|
3631
|
-
throw new (0,
|
|
3635
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("scope='customer' requires customer_id");
|
|
3632
3636
|
}
|
|
3633
3637
|
if (scope === "conversation" && (userId === void 0 || userId === "")) {
|
|
3634
3638
|
onWarning(
|
|
@@ -3637,7 +3641,7 @@ function buildTool(target, options = {}, onWarning = () => {
|
|
|
3637
3641
|
}
|
|
3638
3642
|
const style = String(_nullishCoalesce(options.style, () => ( "openai")));
|
|
3639
3643
|
if (style !== "openai" && style !== "anthropic") {
|
|
3640
|
-
throw new (0,
|
|
3644
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)(`style must be 'openai' or 'anthropic', got '${style}'`);
|
|
3641
3645
|
}
|
|
3642
3646
|
const toolName = _nullishCoalesce(options.name, () => ( `synap_fetch_${scope}_context`));
|
|
3643
3647
|
const toolDesc = _nullishCoalesce(options.description, () => ( defaultToolDescription(scope)));
|
|
@@ -3885,9 +3889,9 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
3885
3889
|
*/
|
|
3886
3890
|
async searchMemory(options) {
|
|
3887
3891
|
const userId = _nullishCoalesce(options.user_id, () => ( options.userId));
|
|
3888
|
-
if (!userId) throw new (0,
|
|
3892
|
+
if (!userId) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("user_id is required");
|
|
3889
3893
|
if (options.query === void 0 || options.query === null) {
|
|
3890
|
-
throw new (0,
|
|
3894
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("query is required");
|
|
3891
3895
|
}
|
|
3892
3896
|
const context = await fetchContext(this.#transport, "user", {
|
|
3893
3897
|
user_id: userId,
|
|
@@ -3908,7 +3912,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
3908
3912
|
*/
|
|
3909
3913
|
async getMemories(options) {
|
|
3910
3914
|
const userId = _nullishCoalesce(options.user_id, () => ( options.userId));
|
|
3911
|
-
if (!userId) throw new (0,
|
|
3915
|
+
if (!userId) throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("user_id is required");
|
|
3912
3916
|
const context = await fetchContext(this.#transport, "user", {
|
|
3913
3917
|
user_id: userId,
|
|
3914
3918
|
...pick3(options, "customer_id", "customerId") !== void 0 ? { customer_id: pick3(options, "customer_id", "customerId") } : {},
|
|
@@ -4013,7 +4017,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
4013
4017
|
*/
|
|
4014
4018
|
configure(options = {}) {
|
|
4015
4019
|
if (this.#initialized) {
|
|
4016
|
-
throw new (0,
|
|
4020
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)("Cannot reconfigure after initialization");
|
|
4017
4021
|
}
|
|
4018
4022
|
if (options.timeouts !== void 0) this.#transport.setTimeouts(options.timeouts);
|
|
4019
4023
|
if (options.retryPolicy !== void 0 || options.retry_policy !== void 0) {
|
|
@@ -4064,6 +4068,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
4064
4068
|
last_n_conversations: lastNConversations = 1,
|
|
4065
4069
|
response_shape: responseShape = "by_type"
|
|
4066
4070
|
} = options;
|
|
4071
|
+
await this.#transport.checkCustomerId(customerId, "sdk.fetch");
|
|
4067
4072
|
validateConversationId(conversationId);
|
|
4068
4073
|
responseShapeOf({ response_shape: responseShape });
|
|
4069
4074
|
const wants = (scope) => scopes === void 0 || scopes.includes(scope);
|
|
@@ -4131,7 +4136,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
4131
4136
|
successful.push([label, result.value]);
|
|
4132
4137
|
continue;
|
|
4133
4138
|
}
|
|
4134
|
-
if (result.reason instanceof
|
|
4139
|
+
if (result.reason instanceof _chunkUXNVTP4Dcjs.InvalidInputError) throw result.reason;
|
|
4135
4140
|
this.#warn(`Scope '${label}' fetch failed in unified fetch (non-fatal): ${String(result.reason)}`);
|
|
4136
4141
|
}
|
|
4137
4142
|
const merged = mergeScopeResults(successful);
|
|
@@ -4210,7 +4215,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
4210
4215
|
if (!this.instance.is_listening) return;
|
|
4211
4216
|
this.instance._internal.sendContextAssembled({
|
|
4212
4217
|
...buildAssembledEvent({
|
|
4213
|
-
correlationId:
|
|
4218
|
+
correlationId: _chunkUXNVTP4Dcjs.newCorrelationId.call(void 0, ),
|
|
4214
4219
|
response,
|
|
4215
4220
|
conversationId: _nullishCoalesce(options["conversation_id"], () => ( options["conversationId"])),
|
|
4216
4221
|
userId: _nullishCoalesce(options["user_id"], () => ( options["userId"])),
|
|
@@ -4438,7 +4443,7 @@ function resolveBaseUrl(options) {
|
|
|
4438
4443
|
function resolveCredentials(options) {
|
|
4439
4444
|
const apiKey = _nullishCoalesce(options.apiKey, () => ( _chunkZKOJDUN4cjs.getEnv.call(void 0, "SYNAP_API_KEY")));
|
|
4440
4445
|
if (!apiKey) {
|
|
4441
|
-
throw new (0,
|
|
4446
|
+
throw new (0, _chunkUXNVTP4Dcjs.InvalidInputError)(
|
|
4442
4447
|
"No Synap API key found. Set SYNAP_API_KEY in your environment, or pass apiKey to the SynapClient constructor."
|
|
4443
4448
|
);
|
|
4444
4449
|
}
|
|
@@ -4506,5 +4511,6 @@ function resolveCredentials(options) {
|
|
|
4506
4511
|
|
|
4507
4512
|
|
|
4508
4513
|
|
|
4509
|
-
|
|
4514
|
+
|
|
4515
|
+
exports.ANY_SCOPE = _chunkICUFS3B5cjs.ANY_SCOPE; exports.AgentUnavailableError = _chunkUXNVTP4Dcjs.AgentUnavailableError; exports.AnticipationCache = _chunkICUFS3B5cjs.AnticipationCache; exports.AuthenticationError = _chunkUXNVTP4Dcjs.AuthenticationError; exports.BM25 = _chunkICUFS3B5cjs.BM25; exports.COMPACTION_LEVELS = COMPACTION_LEVELS; exports.CONTRACT = _chunkICUFS3B5cjs.CONTRACT; exports.ConflictError = _chunkUXNVTP4Dcjs.ConflictError; exports.ConnectionError = _chunkUXNVTP4Dcjs.ConnectionError; exports.ContextNotFoundError = _chunkUXNVTP4Dcjs.ContextNotFoundError; exports.CustomerIdNotAcceptedError = _chunkUXNVTP4Dcjs.CustomerIdNotAcceptedError; exports.DEFAULT_BASE_URL = DEFAULT_BASE_URL; exports.DEFAULT_DOCUMENT_TYPE = DEFAULT_DOCUMENT_TYPE; exports.DEFAULT_INGEST_MODE = DEFAULT_INGEST_MODE; exports.DEFAULT_RETRY_POLICY = DEFAULT_RETRY_POLICY; exports.DEFAULT_TIMEOUTS = DEFAULT_TIMEOUTS; exports.DOCUMENT_TYPES = DOCUMENT_TYPES; exports.ENDPOINTS = ENDPOINTS; exports.EXCERPT_CATEGORY = EXCERPT_CATEGORY; exports.FORGET_MODES = FORGET_MODES; exports.HttpTransport = HttpTransport; exports.INGEST_MODES = INGEST_MODES; exports.ITEM_COLLECTIONS = ITEM_COLLECTIONS; exports.InsufficientCreditsError = _chunkUXNVTP4Dcjs.InsufficientCreditsError; exports.InvalidConversationIdError = _chunkUXNVTP4Dcjs.InvalidConversationIdError; exports.InvalidInputError = _chunkUXNVTP4Dcjs.InvalidInputError; exports.InvalidInstanceIdError = _chunkUXNVTP4Dcjs.InvalidInstanceIdError; exports.ListeningAlreadyActiveError = _chunkUXNVTP4Dcjs.ListeningAlreadyActiveError; exports.ListeningNotActiveError = _chunkUXNVTP4Dcjs.ListeningNotActiveError; exports.MEMORY_TYPES = MEMORY_TYPES; exports.NetworkTimeoutError = _chunkUXNVTP4Dcjs.NetworkTimeoutError; exports.PermanentError = _chunkUXNVTP4Dcjs.PermanentError; exports.RESPONSE_SHAPES = RESPONSE_SHAPES; exports.RateLimitError = _chunkUXNVTP4Dcjs.RateLimitError; exports.SDKError = _chunkUXNVTP4Dcjs.SDKError; exports.SDK_VERSION = SDK_VERSION; exports.ServiceUnavailableError = _chunkUXNVTP4Dcjs.ServiceUnavailableError; exports.SessionExpiredError = _chunkUXNVTP4Dcjs.SessionExpiredError; exports.SynapClient = SynapClient; exports.SynapError = _chunkUXNVTP4Dcjs.SynapError; exports.SynapPermanentError = _chunkUXNVTP4Dcjs.SynapPermanentError; exports.SynapTransientError = _chunkUXNVTP4Dcjs.SynapTransientError; exports.THRESHOLDS = _chunkICUFS3B5cjs.THRESHOLDS; exports.TranscriptConflictError = _chunkUXNVTP4Dcjs.TranscriptConflictError; exports.TransientError = _chunkUXNVTP4Dcjs.TransientError; exports.applyResponseShape = applyResponseShape; exports.flattenContextItems = flattenContextItems; exports.formatForPrompt = formatForPrompt; exports.isOutcomeUnknown = isOutcomeUnknown; exports.isRecallQuery = _chunkICUFS3B5cjs.isRecallQuery; exports.isSynapError = _chunkUXNVTP4Dcjs.isSynapError; exports.mergeScopeResults = mergeScopeResults; exports.rankItems = rankItems; exports.resolvePath = resolvePath; exports.shouldRetry = shouldRetry; exports.stem = _chunkICUFS3B5cjs.stem; exports.tokenize = _chunkICUFS3B5cjs.tokenize; exports.wireRankScore = wireRankScore;
|
|
4510
4516
|
//# sourceMappingURL=index.cjs.map
|