@lightspeed-ai/agent-client 0.1.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.
Files changed (47) hide show
  1. package/README.md +63 -0
  2. package/dist/client.d.ts +65 -0
  3. package/dist/client.d.ts.map +1 -0
  4. package/dist/client.js +194 -0
  5. package/dist/client.js.map +1 -0
  6. package/dist/errors.d.ts +20 -0
  7. package/dist/errors.d.ts.map +1 -0
  8. package/dist/errors.js +47 -0
  9. package/dist/errors.js.map +1 -0
  10. package/dist/generated/methods.d.ts +2497 -0
  11. package/dist/generated/methods.d.ts.map +1 -0
  12. package/dist/generated/methods.js +1751 -0
  13. package/dist/generated/methods.js.map +1 -0
  14. package/dist/generated/types.d.ts +6950 -0
  15. package/dist/generated/types.d.ts.map +1 -0
  16. package/dist/generated/types.js +6 -0
  17. package/dist/generated/types.js.map +1 -0
  18. package/dist/generated/workflow-manifest.d.ts +219 -0
  19. package/dist/generated/workflow-manifest.d.ts.map +1 -0
  20. package/dist/generated/workflow-manifest.js +251 -0
  21. package/dist/generated/workflow-manifest.js.map +1 -0
  22. package/dist/generated/workflow-types.d.ts +451 -0
  23. package/dist/generated/workflow-types.d.ts.map +1 -0
  24. package/dist/generated/workflow-types.js +6 -0
  25. package/dist/generated/workflow-types.js.map +1 -0
  26. package/dist/index.d.ts +8 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +4 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/workflow.d.ts +217 -0
  31. package/dist/workflow.d.ts.map +1 -0
  32. package/dist/workflow.js +338 -0
  33. package/dist/workflow.js.map +1 -0
  34. package/examples/temporal-activity.ts +33 -0
  35. package/package.json +55 -0
  36. package/release.json +4 -0
  37. package/schema/api.schema.json +16643 -0
  38. package/schema/workflow.json +246 -0
  39. package/schema/workflow.schema.json +880 -0
  40. package/src/client.ts +318 -0
  41. package/src/errors.ts +64 -0
  42. package/src/generated/methods.ts +2888 -0
  43. package/src/generated/types.ts +7189 -0
  44. package/src/generated/workflow-manifest.ts +251 -0
  45. package/src/generated/workflow-types.ts +468 -0
  46. package/src/index.ts +31 -0
  47. package/src/workflow.ts +468 -0
