@stackbone/sdk 0.1.0-alpha.7 → 0.1.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.
@@ -1,35 +1,31 @@
1
- /**
2
- * Augmentable registry of the workspace's eve agent NAMES. By default it is
3
- * empty, so `eveAgent(name)` accepts any `string` (today's behavior, validated
4
- * only at runtime against the injected `AGENT_URLS` map). `stackbone dev`
5
- * generates an ambient `.stackbone/agents.d.ts` from the project's
6
- * `stackbone.config.ts` agent list and augments this interface so the names
7
- * become a closed set:
8
- *
9
- * declare module '@stackbone/sdk/workflow' {
10
- * interface AgentRegistry {
11
- * support: true;
12
- * 'lead-qualifier': true;
13
- * }
14
- * }
15
- *
16
- * Once augmented, `eveAgent('lead-qualifier')` is fine and `eveAgent('typo')` is
17
- * a compile error — the editor also autocompletes the declared names. Mirrors the
18
- * `ConfigRegistry` augmentable-interface pattern used for `client.config`.
19
- */
20
- interface AgentRegistry {
1
+ /** One active scheduled trigger, as `listSchedules()` reports it. */
2
+ interface ScheduledWorkflow {
3
+ /** The workflow this trigger starts on each tick. */
4
+ readonly name: string;
5
+ /** The cron expression driving the cadence. */
6
+ readonly cron: string;
7
+ /** The input each tick passes to the workflow. */
8
+ readonly input: unknown;
9
+ /** `'declarative'` (harvested from the workflow, reconciled on boot) or
10
+ * `'dynamic'` (registered at run time via `scheduleWorkflow`). */
11
+ readonly source: 'declarative' | 'dynamic';
21
12
  }
22
- /**
23
- * The set of agent names `eveAgent` accepts, derived from the augmentable
24
- * `AgentRegistry`. The tuple wrap (`[X] extends [never]`) defeats the
25
- * conditional-type distributivity a bare `keyof AgentRegistry extends never`
26
- * would trigger:
27
- *
28
- * - empty registry -> `string` (today's loose behavior: any name, checked at
29
- * runtime when the workflow resolves it against `AGENT_URLS`);
30
- * - augmented registry -> the union of declared agent names (typo = compile error).
31
- */
32
- type AgentName = [keyof AgentRegistry] extends [never] ? string : keyof AgentRegistry;
13
+ /** The runtime-injected bridge the imperative cron helpers reach. */
14
+ interface WorkflowScheduler {
15
+ /** Register (or upsert) a DYNAMIC repeatable trigger that starts `name` with
16
+ * `input` on the `cron` cadence. Idempotent by `name`. */
17
+ schedule(name: string, input: unknown, cron: string): Promise<void>;
18
+ /** Cancel a dynamic trigger by `name`. Resolves whether or not one existed. */
19
+ unschedule(name: string): Promise<void>;
20
+ /** List the active triggers declarative + dynamic. */
21
+ listSchedules(): Promise<ScheduledWorkflow[]>;
22
+ }
23
+ /** Plant (or clear, with `undefined`) the ambient scheduler. The runtime calls
24
+ * this on first dispatch; tests pass a fake. Last write wins. */
25
+ declare function setWorkflowScheduler(scheduler: WorkflowScheduler | undefined): void;
26
+ /** Return the bound ambient scheduler, or throw a clear error when none is bound
27
+ * (the imperative cron API was reached outside a running workflow runtime). */
28
+ declare function getWorkflowScheduler(): WorkflowScheduler;
33
29
 
34
30
  /**
35
31
  * Queue-level options for a workflow trigger.
@@ -87,33 +83,116 @@ declare function setWorkflowStarter(starter: WorkflowStarter | undefined): void;
87
83
  */
88
84
  declare function getWorkflowStarter(): WorkflowStarter;
89
85
 
90
- /** One active scheduled trigger, as `listSchedules()` reports it. */
91
- interface ScheduledWorkflow {
92
- /** The workflow this trigger starts on each tick. */
93
- readonly name: string;
94
- /** The cron expression driving the cadence. */
95
- readonly cron: string;
96
- /** The input each tick passes to the workflow. */
97
- readonly input: unknown;
98
- /** `'declarative'` (harvested from the workflow, reconciled on boot) or
99
- * `'dynamic'` (registered at run time via `scheduleWorkflow`). */
100
- readonly source: 'declarative' | 'dynamic';
86
+ /**
87
+ * Augmentable registry of the workspace's WORKFLOW names. By default it is empty,
88
+ * so `startWorkflow(name, ...)` / `startWorkflowAndWait(name, ...)` accept any
89
+ * `string` (today's behavior, validated only at runtime against the injected
90
+ * name→ref registry). `stackbone dev` generates an ambient
91
+ * `.stackbone/workflows.d.ts` from the project's `stackbone.config.ts` workflow
92
+ * list and augments this interface so the names become a closed set:
93
+ *
94
+ * declare module '@stackbone/sdk/workflow' {
95
+ * interface WorkflowRegistry {
96
+ * onboarding: true;
97
+ * qualifyLead: true;
98
+ * }
99
+ * }
100
+ *
101
+ * Once augmented, `startWorkflow('qualifyLead', ...)` is fine and
102
+ * `startWorkflow('typo', ...)` is a compile error — the editor also autocompletes
103
+ * the declared names. Mirrors the `AgentRegistry` augmentable-interface pattern
104
+ * used for `eveAgent`.
105
+ */
106
+ interface WorkflowRegistry {
101
107
  }
102
- /** The runtime-injected bridge the imperative cron helpers reach. */
103
- interface WorkflowScheduler {
104
- /** Register (or upsert) a DYNAMIC repeatable trigger that starts `name` with
105
- * `input` on the `cron` cadence. Idempotent by `name`. */
106
- schedule(name: string, input: unknown, cron: string): Promise<void>;
107
- /** Cancel a dynamic trigger by `name`. Resolves whether or not one existed. */
108
- unschedule(name: string): Promise<void>;
109
- /** List the active triggers declarative + dynamic. */
110
- listSchedules(): Promise<ScheduledWorkflow[]>;
108
+ /**
109
+ * The set of workflow names the trigger helpers accept, derived from the
110
+ * augmentable `WorkflowRegistry`. The tuple wrap (`[X] extends [never]`) defeats
111
+ * the conditional-type distributivity a bare `keyof WorkflowRegistry extends
112
+ * never` would trigger:
113
+ *
114
+ * - empty registry -> `string` (today's loose behavior: any name, checked at
115
+ * runtime when the workflow resolves it against the manifest);
116
+ * - augmented registry -> the union of declared workflow names (typo = compile error).
117
+ */
118
+ type WorkflowName = [keyof WorkflowRegistry] extends [never] ? string : keyof WorkflowRegistry;
119
+
120
+ /** Options for {@link startWorkflow}. See {@link WorkflowTriggerOptions}. */
121
+ type StartWorkflowOptions = WorkflowTriggerOptions;
122
+
123
+ /**
124
+ * Start the workflow named `name` with its own independent run and return its
125
+ * `{ runId }` immediately — fire-and-forget. The input is validated against the
126
+ * target's declared input schema BEFORE the run is enqueued; a name that does
127
+ * not resolve, or input that violates the schema, rejects without starting
128
+ * anything.
129
+ *
130
+ * `name` is typed `WorkflowName` — a loose `string` by default, narrowed to the
131
+ * workspace's declared workflow names once `stackbone dev` has generated
132
+ * `.stackbone/workflows.d.ts` (see `workflow-registry.ts`), so a typo becomes a
133
+ * compile error.
134
+ *
135
+ * MUST be called from inside a running workflow (the runtime binds the starter on
136
+ * first dispatch); calling it elsewhere throws.
137
+ *
138
+ * DURABILITY: the enqueue runs in a `"use step"`, so once it completes a parent
139
+ * restart resumes with the memoized `{ runId }` and does NOT re-enqueue. A crash
140
+ * WHILE the step is mid-flight re-runs it (at-least-once) — the same shape the
141
+ * eve-agent-from-step path has; for fire-and-forget fan-out this is acceptable.
142
+ * Use {@link startWorkflowAndWait} when you need the child's result.
143
+ */
144
+ declare function startWorkflow(name: WorkflowName, input: unknown, opts?: StartWorkflowOptions): Promise<WorkflowStartHandle>;
145
+
146
+ /** Options for {@link startWorkflowAndWait}. See {@link WorkflowTriggerOptions}. */
147
+ type StartWorkflowAndWaitOptions = WorkflowTriggerOptions;
148
+ /**
149
+ * Start the workflow named `name` with its own independent run and durably wait
150
+ * for it to finish, returning its terminal output (validated against the
151
+ * target's declared output schema). Use this when one workflow needs another's
152
+ * result to continue.
153
+ *
154
+ * The input is validated against the target's declared input schema BEFORE the
155
+ * run is enqueued; a name that does not resolve, or input that violates the
156
+ * schema, rejects without starting anything. `TOutput` lets the caller name the
157
+ * expected output shape (defaults to `unknown`).
158
+ *
159
+ * `name` is typed `WorkflowName` — narrowed to the workspace's declared workflow
160
+ * names once `stackbone dev` has generated `.stackbone/workflows.d.ts`. MUST be
161
+ * called from inside a running workflow.
162
+ */
163
+ declare function startWorkflowAndWait<TOutput = unknown>(name: WorkflowName, input: unknown, opts?: StartWorkflowAndWaitOptions): Promise<TOutput>;
164
+
165
+ /**
166
+ * Augmentable registry of the workspace's eve agent NAMES. By default it is
167
+ * empty, so `eveAgent(name)` accepts any `string` (today's behavior, validated
168
+ * only at runtime against the injected `AGENT_URLS` map). `stackbone dev`
169
+ * generates an ambient `.stackbone/agents.d.ts` from the project's
170
+ * `stackbone.config.ts` agent list and augments this interface so the names
171
+ * become a closed set:
172
+ *
173
+ * declare module '@stackbone/sdk/workflow' {
174
+ * interface AgentRegistry {
175
+ * support: true;
176
+ * 'lead-qualifier': true;
177
+ * }
178
+ * }
179
+ *
180
+ * Once augmented, `eveAgent('lead-qualifier')` is fine and `eveAgent('typo')` is
181
+ * a compile error — the editor also autocompletes the declared names. Mirrors the
182
+ * `ConfigRegistry` augmentable-interface pattern used for `client.config`.
183
+ */
184
+ interface AgentRegistry {
111
185
  }
112
- /** Plant (or clear, with `undefined`) the ambient scheduler. The runtime calls
113
- * this on first dispatch; tests pass a fake. Last write wins. */
114
- declare function setWorkflowScheduler(scheduler: WorkflowScheduler | undefined): void;
115
- /** Return the bound ambient scheduler, or throw a clear error when none is bound
116
- * (the imperative cron API was reached outside a running workflow runtime). */
117
- declare function getWorkflowScheduler(): WorkflowScheduler;
186
+ /**
187
+ * The set of agent names `eveAgent` accepts, derived from the augmentable
188
+ * `AgentRegistry`. The tuple wrap (`[X] extends [never]`) defeats the
189
+ * conditional-type distributivity a bare `keyof AgentRegistry extends never`
190
+ * would trigger:
191
+ *
192
+ * - empty registry -> `string` (today's loose behavior: any name, checked at
193
+ * runtime when the workflow resolves it against `AGENT_URLS`);
194
+ * - augmented registry -> the union of declared agent names (typo = compile error).
195
+ */
196
+ type AgentName = [keyof AgentRegistry] extends [never] ? string : keyof AgentRegistry;
118
197
 
119
- export { type AgentName as A, type ScheduledWorkflow as S, type WorkflowTriggerOptions as W, type WorkflowStartHandle as a, type AgentRegistry as b, type WorkflowScheduler as c, type WorkflowStarter as d, getWorkflowStarter as e, setWorkflowStarter as f, getWorkflowScheduler as g, setWorkflowScheduler as s };
198
+ export { type AgentName as A, type ScheduledWorkflow as S, type WorkflowName as W, type AgentRegistry as a, type StartWorkflowAndWaitOptions as b, type StartWorkflowOptions as c, type WorkflowRegistry as d, type WorkflowStartHandle as e, startWorkflowAndWait as f, type WorkflowScheduler as g, type WorkflowStarter as h, type WorkflowTriggerOptions as i, getWorkflowScheduler as j, getWorkflowStarter as k, setWorkflowScheduler as l, setWorkflowStarter as m, startWorkflow as s };
@@ -1,35 +1,31 @@
1
- /**
2
- * Augmentable registry of the workspace's eve agent NAMES. By default it is
3
- * empty, so `eveAgent(name)` accepts any `string` (today's behavior, validated
4
- * only at runtime against the injected `AGENT_URLS` map). `stackbone dev`
5
- * generates an ambient `.stackbone/agents.d.ts` from the project's
6
- * `stackbone.config.ts` agent list and augments this interface so the names
7
- * become a closed set:
8
- *
9
- * declare module '@stackbone/sdk/workflow' {
10
- * interface AgentRegistry {
11
- * support: true;
12
- * 'lead-qualifier': true;
13
- * }
14
- * }
15
- *
16
- * Once augmented, `eveAgent('lead-qualifier')` is fine and `eveAgent('typo')` is
17
- * a compile error — the editor also autocompletes the declared names. Mirrors the
18
- * `ConfigRegistry` augmentable-interface pattern used for `client.config`.
19
- */
20
- interface AgentRegistry {
1
+ /** One active scheduled trigger, as `listSchedules()` reports it. */
2
+ interface ScheduledWorkflow {
3
+ /** The workflow this trigger starts on each tick. */
4
+ readonly name: string;
5
+ /** The cron expression driving the cadence. */
6
+ readonly cron: string;
7
+ /** The input each tick passes to the workflow. */
8
+ readonly input: unknown;
9
+ /** `'declarative'` (harvested from the workflow, reconciled on boot) or
10
+ * `'dynamic'` (registered at run time via `scheduleWorkflow`). */
11
+ readonly source: 'declarative' | 'dynamic';
21
12
  }
22
- /**
23
- * The set of agent names `eveAgent` accepts, derived from the augmentable
24
- * `AgentRegistry`. The tuple wrap (`[X] extends [never]`) defeats the
25
- * conditional-type distributivity a bare `keyof AgentRegistry extends never`
26
- * would trigger:
27
- *
28
- * - empty registry -> `string` (today's loose behavior: any name, checked at
29
- * runtime when the workflow resolves it against `AGENT_URLS`);
30
- * - augmented registry -> the union of declared agent names (typo = compile error).
31
- */
32
- type AgentName = [keyof AgentRegistry] extends [never] ? string : keyof AgentRegistry;
13
+ /** The runtime-injected bridge the imperative cron helpers reach. */
14
+ interface WorkflowScheduler {
15
+ /** Register (or upsert) a DYNAMIC repeatable trigger that starts `name` with
16
+ * `input` on the `cron` cadence. Idempotent by `name`. */
17
+ schedule(name: string, input: unknown, cron: string): Promise<void>;
18
+ /** Cancel a dynamic trigger by `name`. Resolves whether or not one existed. */
19
+ unschedule(name: string): Promise<void>;
20
+ /** List the active triggers declarative + dynamic. */
21
+ listSchedules(): Promise<ScheduledWorkflow[]>;
22
+ }
23
+ /** Plant (or clear, with `undefined`) the ambient scheduler. The runtime calls
24
+ * this on first dispatch; tests pass a fake. Last write wins. */
25
+ declare function setWorkflowScheduler(scheduler: WorkflowScheduler | undefined): void;
26
+ /** Return the bound ambient scheduler, or throw a clear error when none is bound
27
+ * (the imperative cron API was reached outside a running workflow runtime). */
28
+ declare function getWorkflowScheduler(): WorkflowScheduler;
33
29
 
34
30
  /**
35
31
  * Queue-level options for a workflow trigger.
@@ -87,33 +83,116 @@ declare function setWorkflowStarter(starter: WorkflowStarter | undefined): void;
87
83
  */
88
84
  declare function getWorkflowStarter(): WorkflowStarter;
89
85
 
90
- /** One active scheduled trigger, as `listSchedules()` reports it. */
91
- interface ScheduledWorkflow {
92
- /** The workflow this trigger starts on each tick. */
93
- readonly name: string;
94
- /** The cron expression driving the cadence. */
95
- readonly cron: string;
96
- /** The input each tick passes to the workflow. */
97
- readonly input: unknown;
98
- /** `'declarative'` (harvested from the workflow, reconciled on boot) or
99
- * `'dynamic'` (registered at run time via `scheduleWorkflow`). */
100
- readonly source: 'declarative' | 'dynamic';
86
+ /**
87
+ * Augmentable registry of the workspace's WORKFLOW names. By default it is empty,
88
+ * so `startWorkflow(name, ...)` / `startWorkflowAndWait(name, ...)` accept any
89
+ * `string` (today's behavior, validated only at runtime against the injected
90
+ * name→ref registry). `stackbone dev` generates an ambient
91
+ * `.stackbone/workflows.d.ts` from the project's `stackbone.config.ts` workflow
92
+ * list and augments this interface so the names become a closed set:
93
+ *
94
+ * declare module '@stackbone/sdk/workflow' {
95
+ * interface WorkflowRegistry {
96
+ * onboarding: true;
97
+ * qualifyLead: true;
98
+ * }
99
+ * }
100
+ *
101
+ * Once augmented, `startWorkflow('qualifyLead', ...)` is fine and
102
+ * `startWorkflow('typo', ...)` is a compile error — the editor also autocompletes
103
+ * the declared names. Mirrors the `AgentRegistry` augmentable-interface pattern
104
+ * used for `eveAgent`.
105
+ */
106
+ interface WorkflowRegistry {
101
107
  }
102
- /** The runtime-injected bridge the imperative cron helpers reach. */
103
- interface WorkflowScheduler {
104
- /** Register (or upsert) a DYNAMIC repeatable trigger that starts `name` with
105
- * `input` on the `cron` cadence. Idempotent by `name`. */
106
- schedule(name: string, input: unknown, cron: string): Promise<void>;
107
- /** Cancel a dynamic trigger by `name`. Resolves whether or not one existed. */
108
- unschedule(name: string): Promise<void>;
109
- /** List the active triggers declarative + dynamic. */
110
- listSchedules(): Promise<ScheduledWorkflow[]>;
108
+ /**
109
+ * The set of workflow names the trigger helpers accept, derived from the
110
+ * augmentable `WorkflowRegistry`. The tuple wrap (`[X] extends [never]`) defeats
111
+ * the conditional-type distributivity a bare `keyof WorkflowRegistry extends
112
+ * never` would trigger:
113
+ *
114
+ * - empty registry -> `string` (today's loose behavior: any name, checked at
115
+ * runtime when the workflow resolves it against the manifest);
116
+ * - augmented registry -> the union of declared workflow names (typo = compile error).
117
+ */
118
+ type WorkflowName = [keyof WorkflowRegistry] extends [never] ? string : keyof WorkflowRegistry;
119
+
120
+ /** Options for {@link startWorkflow}. See {@link WorkflowTriggerOptions}. */
121
+ type StartWorkflowOptions = WorkflowTriggerOptions;
122
+
123
+ /**
124
+ * Start the workflow named `name` with its own independent run and return its
125
+ * `{ runId }` immediately — fire-and-forget. The input is validated against the
126
+ * target's declared input schema BEFORE the run is enqueued; a name that does
127
+ * not resolve, or input that violates the schema, rejects without starting
128
+ * anything.
129
+ *
130
+ * `name` is typed `WorkflowName` — a loose `string` by default, narrowed to the
131
+ * workspace's declared workflow names once `stackbone dev` has generated
132
+ * `.stackbone/workflows.d.ts` (see `workflow-registry.ts`), so a typo becomes a
133
+ * compile error.
134
+ *
135
+ * MUST be called from inside a running workflow (the runtime binds the starter on
136
+ * first dispatch); calling it elsewhere throws.
137
+ *
138
+ * DURABILITY: the enqueue runs in a `"use step"`, so once it completes a parent
139
+ * restart resumes with the memoized `{ runId }` and does NOT re-enqueue. A crash
140
+ * WHILE the step is mid-flight re-runs it (at-least-once) — the same shape the
141
+ * eve-agent-from-step path has; for fire-and-forget fan-out this is acceptable.
142
+ * Use {@link startWorkflowAndWait} when you need the child's result.
143
+ */
144
+ declare function startWorkflow(name: WorkflowName, input: unknown, opts?: StartWorkflowOptions): Promise<WorkflowStartHandle>;
145
+
146
+ /** Options for {@link startWorkflowAndWait}. See {@link WorkflowTriggerOptions}. */
147
+ type StartWorkflowAndWaitOptions = WorkflowTriggerOptions;
148
+ /**
149
+ * Start the workflow named `name` with its own independent run and durably wait
150
+ * for it to finish, returning its terminal output (validated against the
151
+ * target's declared output schema). Use this when one workflow needs another's
152
+ * result to continue.
153
+ *
154
+ * The input is validated against the target's declared input schema BEFORE the
155
+ * run is enqueued; a name that does not resolve, or input that violates the
156
+ * schema, rejects without starting anything. `TOutput` lets the caller name the
157
+ * expected output shape (defaults to `unknown`).
158
+ *
159
+ * `name` is typed `WorkflowName` — narrowed to the workspace's declared workflow
160
+ * names once `stackbone dev` has generated `.stackbone/workflows.d.ts`. MUST be
161
+ * called from inside a running workflow.
162
+ */
163
+ declare function startWorkflowAndWait<TOutput = unknown>(name: WorkflowName, input: unknown, opts?: StartWorkflowAndWaitOptions): Promise<TOutput>;
164
+
165
+ /**
166
+ * Augmentable registry of the workspace's eve agent NAMES. By default it is
167
+ * empty, so `eveAgent(name)` accepts any `string` (today's behavior, validated
168
+ * only at runtime against the injected `AGENT_URLS` map). `stackbone dev`
169
+ * generates an ambient `.stackbone/agents.d.ts` from the project's
170
+ * `stackbone.config.ts` agent list and augments this interface so the names
171
+ * become a closed set:
172
+ *
173
+ * declare module '@stackbone/sdk/workflow' {
174
+ * interface AgentRegistry {
175
+ * support: true;
176
+ * 'lead-qualifier': true;
177
+ * }
178
+ * }
179
+ *
180
+ * Once augmented, `eveAgent('lead-qualifier')` is fine and `eveAgent('typo')` is
181
+ * a compile error — the editor also autocompletes the declared names. Mirrors the
182
+ * `ConfigRegistry` augmentable-interface pattern used for `client.config`.
183
+ */
184
+ interface AgentRegistry {
111
185
  }
112
- /** Plant (or clear, with `undefined`) the ambient scheduler. The runtime calls
113
- * this on first dispatch; tests pass a fake. Last write wins. */
114
- declare function setWorkflowScheduler(scheduler: WorkflowScheduler | undefined): void;
115
- /** Return the bound ambient scheduler, or throw a clear error when none is bound
116
- * (the imperative cron API was reached outside a running workflow runtime). */
117
- declare function getWorkflowScheduler(): WorkflowScheduler;
186
+ /**
187
+ * The set of agent names `eveAgent` accepts, derived from the augmentable
188
+ * `AgentRegistry`. The tuple wrap (`[X] extends [never]`) defeats the
189
+ * conditional-type distributivity a bare `keyof AgentRegistry extends never`
190
+ * would trigger:
191
+ *
192
+ * - empty registry -> `string` (today's loose behavior: any name, checked at
193
+ * runtime when the workflow resolves it against `AGENT_URLS`);
194
+ * - augmented registry -> the union of declared agent names (typo = compile error).
195
+ */
196
+ type AgentName = [keyof AgentRegistry] extends [never] ? string : keyof AgentRegistry;
118
197
 
119
- export { type AgentName as A, type ScheduledWorkflow as S, type WorkflowTriggerOptions as W, type WorkflowStartHandle as a, type AgentRegistry as b, type WorkflowScheduler as c, type WorkflowStarter as d, getWorkflowStarter as e, setWorkflowStarter as f, getWorkflowScheduler as g, setWorkflowScheduler as s };
198
+ export { type AgentName as A, type ScheduledWorkflow as S, type WorkflowName as W, type AgentRegistry as a, type StartWorkflowAndWaitOptions as b, type StartWorkflowOptions as c, type WorkflowRegistry as d, type WorkflowStartHandle as e, startWorkflowAndWait as f, type WorkflowScheduler as g, type WorkflowStarter as h, type WorkflowTriggerOptions as i, getWorkflowScheduler as j, getWorkflowStarter as k, setWorkflowScheduler as l, setWorkflowStarter as m, startWorkflow as s };
package/eve.cjs ADDED
@@ -0,0 +1,52 @@
1
+ 'use strict';
2
+
3
+ var openaiCompatible = require('@ai-sdk/openai-compatible');
4
+ var eve = require('eve');
5
+
6
+ var __defProp = Object.defineProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var DEFAULT_MODEL_CONTEXT_WINDOW_TOKENS = 2e5;
9
+ var STACKBONE_EXTERNAL_DEPENDENCIES = [
10
+ "@stackbone/sdk",
11
+ "eve*"
12
+ ];
13
+ var openrouter = openaiCompatible.createOpenAICompatible({
14
+ name: "openrouter",
15
+ baseURL: process.env["OPENROUTER_BASE_URL"] ?? "https://openrouter.ai/api/v1",
16
+ apiKey: process.env["OPENROUTER_API_KEY"]
17
+ });
18
+ function openrouterModel(modelId) {
19
+ return openrouter(modelId);
20
+ }
21
+ __name(openrouterModel, "openrouterModel");
22
+ function defineStackboneAgent(config) {
23
+ const { model, modelContextWindowTokens, build, ...rest } = config;
24
+ return eve.defineAgent({
25
+ ...rest,
26
+ model: typeof model === "string" ? openrouterModel(model) : model,
27
+ modelContextWindowTokens: modelContextWindowTokens ?? DEFAULT_MODEL_CONTEXT_WINDOW_TOKENS,
28
+ build: mergeExternalDependencies(build)
29
+ });
30
+ }
31
+ __name(defineStackboneAgent, "defineStackboneAgent");
32
+ function mergeExternalDependencies(build) {
33
+ const extra = build?.externalDependencies ?? [];
34
+ const externalDependencies = [
35
+ .../* @__PURE__ */ new Set([
36
+ ...STACKBONE_EXTERNAL_DEPENDENCIES,
37
+ ...extra
38
+ ])
39
+ ];
40
+ return {
41
+ ...build,
42
+ externalDependencies
43
+ };
44
+ }
45
+ __name(mergeExternalDependencies, "mergeExternalDependencies");
46
+
47
+ exports.DEFAULT_MODEL_CONTEXT_WINDOW_TOKENS = DEFAULT_MODEL_CONTEXT_WINDOW_TOKENS;
48
+ exports.STACKBONE_EXTERNAL_DEPENDENCIES = STACKBONE_EXTERNAL_DEPENDENCIES;
49
+ exports.defineStackboneAgent = defineStackboneAgent;
50
+ exports.openrouterModel = openrouterModel;
51
+ //# sourceMappingURL=eve.cjs.map
52
+ //# sourceMappingURL=eve.cjs.map
package/eve.cjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../libs/sdk/src/eve.ts"],"names":["DEFAULT_MODEL_CONTEXT_WINDOW_TOKENS","STACKBONE_EXTERNAL_DEPENDENCIES","openrouter","createOpenAICompatible","name","baseURL","process","env","apiKey","openrouterModel","modelId","defineStackboneAgent","config","model","modelContextWindowTokens","build","rest","defineAgent","mergeExternalDependencies","extra","externalDependencies","Set"],"mappings":";;;;;;;AA2CO,IAAMA,mCAAAA,GAAsC;AAS5C,IAAMC,+BAAAA,GAAqD;AAAC,EAAA,gBAAA;AAAkB,EAAA;;AAMrF,IAAMC,aAAaC,uCAAAA,CAAuB;EACxCC,IAAAA,EAAM,YAAA;EACNC,OAAAA,EAASC,OAAAA,CAAQC,GAAAA,CAAI,qBAAA,CAAA,IAA0B,8BAAA;EAC/CC,MAAAA,EAAQF,OAAAA,CAAQC,IAAI,oBAAA;AACtB,CAAA,CAAA;AAOO,SAASE,gBAAgBC,OAAAA,EAAe;AAC7C,EAAA,OAAOR,WAAWQ,OAAAA,CAAAA;AACpB;AAFgBD,MAAAA,CAAAA,eAAAA,EAAAA,iBAAAA,CAAAA;AAoBT,SAASE,qBAAqBC,MAAAA,EAA4B;AAC/D,EAAA,MAAM,EAAEC,KAAAA,EAAOC,wBAAAA,EAA0BC,KAAAA,EAAO,GAAGC,MAAAA,GAASJ,MAAAA;AAC5D,EAAA,OAAOK,eAAAA,CAAY;IACjB,GAAGD,IAAAA;AACHH,IAAAA,KAAAA,EAAO,OAAOA,KAAAA,KAAU,QAAA,GAAWJ,eAAAA,CAAgBI,KAAAA,CAAAA,GAASA,KAAAA;AAC5DC,IAAAA,wBAAAA,EAA0BA,wBAAAA,IAA4Bd,mCAAAA;AACtDe,IAAAA,KAAAA,EAAOG,0BAA0BH,KAAAA;GACnC,CAAA;AACF;AARgBJ,MAAAA,CAAAA,oBAAAA,EAAAA,sBAAAA,CAAAA;AAchB,SAASO,0BAA0BH,KAAAA,EAAuC;AACxE,EAAA,MAAMI,KAAAA,GAAQJ,KAAAA,EAAOK,oBAAAA,IAAwB,EAAA;AAC7C,EAAA,MAAMA,oBAAAA,GAAuB;AAAI,IAAA,mBAAA,IAAIC,GAAAA,CAAI;AAAIpB,MAAAA,GAAAA,+BAAAA;AAAoCkB,MAAAA,GAAAA;AAAM,KAAA;;AACvF,EAAA,OAAO;IAAE,GAAGJ,KAAAA;AAAOK,IAAAA;AAAqB,GAAA;AAC1C;AAJSF,MAAAA,CAAAA,yBAAAA,EAAAA,2BAAAA,CAAAA","file":"eve.cjs","sourcesContent":["// `@stackbone/sdk/eve` — the eve-agent authoring subpath entrypoint.\n//\n// Wraps eve's `defineAgent` with the Stackbone defaults every published eve\n// agent otherwise hand-copies, so an `agent.ts` collapses to:\n//\n// import { defineStackboneAgent } from '@stackbone/sdk/eve';\n//\n// export default defineStackboneAgent({ model: 'anthropic/claude-haiku-4.5' });\n//\n// The helper injects three things:\n//\n// 1. The OpenRouter model bridge. eve routes a BARE model string through the\n// Vercel AI Gateway — it does NOT speak OpenRouter. Stackbone injects the\n// org's managed OpenRouter sub-key as `OPENROUTER_API_KEY`, so we pass a\n// provider INSTANCE (eve routes those directly). Pass `model` as a string id\n// and the helper wraps it with the OpenRouter provider; pass a built\n// `LanguageModel` and it is used verbatim (escape hatch for another provider).\n// 2. `modelContextWindowTokens`. A custom provider carries no AI-Gateway\n// context-window metadata, so eve cannot size the compaction threshold.\n// Defaults to 200_000 (Claude's window); override per agent.\n// 3. `build.externalDependencies`. `@stackbone/sdk` + `eve*` stay external so\n// the published build traces them fully — one SDK AsyncLocalStorage (per-run\n// logs keep their run id) and a complete eve `#`-subpath trace (no\n// ERR_MODULE_NOT_FOUND at boot). `stackbone publish` ENFORCES both; the\n// helper guarantees they are always present and merges in any extra entries.\n//\n// Like `@stackbone/sdk/workflow`, this subpath statically imports the `eve` and\n// `@ai-sdk/openai-compatible` peer dependencies, so it is kept OFF the main\n// `@stackbone/sdk` barrel: a classic tool-only agent imports `@stackbone/sdk`\n// without eager-loading peers it never installed. The build keeps both external\n// (their types come from the sibling `eve-peer.d.ts` /\n// `ai-sdk-openai-compatible-peer.d.ts` shims).\n\nimport { createOpenAICompatible } from '@ai-sdk/openai-compatible';\nimport { defineAgent } from 'eve';\nimport type { AgentBuildDefinition, AgentDefinition, AgentModelDefinition } from 'eve';\n\n/**\n * Default context window (tokens) for the OpenRouter Claude models Stackbone\n * provisions. A custom provider carries no AI-Gateway metadata, so eve needs\n * this to size the conversation-compaction threshold. Override per agent via\n * `modelContextWindowTokens` when targeting a model with a different window.\n */\nexport const DEFAULT_MODEL_CONTEXT_WINDOW_TOKENS = 200_000;\n\n/**\n * External dependencies every published eve agent keeps out of its bundle.\n * `@stackbone/sdk` stays external so the agent shares ONE invocation-context\n * AsyncLocalStorage (per-run logs keep their run id); `eve*` forces a full trace\n * of eve's `#`-subpath imports (no ERR_MODULE_NOT_FOUND at boot). `stackbone\n * publish` enforces both, so the helper always injects them.\n */\nexport const STACKBONE_EXTERNAL_DEPENDENCIES: readonly string[] = ['@stackbone/sdk', 'eve*'];\n\n// The OpenRouter provider bridge, constructed once per module load. Stackbone\n// injects the org's managed sub-key as `OPENROUTER_API_KEY`; OpenRouter exposes\n// an OpenAI-compatible API, so the AI SDK's openai-compatible provider talks to\n// it directly.\nconst openrouter = createOpenAICompatible({\n name: 'openrouter',\n baseURL: process.env['OPENROUTER_BASE_URL'] ?? 'https://openrouter.ai/api/v1',\n apiKey: process.env['OPENROUTER_API_KEY'],\n});\n\n/**\n * Resolve an OpenRouter model INSTANCE by id — the same bridge\n * `defineStackboneAgent` applies to a string `model`, exposed for workflow steps\n * that call an LLM directly (e.g. `generateText({ model: openrouterModel(id) })`).\n */\nexport function openrouterModel(modelId: string): AgentModelDefinition {\n return openrouter(modelId);\n}\n\n/**\n * Config accepted by {@link defineStackboneAgent}: every eve `AgentDefinition`\n * field, except `model` also accepts a bare OpenRouter model id (string) the\n * helper wraps with the provider bridge. `modelContextWindowTokens` and `build`\n * are optional — the helper fills sensible defaults.\n */\nexport type StackboneAgentConfig = Omit<AgentDefinition, 'model'> & {\n readonly model: string | AgentModelDefinition;\n};\n\n/**\n * Define an eve agent with Stackbone's defaults pre-applied: the OpenRouter\n * model bridge, the default context window, and the required external\n * dependencies. Returns the same object shape eve's `defineAgent` produces, so\n * the agent file `export default`s it unchanged.\n */\nexport function defineStackboneAgent(config: StackboneAgentConfig): AgentDefinition {\n const { model, modelContextWindowTokens, build, ...rest } = config;\n return defineAgent({\n ...rest,\n model: typeof model === 'string' ? openrouterModel(model) : model,\n modelContextWindowTokens: modelContextWindowTokens ?? DEFAULT_MODEL_CONTEXT_WINDOW_TOKENS,\n build: mergeExternalDependencies(build),\n });\n}\n\n/**\n * Merge the always-required Stackbone external dependencies with any extra ones\n * a creator declares, de-duplicated and order-stable (Stackbone's first).\n */\nfunction mergeExternalDependencies(build: AgentBuildDefinition | undefined): AgentBuildDefinition {\n const extra = build?.externalDependencies ?? [];\n const externalDependencies = [...new Set([...STACKBONE_EXTERNAL_DEPENDENCIES, ...extra])];\n return { ...build, externalDependencies };\n}\n"]}
package/eve.d.cts ADDED
@@ -0,0 +1,41 @@
1
+ import { AgentDefinition, AgentModelDefinition } from 'eve';
2
+
3
+ /**
4
+ * Default context window (tokens) for the OpenRouter Claude models Stackbone
5
+ * provisions. A custom provider carries no AI-Gateway metadata, so eve needs
6
+ * this to size the conversation-compaction threshold. Override per agent via
7
+ * `modelContextWindowTokens` when targeting a model with a different window.
8
+ */
9
+ declare const DEFAULT_MODEL_CONTEXT_WINDOW_TOKENS = 200000;
10
+ /**
11
+ * External dependencies every published eve agent keeps out of its bundle.
12
+ * `@stackbone/sdk` stays external so the agent shares ONE invocation-context
13
+ * AsyncLocalStorage (per-run logs keep their run id); `eve*` forces a full trace
14
+ * of eve's `#`-subpath imports (no ERR_MODULE_NOT_FOUND at boot). `stackbone
15
+ * publish` enforces both, so the helper always injects them.
16
+ */
17
+ declare const STACKBONE_EXTERNAL_DEPENDENCIES: readonly string[];
18
+ /**
19
+ * Resolve an OpenRouter model INSTANCE by id — the same bridge
20
+ * `defineStackboneAgent` applies to a string `model`, exposed for workflow steps
21
+ * that call an LLM directly (e.g. `generateText({ model: openrouterModel(id) })`).
22
+ */
23
+ declare function openrouterModel(modelId: string): AgentModelDefinition;
24
+ /**
25
+ * Config accepted by {@link defineStackboneAgent}: every eve `AgentDefinition`
26
+ * field, except `model` also accepts a bare OpenRouter model id (string) the
27
+ * helper wraps with the provider bridge. `modelContextWindowTokens` and `build`
28
+ * are optional — the helper fills sensible defaults.
29
+ */
30
+ type StackboneAgentConfig = Omit<AgentDefinition, 'model'> & {
31
+ readonly model: string | AgentModelDefinition;
32
+ };
33
+ /**
34
+ * Define an eve agent with Stackbone's defaults pre-applied: the OpenRouter
35
+ * model bridge, the default context window, and the required external
36
+ * dependencies. Returns the same object shape eve's `defineAgent` produces, so
37
+ * the agent file `export default`s it unchanged.
38
+ */
39
+ declare function defineStackboneAgent(config: StackboneAgentConfig): AgentDefinition;
40
+
41
+ export { DEFAULT_MODEL_CONTEXT_WINDOW_TOKENS, STACKBONE_EXTERNAL_DEPENDENCIES, type StackboneAgentConfig, defineStackboneAgent, openrouterModel };
package/eve.d.ts ADDED
@@ -0,0 +1,41 @@
1
+ import { AgentDefinition, AgentModelDefinition } from 'eve';
2
+
3
+ /**
4
+ * Default context window (tokens) for the OpenRouter Claude models Stackbone
5
+ * provisions. A custom provider carries no AI-Gateway metadata, so eve needs
6
+ * this to size the conversation-compaction threshold. Override per agent via
7
+ * `modelContextWindowTokens` when targeting a model with a different window.
8
+ */
9
+ declare const DEFAULT_MODEL_CONTEXT_WINDOW_TOKENS = 200000;
10
+ /**
11
+ * External dependencies every published eve agent keeps out of its bundle.
12
+ * `@stackbone/sdk` stays external so the agent shares ONE invocation-context
13
+ * AsyncLocalStorage (per-run logs keep their run id); `eve*` forces a full trace
14
+ * of eve's `#`-subpath imports (no ERR_MODULE_NOT_FOUND at boot). `stackbone
15
+ * publish` enforces both, so the helper always injects them.
16
+ */
17
+ declare const STACKBONE_EXTERNAL_DEPENDENCIES: readonly string[];
18
+ /**
19
+ * Resolve an OpenRouter model INSTANCE by id — the same bridge
20
+ * `defineStackboneAgent` applies to a string `model`, exposed for workflow steps
21
+ * that call an LLM directly (e.g. `generateText({ model: openrouterModel(id) })`).
22
+ */
23
+ declare function openrouterModel(modelId: string): AgentModelDefinition;
24
+ /**
25
+ * Config accepted by {@link defineStackboneAgent}: every eve `AgentDefinition`
26
+ * field, except `model` also accepts a bare OpenRouter model id (string) the
27
+ * helper wraps with the provider bridge. `modelContextWindowTokens` and `build`
28
+ * are optional — the helper fills sensible defaults.
29
+ */
30
+ type StackboneAgentConfig = Omit<AgentDefinition, 'model'> & {
31
+ readonly model: string | AgentModelDefinition;
32
+ };
33
+ /**
34
+ * Define an eve agent with Stackbone's defaults pre-applied: the OpenRouter
35
+ * model bridge, the default context window, and the required external
36
+ * dependencies. Returns the same object shape eve's `defineAgent` produces, so
37
+ * the agent file `export default`s it unchanged.
38
+ */
39
+ declare function defineStackboneAgent(config: StackboneAgentConfig): AgentDefinition;
40
+
41
+ export { DEFAULT_MODEL_CONTEXT_WINDOW_TOKENS, STACKBONE_EXTERNAL_DEPENDENCIES, type StackboneAgentConfig, defineStackboneAgent, openrouterModel };
package/eve.js ADDED
@@ -0,0 +1,47 @@
1
+ import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
2
+ import { defineAgent } from 'eve';
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var DEFAULT_MODEL_CONTEXT_WINDOW_TOKENS = 2e5;
7
+ var STACKBONE_EXTERNAL_DEPENDENCIES = [
8
+ "@stackbone/sdk",
9
+ "eve*"
10
+ ];
11
+ var openrouter = createOpenAICompatible({
12
+ name: "openrouter",
13
+ baseURL: process.env["OPENROUTER_BASE_URL"] ?? "https://openrouter.ai/api/v1",
14
+ apiKey: process.env["OPENROUTER_API_KEY"]
15
+ });
16
+ function openrouterModel(modelId) {
17
+ return openrouter(modelId);
18
+ }
19
+ __name(openrouterModel, "openrouterModel");
20
+ function defineStackboneAgent(config) {
21
+ const { model, modelContextWindowTokens, build, ...rest } = config;
22
+ return defineAgent({
23
+ ...rest,
24
+ model: typeof model === "string" ? openrouterModel(model) : model,
25
+ modelContextWindowTokens: modelContextWindowTokens ?? DEFAULT_MODEL_CONTEXT_WINDOW_TOKENS,
26
+ build: mergeExternalDependencies(build)
27
+ });
28
+ }
29
+ __name(defineStackboneAgent, "defineStackboneAgent");
30
+ function mergeExternalDependencies(build) {
31
+ const extra = build?.externalDependencies ?? [];
32
+ const externalDependencies = [
33
+ .../* @__PURE__ */ new Set([
34
+ ...STACKBONE_EXTERNAL_DEPENDENCIES,
35
+ ...extra
36
+ ])
37
+ ];
38
+ return {
39
+ ...build,
40
+ externalDependencies
41
+ };
42
+ }
43
+ __name(mergeExternalDependencies, "mergeExternalDependencies");
44
+
45
+ export { DEFAULT_MODEL_CONTEXT_WINDOW_TOKENS, STACKBONE_EXTERNAL_DEPENDENCIES, defineStackboneAgent, openrouterModel };
46
+ //# sourceMappingURL=eve.js.map
47
+ //# sourceMappingURL=eve.js.map