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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 zacwellmer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -6,6 +6,8 @@ Neckbeard deploys your agent code into an E2B or Daytona sandbox and runs it beh
6
6
 
7
7
  The intent is simple: your production process should not run the agent. The sandbox runs the agent, keeps its filesystem/process state, and exposes a private `/invoke` endpoint that neckbeard calls for each turn.
8
8
 
9
+ This is designed to work from short-lived request handlers and long-running workers, including Vercel Functions, Hatchet workers, and Trigger.dev tasks. See `docs/CONSUMER_ENVIRONMENTS.md` before changing lifecycle, timeout, streaming, or cleanup behavior for those environments.
10
+
9
11
  ## What This Does
10
12
 
11
13
  You write an agent:
@@ -50,6 +52,35 @@ const result = await agent.run({ topic: 'TypeScript generics' }, { sandboxId });
50
52
 
51
53
  `run()` validates input locally, POSTs it to the sandbox server, reads SSE harness events, validates the final output, and returns the existing `{ ok, executionId, output | error }` result shape.
52
54
 
55
+ By default, the package infers the file to bundle from the `new Agent(...)` call stack. In frameworks that bundle server code before runtime, set `sourceFile` to the real agent module so `deploy()` does not rebundle a framework output chunk:
56
+
57
+ ```typescript
58
+ new Agent({
59
+ sourceFile: path.resolve(process.cwd(), 'packages/my-agent/src/agent.ts'),
60
+ // ...
61
+ });
62
+ ```
63
+
64
+ For Next.js/Vercel-style deployments, keep `agent-neckbeard` external to the server bundle and make sure the referenced source file is included in the production artifact:
65
+
66
+ ```typescript
67
+ // next.config.ts
68
+ import { withNeckbeardNextConfig } from 'agent-neckbeard';
69
+
70
+ const nextConfig = withNeckbeardNextConfig({
71
+ // your existing Next config
72
+ }, {
73
+ routeGlob: '/api/my-agent',
74
+ sourceFiles: ['./packages/my-agent/src/**/*'],
75
+ });
76
+
77
+ export default nextConfig;
78
+ ```
79
+
80
+ For Next 13 configs that still use `experimental.serverComponentsExternalPackages`, the helper automatically uses the matching experimental tracing fields when it sees that shape. Set `outputFileTracingRoot` when the agent source is outside the app root.
81
+
82
+ This repo tests that shape locally with `npm run test:compat:next`, which builds and runs a Dockerized Next App Router fixture without pushing to Vercel. The fixture also checks the runtime env contract, Node major, and traced standalone files so source-level tests do not mask deployment artifact problems.
83
+
53
84
  ## Setup
54
85
 
55
86
  ```bash
@@ -152,13 +183,6 @@ new Agent({
152
183
  template: string,
153
184
  },
154
185
  inputSchema: ZodSchema,
155
- outputSchema?: ZodSchema,
156
- run?: (input, ctx) => Promise<output>,
157
- server?: {
158
- port?: number,
159
- frameSchema: ZodSchema,
160
- handler: ({ input, ctx, signal, emit }) => Promise<void>,
161
- },
162
186
  maxDuration?: number,
163
187
  dependencies?: {
164
188
  apt?: string[],
@@ -167,6 +191,15 @@ new Agent({
167
191
  files?: [{ url, path }],
168
192
  claudeDir?: string,
169
193
  envs?: Record<string, string | undefined>,
194
+ // Run-output agents require:
195
+ outputSchema: ZodSchema,
196
+ run: (input, ctx) => Promise<output>,
197
+ // Streaming agents require this instead of outputSchema/run:
198
+ server: {
199
+ port?: number,
200
+ frameSchema: ZodSchema,
201
+ handler: ({ input, ctx, signal, emit }) => Promise<void>,
202
+ },
170
203
  });
171
204
  ```
172
205
 
@@ -209,9 +242,11 @@ try {
209
242
  ## Testing
210
243
 
211
244
  ```bash
212
- npm test
245
+ npm run check
213
246
  ```
214
247
 
248
+ The local check runs typecheck, repository lint checks, formatting hygiene checks, unit tests, generated runtime verification, CJS build verification, and package dry-run validation.
249
+
215
250
  Jest drives both the fast local suite and the live smoke suites. Each live suite automatically skips when its provider key is not set:
216
251
 
217
252
  ```bash
@@ -0,0 +1,50 @@
1
+ // src/runtime/protocol.ts
2
+ var RUNTIME_PROTOCOL_VERSION = 1;
3
+ function isHarnessEvent(value) {
4
+ if (!value || typeof value !== "object") return false;
5
+ const candidate = value;
6
+ if (typeof candidate.kind !== "string") return false;
7
+ if (typeof candidate.invocationId !== "string") return false;
8
+ if (!hasValidMetadata(candidate)) return false;
9
+ switch (candidate.kind) {
10
+ case "started":
11
+ case "done":
12
+ return true;
13
+ case "frame":
14
+ return Object.hasOwn(candidate, "data");
15
+ case "output":
16
+ return Object.hasOwn(candidate, "output");
17
+ case "error":
18
+ return isSerializedError(candidate.error);
19
+ default:
20
+ return false;
21
+ }
22
+ }
23
+ function hasValidMetadata(candidate) {
24
+ if (candidate.protocolVersion !== void 0 && candidate.protocolVersion !== RUNTIME_PROTOCOL_VERSION) {
25
+ return false;
26
+ }
27
+ if (candidate.sequence !== void 0 && typeof candidate.sequence !== "number") {
28
+ return false;
29
+ }
30
+ if (candidate.timestamp !== void 0 && typeof candidate.timestamp !== "string") {
31
+ return false;
32
+ }
33
+ if (candidate.elapsedMs !== void 0 && typeof candidate.elapsedMs !== "number") {
34
+ return false;
35
+ }
36
+ return true;
37
+ }
38
+ function isSerializedError(value) {
39
+ if (!value || typeof value !== "object") return false;
40
+ const candidate = value;
41
+ if (typeof candidate.message !== "string") return false;
42
+ if (candidate.name !== void 0 && typeof candidate.name !== "string") return false;
43
+ if (candidate.stack !== void 0 && typeof candidate.stack !== "string") return false;
44
+ return true;
45
+ }
46
+
47
+ export {
48
+ RUNTIME_PROTOCOL_VERSION,
49
+ isHarnessEvent
50
+ };