@anuma/sdk 10.9.0 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/expo/{consolidate-7QUL3TOE.mjs → consolidate-QBV3DDHU.mjs} +1 -1
- package/dist/expo/index.cjs +3446 -2649
- package/dist/expo/index.d.mts +967 -873
- package/dist/expo/index.d.ts +967 -873
- package/dist/expo/index.mjs +2966 -2177
- package/dist/react/index.cjs +1186 -684
- package/dist/react/index.d.mts +720 -715
- package/dist/react/index.d.ts +720 -715
- package/dist/react/index.mjs +1182 -684
- package/dist/server/index.cjs +19 -13
- package/dist/server/index.d.mts +4 -2
- package/dist/server/index.d.ts +4 -2
- package/dist/server/index.mjs +19 -13
- package/package.json +1 -1
- package/dist/expo/{chunk-4SOUKJD5.mjs → chunk-VNTEHEGI.mjs} +957 -957
package/dist/expo/index.d.mts
CHANGED
|
@@ -1668,34 +1668,126 @@ declare function buildAttachedFilesText(fileContext: string): string;
|
|
|
1668
1668
|
*/
|
|
1669
1669
|
declare function attachFileContextToLastUserMessage(messages: LlmapiMessage[], fileContext: string): LlmapiMessage[];
|
|
1670
1670
|
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
type
|
|
1676
|
-
|
|
1671
|
+
type LlmTokenUsage = {
|
|
1672
|
+
inputTokens?: number;
|
|
1673
|
+
outputTokens?: number;
|
|
1674
|
+
};
|
|
1675
|
+
type ModelCallStartEvent = {
|
|
1676
|
+
runId: string;
|
|
1677
|
+
stepIndex: number;
|
|
1678
|
+
model: string;
|
|
1679
|
+
messages: Array<LlmapiMessage>;
|
|
1680
|
+
tools: Array<LlmapiChatCompletionTool>;
|
|
1681
|
+
requestBody: Record<string, unknown>;
|
|
1682
|
+
};
|
|
1683
|
+
type ModelCallEndEvent = {
|
|
1684
|
+
runId: string;
|
|
1685
|
+
stepIndex: number;
|
|
1686
|
+
content: string;
|
|
1687
|
+
toolCalls: Array<{
|
|
1688
|
+
id: string;
|
|
1689
|
+
name: string;
|
|
1690
|
+
arguments: string;
|
|
1691
|
+
}>;
|
|
1692
|
+
usage?: LlmTokenUsage;
|
|
1693
|
+
finishReason?: string;
|
|
1694
|
+
error?: string;
|
|
1695
|
+
};
|
|
1696
|
+
type ToolUseStartEvent = {
|
|
1697
|
+
runId: string;
|
|
1698
|
+
stepIndex: number;
|
|
1699
|
+
toolCallId: string;
|
|
1700
|
+
name: string;
|
|
1701
|
+
rawArguments: string;
|
|
1702
|
+
parsedArguments?: Record<string, unknown>;
|
|
1703
|
+
};
|
|
1704
|
+
type ToolUseEndEvent = {
|
|
1705
|
+
runId: string;
|
|
1706
|
+
stepIndex: number;
|
|
1707
|
+
toolCallId: string;
|
|
1708
|
+
name: string;
|
|
1709
|
+
result?: unknown;
|
|
1710
|
+
error?: string;
|
|
1711
|
+
errorType?: "parse" | "timeout" | "execution" | "cancelled";
|
|
1712
|
+
};
|
|
1713
|
+
type RunStartEvent = {
|
|
1714
|
+
runId: string;
|
|
1715
|
+
model: string;
|
|
1716
|
+
messages: Array<LlmapiMessage>;
|
|
1717
|
+
tools: Array<LlmapiChatCompletionTool>;
|
|
1718
|
+
};
|
|
1719
|
+
type RunEndEvent = {
|
|
1720
|
+
runId: string;
|
|
1721
|
+
finalContent: string;
|
|
1722
|
+
/** Number of LLM rounds executed. */
|
|
1723
|
+
totalSteps: number;
|
|
1724
|
+
};
|
|
1725
|
+
type RunErrorEvent = {
|
|
1726
|
+
runId: string;
|
|
1727
|
+
error: string;
|
|
1677
1728
|
/**
|
|
1678
|
-
* `
|
|
1679
|
-
* `
|
|
1680
|
-
*
|
|
1729
|
+
* Only `"model"` today. Tool failures surface on {@link RunHooks.afterToolUse}
|
|
1730
|
+
* with `errorType`, not on `onRunError`, so a tool stage isn't needed yet.
|
|
1731
|
+
* Left as a union to leave room for `"validation"` or `"tool"` later
|
|
1732
|
+
* without a breaking change.
|
|
1681
1733
|
*/
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
/**
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1734
|
+
stage: "model";
|
|
1735
|
+
/**
|
|
1736
|
+
* The underlying `Error` when one is available. `RunErrorEvent` predates
|
|
1737
|
+
* this field, so `error` (a string message) is kept for backwards
|
|
1738
|
+
* compatibility; new consumers should prefer `errorObject` when present
|
|
1739
|
+
* for stack traces and `cause`.
|
|
1740
|
+
*/
|
|
1741
|
+
errorObject?: Error;
|
|
1742
|
+
};
|
|
1743
|
+
type RunHooks = {
|
|
1744
|
+
/**
|
|
1745
|
+
* Fires once per `runToolLoop` invocation, before any pre-processor or
|
|
1746
|
+
* model call. The `messages` payload is the raw caller-supplied
|
|
1747
|
+
* conversation — pre-processors that enrich it (e.g. web search context)
|
|
1748
|
+
* run afterwards, so `beforeModelCall.messages` reflects the
|
|
1749
|
+
* post-enrichment state.
|
|
1750
|
+
*/
|
|
1751
|
+
onRunStart?: (e: RunStartEvent) => Promise<void> | void;
|
|
1752
|
+
/**
|
|
1753
|
+
* Fires exactly once per run on clean completion. Mutually exclusive
|
|
1754
|
+
* with `onRunError` — a run that completes fires `onRunEnd`; a run that
|
|
1755
|
+
* errors or is aborted fires `onRunError`. Consumers can rely on
|
|
1756
|
+
* exactly one terminal hook per `onRunStart`.
|
|
1757
|
+
*/
|
|
1758
|
+
onRunEnd?: (e: RunEndEvent) => Promise<void> | void;
|
|
1759
|
+
/**
|
|
1760
|
+
* Fires exactly once per run when the loop errors or is aborted.
|
|
1761
|
+
* `stage` is `"model"` for stream/provider errors and for aborts;
|
|
1762
|
+
* tool execution failures surface as structured `{ error, errorType }`
|
|
1763
|
+
* results on `afterToolUse` rather than firing `onRunError`.
|
|
1764
|
+
* Mutually exclusive with `onRunEnd`.
|
|
1765
|
+
*/
|
|
1766
|
+
onRunError?: (e: RunErrorEvent) => Promise<void> | void;
|
|
1767
|
+
beforeModelCall?: (e: ModelCallStartEvent) => Promise<void> | void;
|
|
1768
|
+
afterModelCall?: (e: ModelCallEndEvent) => Promise<void> | void;
|
|
1769
|
+
/**
|
|
1770
|
+
* Fires before each tool the model invoked — including server-side
|
|
1771
|
+
* tools that have no client executor. Today this is observe-only.
|
|
1772
|
+
* TODO(follow-up PR): allow returning { args?, abort?: { reason } } to
|
|
1773
|
+
* mutate arguments or short-circuit the tool call.
|
|
1774
|
+
*
|
|
1775
|
+
* Pairing with {@link afterToolUse} is asymmetric: server-side tools
|
|
1776
|
+
* routed via `onToolCall` get `beforeToolUse` but no `afterToolUse`,
|
|
1777
|
+
* because they don't execute in-process. Tools blocked by a failed
|
|
1778
|
+
* dependency or a dependency cycle DO get `afterToolUse` with
|
|
1779
|
+
* `errorType: "execution"` — consumers tallying matched pairs should
|
|
1780
|
+
* filter on executor-backed tools to avoid spurious imbalances.
|
|
1781
|
+
*/
|
|
1782
|
+
beforeToolUse?: (e: ToolUseStartEvent) => Promise<void> | void;
|
|
1783
|
+
/**
|
|
1784
|
+
* Fires after each executor-backed tool finishes (success or failure)
|
|
1785
|
+
* and after each dependency-blocked tool is skipped (`errorType:
|
|
1786
|
+
* "execution"`). Does NOT fire for server-side tools routed via
|
|
1787
|
+
* `onToolCall`. See {@link beforeToolUse} for the pairing contract.
|
|
1788
|
+
*/
|
|
1789
|
+
afterToolUse?: (e: ToolUseEndEvent) => Promise<void> | void;
|
|
1696
1790
|
};
|
|
1697
|
-
/** One receipt per kind for the turn's booking and cancel calls, holding the last attempt's outcome unless an earlier one was `made` or `unknown`. */
|
|
1698
|
-
declare function extractReservationReceipts(toolCallEvents?: LlmapiToolCallEvent[]): ReservationReceipt[];
|
|
1699
1791
|
|
|
1700
1792
|
/**
|
|
1701
1793
|
* PII detection patterns for structured data types.
|
|
@@ -2051,166 +2143,232 @@ declare function createStreamingDeAnonymizer(redactor: PiiRedactor, emit: (chunk
|
|
|
2051
2143
|
flush: () => void;
|
|
2052
2144
|
};
|
|
2053
2145
|
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2146
|
+
/**
|
|
2147
|
+
* Configuration for stream output smoothing.
|
|
2148
|
+
*
|
|
2149
|
+
* Controls the adaptive speed ramp that meters out streaming text
|
|
2150
|
+
* at a consistent pace regardless of how fast the model produces tokens.
|
|
2151
|
+
*/
|
|
2152
|
+
type StreamSmoothingConfig = {
|
|
2153
|
+
/** Whether smoothing is enabled. Default: true */
|
|
2154
|
+
enabled: boolean;
|
|
2155
|
+
/** Minimum chars/sec at the start of streaming. Default: 60 */
|
|
2156
|
+
minSpeed?: number;
|
|
2157
|
+
/** Maximum chars/sec after ramp completes. Default: 600 */
|
|
2158
|
+
maxSpeed?: number;
|
|
2159
|
+
/** Duration in ms to ramp from minSpeed to maxSpeed. Default: 4000 */
|
|
2160
|
+
rampDuration?: number;
|
|
2057
2161
|
};
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2162
|
+
|
|
2163
|
+
/**
|
|
2164
|
+
* Server tool call event emitted during streaming
|
|
2165
|
+
*/
|
|
2166
|
+
type ServerToolCallEvent = {
|
|
2167
|
+
/** Tool name (e.g., "BraveSearchMCP_brave_web_search") */
|
|
2168
|
+
name: string;
|
|
2169
|
+
/** Status: "started" when tool begins, "completed" when done */
|
|
2170
|
+
status: "started" | "completed";
|
|
2171
|
+
/** Arguments passed to the tool (JSON string) */
|
|
2172
|
+
arguments?: string;
|
|
2065
2173
|
};
|
|
2066
|
-
|
|
2067
|
-
|
|
2174
|
+
/**
|
|
2175
|
+
* Result from processing a streaming chunk
|
|
2176
|
+
*/
|
|
2177
|
+
/** Event emitted when tool call arguments are being streamed. */
|
|
2178
|
+
type ToolCallArgumentsDeltaEvent = {
|
|
2179
|
+
toolCallId: string;
|
|
2180
|
+
toolName: string;
|
|
2181
|
+
argumentsDelta: string;
|
|
2182
|
+
accumulatedArguments: string;
|
|
2183
|
+
};
|
|
2184
|
+
type ToolExecutionErrorType = "parse" | "timeout" | "execution" | "cancelled";
|
|
2185
|
+
|
|
2186
|
+
/** A tool result from an auto-executed tool. */
|
|
2187
|
+
type AutoExecutedToolResult = {
|
|
2188
|
+
name: string;
|
|
2189
|
+
result: unknown;
|
|
2190
|
+
};
|
|
2191
|
+
/** Information emitted after each tool execution round completes. */
|
|
2192
|
+
type StepFinishEvent = {
|
|
2193
|
+
/** 1-based index of this tool round. */
|
|
2068
2194
|
stepIndex: number;
|
|
2195
|
+
/** Text content the model produced in this round (may be empty if the model only called tools). */
|
|
2069
2196
|
content: string;
|
|
2197
|
+
/** Tool calls the model made in this round. */
|
|
2070
2198
|
toolCalls: Array<{
|
|
2071
|
-
id: string;
|
|
2072
2199
|
name: string;
|
|
2073
2200
|
arguments: string;
|
|
2074
2201
|
}>;
|
|
2075
|
-
|
|
2202
|
+
/** Results from auto-executed tools in this round. */
|
|
2203
|
+
toolResults: Array<{
|
|
2204
|
+
name: string;
|
|
2205
|
+
result: unknown;
|
|
2206
|
+
error?: string;
|
|
2207
|
+
errorType?: ToolExecutionErrorType;
|
|
2208
|
+
}>;
|
|
2209
|
+
/** Token usage for this round, if available. */
|
|
2210
|
+
usage: {
|
|
2211
|
+
inputTokens?: number;
|
|
2212
|
+
outputTokens?: number;
|
|
2213
|
+
};
|
|
2214
|
+
/**
|
|
2215
|
+
* The round's own finish reason, as the provider sent it — `"length"` means
|
|
2216
|
+
* this round hit the output ceiling.
|
|
2217
|
+
*
|
|
2218
|
+
* Per-round, not per-turn: a round can truncate and the loop still recover on
|
|
2219
|
+
* the next one, which is why the loop does not treat it as an error on its
|
|
2220
|
+
* own (see the truncation guard below). Without it a consumer watching steps
|
|
2221
|
+
* cannot tell a round that said everything it meant to from one that was cut
|
|
2222
|
+
* off mid-argument — they differ only in this field (#805).
|
|
2223
|
+
*
|
|
2224
|
+
* Absent when the provider sent no finish reason. Note that no step event
|
|
2225
|
+
* fires for the round that *ends* a turn, so use {@link RunTerminalState} on
|
|
2226
|
+
* the result for the final round.
|
|
2227
|
+
*/
|
|
2076
2228
|
finishReason?: string;
|
|
2077
|
-
error?: string;
|
|
2078
|
-
};
|
|
2079
|
-
type ToolUseStartEvent = {
|
|
2080
|
-
runId: string;
|
|
2081
|
-
stepIndex: number;
|
|
2082
|
-
toolCallId: string;
|
|
2083
|
-
name: string;
|
|
2084
|
-
rawArguments: string;
|
|
2085
|
-
parsedArguments?: Record<string, unknown>;
|
|
2086
|
-
};
|
|
2087
|
-
type ToolUseEndEvent = {
|
|
2088
|
-
runId: string;
|
|
2089
|
-
stepIndex: number;
|
|
2090
|
-
toolCallId: string;
|
|
2091
|
-
name: string;
|
|
2092
|
-
result?: unknown;
|
|
2093
|
-
error?: string;
|
|
2094
|
-
errorType?: "parse" | "timeout" | "execution" | "cancelled";
|
|
2095
2229
|
};
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2230
|
+
/**
|
|
2231
|
+
* Terminal state of the LAST model response in the turn, normalized to the
|
|
2232
|
+
* completions vocabulary (`"stop"` | `"length"` | `"tool_calls"` | provider-
|
|
2233
|
+
* specific values). `undefined` when the stream carried no finish reason at all.
|
|
2234
|
+
*
|
|
2235
|
+
* Exposed because neither response shape reliably carries it out to a caller.
|
|
2236
|
+
* The Responses shape now carries `status` / `incomplete_details` — added in
|
|
2237
|
+
* `clientCompat` and emitted by `buildFinalResponse` — but only in the
|
|
2238
|
+
* Responses vocabulary, so a caller reading it has to translate
|
|
2239
|
+
* `incomplete_details.reason === "max_output_tokens"` itself. Completions
|
|
2240
|
+
* exposes `choices[0].finish_reason`, but omits `tool_calls` entirely when
|
|
2241
|
+
* there are none, so a caller sniffing the response cannot tell "no tool calls"
|
|
2242
|
+
* from "field absent". This field answers both questions in one vocabulary,
|
|
2243
|
+
* for either transport.
|
|
2244
|
+
*
|
|
2245
|
+
* The loop already knows both, unambiguously and identically for either API.
|
|
2246
|
+
* Reporting them here means callers and test harnesses stop reverse-engineering
|
|
2247
|
+
* them from a response shape that cannot answer. See anuma-ai/sdk#805.
|
|
2248
|
+
*/
|
|
2249
|
+
type RunTerminalState = {
|
|
2250
|
+
/** Normalized finish reason of the final response. `"length"` means the output
|
|
2251
|
+
* ceiling cut it off; anything else means the model stopped on its own. */
|
|
2252
|
+
finishReason?: string;
|
|
2253
|
+
/** Tool calls the final response carried. `0` is meaningful — combined with
|
|
2254
|
+
* empty content it identifies a turn that ended having produced nothing. */
|
|
2255
|
+
finalToolCallCount: number;
|
|
2107
2256
|
};
|
|
2108
|
-
type
|
|
2109
|
-
|
|
2257
|
+
type RunToolLoopResult = {
|
|
2258
|
+
data: ApiResponse;
|
|
2259
|
+
error: null;
|
|
2260
|
+
/** Checksum of tools used to generate this response */
|
|
2261
|
+
toolsChecksum?: string;
|
|
2262
|
+
/** Results from tools that were auto-executed by the SDK */
|
|
2263
|
+
autoExecutedToolResults?: AutoExecutedToolResult[];
|
|
2264
|
+
/** Terminal state of the final model response. See {@link RunTerminalState}. */
|
|
2265
|
+
terminalState?: RunTerminalState;
|
|
2266
|
+
} | {
|
|
2267
|
+
data: ApiResponse | null;
|
|
2110
2268
|
error: string;
|
|
2269
|
+
/** HTTP status code from the SSE connection, if available */
|
|
2270
|
+
statusCode?: number;
|
|
2271
|
+
/** Checksum of tools used to generate this response */
|
|
2272
|
+
toolsChecksum?: string;
|
|
2273
|
+
/** True when the loop exited via detachSignal. `error` is "Request detached". */
|
|
2274
|
+
detached?: true;
|
|
2275
|
+
/** Non-null only when `resumable` was true AND an inference id was captured before detach. */
|
|
2276
|
+
resume?: StreamResumeHandle | null;
|
|
2277
|
+
/** True when the connection failed rather than the generation: the portal may still be generating. */
|
|
2278
|
+
connectionLost?: true;
|
|
2111
2279
|
/**
|
|
2112
|
-
*
|
|
2113
|
-
*
|
|
2114
|
-
*
|
|
2115
|
-
* without a breaking change.
|
|
2116
|
-
*/
|
|
2117
|
-
stage: "model";
|
|
2118
|
-
/**
|
|
2119
|
-
* The underlying `Error` when one is available. `RunErrorEvent` predates
|
|
2120
|
-
* this field, so `error` (a string message) is kept for backwards
|
|
2121
|
-
* compatibility; new consumers should prefer `errorObject` when present
|
|
2122
|
-
* for stack traces and `cause`.
|
|
2123
|
-
*/
|
|
2124
|
-
errorObject?: Error;
|
|
2125
|
-
};
|
|
2126
|
-
type RunHooks = {
|
|
2127
|
-
/**
|
|
2128
|
-
* Fires once per `runToolLoop` invocation, before any pre-processor or
|
|
2129
|
-
* model call. The `messages` payload is the raw caller-supplied
|
|
2130
|
-
* conversation — pre-processors that enrich it (e.g. web search context)
|
|
2131
|
-
* run afterwards, so `beforeModelCall.messages` reflects the
|
|
2132
|
-
* post-enrichment state.
|
|
2133
|
-
*/
|
|
2134
|
-
onRunStart?: (e: RunStartEvent) => Promise<void> | void;
|
|
2135
|
-
/**
|
|
2136
|
-
* Fires exactly once per run on clean completion. Mutually exclusive
|
|
2137
|
-
* with `onRunError` — a run that completes fires `onRunEnd`; a run that
|
|
2138
|
-
* errors or is aborted fires `onRunError`. Consumers can rely on
|
|
2139
|
-
* exactly one terminal hook per `onRunStart`.
|
|
2140
|
-
*/
|
|
2141
|
-
onRunEnd?: (e: RunEndEvent) => Promise<void> | void;
|
|
2142
|
-
/**
|
|
2143
|
-
* Fires exactly once per run when the loop errors or is aborted.
|
|
2144
|
-
* `stage` is `"model"` for stream/provider errors and for aborts;
|
|
2145
|
-
* tool execution failures surface as structured `{ error, errorType }`
|
|
2146
|
-
* results on `afterToolUse` rather than firing `onRunError`.
|
|
2147
|
-
* Mutually exclusive with `onRunEnd`.
|
|
2148
|
-
*/
|
|
2149
|
-
onRunError?: (e: RunErrorEvent) => Promise<void> | void;
|
|
2150
|
-
beforeModelCall?: (e: ModelCallStartEvent) => Promise<void> | void;
|
|
2151
|
-
afterModelCall?: (e: ModelCallEndEvent) => Promise<void> | void;
|
|
2152
|
-
/**
|
|
2153
|
-
* Fires before each tool the model invoked — including server-side
|
|
2154
|
-
* tools that have no client executor. Today this is observe-only.
|
|
2155
|
-
* TODO(follow-up PR): allow returning { args?, abort?: { reason } } to
|
|
2156
|
-
* mutate arguments or short-circuit the tool call.
|
|
2280
|
+
* Terminal state of the final model response, when the failure is one the
|
|
2281
|
+
* loop diagnosed FROM that response — today, the truncated-to-nothing
|
|
2282
|
+
* error. See {@link RunTerminalState}.
|
|
2157
2283
|
*
|
|
2158
|
-
*
|
|
2159
|
-
*
|
|
2160
|
-
*
|
|
2161
|
-
*
|
|
2162
|
-
* `
|
|
2163
|
-
* filter on executor-backed tools to avoid spurious imbalances.
|
|
2164
|
-
*/
|
|
2165
|
-
beforeToolUse?: (e: ToolUseStartEvent) => Promise<void> | void;
|
|
2166
|
-
/**
|
|
2167
|
-
* Fires after each executor-backed tool finishes (success or failure)
|
|
2168
|
-
* and after each dependency-blocked tool is skipped (`errorType:
|
|
2169
|
-
* "execution"`). Does NOT fire for server-side tools routed via
|
|
2170
|
-
* `onToolCall`. See {@link beforeToolUse} for the pairing contract.
|
|
2284
|
+
* Absent on failures that never got a terminal response to read (transport
|
|
2285
|
+
* errors, detach, an SSE failure mid-stream), which is why it stays
|
|
2286
|
+
* optional here. Present on the truncation error specifically because that
|
|
2287
|
+
* is where it is most diagnostic: a caller can branch on
|
|
2288
|
+
* `finishReason === "length"` instead of matching the error string.
|
|
2171
2289
|
*/
|
|
2172
|
-
|
|
2290
|
+
terminalState?: RunTerminalState;
|
|
2173
2291
|
};
|
|
2174
|
-
|
|
2292
|
+
/** Capability header: tells the portal this client can resume a detached stream. Pinned with zeta-chain/ai-portal#1139. */
|
|
2293
|
+
declare const STREAM_RESUMABLE_HEADER = "X-Stream-Resumable";
|
|
2294
|
+
/** Response header carrying the per-request stream id, issued by the portal pre-stream. */
|
|
2295
|
+
declare const INFERENCE_ID_HEADER = "X-Inference-ID";
|
|
2175
2296
|
/**
|
|
2176
|
-
*
|
|
2177
|
-
*
|
|
2178
|
-
* Controls the adaptive speed ramp that meters out streaming text
|
|
2179
|
-
* at a consistent pace regardless of how fast the model produces tokens.
|
|
2297
|
+
* Everything resumeStream() needs to replay a detached stream.
|
|
2298
|
+
* @public
|
|
2180
2299
|
*/
|
|
2181
|
-
type
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
rampDuration?: number;
|
|
2300
|
+
type StreamResumeHandle = {
|
|
2301
|
+
inferenceId: string;
|
|
2302
|
+
/** The reply id the storage hook writes this turn's answer under, when it chose one. */
|
|
2303
|
+
assistantMessageId?: string;
|
|
2304
|
+
/** The RESOLVED api type (never "auto") — resolveApiType() already ran inside runToolLoop. */
|
|
2305
|
+
apiType: Exclude<ApiType, "auto">;
|
|
2306
|
+
model?: string;
|
|
2307
|
+
conversationId?: string;
|
|
2190
2308
|
};
|
|
2191
|
-
|
|
2192
2309
|
/**
|
|
2193
|
-
*
|
|
2310
|
+
* Payload for RunToolLoopOptions.onStreamMeta.
|
|
2311
|
+
* @public
|
|
2194
2312
|
*/
|
|
2195
|
-
type
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2313
|
+
type StreamMetaEvent = {
|
|
2314
|
+
inferenceId: string;
|
|
2315
|
+
/** 0 = initial request, 1+ = continuation round (same numbering as RequestEvent.round). */
|
|
2316
|
+
round: number;
|
|
2317
|
+
};
|
|
2318
|
+
/** Options passed to a streaming transport function. */
|
|
2319
|
+
type StreamingTransportOptions = {
|
|
2320
|
+
baseUrl: string;
|
|
2321
|
+
endpoint: string;
|
|
2322
|
+
/** @default "POST" */
|
|
2323
|
+
method?: "GET" | "POST";
|
|
2324
|
+
/** Request body. Optional — GET resume requests have no body. */
|
|
2325
|
+
body?: Record<string, unknown>;
|
|
2326
|
+
token?: string;
|
|
2327
|
+
headers?: Record<string, string>;
|
|
2328
|
+
signal?: AbortSignal;
|
|
2329
|
+
onSseError?: (error: unknown) => void;
|
|
2330
|
+
/** Fires once per request when response headers arrive with X-Inference-ID (2xx only). */
|
|
2331
|
+
onStreamMeta?: (meta: {
|
|
2332
|
+
inferenceId: string;
|
|
2333
|
+
}) => void;
|
|
2334
|
+
/**
|
|
2335
|
+
* Fires when the transport receives bytes, including SSE keep-alive comments.
|
|
2336
|
+
* Consumers can use this callback to reset the idle timeout.
|
|
2337
|
+
* The fetch and XHR transports emit it.
|
|
2338
|
+
* Custom transports can omit it if they cannot report byte activity.
|
|
2339
|
+
*/
|
|
2340
|
+
onActivity?: () => void;
|
|
2341
|
+
};
|
|
2342
|
+
/** Result returned by a streaming transport function. */
|
|
2343
|
+
type StreamingTransportResult = {
|
|
2344
|
+
stream: AsyncIterable<unknown>;
|
|
2202
2345
|
};
|
|
2203
2346
|
/**
|
|
2204
|
-
*
|
|
2347
|
+
* A pluggable transport function for streaming SSE requests.
|
|
2348
|
+
* The default uses `fetch` + `ReadableStream`. React Native environments
|
|
2349
|
+
* can supply an XHR-based transport instead.
|
|
2350
|
+
*
|
|
2351
|
+
* ### Abort contract
|
|
2352
|
+
*
|
|
2353
|
+
* When `options.signal` aborts **mid-stream**, the returned async iterable
|
|
2354
|
+
* MUST surface an `AbortError` (an `Error` whose `name === "AbortError"`)
|
|
2355
|
+
* to its consumer — either by throwing from the iterator, or by causing
|
|
2356
|
+
* the underlying `read()` to reject. It MUST NOT terminate the iterable
|
|
2357
|
+
* with an orderly `done` in that case.
|
|
2358
|
+
*
|
|
2359
|
+
* `runToolLoop` relies on this to distinguish two scenarios that are
|
|
2360
|
+
* otherwise indistinguishable from outside the transport:
|
|
2361
|
+
* 1. The server closed the connection cleanly and every byte was
|
|
2362
|
+
* delivered → iterable returns `done`, result is success.
|
|
2363
|
+
* 2. The caller aborted the request mid-stream → iterable throws
|
|
2364
|
+
* `AbortError`, result is `{ data: <partial>, error: "Request aborted" }`.
|
|
2365
|
+
*
|
|
2366
|
+
* Transports that swallow mid-stream aborts and yield `done` instead
|
|
2367
|
+
* will cause a partial response to be reported as a successful
|
|
2368
|
+
* completion. The built-in `xhrTransport` and the default fetch-based
|
|
2369
|
+
* transport both honor this contract.
|
|
2205
2370
|
*/
|
|
2206
|
-
|
|
2207
|
-
type ToolCallArgumentsDeltaEvent = {
|
|
2208
|
-
toolCallId: string;
|
|
2209
|
-
toolName: string;
|
|
2210
|
-
argumentsDelta: string;
|
|
2211
|
-
accumulatedArguments: string;
|
|
2212
|
-
};
|
|
2213
|
-
type ToolExecutionErrorType = "parse" | "timeout" | "execution" | "cancelled";
|
|
2371
|
+
type StreamingTransport = (options: StreamingTransportOptions) => StreamingTransportResult;
|
|
2214
2372
|
|
|
2215
2373
|
/**
|
|
2216
2374
|
* Tool executor function type
|
|
@@ -2496,580 +2654,9 @@ type ApiType = "auto" | "responses" | "completions";
|
|
|
2496
2654
|
*/
|
|
2497
2655
|
type ApiResponse = LlmapiResponseResponse | LlmapiChatCompletionResponse;
|
|
2498
2656
|
|
|
2499
|
-
|
|
2500
|
-
type
|
|
2501
|
-
|
|
2502
|
-
result: unknown;
|
|
2503
|
-
};
|
|
2504
|
-
/** Information emitted after each tool execution round completes. */
|
|
2505
|
-
type StepFinishEvent = {
|
|
2506
|
-
/** 1-based index of this tool round. */
|
|
2507
|
-
stepIndex: number;
|
|
2508
|
-
/** Text content the model produced in this round (may be empty if the model only called tools). */
|
|
2509
|
-
content: string;
|
|
2510
|
-
/** Tool calls the model made in this round. */
|
|
2511
|
-
toolCalls: Array<{
|
|
2512
|
-
name: string;
|
|
2513
|
-
arguments: string;
|
|
2514
|
-
}>;
|
|
2515
|
-
/** Results from auto-executed tools in this round. */
|
|
2516
|
-
toolResults: Array<{
|
|
2517
|
-
name: string;
|
|
2518
|
-
result: unknown;
|
|
2519
|
-
error?: string;
|
|
2520
|
-
errorType?: ToolExecutionErrorType;
|
|
2521
|
-
}>;
|
|
2522
|
-
/** Token usage for this round, if available. */
|
|
2523
|
-
usage: {
|
|
2524
|
-
inputTokens?: number;
|
|
2525
|
-
outputTokens?: number;
|
|
2526
|
-
};
|
|
2527
|
-
/**
|
|
2528
|
-
* The round's own finish reason, as the provider sent it — `"length"` means
|
|
2529
|
-
* this round hit the output ceiling.
|
|
2530
|
-
*
|
|
2531
|
-
* Per-round, not per-turn: a round can truncate and the loop still recover on
|
|
2532
|
-
* the next one, which is why the loop does not treat it as an error on its
|
|
2533
|
-
* own (see the truncation guard below). Without it a consumer watching steps
|
|
2534
|
-
* cannot tell a round that said everything it meant to from one that was cut
|
|
2535
|
-
* off mid-argument — they differ only in this field (#805).
|
|
2536
|
-
*
|
|
2537
|
-
* Absent when the provider sent no finish reason. Note that no step event
|
|
2538
|
-
* fires for the round that *ends* a turn, so use {@link RunTerminalState} on
|
|
2539
|
-
* the result for the final round.
|
|
2540
|
-
*/
|
|
2541
|
-
finishReason?: string;
|
|
2542
|
-
};
|
|
2543
|
-
/**
|
|
2544
|
-
* Terminal state of the LAST model response in the turn, normalized to the
|
|
2545
|
-
* completions vocabulary (`"stop"` | `"length"` | `"tool_calls"` | provider-
|
|
2546
|
-
* specific values). `undefined` when the stream carried no finish reason at all.
|
|
2547
|
-
*
|
|
2548
|
-
* Exposed because neither response shape reliably carries it out to a caller.
|
|
2549
|
-
* The Responses shape now carries `status` / `incomplete_details` — added in
|
|
2550
|
-
* `clientCompat` and emitted by `buildFinalResponse` — but only in the
|
|
2551
|
-
* Responses vocabulary, so a caller reading it has to translate
|
|
2552
|
-
* `incomplete_details.reason === "max_output_tokens"` itself. Completions
|
|
2553
|
-
* exposes `choices[0].finish_reason`, but omits `tool_calls` entirely when
|
|
2554
|
-
* there are none, so a caller sniffing the response cannot tell "no tool calls"
|
|
2555
|
-
* from "field absent". This field answers both questions in one vocabulary,
|
|
2556
|
-
* for either transport.
|
|
2557
|
-
*
|
|
2558
|
-
* The loop already knows both, unambiguously and identically for either API.
|
|
2559
|
-
* Reporting them here means callers and test harnesses stop reverse-engineering
|
|
2560
|
-
* them from a response shape that cannot answer. See anuma-ai/sdk#805.
|
|
2561
|
-
*/
|
|
2562
|
-
type RunTerminalState = {
|
|
2563
|
-
/** Normalized finish reason of the final response. `"length"` means the output
|
|
2564
|
-
* ceiling cut it off; anything else means the model stopped on its own. */
|
|
2565
|
-
finishReason?: string;
|
|
2566
|
-
/** Tool calls the final response carried. `0` is meaningful — combined with
|
|
2567
|
-
* empty content it identifies a turn that ended having produced nothing. */
|
|
2568
|
-
finalToolCallCount: number;
|
|
2569
|
-
};
|
|
2570
|
-
type RunToolLoopResult = {
|
|
2571
|
-
data: ApiResponse;
|
|
2572
|
-
error: null;
|
|
2573
|
-
/** Checksum of tools used to generate this response */
|
|
2574
|
-
toolsChecksum?: string;
|
|
2575
|
-
/** Results from tools that were auto-executed by the SDK */
|
|
2576
|
-
autoExecutedToolResults?: AutoExecutedToolResult[];
|
|
2577
|
-
/** Terminal state of the final model response. See {@link RunTerminalState}. */
|
|
2578
|
-
terminalState?: RunTerminalState;
|
|
2579
|
-
} | {
|
|
2580
|
-
data: ApiResponse | null;
|
|
2581
|
-
error: string;
|
|
2582
|
-
/** HTTP status code from the SSE connection, if available */
|
|
2583
|
-
statusCode?: number;
|
|
2584
|
-
/** Checksum of tools used to generate this response */
|
|
2585
|
-
toolsChecksum?: string;
|
|
2586
|
-
/** True when the loop exited via detachSignal. `error` is "Request detached". */
|
|
2587
|
-
detached?: true;
|
|
2588
|
-
/** Non-null only when `resumable` was true AND an inference id was captured before detach. */
|
|
2589
|
-
resume?: StreamResumeHandle | null;
|
|
2590
|
-
/** True when the connection failed rather than the generation: the portal may still be generating. */
|
|
2591
|
-
connectionLost?: true;
|
|
2592
|
-
/**
|
|
2593
|
-
* Terminal state of the final model response, when the failure is one the
|
|
2594
|
-
* loop diagnosed FROM that response — today, the truncated-to-nothing
|
|
2595
|
-
* error. See {@link RunTerminalState}.
|
|
2596
|
-
*
|
|
2597
|
-
* Absent on failures that never got a terminal response to read (transport
|
|
2598
|
-
* errors, detach, an SSE failure mid-stream), which is why it stays
|
|
2599
|
-
* optional here. Present on the truncation error specifically because that
|
|
2600
|
-
* is where it is most diagnostic: a caller can branch on
|
|
2601
|
-
* `finishReason === "length"` instead of matching the error string.
|
|
2602
|
-
*/
|
|
2603
|
-
terminalState?: RunTerminalState;
|
|
2604
|
-
};
|
|
2605
|
-
/** Capability header: tells the portal this client can resume a detached stream. Pinned with zeta-chain/ai-portal#1139. */
|
|
2606
|
-
declare const STREAM_RESUMABLE_HEADER = "X-Stream-Resumable";
|
|
2607
|
-
/** Response header carrying the per-request stream id, issued by the portal pre-stream. */
|
|
2608
|
-
declare const INFERENCE_ID_HEADER = "X-Inference-ID";
|
|
2609
|
-
/**
|
|
2610
|
-
* Everything resumeStream() needs to replay a detached stream.
|
|
2611
|
-
* @public
|
|
2612
|
-
*/
|
|
2613
|
-
type StreamResumeHandle = {
|
|
2614
|
-
inferenceId: string;
|
|
2615
|
-
/** The RESOLVED api type (never "auto") — resolveApiType() already ran inside runToolLoop. */
|
|
2616
|
-
apiType: Exclude<ApiType, "auto">;
|
|
2617
|
-
model?: string;
|
|
2618
|
-
conversationId?: string;
|
|
2619
|
-
};
|
|
2620
|
-
/**
|
|
2621
|
-
* Payload for RunToolLoopOptions.onStreamMeta.
|
|
2622
|
-
* @public
|
|
2623
|
-
*/
|
|
2624
|
-
type StreamMetaEvent = {
|
|
2625
|
-
inferenceId: string;
|
|
2626
|
-
/** 0 = initial request, 1+ = continuation round (same numbering as RequestEvent.round). */
|
|
2627
|
-
round: number;
|
|
2628
|
-
};
|
|
2629
|
-
/** Options passed to a streaming transport function. */
|
|
2630
|
-
type StreamingTransportOptions = {
|
|
2631
|
-
baseUrl: string;
|
|
2632
|
-
endpoint: string;
|
|
2633
|
-
/** @default "POST" */
|
|
2634
|
-
method?: "GET" | "POST";
|
|
2635
|
-
/** Request body. Optional — GET resume requests have no body. */
|
|
2636
|
-
body?: Record<string, unknown>;
|
|
2637
|
-
token?: string;
|
|
2638
|
-
headers?: Record<string, string>;
|
|
2639
|
-
signal?: AbortSignal;
|
|
2640
|
-
onSseError?: (error: unknown) => void;
|
|
2641
|
-
/** Fires once per request when response headers arrive with X-Inference-ID (2xx only). */
|
|
2642
|
-
onStreamMeta?: (meta: {
|
|
2643
|
-
inferenceId: string;
|
|
2644
|
-
}) => void;
|
|
2645
|
-
/**
|
|
2646
|
-
* Fires when the transport receives bytes, including SSE keep-alive comments.
|
|
2647
|
-
* Consumers can use this callback to reset the idle timeout.
|
|
2648
|
-
* The fetch and XHR transports emit it.
|
|
2649
|
-
* Custom transports can omit it if they cannot report byte activity.
|
|
2650
|
-
*/
|
|
2651
|
-
onActivity?: () => void;
|
|
2652
|
-
};
|
|
2653
|
-
/** Result returned by a streaming transport function. */
|
|
2654
|
-
type StreamingTransportResult = {
|
|
2655
|
-
stream: AsyncIterable<unknown>;
|
|
2656
|
-
};
|
|
2657
|
-
/**
|
|
2658
|
-
* A pluggable transport function for streaming SSE requests.
|
|
2659
|
-
* The default uses `fetch` + `ReadableStream`. React Native environments
|
|
2660
|
-
* can supply an XHR-based transport instead.
|
|
2661
|
-
*
|
|
2662
|
-
* ### Abort contract
|
|
2663
|
-
*
|
|
2664
|
-
* When `options.signal` aborts **mid-stream**, the returned async iterable
|
|
2665
|
-
* MUST surface an `AbortError` (an `Error` whose `name === "AbortError"`)
|
|
2666
|
-
* to its consumer — either by throwing from the iterator, or by causing
|
|
2667
|
-
* the underlying `read()` to reject. It MUST NOT terminate the iterable
|
|
2668
|
-
* with an orderly `done` in that case.
|
|
2669
|
-
*
|
|
2670
|
-
* `runToolLoop` relies on this to distinguish two scenarios that are
|
|
2671
|
-
* otherwise indistinguishable from outside the transport:
|
|
2672
|
-
* 1. The server closed the connection cleanly and every byte was
|
|
2673
|
-
* delivered → iterable returns `done`, result is success.
|
|
2674
|
-
* 2. The caller aborted the request mid-stream → iterable throws
|
|
2675
|
-
* `AbortError`, result is `{ data: <partial>, error: "Request aborted" }`.
|
|
2676
|
-
*
|
|
2677
|
-
* Transports that swallow mid-stream aborts and yield `done` instead
|
|
2678
|
-
* will cause a partial response to be reported as a successful
|
|
2679
|
-
* completion. The built-in `xhrTransport` and the default fetch-based
|
|
2680
|
-
* transport both honor this contract.
|
|
2681
|
-
*/
|
|
2682
|
-
type StreamingTransport = (options: StreamingTransportOptions) => StreamingTransportResult;
|
|
2683
|
-
|
|
2684
|
-
/**
|
|
2685
|
-
* Build the replay path for a detached stream. The portal serves the buffered
|
|
2686
|
-
* stream from seq 0 on a GET to this path — no `starting_after`, no `id:`
|
|
2687
|
-
* cursor, no request body. Replay always starts from the first buffered byte
|
|
2688
|
-
* and the client rebuilds its own view with a fresh accumulator; partial
|
|
2689
|
-
* client state is never sent back to the server.
|
|
2690
|
-
*
|
|
2691
|
-
* Exported so client repos can mock the endpoint in E2E without string drift.
|
|
2692
|
-
*/
|
|
2693
|
-
declare function streamReplayPath(inferenceId: string): string;
|
|
2694
|
-
/**
|
|
2695
|
-
* Build the cancel path for a detached stream. A POST here tells the portal to
|
|
2696
|
-
* stop generating into the buffer and release it — the billing-safe teardown
|
|
2697
|
-
* for "the user pressed stop after we'd already detached".
|
|
2698
|
-
*
|
|
2699
|
-
* Exported so client repos can mock the endpoint in E2E without string drift.
|
|
2700
|
-
*/
|
|
2701
|
-
declare function streamCancelPath(inferenceId: string): string;
|
|
2702
|
-
/**
|
|
2703
|
-
* Thrown when the portal answers `410 Gone` to a replay GET: the buffered
|
|
2704
|
-
* stream is gone — expired (10-min sliding TTL), absent, not owned by the
|
|
2705
|
-
* caller, or already cancelled. There is nothing to replay; the answer is
|
|
2706
|
-
* permanently lost and the caller should fall back to a fresh send rather than
|
|
2707
|
-
* retry. A `stop()`-then-resume race lands here and finalizes as stopped, which
|
|
2708
|
-
* is correct.
|
|
2709
|
-
*
|
|
2710
|
-
* `resumeStream` throws this (it does not return it) and fires neither
|
|
2711
|
-
* `onFinish` nor `onError` — there is no body to deliver.
|
|
2712
|
-
* @public
|
|
2713
|
-
*/
|
|
2714
|
-
declare class StreamExpiredError extends Error {
|
|
2715
|
-
readonly name = "StreamExpiredError";
|
|
2716
|
-
readonly inferenceId: string;
|
|
2717
|
-
constructor(inferenceId: string, message?: string);
|
|
2718
|
-
}
|
|
2719
|
-
/**
|
|
2720
|
-
* Options for {@link resumeStream}.
|
|
2721
|
-
* @public
|
|
2722
|
-
*/
|
|
2723
|
-
interface ResumeStreamOptions {
|
|
2724
|
-
/** The handle captured from a detached `runToolLoop` result. */
|
|
2725
|
-
handle: StreamResumeHandle;
|
|
2726
|
-
/**
|
|
2727
|
-
* Fresh bearer token. The CALLER fetches it at resume time — a multi-minute
|
|
2728
|
-
* background gap expires the bearer, so a token captured when the original
|
|
2729
|
-
* stream started must never be reused (see `useChat.resumeStream`).
|
|
2730
|
-
*/
|
|
2731
|
-
token: string;
|
|
2732
|
-
/** Base URL for the portal. @default the SDK's configured BASE_URL. */
|
|
2733
|
-
baseUrl?: string;
|
|
2734
|
-
/**
|
|
2735
|
-
* Streaming transport. Defaults to the GET-capable fetch transport; Expo
|
|
2736
|
-
* passes `xhrTransport` (RN can't stream `fetch` bodies).
|
|
2737
|
-
*/
|
|
2738
|
-
transport?: StreamingTransport;
|
|
2739
|
-
/** Aborts the replay; the partial is returned as an interrupted result. */
|
|
2740
|
-
signal?: AbortSignal;
|
|
2741
|
-
/** Adaptive output smoothing for the replayed content. @default true */
|
|
2742
|
-
smoothing?: StreamSmoothingConfig | boolean;
|
|
2743
|
-
/**
|
|
2744
|
-
* Client-side watchdog for a dead live-tail. @default 120_000ms.
|
|
2745
|
-
*
|
|
2746
|
-
* Deliberately NOT ~30s: the portal tolerates >100s reasoning silences (no
|
|
2747
|
-
* `data:` frames on the replay connection during them) and its own liveness
|
|
2748
|
-
* rule (heartbeat stale >90s => SSE error + `[DONE]`) is the authoritative
|
|
2749
|
-
* guard. This client timer is a backstop for a half-open TCP connection and
|
|
2750
|
-
* must sit ABOVE the server's 90s rule so the server error always wins when
|
|
2751
|
-
* the portal is reachable. Set to 0 / Infinity to disable.
|
|
2752
|
-
*/
|
|
2753
|
-
idleTimeoutMs?: number;
|
|
2754
|
-
/** Content text deltas as they replay (always from seq 0 — reset accumulated text first). */
|
|
2755
|
-
onData?: (chunk: string) => void;
|
|
2756
|
-
/** Thinking/reasoning deltas as they replay. */
|
|
2757
|
-
onThinking?: (chunk: string) => void;
|
|
2758
|
-
/** Restores the placeholders this redactor assigned when the original request was sent. */
|
|
2759
|
-
piiRedactor?: PiiRedactor;
|
|
2760
|
-
/** Called once on a clean completion. Never called for 410 nor interrupted terminals. */
|
|
2761
|
-
onFinish?: (response: ApiResponse) => void;
|
|
2762
|
-
/** Called on a transient/unexpected failure. Never called for 410 (throws) nor interrupted terminals. */
|
|
2763
|
-
onError?: (error: Error) => void;
|
|
2764
|
-
}
|
|
2765
|
-
/**
|
|
2766
|
-
* Result of {@link resumeStream}. A `410 Gone` is the only outcome that throws
|
|
2767
|
-
* ({@link StreamExpiredError}); every other terminal is returned.
|
|
2768
|
-
*
|
|
2769
|
-
* - clean completion → `{ data, error: null, interrupted: false, empty }`
|
|
2770
|
-
* - in-stream error / tool-request terminal / idle timeout → `{ data, error,
|
|
2771
|
-
* interrupted: true }` (finalize as a stopped/partial message)
|
|
2772
|
-
* - transient transport/HTTP failure (401, 5xx, network) → `{ data, error,
|
|
2773
|
-
* interrupted: false, statusCode? }` (retryable — keep the handle)
|
|
2774
|
-
*
|
|
2775
|
-
* `empty` is true when the clean terminal delivered ZERO content/thinking
|
|
2776
|
-
* deltas — a `[DONE]`-only replay. That is never a real completion (a
|
|
2777
|
-
* completed generation always buffered at least one content frame); it means
|
|
2778
|
-
* the buffered frames were lost server-side (evicted/trimmed) while the
|
|
2779
|
-
* terminal survived. Consumers must NOT persist `data` (an empty response)
|
|
2780
|
-
* over content they already hold — keep the detached partial instead. On the
|
|
2781
|
-
* empty terminal `onFinish` is NOT fired (there is no completion to deliver);
|
|
2782
|
-
* the flag is optional so existing constructors of the clean arm stay valid.
|
|
2783
|
-
* @public
|
|
2784
|
-
*/
|
|
2785
|
-
type ResumeStreamResult = {
|
|
2786
|
-
data: ApiResponse;
|
|
2787
|
-
error: null;
|
|
2788
|
-
interrupted: false;
|
|
2789
|
-
empty?: boolean;
|
|
2790
|
-
} | {
|
|
2791
|
-
data: ApiResponse | null;
|
|
2792
|
-
error: string;
|
|
2793
|
-
interrupted: boolean;
|
|
2794
|
-
statusCode?: number;
|
|
2795
|
-
};
|
|
2796
|
-
/**
|
|
2797
|
-
* Replay a detached stream from the portal's buffer.
|
|
2798
|
-
*
|
|
2799
|
-
* This is the reconnect primitive: after `runToolLoop` returns the detached
|
|
2800
|
-
* variant with a {@link StreamResumeHandle}, `resumeStream` issues a GET to the
|
|
2801
|
-
* portal's replay endpoint and rebuilds the response from seq 0 using a FRESH
|
|
2802
|
-
* accumulator and FRESH smoothers. Nothing from the original (detached) run is
|
|
2803
|
-
* reused — the completions strategy's reasoning-tag parser is stateful, so
|
|
2804
|
-
* replaying into reused state would double-count; replay-from-0 into fresh
|
|
2805
|
-
* state is the correctness mechanism, not just a simplification.
|
|
2806
|
-
*
|
|
2807
|
-
* Contract highlights:
|
|
2808
|
-
* - **No `starting_after`, no `id:` cursor, no body.** The GET carries the
|
|
2809
|
-
* inference id in the path only; replay is always whole-stream. (The server
|
|
2810
|
-
* reserves `starting_after` but does NOT honor it — sending it would silently
|
|
2811
|
-
* duplicate content.)
|
|
2812
|
-
* - **410 → throws {@link StreamExpiredError}.** No `onFinish`/`onError`.
|
|
2813
|
-
* - **In-stream error / tool-request terminal → `interrupted: true`.** Flushes
|
|
2814
|
-
* both smoothers and returns the partial; no throw, no `onError`, no `onFinish`.
|
|
2815
|
-
* - **token resolved by the caller at resume time** so a refresh during the
|
|
2816
|
-
* detach window is honored.
|
|
2817
|
-
*
|
|
2818
|
-
* @public
|
|
2819
|
-
*/
|
|
2820
|
-
declare function resumeStream(options: ResumeStreamOptions): Promise<ResumeStreamResult>;
|
|
2821
|
-
|
|
2822
|
-
interface StockPriceClassification {
|
|
2823
|
-
/** Whether the prompt likely asks for stock/ETF/FX quote data. */
|
|
2824
|
-
needsStockPrice: boolean;
|
|
2825
|
-
/** Cosine similarity to the "needs stock price" centroid. */
|
|
2826
|
-
stockPriceScore: number;
|
|
2827
|
-
/** Cosine similarity to the "no stock price" centroid. */
|
|
2828
|
-
noStockPriceScore: number;
|
|
2829
|
-
}
|
|
2830
|
-
interface StockPriceClassifierOptions extends EmbeddingOptions {
|
|
2831
|
-
/**
|
|
2832
|
-
* Score margin: the stock-price score must exceed the no-stock-price
|
|
2833
|
-
* score by at least this amount to classify as "needs stock price data".
|
|
2834
|
-
* @default 0.02
|
|
2835
|
-
*/
|
|
2836
|
-
margin?: number;
|
|
2837
|
-
}
|
|
2838
|
-
/**
|
|
2839
|
-
* Classify whether a prompt needs stock/ETF/index/FX price data.
|
|
2840
|
-
*
|
|
2841
|
-
* Domain: traditional financial instruments (equities, indices, ETFs, FX).
|
|
2842
|
-
* Crypto is handled by `classifyCryptoPrice`. Ambiguous prompts
|
|
2843
|
-
* (e.g. *"gold price"*) may fire both — that's expected; the caller can
|
|
2844
|
-
* inject both sets of results.
|
|
2845
|
-
*/
|
|
2846
|
-
declare function classifyStockPrice(prompt: string, options: StockPriceClassifierOptions): Promise<StockPriceClassification>;
|
|
2847
|
-
/**
|
|
2848
|
-
* Batch-classify multiple prompts. Embeds all prompts in one batch
|
|
2849
|
-
* call for efficiency.
|
|
2850
|
-
*/
|
|
2851
|
-
declare function classifyStockPriceBatch(prompts: string[], options: StockPriceClassifierOptions): Promise<StockPriceClassification[]>;
|
|
2852
|
-
interface StockPricePreProcessorOptions {
|
|
2853
|
-
/**
|
|
2854
|
-
* Called with the caller's stock-quote provider when the classifier
|
|
2855
|
-
* decides the prompt is asking for stock/ETF/FX data. Return either a
|
|
2856
|
-
* plain string (wrapped by the SDK in a default user message) or a
|
|
2857
|
-
* fully-formed `LlmapiMessage[]` (full control over role/shape). Omit
|
|
2858
|
-
* to run in observer mode — classification still fires but nothing is
|
|
2859
|
-
* injected.
|
|
2860
|
-
*
|
|
2861
|
-
* The `signal` argument is forwarded from the tool loop so long-running
|
|
2862
|
-
* provider requests can be aborted when the caller aborts.
|
|
2863
|
-
*/
|
|
2864
|
-
fetchStockPriceData?: (prompt: string, options: {
|
|
2865
|
-
signal?: AbortSignal;
|
|
2866
|
-
}) => Promise<string | LlmapiMessage[]>;
|
|
2867
|
-
/**
|
|
2868
|
-
* Score margin: `stockPriceScore` must exceed `noStockPriceScore` by at
|
|
2869
|
-
* least this amount to classify as "needs stock price data".
|
|
2870
|
-
* @default 0.02
|
|
2871
|
-
*/
|
|
2872
|
-
margin?: number;
|
|
2873
|
-
/** Observe the classification without injecting anything. */
|
|
2874
|
-
onClassification?: (result: StockPriceClassification) => void;
|
|
2875
|
-
}
|
|
2876
|
-
/**
|
|
2877
|
-
* Build a pre-processor that runs stock-price classification on the shared
|
|
2878
|
-
* embedding provided by `runToolLoop`, and — if the classifier decides the
|
|
2879
|
-
* prompt is asking for quotes — invokes the caller-supplied
|
|
2880
|
-
* `fetchStockPriceData` and injects the result into the conversation.
|
|
2881
|
-
*
|
|
2882
|
-
* Domain: stocks, ETFs, indices, FX. For crypto use
|
|
2883
|
-
* `createCryptoPricePreProcessor`. The SDK does not run the lookup itself;
|
|
2884
|
-
* the caller wires up whichever provider they want (Twelve Data, Alpha
|
|
2885
|
-
* Vantage, Finnhub, etc.).
|
|
2886
|
-
*/
|
|
2887
|
-
declare function createStockPricePreProcessor(options?: StockPricePreProcessorOptions): PromptPreProcessor;
|
|
2888
|
-
|
|
2889
|
-
/**
|
|
2890
|
-
* Value of the `origin` column on a row the SDK synthesised for a turn's tool results (v44, #866).
|
|
2891
|
-
*
|
|
2892
|
-
* `satisfies MessageOrigin` so this constant and the column's union cannot drift apart silently.
|
|
2893
|
-
*/
|
|
2894
|
-
declare const TOOL_RESULT_ORIGIN = "tool_result";
|
|
2895
|
-
|
|
2896
|
-
interface WeatherClassification {
|
|
2897
|
-
/** Whether the prompt likely asks for weather data. */
|
|
2898
|
-
needsWeather: boolean;
|
|
2899
|
-
/** Cosine similarity to the "needs weather" centroid. */
|
|
2900
|
-
weatherScore: number;
|
|
2901
|
-
/** Cosine similarity to the "no weather" centroid. */
|
|
2902
|
-
noWeatherScore: number;
|
|
2903
|
-
}
|
|
2904
|
-
interface WeatherClassifierOptions extends EmbeddingOptions {
|
|
2905
|
-
/**
|
|
2906
|
-
* Score margin: the weather score must exceed the no-weather score by at
|
|
2907
|
-
* least this amount to classify as "needs weather data".
|
|
2908
|
-
* @default 0.02
|
|
2909
|
-
*/
|
|
2910
|
-
margin?: number;
|
|
2911
|
-
}
|
|
2912
|
-
/**
|
|
2913
|
-
* Classify whether a prompt needs weather data.
|
|
2914
|
-
*
|
|
2915
|
-
* Covers forecasts, temperature, precipitation, wind, humidity, UV, AQI,
|
|
2916
|
-
* marine, flood, climate — anything OpenMeteo-shaped.
|
|
2917
|
-
*/
|
|
2918
|
-
declare function classifyWeather(prompt: string, options: WeatherClassifierOptions): Promise<WeatherClassification>;
|
|
2919
|
-
/**
|
|
2920
|
-
* Batch-classify multiple prompts. Embeds all prompts in one batch
|
|
2921
|
-
* call for efficiency.
|
|
2922
|
-
*/
|
|
2923
|
-
declare function classifyWeatherBatch(prompts: string[], options: WeatherClassifierOptions): Promise<WeatherClassification[]>;
|
|
2924
|
-
interface WeatherPreProcessorOptions {
|
|
2925
|
-
/**
|
|
2926
|
-
* Called with the caller's weather provider when the classifier decides
|
|
2927
|
-
* the prompt is asking for weather. Return either a plain string
|
|
2928
|
-
* (wrapped by the SDK in a default user message) or a fully-formed
|
|
2929
|
-
* `LlmapiMessage[]` (full control over role/shape). Omit to run in
|
|
2930
|
-
* observer mode — classification still fires but nothing is injected.
|
|
2931
|
-
*
|
|
2932
|
-
* The `signal` argument is forwarded from the tool loop so long-running
|
|
2933
|
-
* provider requests can be aborted when the caller aborts.
|
|
2934
|
-
*/
|
|
2935
|
-
fetchWeatherData?: (prompt: string, options: {
|
|
2936
|
-
signal?: AbortSignal;
|
|
2937
|
-
}) => Promise<string | LlmapiMessage[]>;
|
|
2938
|
-
/**
|
|
2939
|
-
* Score margin: `weatherScore` must exceed `noWeatherScore` by at least
|
|
2940
|
-
* this amount to classify as "needs weather data".
|
|
2941
|
-
* @default 0.02
|
|
2942
|
-
*/
|
|
2943
|
-
margin?: number;
|
|
2944
|
-
/** Observe the classification without injecting anything. */
|
|
2945
|
-
onClassification?: (result: WeatherClassification) => void;
|
|
2946
|
-
}
|
|
2947
|
-
/**
|
|
2948
|
-
* Build a pre-processor that runs weather classification on the shared
|
|
2949
|
-
* embedding provided by `runToolLoop`, and — if the classifier decides
|
|
2950
|
-
* the prompt is asking for weather — invokes the caller-supplied
|
|
2951
|
-
* `fetchWeatherData` and injects the result into the conversation.
|
|
2952
|
-
*
|
|
2953
|
-
* The SDK does not run the weather lookup itself; the caller wires up
|
|
2954
|
-
* whichever provider they want (OpenMeteo, AccuWeather, weather.gov, etc.).
|
|
2955
|
-
*/
|
|
2956
|
-
declare function createWeatherPreProcessor(options?: WeatherPreProcessorOptions): PromptPreProcessor;
|
|
2957
|
-
|
|
2958
|
-
interface WebSearchClassification {
|
|
2959
|
-
/** Whether the prompt likely needs a web search. */
|
|
2960
|
-
needsWebSearch: boolean;
|
|
2961
|
-
/** Cosine similarity to the "needs search" centroid. */
|
|
2962
|
-
searchScore: number;
|
|
2963
|
-
/** Cosine similarity to the "no search" centroid. */
|
|
2964
|
-
noSearchScore: number;
|
|
2965
|
-
}
|
|
2966
|
-
interface WebSearchClassifierOptions extends EmbeddingOptions {
|
|
2967
|
-
/**
|
|
2968
|
-
* Score margin: the search score must exceed the no-search score
|
|
2969
|
-
* by at least this amount to classify as "needs web search".
|
|
2970
|
-
* @default 0.02
|
|
2971
|
-
*/
|
|
2972
|
-
margin?: number;
|
|
2973
|
-
}
|
|
2974
|
-
/**
|
|
2975
|
-
* Classify whether a prompt needs a web search.
|
|
2976
|
-
*
|
|
2977
|
-
* Embeds the prompt and compares it against the pre-computed
|
|
2978
|
-
* search and no-search centroid vectors.
|
|
2979
|
-
*/
|
|
2980
|
-
declare function classifyWebSearch(prompt: string, options: WebSearchClassifierOptions): Promise<WebSearchClassification>;
|
|
2981
|
-
/**
|
|
2982
|
-
* Batch-classify multiple prompts. Embeds all prompts in one batch
|
|
2983
|
-
* call for efficiency.
|
|
2984
|
-
*/
|
|
2985
|
-
declare function classifyWebSearchBatch(prompts: string[], options: WebSearchClassifierOptions): Promise<WebSearchClassification[]>;
|
|
2986
|
-
interface WebSearchPreProcessorOptions {
|
|
2987
|
-
/**
|
|
2988
|
-
* Called with the caller's search provider when the classifier decides
|
|
2989
|
-
* a web search is needed. Return either a plain string (the SDK will
|
|
2990
|
-
* wrap it in a default user message) or a fully-formed message array
|
|
2991
|
-
* (full control over role/shape). Omit to run in observer mode —
|
|
2992
|
-
* classification still fires but no messages are injected.
|
|
2993
|
-
*
|
|
2994
|
-
* The `signal` argument is forwarded from the tool loop so long-running
|
|
2995
|
-
* search requests can be aborted when the caller aborts.
|
|
2996
|
-
*/
|
|
2997
|
-
fetchSearchResults?: (prompt: string, options: {
|
|
2998
|
-
signal?: AbortSignal;
|
|
2999
|
-
}) => Promise<string | LlmapiMessage[]>;
|
|
3000
|
-
/**
|
|
3001
|
-
* Score margin: `searchScore` must exceed `noSearchScore` by at least
|
|
3002
|
-
* this amount to classify as "needs web search".
|
|
3003
|
-
* @default 0.02
|
|
3004
|
-
*/
|
|
3005
|
-
margin?: number;
|
|
3006
|
-
/** Observe the classification without injecting anything. */
|
|
3007
|
-
onClassification?: (result: WebSearchClassification) => void;
|
|
3008
|
-
}
|
|
3009
|
-
/**
|
|
3010
|
-
* Build a pre-processor that runs web-search classification on the
|
|
3011
|
-
* shared embedding provided by `runToolLoop`, and — if the classifier
|
|
3012
|
-
* decides a search is warranted — invokes the caller-supplied
|
|
3013
|
-
* `fetchSearchResults` and injects the result into the conversation.
|
|
3014
|
-
*
|
|
3015
|
-
* @example Basic usage with a search provider
|
|
3016
|
-
* ```ts
|
|
3017
|
-
* import { runToolLoop, createWebSearchPreProcessor } from "@anuma/sdk/server";
|
|
3018
|
-
*
|
|
3019
|
-
* const webSearch = createWebSearchPreProcessor({
|
|
3020
|
-
* fetchSearchResults: async (prompt, { signal }) => {
|
|
3021
|
-
* const res = await mySearchProvider.query(prompt, { signal });
|
|
3022
|
-
* return res.results.map((r) => `- ${r.title}: ${r.snippet}`).join("\n");
|
|
3023
|
-
* },
|
|
3024
|
-
* });
|
|
3025
|
-
*
|
|
3026
|
-
* await runToolLoop({
|
|
3027
|
-
* messages,
|
|
3028
|
-
* model,
|
|
3029
|
-
* token,
|
|
3030
|
-
* preProcessors: [webSearch],
|
|
3031
|
-
* });
|
|
3032
|
-
* ```
|
|
3033
|
-
*
|
|
3034
|
-
* @example Observer mode — only log classification, inject nothing
|
|
3035
|
-
* ```ts
|
|
3036
|
-
* const observer = createWebSearchPreProcessor({
|
|
3037
|
-
* onClassification: ({ needsWebSearch, searchScore, noSearchScore }) => {
|
|
3038
|
-
* metrics.record({ needsWebSearch, searchScore, noSearchScore });
|
|
3039
|
-
* },
|
|
3040
|
-
* });
|
|
3041
|
-
* ```
|
|
3042
|
-
*
|
|
3043
|
-
* @example Full control — return a custom message shape
|
|
3044
|
-
* ```ts
|
|
3045
|
-
* const webSearch = createWebSearchPreProcessor({
|
|
3046
|
-
* fetchSearchResults: async (prompt, { signal }) => {
|
|
3047
|
-
* const results = await mySearchProvider.query(prompt, { signal });
|
|
3048
|
-
* return [
|
|
3049
|
-
* {
|
|
3050
|
-
* role: "system",
|
|
3051
|
-
* content: [{ type: "text", text: `Search results for "${prompt}":\n${formatResults(results)}` }],
|
|
3052
|
-
* },
|
|
3053
|
-
* ];
|
|
3054
|
-
* },
|
|
3055
|
-
* });
|
|
3056
|
-
* ```
|
|
3057
|
-
*/
|
|
3058
|
-
declare function createWebSearchPreProcessor(options?: WebSearchPreProcessorOptions): PromptPreProcessor;
|
|
3059
|
-
|
|
3060
|
-
/**
|
|
3061
|
-
* XHR-based streaming transport for React Native environments.
|
|
3062
|
-
*
|
|
3063
|
-
* React Native's `fetch` doesn't support `response.body` streaming,
|
|
3064
|
-
* so this transport uses `XMLHttpRequest` with `onprogress` to stream
|
|
3065
|
-
* SSE events. It exposes the same `{ stream: AsyncIterable }` interface
|
|
3066
|
-
* as the default fetch-based transport.
|
|
3067
|
-
*/
|
|
3068
|
-
declare const xhrTransport: StreamingTransport;
|
|
3069
|
-
|
|
3070
|
-
type ChatRecordKind = "conversation" | "message" | "summary" | "project" | "memory_links" | "setting";
|
|
3071
|
-
type ChatJson = null | boolean | number | string | ChatJson[] | {
|
|
3072
|
-
[key: string]: ChatJson;
|
|
2657
|
+
type ChatRecordKind = "conversation" | "message" | "summary" | "project" | "memory_links" | "setting";
|
|
2658
|
+
type ChatJson = null | boolean | number | string | ChatJson[] | {
|
|
2659
|
+
[key: string]: ChatJson;
|
|
3073
2660
|
};
|
|
3074
2661
|
/** Whole-record JSON data is encrypted on the device, including all text, vectors and tool events. */
|
|
3075
2662
|
interface ChatRecord {
|
|
@@ -4542,7 +4129,7 @@ interface ChatStorageAdapter {
|
|
|
4542
4129
|
createMessage(options: CreateMessageOptions): Promise<StoredMessage>;
|
|
4543
4130
|
updateMessageEmbedding(uniqueId: string, vector: number[], embeddingModel: string): Promise<StoredMessage | null>;
|
|
4544
4131
|
updateMessageChunks(uniqueId: string, chunks: MessageChunk[], embeddingModel: string): Promise<StoredMessage | null>;
|
|
4545
|
-
updateMessageError(uniqueId: string, error: string): Promise<StoredMessage | null>;
|
|
4132
|
+
updateMessageError(uniqueId: string, error: string | null): Promise<StoredMessage | null>;
|
|
4546
4133
|
updateMessageFeedback(uniqueId: string, feedback: MessageFeedback): Promise<StoredMessage | null>;
|
|
4547
4134
|
/**
|
|
4548
4135
|
* Replace a message's attached media ids (`fileIds`). Used to attach a
|
|
@@ -8289,160 +7876,656 @@ interface BaseSendMessageWithStorageArgs {
|
|
|
8289
7876
|
* Controls randomness in the response (0.0 to 2.0).
|
|
8290
7877
|
* Lower values make output more deterministic, higher values more creative.
|
|
8291
7878
|
*/
|
|
8292
|
-
temperature?: number;
|
|
7879
|
+
temperature?: number;
|
|
7880
|
+
/**
|
|
7881
|
+
* Maximum number of tokens to generate in the response.
|
|
7882
|
+
* Use this to limit response length and control costs.
|
|
7883
|
+
*/
|
|
7884
|
+
maxOutputTokens?: number;
|
|
7885
|
+
/**
|
|
7886
|
+
* Client-side tools with optional executors.
|
|
7887
|
+
* These tools run in the browser/app and can have JavaScript executor functions.
|
|
7888
|
+
*/
|
|
7889
|
+
clientTools?: LlmapiChatCompletionTool[];
|
|
7890
|
+
/**
|
|
7891
|
+
* Server-side tools to include from /api/v1/tools.
|
|
7892
|
+
* - undefined: Include all server-side tools (default)
|
|
7893
|
+
* - string[]: Include only tools with these names
|
|
7894
|
+
* - []: Include no server-side tools
|
|
7895
|
+
* - function: Dynamic filter that receives prompt embedding(s) and all tools,
|
|
7896
|
+
* returns tool names to include. Useful for semantic tool matching.
|
|
7897
|
+
*
|
|
7898
|
+
* @example
|
|
7899
|
+
* // Include only specific server tools
|
|
7900
|
+
* serverTools: ["anuma_create_image", "perplexity_search"]
|
|
7901
|
+
*
|
|
7902
|
+
* // Disable server tools for this request
|
|
7903
|
+
* serverTools: []
|
|
7904
|
+
*
|
|
7905
|
+
* // Semantic tool matching based on prompt
|
|
7906
|
+
* serverTools: (embeddings, tools) => {
|
|
7907
|
+
* const matches = findMatchingTools(embeddings, tools, { limit: 5 });
|
|
7908
|
+
* return matches.map(m => m.tool.name);
|
|
7909
|
+
* }
|
|
7910
|
+
*/
|
|
7911
|
+
serverTools?: ServerToolsFilter;
|
|
7912
|
+
/**
|
|
7913
|
+
* Dynamic filter for client-side tools based on prompt embeddings.
|
|
7914
|
+
* Receives the prompt embedding(s) (or null for short messages) and all client tools,
|
|
7915
|
+
* returns tool names to include. Tools not in the returned list are excluded from the request.
|
|
7916
|
+
*
|
|
7917
|
+
* @example
|
|
7918
|
+
* clientToolsFilter: (embeddings, tools) => {
|
|
7919
|
+
* if (!embeddings) return []; // Short message — no client tools
|
|
7920
|
+
* const matches = findMatchingTools(embeddings, pseudoServerTools);
|
|
7921
|
+
* return matches.map(m => m.tool.name);
|
|
7922
|
+
* }
|
|
7923
|
+
*/
|
|
7924
|
+
clientToolsFilter?: ClientToolsFilterFn;
|
|
7925
|
+
/**
|
|
7926
|
+
* Controls which tool the model should use:
|
|
7927
|
+
* - "auto": Model decides whether to use a tool (default)
|
|
7928
|
+
* - "any": Model must use one of the provided tools
|
|
7929
|
+
* - "none": Model cannot use any tools
|
|
7930
|
+
* - "required": Model must use a tool
|
|
7931
|
+
* - Specific tool name: Model must use that specific tool
|
|
7932
|
+
*/
|
|
7933
|
+
toolChoice?: string;
|
|
7934
|
+
/**
|
|
7935
|
+
* Maximum number of tool execution rounds before forcing the model to respond with text.
|
|
7936
|
+
* After this many rounds, `toolChoice` is set to `"none"` on the next continuation,
|
|
7937
|
+
* so the model produces a text answer using whatever tool results it has gathered.
|
|
7938
|
+
* @default 3
|
|
7939
|
+
*/
|
|
7940
|
+
maxToolRounds?: number;
|
|
7941
|
+
/**
|
|
7942
|
+
* Reasoning configuration for o-series and other reasoning models.
|
|
7943
|
+
* Controls reasoning effort level and whether to include reasoning summary.
|
|
7944
|
+
*/
|
|
7945
|
+
reasoning?: LlmapiResponseReasoning;
|
|
7946
|
+
/**
|
|
7947
|
+
* Extended thinking configuration for Anthropic models (Claude).
|
|
7948
|
+
* Enables the model to think through complex problems step by step
|
|
7949
|
+
* before generating the final response.
|
|
7950
|
+
*/
|
|
7951
|
+
thinking?: LlmapiThinkingOptions;
|
|
7952
|
+
/** User-selected image generation model for server-side enforcement. */
|
|
7953
|
+
imageModel?: string;
|
|
7954
|
+
/**
|
|
7955
|
+
* Per-request callback for thinking/reasoning chunks.
|
|
7956
|
+
* Called with delta chunks as the model "thinks" through a problem.
|
|
7957
|
+
* Use this to display thinking progress in the UI.
|
|
7958
|
+
*/
|
|
7959
|
+
onThinking?: (chunk: string) => void;
|
|
7960
|
+
/** Parent message ID for branching (edit/regenerate). Sets on the user message. */
|
|
7961
|
+
parentMessageId?: string;
|
|
7962
|
+
/**
|
|
7963
|
+
* Pre-generated unique ID for the assistant response message.
|
|
7964
|
+
* When provided, the persisted assistant message will use this ID instead of
|
|
7965
|
+
* an auto-generated one. This lets the consumer show an in-flight streaming
|
|
7966
|
+
* placeholder under the same React key, avoiding an unmount/remount flash
|
|
7967
|
+
* when streaming completes and the message is loaded from the database.
|
|
7968
|
+
*/
|
|
7969
|
+
assistantUniqueId?: string;
|
|
7970
|
+
}
|
|
7971
|
+
interface BaseSendMessageSuccessResult {
|
|
7972
|
+
data: ApiResponse;
|
|
7973
|
+
error: null;
|
|
7974
|
+
userMessage: StoredMessage;
|
|
7975
|
+
assistantMessage: StoredMessage;
|
|
7976
|
+
/** Results from tools the SDK auto-executed this turn (e.g. display tools). */
|
|
7977
|
+
autoExecutedToolResults?: {
|
|
7978
|
+
name: string;
|
|
7979
|
+
result: unknown;
|
|
7980
|
+
}[];
|
|
7981
|
+
/**
|
|
7982
|
+
* The synthetic `[Tool Execution Results]` row those results were persisted as.
|
|
7983
|
+
*
|
|
7984
|
+
* Returned so a caller can key its transient overlay on the id the SDK actually wrote instead of
|
|
7985
|
+
* deriving one and hoping the two agree — that guesswork is what mobile's per-card persist
|
|
7986
|
+
* workarounds existed to do (#5519). Absent when the turn executed no tools, or when the row write
|
|
7987
|
+
* failed (non-fatal: the assistant reply is already stored).
|
|
7988
|
+
*/
|
|
7989
|
+
toolResultsMessage?: StoredMessage;
|
|
7990
|
+
}
|
|
7991
|
+
interface BaseSendMessageSkippedResult {
|
|
7992
|
+
data: ApiResponse;
|
|
7993
|
+
error: null;
|
|
7994
|
+
userMessage?: undefined;
|
|
7995
|
+
assistantMessage?: undefined;
|
|
7996
|
+
autoExecutedToolResults?: {
|
|
7997
|
+
name: string;
|
|
7998
|
+
result: unknown;
|
|
7999
|
+
}[];
|
|
8000
|
+
/** Indicates this was a skipStorage request - no messages were persisted */
|
|
8001
|
+
skipped: true;
|
|
8002
|
+
}
|
|
8003
|
+
interface BaseSendMessageErrorResult {
|
|
8004
|
+
data: null;
|
|
8005
|
+
error: string;
|
|
8006
|
+
userMessage?: StoredMessage;
|
|
8007
|
+
assistantMessage?: undefined;
|
|
8008
|
+
}
|
|
8009
|
+
type BaseSendMessageWithStorageResult = BaseSendMessageSuccessResult | BaseSendMessageSkippedResult | BaseSendMessageErrorResult;
|
|
8010
|
+
interface BaseUseChatStorageResult {
|
|
8011
|
+
isLoading: boolean;
|
|
8012
|
+
stop: () => void;
|
|
8013
|
+
conversationId: string | null;
|
|
8014
|
+
setConversationId: (id: string | null) => void;
|
|
8015
|
+
createConversation: (options?: CreateConversationOptions) => Promise<StoredConversation>;
|
|
8016
|
+
getConversation: (id: string) => Promise<StoredConversation | null>;
|
|
8017
|
+
getConversations: () => Promise<StoredConversation[]>;
|
|
8018
|
+
updateConversationTitle: (id: string, title: string) => Promise<boolean>;
|
|
8019
|
+
updateConversationPinned: (id: string, pinned: boolean) => Promise<boolean>;
|
|
8020
|
+
deleteConversation: (id: string) => Promise<boolean>;
|
|
8021
|
+
getMessages: (conversationId: string) => Promise<StoredMessage[]>;
|
|
8022
|
+
/**
|
|
8023
|
+
* Paginated display read: the newest `limit` messages (optionally below
|
|
8024
|
+
* `beforeMessageId`), ascending, with embedding columns skipped.
|
|
8025
|
+
*/
|
|
8026
|
+
getMessagesPage: (conversationId: string, options: GetMessagesPageOptions) => Promise<StoredMessage[]>;
|
|
8027
|
+
/** Whole-thread branch-tree skeleton — no field decryption. */
|
|
8028
|
+
getMessageSkeletons: (conversationId: string) => Promise<MessageSkeleton[]>;
|
|
8029
|
+
/** Total message count for a conversation. */
|
|
8030
|
+
getMessageCount: (conversationId: string) => Promise<number>;
|
|
8031
|
+
}
|
|
8032
|
+
declare function generateConversationId(): string;
|
|
8033
|
+
|
|
8034
|
+
/**
|
|
8035
|
+
* A finished background answer, as portal sealed it into the vault inbox.
|
|
8036
|
+
* @public
|
|
8037
|
+
*/
|
|
8038
|
+
type InboxPlaintext = {
|
|
8039
|
+
v: 1;
|
|
8040
|
+
inference_id: string;
|
|
8041
|
+
conversation_id: string;
|
|
8042
|
+
parent_message_id: string | null;
|
|
8043
|
+
assistant_message_id?: string | null;
|
|
8044
|
+
api_type: "responses" | "completions";
|
|
8045
|
+
model: string;
|
|
8046
|
+
status: "completed" | "tool_request";
|
|
8047
|
+
pending_tool: string | null;
|
|
8048
|
+
response: ApiResponse;
|
|
8049
|
+
finished_at: string;
|
|
8050
|
+
};
|
|
8051
|
+
/**
|
|
8052
|
+
* One sealed item in the vault inbox.
|
|
8053
|
+
* @public
|
|
8054
|
+
*/
|
|
8055
|
+
type InboxItem = {
|
|
8056
|
+
id: string;
|
|
8057
|
+
sealed: string;
|
|
8058
|
+
created_at: string;
|
|
8059
|
+
};
|
|
8060
|
+
/**
|
|
8061
|
+
* The account's vault inbox and the public key portal seals answers to.
|
|
8062
|
+
* @public
|
|
8063
|
+
*/
|
|
8064
|
+
interface VaultInbox {
|
|
8065
|
+
putPublicKey(publicKey: string): Promise<void>;
|
|
8066
|
+
list(): Promise<InboxItem[]>;
|
|
8067
|
+
remove(id: string): Promise<void>;
|
|
8068
|
+
}
|
|
8069
|
+
/**
|
|
8070
|
+
* The vault inbox client, under the same `/api/private-chats` routes as the chat store.
|
|
8071
|
+
* @public
|
|
8072
|
+
*/
|
|
8073
|
+
declare function createVaultInbox(options: {
|
|
8074
|
+
baseUrl: string;
|
|
8075
|
+
getToken: () => Promise<string | null>;
|
|
8076
|
+
fetch?: typeof globalThis.fetch;
|
|
8077
|
+
timeoutMs?: number;
|
|
8078
|
+
}): VaultInbox;
|
|
8079
|
+
/** The 65-byte uncompressed P-256 point, base64url, as vault stores it. */
|
|
8080
|
+
declare function exportInboxPublicKey(publicKey: CryptoKey): Promise<string>;
|
|
8081
|
+
/** Decrypt a sealed inbox item with the account's ECDH key pair. */
|
|
8082
|
+
declare function openInboxItem(item: Pick<InboxItem, "id" | "sealed">, keyPair: CryptoKeyPair): Promise<InboxPlaintext>;
|
|
8083
|
+
/**
|
|
8084
|
+
* Outcome of delivering one vault inbox item.
|
|
8085
|
+
* @public
|
|
8086
|
+
*/
|
|
8087
|
+
type InboxDeliveryResult = {
|
|
8088
|
+
id: string;
|
|
8089
|
+
conversationId: string | null;
|
|
8090
|
+
status: "stored" | "delivered" | "elsewhere" | "unreadable" | "retry";
|
|
8091
|
+
assistantMessage: StoredMessage | null;
|
|
8092
|
+
error?: string;
|
|
8093
|
+
};
|
|
8094
|
+
|
|
8095
|
+
/**
|
|
8096
|
+
* What became of a restaurant booking or cancellation in one turn, read from
|
|
8097
|
+
* the server's own tool result rather than from the model's reply.
|
|
8098
|
+
*/
|
|
8099
|
+
type ReservationReceipt = {
|
|
8100
|
+
kind: "booking" | "cancel";
|
|
8101
|
+
/**
|
|
8102
|
+
* `made`: the provider confirmed it. `not_made`: it did not happen.
|
|
8103
|
+
* `already_done`: an earlier call in the conversation had already done it.
|
|
8104
|
+
* `unknown`: the call reached the provider and its outcome is not known.
|
|
8105
|
+
*/
|
|
8106
|
+
status: "made" | "not_made" | "already_done" | "unknown";
|
|
8107
|
+
venueName: string;
|
|
8108
|
+
/** As the call sent it, e.g. `2026-10-23`. */
|
|
8109
|
+
day: string;
|
|
8110
|
+
/** As the call sent it, e.g. `9:00 PM`. */
|
|
8111
|
+
time: string;
|
|
8112
|
+
partySize?: number;
|
|
8113
|
+
reservationId?: string;
|
|
8114
|
+
/** Resy page where the user can see the reservation. */
|
|
8115
|
+
resyUrl?: string;
|
|
8116
|
+
/** The restaurant's own cancellation terms, when the booking result carries them. */
|
|
8117
|
+
feeSummary?: string;
|
|
8118
|
+
/** The provider's stated reason, when it did not happen. */
|
|
8119
|
+
reason?: string;
|
|
8120
|
+
};
|
|
8121
|
+
/** One receipt per kind for the turn's booking and cancel calls, holding the last attempt's outcome unless an earlier one was `made` or `unknown`. */
|
|
8122
|
+
declare function extractReservationReceipts(toolCallEvents?: LlmapiToolCallEvent[]): ReservationReceipt[];
|
|
8123
|
+
|
|
8124
|
+
/**
|
|
8125
|
+
* Build the replay path for a detached stream. The portal serves the buffered
|
|
8126
|
+
* stream from seq 0 on a GET to this path — no `starting_after`, no `id:`
|
|
8127
|
+
* cursor, no request body. Replay always starts from the first buffered byte
|
|
8128
|
+
* and the client rebuilds its own view with a fresh accumulator; partial
|
|
8129
|
+
* client state is never sent back to the server.
|
|
8130
|
+
*
|
|
8131
|
+
* Exported so client repos can mock the endpoint in E2E without string drift.
|
|
8132
|
+
*/
|
|
8133
|
+
declare function streamReplayPath(inferenceId: string): string;
|
|
8134
|
+
/**
|
|
8135
|
+
* Build the cancel path for a detached stream. A POST here tells the portal to
|
|
8136
|
+
* stop generating into the buffer and release it — the billing-safe teardown
|
|
8137
|
+
* for "the user pressed stop after we'd already detached".
|
|
8138
|
+
*
|
|
8139
|
+
* Exported so client repos can mock the endpoint in E2E without string drift.
|
|
8140
|
+
*/
|
|
8141
|
+
declare function streamCancelPath(inferenceId: string): string;
|
|
8142
|
+
/**
|
|
8143
|
+
* A generation still running on the portal for the caller.
|
|
8144
|
+
* @public
|
|
8145
|
+
*/
|
|
8146
|
+
type ActiveStream = {
|
|
8147
|
+
inferenceId: string;
|
|
8148
|
+
assistantMessageId: string | null;
|
|
8149
|
+
conversationId: string | null;
|
|
8150
|
+
parentMessageId: string | null;
|
|
8151
|
+
apiType: "responses" | "completions";
|
|
8152
|
+
model?: string;
|
|
8153
|
+
startedAt: string;
|
|
8154
|
+
};
|
|
8155
|
+
/** List the caller's generations still running on the portal. */
|
|
8156
|
+
declare function listActiveStreams(options: {
|
|
8157
|
+
token: string;
|
|
8158
|
+
baseUrl?: string;
|
|
8159
|
+
conversationId?: string;
|
|
8160
|
+
fetch?: typeof globalThis.fetch;
|
|
8161
|
+
}): Promise<ActiveStream[]>;
|
|
8162
|
+
/**
|
|
8163
|
+
* Thrown when the portal answers `410 Gone` to a replay GET: the buffered
|
|
8164
|
+
* stream is gone — expired (10-min sliding TTL), absent, not owned by the
|
|
8165
|
+
* caller, or already cancelled. There is nothing to replay; the answer is
|
|
8166
|
+
* permanently lost and the caller should fall back to a fresh send rather than
|
|
8167
|
+
* retry. A `stop()`-then-resume race lands here and finalizes as stopped, which
|
|
8168
|
+
* is correct.
|
|
8169
|
+
*
|
|
8170
|
+
* `resumeStream` throws this (it does not return it) and fires neither
|
|
8171
|
+
* `onFinish` nor `onError` — there is no body to deliver.
|
|
8172
|
+
* @public
|
|
8173
|
+
*/
|
|
8174
|
+
declare class StreamExpiredError extends Error {
|
|
8175
|
+
readonly name = "StreamExpiredError";
|
|
8176
|
+
readonly inferenceId: string;
|
|
8177
|
+
constructor(inferenceId: string, message?: string);
|
|
8178
|
+
}
|
|
8179
|
+
/**
|
|
8180
|
+
* Options for {@link resumeStream}.
|
|
8181
|
+
* @public
|
|
8182
|
+
*/
|
|
8183
|
+
interface ResumeStreamOptions {
|
|
8184
|
+
/** The handle captured from a detached `runToolLoop` result. */
|
|
8185
|
+
handle: StreamResumeHandle;
|
|
8293
8186
|
/**
|
|
8294
|
-
*
|
|
8295
|
-
*
|
|
8187
|
+
* Fresh bearer token. The CALLER fetches it at resume time — a multi-minute
|
|
8188
|
+
* background gap expires the bearer, so a token captured when the original
|
|
8189
|
+
* stream started must never be reused (see `useChat.resumeStream`).
|
|
8296
8190
|
*/
|
|
8297
|
-
|
|
8191
|
+
token: string;
|
|
8192
|
+
/** Base URL for the portal. @default the SDK's configured BASE_URL. */
|
|
8193
|
+
baseUrl?: string;
|
|
8298
8194
|
/**
|
|
8299
|
-
*
|
|
8300
|
-
*
|
|
8195
|
+
* Streaming transport. Defaults to the GET-capable fetch transport; Expo
|
|
8196
|
+
* passes `xhrTransport` (RN can't stream `fetch` bodies).
|
|
8301
8197
|
*/
|
|
8302
|
-
|
|
8198
|
+
transport?: StreamingTransport;
|
|
8199
|
+
/** Aborts the replay; the partial is returned as an interrupted result. */
|
|
8200
|
+
signal?: AbortSignal;
|
|
8201
|
+
/** Adaptive output smoothing for the replayed content. @default true */
|
|
8202
|
+
smoothing?: StreamSmoothingConfig | boolean;
|
|
8303
8203
|
/**
|
|
8304
|
-
*
|
|
8305
|
-
* - undefined: Include all server-side tools (default)
|
|
8306
|
-
* - string[]: Include only tools with these names
|
|
8307
|
-
* - []: Include no server-side tools
|
|
8308
|
-
* - function: Dynamic filter that receives prompt embedding(s) and all tools,
|
|
8309
|
-
* returns tool names to include. Useful for semantic tool matching.
|
|
8310
|
-
*
|
|
8311
|
-
* @example
|
|
8312
|
-
* // Include only specific server tools
|
|
8313
|
-
* serverTools: ["anuma_create_image", "perplexity_search"]
|
|
8314
|
-
*
|
|
8315
|
-
* // Disable server tools for this request
|
|
8316
|
-
* serverTools: []
|
|
8204
|
+
* Client-side watchdog for a dead live-tail. @default 120_000ms.
|
|
8317
8205
|
*
|
|
8318
|
-
*
|
|
8319
|
-
*
|
|
8320
|
-
*
|
|
8321
|
-
*
|
|
8322
|
-
*
|
|
8206
|
+
* Deliberately NOT ~30s: the portal tolerates >100s reasoning silences (no
|
|
8207
|
+
* `data:` frames on the replay connection during them) and its own liveness
|
|
8208
|
+
* rule (heartbeat stale >90s => SSE error + `[DONE]`) is the authoritative
|
|
8209
|
+
* guard. This client timer is a backstop for a half-open TCP connection and
|
|
8210
|
+
* must sit ABOVE the server's 90s rule so the server error always wins when
|
|
8211
|
+
* the portal is reachable. Set to 0 / Infinity to disable.
|
|
8323
8212
|
*/
|
|
8324
|
-
|
|
8213
|
+
idleTimeoutMs?: number;
|
|
8214
|
+
/** Content text deltas as they replay (always from seq 0 — reset accumulated text first). */
|
|
8215
|
+
onData?: (chunk: string) => void;
|
|
8216
|
+
/** Thinking/reasoning deltas as they replay. */
|
|
8217
|
+
onThinking?: (chunk: string) => void;
|
|
8218
|
+
/** Restores the placeholders this redactor assigned when the original request was sent. */
|
|
8219
|
+
piiRedactor?: PiiRedactor;
|
|
8220
|
+
/** Called once on a clean completion. Never called for 410 nor interrupted terminals. */
|
|
8221
|
+
onFinish?: (response: ApiResponse) => void;
|
|
8222
|
+
/** Called on a transient/unexpected failure. Never called for 410 (throws) nor interrupted terminals. */
|
|
8223
|
+
onError?: (error: Error) => void;
|
|
8224
|
+
}
|
|
8225
|
+
/**
|
|
8226
|
+
* Result of {@link resumeStream}. A `410 Gone` is the only outcome that throws
|
|
8227
|
+
* ({@link StreamExpiredError}); every other terminal is returned.
|
|
8228
|
+
*
|
|
8229
|
+
* - clean completion → `{ data, error: null, interrupted: false, empty }`
|
|
8230
|
+
* - in-stream error / tool-request terminal / idle timeout → `{ data, error,
|
|
8231
|
+
* interrupted: true }` (finalize as a stopped/partial message)
|
|
8232
|
+
* - transient transport/HTTP failure (401, 5xx, network) → `{ data, error,
|
|
8233
|
+
* interrupted: false, statusCode? }` (retryable — keep the handle)
|
|
8234
|
+
*
|
|
8235
|
+
* `empty` is true when the clean terminal delivered ZERO content/thinking
|
|
8236
|
+
* deltas — a `[DONE]`-only replay. That is never a real completion (a
|
|
8237
|
+
* completed generation always buffered at least one content frame); it means
|
|
8238
|
+
* the buffered frames were lost server-side (evicted/trimmed) while the
|
|
8239
|
+
* terminal survived. Consumers must NOT persist `data` (an empty response)
|
|
8240
|
+
* over content they already hold — keep the detached partial instead. On the
|
|
8241
|
+
* empty terminal `onFinish` is NOT fired (there is no completion to deliver);
|
|
8242
|
+
* the flag is optional so existing constructors of the clean arm stay valid.
|
|
8243
|
+
* @public
|
|
8244
|
+
*/
|
|
8245
|
+
type ResumeStreamResult = {
|
|
8246
|
+
data: ApiResponse;
|
|
8247
|
+
error: null;
|
|
8248
|
+
interrupted: false;
|
|
8249
|
+
empty?: boolean;
|
|
8250
|
+
} | {
|
|
8251
|
+
data: ApiResponse | null;
|
|
8252
|
+
error: string;
|
|
8253
|
+
interrupted: boolean;
|
|
8254
|
+
statusCode?: number;
|
|
8255
|
+
};
|
|
8256
|
+
/**
|
|
8257
|
+
* Replay a detached stream from the portal's buffer.
|
|
8258
|
+
*
|
|
8259
|
+
* This is the reconnect primitive: after `runToolLoop` returns the detached
|
|
8260
|
+
* variant with a {@link StreamResumeHandle}, `resumeStream` issues a GET to the
|
|
8261
|
+
* portal's replay endpoint and rebuilds the response from seq 0 using a FRESH
|
|
8262
|
+
* accumulator and FRESH smoothers. Nothing from the original (detached) run is
|
|
8263
|
+
* reused — the completions strategy's reasoning-tag parser is stateful, so
|
|
8264
|
+
* replaying into reused state would double-count; replay-from-0 into fresh
|
|
8265
|
+
* state is the correctness mechanism, not just a simplification.
|
|
8266
|
+
*
|
|
8267
|
+
* Contract highlights:
|
|
8268
|
+
* - **No `starting_after`, no `id:` cursor, no body.** The GET carries the
|
|
8269
|
+
* inference id in the path only; replay is always whole-stream. (The server
|
|
8270
|
+
* reserves `starting_after` but does NOT honor it — sending it would silently
|
|
8271
|
+
* duplicate content.)
|
|
8272
|
+
* - **410 → throws {@link StreamExpiredError}.** No `onFinish`/`onError`.
|
|
8273
|
+
* - **In-stream error / tool-request terminal → `interrupted: true`.** Flushes
|
|
8274
|
+
* both smoothers and returns the partial; no throw, no `onError`, no `onFinish`.
|
|
8275
|
+
* - **token resolved by the caller at resume time** so a refresh during the
|
|
8276
|
+
* detach window is honored.
|
|
8277
|
+
*
|
|
8278
|
+
* @public
|
|
8279
|
+
*/
|
|
8280
|
+
declare function resumeStream(options: ResumeStreamOptions): Promise<ResumeStreamResult>;
|
|
8281
|
+
|
|
8282
|
+
interface StockPriceClassification {
|
|
8283
|
+
/** Whether the prompt likely asks for stock/ETF/FX quote data. */
|
|
8284
|
+
needsStockPrice: boolean;
|
|
8285
|
+
/** Cosine similarity to the "needs stock price" centroid. */
|
|
8286
|
+
stockPriceScore: number;
|
|
8287
|
+
/** Cosine similarity to the "no stock price" centroid. */
|
|
8288
|
+
noStockPriceScore: number;
|
|
8289
|
+
}
|
|
8290
|
+
interface StockPriceClassifierOptions extends EmbeddingOptions {
|
|
8325
8291
|
/**
|
|
8326
|
-
*
|
|
8327
|
-
*
|
|
8328
|
-
*
|
|
8329
|
-
*
|
|
8330
|
-
* @example
|
|
8331
|
-
* clientToolsFilter: (embeddings, tools) => {
|
|
8332
|
-
* if (!embeddings) return []; // Short message — no client tools
|
|
8333
|
-
* const matches = findMatchingTools(embeddings, pseudoServerTools);
|
|
8334
|
-
* return matches.map(m => m.tool.name);
|
|
8335
|
-
* }
|
|
8292
|
+
* Score margin: the stock-price score must exceed the no-stock-price
|
|
8293
|
+
* score by at least this amount to classify as "needs stock price data".
|
|
8294
|
+
* @default 0.02
|
|
8336
8295
|
*/
|
|
8337
|
-
|
|
8296
|
+
margin?: number;
|
|
8297
|
+
}
|
|
8298
|
+
/**
|
|
8299
|
+
* Classify whether a prompt needs stock/ETF/index/FX price data.
|
|
8300
|
+
*
|
|
8301
|
+
* Domain: traditional financial instruments (equities, indices, ETFs, FX).
|
|
8302
|
+
* Crypto is handled by `classifyCryptoPrice`. Ambiguous prompts
|
|
8303
|
+
* (e.g. *"gold price"*) may fire both — that's expected; the caller can
|
|
8304
|
+
* inject both sets of results.
|
|
8305
|
+
*/
|
|
8306
|
+
declare function classifyStockPrice(prompt: string, options: StockPriceClassifierOptions): Promise<StockPriceClassification>;
|
|
8307
|
+
/**
|
|
8308
|
+
* Batch-classify multiple prompts. Embeds all prompts in one batch
|
|
8309
|
+
* call for efficiency.
|
|
8310
|
+
*/
|
|
8311
|
+
declare function classifyStockPriceBatch(prompts: string[], options: StockPriceClassifierOptions): Promise<StockPriceClassification[]>;
|
|
8312
|
+
interface StockPricePreProcessorOptions {
|
|
8338
8313
|
/**
|
|
8339
|
-
*
|
|
8340
|
-
*
|
|
8341
|
-
*
|
|
8342
|
-
* -
|
|
8343
|
-
*
|
|
8344
|
-
*
|
|
8314
|
+
* Called with the caller's stock-quote provider when the classifier
|
|
8315
|
+
* decides the prompt is asking for stock/ETF/FX data. Return either a
|
|
8316
|
+
* plain string (wrapped by the SDK in a default user message) or a
|
|
8317
|
+
* fully-formed `LlmapiMessage[]` (full control over role/shape). Omit
|
|
8318
|
+
* to run in observer mode — classification still fires but nothing is
|
|
8319
|
+
* injected.
|
|
8320
|
+
*
|
|
8321
|
+
* The `signal` argument is forwarded from the tool loop so long-running
|
|
8322
|
+
* provider requests can be aborted when the caller aborts.
|
|
8345
8323
|
*/
|
|
8346
|
-
|
|
8324
|
+
fetchStockPriceData?: (prompt: string, options: {
|
|
8325
|
+
signal?: AbortSignal;
|
|
8326
|
+
}) => Promise<string | LlmapiMessage[]>;
|
|
8347
8327
|
/**
|
|
8348
|
-
*
|
|
8349
|
-
*
|
|
8350
|
-
*
|
|
8351
|
-
* @default 3
|
|
8328
|
+
* Score margin: `stockPriceScore` must exceed `noStockPriceScore` by at
|
|
8329
|
+
* least this amount to classify as "needs stock price data".
|
|
8330
|
+
* @default 0.02
|
|
8352
8331
|
*/
|
|
8353
|
-
|
|
8332
|
+
margin?: number;
|
|
8333
|
+
/** Observe the classification without injecting anything. */
|
|
8334
|
+
onClassification?: (result: StockPriceClassification) => void;
|
|
8335
|
+
}
|
|
8336
|
+
/**
|
|
8337
|
+
* Build a pre-processor that runs stock-price classification on the shared
|
|
8338
|
+
* embedding provided by `runToolLoop`, and — if the classifier decides the
|
|
8339
|
+
* prompt is asking for quotes — invokes the caller-supplied
|
|
8340
|
+
* `fetchStockPriceData` and injects the result into the conversation.
|
|
8341
|
+
*
|
|
8342
|
+
* Domain: stocks, ETFs, indices, FX. For crypto use
|
|
8343
|
+
* `createCryptoPricePreProcessor`. The SDK does not run the lookup itself;
|
|
8344
|
+
* the caller wires up whichever provider they want (Twelve Data, Alpha
|
|
8345
|
+
* Vantage, Finnhub, etc.).
|
|
8346
|
+
*/
|
|
8347
|
+
declare function createStockPricePreProcessor(options?: StockPricePreProcessorOptions): PromptPreProcessor;
|
|
8348
|
+
|
|
8349
|
+
/**
|
|
8350
|
+
* Value of the `origin` column on a row the SDK synthesised for a turn's tool results (v44, #866).
|
|
8351
|
+
*
|
|
8352
|
+
* `satisfies MessageOrigin` so this constant and the column's union cannot drift apart silently.
|
|
8353
|
+
*/
|
|
8354
|
+
declare const TOOL_RESULT_ORIGIN = "tool_result";
|
|
8355
|
+
|
|
8356
|
+
interface WeatherClassification {
|
|
8357
|
+
/** Whether the prompt likely asks for weather data. */
|
|
8358
|
+
needsWeather: boolean;
|
|
8359
|
+
/** Cosine similarity to the "needs weather" centroid. */
|
|
8360
|
+
weatherScore: number;
|
|
8361
|
+
/** Cosine similarity to the "no weather" centroid. */
|
|
8362
|
+
noWeatherScore: number;
|
|
8363
|
+
}
|
|
8364
|
+
interface WeatherClassifierOptions extends EmbeddingOptions {
|
|
8354
8365
|
/**
|
|
8355
|
-
*
|
|
8356
|
-
*
|
|
8366
|
+
* Score margin: the weather score must exceed the no-weather score by at
|
|
8367
|
+
* least this amount to classify as "needs weather data".
|
|
8368
|
+
* @default 0.02
|
|
8357
8369
|
*/
|
|
8358
|
-
|
|
8370
|
+
margin?: number;
|
|
8371
|
+
}
|
|
8372
|
+
/**
|
|
8373
|
+
* Classify whether a prompt needs weather data.
|
|
8374
|
+
*
|
|
8375
|
+
* Covers forecasts, temperature, precipitation, wind, humidity, UV, AQI,
|
|
8376
|
+
* marine, flood, climate — anything OpenMeteo-shaped.
|
|
8377
|
+
*/
|
|
8378
|
+
declare function classifyWeather(prompt: string, options: WeatherClassifierOptions): Promise<WeatherClassification>;
|
|
8379
|
+
/**
|
|
8380
|
+
* Batch-classify multiple prompts. Embeds all prompts in one batch
|
|
8381
|
+
* call for efficiency.
|
|
8382
|
+
*/
|
|
8383
|
+
declare function classifyWeatherBatch(prompts: string[], options: WeatherClassifierOptions): Promise<WeatherClassification[]>;
|
|
8384
|
+
interface WeatherPreProcessorOptions {
|
|
8359
8385
|
/**
|
|
8360
|
-
*
|
|
8361
|
-
*
|
|
8362
|
-
*
|
|
8386
|
+
* Called with the caller's weather provider when the classifier decides
|
|
8387
|
+
* the prompt is asking for weather. Return either a plain string
|
|
8388
|
+
* (wrapped by the SDK in a default user message) or a fully-formed
|
|
8389
|
+
* `LlmapiMessage[]` (full control over role/shape). Omit to run in
|
|
8390
|
+
* observer mode — classification still fires but nothing is injected.
|
|
8391
|
+
*
|
|
8392
|
+
* The `signal` argument is forwarded from the tool loop so long-running
|
|
8393
|
+
* provider requests can be aborted when the caller aborts.
|
|
8363
8394
|
*/
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
|
|
8395
|
+
fetchWeatherData?: (prompt: string, options: {
|
|
8396
|
+
signal?: AbortSignal;
|
|
8397
|
+
}) => Promise<string | LlmapiMessage[]>;
|
|
8367
8398
|
/**
|
|
8368
|
-
*
|
|
8369
|
-
*
|
|
8370
|
-
*
|
|
8399
|
+
* Score margin: `weatherScore` must exceed `noWeatherScore` by at least
|
|
8400
|
+
* this amount to classify as "needs weather data".
|
|
8401
|
+
* @default 0.02
|
|
8371
8402
|
*/
|
|
8372
|
-
|
|
8373
|
-
/**
|
|
8374
|
-
|
|
8403
|
+
margin?: number;
|
|
8404
|
+
/** Observe the classification without injecting anything. */
|
|
8405
|
+
onClassification?: (result: WeatherClassification) => void;
|
|
8406
|
+
}
|
|
8407
|
+
/**
|
|
8408
|
+
* Build a pre-processor that runs weather classification on the shared
|
|
8409
|
+
* embedding provided by `runToolLoop`, and — if the classifier decides
|
|
8410
|
+
* the prompt is asking for weather — invokes the caller-supplied
|
|
8411
|
+
* `fetchWeatherData` and injects the result into the conversation.
|
|
8412
|
+
*
|
|
8413
|
+
* The SDK does not run the weather lookup itself; the caller wires up
|
|
8414
|
+
* whichever provider they want (OpenMeteo, AccuWeather, weather.gov, etc.).
|
|
8415
|
+
*/
|
|
8416
|
+
declare function createWeatherPreProcessor(options?: WeatherPreProcessorOptions): PromptPreProcessor;
|
|
8417
|
+
|
|
8418
|
+
interface WebSearchClassification {
|
|
8419
|
+
/** Whether the prompt likely needs a web search. */
|
|
8420
|
+
needsWebSearch: boolean;
|
|
8421
|
+
/** Cosine similarity to the "needs search" centroid. */
|
|
8422
|
+
searchScore: number;
|
|
8423
|
+
/** Cosine similarity to the "no search" centroid. */
|
|
8424
|
+
noSearchScore: number;
|
|
8425
|
+
}
|
|
8426
|
+
interface WebSearchClassifierOptions extends EmbeddingOptions {
|
|
8375
8427
|
/**
|
|
8376
|
-
*
|
|
8377
|
-
*
|
|
8378
|
-
*
|
|
8379
|
-
* placeholder under the same React key, avoiding an unmount/remount flash
|
|
8380
|
-
* when streaming completes and the message is loaded from the database.
|
|
8428
|
+
* Score margin: the search score must exceed the no-search score
|
|
8429
|
+
* by at least this amount to classify as "needs web search".
|
|
8430
|
+
* @default 0.02
|
|
8381
8431
|
*/
|
|
8382
|
-
|
|
8432
|
+
margin?: number;
|
|
8383
8433
|
}
|
|
8384
|
-
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
|
|
8392
|
-
|
|
8393
|
-
|
|
8434
|
+
/**
|
|
8435
|
+
* Classify whether a prompt needs a web search.
|
|
8436
|
+
*
|
|
8437
|
+
* Embeds the prompt and compares it against the pre-computed
|
|
8438
|
+
* search and no-search centroid vectors.
|
|
8439
|
+
*/
|
|
8440
|
+
declare function classifyWebSearch(prompt: string, options: WebSearchClassifierOptions): Promise<WebSearchClassification>;
|
|
8441
|
+
/**
|
|
8442
|
+
* Batch-classify multiple prompts. Embeds all prompts in one batch
|
|
8443
|
+
* call for efficiency.
|
|
8444
|
+
*/
|
|
8445
|
+
declare function classifyWebSearchBatch(prompts: string[], options: WebSearchClassifierOptions): Promise<WebSearchClassification[]>;
|
|
8446
|
+
interface WebSearchPreProcessorOptions {
|
|
8394
8447
|
/**
|
|
8395
|
-
*
|
|
8448
|
+
* Called with the caller's search provider when the classifier decides
|
|
8449
|
+
* a web search is needed. Return either a plain string (the SDK will
|
|
8450
|
+
* wrap it in a default user message) or a fully-formed message array
|
|
8451
|
+
* (full control over role/shape). Omit to run in observer mode —
|
|
8452
|
+
* classification still fires but no messages are injected.
|
|
8396
8453
|
*
|
|
8397
|
-
*
|
|
8398
|
-
*
|
|
8399
|
-
* workarounds existed to do (#5519). Absent when the turn executed no tools, or when the row write
|
|
8400
|
-
* failed (non-fatal: the assistant reply is already stored).
|
|
8454
|
+
* The `signal` argument is forwarded from the tool loop so long-running
|
|
8455
|
+
* search requests can be aborted when the caller aborts.
|
|
8401
8456
|
*/
|
|
8402
|
-
|
|
8403
|
-
|
|
8404
|
-
|
|
8405
|
-
data: ApiResponse;
|
|
8406
|
-
error: null;
|
|
8407
|
-
userMessage?: undefined;
|
|
8408
|
-
assistantMessage?: undefined;
|
|
8409
|
-
autoExecutedToolResults?: {
|
|
8410
|
-
name: string;
|
|
8411
|
-
result: unknown;
|
|
8412
|
-
}[];
|
|
8413
|
-
/** Indicates this was a skipStorage request - no messages were persisted */
|
|
8414
|
-
skipped: true;
|
|
8415
|
-
}
|
|
8416
|
-
interface BaseSendMessageErrorResult {
|
|
8417
|
-
data: null;
|
|
8418
|
-
error: string;
|
|
8419
|
-
userMessage?: StoredMessage;
|
|
8420
|
-
assistantMessage?: undefined;
|
|
8421
|
-
}
|
|
8422
|
-
type BaseSendMessageWithStorageResult = BaseSendMessageSuccessResult | BaseSendMessageSkippedResult | BaseSendMessageErrorResult;
|
|
8423
|
-
interface BaseUseChatStorageResult {
|
|
8424
|
-
isLoading: boolean;
|
|
8425
|
-
stop: () => void;
|
|
8426
|
-
conversationId: string | null;
|
|
8427
|
-
setConversationId: (id: string | null) => void;
|
|
8428
|
-
createConversation: (options?: CreateConversationOptions) => Promise<StoredConversation>;
|
|
8429
|
-
getConversation: (id: string) => Promise<StoredConversation | null>;
|
|
8430
|
-
getConversations: () => Promise<StoredConversation[]>;
|
|
8431
|
-
updateConversationTitle: (id: string, title: string) => Promise<boolean>;
|
|
8432
|
-
updateConversationPinned: (id: string, pinned: boolean) => Promise<boolean>;
|
|
8433
|
-
deleteConversation: (id: string) => Promise<boolean>;
|
|
8434
|
-
getMessages: (conversationId: string) => Promise<StoredMessage[]>;
|
|
8457
|
+
fetchSearchResults?: (prompt: string, options: {
|
|
8458
|
+
signal?: AbortSignal;
|
|
8459
|
+
}) => Promise<string | LlmapiMessage[]>;
|
|
8435
8460
|
/**
|
|
8436
|
-
*
|
|
8437
|
-
*
|
|
8461
|
+
* Score margin: `searchScore` must exceed `noSearchScore` by at least
|
|
8462
|
+
* this amount to classify as "needs web search".
|
|
8463
|
+
* @default 0.02
|
|
8438
8464
|
*/
|
|
8439
|
-
|
|
8440
|
-
/**
|
|
8441
|
-
|
|
8442
|
-
/** Total message count for a conversation. */
|
|
8443
|
-
getMessageCount: (conversationId: string) => Promise<number>;
|
|
8465
|
+
margin?: number;
|
|
8466
|
+
/** Observe the classification without injecting anything. */
|
|
8467
|
+
onClassification?: (result: WebSearchClassification) => void;
|
|
8444
8468
|
}
|
|
8445
|
-
|
|
8469
|
+
/**
|
|
8470
|
+
* Build a pre-processor that runs web-search classification on the
|
|
8471
|
+
* shared embedding provided by `runToolLoop`, and — if the classifier
|
|
8472
|
+
* decides a search is warranted — invokes the caller-supplied
|
|
8473
|
+
* `fetchSearchResults` and injects the result into the conversation.
|
|
8474
|
+
*
|
|
8475
|
+
* @example Basic usage with a search provider
|
|
8476
|
+
* ```ts
|
|
8477
|
+
* import { runToolLoop, createWebSearchPreProcessor } from "@anuma/sdk/server";
|
|
8478
|
+
*
|
|
8479
|
+
* const webSearch = createWebSearchPreProcessor({
|
|
8480
|
+
* fetchSearchResults: async (prompt, { signal }) => {
|
|
8481
|
+
* const res = await mySearchProvider.query(prompt, { signal });
|
|
8482
|
+
* return res.results.map((r) => `- ${r.title}: ${r.snippet}`).join("\n");
|
|
8483
|
+
* },
|
|
8484
|
+
* });
|
|
8485
|
+
*
|
|
8486
|
+
* await runToolLoop({
|
|
8487
|
+
* messages,
|
|
8488
|
+
* model,
|
|
8489
|
+
* token,
|
|
8490
|
+
* preProcessors: [webSearch],
|
|
8491
|
+
* });
|
|
8492
|
+
* ```
|
|
8493
|
+
*
|
|
8494
|
+
* @example Observer mode — only log classification, inject nothing
|
|
8495
|
+
* ```ts
|
|
8496
|
+
* const observer = createWebSearchPreProcessor({
|
|
8497
|
+
* onClassification: ({ needsWebSearch, searchScore, noSearchScore }) => {
|
|
8498
|
+
* metrics.record({ needsWebSearch, searchScore, noSearchScore });
|
|
8499
|
+
* },
|
|
8500
|
+
* });
|
|
8501
|
+
* ```
|
|
8502
|
+
*
|
|
8503
|
+
* @example Full control — return a custom message shape
|
|
8504
|
+
* ```ts
|
|
8505
|
+
* const webSearch = createWebSearchPreProcessor({
|
|
8506
|
+
* fetchSearchResults: async (prompt, { signal }) => {
|
|
8507
|
+
* const results = await mySearchProvider.query(prompt, { signal });
|
|
8508
|
+
* return [
|
|
8509
|
+
* {
|
|
8510
|
+
* role: "system",
|
|
8511
|
+
* content: [{ type: "text", text: `Search results for "${prompt}":\n${formatResults(results)}` }],
|
|
8512
|
+
* },
|
|
8513
|
+
* ];
|
|
8514
|
+
* },
|
|
8515
|
+
* });
|
|
8516
|
+
* ```
|
|
8517
|
+
*/
|
|
8518
|
+
declare function createWebSearchPreProcessor(options?: WebSearchPreProcessorOptions): PromptPreProcessor;
|
|
8519
|
+
|
|
8520
|
+
/**
|
|
8521
|
+
* XHR-based streaming transport for React Native environments.
|
|
8522
|
+
*
|
|
8523
|
+
* React Native's `fetch` doesn't support `response.body` streaming,
|
|
8524
|
+
* so this transport uses `XMLHttpRequest` with `onprogress` to stream
|
|
8525
|
+
* SSE events. It exposes the same `{ stream: AsyncIterable }` interface
|
|
8526
|
+
* as the default fetch-based transport.
|
|
8527
|
+
*/
|
|
8528
|
+
declare const xhrTransport: StreamingTransport;
|
|
8446
8529
|
|
|
8447
8530
|
/** Returns `value` as an {@link AnumaTurn} when it is one, otherwise `undefined`. */
|
|
8448
8531
|
declare function readAnumaTurn(value: unknown): AnumaTurn | undefined;
|
|
@@ -8530,13 +8613,14 @@ declare function saveSetting(store: ChatStore, section: string, data: {
|
|
|
8530
8613
|
}, signal?: AbortSignal): Promise<Setting>;
|
|
8531
8614
|
|
|
8532
8615
|
/**
|
|
8533
|
-
* AES-GCM keys derived from one wallet signature over `SIGN_MESSAGE`.
|
|
8616
|
+
* AES-GCM keys and the topic HMAC key derived from one wallet signature over `SIGN_MESSAGE`.
|
|
8534
8617
|
* @public
|
|
8535
8618
|
*/
|
|
8536
8619
|
interface MemoryKeyRing {
|
|
8537
8620
|
keyId: string;
|
|
8538
8621
|
v3: CryptoKey;
|
|
8539
8622
|
v2: CryptoKey;
|
|
8623
|
+
topicHash: CryptoKey;
|
|
8540
8624
|
}
|
|
8541
8625
|
/**
|
|
8542
8626
|
* Thrown when no supplied key decrypts a field.
|
|
@@ -8546,17 +8630,18 @@ declare class MemoryKeyError extends Error {
|
|
|
8546
8630
|
constructor(message: string);
|
|
8547
8631
|
}
|
|
8548
8632
|
/**
|
|
8549
|
-
* Derive the v3 and legacy v2 memory keys from a hex wallet signature.
|
|
8633
|
+
* Derive the v3 and legacy v2 memory keys and the topic HMAC key from a hex wallet signature.
|
|
8550
8634
|
* @public
|
|
8551
8635
|
*/
|
|
8552
8636
|
declare function deriveMemoryKeyRing(signatureHex: string): Promise<MemoryKeyRing>;
|
|
8553
8637
|
/**
|
|
8554
|
-
* Encrypt and
|
|
8638
|
+
* Encrypt, decrypt and topic-hash callbacks for `createRemoteMemoryPersistence` under the canonical key.
|
|
8555
8639
|
* @public
|
|
8556
8640
|
*/
|
|
8557
8641
|
declare function memoryCipher(canonical: MemoryKeyRing): {
|
|
8558
8642
|
encrypt: (plaintext: string) => Promise<string>;
|
|
8559
8643
|
decrypt: (ciphertext: string) => Promise<string>;
|
|
8644
|
+
hashTopic: (normalized: string) => Promise<string>;
|
|
8560
8645
|
};
|
|
8561
8646
|
/**
|
|
8562
8647
|
* Re-encrypt a local field under the canonical key.
|
|
@@ -10332,7 +10417,7 @@ interface RemoteMemoryWorkPersistence {
|
|
|
10332
10417
|
releaseWork(kind: RemoteMemoryWorkKind, token: string): Promise<void>;
|
|
10333
10418
|
}
|
|
10334
10419
|
|
|
10335
|
-
/** The nearby private-memory row. Content and
|
|
10420
|
+
/** The nearby private-memory row. Content, kind_value and topic names are plaintext ONLY on the device. */
|
|
10336
10421
|
interface RemoteMemoryRow {
|
|
10337
10422
|
memory_id: string;
|
|
10338
10423
|
content: string;
|
|
@@ -10453,8 +10538,10 @@ interface RemoteMemoryPersistenceOptions {
|
|
|
10453
10538
|
keyId: string;
|
|
10454
10539
|
encrypt: (plaintext: string) => Promise<string>;
|
|
10455
10540
|
decrypt: (ciphertext: string) => Promise<string>;
|
|
10541
|
+
/** Keyed hash of a normalized topic name, as provided by `memoryCipher`. */
|
|
10542
|
+
hashTopic: (normalized: string) => Promise<string>;
|
|
10456
10543
|
fetch?: typeof globalThis.fetch;
|
|
10457
|
-
/** Cancellation for the initial account/key check. Individual operations take their own signal. */
|
|
10544
|
+
/** Cancellation for the initial account/key check and the background topic upgrade. Individual operations take their own signal. */
|
|
10458
10545
|
signal?: AbortSignal;
|
|
10459
10546
|
timeoutMs?: number;
|
|
10460
10547
|
}
|
|
@@ -11915,11 +12002,7 @@ interface UseChatOptions extends BaseUseChatOptions {
|
|
|
11915
12002
|
*/
|
|
11916
12003
|
apiType?: ApiType;
|
|
11917
12004
|
/**
|
|
11918
|
-
*
|
|
11919
|
-
* sends `X-Stream-Resumable: 1` so the portal keeps generating into its
|
|
11920
|
-
* buffer after a client disconnect, and `detach()` can hand back a
|
|
11921
|
-
* {@link StreamResumeHandle} for {@link resumeStream}. Off by default — no
|
|
11922
|
-
* header is sent and `detach()` always resolves to `null`.
|
|
12005
|
+
* Keep each generation running on the portal after a disconnect, so `detach()` or a dropped connection resolves the send as detached with a {@link StreamResumeHandle} for {@link resumeStream}.
|
|
11923
12006
|
* @default false
|
|
11924
12007
|
*/
|
|
11925
12008
|
resumable?: boolean;
|
|
@@ -11954,6 +12037,8 @@ interface UseChatOptions extends BaseUseChatOptions {
|
|
|
11954
12037
|
}
|
|
11955
12038
|
type UseChatResult = BaseUseChatResult & {
|
|
11956
12039
|
sendMessage: (args: SendMessageArgs) => Promise<SendMessageResult>;
|
|
12040
|
+
/** The caller's generations still running on the portal, optionally for one conversation. */
|
|
12041
|
+
getActiveStreams: (conversationId?: string) => Promise<ActiveStream[]>;
|
|
11957
12042
|
/**
|
|
11958
12043
|
* Tear down the in-flight request as a DETACH rather than a stop: the portal
|
|
11959
12044
|
* keeps generating server-side and `sendMessage` resolves with the detached
|
|
@@ -12127,7 +12212,10 @@ interface UseChatStorageOptions extends BaseUseChatStorageOptions {
|
|
|
12127
12212
|
apiType: "responses" | "completions";
|
|
12128
12213
|
model?: string;
|
|
12129
12214
|
round?: number;
|
|
12215
|
+
assistantMessageId?: string;
|
|
12130
12216
|
}) => void;
|
|
12217
|
+
/** The vault inbox that receives answers finished while no client was attached. */
|
|
12218
|
+
inbox?: VaultInbox;
|
|
12131
12219
|
/**
|
|
12132
12220
|
* Observability hook fired once per send with the tools actually selected for
|
|
12133
12221
|
* the turn (after server + client filtering). Never throws into the send path.
|
|
@@ -12269,6 +12357,12 @@ interface UseChatStorageResult extends BaseUseChatStorageResult {
|
|
|
12269
12357
|
resumeStream: (handleOverride?: StreamResumeHandle, opts?: {
|
|
12270
12358
|
headless?: boolean;
|
|
12271
12359
|
}) => Promise<ResumeStreamWithStorageResult>;
|
|
12360
|
+
/** The caller's generations still running on the portal, optionally for one conversation. */
|
|
12361
|
+
getActiveStreams: (conversationId?: string) => Promise<ActiveStream[]>;
|
|
12362
|
+
/** Show a running generation from its first frame; nothing is stored. */
|
|
12363
|
+
watchStream: (stream: ActiveStream) => Promise<ResumeStreamResult>;
|
|
12364
|
+
/** Register the inbox public key, then store and remove every answer portal sealed into the inbox. */
|
|
12365
|
+
deliverInbox: () => Promise<InboxDeliveryResult[]>;
|
|
12272
12366
|
/**
|
|
12273
12367
|
* Create a memory engine tool for LLM to search past conversations.
|
|
12274
12368
|
* The tool is pre-configured with the hook's storage context and auth.
|
|
@@ -12370,4 +12464,4 @@ interface UseChatStorageResult extends BaseUseChatStorageResult {
|
|
|
12370
12464
|
*/
|
|
12371
12465
|
declare function useChatStorage(options: UseChatStorageOptions): UseChatStorageResult;
|
|
12372
12466
|
|
|
12373
|
-
export { ANUMA_CONVERSATION_ID, type AnumaTurn, type AnumaTurnOrigin, type AutoExtractMessage, type AutoExtractor, type Budget, CHUNKS_DISCARDED_ORIGIN, type CachedChunkVectors, type CachedServerTools, type ChatAccount, type ChatAccountState, type ChatAttachment, type ChatAttachments, type ChatBackend, type ChatBackendFactory, type ChatBackendSigner, type ChatCacheStorage, type ChatChanges, type ChatChunkSearchOptions, Conversation as ChatConversation, type ChatImport, type ChatJson, type ChatListOptions, Message as ChatMessage, type ChatMigrationOptions, type ChatMigrationProgress, type ChatMigrationResult, type ChatMigrationSkip, type ChatOutboxLocks, type ChatOutboxStorage, type ChatPage, type ChatPresignedUrl, type ChatRecord, type ChatRecordKind, type ChatRef, type ChatRevision, type ChatRole, type ChatSearchHit, type ChatSearchOptions, type ChatSnapshot, type ChatStore, ChatStoreError, type ChatWrite, type ChunkSearchStats, type ChunkVectorCache, type ChunkingOptions, type ConsolidationAction, type ConsolidationFallbackReason, type ConversationMemoryInput, ConversationMemory as ConversationMemoryModel, type ConversationMemoryOperationsContext, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateDecaySweeperOptions, type CreateMessageOptions, type CreateSelectPaymentWalletToolOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CreateWalletPaymentToolOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_DECAY_POLICY, DEFAULT_MAX_CLASSIFIER_CALLS_PER_SWEEP, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_PROFILE_FACETS, DEFAULT_PROFILE_FACT_TYPE_WEIGHTS, DEFAULT_PROFILE_PROOF_ALPHA, DEFAULT_PROFILE_TREND_MULTIPLIERS, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type DecayCandidateRaw, type DecayClassifier, type DecayInput, type DecayPolicy, type DecaySweepResult, type DecaySweeper, type DecayVerdict, type DurableAutoExtractorOptions, ENTITY_FANOUT, type EmbeddedWalletSignerFn, type EmbeddingRepairOptions, type EmbeddingRepairResult, EncryptionKeyMissingError, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type ExtractionFunnel, type ExtractionMessageSource, type ExtractionSourceMessage, type ExtractionSourceStatus, type ExtractionTimings, type FactType, type FileMetadata, type FileProcessingReason, type FileProcessingStatus, type FlushResult, type GetConversationsPageOptions, type GetMessagesPageOptions, type GraphTraversalOptions, HARD_DELETE_WINDOW_MS, INFERENCE_ID_HEADER, type InjectionClassifierOptions, type InjectionReason, type LazyStoredConversation, type LlmDecayClassifierOptions, type LlmNeighborRefinerOptions, type LocalMemoryStoreOptions, type LocalMessageAttachment, type Logger, LoggerProvider, type LoggerProviderProps, MAX_HOPS, MEDIUM_TTL_MS, MEMORY_KINDS, MEMORY_LEVELS, type ManualFactType, type MemoriesNeedingTopicExtraction, type MemoryContextItem, type MemoryContextLane, type MemoryContextOptions, type MemoryContextResult, type MemoryCounts, type MemoryCreate, type MemoryDecay, type MemoryDecaySweeperOptions, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, MemoryKeyError, type MemoryKeyRing, type MemoryKind, type MemoryLevel, MemoryLevelError, type MemoryListOptions, type MemoryMaintenance, type MemoryMigrationOptions, type MemoryMigrationProgress, type MemoryMigrationResult, type MemoryMigrationSkip, type MemoryQuarantinedEvent, type MemoryRecallOptions, type MemoryRetainOptions, type MemoryStore, type MemorySubscribeOptions, type MemoryToVerify, type MemoryTopic, type MemoryTopicBacklog, type MemoryTopicMaintenance, type MemoryUpdate, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MemoryVerification, type MessageAttachmentMigrationOptions, type MessageAttachmentMigrationResult, type MessageRedactionResult, type MessageSkeleton, NEVER_TTL_MS, NODE_BUDGET, NOTION_OAUTH_CONFIG, type NeighborRefiner, type NotionAuthUrlParams, type NotionClientRegistration, type NotionExchangeCodeParams, type NotionMcpCaller, type NotionOAuthEndpoints, type NotionPKCEChallenge, type NotionRefreshTokenParams, type NotionTokenResponse, type NowSource, type ObservationTrend, type ObservationTrendInput, PAST_EVENT_GRACE_MS, PII_PATTERNS, PROFILE_DOC_VERSION, type PaymentWallet, type PhotoIngestResult, type PhotoMediaRef, type PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type PortalLlmFailure, type PortalLlmFailureReason, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type PromptPreProcessor, type PromptPreProcessorContext, type PublishedPhotoMemory, type QuantizedEmbedding, type QuarantinedMemoryInfo, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankableVaultMemory, type RankedMemory, type RankedProfileCandidate, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallEmptyReason, type RecallOptions, type RecallResult, type RecallTelemetryCallbacks, type RecallToolCallbacks, type RecallToolOptions, type RecallTruncation, type RecencyOptions, type RedactionResult, type ReflectOptions, type ReflectResult, type RemoteChatStoreOptions, type RemoteMemoryCandidateOptions, type RemoteMemoryDecodeFailure, RemoteMemoryError, type RemoteMemoryListOptions, type RemoteMemoryMetadataPage, type RemoteMemoryMetadataRecord, type RemoteMemoryPage, RemoteMemoryPartialCreateError, type RemoteMemoryPersistence, type RemoteMemoryPersistenceOptions, type RemoteMemoryPipeline, type RemoteMemoryPipelineOptions, type RemoteMemoryQueryOptions, type RemoteMemoryQueryPage, type RemoteMemoryReadFilters, type RemoteMemoryRecord, type RemoteMemoryRow, type RemoteMemoryStoreOptions, type RemoteMemoryTopic, type RemoteMemoryWorkKind, type RemoteMemoryWorkLease, type RemoteMemoryWorkPersistence, type RemoteTopicPersistence, type RequestEncryptionKeyOptions, RerankerUnavailableError, type ReservationReceipt, type ResumeStreamOptions, type ResumeStreamResult, type ResumeStreamWithStorageResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, SDK_SCHEMA_VERSION, SELECT_PAYMENT_WALLET_TOOL_NAME, SHORT_TTL_MS, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type ScoreProfileSalienceOptions, type ScreenResult, type ScreenedCandidate, type SearchSource, type SelectPaymentWalletResult, type SendMessageWithStorageArgs, type SendMessageWithStorageDetachedResult, type SendMessageWithStorageResult, type ServerToolsOptions, type ServerToolsResponse, type Setting, type SignMessageFn, type StockPriceClassification, type StockPricePreProcessorOptions, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredConversationMemory, type StoredMessage, type StoredMessageWithSimilarity, type StoredTopic, type StoredVaultFolder, VaultFolder as StoredVaultFolderModel, type StoredVaultMemory, VaultMemory as StoredVaultMemoryModel, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type StreamSmoothingConfig, type SynthesizeProfileOptions, TOOL_RESULT_ORIGIN, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TOPIC_SALIENCE_WEIGHTS, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, type TopicExtractOptions, type TopicExtractionBatchDiagnostics, type TopicExtractionInput, type TopicExtractionRunResult, type TopicSalience, type TopicSkipReason, type TurnCompleteEvent, type TurnSkippedEvent, type UncheckedReason, type UnverifiableReason, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseCreditsOptions, type UseCreditsResult, type UseModelsOptions, type UseModelsResult, VAULT_SIZE_HOP_CAP, type VaultAttachmentCache, type VaultAttachmentJournal, type VaultAttachmentOwner, type VaultAttachmentRef, type VaultAttachmentUploadOptions, type VaultAttachments, type VaultAttachmentsOptions, type VaultChatActivity, type VaultChatBackend, type VaultChatBackendOptions, type VaultChatEvent, type VaultEmbeddingCache, type VaultEmbeddingExpectation, type VaultFolderOperationsContext, type VaultMemoryKind, type VaultMemoryOperationsContext, type VaultMemoryProjection, type VaultMemoryVisibility, type VaultMemoryWriter, type VaultSaveOperation, type VaultSearchResult, type VaultWriteAction, type VaultWriteInput, type VaultWriteOutcome, type VerificationSources, type VerifyMemoriesForPublishOptions, WALLET_PAYMENT_TOOL_NAME, type WalletPaymentOutcome, type WalletPaymentPassenger, type WalletPaymentRequest, type WalletPaymentResult, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, type WriteFailureReason, addConversationMemoriesOp, anumaLastReadSortKey, anumaTurnContent, archiveVaultMemoryOp, assembleMemoryContext, attachFileContextToLastUserMessage, backfillMemoryTopicsOp, buildAttachedFilesText, buildNotionAuthUrl, capHopsForDensity, chatStorageMigrations, chatStorageSchema, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyDecay, classifyInjectionCandidates, classifyObservationTrend, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, clearAllEncryptionKeys, clearAllEncryptionState, clearConversationMemoriesOp, clearEncryptionKey, clearLazyTitleCache, clearModelsCache, clearServerToolsCache, consoleLogger, conversationMemoryToStored, cosineInt8, countUnreadAnumaTurns, createAutoExtractor, createChunkVectorCache, createCryptoPricePreProcessor, createDecaySweeper, createDurableAutoExtractor, createLlmDecayClassifier, createLlmNeighborRefiner, createLocalMemoryStore, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageSourceResolver, createNotionProxyTools, createNotionTools, createPlatformCursorStore, createRecallTool, createRemoteChatStore, createRemoteMemoryPersistence, createRemoteMemoryPipeline, createRemoteMemoryStore, createSelectPaymentWalletTool, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultAttachments, createVaultChatBackend, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWalletPaymentTool, createWeatherPreProcessor, createWebSearchPreProcessor, decodeChunkVector, decryptConversationTitle, decryptMessageEmbeddingFields, deleteAllVaultMemoriesForUserOp, deleteMessageOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, deriveKeyFromSignatureBytes, deriveMemoryKeyRing, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, encodeChunkVector, encryptToolCallEventsOp, ensureAnumaConversation, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, extractReservationReceipts, formatFileProcessingNotes, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getConversationsPageOp, getDecayCandidatesRawOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoriesByIdsOp, getVaultMemoryOp, getVaultRankingProjectionsOp, hardDeleteDecayedOp, hasEncryptionKey, ingestPublishedPhotoMemoriesOp, injectionSignatureCatalog, isAttachedFilesText, isDegradedTopicSkip, isEncrypted, isPiiRedactor, isRerankerAvailable, loadSettings, localChatBackend, markAnumaRead, maskScopedEmbeddingCache, maxVaultAttachmentBytes, memoryCipher, migrateChatsToRemote, migrateMemoriesToRemote, migrateMessageAttachments, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, parseMedia, preEmbedVaultMemories, primaryTopic, quantizeEmbedding, queueManager, rankProfileCandidates, readAnumaTurn, recall, reencryptMemoryField, reflect, refreshEncryptionKeyIfMatches, refreshNotionAccessToken, registerNotionClient, relinkMemoryTopicsOp, requestEncryptionKey, resolvePiiRedactor, restoreVaultMemoryOp, resumeStream, retain, saveSetting, scoreProfileSalience, screenCandidatesForInjection, sdkMigrations, sdkModelClasses, sdkSchema, sealLegacyMessageEmbeddingsOp, searchVaultMemories, seedEncryptionKeys, setLogger, setMemoryVisibilityOp, shouldChunkMessage, shouldRecallMemory, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, stripLegacyChunkTextOp, summarizeObservationTrends, supersedeVaultMemoryOp, synthesizeProfile, topicWeight, traverseGraphLane, ttlForType, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, vaultAttachmentRefs, vaultChatBackend, verifyMemoriesForPublish, xhrTransport };
|
|
12467
|
+
export { ANUMA_CONVERSATION_ID, type ActiveStream, type AnumaTurn, type AnumaTurnOrigin, type AutoExtractMessage, type AutoExtractor, type Budget, CHUNKS_DISCARDED_ORIGIN, type CachedChunkVectors, type CachedServerTools, type ChatAccount, type ChatAccountState, type ChatAttachment, type ChatAttachments, type ChatBackend, type ChatBackendFactory, type ChatBackendSigner, type ChatCacheStorage, type ChatChanges, type ChatChunkSearchOptions, Conversation as ChatConversation, type ChatImport, type ChatJson, type ChatListOptions, Message as ChatMessage, type ChatMigrationOptions, type ChatMigrationProgress, type ChatMigrationResult, type ChatMigrationSkip, type ChatOutboxLocks, type ChatOutboxStorage, type ChatPage, type ChatPresignedUrl, type ChatRecord, type ChatRecordKind, type ChatRef, type ChatRevision, type ChatRole, type ChatSearchHit, type ChatSearchOptions, type ChatSnapshot, type ChatStore, ChatStoreError, type ChatWrite, type ChunkSearchStats, type ChunkVectorCache, type ChunkingOptions, type ConsolidationAction, type ConsolidationFallbackReason, type ConversationMemoryInput, ConversationMemory as ConversationMemoryModel, type ConversationMemoryOperationsContext, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateDecaySweeperOptions, type CreateMessageOptions, type CreateSelectPaymentWalletToolOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CreateWalletPaymentToolOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_DECAY_POLICY, DEFAULT_MAX_CLASSIFIER_CALLS_PER_SWEEP, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_PROFILE_FACETS, DEFAULT_PROFILE_FACT_TYPE_WEIGHTS, DEFAULT_PROFILE_PROOF_ALPHA, DEFAULT_PROFILE_TREND_MULTIPLIERS, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type DecayCandidateRaw, type DecayClassifier, type DecayInput, type DecayPolicy, type DecaySweepResult, type DecaySweeper, type DecayVerdict, type DurableAutoExtractorOptions, ENTITY_FANOUT, type EmbeddedWalletSignerFn, type EmbeddingRepairOptions, type EmbeddingRepairResult, EncryptionKeyMissingError, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type ExtractionFunnel, type ExtractionMessageSource, type ExtractionSourceMessage, type ExtractionSourceStatus, type ExtractionTimings, type FactType, type FileMetadata, type FileProcessingReason, type FileProcessingStatus, type FlushResult, type GetConversationsPageOptions, type GetMessagesPageOptions, type GraphTraversalOptions, HARD_DELETE_WINDOW_MS, INFERENCE_ID_HEADER, type InboxDeliveryResult, type InboxItem, type InboxPlaintext, type InjectionClassifierOptions, type InjectionReason, type LazyStoredConversation, type LlmDecayClassifierOptions, type LlmNeighborRefinerOptions, type LocalMemoryStoreOptions, type LocalMessageAttachment, type Logger, LoggerProvider, type LoggerProviderProps, MAX_HOPS, MEDIUM_TTL_MS, MEMORY_KINDS, MEMORY_LEVELS, type ManualFactType, type MemoriesNeedingTopicExtraction, type MemoryContextItem, type MemoryContextLane, type MemoryContextOptions, type MemoryContextResult, type MemoryCounts, type MemoryCreate, type MemoryDecay, type MemoryDecaySweeperOptions, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, MemoryKeyError, type MemoryKeyRing, type MemoryKind, type MemoryLevel, MemoryLevelError, type MemoryListOptions, type MemoryMaintenance, type MemoryMigrationOptions, type MemoryMigrationProgress, type MemoryMigrationResult, type MemoryMigrationSkip, type MemoryQuarantinedEvent, type MemoryRecallOptions, type MemoryRetainOptions, type MemoryStore, type MemorySubscribeOptions, type MemoryToVerify, type MemoryTopic, type MemoryTopicBacklog, type MemoryTopicMaintenance, type MemoryUpdate, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MemoryVerification, type MessageAttachmentMigrationOptions, type MessageAttachmentMigrationResult, type MessageRedactionResult, type MessageSkeleton, NEVER_TTL_MS, NODE_BUDGET, NOTION_OAUTH_CONFIG, type NeighborRefiner, type NotionAuthUrlParams, type NotionClientRegistration, type NotionExchangeCodeParams, type NotionMcpCaller, type NotionOAuthEndpoints, type NotionPKCEChallenge, type NotionRefreshTokenParams, type NotionTokenResponse, type NowSource, type ObservationTrend, type ObservationTrendInput, PAST_EVENT_GRACE_MS, PII_PATTERNS, PROFILE_DOC_VERSION, type PaymentWallet, type PhotoIngestResult, type PhotoMediaRef, type PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type PortalLlmFailure, type PortalLlmFailureReason, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type PromptPreProcessor, type PromptPreProcessorContext, type PublishedPhotoMemory, type QuantizedEmbedding, type QuarantinedMemoryInfo, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankableVaultMemory, type RankedMemory, type RankedProfileCandidate, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallEmptyReason, type RecallOptions, type RecallResult, type RecallTelemetryCallbacks, type RecallToolCallbacks, type RecallToolOptions, type RecallTruncation, type RecencyOptions, type RedactionResult, type ReflectOptions, type ReflectResult, type RemoteChatStoreOptions, type RemoteMemoryCandidateOptions, type RemoteMemoryDecodeFailure, RemoteMemoryError, type RemoteMemoryListOptions, type RemoteMemoryMetadataPage, type RemoteMemoryMetadataRecord, type RemoteMemoryPage, RemoteMemoryPartialCreateError, type RemoteMemoryPersistence, type RemoteMemoryPersistenceOptions, type RemoteMemoryPipeline, type RemoteMemoryPipelineOptions, type RemoteMemoryQueryOptions, type RemoteMemoryQueryPage, type RemoteMemoryReadFilters, type RemoteMemoryRecord, type RemoteMemoryRow, type RemoteMemoryStoreOptions, type RemoteMemoryTopic, type RemoteMemoryWorkKind, type RemoteMemoryWorkLease, type RemoteMemoryWorkPersistence, type RemoteTopicPersistence, type RequestEncryptionKeyOptions, RerankerUnavailableError, type ReservationReceipt, type ResumeStreamOptions, type ResumeStreamResult, type ResumeStreamWithStorageResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, SDK_SCHEMA_VERSION, SELECT_PAYMENT_WALLET_TOOL_NAME, SHORT_TTL_MS, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type ScoreProfileSalienceOptions, type ScreenResult, type ScreenedCandidate, type SearchSource, type SelectPaymentWalletResult, type SendMessageWithStorageArgs, type SendMessageWithStorageDetachedResult, type SendMessageWithStorageResult, type ServerToolsOptions, type ServerToolsResponse, type Setting, type SignMessageFn, type StockPriceClassification, type StockPricePreProcessorOptions, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredConversationMemory, type StoredMessage, type StoredMessageWithSimilarity, type StoredTopic, type StoredVaultFolder, VaultFolder as StoredVaultFolderModel, type StoredVaultMemory, VaultMemory as StoredVaultMemoryModel, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type StreamSmoothingConfig, type SynthesizeProfileOptions, TOOL_RESULT_ORIGIN, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TOPIC_SALIENCE_WEIGHTS, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, type TopicExtractOptions, type TopicExtractionBatchDiagnostics, type TopicExtractionInput, type TopicExtractionRunResult, type TopicSalience, type TopicSkipReason, type TurnCompleteEvent, type TurnSkippedEvent, type UncheckedReason, type UnverifiableReason, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseCreditsOptions, type UseCreditsResult, type UseModelsOptions, type UseModelsResult, VAULT_SIZE_HOP_CAP, type VaultAttachmentCache, type VaultAttachmentJournal, type VaultAttachmentOwner, type VaultAttachmentRef, type VaultAttachmentUploadOptions, type VaultAttachments, type VaultAttachmentsOptions, type VaultChatActivity, type VaultChatBackend, type VaultChatBackendOptions, type VaultChatEvent, type VaultEmbeddingCache, type VaultEmbeddingExpectation, type VaultFolderOperationsContext, type VaultInbox, type VaultMemoryKind, type VaultMemoryOperationsContext, type VaultMemoryProjection, type VaultMemoryVisibility, type VaultMemoryWriter, type VaultSaveOperation, type VaultSearchResult, type VaultWriteAction, type VaultWriteInput, type VaultWriteOutcome, type VerificationSources, type VerifyMemoriesForPublishOptions, WALLET_PAYMENT_TOOL_NAME, type WalletPaymentOutcome, type WalletPaymentPassenger, type WalletPaymentRequest, type WalletPaymentResult, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, type WriteFailureReason, addConversationMemoriesOp, anumaLastReadSortKey, anumaTurnContent, archiveVaultMemoryOp, assembleMemoryContext, attachFileContextToLastUserMessage, backfillMemoryTopicsOp, buildAttachedFilesText, buildNotionAuthUrl, capHopsForDensity, chatStorageMigrations, chatStorageSchema, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyDecay, classifyInjectionCandidates, classifyObservationTrend, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, clearAllEncryptionKeys, clearAllEncryptionState, clearConversationMemoriesOp, clearEncryptionKey, clearLazyTitleCache, clearModelsCache, clearServerToolsCache, consoleLogger, conversationMemoryToStored, cosineInt8, countUnreadAnumaTurns, createAutoExtractor, createChunkVectorCache, createCryptoPricePreProcessor, createDecaySweeper, createDurableAutoExtractor, createLlmDecayClassifier, createLlmNeighborRefiner, createLocalMemoryStore, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageSourceResolver, createNotionProxyTools, createNotionTools, createPlatformCursorStore, createRecallTool, createRemoteChatStore, createRemoteMemoryPersistence, createRemoteMemoryPipeline, createRemoteMemoryStore, createSelectPaymentWalletTool, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultAttachments, createVaultChatBackend, createVaultEmbeddingCache, createVaultFolderOp, createVaultInbox, createVaultMemoriesBatchOp, createVaultMemoryOp, createWalletPaymentTool, createWeatherPreProcessor, createWebSearchPreProcessor, decodeChunkVector, decryptConversationTitle, decryptMessageEmbeddingFields, deleteAllVaultMemoriesForUserOp, deleteMessageOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, deriveKeyFromSignatureBytes, deriveMemoryKeyRing, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, encodeChunkVector, encryptToolCallEventsOp, ensureAnumaConversation, ensureDefaultFoldersOp, exchangeNotionCode, exportInboxPublicKey, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, extractReservationReceipts, formatFileProcessingNotes, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getConversationsPageOp, getDecayCandidatesRawOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoriesByIdsOp, getVaultMemoryOp, getVaultRankingProjectionsOp, hardDeleteDecayedOp, hasEncryptionKey, ingestPublishedPhotoMemoriesOp, injectionSignatureCatalog, isAttachedFilesText, isDegradedTopicSkip, isEncrypted, isPiiRedactor, isRerankerAvailable, listActiveStreams, loadSettings, localChatBackend, markAnumaRead, maskScopedEmbeddingCache, maxVaultAttachmentBytes, memoryCipher, migrateChatsToRemote, migrateMemoriesToRemote, migrateMessageAttachments, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, openInboxItem, parseMedia, preEmbedVaultMemories, primaryTopic, quantizeEmbedding, queueManager, rankProfileCandidates, readAnumaTurn, recall, reencryptMemoryField, reflect, refreshEncryptionKeyIfMatches, refreshNotionAccessToken, registerNotionClient, relinkMemoryTopicsOp, requestEncryptionKey, resolvePiiRedactor, restoreVaultMemoryOp, resumeStream, retain, saveSetting, scoreProfileSalience, screenCandidatesForInjection, sdkMigrations, sdkModelClasses, sdkSchema, sealLegacyMessageEmbeddingsOp, searchVaultMemories, seedEncryptionKeys, setLogger, setMemoryVisibilityOp, shouldChunkMessage, shouldRecallMemory, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, stripLegacyChunkTextOp, summarizeObservationTrends, supersedeVaultMemoryOp, synthesizeProfile, topicWeight, traverseGraphLane, ttlForType, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, vaultAttachmentRefs, vaultChatBackend, verifyMemoriesForPublish, xhrTransport };
|