@ours.network/install 1.2.1-nightly.17 → 1.2.1-nightly.18
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/README.md +39 -0
- package/assets/release-lock.json +1080 -4267
- package/assets/release.json +25 -25
- package/assets/sources.json +35 -35
- package/install.mjs +5 -1
- package/lib/client-cli.mjs +11 -1
- package/lib/server-onboarding.mjs +50 -9
- package/lib/setup-options.mjs +2 -2
- package/lib/workspace-setup.mjs +52 -0
- package/package.json +1 -1
package/assets/release.json
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
3
|
"channel": "nightly",
|
|
4
|
-
"installerVersion": "1.2.1-nightly.
|
|
4
|
+
"installerVersion": "1.2.1-nightly.18",
|
|
5
5
|
"packages": {
|
|
6
6
|
"@ours.network/sdk": {
|
|
7
|
-
"version": "3.8.1-nightly.
|
|
8
|
-
"integrity": "sha512-
|
|
7
|
+
"version": "3.8.1-nightly.15",
|
|
8
|
+
"integrity": "sha512-ynKaKmKtINBqYk3kNovsgEO/3TiFY1CC9FgZzrOH+H6onnM3J//Q8cBb9sun8dl9mhB4mKZYgvneSiOejYwZUw=="
|
|
9
9
|
},
|
|
10
10
|
"@ours.network/cli": {
|
|
11
|
-
"version": "2.8.1-nightly.
|
|
12
|
-
"integrity": "sha512-
|
|
11
|
+
"version": "2.8.1-nightly.13",
|
|
12
|
+
"integrity": "sha512-1BeAG12vh4ruBOeJ54l60qWUhLzPLRNKnGtRiJpQmSXkamNQglrPQeXa9xW3taAM4Vg5uYgEhsz6+ieM+1TUSA=="
|
|
13
13
|
},
|
|
14
14
|
"@ours.network/tg-connector": {
|
|
15
|
-
"version": "1.0.1-nightly.
|
|
16
|
-
"integrity": "sha512-
|
|
15
|
+
"version": "1.0.1-nightly.9",
|
|
16
|
+
"integrity": "sha512-wm0V8c97aIg7p26L9My36I3BE9Cy2Xc5W7WgHg6Vo+hmPvE+jXmen86yA4+DxIu9VYxoVSMtpBbu76485eCeNw=="
|
|
17
17
|
},
|
|
18
18
|
"@ours.network/cowork": {
|
|
19
|
-
"version": "1.3.3-nightly.
|
|
20
|
-
"integrity": "sha512-
|
|
19
|
+
"version": "1.3.3-nightly.20261001.6d49d3a",
|
|
20
|
+
"integrity": "sha512-tqoLOWc4O8CGwLdO1j6ukm6Vn57EE0zbuxKo4BWd0QVwu9ObKgHCEMOKPgW2mXHeESXSv9m7edcIrnK8I5gD+w=="
|
|
21
21
|
},
|
|
22
22
|
"@ours.network/messenger-server": {
|
|
23
|
-
"version": "1.0.31-nightly.
|
|
24
|
-
"integrity": "sha512-
|
|
23
|
+
"version": "1.0.31-nightly.12",
|
|
24
|
+
"integrity": "sha512-vp7RkIYnlPDySAbFcXP3vpeOvu0bHeHWjlxOtBbYlGjGa/B7TixXbZpLYwgvbiuD7pVIaHs1muIDzG8RjJTVeQ=="
|
|
25
25
|
},
|
|
26
26
|
"@ours.network/fleet": {
|
|
27
|
-
"version": "1.2.0-nightly.
|
|
28
|
-
"integrity": "sha512-
|
|
27
|
+
"version": "1.2.0-nightly.28",
|
|
28
|
+
"integrity": "sha512-6Ils463HA+ZY+JV6MIa9Cet8mxi6Ool3Xf2V8Sy/kSBzCZh3aV2S5jozh4dNINGZh72NxptIh2Z6AL5IoS0WKg=="
|
|
29
29
|
},
|
|
30
30
|
"@ours.network/mcp": {
|
|
31
|
-
"version": "1.2.0-nightly.
|
|
32
|
-
"integrity": "sha512-
|
|
31
|
+
"version": "1.2.0-nightly.10",
|
|
32
|
+
"integrity": "sha512-59sxJOcQagNRR+43Z5ScFlqFDBIlZSMQi8iz9mpxp5Jjl38B0dmCFsv5e+srbEYrV3xaOg9ZBsT17OUABFAseQ=="
|
|
33
33
|
},
|
|
34
34
|
"@ours.network/codex": {
|
|
35
|
-
"version": "1.2.0-nightly.
|
|
36
|
-
"integrity": "sha512-
|
|
35
|
+
"version": "1.2.0-nightly.10",
|
|
36
|
+
"integrity": "sha512-7hV4R0w8tiQ/JKFU5MxtM7fihd33tzWDgT+Bn8cidasxI5zmTLqDEIv6om5LM/xk7UqcPw5gDN2kcJYiybnP9Q=="
|
|
37
37
|
},
|
|
38
38
|
"@ours.network/claude-code": {
|
|
39
|
-
"version": "1.2.0-nightly.
|
|
40
|
-
"integrity": "sha512-
|
|
39
|
+
"version": "1.2.0-nightly.10",
|
|
40
|
+
"integrity": "sha512-C3+H/vXespanVj9E1uQAWno9RFrI5KlK2SHSc7dnmRRuFVyRsoVcbvlpVI3nZ8snFaKVzbetebZr7vxd73AWSg=="
|
|
41
41
|
},
|
|
42
42
|
"@ours.network/daemon": {
|
|
43
|
-
"version": "3.8.1-nightly.
|
|
44
|
-
"integrity": "sha512-
|
|
43
|
+
"version": "3.8.1-nightly.7",
|
|
44
|
+
"integrity": "sha512-dDFDm+xERplzu4yXKvLjKGNaIdr9u4ku5/4jiI4g8do3qOX9VS0tF1+O67uSu4jqkypg860UdZRdn9Zce72H/A=="
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
"hostCli": {
|
|
48
48
|
"@ours.network/sdk": {
|
|
49
|
-
"version": "3.8.1-nightly.
|
|
50
|
-
"integrity": "sha512-
|
|
49
|
+
"version": "3.8.1-nightly.15",
|
|
50
|
+
"integrity": "sha512-ynKaKmKtINBqYk3kNovsgEO/3TiFY1CC9FgZzrOH+H6onnM3J//Q8cBb9sun8dl9mhB4mKZYgvneSiOejYwZUw=="
|
|
51
51
|
},
|
|
52
52
|
"@ours.network/cli": {
|
|
53
|
-
"version": "2.8.1-nightly.
|
|
54
|
-
"integrity": "sha512-
|
|
53
|
+
"version": "2.8.1-nightly.13",
|
|
54
|
+
"integrity": "sha512-1BeAG12vh4ruBOeJ54l60qWUhLzPLRNKnGtRiJpQmSXkamNQglrPQeXa9xW3taAM4Vg5uYgEhsz6+ieM+1TUSA=="
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
}
|
package/assets/sources.json
CHANGED
|
@@ -2,100 +2,100 @@
|
|
|
2
2
|
"release": {
|
|
3
3
|
"schema": 1,
|
|
4
4
|
"channel": "nightly",
|
|
5
|
-
"installerVersion": "1.2.1-nightly.
|
|
5
|
+
"installerVersion": "1.2.1-nightly.18",
|
|
6
6
|
"packages": {
|
|
7
7
|
"@ours.network/sdk": {
|
|
8
|
-
"version": "3.8.1-nightly.
|
|
9
|
-
"integrity": "sha512-
|
|
8
|
+
"version": "3.8.1-nightly.15",
|
|
9
|
+
"integrity": "sha512-ynKaKmKtINBqYk3kNovsgEO/3TiFY1CC9FgZzrOH+H6onnM3J//Q8cBb9sun8dl9mhB4mKZYgvneSiOejYwZUw=="
|
|
10
10
|
},
|
|
11
11
|
"@ours.network/cli": {
|
|
12
|
-
"version": "2.8.1-nightly.
|
|
13
|
-
"integrity": "sha512-
|
|
12
|
+
"version": "2.8.1-nightly.13",
|
|
13
|
+
"integrity": "sha512-1BeAG12vh4ruBOeJ54l60qWUhLzPLRNKnGtRiJpQmSXkamNQglrPQeXa9xW3taAM4Vg5uYgEhsz6+ieM+1TUSA=="
|
|
14
14
|
},
|
|
15
15
|
"@ours.network/tg-connector": {
|
|
16
|
-
"version": "1.0.1-nightly.
|
|
17
|
-
"integrity": "sha512-
|
|
16
|
+
"version": "1.0.1-nightly.9",
|
|
17
|
+
"integrity": "sha512-wm0V8c97aIg7p26L9My36I3BE9Cy2Xc5W7WgHg6Vo+hmPvE+jXmen86yA4+DxIu9VYxoVSMtpBbu76485eCeNw=="
|
|
18
18
|
},
|
|
19
19
|
"@ours.network/cowork": {
|
|
20
|
-
"version": "1.3.3-nightly.
|
|
21
|
-
"integrity": "sha512-
|
|
20
|
+
"version": "1.3.3-nightly.20261001.6d49d3a",
|
|
21
|
+
"integrity": "sha512-tqoLOWc4O8CGwLdO1j6ukm6Vn57EE0zbuxKo4BWd0QVwu9ObKgHCEMOKPgW2mXHeESXSv9m7edcIrnK8I5gD+w=="
|
|
22
22
|
},
|
|
23
23
|
"@ours.network/messenger-server": {
|
|
24
|
-
"version": "1.0.31-nightly.
|
|
25
|
-
"integrity": "sha512-
|
|
24
|
+
"version": "1.0.31-nightly.12",
|
|
25
|
+
"integrity": "sha512-vp7RkIYnlPDySAbFcXP3vpeOvu0bHeHWjlxOtBbYlGjGa/B7TixXbZpLYwgvbiuD7pVIaHs1muIDzG8RjJTVeQ=="
|
|
26
26
|
},
|
|
27
27
|
"@ours.network/fleet": {
|
|
28
|
-
"version": "1.2.0-nightly.
|
|
29
|
-
"integrity": "sha512-
|
|
28
|
+
"version": "1.2.0-nightly.28",
|
|
29
|
+
"integrity": "sha512-6Ils463HA+ZY+JV6MIa9Cet8mxi6Ool3Xf2V8Sy/kSBzCZh3aV2S5jozh4dNINGZh72NxptIh2Z6AL5IoS0WKg=="
|
|
30
30
|
},
|
|
31
31
|
"@ours.network/mcp": {
|
|
32
|
-
"version": "1.2.0-nightly.
|
|
33
|
-
"integrity": "sha512-
|
|
32
|
+
"version": "1.2.0-nightly.10",
|
|
33
|
+
"integrity": "sha512-59sxJOcQagNRR+43Z5ScFlqFDBIlZSMQi8iz9mpxp5Jjl38B0dmCFsv5e+srbEYrV3xaOg9ZBsT17OUABFAseQ=="
|
|
34
34
|
},
|
|
35
35
|
"@ours.network/codex": {
|
|
36
|
-
"version": "1.2.0-nightly.
|
|
37
|
-
"integrity": "sha512-
|
|
36
|
+
"version": "1.2.0-nightly.10",
|
|
37
|
+
"integrity": "sha512-7hV4R0w8tiQ/JKFU5MxtM7fihd33tzWDgT+Bn8cidasxI5zmTLqDEIv6om5LM/xk7UqcPw5gDN2kcJYiybnP9Q=="
|
|
38
38
|
},
|
|
39
39
|
"@ours.network/claude-code": {
|
|
40
|
-
"version": "1.2.0-nightly.
|
|
41
|
-
"integrity": "sha512-
|
|
40
|
+
"version": "1.2.0-nightly.10",
|
|
41
|
+
"integrity": "sha512-C3+H/vXespanVj9E1uQAWno9RFrI5KlK2SHSc7dnmRRuFVyRsoVcbvlpVI3nZ8snFaKVzbetebZr7vxd73AWSg=="
|
|
42
42
|
},
|
|
43
43
|
"@ours.network/daemon": {
|
|
44
|
-
"version": "3.8.1-nightly.
|
|
45
|
-
"integrity": "sha512-
|
|
44
|
+
"version": "3.8.1-nightly.7",
|
|
45
|
+
"integrity": "sha512-dDFDm+xERplzu4yXKvLjKGNaIdr9u4ku5/4jiI4g8do3qOX9VS0tF1+O67uSu4jqkypg860UdZRdn9Zce72H/A=="
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"hostCli": {
|
|
49
49
|
"@ours.network/sdk": {
|
|
50
|
-
"version": "3.8.1-nightly.
|
|
51
|
-
"integrity": "sha512-
|
|
50
|
+
"version": "3.8.1-nightly.15",
|
|
51
|
+
"integrity": "sha512-ynKaKmKtINBqYk3kNovsgEO/3TiFY1CC9FgZzrOH+H6onnM3J//Q8cBb9sun8dl9mhB4mKZYgvneSiOejYwZUw=="
|
|
52
52
|
},
|
|
53
53
|
"@ours.network/cli": {
|
|
54
|
-
"version": "2.8.1-nightly.
|
|
55
|
-
"integrity": "sha512-
|
|
54
|
+
"version": "2.8.1-nightly.13",
|
|
55
|
+
"integrity": "sha512-1BeAG12vh4ruBOeJ54l60qWUhLzPLRNKnGtRiJpQmSXkamNQglrPQeXa9xW3taAM4Vg5uYgEhsz6+ieM+1TUSA=="
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
59
|
"packages": {
|
|
60
60
|
"@ours.network/sdk": {
|
|
61
61
|
"type": "npm",
|
|
62
|
-
"version": "3.8.1-nightly.
|
|
62
|
+
"version": "3.8.1-nightly.15"
|
|
63
63
|
},
|
|
64
64
|
"@ours.network/cli": {
|
|
65
65
|
"type": "npm",
|
|
66
|
-
"version": "2.8.1-nightly.
|
|
66
|
+
"version": "2.8.1-nightly.13"
|
|
67
67
|
},
|
|
68
68
|
"@ours.network/tg-connector": {
|
|
69
69
|
"type": "npm",
|
|
70
|
-
"version": "1.0.1-nightly.
|
|
70
|
+
"version": "1.0.1-nightly.9"
|
|
71
71
|
},
|
|
72
72
|
"@ours.network/cowork": {
|
|
73
73
|
"type": "npm",
|
|
74
|
-
"version": "1.3.3-nightly.
|
|
74
|
+
"version": "1.3.3-nightly.20261001.6d49d3a"
|
|
75
75
|
},
|
|
76
76
|
"@ours.network/messenger-server": {
|
|
77
77
|
"type": "npm",
|
|
78
|
-
"version": "1.0.31-nightly.
|
|
78
|
+
"version": "1.0.31-nightly.12"
|
|
79
79
|
},
|
|
80
80
|
"@ours.network/fleet": {
|
|
81
81
|
"type": "npm",
|
|
82
|
-
"version": "1.2.0-nightly.
|
|
82
|
+
"version": "1.2.0-nightly.28"
|
|
83
83
|
},
|
|
84
84
|
"@ours.network/mcp": {
|
|
85
85
|
"type": "npm",
|
|
86
|
-
"version": "1.2.0-nightly.
|
|
86
|
+
"version": "1.2.0-nightly.10"
|
|
87
87
|
},
|
|
88
88
|
"@ours.network/codex": {
|
|
89
89
|
"type": "npm",
|
|
90
|
-
"version": "1.2.0-nightly.
|
|
90
|
+
"version": "1.2.0-nightly.10"
|
|
91
91
|
},
|
|
92
92
|
"@ours.network/claude-code": {
|
|
93
93
|
"type": "npm",
|
|
94
|
-
"version": "1.2.0-nightly.
|
|
94
|
+
"version": "1.2.0-nightly.10"
|
|
95
95
|
},
|
|
96
96
|
"@ours.network/daemon": {
|
|
97
97
|
"type": "npm",
|
|
98
|
-
"version": "3.8.1-nightly.
|
|
98
|
+
"version": "3.8.1-nightly.7"
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
}
|
package/install.mjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { readFileSync } from 'node:fs';
|
|
4
4
|
|
|
5
5
|
import { realEffects } from './lib/effects.mjs';
|
|
6
|
+
import { runWorkspaceSetup } from './lib/workspace-setup.mjs';
|
|
6
7
|
import { runSetup } from './lib/setup.mjs';
|
|
7
8
|
import { closeSync, makeWriter, openTty } from './lib/ui.mjs';
|
|
8
9
|
|
|
@@ -10,7 +11,10 @@ const version = JSON.parse(readFileSync(new URL('./package.json', import.meta.ur
|
|
|
10
11
|
const ttyFd = openTty();
|
|
11
12
|
|
|
12
13
|
try {
|
|
13
|
-
const
|
|
14
|
+
const args=process.argv.slice(2);
|
|
15
|
+
const workspace=args.some(v=>v==='--setup-workspace' || v.startsWith('--setup-workspace=') || v==='--setup-workspace-file' || v.startsWith('--setup-workspace-file='));
|
|
16
|
+
const execute=workspace ? (args,effects)=>runWorkspaceSetup(args,effects,runSetup) : runSetup;
|
|
17
|
+
const code = await execute(args, realEffects({
|
|
14
18
|
write: makeWriter(ttyFd),
|
|
15
19
|
ttyFd,
|
|
16
20
|
env: process.env,
|
package/lib/client-cli.mjs
CHANGED
|
@@ -34,8 +34,18 @@ export async function publishClientCli(effects, packagePath, { policy = {}, isol
|
|
|
34
34
|
const acquisitionRoot = dirname(dirname(dirname(packageRoot)));
|
|
35
35
|
privateAcquisition(effects.home, acquisitionRoot);
|
|
36
36
|
const retained = JSON.parse(readFileSync(join(acquisitionRoot, 'sources.json')));
|
|
37
|
-
|
|
37
|
+
const binding = releaseBinding(retained);
|
|
38
|
+
if (binding && binding.scope !== 'host-cli') throw new Error('Unrecognized private CLI entry');
|
|
38
39
|
verifyReleaseGraph(acquisitionRoot, retained);
|
|
40
|
+
if (!binding) {
|
|
41
|
+
// Development selections publish through npm's global package entry.
|
|
42
|
+
// Require that exact retained selection and global target on retry;
|
|
43
|
+
// integrity-bound private host CLI releases keep their stricter path.
|
|
44
|
+
const npmRoot = (await effects.run('npm', ['root', '--global'])).stdout.trim();
|
|
45
|
+
const selected = retained.packages?.['@ours.network/cli'];
|
|
46
|
+
const pkg = JSON.parse(readFileSync(join(packageRoot, 'package.json')));
|
|
47
|
+
if (!isAbsolute(npmRoot) || realpathSync(join(npmRoot, '@ours.network/cli')) !== packageRoot || selected?.type !== 'npm' || selected.version !== pkg.version) throw new Error('Unrecognized private CLI entry');
|
|
48
|
+
}
|
|
39
49
|
const pkg = JSON.parse(readFileSync(join(packageRoot, 'package.json')));
|
|
40
50
|
if (pkg.name !== '@ours.network/cli' || resolve(packageRoot, pkg.bin?.ours ?? '') !== resolved) throw new Error('Unrecognized private CLI target');
|
|
41
51
|
} else {
|
|
@@ -29,16 +29,56 @@ function validateRecord(record) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export function createServerOnboarding(effects, { compose, localEnv, bin }) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
// CLI client commands only accept gateway profiles in current releases. Use
|
|
33
|
+
// the installed SDK against the selected local daemon and its private file.
|
|
34
|
+
const identityScript = `
|
|
35
|
+
import { createRequire } from 'node:module';
|
|
36
|
+
import { pathToFileURL } from 'node:url';
|
|
37
|
+
import { randomUUID } from 'node:crypto';
|
|
38
|
+
const selection = JSON.parse(process.argv[1]);
|
|
39
|
+
const require = createRequire(selection.anchor);
|
|
40
|
+
const { attachOursClient } = await import(pathToFileURL(require.resolve('@ours.network/sdk/client')).href);
|
|
41
|
+
const client = await attachOursClient({ endpoint: selection.endpoint,
|
|
42
|
+
expectedInstanceId: selection.instanceId, credentialPath: selection.credentialPath,
|
|
43
|
+
sessionMode: 'external', leaseToken: randomUUID(), env: {} });
|
|
44
|
+
try {
|
|
45
|
+
const result = selection.operation === 'list' ? await client.listIdentities()
|
|
46
|
+
: await client.createRootIdentity({ name: selection.name, bio: '',
|
|
47
|
+
exposeLocal: true, localAutoAccept: true, skipIfRootExists: true });
|
|
48
|
+
process.stdout.write(JSON.stringify(result));
|
|
49
|
+
} catch (error) {
|
|
50
|
+
process.stdout.write(JSON.stringify({ onboardingError: error.code || 'OWNER_OPERATION_FAILED' }));
|
|
51
|
+
} finally {
|
|
52
|
+
try { await client.releaseLease(); } finally { await client.close(); }
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
55
|
+
async function identityCommand(record, operation, name) {
|
|
56
|
+
validateRecord(record);
|
|
57
|
+
const docker = record.mode === 'docker';
|
|
58
|
+
const selection = {
|
|
59
|
+
operation, ...(name === undefined ? {} : { name }),
|
|
60
|
+
endpoint: `http://127.0.0.1:${docker ? 3050 : record.port}`,
|
|
61
|
+
instanceId: record.instanceId,
|
|
62
|
+
credentialPath: docker ? '/var/lib/ours/daemon-token' : join(installationPaths(record).daemon, 'daemon-token'),
|
|
63
|
+
anchor: docker ? '/opt/ours/package.json' : join(record.workDir, 'package.json'),
|
|
64
|
+
};
|
|
65
|
+
const args = ['--input-type=module', '-e', identityScript, JSON.stringify(selection)];
|
|
66
|
+
const result = docker
|
|
67
|
+
? await compose(record, ['exec', '-T', 'daemon', 'node', ...args])
|
|
68
|
+
: await effects.run(process.execPath, args, { env: localEnv(record), sensitive: true });
|
|
36
69
|
if (result.code !== undefined && result.code !== 0) throw new Error('Owner identity operation failed');
|
|
37
|
-
|
|
70
|
+
let value;
|
|
71
|
+
try { value = JSON.parse(result.stdout); }
|
|
38
72
|
catch { throw new Error('Owner identity operation returned malformed JSON'); }
|
|
73
|
+
if (value?.onboardingError) {
|
|
74
|
+
const error = new Error('Owner identity operation failed');
|
|
75
|
+
error.code = value.onboardingError;
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
return value;
|
|
39
79
|
}
|
|
40
80
|
async function identities(record) {
|
|
41
|
-
const rows = await identityCommand(record,
|
|
81
|
+
const rows = await identityCommand(record, 'list');
|
|
42
82
|
if (!Array.isArray(rows) || rows.some(row => !row || typeof row.name !== 'string'
|
|
43
83
|
|| (!['root', 'role'].includes(row.kind) && !['reconciling', 'awaiting-root', 'migration-failed', 'refresh-failed'].includes(row.status))
|
|
44
84
|
|| (row.kind && (typeof row.cid !== 'string' || !row.cid)))) throw new Error('Owner identity list is malformed');
|
|
@@ -60,10 +100,11 @@ export function createServerOnboarding(effects, { compose, localEnv, bin }) {
|
|
|
60
100
|
if (prior.rows.some(row => row.name === name)) throw new Error('Requested Human identity name already exists; no identity was changed');
|
|
61
101
|
effects.out?.(`Creating Human identity ${name}; retaining ${prior.rows.length} existing identities.`);
|
|
62
102
|
try {
|
|
63
|
-
await identityCommand(record,
|
|
103
|
+
await identityCommand(record, 'create-root', name);
|
|
64
104
|
} catch (error) {
|
|
65
|
-
//
|
|
105
|
+
// A concurrent creator is safe only
|
|
66
106
|
// when the authoritative list now contains a root; other errors stay errors.
|
|
107
|
+
if (error.code !== 'ROOT_EXISTS') throw error;
|
|
67
108
|
const after = await identities(record);
|
|
68
109
|
if (after.root) return retained(after);
|
|
69
110
|
throw error;
|
|
@@ -76,7 +117,7 @@ export function createServerOnboarding(effects, { compose, localEnv, bin }) {
|
|
|
76
117
|
},
|
|
77
118
|
async prepareLocalClient(record, integrations, fleetSettingsPath) {
|
|
78
119
|
validateRecord(record);
|
|
79
|
-
if (!Array.isArray(integrations) ||
|
|
120
|
+
if (!Array.isArray(integrations) || new Set(integrations).size !== integrations.length
|
|
80
121
|
|| integrations.some(name => !['codex', 'claude-code', 'fleet'].includes(name))) throw new Error('Client integrations must select codex, claude-code and/or fleet');
|
|
81
122
|
if (fleetSettingsPath !== undefined) {
|
|
82
123
|
if (typeof fleetSettingsPath !== 'string' || !isAbsolute(fleetSettingsPath) || resolve(fleetSettingsPath) !== fleetSettingsPath) throw new Error('Fleet settings path must be absolute');
|
package/lib/setup-options.mjs
CHANGED
|
@@ -90,7 +90,7 @@ function expandPaths(options, home) {
|
|
|
90
90
|
return output;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
export function parseSetupArgs(argv, { home } = {}) {
|
|
93
|
+
export function parseSetupArgs(argv, { home, validate = true } = {}) {
|
|
94
94
|
if (!Array.isArray(argv) || !argv.every(arg => typeof arg === 'string')) throw new Error('Arguments must be strings');
|
|
95
95
|
const options = { interactive: false, explicitPorts: [] };
|
|
96
96
|
const seen = new Set();
|
|
@@ -121,7 +121,7 @@ export function parseSetupArgs(argv, { home } = {}) {
|
|
|
121
121
|
if (positional.length && scopes.includes(positional[0])) put('scope', positional.shift());
|
|
122
122
|
if (positional.length && ['install', 'update'].includes(positional[0])) put('operation', positional.shift());
|
|
123
123
|
if (positional.length) throw new Error(`Unexpected setup argument: ${positional.join(' ')}`);
|
|
124
|
-
return validateSetupOptions(expandPaths(options, home), { interactive: false });
|
|
124
|
+
return validate ? validateSetupOptions(expandPaths(options, home), { interactive: false }) : expandPaths(options, home);
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
export async function collectSetupOptions(effects) {
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { chmodSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { join,resolve } from 'node:path';
|
|
3
|
+
import {parseSetupArgs} from './setup-options.mjs';
|
|
4
|
+
/** Base64 is transport, not encryption. Broad provider credentials are never accepted. */
|
|
5
|
+
export function decodeWorkspacePayload(encoded,now=Date.now()) {
|
|
6
|
+
if(typeof encoded!=='string' || encoded.length>32768 || !/^[A-Za-z0-9_-]+$/.test(encoded.trim()))throw Error('Invalid private workspace payload');
|
|
7
|
+
let p;try{p=JSON.parse(Buffer.from(encoded.trim(),'base64url'));}catch{throw Error('Invalid private workspace payload');}
|
|
8
|
+
const allowed=['version','appOrigin','hostname','rootName','name','surname','connectorToken','invitation','serverCid','challenge'];
|
|
9
|
+
if(!p || Object.keys(p).some(k=>!allowed.includes(k)) || p.version!==1 || !['https://app.ours.network','https://app.ours-tunnel.com'].includes(p.appOrigin) || !/^[a-z0-9][a-z0-9-]{2,60}\.ours-tunnel\.com$/.test(p.hostname) || !/^[a-z0-9-]{2,30}@[a-z0-9-]{2,30}$/.test(p.rootName) || !/^[a-f0-9]{64}$/i.test(p.serverCid))throw Error('Invalid workspace payload boundary');
|
|
10
|
+
for(const key of ['name','surname','connectorToken','invitation'])if(typeof p[key]!=='string' || !p[key].trim() || p[key].length>8192 || /[\x00-\x1f\x7f]/.test(p[key]))throw Error('Invalid private workspace payload');
|
|
11
|
+
if(!p.challenge || !['nonce','accountId','workspaceId'].every(k=>/^[\w-]{43}$/.test(p.challenge[k])) || !Number.isFinite(p.challenge.expiresAt) || p.challenge.expiresAt<=now || p.challenge.expiresAt>now+16*60000)throw Error('Workspace challenge expired or invalid');
|
|
12
|
+
return p;
|
|
13
|
+
}
|
|
14
|
+
export function extractWorkspaceArgs(args){
|
|
15
|
+
const flags=['--setup-workspace','--setup-workspace-file','--workspace-fleet-bin','--fleet-settings'];const values={},rest=[];
|
|
16
|
+
for(let i=0;i<args.length;i++){const at=args[i].indexOf('='),flag=at<0?args[i]:args[i].slice(0,at);if(!flags.includes(flag)){rest.push(args[i]);continue;}if(values[flag]!==undefined)throw Error('Duplicate workspace flag');const value=at<0?args[++i]:args[i].slice(at+1);if(!value || value.startsWith('--'))throw Error('Workspace flag requires a value');values[flag]=value;}
|
|
17
|
+
if(values['--setup-workspace'] && values['--setup-workspace-file'])throw Error('Choose one private payload transport');
|
|
18
|
+
return {values,rest};
|
|
19
|
+
}
|
|
20
|
+
export async function runWorkspaceSetup(args,effects,runSetup){
|
|
21
|
+
const migrateAppOrigin=args.includes('--workspace-migrate-app-origin');
|
|
22
|
+
if(args.filter(arg=>arg==='--workspace-migrate-app-origin').length>1)throw Error('Duplicate workspace migration flag');
|
|
23
|
+
const {values,rest}=extractWorkspaceArgs(args.filter(arg=>arg!=='--workspace-migrate-app-origin'));let encoded;
|
|
24
|
+
if(values['--setup-workspace-file']){const path=resolve(values['--setup-workspace-file']),stat=lstatSync(path);if(!stat.isFile() || stat.isSymbolicLink() || stat.nlink!==1 || stat.uid!==process.getuid?.() || stat.size>32768 || (stat.mode&0o077)!==0)throw Error('Setup file must be owned and private (chmod 600)');encoded=readFileSync(path,'utf8').trim();}
|
|
25
|
+
else if(values['--setup-workspace']==='-'){const chunks=[];let bytes=0;for await(const chunk of process.stdin){bytes+=chunk.length;if(bytes>32768)throw Error('Private payload too large');chunks.push(chunk);}encoded=Buffer.concat(chunks).toString().trim();}
|
|
26
|
+
else encoded=values['--setup-workspace'];
|
|
27
|
+
const p=decodeWorkspacePayload(encoded),fleetBin=values['--workspace-fleet-bin'] || 'ours-fleet';
|
|
28
|
+
const parsed=parseSetupArgs(rest,{home:effects.home,validate:false});
|
|
29
|
+
if(parsed.scope==='server')throw Error('Workspace setup requires all or client scope');
|
|
30
|
+
if(parsed.identityName!==undefined || parsed.integrations!==undefined)throw Error('Workspace setup supplies identity and client integration selection');
|
|
31
|
+
// Check feature availability before changing an installation. Task acceptance uses
|
|
32
|
+
// an exact task-built binary; @latest cannot contain an unmerged feature.
|
|
33
|
+
const root=parsed.stateDir || join(effects.home,'.ours-network','workspace'),fleetSettings=values['--fleet-settings'];
|
|
34
|
+
const options=[...rest];if(!parsed.scope)options.push('--scope',parsed.config?'client':'all');if(!parsed.mode && !parsed.config)options.push('--mode','docker');if(!parsed.stateDir && !parsed.config)options.push('--state-dir',root);
|
|
35
|
+
if(!parsed.config)options.push('--identity-name',p.rootName);options.push('--integrations','none');
|
|
36
|
+
parseSetupArgs(options,{home:effects.home});
|
|
37
|
+
await effects.run(fleetBin,['workspace-enroll','--help'],{sensitive:true});
|
|
38
|
+
await effects.run('cloudflared',['--version'],{sensitive:true});
|
|
39
|
+
const result=await runSetup(options,effects);if(result!==0)return result;
|
|
40
|
+
if(options.includes('--dry-run'))return 0;
|
|
41
|
+
const initArgs=['init',...(fleetSettings?['--settings',fleetSettings]:[])];
|
|
42
|
+
const selected=effects.readManagedClientProfile();if(!selected)throw Error('Workspace client profile was not installed');
|
|
43
|
+
const env={OURS_CONFIG:join(effects.home,'.ours-client','profile.json')};
|
|
44
|
+
// An explicit managed gateway profile must not compete with inherited daemon selectors.
|
|
45
|
+
for(const key of ['OURS_PORT','OURS_STATE_DIR','OURS_API_TOKEN','OURS_DAEMON_ID','OURS_DAEMON_URL','OURS_DAEMON_CREDENTIAL_PATH'])env[key]=undefined;
|
|
46
|
+
const initialized=fleetSettings?await effects.run(fleetBin,initArgs,{env}):await effects.runInteractive(fleetBin,initArgs,{env});if(!initialized.ok)throw Error('Fleet configuration incomplete');
|
|
47
|
+
mkdirSync(root,{recursive:true,mode:0o700});const temporary=mkdtempSync(join(root,'.workspace-payload-'));chmodSync(temporary,0o700);
|
|
48
|
+
const payloadFile=join(temporary,'payload');writeFileSync(payloadFile,encoded,{mode:0o600,flag:'wx'});
|
|
49
|
+
try{await effects.run(fleetBin,['workspace-enroll','--file',payloadFile,...(migrateAppOrigin?['--migrate-app-origin']:[])],{env,stream:true,sensitive:true});}
|
|
50
|
+
finally{rmSync(temporary,{recursive:true,force:true});}
|
|
51
|
+
effects.out('Workspace proof submitted. Check verified binding/tunnel status in your account, then scan or paste the private device code.');return 0;
|
|
52
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ours.network/install",
|
|
3
|
-
"version": "1.2.1-nightly.
|
|
3
|
+
"version": "1.2.1-nightly.18",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The all-in-one ours.network installer: one shared daemon, MCP, cowork, Telegram, Fleet initialization, harness plugins, Human identity, progress UI, and guided next steps.",
|
|
6
6
|
"type": "module",
|