@maximem/synap-js-sdk 0.4.3 → 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/anticipation-cache-ARYEEKMU.cjs.map +1 -1
- 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-3JSE64GW.cjs.map +1 -0
- package/dist/{chunk-T3NZBIV2.js → chunk-OCMM2Z5P.js} +7 -1
- package/dist/chunk-OCMM2Z5P.js.map +1 -0
- package/dist/chunk-RB57I2IQ.cjs.map +1 -1
- package/dist/chunk-ZKOJDUN4.cjs.map +1 -1
- package/dist/{chunk-5SC3ELNK.js → chunk-ZU6ZC4SU.js} +1 -1
- package/dist/chunk-ZU6ZC4SU.js.map +1 -0
- package/dist/env-55ULHNJZ.cjs.map +1 -1
- package/dist/grpc/index.cjs +7 -7
- package/dist/grpc/index.cjs.map +1 -1
- 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 +157 -94
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +174 -20
- package/dist/index.d.ts +174 -20
- package/dist/index.js +77 -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/chunk-VXRCBMCY.cjs.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
|
};
|
|
@@ -312,7 +313,14 @@ declare class HttpTransport {
|
|
|
312
313
|
/** Refuse a customer_id on a B2C instance, at the call site. */
|
|
313
314
|
checkCustomerId(customerId: unknown, where: string): void;
|
|
314
315
|
setTimeouts(timeouts: Partial<TimeoutConfig>): void;
|
|
315
|
-
/**
|
|
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
|
+
*/
|
|
316
324
|
setRetryPolicy(policy: Partial<RetryPolicy> | null): void;
|
|
317
325
|
close(): void;
|
|
318
326
|
request<T = unknown>(name: EndpointName, options?: RequestOptions): Promise<T>;
|
|
@@ -489,6 +497,23 @@ interface FetchOptions {
|
|
|
489
497
|
precisionLevel?: string;
|
|
490
498
|
/** Sent only when explicitly false, matching the Python controllers. */
|
|
491
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>;
|
|
492
517
|
}
|
|
493
518
|
|
|
494
519
|
/**
|
|
@@ -567,12 +592,37 @@ interface CreateMemoryOptions {
|
|
|
567
592
|
mode?: IngestMode | string;
|
|
568
593
|
metadata?: Json;
|
|
569
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
|
+
*/
|
|
570
604
|
interface CreateMemoryResult {
|
|
571
|
-
ingestion_id
|
|
572
|
-
|
|
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;
|
|
573
611
|
memories_created?: number;
|
|
574
612
|
[key: string]: unknown;
|
|
575
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
|
+
}
|
|
576
626
|
interface BatchCreateOptions {
|
|
577
627
|
documents: CreateMemoryOptions[];
|
|
578
628
|
fail_fast?: boolean;
|
|
@@ -580,7 +630,7 @@ interface BatchCreateOptions {
|
|
|
580
630
|
}
|
|
581
631
|
interface MemoriesInterface {
|
|
582
632
|
create(options: CreateMemoryOptions): Promise<CreateMemoryResult>;
|
|
583
|
-
batch_create(options: BatchCreateOptions): Promise<
|
|
633
|
+
batch_create(options: BatchCreateOptions): Promise<BatchCreateResult>;
|
|
584
634
|
create_from_file(options: CreateFromFileOptions): Promise<CreateMemoryResult>;
|
|
585
635
|
get(memoryId: string): Promise<Json>;
|
|
586
636
|
update(options: UpdateMemoryOptions): Promise<Json>;
|
|
@@ -676,20 +726,45 @@ interface IngestTranscriptOptions {
|
|
|
676
726
|
ended_at?: string | Date;
|
|
677
727
|
endedAt?: string | Date;
|
|
678
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];
|
|
679
736
|
interface CompactOptions {
|
|
680
737
|
conversation_id?: string;
|
|
681
738
|
conversationId?: string;
|
|
682
739
|
strategy?: string;
|
|
683
|
-
compaction_level?: string;
|
|
684
|
-
compactionLevel?: string;
|
|
740
|
+
compaction_level?: CompactionLevel | string;
|
|
741
|
+
compactionLevel?: CompactionLevel | string;
|
|
685
742
|
target_tokens?: number;
|
|
686
743
|
targetTokens?: number;
|
|
687
744
|
force?: boolean;
|
|
688
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
|
+
}
|
|
689
764
|
interface ConversationNamespace {
|
|
690
765
|
record_message(options: RecordMessageOptions): Promise<Json>;
|
|
691
766
|
record_messages_batch(messages: RecordMessageOptions[]): Promise<Json>;
|
|
692
|
-
ingest_transcript(options: IngestTranscriptOptions): Promise<
|
|
767
|
+
ingest_transcript(options: IngestTranscriptOptions): Promise<TranscriptIngestResult>;
|
|
693
768
|
context: {
|
|
694
769
|
fetch(options?: FetchOptions): Promise<RawContext>;
|
|
695
770
|
get_context_for_prompt(options?: {
|
|
@@ -762,13 +837,71 @@ interface EstimateOptions {
|
|
|
762
837
|
mode?: string;
|
|
763
838
|
}
|
|
764
839
|
interface CreditsNamespace {
|
|
765
|
-
get_balance(): Promise<
|
|
766
|
-
get_ledger(options?:
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
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;
|
|
772
905
|
}
|
|
773
906
|
|
|
774
907
|
/**
|
|
@@ -838,6 +971,15 @@ interface SendMessageOptions {
|
|
|
838
971
|
event_type?: string;
|
|
839
972
|
eventType?: string;
|
|
840
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>;
|
|
841
983
|
search_queries?: string[];
|
|
842
984
|
searchQueries?: string[];
|
|
843
985
|
context_types?: string[];
|
|
@@ -992,10 +1134,16 @@ type ToolDefinition = OpenAiToolDefinition | AnthropicToolDefinition;
|
|
|
992
1134
|
*/
|
|
993
1135
|
|
|
994
1136
|
interface SynapClientOptions {
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
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;
|
|
999
1147
|
timeouts?: HttpTransportOptions['timeouts'];
|
|
1000
1148
|
retryPolicy?: HttpTransportOptions['retryPolicy'];
|
|
1001
1149
|
keepAlive?: HttpTransportOptions['keepAlive'];
|
|
@@ -1301,9 +1449,15 @@ declare class InsufficientCreditsError extends SynapPermanentError {
|
|
|
1301
1449
|
static readonly errorCode: SynapErrorCode;
|
|
1302
1450
|
readonly balanceCredits: number | null;
|
|
1303
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;
|
|
1304
1456
|
constructor(message: string, options?: SynapErrorOptions & {
|
|
1305
1457
|
balanceCredits?: number | null;
|
|
1306
1458
|
requiredCredits?: number | null;
|
|
1459
|
+
recoveryUrl?: string | null;
|
|
1460
|
+
redeemUrl?: string | null;
|
|
1307
1461
|
});
|
|
1308
1462
|
}
|
|
1309
1463
|
declare class InvalidInputError extends SynapPermanentError {
|
|
@@ -1500,4 +1654,4 @@ interface SynapSdkLike {
|
|
|
1500
1654
|
};
|
|
1501
1655
|
}
|
|
1502
1656
|
|
|
1503
|
-
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
|
};
|
|
@@ -312,7 +313,14 @@ declare class HttpTransport {
|
|
|
312
313
|
/** Refuse a customer_id on a B2C instance, at the call site. */
|
|
313
314
|
checkCustomerId(customerId: unknown, where: string): void;
|
|
314
315
|
setTimeouts(timeouts: Partial<TimeoutConfig>): void;
|
|
315
|
-
/**
|
|
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
|
+
*/
|
|
316
324
|
setRetryPolicy(policy: Partial<RetryPolicy> | null): void;
|
|
317
325
|
close(): void;
|
|
318
326
|
request<T = unknown>(name: EndpointName, options?: RequestOptions): Promise<T>;
|
|
@@ -489,6 +497,23 @@ interface FetchOptions {
|
|
|
489
497
|
precisionLevel?: string;
|
|
490
498
|
/** Sent only when explicitly false, matching the Python controllers. */
|
|
491
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>;
|
|
492
517
|
}
|
|
493
518
|
|
|
494
519
|
/**
|
|
@@ -567,12 +592,37 @@ interface CreateMemoryOptions {
|
|
|
567
592
|
mode?: IngestMode | string;
|
|
568
593
|
metadata?: Json;
|
|
569
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
|
+
*/
|
|
570
604
|
interface CreateMemoryResult {
|
|
571
|
-
ingestion_id
|
|
572
|
-
|
|
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;
|
|
573
611
|
memories_created?: number;
|
|
574
612
|
[key: string]: unknown;
|
|
575
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
|
+
}
|
|
576
626
|
interface BatchCreateOptions {
|
|
577
627
|
documents: CreateMemoryOptions[];
|
|
578
628
|
fail_fast?: boolean;
|
|
@@ -580,7 +630,7 @@ interface BatchCreateOptions {
|
|
|
580
630
|
}
|
|
581
631
|
interface MemoriesInterface {
|
|
582
632
|
create(options: CreateMemoryOptions): Promise<CreateMemoryResult>;
|
|
583
|
-
batch_create(options: BatchCreateOptions): Promise<
|
|
633
|
+
batch_create(options: BatchCreateOptions): Promise<BatchCreateResult>;
|
|
584
634
|
create_from_file(options: CreateFromFileOptions): Promise<CreateMemoryResult>;
|
|
585
635
|
get(memoryId: string): Promise<Json>;
|
|
586
636
|
update(options: UpdateMemoryOptions): Promise<Json>;
|
|
@@ -676,20 +726,45 @@ interface IngestTranscriptOptions {
|
|
|
676
726
|
ended_at?: string | Date;
|
|
677
727
|
endedAt?: string | Date;
|
|
678
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];
|
|
679
736
|
interface CompactOptions {
|
|
680
737
|
conversation_id?: string;
|
|
681
738
|
conversationId?: string;
|
|
682
739
|
strategy?: string;
|
|
683
|
-
compaction_level?: string;
|
|
684
|
-
compactionLevel?: string;
|
|
740
|
+
compaction_level?: CompactionLevel | string;
|
|
741
|
+
compactionLevel?: CompactionLevel | string;
|
|
685
742
|
target_tokens?: number;
|
|
686
743
|
targetTokens?: number;
|
|
687
744
|
force?: boolean;
|
|
688
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
|
+
}
|
|
689
764
|
interface ConversationNamespace {
|
|
690
765
|
record_message(options: RecordMessageOptions): Promise<Json>;
|
|
691
766
|
record_messages_batch(messages: RecordMessageOptions[]): Promise<Json>;
|
|
692
|
-
ingest_transcript(options: IngestTranscriptOptions): Promise<
|
|
767
|
+
ingest_transcript(options: IngestTranscriptOptions): Promise<TranscriptIngestResult>;
|
|
693
768
|
context: {
|
|
694
769
|
fetch(options?: FetchOptions): Promise<RawContext>;
|
|
695
770
|
get_context_for_prompt(options?: {
|
|
@@ -762,13 +837,71 @@ interface EstimateOptions {
|
|
|
762
837
|
mode?: string;
|
|
763
838
|
}
|
|
764
839
|
interface CreditsNamespace {
|
|
765
|
-
get_balance(): Promise<
|
|
766
|
-
get_ledger(options?:
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
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;
|
|
772
905
|
}
|
|
773
906
|
|
|
774
907
|
/**
|
|
@@ -838,6 +971,15 @@ interface SendMessageOptions {
|
|
|
838
971
|
event_type?: string;
|
|
839
972
|
eventType?: string;
|
|
840
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>;
|
|
841
983
|
search_queries?: string[];
|
|
842
984
|
searchQueries?: string[];
|
|
843
985
|
context_types?: string[];
|
|
@@ -992,10 +1134,16 @@ type ToolDefinition = OpenAiToolDefinition | AnthropicToolDefinition;
|
|
|
992
1134
|
*/
|
|
993
1135
|
|
|
994
1136
|
interface SynapClientOptions {
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
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;
|
|
999
1147
|
timeouts?: HttpTransportOptions['timeouts'];
|
|
1000
1148
|
retryPolicy?: HttpTransportOptions['retryPolicy'];
|
|
1001
1149
|
keepAlive?: HttpTransportOptions['keepAlive'];
|
|
@@ -1301,9 +1449,15 @@ declare class InsufficientCreditsError extends SynapPermanentError {
|
|
|
1301
1449
|
static readonly errorCode: SynapErrorCode;
|
|
1302
1450
|
readonly balanceCredits: number | null;
|
|
1303
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;
|
|
1304
1456
|
constructor(message: string, options?: SynapErrorOptions & {
|
|
1305
1457
|
balanceCredits?: number | null;
|
|
1306
1458
|
requiredCredits?: number | null;
|
|
1459
|
+
recoveryUrl?: string | null;
|
|
1460
|
+
redeemUrl?: string | null;
|
|
1307
1461
|
});
|
|
1308
1462
|
}
|
|
1309
1463
|
declare class InvalidInputError extends SynapPermanentError {
|
|
@@ -1500,4 +1654,4 @@ interface SynapSdkLike {
|
|
|
1500
1654
|
};
|
|
1501
1655
|
}
|
|
1502
1656
|
|
|
1503
|
-
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 };
|