eve 0.22.3 → 0.22.5
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 +21 -0
- package/README.md +2 -0
- package/dist/src/chunks/{use-eve-agent-Cojyfr4X.js → use-eve-agent-CFBTHlPx.js} +18 -1
- package/dist/src/chunks/{use-eve-agent-D-S1TPCW.js → use-eve-agent-dEGV09g_.js} +18 -1
- package/dist/src/cli/commands/agent-instructions.d.ts +15 -0
- package/dist/src/cli/commands/agent-instructions.js +3 -1
- package/dist/src/cli/commands/agent-prompt/scaffold.md +3 -0
- package/dist/src/cli/commands/extension-build.d.ts +9 -0
- package/dist/src/cli/commands/extension-build.js +1 -0
- package/dist/src/cli/commands/extension-init.d.ts +25 -0
- package/dist/src/cli/commands/extension-init.js +1 -0
- package/dist/src/cli/commands/info.js +1 -1
- package/dist/src/cli/commands/init-git.js +1 -1
- package/dist/src/cli/commands/init-repl.js +1 -1
- package/dist/src/cli/commands/init.d.ts +2 -0
- package/dist/src/cli/commands/init.js +1 -1
- package/dist/src/cli/run.js +1 -1
- package/dist/src/client/agent-host.d.ts +4 -0
- package/dist/src/client/agent-host.js +1 -0
- package/dist/src/compiled/.vendor-stamp.json +4 -4
- package/dist/src/compiled/@workflow/core/global.d.ts +20 -0
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +54 -0
- package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +11 -3
- package/dist/src/compiled/@workflow/core/runtime/run.d.ts +6 -2
- package/dist/src/compiled/@workflow/core/runtime/runs.d.ts +36 -2
- package/dist/src/compiled/@workflow/core/runtime/start.d.ts +28 -0
- package/dist/src/compiled/@workflow/core/runtime/step-executor.d.ts +23 -0
- package/dist/src/compiled/@workflow/core/runtime/step-latency.d.ts +131 -0
- package/dist/src/compiled/@workflow/core/runtime/step-ownership.d.ts +72 -0
- package/dist/src/compiled/@workflow/core/runtime/step-single-flight.d.ts +12 -0
- package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +7 -0
- package/dist/src/compiled/@workflow/core/runtime.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/runtime.js +3 -3
- package/dist/src/compiled/@workflow/core/serialization-format.d.ts +1 -0
- package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +40 -0
- package/dist/src/compiled/@workflow/core/telemetry.d.ts +8 -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/analytics.d.ts +4 -4
- package/dist/src/compiled/@workflow/world/events.d.ts +142 -21
- package/dist/src/compiled/@workflow/world/hooks.d.ts +1 -24
- package/dist/src/compiled/@workflow/world/index.d.ts +3 -2
- package/dist/src/compiled/@workflow/world/queue.d.ts +10 -0
- package/dist/src/compiled/@workflow/world/ulid.d.ts +9 -0
- package/dist/src/compiled/@workflow/world-local/index.js +4 -4
- package/dist/src/compiled/@workflow/world-vercel/index.js +16 -16
- package/dist/src/compiled/_chunks/workflow/attribute-changes-ubiPfqvY.js +20 -0
- package/dist/src/compiled/_chunks/workflow/{dist-DJU_7R9s.js → dist-DnBjuNAZ.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{functions-CnVBREsg.js → functions-BCMO8vbf.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/resume-hook-BkVkWg2r.js +1 -0
- package/dist/src/compiled/_chunks/workflow/run-B3N1kN9q.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{sleep-phozDCW8.js → sleep-C2Bn-UUg.js} +1 -1
- package/dist/src/compiler/manifest.d.ts +4 -4
- package/dist/src/compiler/normalize-subagent.js +1 -1
- package/dist/src/compiler/remote-agent-node.d.ts +1 -1
- package/dist/src/compiler/remote-agent-node.js +1 -1
- package/dist/src/discover/filesystem.d.ts +2 -2
- package/dist/src/discover/filesystem.js +1 -1
- package/dist/src/discover/project.js +1 -1
- package/dist/src/harness/emission.d.ts +2 -4
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/inline-tool-authorization.d.ts +3 -0
- package/dist/src/harness/inline-tool-authorization.js +1 -0
- package/dist/src/harness/interruptible-stream.d.ts +5 -0
- package/dist/src/harness/interruptible-stream.js +1 -0
- package/dist/src/harness/model-call-error.js +1 -1
- package/dist/src/harness/ordered-stream-emitter.d.ts +17 -0
- package/dist/src/harness/ordered-stream-emitter.js +1 -0
- package/dist/src/harness/stream-actions.d.ts +1 -0
- package/dist/src/harness/stream-actions.js +1 -1
- package/dist/src/harness/subagent-depth.d.ts +1 -1
- package/dist/src/harness/subagent-depth.js +1 -1
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/internal/application/optional-package-install.js +2 -2
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-module-loader.d.ts +1 -1
- package/dist/src/internal/nitro/host/build-application.js +1 -1
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/workflow-bundle/eve-service-route-output.d.ts +1 -2
- package/dist/src/internal/workflow-bundle/eve-service-route-output.js +1 -54
- package/dist/src/internal/workflow-bundle/vercel-workflow-output.js +1 -1
- package/dist/src/packages/eve-catalog/src/index.js +1 -1
- package/dist/src/public/definitions/extension.d.ts +4 -4
- package/dist/src/public/definitions/remote-agent.d.ts +11 -2
- package/dist/src/public/index.d.ts +1 -1
- package/dist/src/public/models/openai/chatgpt/auth.d.ts +69 -0
- package/dist/src/public/models/openai/chatgpt/auth.js +1 -0
- package/dist/src/public/models/openai/chatgpt/model.d.ts +8 -0
- package/dist/src/public/models/openai/chatgpt/model.js +1 -0
- package/dist/src/public/models/openai/chatgpt/transport.d.ts +24 -0
- package/dist/src/public/models/openai/chatgpt/transport.js +1 -0
- package/dist/src/public/models/openai/chatgpt/unsigned-jwt.d.ts +5 -0
- package/dist/src/public/models/openai/chatgpt/unsigned-jwt.js +1 -0
- package/dist/src/public/models/openai/index.d.ts +30 -0
- package/dist/src/public/models/openai/index.js +1 -0
- package/dist/src/public/next/index.d.ts +38 -3
- package/dist/src/public/next/index.js +1 -1
- package/dist/src/public/next/server.d.ts +1 -0
- package/dist/src/public/next/server.js +2 -1
- package/dist/src/public/next/vercel-output-config.d.ts +12 -3
- package/dist/src/public/next/vercel-output-config.js +1 -1
- package/dist/src/public/nuxt/dev-server.js +1 -1
- package/dist/src/public/sveltekit/dev-server.js +1 -1
- package/dist/src/react/use-eve-agent.d.ts +8 -1
- package/dist/src/react/use-eve-agent.js +1 -1
- package/dist/src/runtime/resolve-agent-graph.js +1 -1
- package/dist/src/setup/scaffold/connections/catalog.js +1 -1
- package/dist/src/setup/scaffold/create/extension.d.ts +30 -0
- package/dist/src/setup/scaffold/create/extension.js +34 -0
- package/dist/src/setup/scaffold/create/project.d.ts +2 -0
- package/dist/src/setup/scaffold/create/project.js +2 -2
- package/dist/src/setup/scaffold/index.d.ts +1 -0
- package/dist/src/setup/scaffold/index.js +1 -1
- package/dist/src/shared/agent-definition.d.ts +1 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.d.ts +8 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.d.ts +8 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/agent-config.md +1 -1
- package/docs/channels/slack.mdx +6 -0
- package/docs/concepts/sessions-runs-and-streaming.md +1 -1
- package/docs/extensions.md +42 -13
- package/docs/guides/client/streaming.mdx +1 -1
- package/docs/guides/frontend/nextjs.mdx +32 -7
- package/docs/guides/frontend/overview.mdx +7 -1
- package/docs/guides/hooks.md +9 -0
- package/docs/guides/remote-agents.md +23 -8
- package/docs/meta.json +0 -1
- package/docs/reference/cli.md +56 -22
- package/docs/reference/typescript-api.md +17 -0
- package/docs/subagents.mdx +1 -1
- package/package.json +10 -5
- package/dist/src/compiled/_chunks/workflow/attribute-changes-BnKD8Y3m.js +0 -20
- package/dist/src/compiled/_chunks/workflow/resume-hook-DjPY9VGg.js +0 -1
- package/dist/src/compiled/_chunks/workflow/run-BSANnUPR.js +0 -1
|
@@ -2,6 +2,15 @@ import { type World } from '#compiled/@workflow/world/index.js';
|
|
|
2
2
|
export interface RecreateRunOptions {
|
|
3
3
|
deploymentId?: string;
|
|
4
4
|
specVersion?: number;
|
|
5
|
+
/**
|
|
6
|
+
* Queue namespace of the target deployment (e.g. `'eve'` for topics like
|
|
7
|
+
* `__eve_wkf_workflow_*`). Falls back to `WORKFLOW_QUEUE_NAMESPACE` in
|
|
8
|
+
* the calling process. Cross-context callers (e.g. the observability
|
|
9
|
+
* dashboard) must pass the target deployment's namespace explicitly —
|
|
10
|
+
* a run enqueued to a topic the target deployment has no consumer for
|
|
11
|
+
* is never picked up.
|
|
12
|
+
*/
|
|
13
|
+
namespace?: string;
|
|
5
14
|
}
|
|
6
15
|
export interface StopSleepResult {
|
|
7
16
|
/** Number of pending sleeps that were stopped */
|
|
@@ -21,6 +30,28 @@ export interface StopSleepOptions {
|
|
|
21
30
|
* If not provided, all pending sleep calls will be interrupted.
|
|
22
31
|
*/
|
|
23
32
|
correlationIds?: string[];
|
|
33
|
+
/**
|
|
34
|
+
* Queue namespace of the run's deployment (e.g. `'eve'`), used when
|
|
35
|
+
* re-enqueueing the run after completing its waits. Falls back to
|
|
36
|
+
* `WORKFLOW_QUEUE_NAMESPACE` in the calling process. Cross-context
|
|
37
|
+
* callers (e.g. the observability dashboard) must pass it explicitly.
|
|
38
|
+
*/
|
|
39
|
+
namespace?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface ReenqueueRunOptions {
|
|
42
|
+
/**
|
|
43
|
+
* Queue namespace of the run's deployment (e.g. `'eve'`). Falls back to
|
|
44
|
+
* `WORKFLOW_QUEUE_NAMESPACE` in the calling process. Cross-context
|
|
45
|
+
* callers (e.g. the observability dashboard) must pass it explicitly.
|
|
46
|
+
*/
|
|
47
|
+
namespace?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface CancelRunOptions {
|
|
50
|
+
/**
|
|
51
|
+
* Optional free-text reason for the cancellation (max 512 chars), recorded
|
|
52
|
+
* on the run_cancelled event and surfaced in the run detail view.
|
|
53
|
+
*/
|
|
54
|
+
cancelReason?: string;
|
|
24
55
|
}
|
|
25
56
|
/**
|
|
26
57
|
* Start a new workflow run based on an existing run.
|
|
@@ -28,12 +59,15 @@ export interface StopSleepOptions {
|
|
|
28
59
|
export declare function recreateRunFromExisting(world: World, runId: string, options?: RecreateRunOptions): Promise<string>;
|
|
29
60
|
/**
|
|
30
61
|
* Cancel a workflow run.
|
|
62
|
+
*
|
|
63
|
+
* @param options - Optional cancellation settings. `cancelReason` records a
|
|
64
|
+
* free-text reason (max 512 chars) on the run_cancelled event.
|
|
31
65
|
*/
|
|
32
|
-
export declare function cancelRun(world: World, runId: string): Promise<void>;
|
|
66
|
+
export declare function cancelRun(world: World, runId: string, options?: CancelRunOptions): Promise<void>;
|
|
33
67
|
/**
|
|
34
68
|
* Re-enqueue a workflow run.
|
|
35
69
|
*/
|
|
36
|
-
export declare function reenqueueRun(world: World, runId: string): Promise<void>;
|
|
70
|
+
export declare function reenqueueRun(world: World, runId: string, options?: ReenqueueRunOptions): Promise<void>;
|
|
37
71
|
/**
|
|
38
72
|
* Wake up a workflow run by interrupting pending sleep() calls.
|
|
39
73
|
*/
|
|
@@ -36,6 +36,34 @@ export interface StartOptionsBase {
|
|
|
36
36
|
* the `experimental_setAttributes` option of the same name.
|
|
37
37
|
*/
|
|
38
38
|
allowReservedAttributes?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The ID of an existing run this run is being replayed from, if any.
|
|
41
|
+
*
|
|
42
|
+
* Recorded on the new run's `executionContext` as `replayedFromRunId` so
|
|
43
|
+
* tooling (e.g. the dashboard runs list) can show that a run originated as
|
|
44
|
+
* a replay and link back to its source. Set automatically by
|
|
45
|
+
* {@link recreateRunFromExisting}; there's usually no reason to pass it
|
|
46
|
+
* directly.
|
|
47
|
+
*
|
|
48
|
+
* Must be a run ID: `wrun_` followed by a 26-char ULID. It's a foreign key
|
|
49
|
+
* to the source run, so `start()` validates the exact shape and rejects
|
|
50
|
+
* anything else rather than persist a lineage link that points at garbage.
|
|
51
|
+
*/
|
|
52
|
+
replayedFromRunId?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Queue namespace of the target deployment. Scopes the workflow queue
|
|
55
|
+
* topic to `__{namespace}_wkf_workflow_*` (e.g. `'eve'`) instead of the
|
|
56
|
+
* default `__wkf_workflow_*`, and is also used for the cross-deployment
|
|
57
|
+
* capability probe. Falls back to `WORKFLOW_QUEUE_NAMESPACE` in the
|
|
58
|
+
* calling process.
|
|
59
|
+
*
|
|
60
|
+
* Within a deployment the env fallback is correct. Cross-context callers
|
|
61
|
+
* (e.g. the observability dashboard replaying a run) must pass the
|
|
62
|
+
* TARGET deployment's namespace explicitly: the env fallback resolves in
|
|
63
|
+
* the caller's process, and a run enqueued to a topic the target has no
|
|
64
|
+
* consumer for is never picked up.
|
|
65
|
+
*/
|
|
66
|
+
namespace?: string;
|
|
39
67
|
}
|
|
40
68
|
export interface StartOptionsWithDeploymentId extends StartOptionsBase {
|
|
41
69
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Event, SerializedData, World } from '#compiled/@workflow/world/index.js';
|
|
2
2
|
import type { CryptoKey } from '../encryption.js';
|
|
3
|
+
import { type StepLatencyTracking } from './step-latency.js';
|
|
3
4
|
export interface StepExecutorParams {
|
|
4
5
|
world: World;
|
|
5
6
|
workflowRunId: string;
|
|
@@ -28,6 +29,19 @@ export interface StepExecutorParams {
|
|
|
28
29
|
* carries no payload (the legacy contract).
|
|
29
30
|
*/
|
|
30
31
|
lazyStepInput?: SerializedData;
|
|
32
|
+
/**
|
|
33
|
+
* Inline step ownership: the queue message ID of the invocation this
|
|
34
|
+
* executeStep call runs in (from the queue handler's meta). When set, the
|
|
35
|
+
* `step_started` this call sends is stamped with it — on the lazy paths
|
|
36
|
+
* (where `lazyStepInput` is present) and on the owned-recovery bare start
|
|
37
|
+
* (where it is not; the re-stamp keeps a recovered step readable as owned
|
|
38
|
+
* by this message, since ownership derives from the LATEST start). Wake
|
|
39
|
+
* replays that observe an actively-owned step suppress the immediate
|
|
40
|
+
* requeue and enqueue a delayed backstop instead. Omitted on the
|
|
41
|
+
* background-step path, whose bare start intentionally clears ownership
|
|
42
|
+
* (the step is queue-owned from that point).
|
|
43
|
+
*/
|
|
44
|
+
ownerMessageId?: string;
|
|
31
45
|
/**
|
|
32
46
|
* Inline-delta optimization (opt-in). When provided, the cursor of the
|
|
33
47
|
* event log as observed by the caller *before* this step's events were
|
|
@@ -55,6 +69,15 @@ export interface StepExecutorParams {
|
|
|
55
69
|
* outside turbo, where `run_started` was already awaited up front.
|
|
56
70
|
*/
|
|
57
71
|
runReadyBarrier?: Promise<unknown>;
|
|
72
|
+
/**
|
|
73
|
+
* Latency telemetry (TTFS / STSO): eligibility and anchor timestamps decided
|
|
74
|
+
* by the orchestrator. When set, this executor computes the final values
|
|
75
|
+
* against the wall clock taken immediately before user code runs and
|
|
76
|
+
* attaches them to the step's terminal event. Set only for the first step of
|
|
77
|
+
* an inline batch, and only on first-attempt executions that qualify — see
|
|
78
|
+
* runtime/step-latency.ts.
|
|
79
|
+
*/
|
|
80
|
+
latencyTracking?: StepLatencyTracking;
|
|
58
81
|
}
|
|
59
82
|
/**
|
|
60
83
|
* Inline-delta returned by a step-terminal write when the caller passed
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import type { Event } from '#compiled/@workflow/world/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Client-side latency measurement (TTFS / STSO) threaded from the
|
|
4
|
+
* orchestrator's inline execution path into `executeStep`.
|
|
5
|
+
*
|
|
6
|
+
* TTFS (time-to-first-step) measures run creation → the first step's body
|
|
7
|
+
* beginning to execute. STSO (step-to-step overhead) measures the previous
|
|
8
|
+
* step's terminal event → the next step's body beginning to execute. Both are
|
|
9
|
+
* attached to the step's terminal event so a backend can emit latency metrics
|
|
10
|
+
* from the event write alone, without extra event-log queries.
|
|
11
|
+
*
|
|
12
|
+
* Eligibility is decided by the orchestrator (which owns the event log) via
|
|
13
|
+
* {@link computeStepLatencyTracking}; the final values are computed by
|
|
14
|
+
* `executeStep` right before user code runs via
|
|
15
|
+
* {@link computeStepLatencyEventData}.
|
|
16
|
+
*/
|
|
17
|
+
export interface StepLatencyTracking {
|
|
18
|
+
/**
|
|
19
|
+
* Epoch ms of run creation (from the run-id ULID, falling back to the run
|
|
20
|
+
* snapshot's `createdAt`). Present only when the step qualifies for TTFS.
|
|
21
|
+
*/
|
|
22
|
+
ttfsAnchorMs?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Wall-clock ms this invocation spent committing `hook_created` events
|
|
25
|
+
* before the first step (fire-and-forget `createHook()` ahead of the first
|
|
26
|
+
* step commits in the same suspension batch). Subtracted from TTFS so the
|
|
27
|
+
* metric reflects runtime overhead rather than the user's hook writes.
|
|
28
|
+
*/
|
|
29
|
+
preStepBlockingMs?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Epoch ms the first pre-step `attr_set` write began (its client-stamped
|
|
32
|
+
* `occurredAt`, falling back to `createdAt`). When present, the TTFS
|
|
33
|
+
* measurement ENDS here instead of at the step's code start: a
|
|
34
|
+
* workflow-body `experimental_setAttributes` before the first step
|
|
35
|
+
* resolves through an extra replay (see the `hasAttributeEvents` branch in
|
|
36
|
+
* runtime.ts), so everything from this write until the step body runs is
|
|
37
|
+
* the duration of the setAttributes call — which is subtracted by ending
|
|
38
|
+
* the measurement at the point where the step would otherwise have been
|
|
39
|
+
* scheduled.
|
|
40
|
+
*/
|
|
41
|
+
preStepAttrStartMs?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Epoch ms the previous step's terminal event was recorded (its
|
|
44
|
+
* client-stamped `occurredAt`, falling back to `createdAt`). Present only
|
|
45
|
+
* when the step qualifies for STSO.
|
|
46
|
+
*/
|
|
47
|
+
prevStepEndMs?: number;
|
|
48
|
+
/** Number of unique terminal steps already in the event log. */
|
|
49
|
+
stepCount?: number;
|
|
50
|
+
/** Number of events already in the event log. */
|
|
51
|
+
eventCount?: number;
|
|
52
|
+
/** Whether turbo mode is active for this invocation. */
|
|
53
|
+
turbo: boolean;
|
|
54
|
+
}
|
|
55
|
+
/** Latency telemetry attached to a step's terminal event's `eventData`. */
|
|
56
|
+
export interface StepLatencyEventData {
|
|
57
|
+
ttfs?: number;
|
|
58
|
+
stso?: number;
|
|
59
|
+
stepCount?: number;
|
|
60
|
+
eventCount?: number;
|
|
61
|
+
optimizations?: string[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Decide, from the orchestrator's view of the event log, whether the inline
|
|
65
|
+
* step batch about to execute qualifies for TTFS and/or STSO measurement.
|
|
66
|
+
* Returns undefined when neither applies. Called once per batch; the result
|
|
67
|
+
* is passed to the batch's first step only, so a parallel first batch emits a
|
|
68
|
+
* single sample rather than one per sibling.
|
|
69
|
+
*/
|
|
70
|
+
export declare function computeStepLatencyTracking(params: {
|
|
71
|
+
/** The orchestrator's current in-memory event log (ascending order). */
|
|
72
|
+
events: Event[];
|
|
73
|
+
/**
|
|
74
|
+
* Whether this invocation's initial event load contained nothing beyond
|
|
75
|
+
* run_created/run_started/attr_set. Pre-existing hook events were written
|
|
76
|
+
* by an earlier invocation, so the time they added (including the queue
|
|
77
|
+
* hop back to this invocation) is unmeasurable and disqualifies TTFS.
|
|
78
|
+
* attr_set is permitted: a redelivery can land after a committed pre-step
|
|
79
|
+
* attr_set, and the detour it marks is subtracted via `preStepAttrStartMs`
|
|
80
|
+
* regardless of which invocation wrote it.
|
|
81
|
+
*/
|
|
82
|
+
invocationStartedClean: boolean;
|
|
83
|
+
/** Epoch ms of run creation, if recoverable. Absent disqualifies TTFS. */
|
|
84
|
+
runCreatedAtMs: number | undefined;
|
|
85
|
+
/** See {@link StepLatencyTracking.preStepBlockingMs}. */
|
|
86
|
+
preStepBlockingMs: number;
|
|
87
|
+
/**
|
|
88
|
+
* The accumulator's value as of the suspension that wrote the run's first
|
|
89
|
+
* attr_set (its hook phase runs before its attr writes). When the
|
|
90
|
+
* measurement ends at the attr write, only hook time from before that
|
|
91
|
+
* point may be subtracted — later hook writes fall outside the measured
|
|
92
|
+
* window. Undefined when no attr suspension happened in this invocation
|
|
93
|
+
* (e.g. the attr_set was loaded from a redelivery's snapshot, where no
|
|
94
|
+
* same-invocation hook time precedes it).
|
|
95
|
+
*/
|
|
96
|
+
preStepBlockingBeforeAttrMs: number | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* Whether the suspension that scheduled this batch also created waits.
|
|
99
|
+
* Those `wait_created` writes are not in `events` yet (they were committed
|
|
100
|
+
* by this very suspension pass), so they must be reported separately. A
|
|
101
|
+
* wait disqualifies both measurements.
|
|
102
|
+
*/
|
|
103
|
+
suspensionHasWaits: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Whether the suspension that scheduled this batch also created hooks
|
|
106
|
+
* (also not in `events` yet). Hooks keep TTFS eligible — their measured
|
|
107
|
+
* write time is subtracted via `preStepBlockingMs` — but disqualify STSO,
|
|
108
|
+
* which is only meaningful for a pure back-to-back step gap.
|
|
109
|
+
*/
|
|
110
|
+
suspensionCreatedHooks: boolean;
|
|
111
|
+
/** Whether turbo mode is active for this invocation. */
|
|
112
|
+
turbo: boolean;
|
|
113
|
+
}): StepLatencyTracking | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* Compute the latency telemetry to attach to the step's terminal event.
|
|
116
|
+
* Called by `executeStep` with the wall-clock timestamp taken immediately
|
|
117
|
+
* before user step code runs. Returns undefined when there is nothing to
|
|
118
|
+
* report (no tracking, or a retry attempt — retries measure neither TTFS nor
|
|
119
|
+
* STSO).
|
|
120
|
+
*/
|
|
121
|
+
export declare function computeStepLatencyEventData(params: {
|
|
122
|
+
tracking: StepLatencyTracking | undefined;
|
|
123
|
+
/** `Date.now()` taken immediately before user step code began executing. */
|
|
124
|
+
stepCodeStartedAtMs: number;
|
|
125
|
+
attempt: number;
|
|
126
|
+
/** Whether this step was started lazily (no separate step_created write). */
|
|
127
|
+
lazyStepStart: boolean;
|
|
128
|
+
/** Whether the body ran optimistically, without awaiting step_started. */
|
|
129
|
+
optimisticStart: boolean;
|
|
130
|
+
}): StepLatencyEventData | undefined;
|
|
131
|
+
//# sourceMappingURL=step-latency.d.ts.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { Event } from '#compiled/@workflow/world/index.js';
|
|
2
|
+
import type { StepInvocationQueueItem } from '../global.js';
|
|
3
|
+
/**
|
|
4
|
+
* Inline step ownership helpers for the pending-step dispatch decision table
|
|
5
|
+
* in runtime.ts (workflow#2780). Ownership state itself is derived per-replay
|
|
6
|
+
* from the event log by the step consumer in step.ts and surfaced on
|
|
7
|
+
* StepInvocationQueueItem; these functions interpret that state at dispatch
|
|
8
|
+
* time.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Whether inline step ownership is active for a pending step: created,
|
|
12
|
+
* latest `step_started` carries an owner stamp, and no `step_retrying` has
|
|
13
|
+
* been observed (from `step_retrying` on, the step is queue-owned by its
|
|
14
|
+
* delayed retry handoff / replay requeue, so ownership is permanently
|
|
15
|
+
* lapsed for the correlation ID).
|
|
16
|
+
*/
|
|
17
|
+
export declare function isStepOwnershipActive(step: StepInvocationQueueItem): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Seconds left on an owned step's liveness lease, anchored at its latest
|
|
20
|
+
* `step_started`. 0 means the lease has expired (or the start timestamp is
|
|
21
|
+
* missing — the degraded mode for worlds whose events lack usable
|
|
22
|
+
* timestamps), in which case dispatch falls back to the immediate enqueue.
|
|
23
|
+
*
|
|
24
|
+
* The result is clamped to the configured lease: `lastStartedAt` is the
|
|
25
|
+
* server-stamped event `createdAt` while `nowMs` is the local clock, so a
|
|
26
|
+
* client running behind the server would otherwise compute a remainder
|
|
27
|
+
* LONGER than the lease itself — and with the lease tuned to the 900s cap,
|
|
28
|
+
* a `delaySeconds` above the queue's per-message maximum, which SQS-backed
|
|
29
|
+
* worlds reject outright (the wake replay's enqueue would throw and ride
|
|
30
|
+
* the redelivery loop). The clamp makes skew strictly harmless; remaining
|
|
31
|
+
* time can never legitimately exceed the full lease anyway.
|
|
32
|
+
*/
|
|
33
|
+
export declare function stepLeaseRemainingSeconds(step: StepInvocationQueueItem, nowMs: number): number;
|
|
34
|
+
/**
|
|
35
|
+
* Idempotency key for the delayed backstop wake of an inline-owned step.
|
|
36
|
+
*
|
|
37
|
+
* The key is scoped to the current OWNERSHIP EPOCH — the timestamp of the
|
|
38
|
+
* latest `step_started` — not just the correlation ID. Within one epoch,
|
|
39
|
+
* every wake replay derives the same key, so fan-out stays capped at one
|
|
40
|
+
* pending backstop per step. But when owner recovery re-stamps the step
|
|
41
|
+
* (queue redelivery of the owning message → new `step_started` → new
|
|
42
|
+
* `lastStartedAt`), the key CHANGES. This is load-bearing for liveness:
|
|
43
|
+
* queues dedupe an idempotency key for the lifetime of the original
|
|
44
|
+
* message — including while a delivery of it is in flight — so a backstop
|
|
45
|
+
* that fires during a refreshed lease and tries to re-arm under a fixed key
|
|
46
|
+
* would dedupe against ITSELF and be dropped, leaving no escape hatch if
|
|
47
|
+
* the recovered owner later dies without further redeliveries. The epoch
|
|
48
|
+
* suffix gives the re-arm a fresh key. Pending backstops are bounded by the
|
|
49
|
+
* number of ownership epochs, i.e. the queue's redelivery budget for the
|
|
50
|
+
* owning message.
|
|
51
|
+
*
|
|
52
|
+
* The epoch value comes from the persisted event's `createdAt`, so every
|
|
53
|
+
* replayer derives the same key. Callers only build backstops when the
|
|
54
|
+
* lease has time remaining, which requires `lastStartedAt` to be set.
|
|
55
|
+
*
|
|
56
|
+
* The key must also never be the step message's own `idempotencyKey`
|
|
57
|
+
* (the bare correlation ID): the owner's retry handoff enqueues the step
|
|
58
|
+
* under that key with a short backoff, and a pending backstop sharing it
|
|
59
|
+
* would absorb the retry — turning a 1s backoff into a full-lease stall.
|
|
60
|
+
*/
|
|
61
|
+
export declare function backstopIdempotencyKey(step: StepInvocationQueueItem): string;
|
|
62
|
+
/**
|
|
63
|
+
* Whether any of the given pending correlation IDs is inline-owned by
|
|
64
|
+
* `messageId` per the raw event log: its LATEST `step_started` carries
|
|
65
|
+
* `ownerMessageId === messageId` and no `step_retrying` follows it. Used by
|
|
66
|
+
* the background-step fast path, which sees raw events (not the replay's
|
|
67
|
+
* queueItems), to decide whether to fall through to the main loop so this
|
|
68
|
+
* invocation can recover a step it owns instead of returning and leaving it
|
|
69
|
+
* to the delayed backstop.
|
|
70
|
+
*/
|
|
71
|
+
export declare function hasPendingStepOwnedByMessage(events: Event[], pendingCorrelationIds: Set<string | undefined>, messageId: string): boolean;
|
|
72
|
+
//# sourceMappingURL=step-ownership.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { StepExecutionResult } from './step-executor.js';
|
|
2
|
+
/**
|
|
3
|
+
* Run `execute` unless an execution for the same run + step correlation ID is
|
|
4
|
+
* already in flight in this process. The winner's result is returned to the
|
|
5
|
+
* winner; a loser awaits the winner's settlement (success OR failure) and
|
|
6
|
+
* then returns `{ type: 'skipped' }` so its caller acks without running the
|
|
7
|
+
* body. A winner failure is not propagated to the loser — the winner's own
|
|
8
|
+
* queue message redelivers and drives the retry, so exactly one message
|
|
9
|
+
* keeps owning the outcome.
|
|
10
|
+
*/
|
|
11
|
+
export declare function runStepSingleFlight(runId: string, correlationId: string, execute: () => Promise<StepExecutionResult>): Promise<StepExecutionResult>;
|
|
12
|
+
//# sourceMappingURL=step-single-flight.d.ts.map
|
|
@@ -77,6 +77,13 @@ export interface SuspensionHandlerResult {
|
|
|
77
77
|
* inline start (a hook introduces later resume invocations that could race).
|
|
78
78
|
*/
|
|
79
79
|
hasHookEvents: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Wall-clock ms spent committing this suspension's `hook_created` events
|
|
82
|
+
* (0 when it created none). The caller accumulates this across iterations
|
|
83
|
+
* and subtracts it from the TTFS latency measurement, so time spent
|
|
84
|
+
* durably creating the user's hooks doesn't count as runtime overhead.
|
|
85
|
+
*/
|
|
86
|
+
hookCreationMs: number;
|
|
80
87
|
}
|
|
81
88
|
/**
|
|
82
89
|
* Handles a workflow suspension by processing all pending operations (hooks, steps, waits).
|
|
@@ -4,7 +4,7 @@ export { WorkflowSuspension } from './global.js';
|
|
|
4
4
|
export { type HealthCheckEndpoint, type HealthCheckOptions, type HealthCheckResult, healthCheck, } from './runtime/helpers.js';
|
|
5
5
|
export { getHookByToken, resumeHook, resumeWebhook, } from './runtime/resume-hook.js';
|
|
6
6
|
export { getRun, Run, type WorkflowReadableStream, type WorkflowReadableStreamOptions, } from './runtime/run.js';
|
|
7
|
-
export { cancelRun, listStreams, type ReadStreamOptions, type RecreateRunOptions, readStream, recreateRunFromExisting, reenqueueRun, type StopSleepOptions, type StopSleepResult, wakeUpRun, } from './runtime/runs.js';
|
|
7
|
+
export { type CancelRunOptions, cancelRun, listStreams, type ReadStreamOptions, type RecreateRunOptions, type ReenqueueRunOptions, readStream, recreateRunFromExisting, reenqueueRun, type StopSleepOptions, type StopSleepResult, wakeUpRun, } from './runtime/runs.js';
|
|
8
8
|
export { type StartOptions, type StartOptionsBase, type StartOptionsWithDeploymentId, type StartOptionsWithoutDeploymentId, start, } from './runtime/start.js';
|
|
9
9
|
export { createWorld, createWorldFromModule, getWorld, getWorldHandlers, setWorld, type WorldFactoryModule, } from './runtime/world.js';
|
|
10
10
|
/**
|