@lunora/agent 1.0.0-alpha.1 → 1.0.0-alpha.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 +2 -0
- package/dist/channels.d.mts +17 -5
- package/dist/channels.d.ts +17 -5
- package/dist/component.d.mts +14 -0
- package/dist/component.d.ts +14 -0
- package/dist/inbound.d.mts +7 -2
- package/dist/inbound.d.ts +7 -2
- package/dist/index.d.mts +136 -28
- package/dist/index.d.ts +136 -28
- package/dist/naming.d.mts +17 -4
- package/dist/naming.d.ts +17 -4
- package/dist/packem_shared/{types.d-BWG0uUtX.d.mts → types.d-BhJFTvz_.d.mts} +123 -24
- package/dist/packem_shared/{types.d-BWG0uUtX.d.ts → types.d-BhJFTvz_.d.ts} +123 -24
- package/dist/sandbox.d.mts +19 -4
- package/dist/sandbox.d.ts +19 -4
- package/dist/telemetry/index.d.mts +28 -5
- package/dist/telemetry/index.d.ts +28 -5
- package/package.json +7 -7
|
@@ -4,13 +4,20 @@ import { FlexibleSchema, LanguageModel, ModelMessage, ToolSet, ToolChoice, ToolC
|
|
|
4
4
|
* Structural mirror of the Lunora function reference (`{ __lunoraRef }`).
|
|
5
5
|
* Declared locally so the loop can mint references to the agent runtime
|
|
6
6
|
* functions by path without importing `@lunora/dispatch`.
|
|
7
|
+
* @experimental
|
|
7
8
|
*/
|
|
8
9
|
interface AgentFunctionReference {
|
|
9
10
|
__lunoraRef: string;
|
|
10
11
|
}
|
|
11
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* `ctx.run`-shaped dispatcher the loop uses to call Lunora functions.
|
|
14
|
+
* @experimental
|
|
15
|
+
*/
|
|
12
16
|
type AgentRunFunction = (reference: AgentFunctionReference, args?: Record<string, unknown>) => Promise<unknown>;
|
|
13
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Structural subset of the Cloudflare Workflows durable-step API the loop needs.
|
|
19
|
+
* @experimental
|
|
20
|
+
*/
|
|
14
21
|
interface AgentStepLike {
|
|
15
22
|
do: <T>(name: string, callback: () => Promise<T>) => Promise<T>;
|
|
16
23
|
/**
|
|
@@ -39,6 +46,7 @@ interface AgentStepLike {
|
|
|
39
46
|
* workflow replay (native step memoization) — but a step that FAILS mid-body
|
|
40
47
|
* is retried at-least-once, so a side-effecting tool (charge a card, send a
|
|
41
48
|
* mail) must dedupe on this key itself.
|
|
49
|
+
* @experimental
|
|
42
50
|
*/
|
|
43
51
|
interface AgentToolContext {
|
|
44
52
|
/** The Worker environment bindings. */
|
|
@@ -104,6 +112,7 @@ interface AgentToolContext {
|
|
|
104
112
|
* model call — the loop runs it itself inside a named durable step so a
|
|
105
113
|
* completed call never re-runs on replay, and passes the
|
|
106
114
|
* {@link AgentToolContext} alongside the input.
|
|
115
|
+
* @experimental
|
|
107
116
|
*/
|
|
108
117
|
interface AgentToolDefinition<Input = unknown, Output = unknown> {
|
|
109
118
|
/** What the tool does — shown to the model. */
|
|
@@ -130,19 +139,24 @@ interface AgentToolDefinition<Input = unknown, Output = unknown> {
|
|
|
130
139
|
*/
|
|
131
140
|
needsApproval?: ((input: Input, context: AgentToolContext) => boolean | Promise<boolean>) | boolean;
|
|
132
141
|
}
|
|
133
|
-
/**
|
|
142
|
+
/**
|
|
143
|
+
* Author-supplied tool config (see {@link AgentToolDefinition}).
|
|
144
|
+
* @experimental
|
|
145
|
+
*/
|
|
134
146
|
type AgentToolConfig<Input = unknown, Output = unknown> = Omit<AgentToolDefinition<Input, Output>, "isLunoraAgentTool">;
|
|
135
147
|
/**
|
|
136
148
|
* Generic-erased tool for tool maps. `Input` sits in both a covariant
|
|
137
149
|
* (`inputSchema`) and a contravariant (`execute`) position, so no single
|
|
138
150
|
* non-`any` instantiation admits every concrete tool — the same reason the AI
|
|
139
151
|
* SDK's `ToolSet` erases its generics.
|
|
152
|
+
* @experimental
|
|
140
153
|
*/
|
|
141
154
|
type AnyAgentTool = AgentToolDefinition<any, any>;
|
|
142
155
|
/**
|
|
143
156
|
* The model an agent runs on: a Workers AI model id (resolved via `env.AI`),
|
|
144
157
|
* a prebuilt AI SDK {@link LanguageModel}, or a thunk building one from the
|
|
145
158
|
* Worker env (for providers that need API keys off `env`).
|
|
159
|
+
* @experimental
|
|
146
160
|
*/
|
|
147
161
|
type AgentModelInput = LanguageModel | ((env: Record<string, unknown>) => LanguageModel);
|
|
148
162
|
/**
|
|
@@ -158,6 +172,7 @@ type AgentModelInput = LanguageModel | ((env: Record<string, unknown>) => Langua
|
|
|
158
172
|
* `"agentic"` skips auto-injection; the source instead mints a `searchMemory`
|
|
159
173
|
* tool the MODEL calls mid-reasoning (Recursive-LM / "read what you need") — each
|
|
160
174
|
* call a memoized durable step, so multi-hop retrieval is crash-safe for free.
|
|
175
|
+
* @experimental
|
|
161
176
|
*/
|
|
162
177
|
interface AgentMemoryOptions {
|
|
163
178
|
/**
|
|
@@ -238,12 +253,16 @@ interface AgentMemoryOptions {
|
|
|
238
253
|
* carries `knowledge` (keyed by the skill's name). The key names the durable
|
|
239
254
|
* step — the default source keeps the historic `"memory:retrieve"`, a skill
|
|
240
255
|
* source uses `"memory:retrieve:<key>"` — so replay stays deterministic.
|
|
256
|
+
* @experimental
|
|
241
257
|
*/
|
|
242
258
|
interface AgentMemorySource extends AgentMemoryOptions {
|
|
243
259
|
/** Stable source key: `"default"` for `memory`, else the contributing skill's name. */
|
|
244
260
|
key: string;
|
|
245
261
|
}
|
|
246
|
-
/**
|
|
262
|
+
/**
|
|
263
|
+
* Cumulative or per-turn token usage — AI SDK `LanguageModelUsage` field names.
|
|
264
|
+
* @experimental
|
|
265
|
+
*/
|
|
247
266
|
interface AgentUsage {
|
|
248
267
|
/** Prompt (input) tokens. */
|
|
249
268
|
inputTokens?: number;
|
|
@@ -252,7 +271,10 @@ interface AgentUsage {
|
|
|
252
271
|
/** Input + output tokens. */
|
|
253
272
|
totalTokens?: number;
|
|
254
273
|
}
|
|
255
|
-
/**
|
|
274
|
+
/**
|
|
275
|
+
* Context handed to a dynamic {@link AgentConfig.instructions} function.
|
|
276
|
+
* @experimental
|
|
277
|
+
*/
|
|
256
278
|
interface AgentInstructionsContext {
|
|
257
279
|
/** The Worker environment bindings. */
|
|
258
280
|
env: Record<string, unknown>;
|
|
@@ -268,6 +290,7 @@ interface AgentInstructionsContext {
|
|
|
268
290
|
* the SAME {@link AnyAgentTool} shape agents already use
|
|
269
291
|
* (`functionTool`/`mcpTools`/`agentAsTool`), and `knowledge` reuses the
|
|
270
292
|
* {@link AgentMemoryOptions} retrieval verbatim.
|
|
293
|
+
* @experimental
|
|
271
294
|
*/
|
|
272
295
|
interface SkillConfig {
|
|
273
296
|
/**
|
|
@@ -295,12 +318,18 @@ interface SkillConfig {
|
|
|
295
318
|
*/
|
|
296
319
|
tools?: Record<string, AnyAgentTool>;
|
|
297
320
|
}
|
|
298
|
-
/**
|
|
321
|
+
/**
|
|
322
|
+
* A `defineSkill` result — config plus the brand the agent merge checks.
|
|
323
|
+
* @experimental
|
|
324
|
+
*/
|
|
299
325
|
interface SkillDefinition extends SkillConfig {
|
|
300
326
|
/** Runtime brand check (see `isSkillDefinition`). */
|
|
301
327
|
readonly isLunoraSkill: true;
|
|
302
328
|
}
|
|
303
|
-
/**
|
|
329
|
+
/**
|
|
330
|
+
* One prior turn, as {@link AgentConfig.prepareStep} and `stopWhen` observe it.
|
|
331
|
+
* @experimental
|
|
332
|
+
*/
|
|
304
333
|
interface AgentStepInfo {
|
|
305
334
|
/** The assistant text of the turn. */
|
|
306
335
|
text: string;
|
|
@@ -313,7 +342,10 @@ interface AgentStepInfo {
|
|
|
313
342
|
/** The turn's token usage, when the model reported it. */
|
|
314
343
|
usage?: AgentUsage;
|
|
315
344
|
}
|
|
316
|
-
/**
|
|
345
|
+
/**
|
|
346
|
+
* The turn summary handed to {@link AgentConfig.onStepFinish}.
|
|
347
|
+
* @experimental
|
|
348
|
+
*/
|
|
317
349
|
interface AgentStepFinishInfo {
|
|
318
350
|
/** The assistant text produced this turn. */
|
|
319
351
|
text: string;
|
|
@@ -328,9 +360,13 @@ interface AgentStepFinishInfo {
|
|
|
328
360
|
* Called after each LLM turn with that turn's text, tool calls, and usage. Runs
|
|
329
361
|
* inside a named durable step (`agent:step-finish:<turn>`) so it fires exactly
|
|
330
362
|
* once per turn even across a workflow replay.
|
|
363
|
+
* @experimental
|
|
331
364
|
*/
|
|
332
365
|
type AgentOnStepFinish = (info: AgentStepFinishInfo) => Promise<void> | void;
|
|
333
|
-
/**
|
|
366
|
+
/**
|
|
367
|
+
* The input {@link AgentConfig.prepareStep} sees before a turn runs.
|
|
368
|
+
* @experimental
|
|
369
|
+
*/
|
|
334
370
|
interface AgentPrepareStepInput {
|
|
335
371
|
/** The messages assembled for this turn (instructions + memory + history). */
|
|
336
372
|
messages: ReadonlyArray<ModelMessage>;
|
|
@@ -343,6 +379,7 @@ interface AgentPrepareStepInput {
|
|
|
343
379
|
* Per-turn overrides {@link AgentConfig.prepareStep} may return. A returned
|
|
344
380
|
* `messages` array **replaces** the assembled history for that turn — the seam
|
|
345
381
|
* where history compaction lives.
|
|
382
|
+
* @experimental
|
|
346
383
|
*/
|
|
347
384
|
interface AgentPrepareStepResult {
|
|
348
385
|
/** Restrict the tools exposed to the model this turn (by name). */
|
|
@@ -359,11 +396,13 @@ interface AgentPrepareStepResult {
|
|
|
359
396
|
/**
|
|
360
397
|
* Adjust the next turn before it runs — mirrors AI SDK's `prepareStep`. Invoked
|
|
361
398
|
* inside the turn's durable step so its effect is memoized on replay.
|
|
399
|
+
* @experimental
|
|
362
400
|
*/
|
|
363
401
|
type AgentPrepareStep = (input: AgentPrepareStepInput) => AgentPrepareStepResult | Promise<AgentPrepareStepResult | undefined> | undefined;
|
|
364
402
|
/**
|
|
365
403
|
* The subset of {@link AgentRunInput} an {@link AgentEmailMapper} returns to
|
|
366
404
|
* start a run from an inbound email.
|
|
405
|
+
* @experimental
|
|
367
406
|
*/
|
|
368
407
|
interface AgentEmailRun {
|
|
369
408
|
/** The user message that starts (or continues) the thread — the model's prompt. */
|
|
@@ -390,13 +429,17 @@ interface AgentEmailRun {
|
|
|
390
429
|
* is dispatched with RLS bypassed. Gate on `email.authentication` (DKIM/SPF/DMARC
|
|
391
430
|
* verdicts) here before returning a run, and treat every returned field as
|
|
392
431
|
* untrusted input.
|
|
432
|
+
* @experimental
|
|
393
433
|
*/
|
|
394
434
|
type AgentEmailMapper = (email: InboundEmail) => AgentEmailRun | null | Promise<AgentEmailRun | null | undefined> | undefined;
|
|
395
435
|
/** The inbound webhook channels an agent can be triggered from — see `@lunora/agent/channels`. */
|
|
396
436
|
type AgentInboundChannelKind = "discord" | "github" | "slack";
|
|
397
437
|
/** The run-input an inbound-channel mapper returns — the same shape as {@link AgentEmailRun}. */
|
|
398
438
|
type AgentChannelRun = AgentEmailRun;
|
|
399
|
-
/**
|
|
439
|
+
/**
|
|
440
|
+
* The verified, parsed webhook event handed to an {@link AgentInboundChannel.map} mapper.
|
|
441
|
+
* @experimental
|
|
442
|
+
*/
|
|
400
443
|
interface InboundChannelEvent {
|
|
401
444
|
/** Which channel delivered it. */
|
|
402
445
|
channel: AgentInboundChannelKind;
|
|
@@ -434,6 +477,10 @@ interface AgentInboundChannel {
|
|
|
434
477
|
*/
|
|
435
478
|
secret: string | ((env: Record<string, unknown>) => string | undefined);
|
|
436
479
|
}
|
|
480
|
+
/**
|
|
481
|
+
* `AgentConfig` is part of the experimental `@lunora/agent` API and may change without a major version bump.
|
|
482
|
+
* @experimental
|
|
483
|
+
*/
|
|
437
484
|
interface AgentConfig {
|
|
438
485
|
/** Restrict the tools the model may call, by name. Default: all tools. */
|
|
439
486
|
activeTools?: ReadonlyArray<string>;
|
|
@@ -590,6 +637,7 @@ interface AgentConfig {
|
|
|
590
637
|
* and get NO Workflow tool-loop — tool calls are deferred. All fields are
|
|
591
638
|
* optional; the defaults target Workers AI (`@cf/openai/whisper-large-v3-turbo`
|
|
592
639
|
* for STT, `@cf/deepgram/aura-1` for TTS).
|
|
640
|
+
* @experimental
|
|
593
641
|
*/
|
|
594
642
|
interface AgentVoiceConfig {
|
|
595
643
|
/**
|
|
@@ -622,12 +670,18 @@ interface AgentVoiceConfig {
|
|
|
622
670
|
*/
|
|
623
671
|
tts?: string;
|
|
624
672
|
}
|
|
625
|
-
/**
|
|
673
|
+
/**
|
|
674
|
+
* The input the parent model provides when delegating to a sub-agent tool.
|
|
675
|
+
* @experimental
|
|
676
|
+
*/
|
|
626
677
|
interface AgentSubToolInput {
|
|
627
678
|
/** The task or question to hand to the sub-agent. */
|
|
628
679
|
prompt: string;
|
|
629
680
|
}
|
|
630
|
-
/**
|
|
681
|
+
/**
|
|
682
|
+
* Options for {@link AgentDefinition.asTool} (`agent.asTool(...)`).
|
|
683
|
+
* @experimental
|
|
684
|
+
*/
|
|
631
685
|
interface AgentAsToolOptions {
|
|
632
686
|
/** What the sub-agent does — shown to the parent's model (it decides from it). */
|
|
633
687
|
description: string;
|
|
@@ -647,7 +701,10 @@ interface AgentAsToolOptions {
|
|
|
647
701
|
*/
|
|
648
702
|
wait?: (ms: number) => Promise<void>;
|
|
649
703
|
}
|
|
650
|
-
/**
|
|
704
|
+
/**
|
|
705
|
+
* A `defineAgent` result — config plus the brand codegen discovers.
|
|
706
|
+
* @experimental
|
|
707
|
+
*/
|
|
651
708
|
interface AgentDefinition extends AgentConfig {
|
|
652
709
|
/**
|
|
653
710
|
* Adapt this agent into a tool a PARENT agent can call: the returned tool's
|
|
@@ -668,7 +725,10 @@ interface AgentDefinition extends AgentConfig {
|
|
|
668
725
|
*/
|
|
669
726
|
memorySources?: ReadonlyArray<AgentMemorySource>;
|
|
670
727
|
}
|
|
671
|
-
/**
|
|
728
|
+
/**
|
|
729
|
+
* Params of one agent run (the compiled workflow's payload).
|
|
730
|
+
* @experimental
|
|
731
|
+
*/
|
|
672
732
|
interface AgentRunInput {
|
|
673
733
|
/** The user message that starts (or continues) the thread. */
|
|
674
734
|
input: string;
|
|
@@ -686,7 +746,10 @@ interface AgentRunInput {
|
|
|
686
746
|
/** Optional thread title, set on first creation. */
|
|
687
747
|
title?: string;
|
|
688
748
|
}
|
|
689
|
-
/**
|
|
749
|
+
/**
|
|
750
|
+
* Output of one agent run (the compiled workflow's return value).
|
|
751
|
+
* @experimental
|
|
752
|
+
*/
|
|
690
753
|
interface AgentRunResult {
|
|
691
754
|
/** The parsed structured answer, when {@link AgentConfig.output} is set. */
|
|
692
755
|
output?: unknown;
|
|
@@ -706,6 +769,7 @@ interface AgentRunResult {
|
|
|
706
769
|
* Function paths of the agent runtime functions (the `agentComponent()`
|
|
707
770
|
* functions the app re-exports from `lunora/agents.ts`, so codegen registers
|
|
708
771
|
* them under the `agents:` namespace).
|
|
772
|
+
* @experimental
|
|
709
773
|
*/
|
|
710
774
|
interface AgentFunctionPaths {
|
|
711
775
|
appendMessage: string;
|
|
@@ -736,9 +800,13 @@ interface AgentFunctionPaths {
|
|
|
736
800
|
* placeholder written while a run pauses on a gated tool, then `"approved"` /
|
|
737
801
|
* `"rejected"` on the tool result once a client resolves it. Absent on ordinary
|
|
738
802
|
* messages. `"awaiting_approval"` rows are filtered out of the model prompt.
|
|
803
|
+
* @experimental
|
|
739
804
|
*/
|
|
740
805
|
type AgentMessageStatus = "approved" | "awaiting_approval" | "rejected";
|
|
741
|
-
/**
|
|
806
|
+
/**
|
|
807
|
+
* One persisted thread message, as the loop reads it back.
|
|
808
|
+
* @experimental
|
|
809
|
+
*/
|
|
742
810
|
interface AgentMessageRow {
|
|
743
811
|
content: string;
|
|
744
812
|
role: "assistant" | "system" | "tool" | "user";
|
|
@@ -749,13 +817,19 @@ interface AgentMessageRow {
|
|
|
749
817
|
toolCalls?: ReadonlyArray<AgentToolCall>;
|
|
750
818
|
toolName?: string;
|
|
751
819
|
}
|
|
752
|
-
/**
|
|
820
|
+
/**
|
|
821
|
+
* One model-issued tool call.
|
|
822
|
+
* @experimental
|
|
823
|
+
*/
|
|
753
824
|
interface AgentToolCall {
|
|
754
825
|
id: string;
|
|
755
826
|
input: unknown;
|
|
756
827
|
name: string;
|
|
757
828
|
}
|
|
758
|
-
/**
|
|
829
|
+
/**
|
|
830
|
+
* Normalized result of one LLM turn (the `generate` seam's return value).
|
|
831
|
+
* @experimental
|
|
832
|
+
*/
|
|
759
833
|
interface AgentGenerateResult {
|
|
760
834
|
/** The parsed structured answer, when {@link AgentConfig.output} is set. */
|
|
761
835
|
output?: unknown;
|
|
@@ -764,7 +838,10 @@ interface AgentGenerateResult {
|
|
|
764
838
|
/** Token usage the model reported for this turn. */
|
|
765
839
|
usage?: AgentUsage;
|
|
766
840
|
}
|
|
767
|
-
/**
|
|
841
|
+
/**
|
|
842
|
+
* Options passed to the {@link AgentGenerate} seam for one LLM turn.
|
|
843
|
+
* @experimental
|
|
844
|
+
*/
|
|
768
845
|
interface AgentGenerateOptions {
|
|
769
846
|
/** Restrict the tools exposed to the model this turn (by name). */
|
|
770
847
|
activeTools?: ReadonlyArray<string>;
|
|
@@ -785,6 +862,7 @@ interface AgentGenerateOptions {
|
|
|
785
862
|
/**
|
|
786
863
|
* The LLM-turn seam: given the assembled conversation, return the model's
|
|
787
864
|
* decision. Production wires AI SDK `generateText`; tests inject a script.
|
|
865
|
+
* @experimental
|
|
788
866
|
*/
|
|
789
867
|
type AgentGenerate = (options: AgentGenerateOptions) => Promise<AgentGenerateResult>;
|
|
790
868
|
/**
|
|
@@ -867,6 +945,7 @@ type AgentEpisodeExtract = (input: {
|
|
|
867
945
|
* persisted assistant message is the single source of truth). Keyed by
|
|
868
946
|
* `threadKey` + the zero-based `turn` so a client can correlate a delta to the
|
|
869
947
|
* in-flight turn.
|
|
948
|
+
* @experimental
|
|
870
949
|
*/
|
|
871
950
|
interface AgentTokenDelta {
|
|
872
951
|
/**
|
|
@@ -890,6 +969,7 @@ interface AgentTokenDelta {
|
|
|
890
969
|
* replayed. Correlated to the in-flight tool call (and its persisted tool row)
|
|
891
970
|
* by `toolCallId` rather than a turn index, since a single turn can fan out many
|
|
892
971
|
* tool calls.
|
|
972
|
+
* @experimental
|
|
893
973
|
*/
|
|
894
974
|
interface AgentProgressEvent {
|
|
895
975
|
/** The arbitrary, JSON-serializable payload the tool reported. */
|
|
@@ -907,6 +987,7 @@ interface AgentProgressEvent {
|
|
|
907
987
|
* (`toolCallId`-keyed). Both are ephemeral and never replayed — the persisted
|
|
908
988
|
* thread messages remain the single source of truth. Discriminate on `kind`
|
|
909
989
|
* (`"progress"` for the progress arm; token deltas leave it unset).
|
|
990
|
+
* @experimental
|
|
910
991
|
*/
|
|
911
992
|
type AgentLiveEvent = AgentProgressEvent | AgentTokenDelta;
|
|
912
993
|
/**
|
|
@@ -923,6 +1004,7 @@ type AgentLiveEvent = AgentProgressEvent | AgentTokenDelta;
|
|
|
923
1004
|
* of a completed turn. Consumers should therefore reset/dedupe accumulated text
|
|
924
1005
|
* per `threadKey`+`turn` boundary so a step retry cannot visually double-append;
|
|
925
1006
|
* the persisted assistant message remains the single source of truth.
|
|
1007
|
+
* @experimental
|
|
926
1008
|
*/
|
|
927
1009
|
type AgentTokenSink = (event: AgentLiveEvent) => void;
|
|
928
1010
|
/**
|
|
@@ -932,9 +1014,13 @@ type AgentTokenSink = (event: AgentLiveEvent) => void;
|
|
|
932
1014
|
* durable `llm:turn:N` step memoizes (and persists) is identical whether the
|
|
933
1015
|
* turn streamed or not. Production wires AI SDK `streamText`; tests inject a
|
|
934
1016
|
* script. Deltas are live-only — a workflow replay never re-invokes the seam.
|
|
1017
|
+
* @experimental
|
|
935
1018
|
*/
|
|
936
1019
|
type AgentStreamGenerate = (options: AgentGenerateOptions, onDelta: (text: string) => void) => Promise<AgentGenerateResult>;
|
|
937
|
-
/**
|
|
1020
|
+
/**
|
|
1021
|
+
* Spec entry codegen emits per agent: `{ binding: "AGENT_SUPPORT", exportName: "support" }`.
|
|
1022
|
+
* @experimental
|
|
1023
|
+
*/
|
|
938
1024
|
interface AgentBindingSpec {
|
|
939
1025
|
binding: string;
|
|
940
1026
|
exportName: string;
|
|
@@ -954,9 +1040,13 @@ interface AgentBindingSpec {
|
|
|
954
1040
|
* {@link AgentHandle.cancel}, and `"awaiting_input"` while the run is paused on
|
|
955
1041
|
* a human-in-the-loop tool approval. Mirrored by the `status` `v.union` in
|
|
956
1042
|
* `component.ts`.
|
|
1043
|
+
* @experimental
|
|
957
1044
|
*/
|
|
958
1045
|
type AgentThreadStatus = "awaiting_input" | "cancelled" | "error" | "idle" | "running";
|
|
959
|
-
/**
|
|
1046
|
+
/**
|
|
1047
|
+
* Structural subset of a Cloudflare Workflow instance the producer surface needs.
|
|
1048
|
+
* @experimental
|
|
1049
|
+
*/
|
|
960
1050
|
interface AgentWorkflowInstanceLike {
|
|
961
1051
|
/** Deliver an external event to the running instance (resumes a `waitForEvent`). */
|
|
962
1052
|
sendEvent: (event: {
|
|
@@ -966,7 +1056,10 @@ interface AgentWorkflowInstanceLike {
|
|
|
966
1056
|
status: () => Promise<unknown>;
|
|
967
1057
|
terminate: () => Promise<void>;
|
|
968
1058
|
}
|
|
969
|
-
/**
|
|
1059
|
+
/**
|
|
1060
|
+
* Structural subset of a Cloudflare Workflow binding the producer surface needs.
|
|
1061
|
+
* @experimental
|
|
1062
|
+
*/
|
|
970
1063
|
interface AgentWorkflowBindingLike {
|
|
971
1064
|
create: (options?: {
|
|
972
1065
|
id?: string;
|
|
@@ -976,12 +1069,18 @@ interface AgentWorkflowBindingLike {
|
|
|
976
1069
|
}>;
|
|
977
1070
|
get: (id: string) => Promise<AgentWorkflowInstanceLike>;
|
|
978
1071
|
}
|
|
979
|
-
/**
|
|
1072
|
+
/**
|
|
1073
|
+
* A started agent run (a workflow instance).
|
|
1074
|
+
* @experimental
|
|
1075
|
+
*/
|
|
980
1076
|
interface AgentRunHandle {
|
|
981
1077
|
/** The workflow instance id. */
|
|
982
1078
|
id: string;
|
|
983
1079
|
}
|
|
984
|
-
/**
|
|
1080
|
+
/**
|
|
1081
|
+
* The `ctx.agents.<name>` producer handle.
|
|
1082
|
+
* @experimental
|
|
1083
|
+
*/
|
|
985
1084
|
interface AgentHandle {
|
|
986
1085
|
/**
|
|
987
1086
|
* Cancel a run by its workflow instance id: terminate the instance and mark
|