@maximem/synap-js-sdk 0.4.7 → 0.4.8
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-BMVF5sXb.d.cts → anticipation-cache-C1rUEpaW.d.cts} +22 -1
- package/dist/{anticipation-cache-BMVF5sXb.d.ts → anticipation-cache-C1rUEpaW.d.ts} +22 -1
- package/dist/anticipation-cache-LRE3TLK4.cjs +14 -0
- package/dist/anticipation-cache-LRE3TLK4.cjs.map +1 -0
- package/dist/anticipation-cache-WLU4NMD5.js +14 -0
- package/dist/chunk-2TVL5IPQ.cjs.map +1 -1
- package/dist/{chunk-3JSE64GW.cjs → chunk-7CWBRHUO.cjs} +15 -2
- package/dist/chunk-7CWBRHUO.cjs.map +1 -0
- package/dist/{chunk-6LDUDKHS.js → chunk-ODVOQOSO.js} +124 -8
- package/dist/chunk-ODVOQOSO.js.map +1 -0
- package/dist/{chunk-ZU6ZC4SU.js → chunk-T5QQBJ6T.js} +15 -2
- package/dist/chunk-T5QQBJ6T.js.map +1 -0
- package/dist/{chunk-RB57I2IQ.cjs → chunk-T6U5PVAD.cjs} +125 -9
- package/dist/chunk-T6U5PVAD.cjs.map +1 -0
- package/dist/chunk-ZKOJDUN4.cjs.map +1 -1
- package/dist/env-55ULHNJZ.cjs.map +1 -1
- package/dist/grpc/index.cjs +4 -4
- package/dist/grpc/index.cjs.map +1 -1
- package/dist/grpc/index.d.cts +3 -3
- package/dist/grpc/index.d.ts +3 -3
- package/dist/grpc/index.js +3 -3
- package/dist/index.cjs +27 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -4
- package/dist/index.d.ts +11 -4
- package/dist/index.js +25 -14
- package/dist/index.js.map +1 -1
- package/dist/stream-client-2C5KIOWP.js +7 -0
- package/dist/stream-client-GPU37E6F.cjs +7 -0
- package/dist/stream-client-GPU37E6F.cjs.map +1 -0
- package/package.json +6 -1
- package/dist/anticipation-cache-ARYEEKMU.cjs +0 -10
- package/dist/anticipation-cache-ARYEEKMU.cjs.map +0 -1
- package/dist/anticipation-cache-H7HEVWQC.js +0 -10
- package/dist/chunk-3JSE64GW.cjs.map +0 -1
- package/dist/chunk-6LDUDKHS.js.map +0 -1
- package/dist/chunk-RB57I2IQ.cjs.map +0 -1
- package/dist/chunk-ZU6ZC4SU.js.map +0 -1
- package/dist/stream-client-6V4FGKZ3.js +0 -7
- package/dist/stream-client-PRTOH62B.cjs +0 -7
- package/dist/stream-client-PRTOH62B.cjs.map +0 -1
- /package/dist/{anticipation-cache-H7HEVWQC.js.map → anticipation-cache-WLU4NMD5.js.map} +0 -0
- /package/dist/{stream-client-6V4FGKZ3.js.map → stream-client-2C5KIOWP.js.map} +0 -0
|
@@ -40,6 +40,12 @@ interface ContextBundle {
|
|
|
40
40
|
bundleType?: string | null;
|
|
41
41
|
/** The queries the server anticipated. Diagnostics only. */
|
|
42
42
|
searchQueries?: readonly string[] | null;
|
|
43
|
+
/**
|
|
44
|
+
* The scope rung the server retrieved this bundle at, as `rungKey` writes
|
|
45
|
+
* one. Absent from anything an older server sent, which reads as "named no
|
|
46
|
+
* rung" rather than as "matches anything".
|
|
47
|
+
*/
|
|
48
|
+
scopeRung?: string | null;
|
|
43
49
|
}
|
|
44
50
|
interface LookupResult {
|
|
45
51
|
itemsByType: Record<string, BundleItem[]>;
|
|
@@ -53,6 +59,13 @@ interface LookupParams {
|
|
|
53
59
|
customerId?: string | null;
|
|
54
60
|
clientId?: string | null;
|
|
55
61
|
conversationId?: string | null;
|
|
62
|
+
/**
|
|
63
|
+
* The rung this request names, from its `scope_path`. A SECOND, independent
|
|
64
|
+
* dimension and NOT another tier of the entity funnel: the funnel widens and
|
|
65
|
+
* the rung does not, because a rung is a boundary and a boundary that widens
|
|
66
|
+
* is not one.
|
|
67
|
+
*/
|
|
68
|
+
scopeRung?: string | null;
|
|
56
69
|
maxItems?: number;
|
|
57
70
|
}
|
|
58
71
|
type ExitReason = 'empty' | 'recall_bypass' | 'no_query_tokens' | 'novel_term_gate' | 'empty_corpus' | 'no_items_above_threshold' | 'coverage_gate' | 'hit';
|
|
@@ -62,6 +75,7 @@ interface LookupTelemetry {
|
|
|
62
75
|
customerId: string | null;
|
|
63
76
|
clientId: string | null;
|
|
64
77
|
conversationId: string | null;
|
|
78
|
+
scopeRung: string | null;
|
|
65
79
|
scopeFilterAccepted: string[];
|
|
66
80
|
novelTermRatio: number | null;
|
|
67
81
|
bm25Threshold: number | null;
|
|
@@ -156,7 +170,7 @@ declare class AnticipationCache {
|
|
|
156
170
|
* for exactly that reason: the permissive version could splice user A's
|
|
157
171
|
* summary into user B's response on the conversation-scope path.
|
|
158
172
|
*/
|
|
159
|
-
lookupUserSummary(entityId: string | null | undefined): Record<string, unknown> | null;
|
|
173
|
+
lookupUserSummary(entityId: string | null | undefined, scopeRung?: string | null): Record<string, unknown> | null;
|
|
160
174
|
/**
|
|
161
175
|
* Drop every bundle belonging to one conversation.
|
|
162
176
|
*
|
|
@@ -181,6 +195,13 @@ declare class AnticipationCache {
|
|
|
181
195
|
* accidentally match bundles keyed at "".
|
|
182
196
|
*/
|
|
183
197
|
private buildAcceptedScope;
|
|
198
|
+
/**
|
|
199
|
+
* The rung is checked FIRST and it never widens. Everything else here widens
|
|
200
|
+
* deliberately: a user-scope request reaches customer-shared bundles, and a
|
|
201
|
+
* conversation-scope request reaches user-scope ones. A rung is the opposite
|
|
202
|
+
* kind of thing, so it is checked before the tiers and no amount of widening
|
|
203
|
+
* can put a cross-rung bundle back in.
|
|
204
|
+
*/
|
|
184
205
|
private getValidBundleIds;
|
|
185
206
|
private effectiveTtl;
|
|
186
207
|
private evictExpired;
|
|
@@ -40,6 +40,12 @@ interface ContextBundle {
|
|
|
40
40
|
bundleType?: string | null;
|
|
41
41
|
/** The queries the server anticipated. Diagnostics only. */
|
|
42
42
|
searchQueries?: readonly string[] | null;
|
|
43
|
+
/**
|
|
44
|
+
* The scope rung the server retrieved this bundle at, as `rungKey` writes
|
|
45
|
+
* one. Absent from anything an older server sent, which reads as "named no
|
|
46
|
+
* rung" rather than as "matches anything".
|
|
47
|
+
*/
|
|
48
|
+
scopeRung?: string | null;
|
|
43
49
|
}
|
|
44
50
|
interface LookupResult {
|
|
45
51
|
itemsByType: Record<string, BundleItem[]>;
|
|
@@ -53,6 +59,13 @@ interface LookupParams {
|
|
|
53
59
|
customerId?: string | null;
|
|
54
60
|
clientId?: string | null;
|
|
55
61
|
conversationId?: string | null;
|
|
62
|
+
/**
|
|
63
|
+
* The rung this request names, from its `scope_path`. A SECOND, independent
|
|
64
|
+
* dimension and NOT another tier of the entity funnel: the funnel widens and
|
|
65
|
+
* the rung does not, because a rung is a boundary and a boundary that widens
|
|
66
|
+
* is not one.
|
|
67
|
+
*/
|
|
68
|
+
scopeRung?: string | null;
|
|
56
69
|
maxItems?: number;
|
|
57
70
|
}
|
|
58
71
|
type ExitReason = 'empty' | 'recall_bypass' | 'no_query_tokens' | 'novel_term_gate' | 'empty_corpus' | 'no_items_above_threshold' | 'coverage_gate' | 'hit';
|
|
@@ -62,6 +75,7 @@ interface LookupTelemetry {
|
|
|
62
75
|
customerId: string | null;
|
|
63
76
|
clientId: string | null;
|
|
64
77
|
conversationId: string | null;
|
|
78
|
+
scopeRung: string | null;
|
|
65
79
|
scopeFilterAccepted: string[];
|
|
66
80
|
novelTermRatio: number | null;
|
|
67
81
|
bm25Threshold: number | null;
|
|
@@ -156,7 +170,7 @@ declare class AnticipationCache {
|
|
|
156
170
|
* for exactly that reason: the permissive version could splice user A's
|
|
157
171
|
* summary into user B's response on the conversation-scope path.
|
|
158
172
|
*/
|
|
159
|
-
lookupUserSummary(entityId: string | null | undefined): Record<string, unknown> | null;
|
|
173
|
+
lookupUserSummary(entityId: string | null | undefined, scopeRung?: string | null): Record<string, unknown> | null;
|
|
160
174
|
/**
|
|
161
175
|
* Drop every bundle belonging to one conversation.
|
|
162
176
|
*
|
|
@@ -181,6 +195,13 @@ declare class AnticipationCache {
|
|
|
181
195
|
* accidentally match bundles keyed at "".
|
|
182
196
|
*/
|
|
183
197
|
private buildAcceptedScope;
|
|
198
|
+
/**
|
|
199
|
+
* The rung is checked FIRST and it never widens. Everything else here widens
|
|
200
|
+
* deliberately: a user-scope request reaches customer-shared bundles, and a
|
|
201
|
+
* conversation-scope request reaches user-scope ones. A rung is the opposite
|
|
202
|
+
* kind of thing, so it is checked before the tiers and no amount of widening
|
|
203
|
+
* can put a cross-rung bundle back in.
|
|
204
|
+
*/
|
|
184
205
|
private getValidBundleIds;
|
|
185
206
|
private effectiveTtl;
|
|
186
207
|
private evictExpired;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkT6U5PVADcjs = require('./chunk-T6U5PVAD.cjs');
|
|
7
|
+
require('./chunk-ZKOJDUN4.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
exports.ANY_SCOPE = _chunkT6U5PVADcjs.ANY_SCOPE; exports.AnticipationCache = _chunkT6U5PVADcjs.AnticipationCache; exports.rungKey = _chunkT6U5PVADcjs.rungKey; exports.rungServes = _chunkT6U5PVADcjs.rungServes;
|
|
14
|
+
//# sourceMappingURL=anticipation-cache-LRE3TLK4.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/private/tmp/ndeep-main/synap/sdk/js/dist/anticipation-cache-LRE3TLK4.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACF,iNAAC","file":"/private/tmp/ndeep-main/synap/sdk/js/dist/anticipation-cache-LRE3TLK4.cjs"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ANY_SCOPE,
|
|
3
|
+
AnticipationCache,
|
|
4
|
+
rungKey,
|
|
5
|
+
rungServes
|
|
6
|
+
} from "./chunk-ODVOQOSO.js";
|
|
7
|
+
import "./chunk-QBCVMPGK.js";
|
|
8
|
+
export {
|
|
9
|
+
ANY_SCOPE,
|
|
10
|
+
AnticipationCache,
|
|
11
|
+
rungKey,
|
|
12
|
+
rungServes
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=anticipation-cache-WLU4NMD5.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/private/tmp/claude-501/-Users-scaler-maximem-synap/941df347-d7e5-4dc7-a714-e7bd41f7ddd2/scratchpad/wt-scopefix/synap/sdk/js/dist/chunk-2TVL5IPQ.cjs","../src/errors.ts"],"names":[],"mappings":"AAAA;AC6CA,IAAM,MAAA,kBAAQ,MAAA,CAAO,GAAA,CAAI,kCAAkC,CAAA;AAOpD,IAAM,WAAA,YAAN,MAAA,QAAyB,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYpC,4BAAgB,UAAA,EAA4B,cAAA;AAAA;AAAA,EAE5C,6BAAgB,YAAA,EAAuB,MAAA;AAAA;AAAA,EAG9B;AAAA,EACA;AAAA,EACA;AAAA,EAET,WAAA,CAAY,OAAA,EAAiB,QAAA,EAA6B,CAAC,CAAA,EAAG;AAC5D,IAAA,KAAA,CAAM,OAAA,EAAS,OAAA,CAAQ,MAAA,IAAU,KAAA,EAAA,EAAY,EAAE,KAAA,EAAO,OAAA,CAAQ,MAAM,EAAA,EAAI,KAAA,CAAS,CAAA;AACjF,IAAA,MAAM,KAAA,EAAO,GAAA,CAAA,MAAA;AACb,IAAA,IAAA,CAAK,KAAA,EAAO,GAAA,CAAA,MAAA,CAAW,IAAA;AACvB,IAAA,IAAA,CAAK,KAAA,EAAO,IAAA,CAAK,SAAA;AACjB,IAAA,IAAA,CAAK,UAAA,EAAY,IAAA,CAAK,WAAA;AACtB,IAAA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t-scopefix/synap/sdk/js/dist/chunk-2TVL5IPQ.cjs","sourcesContent":[null,"/**\n * Synap SDK error taxonomy.\n *\n * Mirrors `maximem_synap/models/errors.py` 1:1, including the four\n * backward-compatibility aliases at the bottom. If you add an error to one\n * SDK, add it to the other in the same change.\n *\n * ## Why every error carries a `.code`\n *\n * This package ships dual ESM + CJS. A consumer whose dependency graph pulls\n * in both formats gets *two* copies of every class in this file, and then:\n *\n * try { ... } catch (e) { if (e instanceof SynapError) { ... } }\n *\n * silently evaluates to `false` against the copy from the other format. Error\n * handling stops working and nothing throws to tell you. `.code` is a plain\n * string, so it is immune. Prefer it at package boundaries:\n *\n * if (isSynapError(e) && e.code === 'rate_limit') { ... }\n *\n * `Symbol.hasInstance` is also wired up on the base class, so `instanceof`\n * works across realms too -- but `.code` is the documented contract.\n */\n\n/** Stable, format-independent discriminators. Never renumber or reuse. */\nexport type SynapErrorCode =\n | 'synap_error'\n | 'transient'\n | 'permanent'\n | 'network_timeout'\n | 'rate_limit'\n | 'insufficient_credits'\n | 'service_unavailable'\n | 'invalid_input'\n | 'invalid_instance_id'\n | 'invalid_conversation_id'\n | 'authentication'\n | 'context_not_found'\n | 'conflict'\n | 'transcript_conflict'\n | 'session_expired'\n | 'listening_already_active'\n | 'listening_not_active'\n | 'agent_unavailable';\n\nconst BRAND = Symbol.for('@maximem/synap-js-sdk.SynapError');\n\nexport interface SynapErrorOptions {\n correlationId?: string | null;\n cause?: unknown;\n}\n\nexport class SynapError extends Error {\n /**\n * The single declaration site for each subclass's code.\n *\n * It is `static` rather than a class field on purpose. Under\n * `useDefineForClassFields` (the default at our ES2022 target) a class field\n * is an *instance* property, so it is invisible from the constructor object.\n * `Symbol.hasInstance` below only has the constructor to work with, so a\n * field would leave it unable to tell `AuthenticationError` from\n * `RateLimitError` -- it would report every Synap error as an instance of\n * every other one.\n */\n static readonly errorCode: SynapErrorCode = 'synap_error';\n /** True for errors where a retry may succeed. Static for the same reason. */\n static readonly isTransient: boolean = false;\n\n /** Own, enumerable, so logs and JSON.stringify include it. */\n readonly code: SynapErrorCode;\n readonly correlationId: string | null;\n readonly transient: boolean;\n\n constructor(message: string, options: SynapErrorOptions = {}) {\n super(message, options.cause !== undefined ? { cause: options.cause } : undefined);\n const ctor = new.target as typeof SynapError;\n this.name = new.target.name;\n this.code = ctor.errorCode;\n this.transient = ctor.isTransient;\n this.correlationId = options.correlationId ?? null;\n Object.defineProperty(this, BRAND, { value: true, enumerable: false });\n // Without this, subclassing a built-in under a downlevel target breaks the\n // prototype chain and `instanceof` fails even within a single copy.\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static override [Symbol.hasInstance](instance: unknown): boolean {\n if (instance === null || typeof instance !== 'object') return false;\n // Cross-realm / dual-format tolerant: identify by brand, then narrow by the\n // subclass's own code so `e instanceof RateLimitError` stays meaningful.\n if (!(BRAND in instance)) return false;\n const expected = (this as unknown as { errorCode?: SynapErrorCode }).errorCode;\n // Called on something that is not one of our classes: fall back to the brand.\n if (expected === undefined) return true;\n // Everything branded descends from the root.\n if (expected === 'synap_error') return true;\n const actual = (instance as { code?: string }).code;\n return actual === expected || descendsFrom(actual, expected);\n }\n}\n\n/** Type guard that works across ESM/CJS copies and realms. */\nexport function isSynapError(e: unknown): e is SynapError {\n return typeof e === 'object' && e !== null && BRAND in e;\n}\n\nexport class SynapTransientError extends SynapError {\n static override readonly errorCode: SynapErrorCode = 'transient';\n static override readonly isTransient: boolean = true;\n}\n\nexport class SynapPermanentError extends SynapError {\n static override readonly errorCode: SynapErrorCode = 'permanent';\n static override readonly isTransient: boolean = false;\n}\n\n// ─── Transient ────────────────────────────────────────────────────────────────\n\nexport class NetworkTimeoutError extends SynapTransientError {\n static override readonly errorCode: SynapErrorCode = 'network_timeout';\n}\n\nexport class RateLimitError extends SynapTransientError {\n static override readonly errorCode: SynapErrorCode = 'rate_limit';\n readonly retryAfterSeconds: number | null;\n\n constructor(\n message: string,\n options: SynapErrorOptions & { retryAfterSeconds?: number | null } = {},\n ) {\n super(message, options);\n this.retryAfterSeconds = options.retryAfterSeconds ?? null;\n }\n}\n\nexport class ServiceUnavailableError extends SynapTransientError {\n static override readonly errorCode: SynapErrorCode = 'service_unavailable';\n}\n\nexport class AgentUnavailableError extends SynapTransientError {\n static override readonly errorCode: SynapErrorCode = 'agent_unavailable';\n constructor(message = 'Agent unavailable', options: SynapErrorOptions = {}) {\n super(message, options);\n }\n}\n\n// ─── Permanent ────────────────────────────────────────────────────────────────\n\n/**\n * The caller's credit wallet cannot cover this request.\n *\n * HTTP 402, and gRPC RESOURCE_EXHAUSTED with credit-related trailing metadata.\n * Permanent by design: retrying without topping up burns quota and never\n * succeeds. This is the error behind \"the agent forgot\" reports where retrieval\n * silently returns nothing.\n */\nexport class InsufficientCreditsError extends SynapPermanentError {\n static override readonly errorCode: SynapErrorCode = 'insufficient_credits';\n readonly balanceCredits: number | null;\n readonly requiredCredits: number | null;\n /** Where the balance can be viewed. Python calls this `recovery_url`. */\n readonly recoveryUrl: string | null;\n /** Where a redeem code can be entered. Python calls this `redeem_url`. */\n readonly redeemUrl: string | null;\n\n constructor(\n message: string,\n options: SynapErrorOptions & {\n balanceCredits?: number | null;\n requiredCredits?: number | null;\n recoveryUrl?: string | null;\n redeemUrl?: string | null;\n } = {},\n ) {\n super(message, options);\n this.balanceCredits = options.balanceCredits ?? null;\n this.requiredCredits = options.requiredCredits ?? null;\n this.recoveryUrl = options.recoveryUrl ?? null;\n this.redeemUrl = options.redeemUrl ?? null;\n }\n}\n\nexport class InvalidInputError extends SynapPermanentError {\n static override readonly errorCode: SynapErrorCode = 'invalid_input';\n}\n\n/**\n * Raised by `validateInstanceId` before any network call, matching Python's\n * `utils/validators.py`. The message text is identical in both SDKs.\n */\nexport class InvalidInstanceIdError extends InvalidInputError {\n static override readonly errorCode: SynapErrorCode = 'invalid_instance_id';\n}\n\n/** See the note on InvalidInstanceIdError. Raised by `validateConversationId`. */\nexport class InvalidConversationIdError extends InvalidInputError {\n static override readonly errorCode: SynapErrorCode = 'invalid_conversation_id';\n}\n\nexport class AuthenticationError extends SynapPermanentError {\n static override readonly errorCode: SynapErrorCode = 'authentication';\n}\n\nexport class ContextNotFoundError extends SynapPermanentError {\n static override readonly errorCode: SynapErrorCode = 'context_not_found';\n}\n\nexport class ConflictError extends SynapPermanentError {\n static override readonly errorCode: SynapErrorCode = 'conflict';\n}\n\nexport class TranscriptConflictError extends ConflictError {\n static override readonly errorCode: SynapErrorCode = 'transcript_conflict';\n}\n\nexport class SessionExpiredError extends SynapPermanentError {\n static override readonly errorCode: SynapErrorCode = 'session_expired';\n}\n\nexport class ListeningAlreadyActiveError extends SynapPermanentError {\n static override readonly errorCode: SynapErrorCode = 'listening_already_active';\n}\n\nexport class ListeningNotActiveError extends SynapPermanentError {\n static override readonly errorCode: SynapErrorCode = 'listening_not_active';\n}\n\n// ─── Hierarchy metadata (drives the cross-copy instanceof above) ──────────────\n\nconst PARENT: Partial<Record<SynapErrorCode, SynapErrorCode>> = {\n transient: 'synap_error',\n permanent: 'synap_error',\n network_timeout: 'transient',\n rate_limit: 'transient',\n service_unavailable: 'transient',\n agent_unavailable: 'transient',\n insufficient_credits: 'permanent',\n invalid_input: 'permanent',\n invalid_instance_id: 'invalid_input',\n invalid_conversation_id: 'invalid_input',\n authentication: 'permanent',\n context_not_found: 'permanent',\n conflict: 'permanent',\n transcript_conflict: 'conflict',\n session_expired: 'permanent',\n listening_already_active: 'permanent',\n listening_not_active: 'permanent',\n};\n\nfunction descendsFrom(actual: string | undefined, expected: string): boolean {\n let cur = actual as SynapErrorCode | undefined;\n const seen = new Set<string>();\n while (cur && !seen.has(cur)) {\n seen.add(cur);\n if (cur === expected) return true;\n cur = PARENT[cur];\n }\n return false;\n}\n\n// ─── Backward-compatibility aliases (mirrors the tail of errors.py) ──────────\n// `ConnectionError` deliberately shadows the global in a module scope. Python\n// does the same thing; keeping the name means ported code reads identically.\n\nexport const SDKError = SynapError;\nexport const TransientError = SynapTransientError;\nexport const PermanentError = SynapPerm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A,EACV,mBAAA,EAAqB,UAAA;AAAA,EACrB,eAAA,EAAiB,WAAA;AAAA,EACjB,wBAAA,EAA0B,WAAA;AAAA,EAC1B,oBAAA,EAAsB;AACxB,CAAA;AAEA,SAAS,YAAA,CAAa,MAAA,EAA4B,QAAA,EAA2B;AAC3E,EAAA,IAAI,IAAA,EAAM,MAAA;AACV,EAAA,MAAM,KAAA,kBAAO,IAAI,GAAA,CAAY,CAAA;AAC7B,EAAA,MAAA,CAAO,IAAA,GAAO,CAAC,IAAA,CAAK,GAAA,CAAI,GAAG,CAAA,EAAG;AAC5B,IAAA,IAAA,CAAK,GAAA,CAAI,GAAG,CAAA;AACZ,IAAA,GAAA,CAAI,IAAA,IAAQ,QAAA,EAAU,OAAO,IAAA;AAC7B,IAAA,IAAA,EAAM,MAAA,CAAO,GAAG,CAAA;AAAA,EAClB;AACA,EAAA,OAAO,KAAA;AACT;AAMO,IAAM,SAAA,EAAW,UAAA;AACjB,IAAM,eAAA,EAAiB,mBAAA;AACvB,IAAM,eAAA,EAAiB,mBAAA;AACvB,IAAM,gBAAA,EAAkB,mBAAA;ADpH/B;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,onCAAC","file":"/private/tmp/ndeep-main/synap/sdk/js/dist/chunk-2TVL5IPQ.cjs","sourcesContent":[null,"/**\n * Synap SDK error taxonomy.\n *\n * Mirrors `maximem_synap/models/errors.py` 1:1, including the four\n * backward-compatibility aliases at the bottom. If you add an error to one\n * SDK, add it to the other in the same change.\n *\n * ## Why every error carries a `.code`\n *\n * This package ships dual ESM + CJS. A consumer whose dependency graph pulls\n * in both formats gets *two* copies of every class in this file, and then:\n *\n * try { ... } catch (e) { if (e instanceof SynapError) { ... } }\n *\n * silently evaluates to `false` against the copy from the other format. Error\n * handling stops working and nothing throws to tell you. `.code` is a plain\n * string, so it is immune. Prefer it at package boundaries:\n *\n * if (isSynapError(e) && e.code === 'rate_limit') { ... }\n *\n * `Symbol.hasInstance` is also wired up on the base class, so `instanceof`\n * works across realms too -- but `.code` is the documented contract.\n */\n\n/** Stable, format-independent discriminators. Never renumber or reuse. */\nexport type SynapErrorCode =\n | 'synap_error'\n | 'transient'\n | 'permanent'\n | 'network_timeout'\n | 'rate_limit'\n | 'insufficient_credits'\n | 'service_unavailable'\n | 'invalid_input'\n | 'invalid_instance_id'\n | 'invalid_conversation_id'\n | 'authentication'\n | 'context_not_found'\n | 'conflict'\n | 'transcript_conflict'\n | 'session_expired'\n | 'listening_already_active'\n | 'listening_not_active'\n | 'agent_unavailable';\n\nconst BRAND = Symbol.for('@maximem/synap-js-sdk.SynapError');\n\nexport interface SynapErrorOptions {\n correlationId?: string | null;\n cause?: unknown;\n}\n\nexport class SynapError extends Error {\n /**\n * The single declaration site for each subclass's code.\n *\n * It is `static` rather than a class field on purpose. Under\n * `useDefineForClassFields` (the default at our ES2022 target) a class field\n * is an *instance* property, so it is invisible from the constructor object.\n * `Symbol.hasInstance` below only has the constructor to work with, so a\n * field would leave it unable to tell `AuthenticationError` from\n * `RateLimitError` -- it would report every Synap error as an instance of\n * every other one.\n */\n static readonly errorCode: SynapErrorCode = 'synap_error';\n /** True for errors where a retry may succeed. Static for the same reason. */\n static readonly isTransient: boolean = false;\n\n /** Own, enumerable, so logs and JSON.stringify include it. */\n readonly code: SynapErrorCode;\n readonly correlationId: string | null;\n readonly transient: boolean;\n\n constructor(message: string, options: SynapErrorOptions = {}) {\n super(message, options.cause !== undefined ? { cause: options.cause } : undefined);\n const ctor = new.target as typeof SynapError;\n this.name = new.target.name;\n this.code = ctor.errorCode;\n this.transient = ctor.isTransient;\n this.correlationId = options.correlationId ?? null;\n Object.defineProperty(this, BRAND, { value: true, enumerable: false });\n // Without this, subclassing a built-in under a downlevel target breaks the\n // prototype chain and `instanceof` fails even within a single copy.\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static override [Symbol.hasInstance](instance: unknown): boolean {\n if (instance === null || typeof instance !== 'object') return false;\n // Cross-realm / dual-format tolerant: identify by brand, then narrow by the\n // subclass's own code so `e instanceof RateLimitError` stays meaningful.\n if (!(BRAND in instance)) return false;\n const expected = (this as unknown as { errorCode?: SynapErrorCode }).errorCode;\n // Called on something that is not one of our classes: fall back to the brand.\n if (expected === undefined) return true;\n // Everything branded descends from the root.\n if (expected === 'synap_error') return true;\n const actual = (instance as { code?: string }).code;\n return actual === expected || descendsFrom(actual, expected);\n }\n}\n\n/** Type guard that works across ESM/CJS copies and realms. */\nexport function isSynapError(e: unknown): e is SynapError {\n return typeof e === 'object' && e !== null && BRAND in e;\n}\n\nexport class SynapTransientError extends SynapError {\n static override readonly errorCode: SynapErrorCode = 'transient';\n static override readonly isTransient: boolean = true;\n}\n\nexport class SynapPermanentError extends SynapError {\n static override readonly errorCode: SynapErrorCode = 'permanent';\n static override readonly isTransient: boolean = false;\n}\n\n// ─── Transient ────────────────────────────────────────────────────────────────\n\nexport class NetworkTimeoutError extends SynapTransientError {\n static override readonly errorCode: SynapErrorCode = 'network_timeout';\n}\n\nexport class RateLimitError extends SynapTransientError {\n static override readonly errorCode: SynapErrorCode = 'rate_limit';\n readonly retryAfterSeconds: number | null;\n\n constructor(\n message: string,\n options: SynapErrorOptions & { retryAfterSeconds?: number | null } = {},\n ) {\n super(message, options);\n this.retryAfterSeconds = options.retryAfterSeconds ?? null;\n }\n}\n\nexport class ServiceUnavailableError extends SynapTransientError {\n static override readonly errorCode: SynapErrorCode = 'service_unavailable';\n}\n\nexport class AgentUnavailableError extends SynapTransientError {\n static override readonly errorCode: SynapErrorCode = 'agent_unavailable';\n constructor(message = 'Agent unavailable', options: SynapErrorOptions = {}) {\n super(message, options);\n }\n}\n\n// ─── Permanent ────────────────────────────────────────────────────────────────\n\n/**\n * The caller's credit wallet cannot cover this request.\n *\n * HTTP 402, and gRPC RESOURCE_EXHAUSTED with credit-related trailing metadata.\n * Permanent by design: retrying without topping up burns quota and never\n * succeeds. This is the error behind \"the agent forgot\" reports where retrieval\n * silently returns nothing.\n */\nexport class InsufficientCreditsError extends SynapPermanentError {\n static override readonly errorCode: SynapErrorCode = 'insufficient_credits';\n readonly balanceCredits: number | null;\n readonly requiredCredits: number | null;\n /** Where the balance can be viewed. Python calls this `recovery_url`. */\n readonly recoveryUrl: string | null;\n /** Where a redeem code can be entered. Python calls this `redeem_url`. */\n readonly redeemUrl: string | null;\n\n constructor(\n message: string,\n options: SynapErrorOptions & {\n balanceCredits?: number | null;\n requiredCredits?: number | null;\n recoveryUrl?: string | null;\n redeemUrl?: string | null;\n } = {},\n ) {\n super(message, options);\n this.balanceCredits = options.balanceCredits ?? null;\n this.requiredCredits = options.requiredCredits ?? null;\n this.recoveryUrl = options.recoveryUrl ?? null;\n this.redeemUrl = options.redeemUrl ?? null;\n }\n}\n\nexport class InvalidInputError extends SynapPermanentError {\n static override readonly errorCode: SynapErrorCode = 'invalid_input';\n}\n\n/**\n * Raised by `validateInstanceId` before any network call, matching Python's\n * `utils/validators.py`. The message text is identical in both SDKs.\n */\nexport class InvalidInstanceIdError extends InvalidInputError {\n static override readonly errorCode: SynapErrorCode = 'invalid_instance_id';\n}\n\n/** See the note on InvalidInstanceIdError. Raised by `validateConversationId`. */\nexport class InvalidConversationIdError extends InvalidInputError {\n static override readonly errorCode: SynapErrorCode = 'invalid_conversation_id';\n}\n\nexport class AuthenticationError extends SynapPermanentError {\n static override readonly errorCode: SynapErrorCode = 'authentication';\n}\n\nexport class ContextNotFoundError extends SynapPermanentError {\n static override readonly errorCode: SynapErrorCode = 'context_not_found';\n}\n\nexport class ConflictError extends SynapPermanentError {\n static override readonly errorCode: SynapErrorCode = 'conflict';\n}\n\nexport class TranscriptConflictError extends ConflictError {\n static override readonly errorCode: SynapErrorCode = 'transcript_conflict';\n}\n\nexport class SessionExpiredError extends SynapPermanentError {\n static override readonly errorCode: SynapErrorCode = 'session_expired';\n}\n\nexport class ListeningAlreadyActiveError extends SynapPermanentError {\n static override readonly errorCode: SynapErrorCode = 'listening_already_active';\n}\n\nexport class ListeningNotActiveError extends SynapPermanentError {\n static override readonly errorCode: SynapErrorCode = 'listening_not_active';\n}\n\n// ─── Hierarchy metadata (drives the cross-copy instanceof above) ──────────────\n\nconst PARENT: Partial<Record<SynapErrorCode, SynapErrorCode>> = {\n transient: 'synap_error',\n permanent: 'synap_error',\n network_timeout: 'transient',\n rate_limit: 'transient',\n service_unavailable: 'transient',\n agent_unavailable: 'transient',\n insufficient_credits: 'permanent',\n invalid_input: 'permanent',\n invalid_instance_id: 'invalid_input',\n invalid_conversation_id: 'invalid_input',\n authentication: 'permanent',\n context_not_found: 'permanent',\n conflict: 'permanent',\n transcript_conflict: 'conflict',\n session_expired: 'permanent',\n listening_already_active: 'permanent',\n listening_not_active: 'permanent',\n};\n\nfunction descendsFrom(actual: string | undefined, expected: string): boolean {\n let cur = actual as SynapErrorCode | undefined;\n const seen = new Set<string>();\n while (cur && !seen.has(cur)) {\n seen.add(cur);\n if (cur === expected) return true;\n cur = PARENT[cur];\n }\n return false;\n}\n\n// ─── Backward-compatibility aliases (mirrors the tail of errors.py) ──────────\n// `ConnectionError` deliberately shadows the global in a module scope. Python\n// does the same thing; keeping the name means ported code reads identically.\n\nexport const SDKError = SynapError;\nexport const TransientError = SynapTransientError;\nexport const PermanentError = SynapPermanentError;\nexport const ConnectionError = NetworkTimeoutError;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/grpc/descriptor.ts
|
|
2
|
-
var PROTO_SHA = "
|
|
2
|
+
var PROTO_SHA = "a58c9b031b41530d";
|
|
3
3
|
var SYNAP_PROTO_DESCRIPTOR = {
|
|
4
4
|
"nested": {
|
|
5
5
|
"synap": {
|
|
@@ -211,6 +211,11 @@ var SYNAP_PROTO_DESCRIPTOR = {
|
|
|
211
211
|
"rule": "repeated",
|
|
212
212
|
"type": "string",
|
|
213
213
|
"id": 13
|
|
214
|
+
},
|
|
215
|
+
"scope": {
|
|
216
|
+
"keyType": "string",
|
|
217
|
+
"type": "string",
|
|
218
|
+
"id": 14
|
|
214
219
|
}
|
|
215
220
|
}
|
|
216
221
|
},
|
|
@@ -394,6 +399,10 @@ var SYNAP_PROTO_DESCRIPTOR = {
|
|
|
394
399
|
"ttl_hint_seconds": {
|
|
395
400
|
"type": "int32",
|
|
396
401
|
"id": 23
|
|
402
|
+
},
|
|
403
|
+
"anticipation_scope_rung": {
|
|
404
|
+
"type": "string",
|
|
405
|
+
"id": 24
|
|
397
406
|
}
|
|
398
407
|
}
|
|
399
408
|
},
|
|
@@ -780,6 +789,10 @@ var GrpcStreamClient = class {
|
|
|
780
789
|
// customer; falling back to customer id keeps org-scope bundles usable.
|
|
781
790
|
entityId: String(_nullishCoalesce(bundle["anticipation_user_id"], () => ( ""))) || String(_nullishCoalesce(bundle["anticipation_customer_id"], () => ( ""))) || null,
|
|
782
791
|
conversationId: conversationId || null,
|
|
792
|
+
// The rung the server retrieved this bundle at. Absent from anything an
|
|
793
|
+
// older server sent, and absent reads as "named no rung" rather than as
|
|
794
|
+
// "matches anything".
|
|
795
|
+
scopeRung: String(_nullishCoalesce(bundle["anticipation_scope_rung"], () => ( ""))) || null,
|
|
783
796
|
itemsByType,
|
|
784
797
|
// 0 means "use the SDK default"; anything else is floored at 60s.
|
|
785
798
|
ttlHintSeconds: ttlHint > 0 ? Math.max(ttlHint, MIN_TTL_SECONDS) : null,
|
|
@@ -853,4 +866,4 @@ var GrpcStreamClient = class {
|
|
|
853
866
|
|
|
854
867
|
|
|
855
868
|
exports.PROTO_SHA = PROTO_SHA; exports.GrpcStreamClient = GrpcStreamClient;
|
|
856
|
-
//# sourceMappingURL=chunk-
|
|
869
|
+
//# sourceMappingURL=chunk-7CWBRHUO.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/private/tmp/ndeep-main/synap/sdk/js/dist/chunk-7CWBRHUO.cjs","../src/grpc/descriptor.ts","../src/grpc/stream-client.ts"],"names":[],"mappings":"AAAA;ACaO,IAAM,UAAA,EAAY,kBAAA;AAElB,IAAM,uBAAA,EAAyB;AAAA,EACpC,QAAA,EAAU;AAAA,IACR,OAAA,EAAS;AAAA,MACP,QAAA,EAAU;AAAA,QACR,IAAA,EAAM;AAAA,UACJ,QAAA,EAAU;AAAA,YACR,cAAA,EAAgB;AAAA,cACd,SAAA,EAAW;AAAA,gBACT,QAAA,EAAU;AAAA,kBACR,aAAA,EAAe,aAAA;AAAA,kBACf,eAAA,EAAiB,IAAA;AAAA,kBACjB,cAAA,EAAgB,gBAAA;AAAA,kBAChB,gBAAA,EAAkB;AAAA,gBACpB,CAAA;AAAA,gBACA,iBAAA,EAAmB;AAAA,kBACjB,aAAA,EAAe,gBAAA;AAAA,kBACf,eAAA,EAAiB,IAAA;AAAA,kBACjB,cAAA,EAAgB;AAAA,gBAClB;AAAA,cACF;AAAA,YACF,CAAA;AAAA,YACA,aAAA,EAAe;AAAA,cACb,QAAA,EAAU;AAAA,gBACR,SAAA,EAAW;AAAA,kBACT,OAAA,EAAS;AAAA,oBACP,oBAAA;AAAA,oBACA,gBAAA;AAAA,oBACA,iBAAA;AAAA,oBACA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AAA;AACiB,QAAA;AACb,MAAA;AACI,QAAA;AACZ,MAAA;AACC,IAAA;AAGkB,oBAAA;AACvB,EAAA;AAEuB,EAAA;AACZ,IAAA;AACY,MAAA;AACd,MAAA;AACP,IAAA;AACF,EAAA;AAEmB,EAAA;AACb,IAAA;AACc,sBAAA;AACV,IAAA;AAER,IAAA;AACa,IAAA;AACf,EAAA;AAEoC,EAAA;AACpB,IAAA;AACA,oBAAA;AAChB,EAAA;AACF;AFkd2B;AACA;AACA;AACA;AACA","file":"/private/tmp/ndeep-main/synap/sdk/js/dist/chunk-7CWBRHUO.cjs","sourcesContent":[null,"/**\n * GENERATED FILE. Do not edit by hand.\n *\n * Source: synap/proto/synap_service.proto\n * Generator: synap/sdk/scripts/gen_proto_descriptor.mjs\n * Proto SHA: a58c9b031b41530d\n *\n * The proto is inlined as a JSON descriptor rather than loaded from disk so\n * that bundlers and Vercel file tracing cannot lose it. Regenerate with\n * `npm run sync-behavior` in synap/sdk/js.\n */\n\n/** sha256 (first 16 hex chars) of the proto this descriptor was built from. */\nexport const PROTO_SHA = 'a58c9b031b41530d';\n\nexport const SYNAP_PROTO_DESCRIPTOR = {\n \"nested\": {\n \"synap\": {\n \"nested\": {\n \"v1\": {\n \"nested\": {\n \"SynapService\": {\n \"methods\": {\n \"Listen\": {\n \"requestType\": \"StreamEvent\",\n \"requestStream\": true,\n \"responseType\": \"StreamResponse\",\n \"responseStream\": true\n },\n \"IngestTelemetry\": {\n \"requestType\": \"TelemetryEvent\",\n \"requestStream\": true,\n \"responseType\": \"TelemetryAck\"\n }\n }\n },\n \"StreamEvent\": {\n \"oneofs\": {\n \"payload\": {\n \"oneof\": [\n \"conversation_event\",\n \"heartbeat_ping\",\n \"session_control\",\n \"context_used\",\n \"context_assembled\"\n ]\n }\n },\n \"fields\": {\n \"conversation_event\": {\n \"type\": \"ConversationEvent\",\n \"id\": 1\n },\n \"heartbeat_ping\": {\n \"type\": \"HeartbeatPing\",\n \"id\": 2\n },\n \"session_control\": {\n \"type\": \"SessionControl\",\n \"id\": 3\n },\n \"context_used\": {\n \"type\": \"ContextUsedEvent\",\n \"id\": 4\n },\n \"context_assembled\": {\n \"type\": \"ContextAssembledEvent\",\n \"id\": 5\n }\n }\n },\n \"ContextUsedEvent\": {\n \"fields\": {\n \"bundle_id\": {\n \"type\": \"string\",\n \"id\": 1\n },\n \"conversation_id\": {\n \"type\": \"string\",\n \"id\": 2\n },\n \"user_id\": {\n \"type\": \"string\",\n \"id\": 3\n },\n \"customer_id\": {\n \"type\": \"string\",\n \"id\": 4\n },\n \"served_item_ids\": {\n \"rule\": \"repeated\",\n \"type\": \"string\",\n \"id\": 5\n },\n \"timestamp_ms\": {\n \"type\": \"int64\",\n \"id\": 6\n },\n \"scope\": {\n \"type\": \"string\",\n \"id\": 7\n },\n \"source_bundle_ids\": {\n \"rule\": \"repeated\",\n \"type\": \"string\",\n \"id\": 8\n }\n }\n },\n \"ContextAssembledEvent\": {\n \"fields\": {\n \"correlation_id\": {\n \"type\": \"string\",\n \"id\": 1\n },\n \"conversation_id\": {\n \"type\": \"string\",\n \"id\": 2\n },\n \"user_id\": {\n \"type\": \"string\",\n \"id\": 3\n },\n \"customer_id\": {\n \"type\": \"string\",\n \"id\": 4\n },\n \"final_item_ids\": {\n \"rule\": \"repeated\",\n \"type\": \"string\",\n \"id\": 5\n },\n \"final_total_tokens\": {\n \"type\": \"int32\",\n \"id\": 6\n },\n \"compaction_id\": {\n \"type\": \"string\",\n \"id\": 7\n },\n \"recent_turn_count\": {\n \"type\": \"int32\",\n \"id\": 8\n },\n \"compaction_end_timestamp\": {\n \"type\": \"string\",\n \"id\": 9\n },\n \"assembly_source\": {\n \"type\": \"string\",\n \"id\": 10\n },\n \"assembly_duration_ms\": {\n \"type\": \"int32\",\n \"id\": 11\n },\n \"cache_hit\": {\n \"type\": \"bool\",\n \"id\": 12\n },\n \"timestamp_ms\": {\n \"type\": \"int64\",\n \"id\": 13\n },\n \"sdk_version\": {\n \"type\": \"string\",\n \"id\": 14\n }\n }\n },\n \"ConversationEvent\": {\n \"fields\": {\n \"event_type\": {\n \"type\": \"string\",\n \"id\": 1\n },\n \"conversation_id\": {\n \"type\": \"string\",\n \"id\": 2\n },\n \"user_id\": {\n \"type\": \"string\",\n \"id\": 3\n },\n \"role\": {\n \"type\": \"string\",\n \"id\": 4\n },\n \"content\": {\n \"type\": \"string\",\n \"id\": 5\n },\n \"customer_id\": {\n \"type\": \"string\",\n \"id\": 6\n },\n \"session_id\": {\n \"type\": \"string\",\n \"id\": 7\n },\n \"metadata\": {\n \"keyType\": \"string\",\n \"type\": \"string\",\n \"id\": 8\n },\n \"timestamp_ms\": {\n \"type\": \"int64\",\n \"id\": 9\n },\n \"tool_name\": {\n \"type\": \"string\",\n \"id\": 10\n },\n \"tool_args_json\": {\n \"type\": \"string\",\n \"id\": 11\n },\n \"search_queries\": {\n \"rule\": \"repeated\",\n \"type\": \"string\",\n \"id\": 12\n },\n \"context_types\": {\n \"rule\": \"repeated\",\n \"type\": \"string\",\n \"id\": 13\n },\n \"scope\": {\n \"keyType\": \"string\",\n \"type\": \"string\",\n \"id\": 14\n }\n }\n },\n \"HeartbeatPing\": {\n \"fields\": {\n \"timestamp_ms\": {\n \"type\": \"int64\",\n \"id\": 1\n }\n }\n },\n \"SessionControl\": {\n \"fields\": {\n \"action\": {\n \"type\": \"string\",\n \"id\": 1\n },\n \"session_id\": {\n \"type\": \"string\",\n \"id\": 2\n },\n \"conversation_id\": {\n \"type\": \"string\",\n \"id\": 3\n },\n \"user_id\": {\n \"type\": \"string\",\n \"id\": 4\n },\n \"customer_id\": {\n \"type\": \"string\",\n \"id\": 5\n }\n }\n },\n \"StreamResponse\": {\n \"oneofs\": {\n \"payload\": {\n \"oneof\": [\n \"context_bundle\",\n \"heartbeat_pong\",\n \"signal\"\n ]\n }\n },\n \"fields\": {\n \"context_bundle\": {\n \"type\": \"ContextBundleProto\",\n \"id\": 1\n },\n \"heartbeat_pong\": {\n \"type\": \"HeartbeatPong\",\n \"id\": 2\n },\n \"signal\": {\n \"type\": \"StreamSignal\",\n \"id\": 3\n }\n }\n },\n \"HeartbeatPong\": {\n \"fields\": {\n \"timestamp_ms\": {\n \"type\": \"int64\",\n \"id\": 1\n }\n }\n },\n \"StreamSignal\": {\n \"fields\": {\n \"signal_type\": {\n \"type\": \"string\",\n \"id\": 1\n },\n \"reason\": {\n \"type\": \"string\",\n \"id\": 2\n },\n \"metadata\": {\n \"keyType\": \"string\",\n \"type\": \"string\",\n \"id\": 3\n }\n }\n },\n \"ContextBundleProto\": {\n \"fields\": {\n \"bundle_id\": {\n \"type\": \"string\",\n \"id\": 1\n },\n \"decision_id\": {\n \"type\": \"string\",\n \"id\": 2\n },\n \"items_by_type\": {\n \"keyType\": \"string\",\n \"type\": \"ContextItemList\",\n \"id\": 3\n },\n \"total_tokens\": {\n \"type\": \"int32\",\n \"id\": 4\n },\n \"token_budget\": {\n \"type\": \"int32\",\n \"id\": 5\n },\n \"budget_exceeded\": {\n \"type\": \"bool\",\n \"id\": 6\n },\n \"retrieval_mode\": {\n \"type\": \"string\",\n \"id\": 7\n },\n \"sources_queried\": {\n \"rule\": \"repeated\",\n \"type\": \"string\",\n \"id\": 8\n },\n \"degradation_level\": {\n \"type\": \"string\",\n \"id\": 9\n },\n \"warnings\": {\n \"rule\": \"repeated\",\n \"type\": \"string\",\n \"id\": 10\n },\n \"created_at\": {\n \"type\": \"string\",\n \"id\": 11\n },\n \"retrieval_time_ms\": {\n \"type\": \"int32\",\n \"id\": 12\n },\n \"cache_hit\": {\n \"type\": \"bool\",\n \"id\": 13\n },\n \"search_queries\": {\n \"rule\": \"repeated\",\n \"type\": \"string\",\n \"id\": 14\n },\n \"anticipation_user_id\": {\n \"type\": \"string\",\n \"id\": 15\n },\n \"anticipation_customer_id\": {\n \"type\": \"string\",\n \"id\": 16\n },\n \"anticipation_conversation_id\": {\n \"type\": \"string\",\n \"id\": 17\n },\n \"search_keywords\": {\n \"rule\": \"repeated\",\n \"type\": \"string\",\n \"id\": 18\n },\n \"bundle_type\": {\n \"type\": \"string\",\n \"id\": 19\n },\n \"conversation_context\": {\n \"type\": \"ConversationContextProto\",\n \"id\": 20\n },\n \"bundle_confidence\": {\n \"type\": \"float\",\n \"id\": 21\n },\n \"origin_pattern_id\": {\n \"type\": \"string\",\n \"id\": 22\n },\n \"ttl_hint_seconds\": {\n \"type\": \"int32\",\n \"id\": 23\n },\n \"anticipation_scope_rung\": {\n \"type\": \"string\",\n \"id\": 24\n }\n }\n },\n \"ConversationContextProto\": {\n \"fields\": {\n \"summary\": {\n \"type\": \"string\",\n \"id\": 1\n },\n \"current_state_json\": {\n \"type\": \"string\",\n \"id\": 2\n },\n \"key_extractions_json\": {\n \"type\": \"string\",\n \"id\": 3\n },\n \"recent_turns\": {\n \"rule\": \"repeated\",\n \"type\": \"RecentTurnProto\",\n \"id\": 4\n },\n \"compaction_id\": {\n \"type\": \"string\",\n \"id\": 5\n },\n \"compacted_at\": {\n \"type\": \"string\",\n \"id\": 6\n },\n \"conversation_id\": {\n \"type\": \"string\",\n \"id\": 7\n }\n }\n },\n \"RecentTurnProto\": {\n \"fields\": {\n \"role\": {\n \"type\": \"string\",\n \"id\": 1\n },\n \"content\": {\n \"type\": \"string\",\n \"id\": 2\n },\n \"timestamp\": {\n \"type\": \"string\",\n \"id\": 3\n }\n }\n },\n \"ContextItemList\": {\n \"fields\": {\n \"items\": {\n \"rule\": \"repeated\",\n \"type\": \"ContextItemProto\",\n \"id\": 1\n }\n }\n },\n \"ContextItemProto\": {\n \"fields\": {\n \"item_id\": {\n \"type\": \"string\",\n \"id\": 1\n },\n \"content\": {\n \"type\": \"string\",\n \"id\": 2\n },\n \"context_type\": {\n \"type\": \"string\",\n \"id\": 3\n },\n \"source\": {\n \"type\": \"string\",\n \"id\": 4\n },\n \"similarity_score\": {\n \"type\": \"float\",\n \"id\": 5\n },\n \"relevance_score\": {\n \"type\": \"float\",\n \"id\": 6\n },\n \"confidence\": {\n \"type\": \"float\",\n \"id\": 7\n },\n \"scope\": {\n \"type\": \"string\",\n \"id\": 8\n },\n \"entity_id\": {\n \"type\": \"string\",\n \"id\": 9\n },\n \"created_at\": {\n \"type\": \"string\",\n \"id\": 10\n },\n \"event_date\": {\n \"type\": \"string\",\n \"id\": 11\n },\n \"valid_until\": {\n \"type\": \"string\",\n \"id\": 12\n },\n \"temporal_category\": {\n \"type\": \"string\",\n \"id\": 13\n },\n \"temporal_confidence\": {\n \"type\": \"float\",\n \"id\": 14\n }\n }\n },\n \"TelemetryEvent\": {\n \"fields\": {\n \"event_type\": {\n \"type\": \"string\",\n \"id\": 1\n },\n \"instance_id\": {\n \"type\": \"string\",\n \"id\": 2\n },\n \"client_id\": {\n \"type\": \"string\",\n \"id\": 3\n },\n \"correlation_id\": {\n \"type\": \"string\",\n \"id\": 4\n },\n \"timestamp_ms\": {\n \"type\": \"int64\",\n \"id\": 5\n },\n \"latency_ms\": {\n \"type\": \"int32\",\n \"id\": 6\n },\n \"status\": {\n \"type\": \"string\",\n \"id\": 7\n },\n \"error_code\": {\n \"type\": \"string\",\n \"id\": 8\n },\n \"scope\": {\n \"type\": \"string\",\n \"id\": 9\n },\n \"cache_status\": {\n \"type\": \"string\",\n \"id\": 10\n },\n \"attempt\": {\n \"type\": \"int32\",\n \"id\": 11\n },\n \"http_method\": {\n \"type\": \"string\",\n \"id\": 12\n },\n \"http_path\": {\n \"type\": \"string\",\n \"id\": 13\n },\n \"http_status_code\": {\n \"type\": \"int32\",\n \"id\": 14\n },\n \"metadata\": {\n \"keyType\": \"string\",\n \"type\": \"string\",\n \"id\": 15\n },\n \"sdk_version\": {\n \"type\": \"string\",\n \"id\": 16\n },\n \"batch_id\": {\n \"type\": \"string\",\n \"id\": 17\n }\n }\n },\n \"TelemetryAck\": {\n \"fields\": {\n \"status\": {\n \"type\": \"string\",\n \"id\": 1\n },\n \"events_received\": {\n \"type\": \"int32\",\n \"id\": 2\n }\n }\n }\n }\n }\n }\n }\n }\n} as const;\n","/**\n * Bidirectional gRPC stream client for the Synap anticipation channel.\n *\n * Mirrors Python's `GRPCTransport` and the synap-vercel-adk client:\n * - `/synap.v1.SynapService/Listen`, StreamEvent in, StreamResponse out\n * - Auth via `authorization: Bearer <key>` plus `x-client-id` / `x-instance-id`\n * - 30s heartbeat, exponential-backoff reconnect\n * - Server pushes ContextBundleProto, which lands in the AnticipationCache\n *\n * Node-only, and reached exclusively through a lazy `import()` so that merely\n * importing the SDK on Edge or in a Worker stays safe. grpc-js is built on\n * `node:http2`/`node:net`/`node:tls`; a static import fails the BUILD there.\n *\n * The proto arrives as an inlined descriptor (see ./descriptor.ts) rather than\n * being read from disk, so bundlers and Vercel file tracing cannot lose it.\n */\n\nimport type { AnticipationCache } from '../context/anticipation-cache.js';\nimport { SYNAP_PROTO_DESCRIPTOR } from './descriptor.js';\n\nexport type StreamState =\n | 'disconnected' | 'connecting' | 'connected' | 'reconnecting' | 'closed';\n\n/**\n * The ONLY bundle type the cache refuses.\n *\n * NOTE: this deliberately differs from the synap-vercel-adk stream client,\n * which caches an allowlist of `anticipation` and `user_summary` and drops\n * compaction updates. Python's `_handle_anticipated_bundle` stores everything\n * except `reactive`, and Python is the reference implementation, so an\n * allowlist here would silently cache less than the pip SDK does.\n *\n * Reactive bundles are excluded because they answer a fetch that already\n * happened; caching one serves a stale answer to a different question.\n */\nconst UNCACHEABLE_BUNDLE_TYPE = 'reactive';\n\n// Mirrors the Python GRPCTransport constants.\nconst MAX_RECONNECT_ATTEMPTS = 10;\nconst BACKOFF_BASE_MS = 1_000;\nconst BACKOFF_MAX_MS = 30_000;\nconst HEARTBEAT_INTERVAL_MS = 30_000;\nconst HEARTBEAT_TIMEOUT_MS = 10_000;\nconst MAX_MISSED_HEARTBEATS = 3;\n/** The server may only SHORTEN the SDK default, never extend it past this floor. */\nconst MIN_TTL_SECONDS = 60;\n\nexport interface StreamCredentials {\n apiKey: string;\n clientId: string;\n instanceId: string;\n}\n\nexport interface StreamClientOptions {\n host?: string;\n port?: number;\n useTls?: boolean;\n /** Injected in tests so reconnect backoff does not make the suite slow. */\n sleep?: (ms: number) => Promise<void>;\n /** How long to wait for the channel to become ready. Default 10s. */\n connectTimeoutMs?: number;\n onStateChange?: (state: StreamState) => void;\n /** Fires for every bundle, before the cache filter. Backs `listen({onContext})`. */\n onContext?: (bundle: Record<string, unknown>) => void;\n /** Fires only for `compaction_update` bundles. Backs the compaction subscriptions. */\n onCompactionUpdate?: (conversationId: string, bundle: Record<string, unknown>) => void;\n}\n\ninterface DuplexCall {\n write: (msg: unknown) => void;\n on: (event: string, handler: (arg?: unknown) => void) => void;\n end: () => void;\n}\n\nexport interface ConversationEventInput {\n event_type: string;\n conversation_id?: string;\n user_id?: string;\n customer_id?: string;\n role?: string;\n content?: string;\n session_id?: string;\n metadata?: Record<string, string>;\n timestamp_ms?: number;\n /** proto: ConversationEvent.tool_name */\n tool_name?: string;\n /** proto: ConversationEvent.tool_args_json. Python sends json.dumps(tool_args). */\n tool_args_json?: string;\n search_queries?: string[];\n context_types?: string[];\n}\n\nexport class GrpcStreamClient {\n readonly host: string;\n readonly port: number;\n readonly useTls: boolean;\n\n #state: StreamState = 'disconnected';\n #call: DuplexCall | null = null;\n #reconnectAttempts = 0;\n #lastPongAt = 0;\n #missedHeartbeats = 0;\n #heartbeatTimer: ReturnType<typeof setInterval> | null = null;\n #shutdownRequested = false;\n\n #grpc: typeof import('@grpc/grpc-js') | null = null;\n #ServiceStub: (new (target: string, creds: unknown, opts: unknown) => Record<string, unknown>) | null = null;\n\n readonly #credentials: StreamCredentials;\n readonly #cache: AnticipationCache;\n readonly #options: StreamClientOptions;\n readonly #sleep: (ms: number) => Promise<void>;\n readonly #connectTimeoutMs: number;\n\n constructor(\n credentials: StreamCredentials,\n cache: AnticipationCache,\n options: StreamClientOptions = {},\n ) {\n this.#credentials = credentials;\n this.#cache = cache;\n this.#options = options;\n this.host = options.host ?? 'synap-cloud-prod.maximem.ai';\n this.port = options.port ?? 443;\n this.useTls = options.useTls ?? true;\n this.#sleep = options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));\n this.#connectTimeoutMs = options.connectTimeoutMs ?? 10_000;\n }\n\n get currentState(): StreamState { return this.#state; }\n get isConnected(): boolean { return this.#state === 'connected'; }\n\n async connect(): Promise<void> {\n await this.#loadGrpc();\n this.#shutdownRequested = false;\n await this.#establish();\n this.#startHeartbeat();\n }\n\n async disconnect(): Promise<void> {\n this.#shutdownRequested = true;\n this.#stopHeartbeat();\n this.#closeCall();\n this.#setState('closed');\n }\n\n /** Fire-and-forget: a dropped event must never fail the caller's turn. */\n sendConversationEvent(event: ConversationEventInput): void {\n this.#write({ conversation_event: { ...event } });\n }\n\n sendSessionControl(input: {\n action: string;\n session_id?: string;\n conversation_id?: string;\n user_id?: string;\n customer_id?: string;\n }): void {\n this.#write({ session_control: { ...input } });\n }\n\n sendContextUsed(event: Record<string, unknown>): void {\n this.#write({ context_used: { ...event } });\n }\n\n sendContextAssembled(event: Record<string, unknown>): void {\n this.#write({ context_assembled: { ...event } });\n }\n\n #write(msg: unknown): void {\n if (!this.isConnected || this.#call === null) return;\n try {\n this.#call.write(msg);\n } catch {\n // Non-fatal. These are telemetry and control events; losing one is\n // strictly better than surfacing a stream hiccup to the caller.\n }\n }\n\n async #loadGrpc(): Promise<void> {\n if (this.#grpc !== null) return;\n const [grpcMod, protoMod] = await Promise.all([\n import(/* @vite-ignore */ '@grpc/grpc-js'),\n import(/* @vite-ignore */ '@grpc/proto-loader'),\n ]);\n this.#grpc = grpcMod;\n\n // `fromJSON`, not `loadSync`: no path, no disk read, nothing for a bundler\n // to fail to trace. `keepCase` keeps the snake_case field names the server\n // and the Python SDK both use.\n const pkgDef = protoMod.fromJSON(\n SYNAP_PROTO_DESCRIPTOR as unknown as Parameters<typeof protoMod.fromJSON>[0],\n { keepCase: true, longs: Number, enums: String, defaults: true, oneofs: true },\n );\n const pkg = grpcMod.loadPackageDefinition(pkgDef) as unknown as {\n synap: { v1: { SynapService: new (t: string, c: unknown, o: unknown) => Record<string, unknown> } };\n };\n this.#ServiceStub = pkg.synap.v1.SynapService;\n }\n\n async #establish(): Promise<void> {\n this.#setState('connecting');\n const grpc = this.#grpc;\n const Stub = this.#ServiceStub;\n if (grpc === null || Stub === null) throw new Error('gRPC not loaded');\n\n const channelCreds = this.useTls\n ? grpc.credentials.createSsl()\n : grpc.credentials.createInsecure();\n\n const stub = new Stub(`${this.host}:${this.port}`, channelCreds, {\n 'grpc.keepalive_time_ms': 30_000,\n 'grpc.keepalive_timeout_ms': 10_000,\n 'grpc.keepalive_permit_without_calls': 1,\n });\n\n // Wait for the channel before reporting success.\n //\n // grpc-js connects LAZILY: constructing the stub and creating the call both\n // return immediately, and a bad host surfaces later through the call's\n // 'error' event. Without this, `await listen()` resolved against an\n // unreachable port, `is_listening` read true for a stream that never\n // connected, and `send_message()` then dropped every event silently,\n // because sends are deliberately fire-and-forget. Failing loudly here is\n // the difference between a clear error and an agent that looks like it has\n // no memory.\n await new Promise<void>((resolve, reject) => {\n const deadline = new Date(Date.now() + this.#connectTimeoutMs);\n const waitForReady = (stub as unknown as {\n waitForReady?: (d: Date, cb: (e?: Error) => void) => void;\n }).waitForReady;\n if (typeof waitForReady !== 'function') {\n // Older grpc-js, or a stub that does not expose it. Fall back to the\n // lazy behaviour rather than failing outright.\n resolve();\n return;\n }\n waitForReady.call(stub, deadline, (error?: Error) => {\n if (error) reject(error);\n else resolve();\n });\n });\n\n const metadata = new grpc.Metadata();\n metadata.add('authorization', `Bearer ${this.#credentials.apiKey}`);\n metadata.add('x-client-id', this.#credentials.clientId);\n metadata.add('x-instance-id', this.#credentials.instanceId);\n\n const call = (stub['Listen'] as (m: unknown) => DuplexCall)(metadata);\n call.on('data', (msg) => this.#handleMessage(msg as Record<string, unknown>));\n call.on('error', (err) => { void this.#handleDisconnect(`error: ${String(err)}`); });\n call.on('end', () => { void this.#handleDisconnect('server_close'); });\n\n this.#call = call;\n this.#setState('connected');\n this.#reconnectAttempts = 0;\n this.#lastPongAt = Date.now();\n }\n\n #handleMessage(msg: Record<string, unknown>): void {\n if (msg['context_bundle']) {\n this.#handleBundle(msg['context_bundle'] as Record<string, unknown>);\n return;\n }\n if (msg['heartbeat_pong']) {\n this.#lastPongAt = Date.now();\n this.#missedHeartbeats = 0;\n return;\n }\n const signal = msg['signal'] as { signal_type?: string } | undefined;\n if (signal?.signal_type === 'closing') {\n void this.#handleDisconnect('server_signal_closing');\n }\n }\n\n #handleBundle(bundle: Record<string, unknown>): void {\n const bundleType = String(bundle['bundle_type'] ?? '') || 'anticipation';\n const conversationId = String(bundle['anticipation_conversation_id'] ?? '');\n\n if (bundleType !== UNCACHEABLE_BUNDLE_TYPE) this.#store(bundle, bundleType, conversationId);\n\n if (bundleType === 'compaction_update' && conversationId !== '') {\n // Python also deletes this conversation's `compacted_full` /\n // `compacted_context` entries from its separate CacheManager. This SDK\n // has no such cache, and calling dropConversation() here would delete\n // the bundle just stored above, so there is nothing to invalidate.\n this.#options.onCompactionUpdate?.(conversationId, bundle);\n }\n\n // Fires for every type, after storing, matching Python's ordering.\n this.#options.onContext?.(bundle);\n }\n\n #store(bundle: Record<string, unknown>, bundleType: string, conversationId: string): void {\n const itemsByType: Record<string, Array<Record<string, unknown>>> = {};\n for (const [type, list] of Object.entries(bundle['items_by_type'] ?? {})) {\n const items = (list as { items?: Array<Record<string, unknown>> })?.items;\n itemsByType[type] = items ?? [];\n }\n\n const ttlHint = Number(bundle['ttl_hint_seconds'] ?? 0);\n this.#cache.store({\n bundleId: String(bundle['bundle_id'] ?? ''),\n // The cache keys on ONE entity. User id wins when present, so a bundle\n // pushed for a user cannot be served to a different user in the same\n // customer; falling back to customer id keeps org-scope bundles usable.\n entityId:\n String(bundle['anticipation_user_id'] ?? '') ||\n String(bundle['anticipation_customer_id'] ?? '') ||\n null,\n conversationId: conversationId || null,\n // The rung the server retrieved this bundle at. Absent from anything an\n // older server sent, and absent reads as \"named no rung\" rather than as\n // \"matches anything\".\n scopeRung: String(bundle['anticipation_scope_rung'] ?? '') || null,\n itemsByType,\n // 0 means \"use the SDK default\"; anything else is floored at 60s.\n ttlHintSeconds: ttlHint > 0 ? Math.max(ttlHint, MIN_TTL_SECONDS) : null,\n bundleType,\n searchQueries: [\n ...((bundle['search_queries'] as string[] | undefined) ?? []),\n ...((bundle['search_keywords'] as string[] | undefined) ?? []),\n ],\n });\n }\n\n async #handleDisconnect(_reason: string): Promise<void> {\n if (this.#shutdownRequested) return;\n\n this.#closeCall();\n this.#setState('reconnecting');\n\n if (this.#reconnectAttempts >= MAX_RECONNECT_ATTEMPTS) {\n this.#setState('disconnected');\n return;\n }\n\n // Jittered exponential backoff. The jitter matters with many SDK instances\n // behind one deploy: without it they all retry in lockstep.\n const delay = Math.min(\n BACKOFF_BASE_MS * 2 ** this.#reconnectAttempts + Math.random() * 1_000,\n BACKOFF_MAX_MS,\n );\n this.#reconnectAttempts += 1;\n\n await this.#sleep(delay);\n if (this.#shutdownRequested) return;\n try {\n await this.#establish();\n } catch {\n void this.#handleDisconnect('reconnect_failed');\n }\n }\n\n #startHeartbeat(): void {\n this.#heartbeatTimer = setInterval(() => {\n if (!this.isConnected || this.#call === null) return;\n const now = Date.now();\n\n if (now - this.#lastPongAt > HEARTBEAT_TIMEOUT_MS) {\n this.#missedHeartbeats += 1;\n if (this.#missedHeartbeats >= MAX_MISSED_HEARTBEATS) {\n void this.#handleDisconnect('heartbeat_timeout');\n return;\n }\n }\n try {\n this.#call.write({ heartbeat_ping: { timestamp_ms: now } });\n } catch {\n void this.#handleDisconnect('heartbeat_write_error');\n }\n }, HEARTBEAT_INTERVAL_MS);\n // Never hold the process open on the heartbeat alone: a CLI that finishes\n // its work should exit, not hang for 30s.\n this.#heartbeatTimer.unref?.();\n }\n\n #stopHeartbeat(): void {\n if (this.#heartbeatTimer !== null) {\n clearInterval(this.#heartbeatTimer);\n this.#heartbeatTimer = null;\n }\n }\n\n #closeCall(): void {\n try {\n this.#call?.end();\n } catch {\n /* already torn down */\n }\n this.#call = null;\n }\n\n #setState(state: StreamState): void {\n this.#state = state;\n this.#options.onStateChange?.(state);\n }\n}\n"]}
|
|
@@ -269,6 +269,89 @@ var anticipation_default = {
|
|
|
269
269
|
note: "Rejected items reported per lookup, highest score first, so a large cache cannot bloat the payload."
|
|
270
270
|
},
|
|
271
271
|
content_preview_chars: 120
|
|
272
|
+
},
|
|
273
|
+
rung_key: {
|
|
274
|
+
$comment: "SOURCE OF TRUTH for how a scope rung is written on the wire and compared in both SDK anticipation caches. The server stamps a pushed bundle with this string (ContextBundleProto.anticipation_scope_rung) and each SDK builds the same string from the `scope` path its own fetch names; a bundle is servable only when the two agree. Three implementations exist by necessity (server Python, SDK Python, SDK TypeScript) because the producer is not an SDK, so the vectors below are what stops them drifting.",
|
|
275
|
+
note: "Node ids are deliberately not what travels. They are registry surrogates and an SDK in a customer's process has never seen one; a caller names a rung with level keys and its own external ids, so that is the vocabulary the comparison happens in. Level keys are ^[a-z][a-z0-9_]{0,63}$ so they can hold neither separator and only the value needs escaping.",
|
|
276
|
+
separator: "|",
|
|
277
|
+
assign: "=",
|
|
278
|
+
sort: "by level key, ascending, plain codepoint order",
|
|
279
|
+
escapes: {
|
|
280
|
+
"\\": "\\\\",
|
|
281
|
+
"|": "\\p",
|
|
282
|
+
"=": "\\e"
|
|
283
|
+
},
|
|
284
|
+
escape_order: "backslash first. Reversing it makes `a|b` and `a\\pb` encode to the same string, which is a false match between two different rungs.",
|
|
285
|
+
absent: "null (an empty proto string on the wire) means the bundle or the request named no rung. Serving requires the two to be EQUAL, so absent matches only absent. That leaves every client without nested scoping byte-identical to today and refuses every genuinely cross-rung serve; the cost of the rule being wrong is a cold fetch, and the cost of a subset rule being wrong is one person's context handed to another.",
|
|
286
|
+
vectors: [
|
|
287
|
+
{
|
|
288
|
+
path: {},
|
|
289
|
+
key: null,
|
|
290
|
+
note: "no path named"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
path: {
|
|
294
|
+
customer: "acme"
|
|
295
|
+
},
|
|
296
|
+
key: "customer=acme"
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
path: {
|
|
300
|
+
customer: "acme",
|
|
301
|
+
team: "payments",
|
|
302
|
+
user: "dana"
|
|
303
|
+
},
|
|
304
|
+
key: "customer=acme|team=payments|user=dana"
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
path: {
|
|
308
|
+
user: "dana",
|
|
309
|
+
team: "payments",
|
|
310
|
+
customer: "acme"
|
|
311
|
+
},
|
|
312
|
+
key: "customer=acme|team=payments|user=dana",
|
|
313
|
+
note: "insertion order must not change the key; a dict has whatever order the caller wrote and ladder order is not available here"
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
path: {
|
|
317
|
+
customer: "a|b"
|
|
318
|
+
},
|
|
319
|
+
key: "customer=a\\pb"
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
path: {
|
|
323
|
+
customer: "a=b"
|
|
324
|
+
},
|
|
325
|
+
key: "customer=a\\eb"
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
path: {
|
|
329
|
+
customer: "a\\b"
|
|
330
|
+
},
|
|
331
|
+
key: "customer=a\\\\b"
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
path: {
|
|
335
|
+
customer: "a\\pb"
|
|
336
|
+
},
|
|
337
|
+
key: "customer=a\\\\pb",
|
|
338
|
+
note: "the escape-order case: this must NOT collide with a|b above"
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
path: {
|
|
342
|
+
customer: "ab"
|
|
343
|
+
},
|
|
344
|
+
key: "customer=ab"
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
path: {
|
|
348
|
+
customer: "a",
|
|
349
|
+
b: "c"
|
|
350
|
+
},
|
|
351
|
+
key: "b=c|customer=a",
|
|
352
|
+
note: "sorted by key, so `customer=ab` and this cannot collapse"
|
|
353
|
+
}
|
|
354
|
+
]
|
|
272
355
|
}
|
|
273
356
|
};
|
|
274
357
|
|
|
@@ -395,6 +478,25 @@ var QUERY_TOKEN_SCALE = CONTRACT.thresholds.query_token_scale.value;
|
|
|
395
478
|
var REJECTED_CAP = CONTRACT.telemetry.rejected_items_cap.value;
|
|
396
479
|
var PREVIEW_CHARS = CONTRACT.telemetry.content_preview_chars;
|
|
397
480
|
var ANY_SCOPE = "_any";
|
|
481
|
+
var RUNG_SEPARATOR = "|";
|
|
482
|
+
var RUNG_ASSIGN = "=";
|
|
483
|
+
function rungKey(scopePath) {
|
|
484
|
+
if (!scopePath) return null;
|
|
485
|
+
const pairs = [];
|
|
486
|
+
for (const [k, v] of Object.entries(scopePath)) {
|
|
487
|
+
if (k === "" || v === null || v === void 0 || String(v) === "") continue;
|
|
488
|
+
pairs.push([String(k), String(v)]);
|
|
489
|
+
}
|
|
490
|
+
if (pairs.length === 0) return null;
|
|
491
|
+
pairs.sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
|
|
492
|
+
return pairs.map(([k, v]) => {
|
|
493
|
+
const escaped = v.split("\\").join("\\\\").split(RUNG_SEPARATOR).join("\\p").split(RUNG_ASSIGN).join("\\e");
|
|
494
|
+
return `${k}${RUNG_ASSIGN}${escaped}`;
|
|
495
|
+
}).join(RUNG_SEPARATOR);
|
|
496
|
+
}
|
|
497
|
+
function rungServes(bundleRung, requestRung) {
|
|
498
|
+
return (bundleRung || null) === (requestRung || null);
|
|
499
|
+
}
|
|
398
500
|
var DEFAULT_TTL_SECONDS = 1800;
|
|
399
501
|
var DEFAULT_MAX_BUNDLES = 50;
|
|
400
502
|
var AnticipationCache = class {
|
|
@@ -433,7 +535,8 @@ var AnticipationCache = class {
|
|
|
433
535
|
searchQueries: [...bundle.searchQueries ?? []],
|
|
434
536
|
storedAt: now,
|
|
435
537
|
createdAt: now,
|
|
436
|
-
ttlHintSeconds: bundle.ttlHintSeconds ?? null
|
|
538
|
+
ttlHintSeconds: bundle.ttlHintSeconds ?? null,
|
|
539
|
+
scopeRung: bundle.scopeRung || null
|
|
437
540
|
});
|
|
438
541
|
for (const [itemType, list] of Object.entries(bundle.itemsByType ?? {})) {
|
|
439
542
|
for (const item of list ?? []) {
|
|
@@ -460,6 +563,7 @@ var AnticipationCache = class {
|
|
|
460
563
|
customerId = null,
|
|
461
564
|
clientId = null,
|
|
462
565
|
conversationId = null,
|
|
566
|
+
scopeRung = null,
|
|
463
567
|
maxItems = 10
|
|
464
568
|
} = params;
|
|
465
569
|
this.evictExpired();
|
|
@@ -470,6 +574,7 @@ var AnticipationCache = class {
|
|
|
470
574
|
customerId,
|
|
471
575
|
clientId,
|
|
472
576
|
conversationId,
|
|
577
|
+
scopeRung: scopeRung ?? null,
|
|
473
578
|
scopeFilterAccepted: [...accepted].sort(),
|
|
474
579
|
novelTermRatio: null,
|
|
475
580
|
bm25Threshold: null,
|
|
@@ -485,7 +590,7 @@ var AnticipationCache = class {
|
|
|
485
590
|
}
|
|
486
591
|
const hasQuery = (searchQuery ?? []).some((q) => q && q.trim() !== "");
|
|
487
592
|
if (!hasQuery) {
|
|
488
|
-
return this.freshnessLookup(entityId, maxItems, telemetry);
|
|
593
|
+
return this.freshnessLookup(entityId, scopeRung ?? null, maxItems, telemetry);
|
|
489
594
|
}
|
|
490
595
|
if (getEnvFlag(CONTRACT.recall_bypass.env_flag) && isRecallQuery(searchQuery)) {
|
|
491
596
|
return this.miss(telemetry, "recall_bypass");
|
|
@@ -509,7 +614,7 @@ var AnticipationCache = class {
|
|
|
509
614
|
this.bm25Dirty = false;
|
|
510
615
|
}
|
|
511
616
|
const scores = this.bm25.scores(queryTokens);
|
|
512
|
-
const validBundles = this.getValidBundleIds(accepted, conversationId);
|
|
617
|
+
const validBundles = this.getValidBundleIds(accepted, conversationId, scopeRung ?? null);
|
|
513
618
|
const effectiveThreshold = Math.max(
|
|
514
619
|
EFFECTIVE_FLOOR,
|
|
515
620
|
Math.min(THRESHOLDS.bm25, QUERY_TOKEN_SCALE * queryTokens.length)
|
|
@@ -683,12 +788,13 @@ var AnticipationCache = class {
|
|
|
683
788
|
* for exactly that reason: the permissive version could splice user A's
|
|
684
789
|
* summary into user B's response on the conversation-scope path.
|
|
685
790
|
*/
|
|
686
|
-
lookupUserSummary(entityId) {
|
|
791
|
+
lookupUserSummary(entityId, scopeRung = null) {
|
|
687
792
|
if (!entityId) return null;
|
|
688
793
|
this.evictExpired();
|
|
689
794
|
let freshest = null;
|
|
690
795
|
for (const entry of this.entries.values()) {
|
|
691
796
|
if (entry.bundleType !== "user_summary") continue;
|
|
797
|
+
if (!rungServes(entry.scopeRung, scopeRung)) continue;
|
|
692
798
|
if (entry.entityId !== entityId && entry.entityId !== ANY_SCOPE) continue;
|
|
693
799
|
if (freshest === null || entry.storedAt > freshest.storedAt) freshest = entry;
|
|
694
800
|
}
|
|
@@ -749,8 +855,8 @@ var AnticipationCache = class {
|
|
|
749
855
|
} catch {
|
|
750
856
|
}
|
|
751
857
|
}
|
|
752
|
-
freshnessLookup(entityId, maxItems, telemetry) {
|
|
753
|
-
const candidates = [...this.entries.values()].filter((e) => entityId === null || e.entityId === entityId || e.entityId === ANY_SCOPE).sort((a, b) => b.storedAt - a.storedAt);
|
|
858
|
+
freshnessLookup(entityId, scopeRung, maxItems, telemetry) {
|
|
859
|
+
const candidates = [...this.entries.values()].filter((e) => rungServes(e.scopeRung, scopeRung)).filter((e) => entityId === null || e.entityId === entityId || e.entityId === ANY_SCOPE).sort((a, b) => b.storedAt - a.storedAt);
|
|
754
860
|
if (candidates.length === 0) return this.miss(telemetry, "empty");
|
|
755
861
|
const newest = candidates[0];
|
|
756
862
|
const itemsByType = {};
|
|
@@ -781,9 +887,17 @@ var AnticipationCache = class {
|
|
|
781
887
|
if (clientId) accepted.add(clientId);
|
|
782
888
|
return accepted;
|
|
783
889
|
}
|
|
784
|
-
|
|
890
|
+
/**
|
|
891
|
+
* The rung is checked FIRST and it never widens. Everything else here widens
|
|
892
|
+
* deliberately: a user-scope request reaches customer-shared bundles, and a
|
|
893
|
+
* conversation-scope request reaches user-scope ones. A rung is the opposite
|
|
894
|
+
* kind of thing, so it is checked before the tiers and no amount of widening
|
|
895
|
+
* can put a cross-rung bundle back in.
|
|
896
|
+
*/
|
|
897
|
+
getValidBundleIds(accepted, conversationId, scopeRung) {
|
|
785
898
|
const valid = /* @__PURE__ */ new Set();
|
|
786
899
|
for (const entry of this.entries.values()) {
|
|
900
|
+
if (!rungServes(entry.scopeRung, scopeRung)) continue;
|
|
787
901
|
if (!accepted.has(entry.entityId)) continue;
|
|
788
902
|
if (entry.conversationId && conversationId && entry.conversationId !== conversationId) continue;
|
|
789
903
|
valid.add(entry.bundleId);
|
|
@@ -827,6 +941,8 @@ export {
|
|
|
827
941
|
tokenize,
|
|
828
942
|
BM25,
|
|
829
943
|
ANY_SCOPE,
|
|
944
|
+
rungKey,
|
|
945
|
+
rungServes,
|
|
830
946
|
AnticipationCache
|
|
831
947
|
};
|
|
832
|
-
//# sourceMappingURL=chunk-
|
|
948
|
+
//# sourceMappingURL=chunk-ODVOQOSO.js.map
|