@volter/world-attach 2.0.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.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env node
2
+ // volter-attach — the shim-only attach client (docs/guides/route-a-cli-through-the-world.md, rung 0 for
3
+ // machines with no Twins checkout). Deliberately thin: it resolves the
4
+ // kernel's dormant attach entry (`@volter/world-core/attach`), sets VOLTER_WORLD,
5
+ // and execs the command — ALL attach logic (manifest fetch, env synthesis,
6
+ // CA trust, arming the injector) lives in that one shared file.
7
+ //
8
+ // volter-attach <world-url> [--token <t>] -- <command…>
9
+ import { spawnSync } from 'node:child_process';
10
+ import { createRequire } from 'node:module';
11
+ const require = createRequire(import.meta.url);
12
+ const args = process.argv.slice(2);
13
+ const split = args.indexOf('--');
14
+ const head = split >= 0 ? args.slice(0, split) : args;
15
+ const command = split >= 0 ? args.slice(split + 1) : [];
16
+ const ref = head[0];
17
+ const tokenIndex = head.indexOf('--token');
18
+ const token = tokenIndex >= 0 ? head[tokenIndex + 1] : undefined;
19
+ if (!ref || ref.startsWith('-') || command.length === 0) {
20
+ process.stderr.write('Usage: volter-attach <world-url> [--token <t>] -- <command…>\n');
21
+ process.exit(2);
22
+ }
23
+ const attachEntry = require.resolve('@volter/world-core/attach');
24
+ const result = spawnSync(command[0], command.slice(1), {
25
+ env: {
26
+ ...process.env,
27
+ NODE_OPTIONS: `${process.env.NODE_OPTIONS ?? ''} --require ${attachEntry}`.trim(),
28
+ VOLTER_WORLD: ref,
29
+ ...(token === undefined ? {} : { VOLTER_WORLD_TOKEN: token }),
30
+ },
31
+ stdio: 'inherit',
32
+ });
33
+ process.exit(result.status ?? 1);
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@volter/world-attach",
3
+ "version": "2.0.0",
4
+ "description": "Shim-only attach client for Twins worlds: point any Node app at a local or served world with zero repo integration (docs/guides/route-a-cli-through-the-world.md). No twins in it.",
5
+ "keywords": [
6
+ "twin",
7
+ "attach",
8
+ "world",
9
+ "sdk",
10
+ "localstack"
11
+ ],
12
+ "author": "Volter (https://github.com/volter-ai)",
13
+ "license": "Apache-2.0",
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "type": "module",
18
+ "bin": {
19
+ "volter-attach": "dist/src/cli.js"
20
+ },
21
+ "files": [
22
+ "src",
23
+ "dist"
24
+ ],
25
+ "dependencies": {
26
+ "@volter/world-core": "2.0.0"
27
+ },
28
+ "scripts": {
29
+ "build": "node ../../scripts/publish/build.mjs",
30
+ "prepack": "node ../../scripts/publish/prepare-publish.mjs prepack",
31
+ "postpack": "node ../../scripts/publish/prepare-publish.mjs postpack"
32
+ }
33
+ }
package/src/cli.ts ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+ // volter-attach — the shim-only attach client (docs/guides/route-a-cli-through-the-world.md, rung 0 for
3
+ // machines with no Twins checkout). Deliberately thin: it resolves the
4
+ // kernel's dormant attach entry (`@volter/world-core/attach`), sets VOLTER_WORLD,
5
+ // and execs the command — ALL attach logic (manifest fetch, env synthesis,
6
+ // CA trust, arming the injector) lives in that one shared file.
7
+ //
8
+ // volter-attach <world-url> [--token <t>] -- <command…>
9
+ import { spawnSync } from 'node:child_process';
10
+ import { createRequire } from 'node:module';
11
+
12
+ const require = createRequire(import.meta.url);
13
+ const args = process.argv.slice(2);
14
+ const split = args.indexOf('--');
15
+ const head = split >= 0 ? args.slice(0, split) : args;
16
+ const command = split >= 0 ? args.slice(split + 1) : [];
17
+ const ref = head[0];
18
+ const tokenIndex = head.indexOf('--token');
19
+ const token = tokenIndex >= 0 ? head[tokenIndex + 1] : undefined;
20
+
21
+ if (!ref || ref.startsWith('-') || command.length === 0) {
22
+ process.stderr.write('Usage: volter-attach <world-url> [--token <t>] -- <command…>\n');
23
+ process.exit(2);
24
+ }
25
+
26
+ const attachEntry = require.resolve('@volter/world-core/attach');
27
+ const result = spawnSync(command[0]!, command.slice(1), {
28
+ env: {
29
+ ...process.env,
30
+ NODE_OPTIONS: `${process.env.NODE_OPTIONS ?? ''} --require ${attachEntry}`.trim(),
31
+ VOLTER_WORLD: ref,
32
+ ...(token === undefined ? {} : { VOLTER_WORLD_TOKEN: token }),
33
+ },
34
+ stdio: 'inherit',
35
+ });
36
+ process.exit(result.status ?? 1);