@roj-ai/sandbox-runtime 0.1.12 → 0.1.13

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/main.d.ts CHANGED
@@ -1,11 +1,22 @@
1
+ #!/usr/bin/env bun
1
2
  /**
2
3
  * Main Entry Point for Agent Server
3
4
  *
4
5
  * Usage:
5
6
  * bun src/main.ts [config-path]
7
+ * bunx @roj-ai/sandbox-runtime [bundle-path] (sandbox runtime case)
6
8
  *
7
9
  * Arguments:
8
- * config-path Path to roj.config.ts (default: roj.config.ts in CWD)
10
+ * path Path to roj.config.ts (dev) or a built bundle.js (sandbox).
11
+ * Defaults to roj.config.ts in CWD.
12
+ *
13
+ * When run inside an E2B sandbox, the agent bundle was built with
14
+ * `runtime.external = true`, so its `import "@roj-ai/*"` calls need to
15
+ * resolve to the runtime's installed copy. This entry point ensures
16
+ * `<bundleDir>/node_modules/@roj-ai` points at the runtime's `@roj-ai`
17
+ * dir before dynamic-importing the bundle. Idempotent: workspace dev
18
+ * setups already have `@roj-ai/*` resolvable upward, so the symlink
19
+ * step is skipped.
9
20
  */
10
21
  export {};
11
22
  //# sourceMappingURL=main.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;GAkBG"}
package/dist/main.js CHANGED
@@ -1,18 +1,51 @@
1
+ #!/usr/bin/env bun
1
2
  /**
2
3
  * Main Entry Point for Agent Server
3
4
  *
4
5
  * Usage:
5
6
  * bun src/main.ts [config-path]
7
+ * bunx @roj-ai/sandbox-runtime [bundle-path] (sandbox runtime case)
6
8
  *
7
9
  * Arguments:
8
- * config-path Path to roj.config.ts (default: roj.config.ts in CWD)
10
+ * path Path to roj.config.ts (dev) or a built bundle.js (sandbox).
11
+ * Defaults to roj.config.ts in CWD.
12
+ *
13
+ * When run inside an E2B sandbox, the agent bundle was built with
14
+ * `runtime.external = true`, so its `import "@roj-ai/*"` calls need to
15
+ * resolve to the runtime's installed copy. This entry point ensures
16
+ * `<bundleDir>/node_modules/@roj-ai` points at the runtime's `@roj-ai`
17
+ * dir before dynamic-importing the bundle. Idempotent: workspace dev
18
+ * setups already have `@roj-ai/*` resolvable upward, so the symlink
19
+ * step is skipped.
9
20
  */
10
- import { resolve } from 'node:path';
21
+ import { resolve, dirname, join } from 'node:path';
22
+ import { symlink, mkdir, rm } from 'node:fs/promises';
23
+ import { createRequire } from 'node:module';
11
24
  import { startServer } from './server.js';
12
25
  import { loadUserConfig } from './user-config-loader.js';
26
+ async function ensureSdkResolvable(bundleDir) {
27
+ const userReq = createRequire(join(bundleDir, '__roj_anchor__'));
28
+ try {
29
+ userReq.resolve('@roj-ai/sdk/package.json');
30
+ return;
31
+ }
32
+ catch {
33
+ // Not resolvable — fall through to symlink path.
34
+ }
35
+ const runtimeReq = createRequire(import.meta.url);
36
+ const sdkPkgPath = runtimeReq.resolve('@roj-ai/sdk/package.json');
37
+ const runtimeRojDir = resolve(sdkPkgPath, '..', '..');
38
+ const linkPath = join(bundleDir, 'node_modules', '@roj-ai');
39
+ await rm(linkPath, { recursive: true, force: true });
40
+ await mkdir(dirname(linkPath), { recursive: true });
41
+ await symlink(runtimeRojDir, linkPath, 'dir');
42
+ console.log(`[sandbox-runtime] linked ${linkPath} → ${runtimeRojDir}`);
43
+ }
13
44
  async function main() {
14
45
  const configPath = process.argv[2] ?? 'roj.config.ts';
15
46
  const absoluteConfigPath = resolve(process.cwd(), configPath);
47
+ const bundleDir = dirname(absoluteConfigPath);
48
+ await ensureSdkResolvable(bundleDir);
16
49
  let userConfig;
17
50
  try {
18
51
  userConfig = await loadUserConfig(absoluteConfigPath);
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../src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,EAAE,EAAE;IACtB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAA;IACpC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAChB,CAAC,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roj-ai/sandbox-runtime",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "exports": {
@@ -20,6 +20,9 @@
20
20
  "default": "./dist/user-config-loader.js"
21
21
  }
22
22
  },
