agent-neckbeard 0.0.3 → 0.0.4

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.

Potentially problematic release.


This version of agent-neckbeard might be problematic. Click here for more details.

Files changed (3) hide show
  1. package/README.md +6 -2
  2. package/dist/index.js +28 -10
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -136,9 +136,13 @@ const agent = new Agent({
136
136
  const result = await agent.run({ topic: 'hello' });
137
137
  ```
138
138
 
139
- ## Claude Agent SDK Support
139
+ ## External Packages
140
140
 
141
- When your agent uses `@anthropic-ai/claude-agent-sdk`, it's automatically detected and installed in the sandbox. The SDK's CLI is available for spawning Claude processes.
141
+ Some packages can't be bundled and need to be installed in the sandbox at runtime. These include packages that:
142
+ - Spawn child processes (like `@anthropic-ai/claude-agent-sdk` which spawns its CLI)
143
+ - Have native modules
144
+
145
+ These packages are automatically marked as external during bundling and installed via npm in the sandbox.
142
146
 
143
147
  ```typescript
144
148
  import { query } from '@anthropic-ai/claude-agent-sdk';
package/dist/index.js CHANGED
@@ -42,6 +42,11 @@ var Agent = class {
42
42
  if (this._sandboxId) return;
43
43
  const esbuild = await getEsbuild();
44
44
  const { Sandbox } = await getE2b();
45
+ const collectedExternals = /* @__PURE__ */ new Set();
46
+ const mustBeExternal = [
47
+ /^@anthropic-ai\/claude-agent-sdk/
48
+ // Spawns cli.js as child process
49
+ ];
45
50
  const result = await esbuild.build({
46
51
  entryPoints: [this._sourceFile],
47
52
  bundle: true,
@@ -52,7 +57,7 @@ var Agent = class {
52
57
  minify: true,
53
58
  keepNames: true,
54
59
  plugins: [{
55
- name: "agent-neckbeard-shim",
60
+ name: "agent-neckbeard-externals",
56
61
  setup(build) {
57
62
  build.onResolve({ filter: /^agent-neckbeard$/ }, () => ({
58
63
  path: "agent-neckbeard",
@@ -72,9 +77,21 @@ var Agent = class {
72
77
  `,
73
78
  loader: "js"
74
79
  }));
75
- build.onResolve({ filter: /^@anthropic-ai\/claude-agent-sdk/ }, () => ({
76
- external: true
77
- }));
80
+ build.onResolve({ filter: /.*/ }, (args) => {
81
+ if (args.path.startsWith(".") || args.path.startsWith("/") || args.path.startsWith("node:")) {
82
+ return null;
83
+ }
84
+ for (const pattern of mustBeExternal) {
85
+ if (pattern.test(args.path)) {
86
+ const match = args.path.match(/^(@[^/]+\/[^/]+|[^/]+)/);
87
+ if (match) {
88
+ collectedExternals.add(match[1]);
89
+ }
90
+ return { external: true };
91
+ }
92
+ }
93
+ return null;
94
+ });
78
95
  }
79
96
  }]
80
97
  });
@@ -138,19 +155,20 @@ try {
138
155
  }
139
156
  await sandbox.files.write("/home/user/agent.mjs", result.outputFiles[0].text);
140
157
  await sandbox.files.write("/home/user/runner.mjs", runnerCode);
141
- const bundledCode = result.outputFiles[0].text;
142
- if (bundledCode.includes("@anthropic-ai/claude-agent-sdk")) {
158
+ if (collectedExternals.size > 0) {
159
+ const dependencies = {};
160
+ for (const pkg of collectedExternals) {
161
+ dependencies[pkg] = "*";
162
+ }
143
163
  const pkgJson = JSON.stringify({
144
164
  name: "agent-sandbox",
145
165
  type: "module",
146
- dependencies: {
147
- "@anthropic-ai/claude-agent-sdk": "*"
148
- }
166
+ dependencies
149
167
  });
150
168
  await sandbox.files.write("/home/user/package.json", pkgJson);
151
169
  const installResult = await sandbox.commands.run("cd /home/user && npm install", { timeoutMs: 3e5 });
152
170
  if (installResult.exitCode !== 0) {
153
- throw new Error(`Failed to install claude-agent-sdk: ${installResult.stderr}`);
171
+ throw new Error(`Failed to install external packages: ${installResult.stderr}`);
154
172
  }
155
173
  }
156
174
  this._sandboxId = sandbox.sandboxId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-neckbeard",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Deploy AI agents to E2B sandboxes",
5
5
  "type": "module",
6
6
  "exports": {