@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.
package/eve.js.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,sBAAAA,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,WAAAA,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.js","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/index.cjs CHANGED
@@ -16017,6 +16017,71 @@ var SecretsFacade = class {
16017
16017
  }
16018
16018
  }
16019
16019
  };
16020
+
16021
+ // src/runtime/workflow-scheduler.ts
16022
+ var current;
16023
+ function setWorkflowScheduler(scheduler) {
16024
+ current = scheduler;
16025
+ }
16026
+ __name(setWorkflowScheduler, "setWorkflowScheduler");
16027
+ function getWorkflowScheduler() {
16028
+ if (!current) {
16029
+ throw new Error("No workflow scheduler is bound. `scheduleWorkflow` / `unschedule` / `listSchedules` can only be called inside a running workflow runtime \u2014 the runtime binds the scheduler on its first dispatch.");
16030
+ }
16031
+ return current;
16032
+ }
16033
+ __name(getWorkflowScheduler, "getWorkflowScheduler");
16034
+
16035
+ // src/surfaces/agent-local/workflows/schedule-workflow.ts
16036
+ async function scheduleWorkflow(name, input, cron) {
16037
+ return getWorkflowScheduler().schedule(name, input, cron);
16038
+ }
16039
+ __name(scheduleWorkflow, "scheduleWorkflow");
16040
+ async function unschedule(name) {
16041
+ return getWorkflowScheduler().unschedule(name);
16042
+ }
16043
+ __name(unschedule, "unschedule");
16044
+ async function listSchedules() {
16045
+ return getWorkflowScheduler().listSchedules();
16046
+ }
16047
+ __name(listSchedules, "listSchedules");
16048
+
16049
+ // src/runtime/workflow-starter.ts
16050
+ var current2;
16051
+ function setWorkflowStarter(starter) {
16052
+ current2 = starter;
16053
+ }
16054
+ __name(setWorkflowStarter, "setWorkflowStarter");
16055
+ function getWorkflowStarter() {
16056
+ if (!current2) {
16057
+ throw new Error("No workflow starter is bound. `startWorkflow` / `startWorkflowAndWait` can only be called from inside a running workflow \u2014 the runtime binds the starter on its first dispatch.");
16058
+ }
16059
+ return current2;
16060
+ }
16061
+ __name(getWorkflowStarter, "getWorkflowStarter");
16062
+
16063
+ // src/surfaces/agent-local/workflows/start-workflow.ts
16064
+ async function startWorkflow(name, input, opts) {
16065
+ "use step";
16066
+ return getWorkflowStarter().start(name, input, opts);
16067
+ }
16068
+ __name(startWorkflow, "startWorkflow");
16069
+
16070
+ // src/surfaces/agent-local/workflows/start-workflow-and-wait.ts
16071
+ async function startWorkflowAndWait(name, input, opts) {
16072
+ "use step";
16073
+ return await getWorkflowStarter().startAndWait(name, input, opts);
16074
+ }
16075
+ __name(startWorkflowAndWait, "startWorkflowAndWait");
16076
+
16077
+ // src/surfaces/agent-local/workflows/workflows-accessor.ts
16078
+ var workflows = {
16079
+ start: startWorkflow,
16080
+ startAndWait: startWorkflowAndWait,
16081
+ schedule: scheduleWorkflow,
16082
+ unschedule,
16083
+ listSchedules
16084
+ };
16020
16085
  function agentRegistry() {
16021
16086
  const raw = process.env["AGENT_URLS"];
16022
16087
  if (!raw) {
@@ -17146,6 +17211,24 @@ var StackboneClient = class {
17146
17211
  return agent;
17147
17212
  }
17148
17213
  /**
17214
+ * Namespaced workflow trigger + schedule surface — `stackbone.workflows.start(...)`
17215
+ * / `.startAndWait(...)` / `.schedule(...)` / `.unschedule(...)` / `.listSchedules()`.
17216
+ * Start another workflow by name (fire-and-forget or durable sub-routine) and
17217
+ * manage dynamic cron triggers, all from inside a running workflow.
17218
+ *
17219
+ * These are peer-free shims over the ambient `WorkflowStarter` / `WorkflowScheduler`
17220
+ * the runtime injects on first dispatch — they import NO `workflow` / `eve` peer,
17221
+ * so (like `connection` / `agent`) they are wired directly onto the client and
17222
+ * pull nothing new into the main barrel. This is the namespaced form of the loose
17223
+ * `startWorkflow(...)` / `scheduleWorkflow(...)` exports (now `@deprecated`) on the
17224
+ * `@stackbone/sdk/workflow` subpath; both delegate to the same implementation, so
17225
+ * `start` / `startAndWait` keep their `"use step"` durability. The peer-bound
17226
+ * authoring API (`requestApproval` / `defineHook` / `sleep`) stays on that subpath.
17227
+ */
17228
+ get workflows() {
17229
+ return workflows;
17230
+ }
17231
+ /**
17149
17232
  * Pending surface — runtime not built. Every method returns
17150
17233
  * `not_implemented`. Mem0 is a third-party integration, not a Stackbone
17151
17234
  * Agent Protocol capability, so this surface is intentionally not gated.
@@ -17549,34 +17632,6 @@ function runWithCallerId(id, fn, options) {
17549
17632
  }
17550
17633
  __name(runWithCallerId, "runWithCallerId");
17551
17634
 
17552
- // src/runtime/workflow-starter.ts
17553
- var current;
17554
- function setWorkflowStarter(starter) {
17555
- current = starter;
17556
- }
17557
- __name(setWorkflowStarter, "setWorkflowStarter");
17558
- function getWorkflowStarter() {
17559
- if (!current) {
17560
- throw new Error("No workflow starter is bound. `startWorkflow` / `startWorkflowAndWait` can only be called from inside a running workflow \u2014 the runtime binds the starter on its first dispatch.");
17561
- }
17562
- return current;
17563
- }
17564
- __name(getWorkflowStarter, "getWorkflowStarter");
17565
-
17566
- // src/runtime/workflow-scheduler.ts
17567
- var current2;
17568
- function setWorkflowScheduler(scheduler) {
17569
- current2 = scheduler;
17570
- }
17571
- __name(setWorkflowScheduler, "setWorkflowScheduler");
17572
- function getWorkflowScheduler() {
17573
- if (!current2) {
17574
- throw new Error("No workflow scheduler is bound. `scheduleWorkflow` / `unschedule` / `listSchedules` can only be called inside a running workflow runtime \u2014 the runtime binds the scheduler on its first dispatch.");
17575
- }
17576
- return current2;
17577
- }
17578
- __name(getWorkflowScheduler, "getWorkflowScheduler");
17579
-
17580
17635
  // src/runtime/ambient-client.ts
17581
17636
  var cached;
17582
17637
  function resolveAmbientClient() {