eve 0.22.4 → 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.
Files changed (100) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +2 -0
  3. package/dist/src/cli/commands/agent-instructions.d.ts +15 -0
  4. package/dist/src/cli/commands/agent-instructions.js +3 -1
  5. package/dist/src/cli/commands/agent-prompt/scaffold.md +3 -0
  6. package/dist/src/cli/commands/extension-build.d.ts +9 -0
  7. package/dist/src/cli/commands/extension-build.js +1 -0
  8. package/dist/src/cli/commands/extension-init.d.ts +25 -0
  9. package/dist/src/cli/commands/extension-init.js +1 -0
  10. package/dist/src/cli/commands/info.js +1 -1
  11. package/dist/src/cli/commands/init-git.js +1 -1
  12. package/dist/src/cli/commands/init-repl.js +1 -1
  13. package/dist/src/cli/commands/init.d.ts +2 -0
  14. package/dist/src/cli/commands/init.js +1 -1
  15. package/dist/src/cli/run.js +1 -1
  16. package/dist/src/compiled/.vendor-stamp.json +4 -4
  17. package/dist/src/compiled/@workflow/core/global.d.ts +20 -0
  18. package/dist/src/compiled/@workflow/core/index.js +2 -2
  19. package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +54 -0
  20. package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +11 -3
  21. package/dist/src/compiled/@workflow/core/runtime/run.d.ts +6 -2
  22. package/dist/src/compiled/@workflow/core/runtime/runs.d.ts +36 -2
  23. package/dist/src/compiled/@workflow/core/runtime/start.d.ts +28 -0
  24. package/dist/src/compiled/@workflow/core/runtime/step-executor.d.ts +23 -0
  25. package/dist/src/compiled/@workflow/core/runtime/step-latency.d.ts +131 -0
  26. package/dist/src/compiled/@workflow/core/runtime/step-ownership.d.ts +72 -0
  27. package/dist/src/compiled/@workflow/core/runtime/step-single-flight.d.ts +12 -0
  28. package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +7 -0
  29. package/dist/src/compiled/@workflow/core/runtime.d.ts +1 -1
  30. package/dist/src/compiled/@workflow/core/runtime.js +3 -3
  31. package/dist/src/compiled/@workflow/core/serialization-format.d.ts +1 -0
  32. package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +40 -0
  33. package/dist/src/compiled/@workflow/core/telemetry.d.ts +8 -0
  34. package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
  35. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  36. package/dist/src/compiled/@workflow/world/analytics.d.ts +4 -4
  37. package/dist/src/compiled/@workflow/world/events.d.ts +142 -21
  38. package/dist/src/compiled/@workflow/world/hooks.d.ts +1 -24
  39. package/dist/src/compiled/@workflow/world/index.d.ts +3 -2
  40. package/dist/src/compiled/@workflow/world/queue.d.ts +10 -0
  41. package/dist/src/compiled/@workflow/world/ulid.d.ts +9 -0
  42. package/dist/src/compiled/@workflow/world-local/index.js +4 -4
  43. package/dist/src/compiled/@workflow/world-vercel/index.js +16 -16
  44. package/dist/src/compiled/_chunks/workflow/attribute-changes-ubiPfqvY.js +20 -0
  45. package/dist/src/compiled/_chunks/workflow/{dist-DJU_7R9s.js → dist-DnBjuNAZ.js} +1 -1
  46. package/dist/src/compiled/_chunks/workflow/{functions-CnVBREsg.js → functions-BCMO8vbf.js} +1 -1
  47. package/dist/src/compiled/_chunks/workflow/resume-hook-BkVkWg2r.js +1 -0
  48. package/dist/src/compiled/_chunks/workflow/run-B3N1kN9q.js +1 -0
  49. package/dist/src/compiled/_chunks/workflow/{sleep-phozDCW8.js → sleep-C2Bn-UUg.js} +1 -1
  50. package/dist/src/harness/emission.d.ts +2 -4
  51. package/dist/src/harness/emission.js +1 -1
  52. package/dist/src/harness/inline-tool-authorization.d.ts +3 -0
  53. package/dist/src/harness/inline-tool-authorization.js +1 -0
  54. package/dist/src/harness/interruptible-stream.d.ts +5 -0
  55. package/dist/src/harness/interruptible-stream.js +1 -0
  56. package/dist/src/harness/model-call-error.js +1 -1
  57. package/dist/src/harness/ordered-stream-emitter.d.ts +17 -0
  58. package/dist/src/harness/ordered-stream-emitter.js +1 -0
  59. package/dist/src/harness/stream-actions.d.ts +1 -0
  60. package/dist/src/harness/stream-actions.js +1 -1
  61. package/dist/src/harness/subagent-depth.d.ts +1 -1
  62. package/dist/src/harness/subagent-depth.js +1 -1
  63. package/dist/src/harness/tool-loop.js +1 -1
  64. package/dist/src/internal/application/optional-package-install.js +2 -2
  65. package/dist/src/internal/application/package.js +1 -1
  66. package/dist/src/internal/authored-module-loader.d.ts +1 -1
  67. package/dist/src/internal/nitro/host/build-application.js +1 -1
  68. package/dist/src/public/definitions/extension.d.ts +4 -4
  69. package/dist/src/public/models/openai/chatgpt/auth.d.ts +69 -0
  70. package/dist/src/public/models/openai/chatgpt/auth.js +1 -0
  71. package/dist/src/public/models/openai/chatgpt/model.d.ts +8 -0
  72. package/dist/src/public/models/openai/chatgpt/model.js +1 -0
  73. package/dist/src/public/models/openai/chatgpt/transport.d.ts +24 -0
  74. package/dist/src/public/models/openai/chatgpt/transport.js +1 -0
  75. package/dist/src/public/models/openai/chatgpt/unsigned-jwt.d.ts +5 -0
  76. package/dist/src/public/models/openai/chatgpt/unsigned-jwt.js +1 -0
  77. package/dist/src/public/models/openai/index.d.ts +30 -0
  78. package/dist/src/public/models/openai/index.js +1 -0
  79. package/dist/src/public/next/server.js +2 -2
  80. package/dist/src/public/nuxt/dev-server.js +1 -1
  81. package/dist/src/public/sveltekit/dev-server.js +1 -1
  82. package/dist/src/setup/scaffold/create/extension.d.ts +30 -0
  83. package/dist/src/setup/scaffold/create/extension.js +34 -0
  84. package/dist/src/setup/scaffold/create/project.d.ts +2 -0
  85. package/dist/src/setup/scaffold/create/project.js +2 -2
  86. package/dist/src/setup/scaffold/index.d.ts +1 -0
  87. package/dist/src/setup/scaffold/index.js +1 -1
  88. package/dist/src/shared/agent-definition.d.ts +1 -1
  89. package/docs/agent-config.md +1 -1
  90. package/docs/channels/slack.mdx +6 -0
  91. package/docs/concepts/sessions-runs-and-streaming.md +1 -1
  92. package/docs/extensions.md +21 -13
  93. package/docs/guides/client/streaming.mdx +1 -1
  94. package/docs/reference/cli.md +56 -22
  95. package/docs/reference/typescript-api.md +17 -0
  96. package/docs/subagents.mdx +1 -1
  97. package/package.json +10 -5
  98. package/dist/src/compiled/_chunks/workflow/attribute-changes-BnKD8Y3m.js +0 -20
  99. package/dist/src/compiled/_chunks/workflow/resume-hook-DjPY9VGg.js +0 -1
  100. package/dist/src/compiled/_chunks/workflow/run-BSANnUPR.js +0 -1
@@ -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
  /**