agent-neckbeard 1.1.10 → 1.1.12

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/dist/index.d.cts CHANGED
@@ -85,6 +85,63 @@ interface BuildOptions {
85
85
  */
86
86
  autoDetectExternal?: boolean;
87
87
  }
88
+ interface NeckbeardNextConfigOptions {
89
+ /**
90
+ * Agent source file globs to include in the deployed Next.js server artifact.
91
+ *
92
+ * Paths follow Next.js `outputFileTracingIncludes` semantics and are resolved
93
+ * relative to the app root unless `outputFileTracingRoot` is also set.
94
+ */
95
+ sourceFiles: string[];
96
+ /**
97
+ * Route glob or globs whose server traces should include `sourceFiles`.
98
+ *
99
+ * @default '/*'
100
+ */
101
+ routeGlob?: string | string[];
102
+ /**
103
+ * Next.js output file tracing root. Set this for monorepos when source files
104
+ * live outside the app directory.
105
+ */
106
+ outputFileTracingRoot?: string;
107
+ /**
108
+ * Force the older Next.js experimental config placement used by Next 13.
109
+ *
110
+ * By default this is inferred when the provided config already uses
111
+ * `experimental.serverComponentsExternalPackages` or experimental tracing.
112
+ */
113
+ legacyExperimental?: boolean;
114
+ }
115
+ interface ResolveAgentSourceFileOptions {
116
+ /** Custom error prefix when no source file candidate exists outside the sandbox runtime. */
117
+ errorMessage?: string;
118
+ /**
119
+ * Existing file to use when the bundled agent is imported by the in-sandbox runtime server.
120
+ *
121
+ * @default `${process.cwd()}/agent.mjs`
122
+ */
123
+ sandboxSourceFile?: string;
124
+ }
125
+ declare function resolveAgentSourceFile(candidates: string[], options?: ResolveAgentSourceFileOptions): string;
126
+ type NextConfigObject = {
127
+ experimental?: Record<string, unknown>;
128
+ outputFileTracingIncludes?: Record<string, unknown>;
129
+ outputFileTracingRoot?: string;
130
+ serverExternalPackages?: string[];
131
+ webpack?: NextWebpackFunction;
132
+ [key: string]: unknown;
133
+ };
134
+ type NextWebpackConfig = Record<string, unknown> & {
135
+ externals?: unknown;
136
+ plugins?: unknown[];
137
+ };
138
+ type NextWebpackContext = Record<string, unknown> & {
139
+ dev?: boolean;
140
+ dir?: string;
141
+ isServer?: boolean;
142
+ };
143
+ type NextWebpackFunction = (config: NextWebpackConfig, context: NextWebpackContext) => NextWebpackConfig;
144
+ declare function withNeckbeardNextConfig<TConfig extends NextConfigObject>(nextConfig: TConfig, options: NeckbeardNextConfigOptions): TConfig & NextConfigObject;
88
145
  /**
89
146
  * Configuration for downloading a file into the sandbox filesystem.
90
147
  * Files are downloaded during deploy() before the agent runs.
@@ -107,6 +164,14 @@ interface AgentSharedConfig<TInput> {
107
164
  sandbox: SandboxConfig;
108
165
  inputSchema: SchemaLike<TInput>;
109
166
  maxDuration?: number;
167
+ /**
168
+ * Local source file to bundle for deploy().
169
+ *
170
+ * By default this is inferred from the Agent constructor stack. Set this
171
+ * explicitly when a framework bundles server code before runtime, such as a
172
+ * Next.js route handler running from `.next/server/chunks/*.js`.
173
+ */
174
+ sourceFile?: string;
110
175
  /** OS-level dependencies to install in the sandbox. Defaults to Claude Code. Set to {} to skip. */
111
176
  dependencies?: OsDependencies;
112
177
  /**
@@ -214,25 +279,6 @@ type SandboxConfig = E2BSandboxConfig | DaytonaSandboxConfig;
214
279
  * Mode is discriminated at runtime by the presence of `server` vs `run`.
215
280
  */
216
281
  type AgentConfig<TInput, TOutput, TFrame = unknown> = RunAgentConfig<TInput, TOutput> | ServerAgentConfig<TInput, TFrame>;
217
- interface RuntimeConnection {
218
- sandboxId: string;
219
- serverUrl: string;
220
- provider: SandboxProvider;
221
- trafficToken?: string;
222
- }
223
- /**
224
- * Normalizes a path captured from a stack trace into a real on-disk file
225
- * path. Handles plain paths, `file://` URLs, and `webpack-internal://` URLs
226
- * emitted when user code runs inside a Next.js route handler or other
227
- * webpack-bundled context.
228
- *
229
- * Returns null when the input is a `webpack-internal://` URL but the
230
- * resolved disk path does not exist — callers should skip and keep walking
231
- * the stack in that case.
232
- *
233
- * @internal Exported for testing.
234
- */
235
- declare function normalizeStackFramePath(rawPath: string, cwd?: string): string | null;
236
282
  type AgentMode = 'run' | 'stream';
