@dudousxd/nestjs-agent 0.9.0 → 0.10.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,6 +1,6 @@
1
1
  import { LlmStepEnvelope, ModelTurnResult, ToolStepEnvelope, AgentStore, AgentRunInput, AgentRunner, Decision } from '@dudousxd/nestjs-agent-core';
2
2
  import { WorkflowCtx } from '@dudousxd/nestjs-durable-core';
3
- import { A as AgentDepsFactory, a as AgentModuleOptions } from '../agent-deps.factory-DNslT7_J.cjs';
3
+ import { A as AgentDepsFactory, a as AgentSurface, b as AgentModuleOptions } from '../agent-deps.factory-D7GdhqdK.cjs';
4
4
  import { WorkflowService } from '@dudousxd/nestjs-durable';
5
5
  import { DynamicModule } from '@nestjs/common';
6
6
 
@@ -85,7 +85,7 @@ declare class AgentRunWorkflow {
85
85
  private readonly store;
86
86
  private readonly steps;
87
87
  private readonly dispatchedSteps;
88
- constructor(factory: AgentDepsFactory, store: AgentStore, steps: AgentRunSteps, dispatchedSteps: boolean);
88
+ constructor(factory: AgentDepsFactory, store: AgentStore, steps: AgentRunSteps | undefined, dispatchedSteps: boolean);
89
89
  run(ctx: WorkflowCtx, input: AgentRunInput): Promise<{
90
90
  text: string;
91
91
  }>;
@@ -106,6 +106,31 @@ declare class DurableAgentRunner implements AgentRunner {
106
106
  cancel(_runId: string): Promise<void>;
107
107
  }
108
108
 
109
+ /**
110
+ * `AgentDurableModule.forRoot()` options. `surface` mirrors `AgentModuleOptions.surface` — it has
111
+ * to be its OWN option here (not read off the shared `AGENT_OPTIONS` provider) because Nest builds
112
+ * a module's provider LIST at static/decoration time, before any DI value (including
113
+ * `AGENT_OPTIONS`) exists to read; there is no way to make a `providers` array conditional on an
114
+ * injected value. Keep both in sync — `agentDurable()` (`./agent-durable.js`) does this
115
+ * automatically for the one-call setup; importing `AgentModule`/`AgentDurableModule` separately
116
+ * means passing `surface` to both by hand.
117
+ */
118
+ interface AgentDurableModuleOptions {
119
+ /**
120
+ * Omit (or `'engine'`/`'both'`) for today's full wiring, unconditionally — identical to importing
121
+ * the bare `AgentDurableModule` class (registers `agent.run` AND `AgentRunSteps.llm`/`.tool`).
122
+ *
123
+ * `'http'` registers the `agent.run` WORKFLOW (so `WorkflowService.start(AgentRunWorkflow, …)`
124
+ * still works — `engine.start` requires local registration to validate/persist a new run, even
125
+ * on an enqueue-only pod) but does NOT provide `AgentRunSteps` — the fix for the flip incident
126
+ * this option exists for: an API pod that also registered the dispatched-step handlers
127
+ * subscribed their queues and ran LLM/tool work meant for the worker fleet. Pair `surface: 'http'`
128
+ * with the durable `DurableModule.forRoot({ drive: false })` enqueue-only config so this pod also
129
+ * never DRIVES (polls/executes) the run it just registered — registration alone only satisfies
130
+ * `start()`'s bookkeeping, it doesn't make this pod execute anything on its own.
131
+ */
132
+ surface?: AgentSurface;
133
+ }
109
134
  /**
110
135
  * Opt-in durable runner. Import this alongside `AgentModule.forRoot({ durable: true })` and a
111
136
  * configured `DurableModule`. It registers the `agent.run` workflow (discovered by DurableModule)
@@ -114,15 +139,20 @@ declare class DurableAgentRunner implements AgentRunner {
114
139
  *
115
140
  * Always provides `AgentRunSteps` regardless of `dispatchedSteps` — the worker group it serves
116
141
  * (`AgentRunSteps.llm`/`.tool`) must never be orphaned by a config flag the durable step registrar
117
- * can't see ahead of time.
142
+ * can't see ahead of time. This is the FULL ('both'/'engine'-equivalent) wiring: bare-importing this
143
+ * class (no `forRoot()` call) always gets it, unconditionally — `forRoot({ surface: 'http' })` is
144
+ * the only form that diverges (see `AgentDurableHttpModule` above).
118
145
  */
119
146
  declare class AgentDurableModule {
120
147
  /**
121
- * The dynamic form used by the `agentDurable` helper. The module needs no configuration of its
122
- * own (its providers come from the decorator above), so this just yields the module reference —
123
- * importing `AgentDurableModule` directly stays equivalent.
148
+ * `surface: 'http'` returns the reduced `AgentDurableHttpModule` wiring (no `AgentRunSteps`);
149
+ * everything else (omitted, `'engine'`, `'both'`) returns this module's own full wiring — the
150
+ * class's `@Module` providers above merge in regardless of which DynamicModule shape a caller
151
+ * imports (Nest merges a class's static provider list with whatever a self-referencing
152
+ * `DynamicModule` adds), which is exactly why the reduced case has to be a DIFFERENT module class
153
+ * rather than a conditional subset of this one's own decorator.
124
154
  */
125
- static forRoot(): DynamicModule;
155
+ static forRoot(options?: AgentDurableModuleOptions): DynamicModule;
126
156
  }
127
157
 
128
158
  /**
@@ -134,7 +164,10 @@ declare class AgentDurableModule {
134
164
  *
135
165
  * It wires `AgentModule.forRoot({ ...options, durable: true })` together with `AgentDurableModule`,
136
166
  * the equivalent of importing both by hand. A configured `DurableModule` is still required. The
137
- * durable runner has no configuration of its own, so `options` is exactly the agent options.
167
+ * durable runner has no configuration of its own beyond the agent options, so `options` is exactly
168
+ * `AgentModuleOptions` — including `surface`, which this helper threads to BOTH calls so a consumer
169
+ * sets it in exactly one place (see `AgentModuleOptions.surface` / `AgentDurableModuleOptions.surface`
170
+ * for why each needs its own copy of the value rather than one reading it off the other via DI).
138
171
  */
139
172
  declare function agentDurable(options: AgentModuleOptions): DynamicModule[];
140
173
 
@@ -148,4 +181,4 @@ declare function agentDurable(options: AgentModuleOptions): DynamicModule[];
148
181
  */
149
182
  declare const AGENT_DISPATCHED_STEPS: unique symbol;
150
183
 
151
- export { AGENT_DISPATCHED_STEPS, AgentDurableModule, AgentRunSteps, AgentRunWorkflow, type DispatchedLlmInput, type DispatchedToolInput, DurableAgentRunner, agentDurable };
184
+ export { AGENT_DISPATCHED_STEPS, AgentDurableModule, type AgentDurableModuleOptions, AgentRunSteps, AgentRunWorkflow, type DispatchedLlmInput, type DispatchedToolInput, DurableAgentRunner, agentDurable };
@@ -1,6 +1,6 @@
1
1
  import { LlmStepEnvelope, ModelTurnResult, ToolStepEnvelope, AgentStore, AgentRunInput, AgentRunner, Decision } from '@dudousxd/nestjs-agent-core';
2
2
  import { WorkflowCtx } from '@dudousxd/nestjs-durable-core';
3
- import { A as AgentDepsFactory, a as AgentModuleOptions } from '../agent-deps.factory-DNslT7_J.js';
3
+ import { A as AgentDepsFactory, a as AgentSurface, b as AgentModuleOptions } from '../agent-deps.factory-D7GdhqdK.js';
4
4
  import { WorkflowService } from '@dudousxd/nestjs-durable';
5
5
  import { DynamicModule } from '@nestjs/common';
6
6
 
@@ -85,7 +85,7 @@ declare class AgentRunWorkflow {
85
85
  private readonly store;
86
86
  private readonly steps;
87
87
  private readonly dispatchedSteps;
88
- constructor(factory: AgentDepsFactory, store: AgentStore, steps: AgentRunSteps, dispatchedSteps: boolean);
88
+ constructor(factory: AgentDepsFactory, store: AgentStore, steps: AgentRunSteps | undefined, dispatchedSteps: boolean);
89
89
  run(ctx: WorkflowCtx, input: AgentRunInput): Promise<{
90
90
  text: string;
91
91
  }>;
@@ -106,6 +106,31 @@ declare class DurableAgentRunner implements AgentRunner {
106
106
  cancel(_runId: string): Promise<void>;
107
107
  }
108
108
 
109
+ /**
110
+ * `AgentDurableModule.forRoot()` options. `surface` mirrors `AgentModuleOptions.surface` — it has
111
+ * to be its OWN option here (not read off the shared `AGENT_OPTIONS` provider) because Nest builds
112
+ * a module's provider LIST at static/decoration time, before any DI value (including
113
+ * `AGENT_OPTIONS`) exists to read; there is no way to make a `providers` array conditional on an
114
+ * injected value. Keep both in sync — `agentDurable()` (`./agent-durable.js`) does this
115
+ * automatically for the one-call setup; importing `AgentModule`/`AgentDurableModule` separately
116
+ * means passing `surface` to both by hand.
117
+ */
118
+ interface AgentDurableModuleOptions {
119
+ /**
120
+ * Omit (or `'engine'`/`'both'`) for today's full wiring, unconditionally — identical to importing
121
+ * the bare `AgentDurableModule` class (registers `agent.run` AND `AgentRunSteps.llm`/`.tool`).
122
+ *
123
+ * `'http'` registers the `agent.run` WORKFLOW (so `WorkflowService.start(AgentRunWorkflow, …)`
124
+ * still works — `engine.start` requires local registration to validate/persist a new run, even
125
+ * on an enqueue-only pod) but does NOT provide `AgentRunSteps` — the fix for the flip incident
126
+ * this option exists for: an API pod that also registered the dispatched-step handlers
127
+ * subscribed their queues and ran LLM/tool work meant for the worker fleet. Pair `surface: 'http'`
128
+ * with the durable `DurableModule.forRoot({ drive: false })` enqueue-only config so this pod also
129
+ * never DRIVES (polls/executes) the run it just registered — registration alone only satisfies
130
+ * `start()`'s bookkeeping, it doesn't make this pod execute anything on its own.
131
+ */
132
+ surface?: AgentSurface;
133
+ }
109
134
  /**
110
135
  * Opt-in durable runner. Import this alongside `AgentModule.forRoot({ durable: true })` and a
111
136
  * configured `DurableModule`. It registers the `agent.run` workflow (discovered by DurableModule)
@@ -114,15 +139,20 @@ declare class DurableAgentRunner implements AgentRunner {
114
139
  *
115
140
  * Always provides `AgentRunSteps` regardless of `dispatchedSteps` — the worker group it serves
116
141
  * (`AgentRunSteps.llm`/`.tool`) must never be orphaned by a config flag the durable step registrar
117
- * can't see ahead of time.
142
+ * can't see ahead of time. This is the FULL ('both'/'engine'-equivalent) wiring: bare-importing this
143
+ * class (no `forRoot()` call) always gets it, unconditionally — `forRoot({ surface: 'http' })` is
144
+ * the only form that diverges (see `AgentDurableHttpModule` above).
118
145
  */
119
146
  declare class AgentDurableModule {
120
147
  /**
121
- * The dynamic form used by the `agentDurable` helper. The module needs no configuration of its
122
- * own (its providers come from the decorator above), so this just yields the module reference —
123
- * importing `AgentDurableModule` directly stays equivalent.
148
+ * `surface: 'http'` returns the reduced `AgentDurableHttpModule` wiring (no `AgentRunSteps`);
149
+ * everything else (omitted, `'engine'`, `'both'`) returns this module's own full wiring — the
150
+ * class's `@Module` providers above merge in regardless of which DynamicModule shape a caller
151
+ * imports (Nest merges a class's static provider list with whatever a self-referencing
152
+ * `DynamicModule` adds), which is exactly why the reduced case has to be a DIFFERENT module class
153
+ * rather than a conditional subset of this one's own decorator.
124
154
  */
125
- static forRoot(): DynamicModule;
155
+ static forRoot(options?: AgentDurableModuleOptions): DynamicModule;
126
156
  }
127
157
 
128
158
  /**
@@ -134,7 +164,10 @@ declare class AgentDurableModule {
134
164
  *
135
165
  * It wires `AgentModule.forRoot({ ...options, durable: true })` together with `AgentDurableModule`,
136
166
  * the equivalent of importing both by hand. A configured `DurableModule` is still required. The
137
- * durable runner has no configuration of its own, so `options` is exactly the agent options.
167
+ * durable runner has no configuration of its own beyond the agent options, so `options` is exactly
168
+ * `AgentModuleOptions` — including `surface`, which this helper threads to BOTH calls so a consumer
169
+ * sets it in exactly one place (see `AgentModuleOptions.surface` / `AgentDurableModuleOptions.surface`
170
+ * for why each needs its own copy of the value rather than one reading it off the other via DI).
138
171
  */
139
172
  declare function agentDurable(options: AgentModuleOptions): DynamicModule[];
140
173
 
@@ -148,4 +181,4 @@ declare function agentDurable(options: AgentModuleOptions): DynamicModule[];
148
181
  */
149
182
  declare const AGENT_DISPATCHED_STEPS: unique symbol;
150
183
 
151
- export { AGENT_DISPATCHED_STEPS, AgentDurableModule, AgentRunSteps, AgentRunWorkflow, type DispatchedLlmInput, type DispatchedToolInput, DurableAgentRunner, agentDurable };
184
+ export { AGENT_DISPATCHED_STEPS, AgentDurableModule, type AgentDurableModuleOptions, AgentRunSteps, AgentRunWorkflow, type DispatchedLlmInput, type DispatchedToolInput, DurableAgentRunner, agentDurable };