@relayflows/surface 2.0.34 → 2.0.36

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.
@@ -0,0 +1,46 @@
1
+ /** A duration in whole milliseconds or an unambiguous wall-clock literal. */
2
+ export type ActivityDuration = number | string;
3
+ /**
4
+ * Opaque provider event preserved by the journal. Providers may add fields;
5
+ * bodies must re-read provider state instead of treating this payload as truth.
6
+ */
7
+ export interface EventFrame {
8
+ readonly type: string;
9
+ readonly payload?: unknown;
10
+ readonly [field: string]: unknown;
11
+ }
12
+ export type Wake = {
13
+ readonly kind: "events";
14
+ readonly events: readonly EventFrame[];
15
+ readonly offset: number;
16
+ } | {
17
+ readonly kind: "idle";
18
+ } | {
19
+ readonly kind: "deadline";
20
+ readonly pending: {
21
+ readonly from: number;
22
+ readonly to: number;
23
+ } | null;
24
+ } | {
25
+ readonly kind: "overflow";
26
+ readonly retained: number;
27
+ readonly bytes: number;
28
+ readonly from: number;
29
+ };
30
+ /** Bounds are required so a body-level subscription cannot keep a run open forever. */
31
+ export interface ActivityOptions {
32
+ /** Coalesce a burst until this long after its most recent frame. Defaults to zero. */
33
+ readonly settle?: ActivityDuration;
34
+ /** Per wake: return idle after this long without a buffered matching frame. */
35
+ readonly idle: ActivityDuration;
36
+ /** Absolute cap fixed when the subscription is opened. */
37
+ readonly deadline: ActivityDuration;
38
+ /** Include events caused by the run identity. Defaults to false. */
39
+ readonly includeSelf?: boolean;
40
+ }
41
+ /** A durable, bounded cursor over matching provider events. */
42
+ export interface Activity {
43
+ next(): Promise<Wake>;
44
+ close(): Promise<void>;
45
+ }
46
+ //# sourceMappingURL=activity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activity.d.ts","sourceRoot":"","sources":["../src/activity.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,CAAC;AAE/C;;;GAGG;AACH,MAAM,WAAW,U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 -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=activity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activity.js","sourceRoot":"","sources":["../src/activity.ts"],"names":[],"mappings":""}
package/dist/context.d.ts CHANGED
@@ -3,6 +3,8 @@ import type { MemoryHelper } from "./memory.js";
3
3
  import type { CloudCapabilities, CloudHelper } from "./cloud.js";
4
4
  import type { FlowCompletionReason } from "./completion.js";
5
5
  import type { Step } from "./step.js";