237
283
  declare class Agent<TInput, TOutput = unknown, TFrame = unknown> {
238
284
  readonly sandbox: SandboxConfig;
@@ -250,16 +296,6 @@ declare class Agent<TInput, TOutput = unknown, TFrame = unknown> {
250
296
  readonly claudeDir?: string;
251
297
  readonly envs: Record<string, string | undefined>;
252
298
  readonly build: BuildOptions;
253
- /** @internal Used by the in-sandbox server for run-output agents. */
254
- _run?: (input: TInput, ctx: AgentRunContext) => Promise<TOutput>;
255
- /** @internal Used by the in-sandbox server for streaming agents. */
256
- _server?: ServerAgentConfig<TInput, TFrame>['server'];
257
- /** @internal Runtime state populated by deploy(). */
258
- _serverRuntime?: {
259
- sessionId?: string;
260
- commandId?: string;
261
- connection: RuntimeConnection;
262
- };
263
299
  private _sandboxId?;
264
300
  private _sourceFile;
265
301
  constructor(config: RunAgentConfig<TInput, TOutput>);
@@ -356,4 +392,4 @@ declare class Agent<TInput, TOutput = unknown, TFrame = unknown> {
356
392
  }): AsyncGenerator<TFrame>;
357
393
  }
358
394
 
359
- export { Agent, type AgentConfig, type AgentMode, type AgentRunContext, type AgentRunResult, type AgentSandboxContext, type BuildOptions, ConfigurationError, DEFAULT_DEPENDENCIES, type DaytonaSandboxConfig, DeploymentError, type E2BSandboxConfig, ExecutionError, type FileDownload, NeckbeardError, type OsDependencies, type RunAgentConfig, type SandboxConfig, type SandboxProvider, type ServerAgentConfig, ValidationError, normalizeStackFramePath };
395
+ export { Agent, type AgentConfig, type AgentMode, type AgentRunContext, type AgentRunResult, type AgentSandboxContext, type BuildOptions, ConfigurationError, DEFAULT_DEPENDENCIES, type DaytonaSandboxConfig, DeploymentError, type E2BSandboxConfig, ExecutionError, type FileDownload, NeckbeardError, type NeckbeardNextConfigOptions, type OsDependencies, type ResolveAgentSourceFileOptions, type RunAgentConfig, type SandboxConfig, type SandboxProvider, type ServerAgentConfig, ValidationError, resolveAgentSourceFile, withNeckbeardNextConfig };
package/dist/index.d.ts CHANGED
@@ -85,6 +85,63 @@ interface BuildOptions {
85
85
  */
86
86
  autoDetectExternal?: boolean;
87
87
  }
88
+ interface NeckbeardNextConfigOptions {
89
+ /**
90
+ * Agent source file globs to include in the deployed Next.js server artifact.
91
+ *
92
+ * Paths follow Next.js `outputFileTracingIncludes` semantics and are resolved
93
+ * relative to the app root unless `outputFileTracingRoot` is also set.
94
+ */
95
+ sourceFiles: string[];
96
+ /**
97
+ * Route glob or globs whose server traces should include `sourceFiles`.
98
+ *
99
+ * @default '/*'
100
+ */
101
+ routeGlob?: string | string[];
102
+ /**
103
+ * Next.js output file tracing root. Set this for monorepos when source files
104
+ * live outside the app directory.
105
+ */
106
+ outputFileTracingRoot?: string;
107
+ /**
108
+ * Force the older Next.js experimental config placement used by Next 13.
109
+ *
110
+ * By default this is inferred when the provided config already uses
111
+ * `experimental.serverComponentsExternalPackages` or experimental tracing.
112
+ */
113
+ legacyExperimental?: boolean;
114
+ }
115
+ interface ResolveAgentSourceFileOptions {
116
+ /** Custom error prefix when no source file candidate exists outside the sandbox runtime. */
117
+ errorMessage?: string;
118
+ /**
119
+ * Existing file to use when the bundled agent is imported by the in-sandbox runtime server.
120
+ *
121
+ * @default `${process.cwd()}/agent.mjs`
122
+ */
123
+ sandboxSourceFile?: string;
124
+ }
125
+ declare function resolveAgentSourceFile(candidates: string[], options?: ResolveAgentSourceFileOptions): string;
126
+ type NextConfigObject = {
127
+ experimental?: Record<string, unknown>;
128
+ outputFileTracingIncludes?: Record<string, unknown>;
129
+ outputFileTracingRoot?: string;
130
+ serverExternalPackages?: string[];
131
+ webpack?: NextWebpackFunction;
132
+ [key: string]: unknown;
133
+ };
134
+ type NextWebpackConfig = Record<string, unknown> & {
135
+ externals?: unknown;
136
+ plugins?: unknown[];
137
+ };
138
+ type NextWebpackContext = Record<string, unknown> & {
139
+ dev?: boolean;
140
+ dir?: string;
141
+ isServer?: boolean;
142
+ };
143
+ type NextWebpackFunction = (config: NextWebpackConfig, context: NextWebpackContext) => NextWebpackConfig;
144
+ declare function withNeckbeardNextConfig<TConfig extends NextConfigObject>(nextConfig: TConfig, options: NeckbeardNextConfigOptions): TConfig & NextConfigObject;
88
145
  /**
89
146
  * Configuration for downloading a file into the sandbox filesystem.
90
147
  * Files are downloaded during deploy() before the agent runs.
@@ -107,6 +164,14 @@ interface AgentSharedConfig<TInput> {
107
164
  sandbox: SandboxConfig;
108
165
  inputSchema: SchemaLike<TInput>;
109
166
  maxDuration?: number;
167
+ /**
168
+ * Local source file to bundle for deploy().
169
+ *
170
+ * By default this is inferred from the Agent constructor stack. Set this
171
+ * explicitly when a framework bundles server code before runtime, such as a
172
+ * Next.js route handler running from `.next/server/chunks/*.js`.
173
+ */
174
+ sourceFile?: string;
110
175
  /** OS-level dependencies to install in the sandbox. Defaults to Claude Code. Set to {} to skip. */
