@restatedev/agents 0.11.1 → 0.12.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/README.md +189 -808
- package/dist/pi/factory.d.ts +73 -0
- package/dist/pi/factory.d.ts.map +1 -0
- package/dist/pi/factory.js +145 -0
- package/dist/pi/factory.js.map +1 -0
- package/dist/pi/index.d.ts +5 -129
- package/dist/pi/index.d.ts.map +1 -1
- package/dist/pi/index.js +31 -571
- package/dist/pi/index.js.map +1 -1
- package/dist/pi/keepalive.d.ts +3 -16
- package/dist/pi/keepalive.d.ts.map +1 -1
- package/dist/pi/keepalive.js +38 -41
- package/dist/pi/keepalive.js.map +1 -1
- package/dist/pi/left.d.ts +16 -0
- package/dist/pi/left.d.ts.map +1 -0
- package/dist/pi/left.js +23 -0
- package/dist/pi/left.js.map +1 -0
- package/dist/pi/storage.d.ts +19 -76
- package/dist/pi/storage.d.ts.map +1 -1
- package/dist/pi/storage.js +50 -368
- package/dist/pi/storage.js.map +1 -1
- package/dist/pi/tools.d.ts +12 -0
- package/dist/pi/tools.d.ts.map +1 -0
- package/dist/pi/tools.js +70 -0
- package/dist/pi/tools.js.map +1 -0
- package/package.json +11 -254
- package/src/pi/factory.ts +231 -0
- package/src/pi/index.ts +31 -759
- package/src/pi/keepalive.ts +46 -56
- package/src/pi/left.ts +52 -0
- package/src/pi/storage.ts +75 -409
- package/src/pi/tools.ts +78 -0
- package/dist/agentlib/agent.d.ts +0 -32
- package/dist/agentlib/agent.d.ts.map +0 -1
- package/dist/agentlib/agent.js +0 -174
- package/dist/agentlib/agent.js.map +0 -1
- package/dist/agentlib/index.d.ts +0 -5
- package/dist/agentlib/index.d.ts.map +0 -1
- package/dist/agentlib/index.js +0 -15
- package/dist/agentlib/index.js.map +0 -1
- package/dist/agentlib/messages.d.ts +0 -39
- package/dist/agentlib/messages.d.ts.map +0 -1
- package/dist/agentlib/messages.js +0 -177
- package/dist/agentlib/messages.js.map +0 -1
- package/dist/agentlib/model.d.ts +0 -31
- package/dist/agentlib/model.d.ts.map +0 -1
- package/dist/agentlib/model.js +0 -140
- package/dist/agentlib/model.js.map +0 -1
- package/dist/agentlib/options.d.ts +0 -58
- package/dist/agentlib/options.d.ts.map +0 -1
- package/dist/agentlib/options.js +0 -2
- package/dist/agentlib/options.js.map +0 -1
- package/dist/agentlib/runtime.d.ts +0 -37
- package/dist/agentlib/runtime.d.ts.map +0 -1
- package/dist/agentlib/runtime.js +0 -216
- package/dist/agentlib/runtime.js.map +0 -1
- package/dist/agentlib/state.d.ts +0 -114
- package/dist/agentlib/state.d.ts.map +0 -1
- package/dist/agentlib/state.js +0 -52
- package/dist/agentlib/state.js.map +0 -1
- package/dist/agentlib/steering.d.ts +0 -23
- package/dist/agentlib/steering.d.ts.map +0 -1
- package/dist/agentlib/steering.js +0 -48
- package/dist/agentlib/steering.js.map +0 -1
- package/dist/agentlib/tools.d.ts +0 -33
- package/dist/agentlib/tools.d.ts.map +0 -1
- package/dist/agentlib/tools.js +0 -245
- package/dist/agentlib/tools.js.map +0 -1
- package/dist/agentlib/turn.d.ts +0 -82
- package/dist/agentlib/turn.d.ts.map +0 -1
- package/dist/agentlib/turn.js +0 -253
- package/dist/agentlib/turn.js.map +0 -1
- package/dist/calls.d.ts +0 -90
- package/dist/calls.d.ts.map +0 -1
- package/dist/calls.js +0 -235
- package/dist/calls.js.map +0 -1
- package/dist/claude/index.d.ts +0 -106
- package/dist/claude/index.d.ts.map +0 -1
- package/dist/claude/index.js +0 -386
- package/dist/claude/index.js.map +0 -1
- package/dist/client.d.ts +0 -90
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js +0 -88
- package/dist/client.js.map +0 -1
- package/dist/common.d.ts +0 -410
- package/dist/common.d.ts.map +0 -1
- package/dist/common.js +0 -563
- package/dist/common.js.map +0 -1
- package/dist/companion.d.ts +0 -286
- package/dist/companion.d.ts.map +0 -1
- package/dist/companion.js +0 -463
- package/dist/companion.js.map +0 -1
- package/dist/conversation.d.ts +0 -576
- package/dist/conversation.d.ts.map +0 -1
- package/dist/conversation.js +0 -1476
- package/dist/conversation.js.map +0 -1
- package/dist/deepseek/barriers.d.ts +0 -11
- package/dist/deepseek/barriers.d.ts.map +0 -1
- package/dist/deepseek/barriers.js +0 -36
- package/dist/deepseek/barriers.js.map +0 -1
- package/dist/deepseek/index.d.ts +0 -97
- package/dist/deepseek/index.d.ts.map +0 -1
- package/dist/deepseek/index.js +0 -603
- package/dist/deepseek/index.js.map +0 -1
- package/dist/deepseek/persistence.d.ts +0 -83
- package/dist/deepseek/persistence.d.ts.map +0 -1
- package/dist/deepseek/persistence.js +0 -262
- package/dist/deepseek/persistence.js.map +0 -1
- package/dist/index.d.ts +0 -14
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -17
- package/dist/index.js.map +0 -1
- package/dist/langgraph/checkpointer.d.ts +0 -52
- package/dist/langgraph/checkpointer.d.ts.map +0 -1
- package/dist/langgraph/checkpointer.js +0 -477
- package/dist/langgraph/checkpointer.js.map +0 -1
- package/dist/langgraph/context.d.ts +0 -10
- package/dist/langgraph/context.d.ts.map +0 -1
- package/dist/langgraph/context.js +0 -21
- package/dist/langgraph/context.js.map +0 -1
- package/dist/langgraph/errors.d.ts +0 -16
- package/dist/langgraph/errors.d.ts.map +0 -1
- package/dist/langgraph/errors.js +0 -30
- package/dist/langgraph/errors.js.map +0 -1
- package/dist/langgraph/graph.d.ts +0 -25
- package/dist/langgraph/graph.d.ts.map +0 -1
- package/dist/langgraph/graph.js +0 -378
- package/dist/langgraph/graph.js.map +0 -1
- package/dist/langgraph/index.d.ts +0 -119
- package/dist/langgraph/index.d.ts.map +0 -1
- package/dist/langgraph/index.js +0 -325
- package/dist/langgraph/index.js.map +0 -1
- package/dist/langgraph/keepalive.d.ts +0 -16
- package/dist/langgraph/keepalive.d.ts.map +0 -1
- package/dist/langgraph/keepalive.js +0 -51
- package/dist/langgraph/keepalive.js.map +0 -1
- package/dist/langgraph/nodes.d.ts +0 -71
- package/dist/langgraph/nodes.d.ts.map +0 -1
- package/dist/langgraph/nodes.js +0 -148
- package/dist/langgraph/nodes.js.map +0 -1
- package/dist/messages.d.ts +0 -18
- package/dist/messages.d.ts.map +0 -1
- package/dist/messages.js +0 -182
- package/dist/messages.js.map +0 -1
- package/dist/object.d.ts +0 -213
- package/dist/object.d.ts.map +0 -1
- package/dist/object.js +0 -309
- package/dist/object.js.map +0 -1
- package/dist/opencode/db.d.ts +0 -81
- package/dist/opencode/db.d.ts.map +0 -1
- package/dist/opencode/db.js +0 -249
- package/dist/opencode/db.js.map +0 -1
- package/dist/opencode/index.d.ts +0 -184
- package/dist/opencode/index.d.ts.map +0 -1
- package/dist/opencode/index.js +0 -1079
- package/dist/opencode/index.js.map +0 -1
- package/dist/output.d.ts +0 -25
- package/dist/output.d.ts.map +0 -1
- package/dist/output.js +0 -99
- package/dist/output.js.map +0 -1
- package/dist/pi/commits.d.ts +0 -6
- package/dist/pi/commits.d.ts.map +0 -1
- package/dist/pi/commits.js +0 -3
- package/dist/pi/commits.js.map +0 -1
- package/dist/steering.d.ts +0 -32
- package/dist/steering.d.ts.map +0 -1
- package/dist/steering.js +0 -45
- package/dist/steering.js.map +0 -1
- package/dist/tools.d.ts +0 -267
- package/dist/tools.d.ts.map +0 -1
- package/dist/tools.js +0 -305
- package/dist/tools.js.map +0 -1
- package/dist/webhook.d.ts +0 -71
- package/dist/webhook.d.ts.map +0 -1
- package/dist/webhook.js +0 -102
- package/dist/webhook.js.map +0 -1
- package/src/agentlib/README.md +0 -229
- package/src/agentlib/agent.ts +0 -216
- package/src/agentlib/index.ts +0 -16
- package/src/agentlib/messages.ts +0 -207
- package/src/agentlib/model.ts +0 -156
- package/src/agentlib/options.ts +0 -62
- package/src/agentlib/runtime.ts +0 -252
- package/src/agentlib/state.ts +0 -93
- package/src/agentlib/steering.ts +0 -53
- package/src/agentlib/tools.ts +0 -355
- package/src/agentlib/turn.ts +0 -302
- package/src/calls.ts +0 -330
- package/src/claude/README.md +0 -107
- package/src/claude/index.ts +0 -487
- package/src/client.ts +0 -187
- package/src/common.ts +0 -766
- package/src/companion.ts +0 -675
- package/src/conversation.ts +0 -1799
- package/src/deepseek/README.md +0 -202
- package/src/deepseek/barriers.ts +0 -63
- package/src/deepseek/index.ts +0 -740
- package/src/deepseek/persistence.ts +0 -337
- package/src/index.ts +0 -41
- package/src/langgraph/README.md +0 -199
- package/src/langgraph/checkpointer.ts +0 -614
- package/src/langgraph/context.ts +0 -27
- package/src/langgraph/errors.ts +0 -26
- package/src/langgraph/graph.ts +0 -422
- package/src/langgraph/index.ts +0 -500
- package/src/langgraph/keepalive.ts +0 -58
- package/src/langgraph/nodes.ts +0 -247
- package/src/messages.ts +0 -244
- package/src/object.ts +0 -454
- package/src/opencode/README.md +0 -249
- package/src/opencode/db.ts +0 -387
- package/src/opencode/index.ts +0 -1339
- package/src/output.ts +0 -116
- package/src/pi/README.md +0 -174
- package/src/pi/commits.ts +0 -7
- package/src/steering.ts +0 -68
- package/src/tools.ts +0 -515
- package/src/webhook.ts +0 -161
package/dist/companion.d.ts
DELETED
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
import type { SessionContext, ViewContext } from '@restatedev/sessions';
|
|
2
|
-
import { sdk as restate } from '@restatedev/sessions/internal';
|
|
3
|
-
import type { Answering } from './common.ts';
|
|
4
|
-
import type { Status } from './object.ts';
|
|
5
|
-
/**
|
|
6
|
-
* What an agent's companion's name adds to the agent's: `<agent>.prebuilt.restate`.
|
|
7
|
-
* Restate refuses the names that start with `restate`, so it is a suffix.
|
|
8
|
-
*/
|
|
9
|
-
export declare const COMPANION_SUFFIX = ".prebuilt.restate";
|
|
10
|
-
/** The name of the companion of agent `agent`: `<agent>.prebuilt.restate`. */
|
|
11
|
-
export declare const companionName: (agent: string) => string;
|
|
12
|
-
/** The companion object of an agent, as a client takes it: see {@link companionFor}. */
|
|
13
|
-
export type Companion = ReturnType<typeof makeCompanion>;
|
|
14
|
-
/**
|
|
15
|
-
* The companion of the agent named `agent`: its object, made once, which a
|
|
16
|
-
* handler of the agent calls with the agent's own key.
|
|
17
|
-
*/
|
|
18
|
-
export declare function companionFor(agent: string): Companion;
|
|
19
|
-
/**
|
|
20
|
-
* The companion of the agent of `ctx` (any handler's or view's of its
|
|
21
|
-
* object): the agent's own, which it calls with its own key, `ctx.key`.
|
|
22
|
-
*
|
|
23
|
-
* ctx.rpc(companionAt(ctx), ctx.key).status()
|
|
24
|
-
*/
|
|
25
|
-
export declare const companionAt: (ctx: {
|
|
26
|
-
readonly request: {
|
|
27
|
-
readonly target: {
|
|
28
|
-
readonly service: string;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
}) => restate.VirtualObjectDefinition<string, {
|
|
32
|
-
wait: (ctx: restate.ObjectSharedContext<State>, input: {
|
|
33
|
-
id: string;
|
|
34
|
-
name: string;
|
|
35
|
-
input?: unknown;
|
|
36
|
-
}) => Promise<unknown>;
|
|
37
|
-
resolve: (ctx: restate.ObjectContext<State>, input: Signal) => Promise<{
|
|
38
|
-
resolved: null;
|
|
39
|
-
} | {
|
|
40
|
-
resolved: string;
|
|
41
|
-
}>;
|
|
42
|
-
pending: (ctx: restate.ObjectSharedContext<State>) => Promise<Waiting[]>;
|
|
43
|
-
listen: (ctx: restate.ObjectContext<State>, input: Waiting & {
|
|
44
|
-
awakeable: string;
|
|
45
|
-
}) => Promise<void>;
|
|
46
|
-
start: (ctx: restate.ObjectContext<State>, input: Started) => Promise<Published | undefined>;
|
|
47
|
-
awaitTurn: (ctx: restate.ObjectSharedContext<State>, input: string) => Promise<void>;
|
|
48
|
-
status: (ctx: restate.ObjectSharedContext<State>) => Promise<Status>;
|
|
49
|
-
watch: (ctx: restate.ObjectSharedContext<State>, input: Watch) => Promise<Notifications>;
|
|
50
|
-
close: (ctx: restate.ObjectContext<State>, input: string) => Promise<void>;
|
|
51
|
-
ended: (ctx: restate.ObjectContext<State>, input: string) => Promise<void>;
|
|
52
|
-
reset: (ctx: restate.ObjectContext<State>) => Promise<void>;
|
|
53
|
-
forget: (ctx: restate.ObjectContext<State>, input: string) => Promise<void>;
|
|
54
|
-
publish: (ctx: restate.ObjectContext<State>) => Promise<Published>;
|
|
55
|
-
steer: (ctx: restate.ObjectContext<State>, input: Steer) => Promise<Steered>;
|
|
56
|
-
taken: (ctx: restate.ObjectContext<State>, input: string[]) => Promise<void>;
|
|
57
|
-
notifications: (ctx: restate.ObjectSharedContext<State>) => Promise<Notifications>;
|
|
58
|
-
subscribe: (ctx: restate.ObjectContext<State>, input: {
|
|
59
|
-
revision: number;
|
|
60
|
-
awakeable: string;
|
|
61
|
-
}) => Promise<void>;
|
|
62
|
-
unsubscribe: (ctx: restate.ObjectContext<State>, input: string) => Promise<void>;
|
|
63
|
-
}>;
|
|
64
|
-
/**
|
|
65
|
-
* `definition`, with its companion: what `sessionObject()` returns. `serve`
|
|
66
|
-
* serves the companion beside it.
|
|
67
|
-
*/
|
|
68
|
-
export declare const withCompanion: <D extends {
|
|
69
|
-
name: string;
|
|
70
|
-
}>(definition: D) => D;
|
|
71
|
-
/**
|
|
72
|
-
* The companion object of `agent` (an `sessionObject()` or `agent()` of
|
|
73
|
-
* @restatedev/agents), named `<agent>.prebuilt.restate`: served with
|
|
74
|
-
* the agent, and keyed as the agent. Clients reach it only through the
|
|
75
|
-
* agent's own views (`status`, `pending`, `signal`, `watch`...).
|
|
76
|
-
*/
|
|
77
|
-
export declare function companionOf(agent: {
|
|
78
|
-
name: string;
|
|
79
|
-
}): Companion;
|
|
80
|
-
/** Whether `agent` is an object of @restatedev/agents, with a companion. */
|
|
81
|
-
export declare const hasCompanion: (agent: object) => boolean;
|
|
82
|
-
/**
|
|
83
|
-
* What a handler meets as it reaches for its object's companion when the
|
|
84
|
-
* object has none: a plain session object of @restatedev/sessions, say, that
|
|
85
|
-
* runs a framework's `prompt()` with a `signal` tool. A programming error,
|
|
86
|
-
* which a retry meets again: terminal, so the invocation fails once.
|
|
87
|
-
*/
|
|
88
|
-
export declare class NoCompanion extends restate.TerminalError {
|
|
89
|
-
constructor(service: string, needs: string);
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* The companion of the object of `ctx` (a handler's or a view's), which
|
|
93
|
-
* `needs` (a wait for a signal, a chat turn, a publish...) needs: its own,
|
|
94
|
-
* which it calls with its own key. An object without one (not made by
|
|
95
|
-
* `sessionObject()` or an `agent()`) fails with {@link NoCompanion}, rather
|
|
96
|
-
* than call a companion that nobody serves.
|
|
97
|
-
*
|
|
98
|
-
* ctx.rpc(companionHere(ctx, 'a wait for a signal'), ctx.key).wait(...)
|
|
99
|
-
*/
|
|
100
|
-
export declare function companionHere(ctx: SessionContext | ViewContext, needs: string): Companion;
|
|
101
|
-
/**
|
|
102
|
-
* Deliver `text` to `agent`'s key `key`, from any handler: a message of its
|
|
103
|
-
* own (as `chat`), which it answers after the messages before it. It is
|
|
104
|
-
* sent, not awaited: `opts` may give it an idempotency key, so that it is
|
|
105
|
-
* delivered once.
|
|
106
|
-
*
|
|
107
|
-
* deliver(ctx, triage, 'ENG-1', 'The issue was closed', { idempotencyKey: delivery });
|
|
108
|
-
*/
|
|
109
|
-
export declare function deliver(ctx: Pick<restate.Context, 'genericSend'> | Pick<SessionContext, 'send'>, agent: {
|
|
110
|
-
name: string;
|
|
111
|
-
}, key: string, text: string, { idempotencyKey }?: {
|
|
112
|
-
idempotencyKey?: string;
|
|
113
|
-
}): void;
|
|
114
|
-
/** A wait for a signal, as `pending` lists it. */
|
|
115
|
-
export interface Waiting {
|
|
116
|
-
/** The wait's id, which `signal` takes to resolve this wait and no other. */
|
|
117
|
-
id: string;
|
|
118
|
-
/** The signal it waits for, such as `approval`. */
|
|
119
|
-
name: string;
|
|
120
|
-
/** What it waits for, as the model said it (such as the refund to approve), if the tool takes an input. */
|
|
121
|
-
input?: unknown;
|
|
122
|
-
/** When it started, as an ISO date. */
|
|
123
|
-
since: string;
|
|
124
|
-
}
|
|
125
|
-
/** Which wait a signal resolves, and with what. */
|
|
126
|
-
export interface Signal {
|
|
127
|
-
/** The wait of this id (from `pending`). */
|
|
128
|
-
id?: string;
|
|
129
|
-
/** Else the oldest wait for the signal of this name. */
|
|
130
|
-
name?: string;
|
|
131
|
-
/** Its value: what the wait answers the model with. */
|
|
132
|
-
value?: unknown;
|
|
133
|
-
/** With a `name` and no one waiting for it, keep the signal for the next wait for it (by default it is dropped). */
|
|
134
|
-
keep?: boolean;
|
|
135
|
-
}
|
|
136
|
-
/** What `signal` did: the id of the wait it resolved, or null if none waited (and it was dropped, or kept). */
|
|
137
|
-
export interface Resolved {
|
|
138
|
-
resolved: string | null;
|
|
139
|
-
}
|
|
140
|
-
/** The revision of an agent's conversation: each change of what a client reads increases it. */
|
|
141
|
-
export interface Notifications {
|
|
142
|
-
revision: number;
|
|
143
|
-
}
|
|
144
|
-
/** A message steered to the turn being answered (`steer`): its id (the `steer` request's) and its text. */
|
|
145
|
-
export interface Steer {
|
|
146
|
-
id: string;
|
|
147
|
-
text: string;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* What `publish` answers the turn that published: the new revision, and the
|
|
151
|
-
* messages steered to the turn being answered that it has not taken yet, if
|
|
152
|
-
* any, oldest first.
|
|
153
|
-
*/
|
|
154
|
-
export interface Published extends Notifications {
|
|
155
|
-
steering?: Steer[];
|
|
156
|
-
}
|
|
157
|
-
/** A message steered to the turn being answered that it has not taken yet, as `status` shows it. */
|
|
158
|
-
export interface Steering {
|
|
159
|
-
id: string;
|
|
160
|
-
/** When it was sent, as an ISO date. */
|
|
161
|
-
since: string;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* What the `steer` view answers: the message's id (the request's), and the
|
|
165
|
-
* invocation of the turn being answered, which takes the message at its next
|
|
166
|
-
* step if it reaches one; null if no turn takes it. Either way the message is
|
|
167
|
-
* answered once: in that turn, or else as a turn of its own, in the order it
|
|
168
|
-
* was sent.
|
|
169
|
-
*/
|
|
170
|
-
export interface Steered {
|
|
171
|
-
id: string;
|
|
172
|
-
turn: string | null;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* How many messages a turn takes by `steer`, at most: past them, each is
|
|
176
|
-
* answered as a turn of its own. The companion counts each message it holds
|
|
177
|
-
* for the turn, taken or not, until the turn ends: so a turn that someone
|
|
178
|
-
* steers on and on stays within bounds, and so does what the companion holds
|
|
179
|
-
* for it.
|
|
180
|
-
*/
|
|
181
|
-
export declare const STEERS = 16;
|
|
182
|
-
/** What `watch` waits for: a revision newer than `revision`, for at most `timeoutSeconds` (default 50, at most 60). */
|
|
183
|
-
export interface Watch {
|
|
184
|
-
revision: number;
|
|
185
|
-
timeoutSeconds?: number;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* A turn as its agent starts it, and whether the agent closes it itself once
|
|
189
|
-
* its invocation is gone: whether it has the private `settle` handler (an
|
|
190
|
-
* agent on the conversation of turns), which the companion sends such a
|
|
191
|
-
* turn. Any other agent is sent nothing: its next message closes such a turn.
|
|
192
|
-
*/
|
|
193
|
-
export interface Started extends Answering {
|
|
194
|
-
settles?: boolean;
|
|
195
|
-
/**
|
|
196
|
-
* Whether the turn takes steered messages at its steps (`steer`). A turn
|
|
197
|
-
* that does not say so (of an agent whose framework cannot take them, or
|
|
198
|
-
* that runs in the background) gets none: each is answered as a turn of
|
|
199
|
-
* its own.
|
|
200
|
-
*/
|
|
201
|
-
steers?: boolean;
|
|
202
|
-
/**
|
|
203
|
-
* Whether `start` publishes the turn's start, and returns what `publish`
|
|
204
|
-
* returns: a followed turn, which then makes no publish of its own to
|
|
205
|
-
* start. A turn that does not say so (of an agent that runs in the
|
|
206
|
-
* background, which publishes its end only) is not published by `start`,
|
|
207
|
-
* which returns nothing.
|
|
208
|
-
*/
|
|
209
|
-
publishes?: boolean;
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* A message steered to the turn `turn` (an invocation id), as the companion
|
|
213
|
-
* holds it until the turn ends: with its text until the turn takes it
|
|
214
|
-
* (`taken`), and then only as one of the turn's {@link STEERS}.
|
|
215
|
-
*/
|
|
216
|
-
interface Inboxed {
|
|
217
|
-
id: string;
|
|
218
|
-
since: string;
|
|
219
|
-
turn: string;
|
|
220
|
-
text?: string;
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* The message the agent answers; the waits, in the order they started, each
|
|
224
|
-
* with its awakeable; the signals kept for the next wait; and the
|
|
225
|
-
* conversation's revision, with the `watch`es waiting for a newer one.
|
|
226
|
-
* Exported for the declarations of the companion's client, which name it.
|
|
227
|
-
*/
|
|
228
|
-
export interface State {
|
|
229
|
-
/** The message the agent answers, from its turn's start to its close. */
|
|
230
|
-
turn: Started;
|
|
231
|
-
waiting: (Waiting & {
|
|
232
|
-
awakeable: string;
|
|
233
|
-
})[];
|
|
234
|
-
kept: Record<string, unknown[]>;
|
|
235
|
-
/** The messages steered to the turns not closed yet (the one being answered), taken or not, oldest first. */
|
|
236
|
-
inbox: Inboxed[];
|
|
237
|
-
revision: number;
|
|
238
|
-
watching: {
|
|
239
|
-
revision: number;
|
|
240
|
-
awakeable: string;
|
|
241
|
-
}[];
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* The companion of agent `agent`: an object named
|
|
245
|
-
* `<agent>.prebuilt.restate` ({@link companionName}), keyed as the
|
|
246
|
-
* agent, whose handlers only the agent's own handlers and views call
|
|
247
|
-
* (Restate's ingress refuses them all): clients ask the agent's views
|
|
248
|
-
* (`status`, `pending`, `signal`, `steer`, `watch`...), which ask it. Its
|
|
249
|
-
* sends to its agent (`settle`, `steered`) go to `agent`, at its own key.
|
|
250
|
-
* See {@link companionFor}, which makes one per agent.
|
|
251
|
-
*/
|
|
252
|
-
declare function makeCompanion(agent: string): restate.VirtualObjectDefinition<string, {
|
|
253
|
-
wait: (ctx: restate.ObjectSharedContext<State>, input: {
|
|
254
|
-
id: string;
|
|
255
|
-
name: string;
|
|
256
|
-
input?: unknown;
|
|
257
|
-
}) => Promise<unknown>;
|
|
258
|
-
resolve: (ctx: restate.ObjectContext<State>, input: Signal) => Promise<{
|
|
259
|
-
resolved: null;
|
|
260
|
-
} | {
|
|
261
|
-
resolved: string;
|
|
262
|
-
}>;
|
|
263
|
-
pending: (ctx: restate.ObjectSharedContext<State>) => Promise<Waiting[]>;
|
|
264
|
-
listen: (ctx: restate.ObjectContext<State>, input: Waiting & {
|
|
265
|
-
awakeable: string;
|
|
266
|
-
}) => Promise<void>;
|
|
267
|
-
start: (ctx: restate.ObjectContext<State>, input: Started) => Promise<Published | undefined>;
|
|
268
|
-
awaitTurn: (ctx: restate.ObjectSharedContext<State>, input: string) => Promise<void>;
|
|
269
|
-
status: (ctx: restate.ObjectSharedContext<State>) => Promise<Status>;
|
|
270
|
-
watch: (ctx: restate.ObjectSharedContext<State>, input: Watch) => Promise<Notifications>;
|
|
271
|
-
close: (ctx: restate.ObjectContext<State>, input: string) => Promise<void>;
|
|
272
|
-
ended: (ctx: restate.ObjectContext<State>, input: string) => Promise<void>;
|
|
273
|
-
reset: (ctx: restate.ObjectContext<State>) => Promise<void>;
|
|
274
|
-
forget: (ctx: restate.ObjectContext<State>, input: string) => Promise<void>;
|
|
275
|
-
publish: (ctx: restate.ObjectContext<State>) => Promise<Published>;
|
|
276
|
-
steer: (ctx: restate.ObjectContext<State>, input: Steer) => Promise<Steered>;
|
|
277
|
-
taken: (ctx: restate.ObjectContext<State>, input: string[]) => Promise<void>;
|
|
278
|
-
notifications: (ctx: restate.ObjectSharedContext<State>) => Promise<Notifications>;
|
|
279
|
-
subscribe: (ctx: restate.ObjectContext<State>, input: {
|
|
280
|
-
revision: number;
|
|
281
|
-
awakeable: string;
|
|
282
|
-
}) => Promise<void>;
|
|
283
|
-
unsubscribe: (ctx: restate.ObjectContext<State>, input: string) => Promise<void>;
|
|
284
|
-
}>;
|
|
285
|
-
export {};
|
|
286
|
-
//# sourceMappingURL=companion.d.ts.map
|
package/dist/companion.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"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