agents 0.13.0 → 0.13.2
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/README.md +1 -1
- package/dist/{agent-tool-types-BVgYyKO9.d.ts → agent-tool-types-Dn9n-3SI.d.ts} +183 -68
- package/dist/agent-tool-types.d.ts +1 -1
- package/dist/{agent-tools-C-Ch8Thl.d.ts → agent-tools-B1ttU-pq.d.ts} +2 -2
- package/dist/agent-tools.d.ts +1 -1
- package/dist/chat/index.d.ts +2 -2
- package/dist/chat-sdk/index.d.ts +135 -0
- package/dist/chat-sdk/index.js +453 -0
- package/dist/chat-sdk/index.js.map +1 -0
- package/dist/client.d.ts +1 -1
- package/dist/index.d.ts +47 -33
- package/dist/index.js +493 -21
- package/dist/index.js.map +1 -1
- package/dist/mcp/client.d.ts +12 -12
- package/dist/mcp/index.d.ts +26 -26
- package/dist/react.d.ts +3 -3
- package/dist/serializable.d.ts +1 -1
- package/dist/sub-routing.d.ts +6 -6
- package/dist/workflows.d.ts +1 -1
- package/package.json +11 -1
package/README.md
CHANGED
|
@@ -110,7 +110,7 @@ State changes sync to all connected clients automatically. Call methods like the
|
|
|
110
110
|
Core State sync · Routing · HTTP & WebSockets · @callable RPC · Sub-agents (facets)
|
|
111
111
|
Clients React hook · Vanilla JS · Real-time state sync
|
|
112
112
|
Channels WebSocket · HTTP · Email · (coming: SMS, Voice, Messengers)
|
|
113
|
-
Background Queue · Scheduling · Workflows · Human-in-the-loop
|
|
113
|
+
Background Queue · Scheduling · Managed fibers · Workflows · Human-in-the-loop
|
|
114
114
|
AI Chat agents · Agent tools · Tool calling · MCP servers & clients
|
|
115
115
|
Platform Observability · Cross-domain auth · Resumable streams
|
|
116
116
|
```
|
|
@@ -1825,19 +1825,85 @@ type ScheduleCriteria = {
|
|
|
1825
1825
|
* and identity for durable execution.
|
|
1826
1826
|
*/
|
|
1827
1827
|
type FiberContext = {
|
|
1828
|
-
/** Unique identifier for this fiber execution. */ id: string /**
|
|
1828
|
+
/** Unique identifier for this fiber execution. */ id: string /** Cooperative cancellation signal for managed fiber callers. */;
|
|
1829
|
+
signal: AbortSignal /** Checkpoint data during execution. Synchronous SQLite write. */;
|
|
1829
1830
|
stash(
|
|
1830
1831
|
data: unknown
|
|
1831
|
-
): void /**
|
|
1832
|
+
): void /** Currently null during execution; recovered snapshots are passed to onFiberRecovered(). */;
|
|
1832
1833
|
snapshot: unknown | null;
|
|
1833
1834
|
};
|
|
1835
|
+
type FiberStatus =
|
|
1836
|
+
| "pending"
|
|
1837
|
+
| "running"
|
|
1838
|
+
| "completed"
|
|
1839
|
+
| "aborted"
|
|
1840
|
+
| "interrupted"
|
|
1841
|
+
| "error";
|
|
1842
|
+
type StartFiberOptions = {
|
|
1843
|
+
fiberId?: string;
|
|
1844
|
+
idempotencyKey?: string;
|
|
1845
|
+
metadata?: Record<string, unknown>;
|
|
1846
|
+
waitForCompletion?: boolean;
|
|
1847
|
+
};
|
|
1848
|
+
type FiberInspection = {
|
|
1849
|
+
fiberId: string;
|
|
1850
|
+
name: string;
|
|
1851
|
+
idempotencyKey?: string;
|
|
1852
|
+
status: FiberStatus;
|
|
1853
|
+
snapshot?: unknown;
|
|
1854
|
+
error?: string;
|
|
1855
|
+
metadata?: Record<string, unknown>;
|
|
1856
|
+
createdAt: number;
|
|
1857
|
+
startedAt?: number;
|
|
1858
|
+
settledAt?: number;
|
|
1859
|
+
};
|
|
1860
|
+
type StartFiberResult = FiberInspection & {
|
|
1861
|
+
accepted: boolean;
|
|
1862
|
+
};
|
|
1863
|
+
type FiberRecoveryResult =
|
|
1864
|
+
| {
|
|
1865
|
+
status: "completed";
|
|
1866
|
+
snapshot?: unknown;
|
|
1867
|
+
metadata?: Record<string, unknown>;
|
|
1868
|
+
}
|
|
1869
|
+
| {
|
|
1870
|
+
status: "error";
|
|
1871
|
+
error?: unknown;
|
|
1872
|
+
snapshot?: unknown;
|
|
1873
|
+
}
|
|
1874
|
+
| {
|
|
1875
|
+
status: "aborted";
|
|
1876
|
+
reason?: string;
|
|
1877
|
+
snapshot?: unknown;
|
|
1878
|
+
}
|
|
1879
|
+
| {
|
|
1880
|
+
status: "interrupted";
|
|
1881
|
+
reason?: string;
|
|
1882
|
+
snapshot?: unknown;
|
|
1883
|
+
};
|
|
1884
|
+
type ListFibersOptions = {
|
|
1885
|
+
status?: FiberStatus | FiberStatus[];
|
|
1886
|
+
name?: string;
|
|
1887
|
+
limit?: number;
|
|
1888
|
+
};
|
|
1889
|
+
type DeleteFibersOptions = {
|
|
1890
|
+
status?: FiberStatus | FiberStatus[];
|
|
1891
|
+
settledBefore?: Date;
|
|
1892
|
+
limit?: number;
|
|
1893
|
+
};
|
|
1834
1894
|
/**
|
|
1835
1895
|
* Context passed to the `onFiberRecovered` hook when an interrupted
|
|
1836
1896
|
* fiber is detected after DO restart.
|
|
1837
1897
|
*/
|
|
1838
1898
|
type FiberRecoveryContext = {
|
|
1839
1899
|
/** Fiber ID. */ id: string /** Name passed to `runFiber`. */;
|
|
1840
|
-
name: string /**
|
|
1900
|
+
name: string /** Status for managed fibers recovered through the retained ledger. */;
|
|
1901
|
+
status?: FiberStatus /** Idempotency key for managed fibers, if one was supplied. */;
|
|
1902
|
+
idempotencyKey?: string /** Metadata for managed fibers, if one was supplied. */;
|
|
1903
|
+
metadata?: Record<
|
|
1904
|
+
string,
|
|
1905
|
+
unknown
|
|
1906
|
+
> | null /** Last checkpoint data from `stash()`, or null if never stashed. */;
|
|
1841
1907
|
snapshot: unknown | null;
|
|
1842
1908
|
/**
|
|
1843
1909
|
* Epoch milliseconds when the fiber row was inserted (when `runFiber`
|
|
@@ -2033,6 +2099,12 @@ declare class Agent<
|
|
|
2033
2099
|
private _facetKeepAliveTokens;
|
|
2034
2100
|
/** @internal In-memory set of fiber IDs running in this process. */
|
|
2035
2101
|
private _runFiberActiveFibers;
|
|
2102
|
+
/** @internal In-memory abort controllers for managed running fibers. */
|
|
2103
|
+
private _managedFiberAbortControllers;
|
|
2104
|
+
/** @internal In-memory executions for callers that want to await accepted work. */
|
|
2105
|
+
private _managedFiberExecutions;
|
|
2106
|
+
/** @internal In-memory waiters for managed fibers reaching terminal ledger state. */
|
|
2107
|
+
private _managedFiberTerminalWaiters;
|
|
2036
2108
|
/** @internal Prevents re-entrant recovery from overlapping alarm ticks. */
|
|
2037
2109
|
private _runFiberRecoveryInProgress;
|
|
2038
2110
|
private _ParentClass;
|
|
@@ -2715,6 +2787,33 @@ declare class Agent<
|
|
|
2715
2787
|
* ```
|
|
2716
2788
|
*/
|
|
2717
2789
|
keepAliveWhile<T>(fn: () => Promise<T>): Promise<T>;
|
|
2790
|
+
private _isTerminalFiberStatus;
|
|
2791
|
+
private _notifyManagedFiberTerminal;
|
|
2792
|
+
private _waitForManagedFiberTerminal;
|
|
2793
|
+
private _normalizeFiberStatusFilter;
|
|
2794
|
+
private _parseFiberJsonObject;
|
|
2795
|
+
private _parseFiberSnapshot;
|
|
2796
|
+
private _fiberErrorMessage;
|
|
2797
|
+
private _stringifyFiberSnapshot;
|
|
2798
|
+
private _fiberRecoveryErrorMessage;
|
|
2799
|
+
private _applyManagedFiberRecoveryResult;
|
|
2800
|
+
private _settleManagedFiberExecution;
|
|
2801
|
+
private _parseFiberRecoverySnapshot;
|
|
2802
|
+
private _runFiberRecoveryHook;
|
|
2803
|
+
private _fiberInspectionFromRow;
|
|
2804
|
+
private _waitForManagedFiber;
|
|
2805
|
+
private _readFiber;
|
|
2806
|
+
private _readFiberByKey;
|
|
2807
|
+
private _listFiberRows;
|
|
2808
|
+
private _listFiberRowsByStatus;
|
|
2809
|
+
inspectFiber(fiberId: string): Promise<FiberInspection | null>;
|
|
2810
|
+
inspectFiberByKey(idempotencyKey: string): Promise<FiberInspection | null>;
|
|
2811
|
+
listFibers(options?: ListFibersOptions): Promise<FiberInspection[]>;
|
|
2812
|
+
cancelFiber(fiberId: string, reason?: string): Promise<boolean>;
|
|
2813
|
+
cancelFiberByKey(idempotencyKey: string, reason?: string): Promise<boolean>;
|
|
2814
|
+
resolveFiber(fiberId: string, result: FiberRecoveryResult): Promise<boolean>;
|
|
2815
|
+
deleteFibers(options?: DeleteFibersOptions): Promise<number>;
|
|
2816
|
+
private _listTerminalFiberRowsForDelete;
|
|
2718
2817
|
/**
|
|
2719
2818
|
* Run a function as a durable fiber. The fiber is registered in SQLite
|
|
2720
2819
|
* before execution, checkpointable during execution via `ctx.stash()`,
|
|
@@ -2729,6 +2828,13 @@ declare class Agent<
|
|
|
2729
2828
|
* @returns The return value of fn
|
|
2730
2829
|
*/
|
|
2731
2830
|
runFiber<T>(name: string, fn: (ctx: FiberContext) => Promise<T>): Promise<T>;
|
|
2831
|
+
startFiber(
|
|
2832
|
+
name: string,
|
|
2833
|
+
fn: (ctx: FiberContext) => Promise<void>,
|
|
2834
|
+
options?: StartFiberOptions
|
|
2835
|
+
): Promise<StartFiberResult>;
|
|
2836
|
+
private _executeManagedFiber;
|
|
2837
|
+
private _runFiberInternal;
|
|
2732
2838
|
/**
|
|
2733
2839
|
* Checkpoint data for the currently executing fiber.
|
|
2734
2840
|
* Uses AsyncLocalStorage to identify the correct fiber,
|
|
@@ -2746,7 +2852,9 @@ declare class Agent<
|
|
|
2746
2852
|
*
|
|
2747
2853
|
* Default: logs a warning.
|
|
2748
2854
|
*/
|
|
2749
|
-
onFiberRecovered(
|
|
2855
|
+
onFiberRecovered(
|
|
2856
|
+
_ctx: FiberRecoveryContext
|
|
2857
|
+
): Promise<void | FiberRecoveryResult>;
|
|
2750
2858
|
/**
|
|
2751
2859
|
* Override point for subclasses to handle internal (framework) fibers
|
|
2752
2860
|
* before the user's recovery hook fires. Return `true` if handled.
|
|
@@ -4031,95 +4139,102 @@ type AgentToolEventState = {
|
|
|
4031
4139
|
};
|
|
4032
4140
|
//#endregion
|
|
4033
4141
|
export {
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4142
|
+
SubAgentStub as $,
|
|
4143
|
+
EmailSendBinding as A,
|
|
4144
|
+
McpAuthContext as At,
|
|
4145
|
+
QueueItem as B,
|
|
4146
|
+
SubAgentPathMatch as Bt,
|
|
4038
4147
|
AgentStaticOptions as C,
|
|
4039
|
-
|
|
4148
|
+
ElicitRequest$1 as Ct,
|
|
4040
4149
|
DEFAULT_AGENT_STATIC_OPTIONS as D,
|
|
4041
|
-
|
|
4150
|
+
CreateMcpHandlerOptions as Dt,
|
|
4042
4151
|
ConnectionContext$1 as E,
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
MCPServer as
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4152
|
+
McpAgent as Et,
|
|
4153
|
+
FiberStatus as F,
|
|
4154
|
+
SSEEdgeClientTransport as Ft,
|
|
4155
|
+
ScheduleCriteria as G,
|
|
4156
|
+
RPCResponse as H,
|
|
4157
|
+
parseSubAgentPath as Ht,
|
|
4158
|
+
ListFibersOptions as I,
|
|
4159
|
+
StreamableHTTPEdgeClientTransport as It,
|
|
4160
|
+
StartFiberOptions as J,
|
|
4161
|
+
SendEmailOptions as K,
|
|
4162
|
+
MCPServer as L,
|
|
4163
|
+
McpClientOptions as Lt,
|
|
4164
|
+
FiberInspection as M,
|
|
4165
|
+
TransportState as Mt,
|
|
4166
|
+
FiberRecoveryContext as N,
|
|
4167
|
+
WorkerTransport as Nt,
|
|
4168
|
+
DeleteFibersOptions as O,
|
|
4169
|
+
createMcpHandler as Ot,
|
|
4170
|
+
FiberRecoveryResult as P,
|
|
4171
|
+
WorkerTransportOptions as Pt,
|
|
4172
|
+
SubAgentClass as Q,
|
|
4173
|
+
MCPServerMessage as R,
|
|
4174
|
+
TransportType as Rt,
|
|
4063
4175
|
AgentOptions as S,
|
|
4064
|
-
|
|
4176
|
+
RPC_DO_PREFIX as St,
|
|
4065
4177
|
Connection$1 as T,
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4178
|
+
ElicitResult$1 as Tt,
|
|
4179
|
+
RoutingRetryOptions as U,
|
|
4180
|
+
routeSubAgentRequest as Ut,
|
|
4181
|
+
RPCRequest as V,
|
|
4182
|
+
getSubAgentByName as Vt,
|
|
4183
|
+
Schedule as W,
|
|
4184
|
+
StateUpdateMessage as X,
|
|
4185
|
+
StartFiberResult as Y,
|
|
4186
|
+
StreamingResponse as Z,
|
|
4073
4187
|
AddRpcMcpServerOptions as _,
|
|
4074
|
-
|
|
4188
|
+
getNamespacedData as _t,
|
|
4075
4189
|
AgentToolEventState as a,
|
|
4076
|
-
|
|
4190
|
+
routeAgentRequest as at,
|
|
4077
4191
|
AgentGetOptions as b,
|
|
4078
|
-
|
|
4192
|
+
RPCServerTransport as bt,
|
|
4079
4193
|
AgentToolRunInspection as c,
|
|
4080
|
-
|
|
4194
|
+
MCPClientManagerOptions as ct,
|
|
4081
4195
|
AgentToolStoredChunk as d,
|
|
4082
|
-
|
|
4083
|
-
|
|
4196
|
+
MCPConnectionResult as dt,
|
|
4197
|
+
WSMessage$1 as et,
|
|
4084
4198
|
AgentToolTerminalStatus as f,
|
|
4085
|
-
|
|
4199
|
+
MCPDiscoverResult as ft,
|
|
4086
4200
|
AddMcpServerOptions as g,
|
|
4087
|
-
|
|
4201
|
+
RegisterServerOptions as gt,
|
|
4088
4202
|
RunAgentToolResult as h,
|
|
4089
|
-
|
|
4203
|
+
MCPServerOptions as ht,
|
|
4090
4204
|
AgentToolEventMessage as i,
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4205
|
+
routeAgentEmail as it,
|
|
4206
|
+
FiberContext as j,
|
|
4207
|
+
getMcpAuthContext as jt,
|
|
4208
|
+
EmailRoutingOptions as k,
|
|
4209
|
+
experimental_createMcpHandler as kt,
|
|
4096
4210
|
AgentToolRunState as l,
|
|
4097
|
-
|
|
4211
|
+
MCPClientOAuthCallbackConfig as lt,
|
|
4098
4212
|
RunAgentToolOptions as m,
|
|
4099
|
-
|
|
4213
|
+
MCPServerFilter as mt,
|
|
4100
4214
|
AgentToolDisplayMetadata as n,
|
|
4101
|
-
|
|
4215
|
+
getAgentByName as nt,
|
|
4102
4216
|
AgentToolLifecycleResult as o,
|
|
4103
|
-
|
|
4217
|
+
unstable_callable as ot,
|
|
4104
4218
|
ChatCapableAgentClass as p,
|
|
4105
|
-
|
|
4106
|
-
|
|
4219
|
+
MCPOAuthCallbackResult as pt,
|
|
4220
|
+
SqlError as q,
|
|
4107
4221
|
AgentToolEvent as r,
|
|
4108
|
-
|
|
4222
|
+
getCurrentAgent as rt,
|
|
4109
4223
|
AgentToolRunInfo as s,
|
|
4110
|
-
|
|
4224
|
+
MCPClientManager as st,
|
|
4111
4225
|
AgentToolChildAdapter as t,
|
|
4112
|
-
|
|
4226
|
+
callable as tt,
|
|
4113
4227
|
AgentToolRunStatus as u,
|
|
4114
|
-
|
|
4228
|
+
MCPClientOAuthResult as ut,
|
|
4115
4229
|
Agent as v,
|
|
4116
|
-
|
|
4230
|
+
RPCClientTransport as vt,
|
|
4117
4231
|
CallableMetadata as w,
|
|
4118
|
-
|
|
4232
|
+
ElicitRequestSchema$1 as wt,
|
|
4119
4233
|
AgentNamespace as x,
|
|
4120
|
-
|
|
4234
|
+
RPCServerTransportOptions as xt,
|
|
4121
4235
|
AgentContext as y,
|
|
4122
|
-
|
|
4123
|
-
|
|
4236
|
+
RPCClientTransportOptions as yt,
|
|
4237
|
+
MCPServersState as z,
|
|
4238
|
+
SUB_PREFIX as zt
|
|
4124
4239
|
};
|
|
4125
|
-
//# sourceMappingURL=agent-tool-types-
|
|
4240
|
+
//# sourceMappingURL=agent-tool-types-Dn9n-3SI.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
a as AgentToolEventState,
|
|
3
3
|
i as AgentToolEventMessage
|
|
4
|
-
} from "./agent-tool-types-
|
|
4
|
+
} from "./agent-tool-types-Dn9n-3SI.js";
|
|
5
5
|
|
|
6
6
|
//#region src/chat/agent-tools.d.ts
|
|
7
7
|
declare function createAgentToolEventState(): AgentToolEventState;
|
|
@@ -11,4 +11,4 @@ declare function applyAgentToolEvent(
|
|
|
11
11
|
): AgentToolEventState;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { createAgentToolEventState as n, applyAgentToolEvent as t };
|
|
14
|
-
//# sourceMappingURL=agent-tools-
|
|
14
|
+
//# sourceMappingURL=agent-tools-B1ttU-pq.d.ts.map
|
package/dist/agent-tools.d.ts
CHANGED
package/dist/chat/index.d.ts
CHANGED
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
i as AgentToolEventMessage,
|
|
4
4
|
l as AgentToolRunState,
|
|
5
5
|
r as AgentToolEvent
|
|
6
|
-
} from "../agent-tool-types-
|
|
6
|
+
} from "../agent-tool-types-Dn9n-3SI.js";
|
|
7
7
|
import {
|
|
8
8
|
n as createAgentToolEventState,
|
|
9
9
|
t as applyAgentToolEvent
|
|
10
|
-
} from "../agent-tools-
|
|
10
|
+
} from "../agent-tools-B1ttU-pq.js";
|
|
11
11
|
import { JSONSchema7, Tool, ToolSet, UIMessage } from "ai";
|
|
12
12
|
import { Connection } from "agents";
|
|
13
13
|
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import {
|
|
2
|
+
$ as SubAgentStub,
|
|
3
|
+
Q as SubAgentClass,
|
|
4
|
+
v as Agent
|
|
5
|
+
} from "../agent-tool-types-Dn9n-3SI.js";
|
|
6
|
+
import { Lock, QueueEntry, StateAdapter } from "chat";
|
|
7
|
+
|
|
8
|
+
//#region src/chat-sdk/agent.d.ts
|
|
9
|
+
interface StoredLock {
|
|
10
|
+
threadId: string;
|
|
11
|
+
token: string;
|
|
12
|
+
expiresAt: number;
|
|
13
|
+
}
|
|
14
|
+
declare class ChatSdkStateAgent extends Agent {
|
|
15
|
+
onStart(): void;
|
|
16
|
+
subscribe(threadId: string): void;
|
|
17
|
+
unsubscribe(threadId: string): void;
|
|
18
|
+
isSubscribed(threadId: string): boolean;
|
|
19
|
+
acquireLock(threadId: string, ttlMs: number): Promise<StoredLock | null>;
|
|
20
|
+
releaseLock(threadId: string, token: string): void;
|
|
21
|
+
extendLock(threadId: string, token: string, ttlMs: number): Promise<boolean>;
|
|
22
|
+
forceReleaseLock(threadId: string): void;
|
|
23
|
+
enqueue(threadId: string, value: string, maxSize: number): Promise<number>;
|
|
24
|
+
popQueue(threadId: string): string | null;
|
|
25
|
+
queueDepth(threadId: string): number;
|
|
26
|
+
listAppend(
|
|
27
|
+
key: string,
|
|
28
|
+
value: string,
|
|
29
|
+
maxLength?: number,
|
|
30
|
+
ttlMs?: number
|
|
31
|
+
): Promise<void>;
|
|
32
|
+
listGet(key: string): string[];
|
|
33
|
+
cacheGet(key: string): string | null;
|
|
34
|
+
cacheSet(key: string, value: string, ttlMs?: number): Promise<void>;
|
|
35
|
+
cacheSetIfNotExists(
|
|
36
|
+
key: string,
|
|
37
|
+
value: string,
|
|
38
|
+
ttlMs?: number
|
|
39
|
+
): Promise<boolean>;
|
|
40
|
+
cacheDelete(key: string): void;
|
|
41
|
+
cleanupExpired(payload?: { expiresAt?: number }): Promise<void>;
|
|
42
|
+
private migrate;
|
|
43
|
+
private readCacheValue;
|
|
44
|
+
private upsertCacheValue;
|
|
45
|
+
private scheduleCleanupForExpiry;
|
|
46
|
+
private scheduleNextCleanup;
|
|
47
|
+
private ensureCleanupScheduled;
|
|
48
|
+
private nextExpiry;
|
|
49
|
+
private readCleanupMetadata;
|
|
50
|
+
private writeCleanupMetadata;
|
|
51
|
+
private clearCleanupMetadata;
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/chat-sdk/types.d.ts
|
|
55
|
+
interface ChatSdkStateParent {
|
|
56
|
+
subAgent<T extends ChatSdkStateAgent>(
|
|
57
|
+
agentClass: SubAgentClass<T>,
|
|
58
|
+
name: string
|
|
59
|
+
): Promise<SubAgentStub<T>>;
|
|
60
|
+
}
|
|
61
|
+
interface ChatSdkStateAdapterOptions {
|
|
62
|
+
agent?: SubAgentClass<ChatSdkStateAgent>;
|
|
63
|
+
parent?: ChatSdkStateParent;
|
|
64
|
+
name?: string;
|
|
65
|
+
keyShard?: (key: string) => string | undefined;
|
|
66
|
+
shardKey?: (threadId: string) => string;
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/chat-sdk/adapter.d.ts
|
|
70
|
+
declare function defaultThreadShard(threadId: string): string;
|
|
71
|
+
declare function defaultKeyShard(
|
|
72
|
+
key: string,
|
|
73
|
+
shardThread?: (threadId: string) => string
|
|
74
|
+
): string | undefined;
|
|
75
|
+
declare class ChatSdkStateAdapter implements StateAdapter {
|
|
76
|
+
private readonly parent;
|
|
77
|
+
private readonly agentClass;
|
|
78
|
+
private readonly defaultName;
|
|
79
|
+
private readonly keyShard?;
|
|
80
|
+
private readonly shardKey;
|
|
81
|
+
private connected;
|
|
82
|
+
constructor(options?: ChatSdkStateAdapterOptions);
|
|
83
|
+
connect(): Promise<void>;
|
|
84
|
+
disconnect(): Promise<void>;
|
|
85
|
+
subscribe(threadId: string): Promise<void>;
|
|
86
|
+
unsubscribe(threadId: string): Promise<void>;
|
|
87
|
+
isSubscribed(threadId: string): Promise<boolean>;
|
|
88
|
+
acquireLock(threadId: string, ttlMs: number): Promise<Lock | null>;
|
|
89
|
+
releaseLock(lock: Lock): Promise<void>;
|
|
90
|
+
extendLock(lock: Lock, ttlMs: number): Promise<boolean>;
|
|
91
|
+
forceReleaseLock(threadId: string): Promise<void>;
|
|
92
|
+
enqueue(
|
|
93
|
+
threadId: string,
|
|
94
|
+
entry: QueueEntry,
|
|
95
|
+
maxSize: number
|
|
96
|
+
): Promise<number>;
|
|
97
|
+
dequeue(threadId: string): Promise<QueueEntry | null>;
|
|
98
|
+
queueDepth(threadId: string): Promise<number>;
|
|
99
|
+
appendToList(
|
|
100
|
+
key: string,
|
|
101
|
+
value: unknown,
|
|
102
|
+
options?: {
|
|
103
|
+
maxLength?: number;
|
|
104
|
+
ttlMs?: number;
|
|
105
|
+
}
|
|
106
|
+
): Promise<void>;
|
|
107
|
+
getList<T = unknown>(key: string): Promise<T[]>;
|
|
108
|
+
get<T = unknown>(key: string): Promise<T | null>;
|
|
109
|
+
set<T = unknown>(key: string, value: T, ttlMs?: number): Promise<void>;
|
|
110
|
+
setIfNotExists<T = unknown>(
|
|
111
|
+
key: string,
|
|
112
|
+
value: T,
|
|
113
|
+
ttlMs?: number
|
|
114
|
+
): Promise<boolean>;
|
|
115
|
+
delete(key: string): Promise<void>;
|
|
116
|
+
private stateAgent;
|
|
117
|
+
private stateAgentForKey;
|
|
118
|
+
private ensureConnected;
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/chat-sdk/index.d.ts
|
|
122
|
+
declare function createChatSdkState(
|
|
123
|
+
options?: ChatSdkStateAdapterOptions
|
|
124
|
+
): ChatSdkStateAdapter;
|
|
125
|
+
//#endregion
|
|
126
|
+
export {
|
|
127
|
+
ChatSdkStateAdapter,
|
|
128
|
+
type ChatSdkStateAdapterOptions,
|
|
129
|
+
ChatSdkStateAgent,
|
|
130
|
+
type ChatSdkStateParent,
|
|
131
|
+
createChatSdkState,
|
|
132
|
+
defaultKeyShard,
|
|
133
|
+
defaultThreadShard
|
|
134
|
+
};
|
|
135
|
+
//# sourceMappingURL=index.d.ts.map
|