@@ -0,0 +1,468 @@
1
+ /*
2
+ * Generated by clients/typescript/scripts/generate.mjs.
3
+ * Do not edit by hand.
4
+ */
5
+
6
+ /**
7
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
8
+ * via the `definition` "BotId".
9
+ */
10
+ export type BotId = string;
11
+ /**
12
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
13
+ * via the `definition` "BotTriggerId".
14
+ */
15
+ export type BotTriggerId = string;
16
+ /**
17
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
18
+ * via the `definition` "ChannelAccountId".
19
+ */
20
+ export type ChannelAccountId = string;
21
+ /**
22
+ * What a connector executes: provider message ids and their direction.
23
+ *
24
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
25
+ * via the `definition` "ChannelDeliveryOperation".
26
+ */
27
+ export type ChannelDeliveryOperation =
28
+ | {
29
+ replyContext?: ReplyContext | null;
30
+ replyTo?: string | null;
31
+ text: string;
32
+ type: "send";
33
+ }
34
+ | {
35
+ messageId: string;
36
+ text: string;
37
+ type: "edit";
38
+ }
39
+ | {
40
+ emoji: string;
41
+ /**
42
+ * Whether the reacted-to message is the bot's own.
43
+ */
44
+ fromMe: boolean;
45
+ messageId: string;
46
+ type: "react";
47
+ };
48
+ /**
49
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
50
+ * via the `definition` "ChannelProvider".
51
+ */
52
+ export type ChannelProvider = string;
53
+ /**
54
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
55
+ * via the `definition` "ChannelMediaKind".
56
+ */
57
+ export type ChannelMediaKind = "image" | "audio" | "document";
58
+ /**
59
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
60
+ * via the `definition` "ChatTurnAccess".
61
+ */
62
+ export type ChatTurnAccess = "anyone" | "listed";
63
+ /**
64
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
65
+ * via the `definition` "ChatGroupActivation".
66
+ */
67
+ export type ChatGroupActivation = "mention" | "always";
68
+ /**
69
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
70
+ * via the `definition` "ChatScope".
71
+ */
72
+ export type ChatScope = "direct" | "group";
73
+ /**
74
+ * Closed internal vocabulary carried by the shared delivery signal.
75
+ *
76
+ * Workflow-tool invocation bodies join this enum when the durable tool
77
+ * contracts land. This first slice folds the two existing transports.
78
+ *
79
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
80
+ * via the `definition` "EmissionBody".
81
+ */
82
+ export type EmissionBody =
83
+ | {
84
+ failure_message_ref?: string | null;
85
+ kind: "run_terminal";
86
+ output_ref?: string | null;
87
+ run_id: number;
88
+ status: RunStatus;
89
+ token: string;
90
+ }
91
+ | {
92
+ kind: "source_resolution";
93
+ promise_id: PromiseId;
94
+ resolution: PromiseResolution;
95
+ }
96
+ | {
97
+ /**
98
+ * Workflow id of the session that emitted the invocation — the
99
+ * endpoint a receiver signals its reply to. Supplied by the
100
+ * substrate adapter; the engine treats it as opaque.
101
+ */
102
+ holder_workflow_id: string;
103
+ invocation: WorkflowToolInvocation;
104
+ kind: "tool_invocation";
105
+ }
106
+ | {
107
+ completion_key: string;
108
+ invocation_id: WorkflowToolInvocationId;
109
+ kind: "invocation_cancellation";
110
+ promise_id: PromiseId;
111
+ };
112
+ /**
113
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
114
+ * via the `definition` "RunStatus".
115
+ */
116
+ export type RunStatus = "active" | "parked" | "cancelling" | "completed" | "failed" | "cancelled";
117
+ /**
118
+ * Stable identifier for a promise: a session-scoped counter rendered as
119
+ * `promise_<n>`, the same convention as `run_<n>`, so the model copies a
120
+ * short handle rather than a digest. The engine hands every tool batch a
121
+ * base one past the session cursor (`ToolInvocationBatchRequest::
122
+ * promise_id_base`); the executor numbers the promises it creates from
123
+ * that base, and the reducer accepts a creation only at or above the
124
+ * batch's base and never twice. Producer correlation lives on
125
+ * `PromiseSource`, not in the id.
126
+ *
127
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
128
+ * via the `definition` "PromiseId".
129
+ */
130
+ export type PromiseId = string;
131
+ /**
132
+ * How a promise reached a terminal state. Used by `ResolvePromise`
133
+ * admission; all transports (push notifications, poll results, timers,
134
+ * cancellation) converge on this one funnel.
135
+ *
136
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
137
+ * via the `definition` "PromiseResolution".
138
+ */
139
+ export type PromiseResolution =
140
+ | {
141
+ kind: "resolved";
142
+ payload_ref?: string | null;
143
+ }
144
+ | {
145
+ error_ref?: string | null;
146
+ kind: "failed";
147
+ }
148
+ | {
149
+ kind: "cancelled";
150
+ };
151
+ /**
152
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
153
+ * via the `definition` "WorkflowToolInvocationId".
154
+ */
155
+ export type WorkflowToolInvocationId = string;
156
+ /**
157
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
158
+ * via the `definition` "SessionId".
159
+ */
160
+ export type SessionId = string;
161
+ /**
162
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
163
+ * via the `definition` "ToolCallId".
164
+ */
165
+ export type ToolCallId = string;
166
+ /**
167
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
168
+ * via the `definition` "WorkflowToolId".
169
+ */
170
+ export type WorkflowToolId = string;
171
+ /**
172
+ * Stable identity for one cross-workflow emission.
173
+ *
174
+ * Ids are deterministic digests over a domain-separated, length-prefixed
175
+ * producer/source identity. They are safe to recompute after activity retry,
176
+ * worker restart, or workflow continue-as-new.
177
+ *
178
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
179
+ * via the `definition` "EmissionId".
180
+ */
181
+ export type EmissionId = string;
182
+ /**
183
+ * Durable producer identity carried with every emission.
184
+ *
185
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
186
+ * via the `definition` "EmissionProducer".
187
+ */
188
+ export type EmissionProducer =
189
+ | {
190
+ kind: "session";
191
+ log_seq: number;
192
+ session_id: SessionId;
193
+ universe_id: string;
194
+ }
195
+ | {
196
+ kind: "workflow";
197
+ universe_id: string;
198
+ workflow_id: string;
199
+ };
200
+
201
+ /**
202
+ * Envelope and start-on-call types of the fixed deliver_emission transport between sessions and receiver workflows.
203
+ */
204
+ export interface LightspeedWorkflowContract {
205
+ [k: string]: unknown;
206
+ }
207
+ /**
208
+ * One connector activity call. `idempotency_key` is the invocation id, or
209
+ * `{invocation}:chunk:{i}/{n}` for a chunk of a split send.
210
+ *
211
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
212
+ * via the `definition` "ChannelDeliveryCommand".
213
+ */
214
+ export interface ChannelDeliveryCommand {
215
+ idempotencyKey: string;
216
+ invocationId: string;
217
+ operation: ChannelDeliveryOperation;
218
+ route: ChannelRoute;
219
+ version: number;
220
+ }
221
+ /**
222
+ * The message a send replies to, for providers that quote it themselves.
223
+ *
224
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
225
+ * via the `definition` "ReplyContext".
226
+ */
227
+ export interface ReplyContext {
228
+ senderId: string;
229
+ text: string;
230
+ }
231
+ /**
232
+ * Where a delivery goes: one account's chat, optionally a thread.
233
+ *
234
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
235
+ * via the `definition` "ChannelRoute".
236
+ */
237
+ export interface ChannelRoute {
238
+ accountId: ChannelAccountId;
239
+ chatId: string;
240
+ provider: ChannelProvider;
241
+ threadId?: string | null;
242
+ }
243
+ /**
244
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
245
+ * via the `definition` "ChannelDeliveryResult".
246
+ */
247
+ export interface ChannelDeliveryResult {
248
+ /**
249
+ * Every provider id the delivery produced (a chunked send has several;
250
+ * the first is the anchor).
251
+ */
252
+ messageIds: string[];
253
+ provider: ChannelProvider;
254
+ version: number;
255
+ }
256
+ /**
257
+ * A provider-owned attachment reference; never bytes. The connector
258
+ * downloads it when the conversation workflow asks (`prepare_channel_media`).
259
+ *
260
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
261
+ * via the `definition` "ChannelInboundMedia".
262
+ */
263
+ export interface ChannelInboundMedia {
264
+ byteSize?: number | null;
265
+ /**
266
+ * Provider file handle (a Telegram file id, a sealed WhatsApp locator).
267
+ */
268
+ fileId: string;
269
+ kind: ChannelMediaKind;
270
+ mime: string;
271
+ name?: string | null;
272
+ }
273
+ /**
274
+ * Who may take a turn and who may issue control commands, by provider
275
+ * handle (Telegram user id, WhatsApp JID). Handle allowlists on the
276
+ * trigger replace any platform membership lookup.
277
+ *
278
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
279
+ * via the `definition` "ChatAccess".
280
+ */
281
+ export interface ChatAccess {
282
+ /**
283
+ * Handles allowed to take a turn when `turn` is `listed`.
284
+ */
285
+ allowed?: string[];
286
+ /**
287
+ * Handles allowed to issue `/activation` and `/status`; empty denies
288
+ * control commands to everyone.
289
+ */
290
+ controllers?: string[];
291
+ turn?: ChatTurnAccess & string;
292
+ }
293
+ /**
294
+ * When the bot acts in a conversation.
295
+ *
296
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
297
+ * via the `definition` "ChatActivation".
298
+ */
299
+ export interface ChatActivation {
300
+ group?: ChatGroupActivation | null;
301
+ mentionNames?: string[];
302
+ triggerPrefixes?: string[];
303
+ }
304
+ /**
305
+ * The conversation a message belongs to: one account's chat, optionally
306
+ * a thread inside it.
307
+ *
308
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
309
+ * via the `definition` "ConversationRef".
310
+ */
311
+ export interface ConversationRef {
312
+ accountId: ChannelAccountId;
313
+ chatId: string;
314
+ threadId?: string | null;
315
+ }
316
+ /**
317
+ * Secret-free durable input of one conversation workflow: the chat trigger
318
+ * it serves and the conversation it fronts. The workflow owns nothing on
319
+ * the core side: the bot controller creates and controls the session; the
320
+ * workflow is the source of the conversation's events and the receiver of
321
+ * its `message_*` tools.
322
+ *
323
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
324
+ * via the `definition` "ConversationStart".
325
+ */
326
+ export interface ConversationStart {
327
+ access: ChatAccess;
328
+ accountId: ChannelAccountId;
329
+ activation: ChatActivation;
330
+ botId: BotId;
331
+ /**
332
+ * Task queue of the connector host serving the account.
333
+ */
334
+ connectorTaskQueue: string;
335
+ conversation: ConversationRef;
336
+ /**
337
+ * Human label of the conversation (routed session label, display name).
338
+ */
339
+ label: string;
340
+ provider: ChannelProvider;
341
+ scope: ChatScope;
342
+ triggerId: BotTriggerId;
343
+ universeId: string;
344
+ }
345
+ /**
346
+ * Bounded durable record of one successful workflow-tool tool call.
347
+ *
348
+ * The model arguments remain in CAS and are referenced by `arguments_ref`.
349
+ * Receiver-specific interpretation belongs to the receiving workflow.
350
+ *
351
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
352
+ * via the `definition` "WorkflowToolInvocation".
353
+ */
354
+ export interface WorkflowToolInvocation {
355
+ arguments_ref: string;
356
+ binding_fingerprint: string;
357
+ /**
358
+ * Keyed promise set created atomically with this invocation; `None`
359
+ * for notify (`Accepted`) completion. Request/reply is the single
360
+ * reserved key `reply`.
361
+ */
362
+ completion_promises?: {
363
+ [k: string]: PromiseId;
364
+ } | null;
365
+ /**
366
+ * Opaque, runtime-supplied context for the receiving workflow. This is
367
+ * separate from model-authored arguments so runtime state can be pinned
368
+ * without changing the tool's declared argument schema.
369
+ */
370
+ execution_context_ref?: string | null;
371
+ invocation_id: WorkflowToolInvocationId;
372
+ run_id: number;
373
+ schema_revision: number;
374
+ semantic_type: string;
375
+ session_id: SessionId;
376
+ session_universe_id: string;
377
+ tool_batch_id: number;
378
+ tool_call_id: ToolCallId;
379
+ tool_id: WorkflowToolId;
380
+ turn_id: number;
381
+ }
382
+ /**
383
+ * Bounded cross-workflow fact delivered through the fixed
384
+ * `deliver_emission` signal.
385
+ *
386
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
387
+ * via the `definition` "EmissionEnvelope".
388
+ */
389
+ export interface EmissionEnvelope {
390
+ body: EmissionBody;
391
+ emission_id: EmissionId;
392
+ producer: EmissionProducer;
393
+ }
394
+ /**
395
+ * `maintain_channel_typing`: keep the provider's typing indicator up for
396
+ * the conversation until the activity is cancelled.
397
+ *
398
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
399
+ * via the `definition` "MaintainChannelTypingInput".
400
+ */
401
+ export interface MaintainChannelTypingInput {
402
+ route: ChannelRoute;
403
+ }
404
+ /**
405
+ * `prepare_channel_media`: the connector downloads the provider file and
406
+ * stores it in the universe's CAS.
407
+ *
408
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
409
+ * via the `definition` "PrepareChannelMediaInput".
410
+ */
411
+ export interface PrepareChannelMediaInput {
412
+ media: ChannelInboundMedia;
413
+ route: ChannelRoute;
414
+ universeId: string;
415
+ }
416
+ /**
417
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
418
+ * via the `definition` "PrepareChannelMediaResult".
419
+ */
420
+ export interface PrepareChannelMediaResult {
421
+ item: PreparedMediaItem;
422
+ }
423
+ /**
424
+ * A prepared attachment: a CAS reference, never bytes.
425
+ *
426
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
427
+ * via the `definition` "PreparedMediaItem".
428
+ */
429
+ export interface PreparedMediaItem {
430
+ blobRef: string;
431
+ kind: ChannelMediaKind;
432
+ mime: string;
433
+ name?: string | null;
434
+ }
435
+ /**
436
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
437
+ * via the `definition` "WorkflowToolRecipeV1".
438
+ */
439
+ export interface WorkflowToolRecipeV1 {
440
+ taskQueue: string;
441
+ workflowType: string;
442
+ }
443
+ /**
444
+ * Result shape of [`WORKFLOW_TOOL_RECOVERY_QUERY`].
445
+ *
446
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
447
+ * via the `definition` "WorkflowToolRecoveryResult".
448
+ */
449
+ export interface WorkflowToolRecoveryResult {
450
+ resolutions?: {
451
+ [k: string]: PromiseResolution;
452
+ };
453
+ }
454
+ /**
455
+ * Start arguments every start-on-call plugin workflow receives. The plugin
456
+ * resolves each keyed completion promise by emitting `SourceResolution`
457
+ * bodies to the holder workflow through the fixed `deliver_emission`
458
+ * signal, using its own execution id as the producer workflow id.
459
+ *
460
+ * This interface was referenced by `LightspeedWorkflowContract`'s JSON-Schema
461
+ * via the `definition` "WorkflowToolStartArgs".
462
+ */
463
+ export interface WorkflowToolStartArgs {
464
+ execution_id: string;
465
+ holder_workflow_id: string;
466
+ invocation: WorkflowToolInvocation;
467
+ universe_id: string;
468
+ }
package/src/index.ts ADDED
@@ -0,0 +1,31 @@
1
+ export { LightspeedRpcError, LightspeedTransportError, lightspeedRpcErrorKind } from "./errors.js";
2
+ export type { LightspeedRpcErrorKind, JsonRpcErrorPayload } from "./errors.js";
3
+ export {
4
+ LightspeedClient,
5
+ generateSubmissionId,
6
+ } from "./client.js";
7
+ export type {
8
+ AwaitRunOptions,
9
+ AwaitRunResult,
10
+ CallOptions,
11
+ LightspeedClientOptions,
12
+ ReadEventsOptions,
13
+ RequestId,
14
+ RunTerminalState,
15
+ StartRunOptions,
16
+ } from "./client.js";
17
+ export {
18
+ METHODS,
19
+ METHOD_INFO,
20
+ NOTIFICATIONS,
21
+ rpc,
22
+ } from "./generated/methods.js";
23
+ export type {
24
+ Method,
25
+ MethodMap,
26
+ MethodParams,
27
+ MethodResult,
28
+ NotificationMethod,
29
+ RpcCaller,
30
+ } from "./generated/methods.js";
31
+ export type * from "./generated/types.js";