6
+ import type { Activity, ActivityOptions } from "./activity.js";
7
+ import type { TriggerSource } from "./triggers.js";
6
8
  export interface AgentResult {
7
9
  summary: string;
8
10
  /**
@@ -94,6 +96,15 @@ export interface LlmOptions {
94
96
  cli?: string;
95
97
  model?: string;
96
98
  }
99
+ /** Durable receipt returned after a statically declared child flow succeeds. */
100
+ export interface DispatchResult {
101
+ /** The child flow's declared name. */
102
+ name: string;
103
+ /** `success`; every other child verdict rejects the dispatch. */
104
+ completionReason: 'success';
105
+ /** The child's journaled completion detail, when it supplied one. */
106
+ completionDetail?: string;
107
+ }
97
108
  /** The optional second argument to {@link Ctx.done}. */
98
109
  export interface DoneOptions {
99
110
  /** Why the flow reached this verdict; redacted, bounded, and journaled. */
@@ -133,6 +144,8 @@ export interface Ctx extends Helpers {
133
144
  /** JSON Schema validates the value at runtime; narrow unknown in author code. */
134
145
  llm(prompt: string, options: LlmOptions): Step<unknown>;
135
146
  agent(name: string, options: AgentOptions): Step<AgentResult>;
147
+ /** Open a durable, bounded event subscription for this running body. */
148
+ on(source: TriggerSource, options: ActivityOptions): Activity;
136
149
  /**
137
150
  * Ask a person a yes/no question and park until they answer. The run
138
151
  * parks durably (kernel `wait.human`); `flows answer <run> <wait> yes|no`
@@ -143,7 +156,12 @@ export interface Ctx extends Helpers {
143
156
  human(question: string, options: {
144
157
  to: string;
145
158
  }): Step<boolean>;
146
- dispatch<T>(flow: string, input: unknown): Promise<T>;
159
+ /**
160
+ * Run a direct child declared in this flow's `use` header. The child shares
161
+ * this durable root, budget, worker capacity and Cloud graph; arbitrary
162
+ * paths and undeclared flow names are refused before the child body runs.
163
+ */
164
+ dispatch(flow: string, input: unknown): Step<DispatchResult>;
147
165
  /**
148
166
  * Run every installed implementation of a named hook in lock order and
149
167
  * AND-compose the booleans. With no implementations this is a journaled
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,YAAY,CAAC,EAAE,UAAU,GAAG,WAAW,CAAC;CACzC;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0EAA0E;IAC1E,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;;;;;;;OAYG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,SAAS,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;CAChC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS;I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udHelper, CloudCapabilities, CloudBabysitterTurnCapability, CloudBabysitterTurnDelivery, CloudBabysitterTurnReceipt, } from "./cloud.js";
2
- export type { AgentOptions, AgentResult, DoneOptions, PermissionsSpec, LlmOptions, RunOptions, RunResult, Ctx } from "./context.js";
2
+ export type { AgentOptions, AgentResult, DispatchResult, DoneOptions, PermissionsSpec, LlmOptions, RunOptions, RunResult, Ctx } from "./context.js";
3
+ export type { Activity, ActivityDuration, ActivityOptions, EventFrame, Wake } from "./activity.js";
3
4
  export { COMPLETION_DETAIL_MAX_CODE_POINTS, COMPLETION_REASONS, RUN_COMPLETION_REASONS, FLOW_COMPLETION_REASONS, type CompletionReason, type RunCompletionReason, type FlowCompletionReason, } from "./completion.js";
4
5
  export type { Step, NamedGate, ReferencesInputNamedGate, SubprocessNamedGate, WordCountBoundsNamedGate, RegexMatchNamedGate, } from "./step.js";
5
6
  export { flow, type FlowHandle, type TriggeredFlowHandle, type FlowHeader, } from "./flow.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,iBAAiB,EACjB,SAAS,EACT,WAAW,EACX,UAAU,EACV,aAAa,EACb,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,6BAA6B,EAC7B,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACpI,OAAO,EACL,iCAAiC,EACjC,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,GAC1B,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,IAAI,EACJ,SAAS,EACT,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,EACxB,mBA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qB,EAAE,MAAM,uBAAuB,CAAC;AACnE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,iCAAiC,EACjC,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,GAIxB,MAAM,iBAAiB,CAAC;AASzB,OAAO,EACL,IAAI,GAIL,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,2BAA2B,GAO5B,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,OAAO,EAAwF,MAAM,eAAe,CAAC;AAC9H,OAAO,EACL,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,mBAAmB,EAAE,YAAY,EAAE,SAAS,GAE3F,MAAM,eAAe,CAAC;AACvB,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,iCAAiC,EACjC,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,GAIxB,MAAM,iBAAiB,CAAC;AASzB,OAAO,EACL,IAAI,GAIL,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,2BAA2B,GAO5B,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,OAAO,EAAwF,MAAM,eAAe,CAAC;AAC9H,OAAO,EACL,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,mBAAmB,EAAE,YAAY,EAAE,SAAS,GAE3F,MAAM,eAAe,CAAC;AACvB,cAAc,qBAAqB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@relayflows/surface",
3
- "version": "2.0.34",
3
+ "version": "2.0.36",
4
4
  "description": "TypeScript authoring surface for Relayflows.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -0,0 +1,36 @@
1
+ /** A duration in whole milliseconds or an unambiguous wall-clock literal. */
2
+ export type ActivityDuration = number | string;
3
+
4
+ /**
5
+ * Opaque provider event preserved by the journal. Providers may add fields;
6
+ * bodies must re-read provider state instead of treating this payload as truth.
7
+ */
8
+ export interface EventFrame {
9
+ readonly type: string;
10
+ readonly payload?: unknown;
11
+ readonly [field: string]: unknown;
12
+ }
13
+
14
+ export type Wake =
15
+ | { readonly kind: "events"; readonly events: readonly EventFrame[]; readonly offset: number }
16
+ | { readonly kind: "idle" }
17
+ | { readonly kind: "deadline"; readonly pending: { readonly from: number; readonly to: number } | null }
18
+ | { readonly kind: "overflow"; readonly retained: number; readonly bytes: number; readonly from: number };
19
+
20
+ /** Bounds are required so a body-level subscription cannot keep a run open forever. */
21
+ export interface ActivityOptions {
22
+ /** Coalesce a burst until this long after its most recent frame. Defaults to zero. */
23
+ readonly settle?: ActivityDuration;
24
+ /** Per wake: return idle after this long without a buffered matching frame. */
25
+ readonly idle: ActivityDuration;
26
+ /** Absolute cap fixed when the subscription is opened. */
27
+ readonly deadline: ActivityDuration;
28
+ /** Include events caused by the run identity. Defaults to false. */
29
+ readonly includeSelf?: boolean;
30
+ }
31
+
32
+ /** A durable, bounded cursor over matching provider events. */
33
+ export interface Activity {
34
+ next(): Promise<Wake>;
35
+ close(): Promise<void>;
36
+ }
package/src/context.ts CHANGED
@@ -3,6 +3,8 @@ import type { MemoryHelper } from "./memory.js";
3
3
  import type { CloudCapabilities, CloudHelper } from "./cloud.js";
4
4
  import type { FlowCompletionReason } from "./completion.js";
5
5
  import type { Step } from "./step.js";
6
+ import type { Activity, ActivityOptions } from "./activity.js";
7
+ import type { TriggerSource } from "./triggers.js";
6
8
 
7
9
  export interface AgentResult {
8
10
  summary: string;
@@ -101,6 +103,16 @@ export interface LlmOptions {
101
103
  model?: string;
102
104
  }
103
105
 
106
+ /** Durable receipt returned after a statically declared child flow succeeds. */
107
+ export interface DispatchResult {
108
+ /** The child flow's declared name. */
109
+ name: string;
110
+ /** `success`; every other child verdict rejects the dispatch. */
111
+ completionReason: 'success';
112
+ /** The child's journaled completion detail, when it supplied one. */
113
+ completionDetail?: string;
114
+ }
115
+
104
116
  /** The optional second argument to {@link Ctx.done}. */
105
117
  export interface DoneOptions {
106
118
  /** Why the flow reached this verdict; redacted, bounded, and journaled. */
@@ -135,6 +147,8 @@ export interface Ctx extends Helpers {
135
147
  /** JSON Schema validates the value at runtime; narrow unknown in author code. */
136
148
  llm(prompt: string, options: LlmOptions): Step<unknown>;
137
149
  agent(name: string, options: AgentOptions): Step<AgentResult>;
150
+ /** Open a durable, bounded event subscription for this running body. */
151
+ on(source: TriggerSource, options: ActivityOptions): Activity;
138
152
  /**
139
153
  * Ask a person a yes/no question and park until they answer. The run
140
154
  * parks durably (kernel `wait.human`); `flows answer <run> <wait> yes|no`
@@ -143,7 +157,12 @@ export interface Ctx extends Helpers {
143
157
  * recorded with the question; it is not a delivery address.
144
158
  */
145
159
  human(question: string, options: { to: string }): Step<boolean>;
146
- dispatch<T>(flow: string, input: unknown): Promise<T>;
160
+ /**
161
+ * Run a direct child declared in this flow's `use` header. The child shares
162
+ * this durable root, budget, worker capacity and Cloud graph; arbitrary
163
+ * paths and undeclared flow names are refused before the child body runs.
164
+ */
165
+ dispatch(flow: string, input: unknown): Step<DispatchResult>;
147
166
  /**
148
167
  * Run every installed implementation of a named hook in lock order and
149
168
  * AND-compose the booleans. With no implementations this is a journaled
package/src/index.ts CHANGED
@@ -11,7 +11,8 @@ export type {
11
11
  CloudBabysitterTurnDelivery,
12
12
  CloudBabysitterTurnReceipt,
13
13
  } from "./cloud.js";
14
- export type { AgentOptions, AgentResult, DoneOptions, PermissionsSpec, LlmOptions, RunOptions, RunResult, Ctx } from "./context.js";
14
+ export type { AgentOptions, AgentResult, DispatchResult, DoneOptions, PermissionsSpec, LlmOptions, RunOptions, RunResult, Ctx } from "./context.js";
15
+ export type { Activity, ActivityDuration, ActivityOptions, EventFrame, Wake } from "./activity.js";
15
16
  export {
16
17
  COMPLETION_DETAIL_MAX_CODE_POINTS,
17
18
  COMPLETION_REASONS,