@maximem/synap-js-sdk 0.4.2 → 0.4.4
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-HR5Y3KXS.cjs → chunk-2TVL5IPQ.cjs} +7 -1
- package/dist/chunk-2TVL5IPQ.cjs.map +1 -0
- package/dist/{chunk-VXRCBMCY.cjs → chunk-3JSE64GW.cjs} +1 -1
- package/dist/{chunk-VXRCBMCY.cjs.map → chunk-3JSE64GW.cjs.map} +1 -1
- package/dist/{chunk-T3NZBIV2.js → chunk-OCMM2Z5P.js} +7 -1
- package/dist/chunk-OCMM2Z5P.js.map +1 -0
- package/dist/{chunk-5SC3ELNK.js → chunk-ZU6ZC4SU.js} +1 -1
- package/dist/chunk-ZU6ZC4SU.js.map +1 -0
- package/dist/grpc/index.cjs +7 -7
- package/dist/grpc/index.d.cts +4 -0
- package/dist/grpc/index.d.ts +4 -0
- package/dist/grpc/index.js +3 -3
- package/dist/index.cjs +204 -94
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +186 -20
- package/dist/index.d.ts +186 -20
- package/dist/index.js +124 -14
- package/dist/index.js.map +1 -1
- package/dist/stream-client-6V4FGKZ3.js +7 -0
- package/dist/stream-client-PRTOH62B.cjs +7 -0
- package/dist/stream-client-PRTOH62B.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-5SC3ELNK.js.map +0 -1
- package/dist/chunk-HR5Y3KXS.cjs.map +0 -1
- package/dist/chunk-T3NZBIV2.js.map +0 -1
- package/dist/stream-client-ME5N5NK4.js +0 -7
- package/dist/stream-client-ZN6ADZBR.cjs +0 -7
- package/dist/stream-client-ZN6ADZBR.cjs.map +0 -1
- /package/dist/{stream-client-ME5N5NK4.js.map → stream-client-6V4FGKZ3.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -245,7 +245,8 @@ interface HttpTransportOptions {
|
|
|
245
245
|
credentials: Credentials;
|
|
246
246
|
baseUrl?: string;
|
|
247
247
|
timeouts?: Partial<TimeoutConfig>;
|
|
248
|
-
|
|
248
|
+
/** `null` disables retries entirely, as Python's `retry_policy=None` does. */
|
|
249
|
+
retryPolicy?: Partial<RetryPolicy> | null;
|
|
249
250
|
keepAlive?: KeepAliveOptions & {
|
|
250
251
|
heartbeatIntervalMs?: number;
|
|
251
252
|
};
|
|
@@ -299,8 +300,27 @@ declare class HttpTransport {
|
|
|
299
300
|
currentCredentials(): Credentials;
|
|
300
301
|
/** Write back identity resolved from `GET /api/v1/auth/whoami`. */
|
|
301
302
|
updateCredentials(patch: Partial<Credentials>): void;
|
|
303
|
+
/**
|
|
304
|
+
* The instance's scoping mode, from whoami. Lives here rather than on the
|
|
305
|
+
* client because every interface factory already receives the transport,
|
|
306
|
+
* and it is per-client, so a module-level global would be wrong the moment a
|
|
307
|
+
* process holds two clients.
|
|
308
|
+
*
|
|
309
|
+
* undefined means the server did not report it, which is true of any
|
|
310
|
+
* deployment older than the field, and must mean "enforce nothing".
|
|
311
|
+
*/
|
|
312
|
+
userContextIsolation: string | undefined;
|
|
313
|
+
/** Refuse a customer_id on a B2C instance, at the call site. */
|
|
314
|
+
checkCustomerId(customerId: unknown, where: string): void;
|
|
302
315
|
setTimeouts(timeouts: Partial<TimeoutConfig>): void;
|
|
303
|
-
/**
|
|
316
|
+
/**
|
|
317
|
+
* `null` DISABLES retries, matching Python.
|
|
318
|
+
*
|
|
319
|
+
* Python's `SDKConfig(retry_policy=None)` leaves `self.retry_policy` unset and
|
|
320
|
+
* `max_attempts` falls to 1 (http_client.py:180). We restored the default
|
|
321
|
+
* policy instead, so a caller following the "Disabling Retries" documentation
|
|
322
|
+
* got three attempts and no way to turn them off.
|
|
323
|
+
*/
|
|
304
324
|
setRetryPolicy(policy: Partial<RetryPolicy> | null): void;
|
|
305
325
|
close(): void;
|
|
306
326
|
request<T = unknown>(name: EndpointName, options?: RequestOptions): Promise<T>;
|
|
@@ -477,6 +497,23 @@ interface FetchOptions {
|
|
|
477
497
|
precisionLevel?: string;
|
|
478
498
|
/** Sent only when explicitly false, matching the Python controllers. */
|
|
479
499
|
include_conversation_context?: boolean;
|
|
500
|
+
/**
|
|
501
|
+
* `"in-conversation"` (default) or `"conversation-summary"`.
|
|
502
|
+
*
|
|
503
|
+
* Summary mode returns a caller profile plus previous-conversation
|
|
504
|
+
* summaries. USER SCOPE ONLY: the other three routes reject it with 422.
|
|
505
|
+
*/
|
|
506
|
+
context_mode?: string;
|
|
507
|
+
contextMode?: string;
|
|
508
|
+
/** Summary mode only. Include the caller profile. */
|
|
509
|
+
include_profile?: boolean;
|
|
510
|
+
includeProfile?: boolean;
|
|
511
|
+
/** Summary mode only. Previous conversations to summarise, 0 to 20. */
|
|
512
|
+
last_n_conversations?: number;
|
|
513
|
+
lastNConversations?: number;
|
|
514
|
+
/** Explicit scope ladder. Sent as `scope` when supplied. */
|
|
515
|
+
scope_path?: Record<string, string>;
|
|
516
|
+
scopePath?: Record<string, string>;
|
|
480
517
|
}
|
|
481
518
|
|
|
482
519
|
/**
|
|
@@ -555,12 +592,37 @@ interface CreateMemoryOptions {
|
|
|
555
592
|
mode?: IngestMode | string;
|
|
556
593
|
metadata?: Json;
|
|
557
594
|
}
|
|
595
|
+
/**
|
|
596
|
+
* Mirrors Python's `CreateMemoryResponse`.
|
|
597
|
+
*
|
|
598
|
+
* The first four fields are required there (Pydantic would raise if the server
|
|
599
|
+
* omitted one), so they are required here too. Declaring `ingestion_id` optional
|
|
600
|
+
* made the commonest two-line pattern in the docs fail to compile under strict
|
|
601
|
+
* TypeScript: `wait_for_completion(result.ingestion_id)` cannot take
|
|
602
|
+
* `string | undefined`.
|
|
603
|
+
*/
|
|
558
604
|
interface CreateMemoryResult {
|
|
559
|
-
ingestion_id
|
|
560
|
-
|
|
605
|
+
ingestion_id: string;
|
|
606
|
+
document_id: string;
|
|
607
|
+
status: string;
|
|
608
|
+
/** ISO-8601. Python types this as a datetime. */
|
|
609
|
+
queued_at: string;
|
|
610
|
+
error_message?: string | null;
|
|
561
611
|
memories_created?: number;
|
|
562
612
|
[key: string]: unknown;
|
|
563
613
|
}
|
|
614
|
+
/**
|
|
615
|
+
* Result of `memories.batch_create`, mirroring Python's `BatchCreateResponse`.
|
|
616
|
+
* It was `Json`, so `results` came back as `unknown` and could not be iterated.
|
|
617
|
+
*/
|
|
618
|
+
interface BatchCreateResult {
|
|
619
|
+
batch_id: string;
|
|
620
|
+
total: number;
|
|
621
|
+
succeeded: number;
|
|
622
|
+
failed: number;
|
|
623
|
+
results: CreateMemoryResult[];
|
|
624
|
+
[key: string]: unknown;
|
|
625
|
+
}
|
|
564
626
|
interface BatchCreateOptions {
|
|
565
627
|
documents: CreateMemoryOptions[];
|
|
566
628
|
fail_fast?: boolean;
|
|
@@ -568,7 +630,7 @@ interface BatchCreateOptions {
|
|
|
568
630
|
}
|
|
569
631
|
interface MemoriesInterface {
|
|
570
632
|
create(options: CreateMemoryOptions): Promise<CreateMemoryResult>;
|
|
571
|
-
batch_create(options: BatchCreateOptions): Promise<
|
|
633
|
+
batch_create(options: BatchCreateOptions): Promise<BatchCreateResult>;
|
|
572
634
|
create_from_file(options: CreateFromFileOptions): Promise<CreateMemoryResult>;
|
|
573
635
|
get(memoryId: string): Promise<Json>;
|
|
574
636
|
update(options: UpdateMemoryOptions): Promise<Json>;
|
|
@@ -664,20 +726,45 @@ interface IngestTranscriptOptions {
|
|
|
664
726
|
ended_at?: string | Date;
|
|
665
727
|
endedAt?: string | Date;
|
|
666
728
|
}
|
|
729
|
+
/**
|
|
730
|
+
* Compaction levels, mirroring Python's `CompactionLevel` enum. The JS SDK
|
|
731
|
+
* exported no equivalent, so `compaction_level` was an untyped `string` and a
|
|
732
|
+
* typo reached the server instead of the compiler.
|
|
733
|
+
*/
|
|
734
|
+
declare const COMPACTION_LEVELS: readonly ["low", "medium", "high", "adaptive", "aggressive", "balanced", "conservative"];
|
|
735
|
+
type CompactionLevel = (typeof COMPACTION_LEVELS)[number];
|
|
667
736
|
interface CompactOptions {
|
|
668
737
|
conversation_id?: string;
|
|
669
738
|
conversationId?: string;
|
|
670
739
|
strategy?: string;
|
|
671
|
-
compaction_level?: string;
|
|
672
|
-
compactionLevel?: string;
|
|
740
|
+
compaction_level?: CompactionLevel | string;
|
|
741
|
+
compactionLevel?: CompactionLevel | string;
|
|
673
742
|
target_tokens?: number;
|
|
674
743
|
targetTokens?: number;
|
|
675
744
|
force?: boolean;
|
|
676
745
|
}
|
|
746
|
+
/**
|
|
747
|
+
* Result of `conversation.ingest_transcript`, mirroring Python's
|
|
748
|
+
* `TranscriptIngestResponse`. It was `Json` here, so `ingestion_id` came back
|
|
749
|
+
* as `unknown` and could not be handed to `wait_for_completion` without a cast.
|
|
750
|
+
*/
|
|
751
|
+
interface TranscriptIngestResult {
|
|
752
|
+
conversation_id: string;
|
|
753
|
+
/** The raw client-supplied id, echoed back. */
|
|
754
|
+
external_conversation_id: string;
|
|
755
|
+
/** Always set on a 2xx, including the `duplicate` branch. */
|
|
756
|
+
ingestion_id: string;
|
|
757
|
+
status: 'queued' | 'duplicate';
|
|
758
|
+
turns_recorded: number;
|
|
759
|
+
summary_status: 'in_progress' | 'already_compacted' | 'skipped';
|
|
760
|
+
/** ISO-8601. */
|
|
761
|
+
queued_at: string;
|
|
762
|
+
[key: string]: unknown;
|
|
763
|
+
}
|
|
677
764
|
interface ConversationNamespace {
|
|
678
765
|
record_message(options: RecordMessageOptions): Promise<Json>;
|
|
679
766
|
record_messages_batch(messages: RecordMessageOptions[]): Promise<Json>;
|
|
680
|
-
ingest_transcript(options: IngestTranscriptOptions): Promise<
|
|
767
|
+
ingest_transcript(options: IngestTranscriptOptions): Promise<TranscriptIngestResult>;
|
|
681
768
|
context: {
|
|
682
769
|
fetch(options?: FetchOptions): Promise<RawContext>;
|
|
683
770
|
get_context_for_prompt(options?: {
|
|
@@ -750,13 +837,71 @@ interface EstimateOptions {
|
|
|
750
837
|
mode?: string;
|
|
751
838
|
}
|
|
752
839
|
interface CreditsNamespace {
|
|
753
|
-
get_balance(): Promise<
|
|
754
|
-
get_ledger(options?:
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
840
|
+
get_balance(): Promise<CreditBalance>;
|
|
841
|
+
get_ledger(options?: LedgerOptions): Promise<CreditLedgerPage>;
|
|
842
|
+
estimate(options: EstimateOptions): Promise<CreditEstimate>;
|
|
843
|
+
redeem(code: string): Promise<RedeemResult>;
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* Return types for the credits namespace, mirroring Python's dataclasses in
|
|
847
|
+
* `maximem_synap/credits.py`. These were all `Json` (`Record<string, unknown>`)
|
|
848
|
+
* before, so every field read was `unknown` and no documented example compiled.
|
|
849
|
+
*/
|
|
850
|
+
interface CreditBucket {
|
|
851
|
+
source_type: string;
|
|
852
|
+
balance: number;
|
|
853
|
+
/** ISO-8601, or null when the bucket does not expire. */
|
|
854
|
+
expires_at: string | null;
|
|
855
|
+
}
|
|
856
|
+
interface CreditBalance {
|
|
857
|
+
client_id: string;
|
|
858
|
+
balance_credits: number;
|
|
859
|
+
warning_low: boolean;
|
|
860
|
+
buckets: CreditBucket[];
|
|
861
|
+
[key: string]: unknown;
|
|
862
|
+
}
|
|
863
|
+
interface CreditLedgerEntry {
|
|
864
|
+
ledger_id: string;
|
|
865
|
+
entry_type: string;
|
|
866
|
+
delta: number;
|
|
867
|
+
metric_type: string | null;
|
|
868
|
+
category: string | null;
|
|
869
|
+
/** ISO-8601. */
|
|
870
|
+
created_at: string;
|
|
871
|
+
}
|
|
872
|
+
interface CreditLedgerPage {
|
|
873
|
+
entries: CreditLedgerEntry[];
|
|
874
|
+
total: number;
|
|
875
|
+
limit: number;
|
|
876
|
+
offset: number;
|
|
877
|
+
[key: string]: unknown;
|
|
878
|
+
}
|
|
879
|
+
interface CreditEstimate {
|
|
880
|
+
credits_estimate: number;
|
|
881
|
+
[key: string]: unknown;
|
|
882
|
+
}
|
|
883
|
+
interface RedeemResult {
|
|
884
|
+
redemption_id: string;
|
|
885
|
+
credits_granted: number;
|
|
886
|
+
new_balance_credits: number;
|
|
887
|
+
/** ISO-8601, or null when the granted credits do not expire. */
|
|
888
|
+
expires_at: string | null;
|
|
889
|
+
[key: string]: unknown;
|
|
890
|
+
}
|
|
891
|
+
/** Options for `credits.get_ledger`. Mirrors Python's keyword arguments. */
|
|
892
|
+
interface LedgerOptions {
|
|
893
|
+
/** Filter to one ledger entry type. */
|
|
894
|
+
entry_type?: string;
|
|
895
|
+
entryType?: string;
|
|
896
|
+
/** Inclusive lower bound. ISO-8601 string or Date. Sent as `from`. */
|
|
897
|
+
from_time?: string | Date;
|
|
898
|
+
fromTime?: string | Date;
|
|
899
|
+
/** Inclusive upper bound. ISO-8601 string or Date. Sent as `to`. */
|
|
900
|
+
to_time?: string | Date;
|
|
901
|
+
toTime?: string | Date;
|
|
902
|
+
/** Defaults to 100, as in Python. */
|
|
903
|
+
limit?: number;
|
|
904
|
+
offset?: number;
|
|
760
905
|
}
|
|
761
906
|
|
|
762
907
|
/**
|
|
@@ -826,6 +971,15 @@ interface SendMessageOptions {
|
|
|
826
971
|
event_type?: string;
|
|
827
972
|
eventType?: string;
|
|
828
973
|
metadata?: Record<string, string>;
|
|
974
|
+
/**
|
|
975
|
+
* Report a tool call on the stream. Python's `send_message` takes both, and
|
|
976
|
+
* the proto has `tool_name` / `tool_args_json`; the JS surface simply never
|
|
977
|
+
* exposed them, so a tool call could not be reported from JavaScript.
|
|
978
|
+
*/
|
|
979
|
+
tool_name?: string;
|
|
980
|
+
toolName?: string;
|
|
981
|
+
tool_args?: Record<string, unknown>;
|
|
982
|
+
toolArgs?: Record<string, unknown>;
|
|
829
983
|
search_queries?: string[];
|
|
830
984
|
searchQueries?: string[];
|
|
831
985
|
context_types?: string[];
|
|
@@ -980,10 +1134,16 @@ type ToolDefinition = OpenAiToolDefinition | AnthropicToolDefinition;
|
|
|
980
1134
|
*/
|
|
981
1135
|
|
|
982
1136
|
interface SynapClientOptions {
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
1137
|
+
/**
|
|
1138
|
+
* The four identity fields are `| undefined` rather than plain optional so a
|
|
1139
|
+
* consumer with `exactOptionalPropertyTypes` can pass `process.env.X`
|
|
1140
|
+
* directly, which is what every example does. Undefined already means "fall
|
|
1141
|
+
* back to the environment" at runtime; this makes the type say so.
|
|
1142
|
+
*/
|
|
1143
|
+
apiKey?: string | undefined;
|
|
1144
|
+
clientId?: string | undefined;
|
|
1145
|
+
instanceId?: string | undefined;
|
|
1146
|
+
baseUrl?: string | undefined;
|
|
987
1147
|
timeouts?: HttpTransportOptions['timeouts'];
|
|
988
1148
|
retryPolicy?: HttpTransportOptions['retryPolicy'];
|
|
989
1149
|
keepAlive?: HttpTransportOptions['keepAlive'];
|
|
@@ -1289,9 +1449,15 @@ declare class InsufficientCreditsError extends SynapPermanentError {
|
|
|
1289
1449
|
static readonly errorCode: SynapErrorCode;
|
|
1290
1450
|
readonly balanceCredits: number | null;
|
|
1291
1451
|
readonly requiredCredits: number | null;
|
|
1452
|
+
/** Where the balance can be viewed. Python calls this `recovery_url`. */
|
|
1453
|
+
readonly recoveryUrl: string | null;
|
|
1454
|
+
/** Where a redeem code can be entered. Python calls this `redeem_url`. */
|
|
1455
|
+
readonly redeemUrl: string | null;
|
|
1292
1456
|
constructor(message: string, options?: SynapErrorOptions & {
|
|
1293
1457
|
balanceCredits?: number | null;
|
|
1294
1458
|
requiredCredits?: number | null;
|
|
1459
|
+
recoveryUrl?: string | null;
|
|
1460
|
+
redeemUrl?: string | null;
|
|
1295
1461
|
});
|
|
1296
1462
|
}
|
|
1297
1463
|
declare class InvalidInputError extends SynapPermanentError {
|
|
@@ -1488,4 +1654,4 @@ interface SynapSdkLike {
|
|
|
1488
1654
|
};
|
|
1489
1655
|
}
|
|
1490
1656
|
|
|
1491
|
-
export { AgentUnavailableError, type AnthropicToolDefinition, AnticipationCacheSnapshot, type AsToolOptions, AuthenticationError, BM25, CONTRACT, type CacheNamespace, type CacheStats, type CompactOptions, type CompactionCallback, type ConfigureOptions, ConflictError, ConnectionError, type ContextMetadata, ContextNotFoundError, type ConversationContext, type ConversationNamespace, type CreateFromFileOptions, type CreateMemoryOptions, type CreateMemoryResult, type Credentials, type CreditsNamespace, DEFAULT_BASE_URL, DEFAULT_DOCUMENT_TYPE, DEFAULT_INGEST_MODE, DEFAULT_RETRY_POLICY, DEFAULT_TIMEOUTS, DOCUMENT_TYPES, type DocumentType, ENDPOINTS, type Emotion, type EndpointName, type EndpointSpec, type Episode, type EstimateOptions, type Fact, type FetchOptions, type FlatMemory, type FormatOptions, HttpTransport, type HttpTransportOptions, INGEST_MODES, ITEM_COLLECTIONS, type IngestMode, type IngestTranscriptOptions, type InstanceNamespace, InsufficientCreditsError, InvalidConversationIdError, InvalidInputError, InvalidInstanceIdError, type ItemCollection, type Json, type ListenOptions, ListeningAlreadyActiveError, ListeningNotActiveError, type MemoriesInterface, NetworkTimeoutError, type NormalisedContext, type OpenAiToolDefinition, PermanentError, type Preference, RateLimitError, type RawContext, type RawContextItem, type RawConversationContext, type RecordMessageOptions, type RecordThinkingOptions, type RequestOptions, type RetryPolicy, SDKError, SDK_VERSION, type Scope, type SendMessageOptions, ServiceUnavailableError, SessionExpiredError, SynapClient, type SynapClientOptions, SynapError, type SynapErrorCode, type SynapErrorOptions, SynapPermanentError, type SynapSdkLike, SynapTransientError, THRESHOLDS, type TemporalEvent, type TemporalFields, type TimeoutConfig, type ToolDefinition, type ToolHandler, type ToolScope, type ToolStyle, TranscriptConflictError, type TranscriptTurn, TransientError, type UnifiedContext, type UnifiedFetchOptions, type UpdateMemoryOptions, type UserNamespace, type WaitOptions, type WriteInvalidator, flattenContextItems, formatForPrompt, isOutcomeUnknown, isRecallQuery, isSynapError, mergeScopeResults, resolvePath, shouldRetry, stem, tokenize };
|
|
1657
|
+
export { AgentUnavailableError, type AnthropicToolDefinition, AnticipationCacheSnapshot, type AsToolOptions, AuthenticationError, BM25, type BatchCreateResult, COMPACTION_LEVELS, CONTRACT, type CacheNamespace, type CacheStats, type CompactOptions, type CompactionCallback, type CompactionLevel, type ConfigureOptions, ConflictError, ConnectionError, type ContextMetadata, ContextNotFoundError, type ConversationContext, type ConversationNamespace, type CreateFromFileOptions, type CreateMemoryOptions, type CreateMemoryResult, type Credentials, type CreditBalance, type CreditBucket, type CreditEstimate, type CreditLedgerEntry, type CreditLedgerPage, type CreditsNamespace, DEFAULT_BASE_URL, DEFAULT_DOCUMENT_TYPE, DEFAULT_INGEST_MODE, DEFAULT_RETRY_POLICY, DEFAULT_TIMEOUTS, DOCUMENT_TYPES, type DocumentType, ENDPOINTS, type Emotion, type EndpointName, type EndpointSpec, type Episode, type EstimateOptions, type Fact, type FetchOptions, type FlatMemory, type FormatOptions, HttpTransport, type HttpTransportOptions, INGEST_MODES, ITEM_COLLECTIONS, type IngestMode, type IngestTranscriptOptions, type InstanceNamespace, InsufficientCreditsError, InvalidConversationIdError, InvalidInputError, InvalidInstanceIdError, type ItemCollection, type Json, type LedgerOptions, type ListenOptions, ListeningAlreadyActiveError, ListeningNotActiveError, type MemoriesInterface, NetworkTimeoutError, type NormalisedContext, type OpenAiToolDefinition, PermanentError, type Preference, RateLimitError, type RawContext, type RawContextItem, type RawConversationContext, type RecordMessageOptions, type RecordThinkingOptions, type RedeemResult, type RequestOptions, type RetryPolicy, SDKError, SDK_VERSION, type Scope, type SendMessageOptions, ServiceUnavailableError, SessionExpiredError, SynapClient, type SynapClientOptions, SynapError, type SynapErrorCode, type SynapErrorOptions, SynapPermanentError, type SynapSdkLike, SynapTransientError, THRESHOLDS, type TemporalEvent, type TemporalFields, type TimeoutConfig, type ToolDefinition, type ToolHandler, type ToolScope, type ToolStyle, TranscriptConflictError, type TranscriptIngestResult, type TranscriptTurn, TransientError, type UnifiedContext, type UnifiedFetchOptions, type UpdateMemoryOptions, type UserNamespace, type WaitOptions, type WriteInvalidator, flattenContextItems, formatForPrompt, isOutcomeUnknown, isRecallQuery, isSynapError, mergeScopeResults, resolvePath, shouldRetry, stem, tokenize };
|
package/dist/index.d.ts
CHANGED
|
@@ -245,7 +245,8 @@ interface HttpTransportOptions {
|
|
|
245
245
|
credentials: Credentials;
|
|
246
246
|
baseUrl?: string;
|
|
247
247
|
timeouts?: Partial<TimeoutConfig>;
|
|
248
|
-
|
|
248
|
+
/** `null` disables retries entirely, as Python's `retry_policy=None` does. */
|
|
249
|
+
retryPolicy?: Partial<RetryPolicy> | null;
|
|
249
250
|
keepAlive?: KeepAliveOptions & {
|
|
250
251
|
heartbeatIntervalMs?: number;
|
|
251
252
|
};
|
|
@@ -299,8 +300,27 @@ declare class HttpTransport {
|
|
|
299
300
|
currentCredentials(): Credentials;
|
|
300
301
|
/** Write back identity resolved from `GET /api/v1/auth/whoami`. */
|
|
301
302
|
updateCredentials(patch: Partial<Credentials>): void;
|
|
303
|
+
/**
|
|
304
|
+
* The instance's scoping mode, from whoami. Lives here rather than on the
|
|
305
|
+
* client because every interface factory already receives the transport,
|
|
306
|
+
* and it is per-client, so a module-level global would be wrong the moment a
|
|
307
|
+
* process holds two clients.
|
|
308
|
+
*
|
|
309
|
+
* undefined means the server did not report it, which is true of any
|
|
310
|
+
* deployment older than the field, and must mean "enforce nothing".
|
|
311
|
+
*/
|
|
312
|
+
userContextIsolation: string | undefined;
|
|
313
|
+
/** Refuse a customer_id on a B2C instance, at the call site. */
|
|
314
|
+
checkCustomerId(customerId: unknown, where: string): void;
|
|
302
315
|
setTimeouts(timeouts: Partial<TimeoutConfig>): void;
|
|
303
|
-
/**
|
|
316
|
+
/**
|
|
317
|
+
* `null` DISABLES retries, matching Python.
|
|
318
|
+
*
|
|
319
|
+
* Python's `SDKConfig(retry_policy=None)` leaves `self.retry_policy` unset and
|
|
320
|
+
* `max_attempts` falls to 1 (http_client.py:180). We restored the default
|
|
321
|
+
* policy instead, so a caller following the "Disabling Retries" documentation
|
|
322
|
+
* got three attempts and no way to turn them off.
|
|
323
|
+
*/
|
|
304
324
|
setRetryPolicy(policy: Partial<RetryPolicy> | null): void;
|
|
305
325
|
close(): void;
|
|
306
326
|
request<T = unknown>(name: EndpointName, options?: RequestOptions): Promise<T>;
|
|
@@ -477,6 +497,23 @@ interface FetchOptions {
|
|
|
477
497
|
precisionLevel?: string;
|
|
478
498
|
/** Sent only when explicitly false, matching the Python controllers. */
|
|
479
499
|
include_conversation_context?: boolean;
|
|
500
|
+
/**
|
|
501
|
+
* `"in-conversation"` (default) or `"conversation-summary"`.
|
|
502
|
+
*
|
|
503
|
+
* Summary mode returns a caller profile plus previous-conversation
|
|
504
|
+
* summaries. USER SCOPE ONLY: the other three routes reject it with 422.
|
|
505
|
+
*/
|
|
506
|
+
context_mode?: string;
|
|
507
|
+
contextMode?: string;
|
|
508
|
+
/** Summary mode only. Include the caller profile. */
|
|
509
|
+
include_profile?: boolean;
|
|
510
|
+
includeProfile?: boolean;
|
|
511
|
+
/** Summary mode only. Previous conversations to summarise, 0 to 20. */
|
|
512
|
+
last_n_conversations?: number;
|
|
513
|
+
lastNConversations?: number;
|
|
514
|
+
/** Explicit scope ladder. Sent as `scope` when supplied. */
|
|
515
|
+
scope_path?: Record<string, string>;
|
|
516
|
+
scopePath?: Record<string, string>;
|
|
480
517
|
}
|
|
481
518
|
|
|
482
519
|
/**
|
|
@@ -555,12 +592,37 @@ interface CreateMemoryOptions {
|
|
|
555
592
|
mode?: IngestMode | string;
|
|
556
593
|
metadata?: Json;
|
|
557
594
|
}
|
|
595
|
+
/**
|
|
596
|
+
* Mirrors Python's `CreateMemoryResponse`.
|
|
597
|
+
*
|
|
598
|
+
* The first four fields are required there (Pydantic would raise if the server
|
|
599
|
+
* omitted one), so they are required here too. Declaring `ingestion_id` optional
|
|
600
|
+
* made the commonest two-line pattern in the docs fail to compile under strict
|
|
601
|
+
* TypeScript: `wait_for_completion(result.ingestion_id)` cannot take
|
|
602
|
+
* `string | undefined`.
|
|
603
|
+
*/
|
|
558
604
|
interface CreateMemoryResult {
|
|
559
|
-
ingestion_id
|
|
560
|
-
|
|
605
|
+
ingestion_id: string;
|
|
606
|
+
document_id: string;
|
|
607
|
+
status: string;
|
|
608
|
+
/** ISO-8601. Python types this as a datetime. */
|
|
609
|
+
queued_at: string;
|
|
610
|
+
error_message?: string | null;
|
|
561
611
|
memories_created?: number;
|
|
562
612
|
[key: string]: unknown;
|
|
563
613
|
}
|
|
614
|
+
/**
|
|
615
|
+
* Result of `memories.batch_create`, mirroring Python's `BatchCreateResponse`.
|
|
616
|
+
* It was `Json`, so `results` came back as `unknown` and could not be iterated.
|
|
617
|
+
*/
|
|
618
|
+
interface BatchCreateResult {
|
|
619
|
+
batch_id: string;
|
|
620
|
+
total: number;
|
|
621
|
+
succeeded: number;
|
|
622
|
+
failed: number;
|
|
623
|
+
results: CreateMemoryResult[];
|
|
624
|
+
[key: string]: unknown;
|
|
625
|
+
}
|
|
564
626
|
interface BatchCreateOptions {
|
|
565
627
|
documents: CreateMemoryOptions[];
|
|
566
628
|
fail_fast?: boolean;
|
|
@@ -568,7 +630,7 @@ interface BatchCreateOptions {
|
|
|
568
630
|
}
|
|
569
631
|
interface MemoriesInterface {
|
|
570
632
|
create(options: CreateMemoryOptions): Promise<CreateMemoryResult>;
|
|
571
|
-
batch_create(options: BatchCreateOptions): Promise<
|
|
633
|
+
batch_create(options: BatchCreateOptions): Promise<BatchCreateResult>;
|
|
572
634
|
create_from_file(options: CreateFromFileOptions): Promise<CreateMemoryResult>;
|
|
573
635
|
get(memoryId: string): Promise<Json>;
|
|
574
636
|
update(options: UpdateMemoryOptions): Promise<Json>;
|
|
@@ -664,20 +726,45 @@ interface IngestTranscriptOptions {
|
|
|
664
726
|
ended_at?: string | Date;
|
|
665
727
|
endedAt?: string | Date;
|
|
666
728
|
}
|
|
729
|
+
/**
|
|
730
|
+
* Compaction levels, mirroring Python's `CompactionLevel` enum. The JS SDK
|
|
731
|
+
* exported no equivalent, so `compaction_level` was an untyped `string` and a
|
|
732
|
+
* typo reached the server instead of the compiler.
|
|
733
|
+
*/
|
|
734
|
+
declare const COMPACTION_LEVELS: readonly ["low", "medium", "high", "adaptive", "aggressive", "balanced", "conservative"];
|
|
735
|
+
type CompactionLevel = (typeof COMPACTION_LEVELS)[number];
|
|
667
736
|
interface CompactOptions {
|
|
668
737
|
conversation_id?: string;
|
|
669
738
|
conversationId?: string;
|
|
670
739
|
strategy?: string;
|
|
671
|
-
compaction_level?: string;
|
|
672
|
-
compactionLevel?: string;
|
|
740
|
+
compaction_level?: CompactionLevel | string;
|
|
741
|
+
compactionLevel?: CompactionLevel | string;
|
|
673
742
|
target_tokens?: number;
|
|
674
743
|
targetTokens?: number;
|
|
675
744
|
force?: boolean;
|
|
676
745
|
}
|
|
746
|
+
/**
|
|
747
|
+
* Result of `conversation.ingest_transcript`, mirroring Python's
|
|
748
|
+
* `TranscriptIngestResponse`. It was `Json` here, so `ingestion_id` came back
|
|
749
|
+
* as `unknown` and could not be handed to `wait_for_completion` without a cast.
|
|
750
|
+
*/
|
|
751
|
+
interface TranscriptIngestResult {
|
|
752
|
+
conversation_id: string;
|
|
753
|
+
/** The raw client-supplied id, echoed back. */
|
|
754
|
+
external_conversation_id: string;
|
|
755
|
+
/** Always set on a 2xx, including the `duplicate` branch. */
|
|
756
|
+
ingestion_id: string;
|
|
757
|
+
status: 'queued' | 'duplicate';
|
|
758
|
+
turns_recorded: number;
|
|
759
|
+
summary_status: 'in_progress' | 'already_compacted' | 'skipped';
|
|
760
|
+
/** ISO-8601. */
|
|
761
|
+
queued_at: string;
|
|
762
|
+
[key: string]: unknown;
|
|
763
|
+
}
|
|
677
764
|
interface ConversationNamespace {
|
|
678
765
|
record_message(options: RecordMessageOptions): Promise<Json>;
|
|
679
766
|
record_messages_batch(messages: RecordMessageOptions[]): Promise<Json>;
|
|
680
|
-
ingest_transcript(options: IngestTranscriptOptions): Promise<
|
|
767
|
+
ingest_transcript(options: IngestTranscriptOptions): Promise<TranscriptIngestResult>;
|
|
681
768
|
context: {
|
|
682
769
|
fetch(options?: FetchOptions): Promise<RawContext>;
|
|
683
770
|
get_context_for_prompt(options?: {
|
|
@@ -750,13 +837,71 @@ interface EstimateOptions {
|
|
|
750
837
|
mode?: string;
|
|
751
838
|
}
|
|
752
839
|
interface CreditsNamespace {
|
|
753
|
-
get_balance(): Promise<
|
|
754
|
-
get_ledger(options?:
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
840
|
+
get_balance(): Promise<CreditBalance>;
|
|
841
|
+
get_ledger(options?: LedgerOptions): Promise<CreditLedgerPage>;
|
|
842
|
+
estimate(options: EstimateOptions): Promise<CreditEstimate>;
|
|
843
|
+
redeem(code: string): Promise<RedeemResult>;
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* Return types for the credits namespace, mirroring Python's dataclasses in
|
|
847
|
+
* `maximem_synap/credits.py`. These were all `Json` (`Record<string, unknown>`)
|
|
848
|
+
* before, so every field read was `unknown` and no documented example compiled.
|
|
849
|
+
*/
|
|
850
|
+
interface CreditBucket {
|
|
851
|
+
source_type: string;
|
|
852
|
+
balance: number;
|
|
853
|
+
/** ISO-8601, or null when the bucket does not expire. */
|
|
854
|
+
expires_at: string | null;
|
|
855
|
+
}
|
|
856
|
+
interface CreditBalance {
|
|
857
|
+
client_id: string;
|
|
858
|
+
balance_credits: number;
|
|
859
|
+
warning_low: boolean;
|
|
860
|
+
buckets: CreditBucket[];
|
|
861
|
+
[key: string]: unknown;
|
|
862
|
+
}
|
|
863
|
+
interface CreditLedgerEntry {
|
|
864
|
+
ledger_id: string;
|
|
865
|
+
entry_type: string;
|
|
866
|
+
delta: number;
|
|
867
|
+
metric_type: string | null;
|
|
868
|
+
category: string | null;
|
|
869
|
+
/** ISO-8601. */
|
|
870
|
+
created_at: string;
|
|
871
|
+
}
|
|
872
|
+
interface CreditLedgerPage {
|
|
873
|
+
entries: CreditLedgerEntry[];
|
|
874
|
+
total: number;
|
|
875
|
+
limit: number;
|
|
876
|
+
offset: number;
|
|
877
|
+
[key: string]: unknown;
|
|
878
|
+
}
|
|
879
|
+
interface CreditEstimate {
|
|
880
|
+
credits_estimate: number;
|
|
881
|
+
[key: string]: unknown;
|
|
882
|
+
}
|
|
883
|
+
interface RedeemResult {
|
|
884
|
+
redemption_id: string;
|
|
885
|
+
credits_granted: number;
|
|
886
|
+
new_balance_credits: number;
|
|
887
|
+
/** ISO-8601, or null when the granted credits do not expire. */
|
|
888
|
+
expires_at: string | null;
|
|
889
|
+
[key: string]: unknown;
|
|
890
|
+
}
|
|
891
|
+
/** Options for `credits.get_ledger`. Mirrors Python's keyword arguments. */
|
|
892
|
+
interface LedgerOptions {
|
|
893
|
+
/** Filter to one ledger entry type. */
|
|
894
|
+
entry_type?: string;
|
|
895
|
+
entryType?: string;
|
|
896
|
+
/** Inclusive lower bound. ISO-8601 string or Date. Sent as `from`. */
|
|
897
|
+
from_time?: string | Date;
|
|
898
|
+
fromTime?: string | Date;
|
|
899
|
+
/** Inclusive upper bound. ISO-8601 string or Date. Sent as `to`. */
|
|
900
|
+
to_time?: string | Date;
|
|
901
|
+
toTime?: string | Date;
|
|
902
|
+
/** Defaults to 100, as in Python. */
|
|
903
|
+
limit?: number;
|
|
904
|
+
offset?: number;
|
|
760
905
|
}
|
|
761
906
|
|
|
762
907
|
/**
|
|
@@ -826,6 +971,15 @@ interface SendMessageOptions {
|
|
|
826
971
|
event_type?: string;
|
|
827
972
|
eventType?: string;
|
|
828
973
|
metadata?: Record<string, string>;
|
|
974
|
+
/**
|
|
975
|
+
* Report a tool call on the stream. Python's `send_message` takes both, and
|
|
976
|
+
* the proto has `tool_name` / `tool_args_json`; the JS surface simply never
|
|
977
|
+
* exposed them, so a tool call could not be reported from JavaScript.
|
|
978
|
+
*/
|
|
979
|
+
tool_name?: string;
|
|
980
|
+
toolName?: string;
|
|
981
|
+
tool_args?: Record<string, unknown>;
|
|
982
|
+
toolArgs?: Record<string, unknown>;
|
|
829
983
|
search_queries?: string[];
|
|
830
984
|
searchQueries?: string[];
|
|
831
985
|
context_types?: string[];
|
|
@@ -980,10 +1134,16 @@ type ToolDefinition = OpenAiToolDefinition | AnthropicToolDefinition;
|
|
|
980
1134
|
*/
|
|
981
1135
|
|
|
982
1136
|
interface SynapClientOptions {
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
1137
|
+
/**
|
|
1138
|
+
* The four identity fields are `| undefined` rather than plain optional so a
|
|
1139
|
+
* consumer with `exactOptionalPropertyTypes` can pass `process.env.X`
|
|
1140
|
+
* directly, which is what every example does. Undefined already means "fall
|
|
1141
|
+
* back to the environment" at runtime; this makes the type say so.
|
|
1142
|
+
*/
|
|
1143
|
+
apiKey?: string | undefined;
|
|
1144
|
+
clientId?: string | undefined;
|
|
1145
|
+
instanceId?: string | undefined;
|
|
1146
|
+
baseUrl?: string | undefined;
|
|
987
1147
|
timeouts?: HttpTransportOptions['timeouts'];
|
|
988
1148
|
retryPolicy?: HttpTransportOptions['retryPolicy'];
|
|
989
1149
|
keepAlive?: HttpTransportOptions['keepAlive'];
|
|
@@ -1289,9 +1449,15 @@ declare class InsufficientCreditsError extends SynapPermanentError {
|
|
|
1289
1449
|
static readonly errorCode: SynapErrorCode;
|
|
1290
1450
|
readonly balanceCredits: number | null;
|
|
1291
1451
|
readonly requiredCredits: number | null;
|
|
1452
|
+
/** Where the balance can be viewed. Python calls this `recovery_url`. */
|
|
1453
|
+
readonly recoveryUrl: string | null;
|
|
1454
|
+
/** Where a redeem code can be entered. Python calls this `redeem_url`. */
|
|
1455
|
+
readonly redeemUrl: string | null;
|
|
1292
1456
|
constructor(message: string, options?: SynapErrorOptions & {
|
|
1293
1457
|
balanceCredits?: number | null;
|
|
1294
1458
|
requiredCredits?: number | null;
|
|
1459
|
+
recoveryUrl?: string | null;
|
|
1460
|
+
redeemUrl?: string | null;
|
|
1295
1461
|
});
|
|
1296
1462
|
}
|
|
1297
1463
|
declare class InvalidInputError extends SynapPermanentError {
|
|
@@ -1488,4 +1654,4 @@ interface SynapSdkLike {
|
|
|
1488
1654
|
};
|
|
1489
1655
|
}
|
|
1490
1656
|
|
|
1491
|
-
export { AgentUnavailableError, type AnthropicToolDefinition, AnticipationCacheSnapshot, type AsToolOptions, AuthenticationError, BM25, CONTRACT, type CacheNamespace, type CacheStats, type CompactOptions, type CompactionCallback, type ConfigureOptions, ConflictError, ConnectionError, type ContextMetadata, ContextNotFoundError, type ConversationContext, type ConversationNamespace, type CreateFromFileOptions, type CreateMemoryOptions, type CreateMemoryResult, type Credentials, type CreditsNamespace, DEFAULT_BASE_URL, DEFAULT_DOCUMENT_TYPE, DEFAULT_INGEST_MODE, DEFAULT_RETRY_POLICY, DEFAULT_TIMEOUTS, DOCUMENT_TYPES, type DocumentType, ENDPOINTS, type Emotion, type EndpointName, type EndpointSpec, type Episode, type EstimateOptions, type Fact, type FetchOptions, type FlatMemory, type FormatOptions, HttpTransport, type HttpTransportOptions, INGEST_MODES, ITEM_COLLECTIONS, type IngestMode, type IngestTranscriptOptions, type InstanceNamespace, InsufficientCreditsError, InvalidConversationIdError, InvalidInputError, InvalidInstanceIdError, type ItemCollection, type Json, type ListenOptions, ListeningAlreadyActiveError, ListeningNotActiveError, type MemoriesInterface, NetworkTimeoutError, type NormalisedContext, type OpenAiToolDefinition, PermanentError, type Preference, RateLimitError, type RawContext, type RawContextItem, type RawConversationContext, type RecordMessageOptions, type RecordThinkingOptions, type RequestOptions, type RetryPolicy, SDKError, SDK_VERSION, type Scope, type SendMessageOptions, ServiceUnavailableError, SessionExpiredError, SynapClient, type SynapClientOptions, SynapError, type SynapErrorCode, type SynapErrorOptions, SynapPermanentError, type SynapSdkLike, SynapTransientError, THRESHOLDS, type TemporalEvent, type TemporalFields, type TimeoutConfig, type ToolDefinition, type ToolHandler, type ToolScope, type ToolStyle, TranscriptConflictError, type TranscriptTurn, TransientError, type UnifiedContext, type UnifiedFetchOptions, type UpdateMemoryOptions, type UserNamespace, type WaitOptions, type WriteInvalidator, flattenContextItems, formatForPrompt, isOutcomeUnknown, isRecallQuery, isSynapError, mergeScopeResults, resolvePath, shouldRetry, stem, tokenize };
|
|
1657
|
+
export { AgentUnavailableError, type AnthropicToolDefinition, AnticipationCacheSnapshot, type AsToolOptions, AuthenticationError, BM25, type BatchCreateResult, COMPACTION_LEVELS, CONTRACT, type CacheNamespace, type CacheStats, type CompactOptions, type CompactionCallback, type CompactionLevel, type ConfigureOptions, ConflictError, ConnectionError, type ContextMetadata, ContextNotFoundError, type ConversationContext, type ConversationNamespace, type CreateFromFileOptions, type CreateMemoryOptions, type CreateMemoryResult, type Credentials, type CreditBalance, type CreditBucket, type CreditEstimate, type CreditLedgerEntry, type CreditLedgerPage, type CreditsNamespace, DEFAULT_BASE_URL, DEFAULT_DOCUMENT_TYPE, DEFAULT_INGEST_MODE, DEFAULT_RETRY_POLICY, DEFAULT_TIMEOUTS, DOCUMENT_TYPES, type DocumentType, ENDPOINTS, type Emotion, type EndpointName, type EndpointSpec, type Episode, type EstimateOptions, type Fact, type FetchOptions, type FlatMemory, type FormatOptions, HttpTransport, type HttpTransportOptions, INGEST_MODES, ITEM_COLLECTIONS, type IngestMode, type IngestTranscriptOptions, type InstanceNamespace, InsufficientCreditsError, InvalidConversationIdError, InvalidInputError, InvalidInstanceIdError, type ItemCollection, type Json, type LedgerOptions, type ListenOptions, ListeningAlreadyActiveError, ListeningNotActiveError, type MemoriesInterface, NetworkTimeoutError, type NormalisedContext, type OpenAiToolDefinition, PermanentError, type Preference, RateLimitError, type RawContext, type RawContextItem, type RawConversationContext, type RecordMessageOptions, type RecordThinkingOptions, type RedeemResult, type RequestOptions, type RetryPolicy, SDKError, SDK_VERSION, type Scope, type SendMessageOptions, ServiceUnavailableError, SessionExpiredError, SynapClient, type SynapClientOptions, SynapError, type SynapErrorCode, type SynapErrorOptions, SynapPermanentError, type SynapSdkLike, SynapTransientError, THRESHOLDS, type TemporalEvent, type TemporalFields, type TimeoutConfig, type ToolDefinition, type ToolHandler, type ToolScope, type ToolStyle, TranscriptConflictError, type TranscriptIngestResult, type TranscriptTurn, TransientError, type UnifiedContext, type UnifiedFetchOptions, type UpdateMemoryOptions, type UserNamespace, type WaitOptions, type WriteInvalidator, flattenContextItems, formatForPrompt, isOutcomeUnknown, isRecallQuery, isSynapError, mergeScopeResults, resolvePath, shouldRetry, stem, tokenize };
|