23
+ "bin": {
24
+ "roj-sandbox-runtime": "./dist/main.js"
25
+ },
23
26
  "files": [
24
27
  "src",
25
28
  "dist"
@@ -43,8 +46,8 @@
43
46
  "type-check": "tsc --noEmit"
44
47
  },
45
48
  "dependencies": {
46
- "@roj-ai/sdk": "^0.1.12",
47
- "@roj-ai/transport": "^0.1.12",
49
+ "@roj-ai/sdk": "^0.1.13",
50
+ "@roj-ai/transport": "^0.1.13",
48
51
  "hono": "4.12.5"
49
52
  },
50
53
  "devDependencies": {
package/src/main.ts CHANGED
@@ -1,20 +1,56 @@
1
+ #!/usr/bin/env bun
1
2
  /**
2
3
  * Main Entry Point for Agent Server
3
4
  *
4
5
  * Usage:
5
6
  * bun src/main.ts [config-path]
7
+ * bunx @roj-ai/sandbox-runtime [bundle-path] (sandbox runtime case)
6
8
  *
7
9
  * Arguments:
8
- * config-path Path to roj.config.ts (default: roj.config.ts in CWD)
10
+ * path Path to roj.config.ts (dev) or a built bundle.js (sandbox).
11
+ * Defaults to roj.config.ts in CWD.
12
+ *
13
+ * When run inside an E2B sandbox, the agent bundle was built with
14
+ * `runtime.external = true`, so its `import "@roj-ai/*"` calls need to
15
+ * resolve to the runtime's installed copy. This entry point ensures
16
+ * `<bundleDir>/node_modules/@roj-ai` points at the runtime's `@roj-ai`
17
+ * dir before dynamic-importing the bundle. Idempotent: workspace dev
18
+ * setups already have `@roj-ai/*` resolvable upward, so the symlink
19
+ * step is skipped.
9
20
  */
10
21
 
11
- import { resolve } from 'node:path'
22
+ import { resolve, dirname, join } from 'node:path'
23
+ import { symlink, mkdir, rm } from 'node:fs/promises'
24
+ import { createRequire } from 'node:module'
12
25
  import { startServer } from './server.js'
13
26
  import { loadUserConfig } from './user-config-loader.js'
14
27
 
28
+ async function ensureSdkResolvable(bundleDir: string): Promise<void> {
29
+ const userReq = createRequire(join(bundleDir, '__roj_anchor__'))
30
+ try {
31
+ userReq.resolve('@roj-ai/sdk/package.json')
32
+ return
33
+ } catch {
34
+ // Not resolvable — fall through to symlink path.
35
+ }
36
+
37
+ const runtimeReq = createRequire(import.meta.url)
38
+ const sdkPkgPath = runtimeReq.resolve('@roj-ai/sdk/package.json')
39
+ const runtimeRojDir = resolve(sdkPkgPath, '..', '..')
40
+
41
+ const linkPath = join(bundleDir, 'node_modules', '@roj-ai')
42
+ await rm(linkPath, { recursive: true, force: true })
43
+ await mkdir(dirname(linkPath), { recursive: true })
44
+ await symlink(runtimeRojDir, linkPath, 'dir')
45
+ console.log(`[sandbox-runtime] linked ${linkPath} → ${runtimeRojDir}`)
46
+ }
47
+
15
48
  async function main() {
16
49
  const configPath = process.argv[2] ?? 'roj.config.ts'
17
50
  const absoluteConfigPath = resolve(process.cwd(), configPath)
51
+ const bundleDir = dirname(absoluteConfigPath)
52
+
53
+ await ensureSdkResolvable(bundleDir)
18
54
 
19
55
  let userConfig: Awaited<ReturnType<typeof loadUserConfig>>
20
56
  try {