@relayflows/surface 2.0.35 → 2.0.37
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/dist/activity.d.ts +46 -0
- package/dist/activity.d.ts.map +1 -0
- package/dist/activity.js +2 -0
- package/dist/activity.js.map +1 -0
- package/dist/context.d.ts +4 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/activity.ts +36 -0
- package/src/context.ts +4 -0
- package/src/index.ts +1 -0
|
@@ -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,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CACnC;AAED,MAAM,MAAM,IAAI,GACZ;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC5F;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;CAAE,GACtG;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5G,uFAAuF;AACvF,MAAM,WAAW,eAAe;IAC9B,sFAAsF;IACtF,QAAQ,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAAC;IACnC,+EAA+E;IAC/E,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,0DAA0D;IAC1D,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,oEAAoE;IACpE,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,+DAA+D;AAC/D,MAAM,WAAW,QAAQ;IACvB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
|
package/dist/activity.js
ADDED
|
@@ -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
|
/**
|
|
@@ -142,6 +144,8 @@ export interface Ctx extends Helpers {
|
|
|
142
144
|
/** JSON Schema validates the value at runtime; narrow unknown in author code. */
|
|
143
145
|
llm(prompt: string, options: LlmOptions): Step<unknown>;
|
|
144
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;
|
|
145
149
|
/**
|
|
146
150
|
* Ask a person a yes/no question and park until they answer. The run
|
|
147
151
|
* parks durably (kernel `wait.human`); `flows answer <run> <wait> yes|no`
|
package/dist/context.d.ts.map
CHANGED
|
@@ -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;
|
|
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;AACtC,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,MA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,CAAC,WAAW,CAAC,CAAC;IAC9D,wEAAwE;IACxE,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,GAAG,QAAQ,CAAC;IAC9D;;;;;;OAMG;IACH,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IAChE;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC;IAC7D;;;;OAIG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IAClD;;;;;;;;;;;;;OAaG;IACH,IAAI,CAAC,MAAM,EAAE,oBAAoB,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAChE,KAAK,EAAE,WAAW,CAAC;IACnB,MAAM,EAAE,YAAY,CAAC;CACtB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type { EnrollmentReceipt, Heartbeat, JournalStep, RunJournal, ScheduleState, WorkerSummary, CloudHelper, CloudCapabilities, CloudBabysitterTurnCapability, CloudBabysitterTurnDelivery, CloudBabysitterTurnReceipt, } from "./cloud.js";
|
|
2
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";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACpJ,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,mBAAmB,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,IAAI,EACJ,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,UAAU,GAChB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,2BAA2B,EAC3B,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa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,WAAW,CAAC;AACnB,OAAO,EACL,IAAI,EACJ,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,UAAU,GAChB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,2BAA2B,EAC3B,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnH,OAAO,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,oBAAoB,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAC9H,OAAO,EACL,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,mBAAmB,EAAE,YAAY,EAAE,SAAS,EAC1F,KAAK,qBAAqB,EAAE,KAAK,mBAAmB,EAAE,KAAK,UAAU,EAAE,KAAK,QAAQ,GACrF,MAAM,eAAe,CAAC;AACvB,cAAc,qBAAqB,CAAC;AACpC,YAAY,EAAE,qBAAqB,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":"
|
|
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
package/src/activity.ts
ADDED
|
@@ -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;
|
|
@@ -145,6 +147,8 @@ export interface Ctx extends Helpers {
|
|
|
145
147
|
/** JSON Schema validates the value at runtime; narrow unknown in author code. */
|
|
146
148
|
llm(prompt: string, options: LlmOptions): Step<unknown>;
|
|
147
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;
|
|
148
152
|
/**
|
|
149
153
|
* Ask a person a yes/no question and park until they answer. The run
|
|
150
154
|
* parks durably (kernel `wait.human`); `flows answer <run> <wait> yes|no`
|
package/src/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ export type {
|
|
|
12
12
|
CloudBabysitterTurnReceipt,
|
|
13
13
|
} from "./cloud.js";
|
|
14
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,
|