eve 0.39.2 → 0.40.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/CHANGELOG.md +24 -1
- package/dist/src/channel/delivery-metadata.js +1 -1
- package/dist/src/cli/commands/registry.js +1 -1
- package/dist/src/cli/dev/tui/tool-presentation.js +1 -1
- package/dist/src/cli/run.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +6 -6
- package/dist/src/compiled/@workflow/core/create-hook.d.ts +9 -5
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/private.d.ts +31 -12
- package/dist/src/compiled/@workflow/core/private.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +27 -0
- package/dist/src/compiled/@workflow/core/runtime/quickjs-entrypoint.d.ts +2 -0
- package/dist/src/compiled/@workflow/core/runtime/step-executor.d.ts +49 -1
- package/dist/src/compiled/@workflow/core/runtime/step-latency.d.ts +6 -0
- package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +81 -1
- package/dist/src/compiled/@workflow/core/runtime.js +3 -3
- package/dist/src/compiled/@workflow/core/serialization.d.ts +10 -2
- package/dist/src/compiled/@workflow/core/telemetry.d.ts +6 -0
- package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/world/env-config.d.ts +10 -0
- package/dist/src/compiled/@workflow/world/events.d.ts +96 -0
- package/dist/src/compiled/@workflow/world/index.d.ts +2 -1
- package/dist/src/compiled/@workflow/world/interfaces.d.ts +38 -1
- package/dist/src/compiled/@workflow/world/node-http-flag.d.ts +41 -0
- package/dist/src/compiled/@workflow/world/node-http.d.ts +81 -0
- package/dist/src/compiled/@workflow/world-local/index.js +5 -5
- package/dist/src/compiled/@workflow/world-vercel/index.js +12 -12
- package/dist/src/compiled/_chunks/workflow/{attribute-changes-B8K0pwpH.js → attribute-changes-DXbpwBdw.js} +2 -2
- package/dist/src/compiled/_chunks/workflow/{dist-BRGbNjhD.js → dist-Dk0aQqFO.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{env-config-DxamfI7T.js → env-config-L94XftKz.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/frames-Dl2Hcma4.js +3 -0
- package/dist/src/compiled/_chunks/workflow/{private-z_2Kcwee.js → private-CuQ4HTFC.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/resume-hook-E-Nkx8q_.js +1 -0
- package/dist/src/compiled/_chunks/workflow/run-cIeex2KF.js +1 -0
- package/dist/src/compiled/_chunks/workflow/sleep-CxFsdxB_.js +1 -0
- package/dist/src/compiled/_chunks/workflow/undici-DznrXKcM.js +95 -0
- package/dist/src/compiled/_chunks/workflow/wait-until-BZHmJCAW.js +15 -0
- package/dist/src/compiled/_chunks/workflow/{ws-transport-TYZ9zwoZ.js → ws-transport-Ct6yyRWZ.js} +1 -1
- package/dist/src/compiled/shadcn-registry/index.d.ts +1 -0
- package/dist/src/compiled/shadcn-registry/index.js +285 -379
- package/dist/src/compiler/extension-compatibility.d.ts +2 -2
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/execution/parked-delivery-wait.js +1 -1
- package/dist/src/execution/proxied-deliver-step.js +1 -1
- package/dist/src/execution/report-dropped-wire-payload-step.d.ts +13 -0
- package/dist/src/execution/report-dropped-wire-payload-step.js +1 -0
- package/dist/src/execution/sandbox/bindings/just-bash-runtime.js +1 -1
- package/dist/src/execution/sandbox/logging-session.js +1 -1
- package/dist/src/execution/session-command-inbox.d.ts +3 -5
- package/dist/src/execution/session-command-inbox.js +1 -1
- package/dist/src/execution/session-timeout-steps.js +1 -1
- package/dist/src/execution/tasks/child/steps.d.ts +1 -0
- package/dist/src/execution/tasks/child/steps.js +1 -1
- package/dist/src/execution/tasks/parent/control-shared.d.ts +1 -1
- package/dist/src/execution/tasks/parent/dispatch-task-step.d.ts +1 -1
- package/dist/src/execution/tasks/parent/dispatch.js +1 -1
- package/dist/src/execution/turn-control-receiver.js +1 -1
- package/dist/src/execution/wire/session-inbox-contract.d.ts +24 -0
- package/dist/src/execution/wire/session-inbox-contract.js +1 -0
- package/dist/src/execution/wire/session-inbox-encoder.d.ts +23 -0
- package/dist/src/execution/wire/session-inbox-encoder.js +1 -0
- package/dist/src/execution/wire/session-inbox-resume.d.ts +10 -0
- package/dist/src/execution/wire/session-inbox-resume.js +1 -0
- package/dist/src/execution/wire/session-inbox-wire.d.ts +29 -0
- package/dist/src/execution/wire/session-inbox-wire.js +1 -0
- package/dist/src/execution/wire/session-inbox-wire.v0.d.ts +5 -0
- package/dist/src/execution/wire/session-inbox-wire.v0.js +1 -0
- package/dist/src/execution/wire/session-inbox-wire.v1.d.ts +237 -0
- package/dist/src/execution/wire/session-inbox-wire.v1.js +1 -0
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/harness/execute-tool.d.ts +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-module-loader.js +3 -3
- package/dist/src/internal/nitro/host/extension-external-dependency-plugin.js +1 -1
- package/dist/src/public/channels/eve.js +1 -1
- package/dist/src/public/channels/slack/slackChannel.d.ts +3 -1
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/definitions/channel.d.ts +2 -0
- package/dist/src/public/definitions/channel.js +1 -1
- package/dist/src/public/sandbox/just-bash-sandbox.d.ts +2 -0
- package/dist/src/runtime/actions/types.js +1 -1
- package/dist/src/runtime/framework-tools/tasks.d.ts +1 -5
- package/dist/src/runtime/framework-tools/tasks.js +1 -1
- package/dist/src/runtime/prompt/compose.js +1 -1
- package/dist/src/runtime/session-callback-route.js +1 -1
- package/dist/src/runtime/task-input-response-route.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/shared/empty-delivery.d.ts +1 -1
- package/dist/src/shared/empty-delivery.js +1 -1
- package/docs/meta.json +2 -1
- package/package.json +7 -6
- package/dist/src/compiled/_chunks/workflow/frames-DoexhtxJ.js +0 -3
- package/dist/src/compiled/_chunks/workflow/resume-hook-DO_MuJlY.js +0 -1
- package/dist/src/compiled/_chunks/workflow/run-lq7-eG0l.js +0 -1
- package/dist/src/compiled/_chunks/workflow/sleep-7TgF3i-e.js +0 -1
- package/dist/src/compiled/_chunks/workflow/undici-BBG5cZTy.js +0 -95
- package/dist/src/compiled/_chunks/workflow/wait-until-BPSgt1Wg.js +0 -15
- package/dist/src/execution/session-command-wire.d.ts +0 -24
- package/dist/src/execution/session-command-wire.js +0 -1
|
@@ -84,8 +84,16 @@ export declare const FRAMED_STREAM_MAX_TOTAL_RECONNECTS = 1000;
|
|
|
84
84
|
* bytes buffered before the cut are discarded — the server will resend the
|
|
85
85
|
* in-flight chunk in full from the new startIndex.
|
|
86
86
|
*
|
|
87
|
-
* A clean upstream close (EOF with no error)
|
|
88
|
-
*
|
|
87
|
+
* A clean upstream close (EOF with no error) is NOT trusted as completion
|
|
88
|
+
* on its own: some transport paths normalize a mid-stream abort into a
|
|
89
|
+
* graceful end (observed in production on Vercel response streaming, where
|
|
90
|
+
* the server's max-duration abort arrives at the client as a clean EOF).
|
|
91
|
+
* On EOF the wrapper verifies against the stream's authoritative metadata
|
|
92
|
+
* (`streams.getInfo`) that the stream is complete AND that every chunk up to
|
|
93
|
+
* `done` was delivered; otherwise it reconnects from the next chunk exactly
|
|
94
|
+
* like an errored connection. If the metadata read itself fails, the EOF is
|
|
95
|
+
* trusted (legacy behavior) rather than failing a read that may well be
|
|
96
|
+
* complete.
|
|
89
97
|
*
|
|
90
98
|
* Negative `startIndex` values (last-N semantics) skip the reconnect
|
|
91
99
|
* machinery because we cannot compute an absolute resume position without
|
|
@@ -81,6 +81,12 @@ export declare function trace<T>(spanName: string, ...args: [fn: (span?: Span) =
|
|
|
81
81
|
* callback. No-op when OpenTelemetry is not available.
|
|
82
82
|
*/
|
|
83
83
|
export declare function recordElapsedSpan(spanName: string, startEpochMs: number, opts?: SpanOptions): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Records the same user-code interval as the inner `step.execute` span. The
|
|
86
|
+
* configured OpenTelemetry meter provider attaches resource dimensions such as
|
|
87
|
+
* service.name, so this avoids accepting a caller-controlled service tag.
|
|
88
|
+
*/
|
|
89
|
+
export declare function recordStepExecutionDuration(durationMs: number, status: 'ok' | 'error'): Promise<void>;
|
|
84
90
|
/**
|
|
85
91
|
* Applies the workflow suspension algebraic effect to an active span.
|
|
86
92
|
*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "5.0.0-beta.
|
|
1
|
+
export declare const version = "5.0.0-beta.43";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Qn as e,Zn as t,br as n,pr as r,vr as i,yr as a}from"../../_chunks/workflow/wait-until-BZHmJCAW.js";import{i as o,u as s}from"../../_chunks/workflow/dist-CqvWKNQv.js";import"../../_chunks/workflow/dist-DpYyXbJv.js";import{i as c}from"../../_chunks/workflow/workflow-routes-CwqB063q.js";import{c as l,i as u,o as d,r as f,t as p}from"../../_chunks/workflow/attribute-changes-DXbpwBdw.js";import{t as m}from"../../_chunks/workflow/sleep-CxFsdxB_.js";import{t as h}from"../../_chunks/workflow/run-cIeex2KF.js";e(t,h);function g(e){let t=globalThis[i];return t||u(`createHook()`,`https://workflow-sdk.dev/docs/api-reference/workflow/create-hook`,g),t(e)}function _(e){let{respondWith:t,token:n,...r}=e??{};if(n!==void 0)throw Error("`createWebhook()` does not accept a `token` option. Webhook tokens are always generated for you. Use `createHook()` with `resumeHook()` for deterministic token patterns.");let i;t!==void 0&&(i={respondWith:t});let a=g({...r,metadata:i,isWebhook:!0}),{url:o}=l();return a.url=c(o,{type:`webhook`,token:a.token}),a}function v(){function e(t,n){d(`defineHook().resume()`,`https://workflow-sdk.dev/docs/api-reference/workflow-api/resume-hook`,e)}return{create(e){return g(e)},resume:e}}async function y(e,t={}){let r=p(e,t);if(r.length===0)return;let i=t.allowReservedAttributes===!0,a=globalThis[n];if(!a)throw new o("setAttributes() called outside a workflow runtime context. It must be called from within a workflow body (`use workflow`).");await a(r,i?{allowReservedAttributes:!0}:{})}function b(e={}){let{namespace:t}=e,n=globalThis[a](t);return Object.create(globalThis.WritableStream.prototype,{[r]:{value:n,writable:!1}})}function x(){f(`getStepMetadata()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-step-metadata`,x)}function S(){d(`resumeHook()`,`https://workflow-sdk.dev/docs/api-reference/workflow-api/resume-hook`,S)}export{o as FatalError,s as RetryableError,g as createHook,_ as createWebhook,v as defineHook,x as getStepMetadata,l as getWorkflowMetadata,b as getWritable,S as resumeHook,y as setAttributes,m as sleep};
|
|
@@ -29,6 +29,16 @@ export interface EnvNumberOptions {
|
|
|
29
29
|
* `[min, max]` when provided.
|
|
30
30
|
*/
|
|
31
31
|
export declare function envNumber(name: string, fallback: number, options?: EnvNumberOptions): number;
|
|
32
|
+
/**
|
|
33
|
+
* Resolve a boolean feature flag from `process.env[name]`.
|
|
34
|
+
*
|
|
35
|
+
* Matches the convention the runtime flags already use (`WORKFLOW_TURBO`,
|
|
36
|
+
* `WORKFLOW_SLOT_IDENTITY`, …): unset or empty takes `fallback`, and the only
|
|
37
|
+
* values that force a side are `0` / `false` and `1` / `true`
|
|
38
|
+
* (case-insensitive). Anything else falls back rather than throwing — a flag is
|
|
39
|
+
* an escape hatch, not a hard requirement — and warns once per process.
|
|
40
|
+
*/
|
|
41
|
+
export declare function envFlag(name: string, fallback: boolean, env?: Record<string, string | undefined>): boolean;
|
|
32
42
|
export declare function getMaxEventsPerRun(): number;
|
|
33
43
|
/**
|
|
34
44
|
* Reset the warn-once cache. Test-only — exported so unit tests can exercise
|
|
@@ -876,6 +876,102 @@ export type EventResult<T extends EventType = EventType> = {
|
|
|
876
876
|
} : T extends 'step_started' ? {
|
|
877
877
|
step: StartedStep;
|
|
878
878
|
} : unknown);
|
|
879
|
+
/**
|
|
880
|
+
* One event of a batch write ({@link Storage.events.createBatch}), in request
|
|
881
|
+
* order — which is the order the events land in the run's log.
|
|
882
|
+
*/
|
|
883
|
+
export interface BatchEventRequest {
|
|
884
|
+
/** The event, same discriminated union the single `create` takes. */
|
|
885
|
+
event: CreateEventRequest;
|
|
886
|
+
/**
|
|
887
|
+
* Client event time for this event. Under slot identity this is the source
|
|
888
|
+
* of the durable event's `createdAt` (a slot id carries no time), so the
|
|
889
|
+
* timestamp a replay observes is the one the writer chose — set it to the
|
|
890
|
+
* instant the event logically occurred.
|
|
891
|
+
*/
|
|
892
|
+
occurredAt?: Date;
|
|
893
|
+
/**
|
|
894
|
+
* Compute-instance attribution for this event, same as the single create's
|
|
895
|
+
* {@link CreateEventParams.computeInstanceId}. Set on the `step_started`
|
|
896
|
+
* half of a pre-claimed inline pair so a batched claim attributes the
|
|
897
|
+
* executing instance exactly like the lazy claim it replaces.
|
|
898
|
+
*/
|
|
899
|
+
computeInstanceId?: string;
|
|
900
|
+
}
|
|
901
|
+
/** Per-batch parameters for {@link Storage.events.createBatch}. */
|
|
902
|
+
export interface CreateEventBatchParams {
|
|
903
|
+
resolveData?: ResolveData;
|
|
904
|
+
/**
|
|
905
|
+
* Request id for per-write attribution, same as the single create's
|
|
906
|
+
* {@link CreateEventParams.requestId}: stamped on every event in the batch
|
|
907
|
+
* so a batched write's usage facts and telemetry carry the same request
|
|
908
|
+
* attribution its single-path twin would.
|
|
909
|
+
*/
|
|
910
|
+
requestId?: string;
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* One event's outcome in a batch response, index-aligned with the submitted
|
|
914
|
+
* events. `error === undefined` discriminates success.
|
|
915
|
+
*
|
|
916
|
+
* A batch is processed as a whole (HTTP 200 whenever the World evaluated it);
|
|
917
|
+
* each event reports the outcome its OWN single `create` would have had:
|
|
918
|
+
*
|
|
919
|
+
* - success → `status: 200` plus the committed event and the same
|
|
920
|
+
* materialized entity the single create returns (`step` for step events,
|
|
921
|
+
* `wait` for wait events, `run` for run terminals);
|
|
922
|
+
* - rejection → the status code and error code the single create would have
|
|
923
|
+
* failed with, so callers reuse their single-path conflict handling per
|
|
924
|
+
* event. A `409`/`conflict` means the entity was not in the prior state
|
|
925
|
+
* the event requires — most commonly because an earlier delivery already
|
|
926
|
+
* applied the same event, but possibly because the entity reached a
|
|
927
|
+
* DIFFERENT state (e.g. `step_completed` conflicting because the step
|
|
928
|
+
* failed). A 409 alone does not prove the equivalent effect was applied;
|
|
929
|
+
* a caller that needs effect-equivalence consults the entity (returned on
|
|
930
|
+
* sibling successes, or reloaded).
|
|
931
|
+
*
|
|
932
|
+
* The batch is atomic per attempt, not all-or-nothing across the submitted
|
|
933
|
+
* set: a World may drop rejected events and commit the survivors, so a batch
|
|
934
|
+
* can return a mix of 200s and 409s from one call.
|
|
935
|
+
*
|
|
936
|
+
* Retry semantics: a transport retry of a committed batch converges to
|
|
937
|
+
* per-event 409s ONLY for entity-conditioned events — creates and terminal
|
|
938
|
+
* transitions. A standalone bare `step_started` or a `step_retrying`
|
|
939
|
+
* re-patches its step on every attempt and does NOT converge, and
|
|
940
|
+
* `hook_received` appends a new row per attempt — `world-vercel` rejects
|
|
941
|
+
* `hook_received` in a batch outright and only auto-retries batches whose
|
|
942
|
+
* every event is retry-convergent.
|
|
943
|
+
*
|
|
944
|
+
* The born-running `step_created`+`step_started` pair converges (the pair's
|
|
945
|
+
* create fences it) but is still excluded from auto-retry, because
|
|
946
|
+
* convergence alone is not enough for the caller: a pair 409 means "this step
|
|
947
|
+
* already exists", and on a retry that is indistinguishable from "my own
|
|
948
|
+
* previous attempt committed it". A caller that reads the 409 as a lost claim
|
|
949
|
+
* would skip a body it actually owns, so a batch carrying a `step_started`
|
|
950
|
+
* runs single-attempt and leaves transient-failure recovery to queue
|
|
951
|
+
* redelivery.
|
|
952
|
+
*/
|
|
953
|
+
export type BatchEventItemResult = {
|
|
954
|
+
status: 200;
|
|
955
|
+
error?: undefined;
|
|
956
|
+
message?: undefined;
|
|
957
|
+
event: Event;
|
|
958
|
+
run?: WorkflowRun;
|
|
959
|
+
step?: Step;
|
|
960
|
+
wait?: Wait;
|
|
961
|
+
} | {
|
|
962
|
+
status: number;
|
|
963
|
+
error: string;
|
|
964
|
+
message: string;
|
|
965
|
+
event?: undefined;
|
|
966
|
+
run?: undefined;
|
|
967
|
+
step?: undefined;
|
|
968
|
+
wait?: undefined;
|
|
969
|
+
};
|
|
970
|
+
/** Result of {@link Storage.events.createBatch}. */
|
|
971
|
+
export interface EventBatchResult {
|
|
972
|
+
/** One entry per submitted event, in request order. */
|
|
973
|
+
results: BatchEventItemResult[];
|
|
974
|
+
}
|
|
879
975
|
export interface GetEventParams {
|
|
880
976
|
resolveData?: ResolveData;
|
|
881
977
|
}
|
|
@@ -2,12 +2,13 @@ export type * from './analytics.js';
|
|
|
2
2
|
export { ANALYTICS_EVENTS_GET_MANY_LIMIT, AnalyticsAttributeKeySchema, AnalyticsEventSchema, AnalyticsHookSchema, AnalyticsRunSchema, AnalyticsStepSchema, AnalyticsWaitSchema, } from './analytics.js';
|
|
3
3
|
export type * from './attributes.js';
|
|
4
4
|
export { ATTRIBUTE_KEY_MAX_LENGTH, ATTRIBUTE_MAX_PER_RUN, ATTRIBUTE_VALUE_MAX_BYTES, AttributeChangeSchema, AttributeChangesSchema, AttributeValidationError, applyAttributeChanges, PARENT_RUN_ID_ATTRIBUTE, RESERVED_ATTRIBUTE_KEY_PREFIX, ROOT_RUN_ID_ATTRIBUTE, validateAttributeChanges, validateAttributeKey, validateAttributeValue, } from './attributes.js';
|
|
5
|
-
export { _resetEnvWarnCacheForTests, type EnvNumberOptions, envNumber, getMaxEventsPerRun, } from './env-config.js';
|
|
5
|
+
export { _resetEnvWarnCacheForTests, type EnvNumberOptions, envFlag, envNumber, getMaxEventsPerRun, } from './env-config.js';
|
|
6
6
|
export type * from './events.js';
|
|
7
7
|
export { BaseEventSchema, CHILD_ENTITY_CREATION_EVENT_TYPES, CreateEventSchema, EVENT_DATA_PAYLOAD_FIELD_BY_EVENT_TYPE, EVENT_DATA_REF_FIELDS, EventSchema, EventTypeSchema, entityEventClass, getEventDataPayloadField, getEventDataRefFields, HOOK_EVENTS_REQUIRING_EXISTENCE, HOOK_LIFECYCLE_EVENT_TYPES, HookCreatedEventSchema, isChildEntityCreationEvent, isChildEntityCreationEventType, isHookEventRequiringExistence, isHookLifecycleEventType, isRunEventType, isStepEventType, isTerminalRunEventType, isTerminalStepEventType, isWaitEventType, RUN_EVENT_TYPES, STEP_EVENT_TYPES, stripEventDataRefs, TERMINAL_RUN_EVENT_TYPES, TERMINAL_STEP_EVENT_TYPES, TerminalRunEventTypeSchema, WAIT_EVENT_TYPES, } from './events.js';
|
|
8
8
|
export type * from './hooks.js';
|
|
9
9
|
export { HOOK_RESUME_DEDUP_VERSION, HOOK_RESUME_INPUT_VERSION, HookResumeCapabilitiesSchema, HookSchema, } from './hooks.js';
|
|
10
10
|
export type * from './interfaces.js';
|
|
11
|
+
export { isNodeHttpEnabled, NODE_HTTP_DEFAULT, NODE_HTTP_ENV_VAR, } from './node-http-flag.js';
|
|
11
12
|
export type * from './queue.js';
|
|
12
13
|
export { getQueueTopicPrefix, HealthCheckPayloadSchema, MessageId, parseQueueName, QueuePayloadSchema, QueuePrefix, RunInputSchema, resolveQueueNamespace, ValidQueueName, WorkflowInvokePayloadSchema, } from './queue.js';
|
|
13
14
|
export { reenqueueActiveRuns } from './recovery.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Analytics } from './analytics.js';
|
|
2
2
|
import type { AttributeChange, ExperimentalSetAttributesResult } from './attributes.js';
|
|
3
|
-
import type { CreateEventParams, CreateEventRequest, Event, EventResult, GetEventParams, ListEventsByCorrelationIdParams, ListEventsParams, RunCreatedEventRequest } from './events.js';
|
|
3
|
+
import type { BatchEventRequest, CreateEventBatchParams, CreateEventParams, CreateEventRequest, Event, EventBatchResult, EventResult, GetEventParams, ListEventsByCorrelationIdParams, ListEventsParams, RunCreatedEventRequest } from './events.js';
|
|
4
4
|
import type { GetHookParams, Hook, ListHooksParams } from './hooks.js';
|
|
5
5
|
import type { Queue } from './queue.js';
|
|
6
6
|
import type { BulkCancelWorkflowRunsRequest, BulkCancelWorkflowRunsResult, GetWorkflowRunParams, ListWorkflowRunsParams, WorkflowRun, WorkflowRunWithoutData } from './runs.js';
|
|
@@ -226,6 +226,43 @@ export interface Storage {
|
|
|
226
226
|
* @returns Promise resolving to the created event and affected entity
|
|
227
227
|
*/
|
|
228
228
|
create<T extends CreateEventRequest>(runId: string, data: T, params?: CreateEventParams): Promise<EventResult<T['eventType']>>;
|
|
229
|
+
/**
|
|
230
|
+
* OPTIONAL batch write — append an ordered list of events to the run's
|
|
231
|
+
* log in one durable, atomic-per-attempt write, with a per-event outcome
|
|
232
|
+
* for each (see {@link BatchEventItemResult}). The events land in request
|
|
233
|
+
* order at consecutive slots. A concurrent writer may push the whole
|
|
234
|
+
* batch to slots above the caller's view of the log; no skipped-event
|
|
235
|
+
* report accompanies the result, so a position-tracking caller compares
|
|
236
|
+
* the committed slots against its expectation and reloads the log to
|
|
237
|
+
* observe what landed in between. Its local view stays a strict PREFIX
|
|
238
|
+
* of the log — never a hole — so replaying it stays correct and the
|
|
239
|
+
* next reload self-corrects.
|
|
240
|
+
*
|
|
241
|
+
* Presence of the method IS the capability declaration: the core runtime
|
|
242
|
+
* batches only when the World implements it (and the run's spec version
|
|
243
|
+
* supports slot identity); absent, every write takes the single-event
|
|
244
|
+
* `create` path unchanged. A World must implement it with real
|
|
245
|
+
* atomicity per attempt — a lost race must leave nothing behind — or not
|
|
246
|
+
* implement it at all.
|
|
247
|
+
*
|
|
248
|
+
* Size limits are the caller's problem: Worlds enforce their own caps
|
|
249
|
+
* (world-vercel enforces an event-count cap and a byte budget over frame
|
|
250
|
+
* meta plus inline-bound payloads) and reject an oversized batch with a
|
|
251
|
+
* request-level error. The core fold sizes its chunks accordingly.
|
|
252
|
+
*
|
|
253
|
+
* Not expressible in a batch (Worlds reject the whole batch with a
|
|
254
|
+
* request-level error): `run_created`, `run_started`, `run_cancelled`,
|
|
255
|
+
* `hook_created`, `hook_disposed`, `attr_set`, and more events targeting
|
|
256
|
+
* one entity than a single write can express (the one legal combination
|
|
257
|
+
* is `step_created` followed by `step_started` for the same step, which
|
|
258
|
+
* creates the step born-running — the step's input MUST ride the
|
|
259
|
+
* `step_created`; a `step_started` carrying a payload rejects the whole
|
|
260
|
+
* batch). Events outside this list keep their own ordering requirements:
|
|
261
|
+
* a caller mixing a batch with single writes (hook or attribute events)
|
|
262
|
+
* owns those barriers itself — the core runtime simply never batches a
|
|
263
|
+
* suspension that carries hook or attribute writes.
|
|
264
|
+
*/
|
|
265
|
+
createBatch?(runId: string, events: BatchEventRequest[], params?: CreateEventBatchParams): Promise<EventBatchResult>;
|
|
229
266
|
get(runId: string, eventId: string, params?: GetEventParams): Promise<Event>;
|
|
230
267
|
list(params: ListEventsParams): Promise<PaginatedResponse<Event>>;
|
|
231
268
|
listByCorrelationId(params: ListEventsByCorrelationIdParams): Promise<PaginatedResponse<Event>>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport selection for the HTTP-backed Worlds (Vercel and local).
|
|
3
|
+
*
|
|
4
|
+
* Both adapters normally issue their requests through the global `fetch`,
|
|
5
|
+
* handing it a hand-built undici `Agent` (wrapped in a `RetryAgent`) so they can
|
|
6
|
+
* set connection pooling, HTTP/2, receive windows, per-request timeouts, and a
|
|
7
|
+
* retry policy tuned per call site. That is undici twice over: the dispatcher
|
|
8
|
+
* the adapter builds, and the undici implementation behind `fetch` itself.
|
|
9
|
+
*
|
|
10
|
+
* {@link NODE_HTTP_ENV_VAR} switches those requests onto a client built on
|
|
11
|
+
* `node:http` / `node:https`, which reach the network through `node:net` /
|
|
12
|
+
* `node:tls` with no undici in the path at all. It exists for a deployment
|
|
13
|
+
* where undici is not a usable dependency: a bundler that mangles its
|
|
14
|
+
* `node:http2` require, or a runtime that ships no working copy of it.
|
|
15
|
+
*
|
|
16
|
+
* See `@workflow/world/node-http.js` for the client itself, and the
|
|
17
|
+
* `WORKFLOW_NODE_HTTP` docs entry for what the swap costs.
|
|
18
|
+
*/
|
|
19
|
+
/** Environment variable that selects the `node:http` / `node:https` transport. */
|
|
20
|
+
export declare const NODE_HTTP_ENV_VAR = "WORKFLOW_NODE_HTTP";
|
|
21
|
+
/**
|
|
22
|
+
* Default for {@link NODE_HTTP_ENV_VAR}.
|
|
23
|
+
*
|
|
24
|
+
* The undici path stays the default because it is the one every deployment has
|
|
25
|
+
* run so far. This transport is opt-in, for the deployments that cannot use
|
|
26
|
+
* undici at all.
|
|
27
|
+
*/
|
|
28
|
+
export declare const NODE_HTTP_DEFAULT = false;
|
|
29
|
+
/**
|
|
30
|
+
* Whether the HTTP Worlds should send their requests over Node's core HTTP
|
|
31
|
+
* client instead of `fetch` + a custom undici dispatcher.
|
|
32
|
+
*
|
|
33
|
+
* Read lazily on every call rather than at module load, so a test or a single
|
|
34
|
+
* process can exercise both transports.
|
|
35
|
+
*
|
|
36
|
+
* An explicitly-supplied dispatcher (`createVercelWorld({ dispatcher })`) still
|
|
37
|
+
* wins over this flag: passing one is an instruction to use undici, so the
|
|
38
|
+
* request goes back through `fetch` with that dispatcher.
|
|
39
|
+
*/
|
|
40
|
+
export declare function isNodeHttpEnabled(env?: Record<string, string | undefined>): boolean;
|
|
41
|
+
//# sourceMappingURL=node-http-flag.d.ts.map
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A `fetch`-shaped client built on Node's core HTTP modules.
|
|
3
|
+
*
|
|
4
|
+
* `node:http` / `node:https` sit directly on `node:net` / `node:tls`, so a
|
|
5
|
+
* request issued here involves no undici at all: not the adapter's own
|
|
6
|
+
* `Agent`, and not the one behind the runtime's global `fetch`. That is the
|
|
7
|
+
* whole point of this module: it is the transport
|
|
8
|
+
* {@link ./node-http-flag.js | WORKFLOW_NODE_HTTP} selects, for a deployment
|
|
9
|
+
* where undici is not a usable dependency (a bundler that mangles its
|
|
10
|
+
* `node:http2` require, a runtime that ships no working copy of it).
|
|
11
|
+
*
|
|
12
|
+
* The returned value is a platform `Response` built around a streaming body,
|
|
13
|
+
* so every consumer shape the Worlds use keeps working: `text()`, `json()`,
|
|
14
|
+
* `arrayBuffer()`, and reading `body` as a `ReadableStream` / async iterable
|
|
15
|
+
* while the response is still arriving.
|
|
16
|
+
*
|
|
17
|
+
* Node builtins are imported statically here, which is why this module is
|
|
18
|
+
* reached by subpath (`@workflow/world/node-http.js`) and is deliberately not
|
|
19
|
+
* re-exported from the package index: `@workflow/world` is also consumed by
|
|
20
|
+
* browser bundles that must not pull `node:https` into their graph.
|
|
21
|
+
*/
|
|
22
|
+
import http from 'node:http';
|
|
23
|
+
import https from 'node:https';
|
|
24
|
+
/**
|
|
25
|
+
* Keep-alive connection pools, one per scheme. Mirrors the role of an undici
|
|
26
|
+
* `Agent`: a caller builds a pair once and hands it to every request that
|
|
27
|
+
* should share its sockets.
|
|
28
|
+
*/
|
|
29
|
+
export interface NodeHttpAgents {
|
|
30
|
+
http: http.Agent;
|
|
31
|
+
https: https.Agent;
|
|
32
|
+
}
|
|
33
|
+
export interface NodeHttpAgentOptions {
|
|
34
|
+
/** Max concurrent sockets per origin. Mirrors undici's `connections`. */
|
|
35
|
+
maxSockets: number;
|
|
36
|
+
/** How long an idle socket is kept. Mirrors undici's `keepAliveTimeout`. */
|
|
37
|
+
keepAliveMs: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Build a keep-alive pool pair. Both schemes are created up front because the
|
|
41
|
+
* scheme is a property of each request URL, not of the pool: a local queue
|
|
42
|
+
* delivering to `http://localhost` and a World talking to an `https://` origin
|
|
43
|
+
* both go through {@link nodeHttpFetch}.
|
|
44
|
+
*/
|
|
45
|
+
export declare function createNodeHttpAgents(options: NodeHttpAgentOptions): NodeHttpAgents;
|
|
46
|
+
/** Close both pools and drop their idle sockets. */
|
|
47
|
+
export declare function destroyNodeHttpAgents(agents: NodeHttpAgents): void;
|
|
48
|
+
export interface NodeHttpFetchInit {
|
|
49
|
+
method?: string;
|
|
50
|
+
headers?: Headers;
|
|
51
|
+
/** Fully-buffered request body. Streaming uploads are not supported. */
|
|
52
|
+
body?: Uint8Array | string | null;
|
|
53
|
+
/** Composed caller/timeout signal. Rejects with `signal.reason`, like `fetch`. */
|
|
54
|
+
signal?: AbortSignal;
|
|
55
|
+
/** Connection pool to dispatch on. Omitted means Node's global agent. */
|
|
56
|
+
agents?: NodeHttpAgents;
|
|
57
|
+
/**
|
|
58
|
+
* Give up if response headers do not arrive within this many ms. `0` or
|
|
59
|
+
* omitted means no deadline, matching undici's `headersTimeout`.
|
|
60
|
+
*
|
|
61
|
+
* Starts when the request is handed a socket, matching where undici starts
|
|
62
|
+
* its own: waiting for a free socket does not consume the budget, connecting
|
|
63
|
+
* does (undici bounds that separately with `connectTimeout`).
|
|
64
|
+
*/
|
|
65
|
+
headersTimeoutMs?: number;
|
|
66
|
+
/**
|
|
67
|
+
* Give up after this many ms with no progress on the response body. `0` or
|
|
68
|
+
* omitted means no deadline, matching undici's `bodyTimeout`.
|
|
69
|
+
*/
|
|
70
|
+
bodyTimeoutMs?: number;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Issue one request over Node's core HTTP client and resolve with a platform
|
|
74
|
+
* `Response`.
|
|
75
|
+
*
|
|
76
|
+
* Differences from `fetch` that callers here rely on not mattering: redirects
|
|
77
|
+
* are not followed (every Worlds endpoint answers directly), the request body
|
|
78
|
+
* must be fully buffered, and no cookie or cache handling is applied.
|
|
79
|
+
*/
|
|
80
|
+
export declare function nodeHttpFetch(url: string, init?: NodeHttpFetchInit): Promise<Response>;
|
|
81
|
+
//# sourceMappingURL=node-http.d.ts.map
|