111
176
  dependencies?: OsDependencies;
112
177
  /**
@@ -214,25 +279,6 @@ type SandboxConfig = E2BSandboxConfig | DaytonaSandboxConfig;
214
279
  * Mode is discriminated at runtime by the presence of `server` vs `run`.
215
280
  */
216
281
  type AgentConfig<TInput, TOutput, TFrame = unknown> = RunAgentConfig<TInput, TOutput> | ServerAgentConfig<TInput, TFrame>;
217
- interface RuntimeConnection {
218
- sandboxId: string;
219
- serverUrl: string;
220
- provider: SandboxProvider;
221
- trafficToken?: string;
222
- }
223
- /**
224
- * Normalizes a path captured from a stack trace into a real on-disk file
225
- * path. Handles plain paths, `file://` URLs, and `webpack-internal://` URLs
226
- * emitted when user code runs inside a Next.js route handler or other
227
- * webpack-bundled context.
228
- *
229
- * Returns null when the input is a `webpack-internal://` URL but the
230
- * resolved disk path does not exist — callers should skip and keep walking
231
- * the stack in that case.
232
- *
233
- * @internal Exported for testing.
234
- */
235
- declare function normalizeStackFramePath(rawPath: string, cwd?: string): string | null;
236
282
  type AgentMode = 'run' | 'stream';
237
283
  declare class Agent<TInput, TOutput = unknown, TFrame = unknown> {
238
284
  readonly sandbox: SandboxConfig;
@@ -250,16 +296,6 @@ declare class Agent<TInput, TOutput = unknown, TFrame = unknown> {
250
296
  readonly claudeDir?: string;
251
297
  readonly envs: Record<string, string | undefined>;
252
298
  readonly build: BuildOptions;
253
- /** @internal Used by the in-sandbox server for run-output agents. */
254
- _run?: (input: TInput, ctx: AgentRunContext) => Promise<TOutput>;
255
- /** @internal Used by the in-sandbox server for streaming agents. */
256
- _server?: ServerAgentConfig<TInput, TFrame>['server'];
257
- /** @internal Runtime state populated by deploy(). */
258
- _serverRuntime?: {
259
- sessionId?: string;
260
- commandId?: string;
261
- connection: RuntimeConnection;
262
- };
263
299
  private _sandboxId?;
264
300
  private _sourceFile;
265
301
  constructor(config: RunAgentConfig<TInput, TOutput>);
@@ -356,4 +392,4 @@ declare class Agent<TInput, TOutput = unknown, TFrame = unknown> {
356
392
  }): AsyncGenerator<TFrame>;
357
393
  }
358
394
 
359
- export { Agent, type AgentConfig, type AgentMode, type AgentRunContext, type AgentRunResult, type AgentSandboxContext, type BuildOptions, ConfigurationError, DEFAULT_DEPENDENCIES, type DaytonaSandboxConfig, DeploymentError, type E2BSandboxConfig, ExecutionError, type FileDownload, NeckbeardError, type OsDependencies, type RunAgentConfig, type SandboxConfig, type SandboxProvider, type ServerAgentConfig, ValidationError, normalizeStackFramePath };
395
+ export { Agent, type AgentConfig, type AgentMode, type AgentRunContext, type AgentRunResult, type AgentSandboxContext, type BuildOptions, ConfigurationError, DEFAULT_DEPENDENCIES, type DaytonaSandboxConfig, DeploymentError, type E2BSandboxConfig, ExecutionError, type FileDownload, NeckbeardError, type NeckbeardNextConfigOptions, type OsDependencies, type ResolveAgentSourceFileOptions, type RunAgentConfig, type SandboxConfig, type SandboxProvider, type ServerAgentConfig, ValidationError, resolveAgentSourceFile, withNeckbeardNextConfig };