@memohai/cloud-runtime 0.1.0 → 2026.9.12-1

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/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@memohai/cloud-runtime",
3
- "version": "0.1.0",
3
+ "version": "2026.9.12-1",
4
4
  "description": "Memoh Cloud Remote Runtime CLI — connects a local machine to Memoh Cloud",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "git+https://github.com/memohai/Memoh-Cloud.git",
7
+ "url": "git+https://github.com/felinics/Memoh-Cloud.git",
8
8
  "directory": "packages/cloud-runtime"
9
9
  },
10
10
  "license": "AGPL-3.0-only",
@@ -20,6 +20,12 @@
20
20
  "publishConfig": {
21
21
  "access": "public"
22
22
  },
23
+ "scripts": {
24
+ "build": "node scripts/build.mjs",
25
+ "prepack": "pnpm run build",
26
+ "test": "vitest run",
27
+ "typecheck": "tsc --noEmit"
28
+ },
23
29
  "engines": {
24
30
  "node": ">=20"
25
31
  },
@@ -28,10 +34,5 @@
28
34
  "esbuild": "0.27.2",
29
35
  "typescript": "^6.0.3",
30
36
  "vitest": "^4.1.10"
31
- },
32
- "scripts": {
33
- "build": "node scripts/build.mjs",
34
- "test": "vitest run",
35
- "typecheck": "tsc --noEmit"
36
37
  }
37
- }
38
+ }
package/scripts/build.mjs CHANGED
@@ -82,15 +82,16 @@ await verifyHelpBranding()
82
82
  * is live, so its own error is the success signal here.
83
83
  */
84
84
  async function verifyBundleLoads() {
85
- const { code, stderr, stdout } = await run(process.execPath, [resolve(outdir, 'cli.mjs')], {
85
+ const { code, stderr, stdout } = await run(process.execPath, [resolve(outdir, 'cli.mjs'), '--server', 'https://runtime-smoke.invalid'], {
86
86
  // Scrub the developer's own credentials: with a key present the CLI would
87
- // skip validation and try to connect, hanging the build.
87
+ // skip validation and try to connect, hanging the build. An explicit server
88
+ // also prevents the new CLI from reading any saved local enrollment.
88
89
  ...process.env,
89
90
  MEMOH_RUNTIME_SERVER: '',
90
91
  MEMOH_RUNTIME_KEY: '',
91
92
  MEMOH_RUNTIME_TEAM_ID: '',
92
93
  })
93
- if (!stderr.includes('--server and --key are required')) {
94
+ if (code === 0 || !/--server and --key (?:are required|must be provided together)/.test(stderr)) {
94
95
  throw new Error(`bundle smoke test failed (exit ${code}):\n${stderr || stdout}`)
95
96
  }
96
97
  }
package/src/bootstrap.ts CHANGED
@@ -14,14 +14,14 @@ const args = process.argv.slice(2)
14
14
 
15
15
  // Both flags are handled here rather than upstream: the usage string there
16
16
  // names `memoh-runtime` and cannot know the Cloud default endpoint, and
17
- // upstream has no --version at all.
18
- if (args.includes('--help') || args.includes('-h')) {
17
+ // the build stamp also identifies the bundled upstream commit.
18
+ if (args[0] === 'help' || args.includes('--help') || args.includes('-h')) {
19
19
  // stderr and exit 0, matching upstream's usage() contract.
20
- console.error(cloudUsage())
20
+ console.error(cloudUsage(args))
21
21
  process.exit(0)
22
22
  }
23
23
 
24
- if (args.includes('--version') || args.includes('-v')) {
24
+ if (args[0] === 'version' || args.includes('--version') || args.includes('-v')) {
25
25
  console.log(versionReport())
26
26
  process.exit(0)
27
27
  }
package/src/cloud.ts CHANGED
@@ -30,10 +30,13 @@ export const serverUrlEnvVar = 'MEMOH_RUNTIME_SERVER'
30
30
  * install), which is why both escape hatches are checked first.
31
31
  */
32
32
  export function applyCloudDefaults(args: readonly string[], env: NodeJS.ProcessEnv): void {
33
- // The prefix match also catches `--server=url`, a spelling upstream does NOT
34
- // parse. Seeding the default there would silently redirect a mistyped-but-
35
- // explicit endpoint to Cloud production; deferring lets upstream's own
36
- // usage error surface so the caller fixes the spelling instead.
33
+ // A foreground run without a new key reads the saved enrollment. Injecting
34
+ // a server alone would turn it into an incomplete explicit connection.
35
+ if (!args.some(arg => arg === '--key' || arg.startsWith('--key=')) && !env.MEMOH_RUNTIME_KEY?.trim()) {
36
+ return
37
+ }
38
+ // Both endpoint spellings remain owned by the caller. Upstream validates
39
+ // their values; Cloud must not redirect an explicit endpoint.
37
40
  if (args.some(arg => arg === '--server' || arg.startsWith('--server='))) {
38
41
  return
39
42
  }
@@ -47,11 +50,24 @@ export function applyCloudDefaults(args: readonly string[], env: NodeJS.ProcessE
47
50
  * Cloud-branded help text. The upstream string names `memoh-runtime` and omits
48
51
  * the default endpoint, so this package prints its own and never reaches it.
49
52
  */
50
- export function cloudUsage(): string {
53
+ export function cloudUsage(args: readonly string[] = []): string {
54
+ const command = args[0]
55
+ if (command === 'service') {
56
+ return 'Usage: memoh-cloud-runtime service <install|start|stop|restart|status|uninstall>\nInstall registers a stopped service. Use enroll first; status supports --json.'
57
+ }
58
+ if (command === 'enroll') {
59
+ return `Usage: memoh-cloud-runtime enroll --key <key> [--server <url>] [--team-id <uuid>] [--replace]\nOr use enroll --config <file>. Saves enrollment for future runs.\n--server defaults to ${cloudDefaultServerUrl} (or $MEMOH_RUNTIME_SERVER).`
60
+ }
61
+ if (command === 'run') {
62
+ return `Usage: memoh-cloud-runtime run [--key <key> [--server <url>] | --config <file>] [--log <file>]\nReads saved enrollment when no new connection is supplied. Never saves or changes a service.\n--server defaults to ${cloudDefaultServerUrl} when a new key is supplied.`
63
+ }
51
64
  return [
52
- 'Usage: memoh-cloud-runtime --key <key> [--team-id <uuid>] [--server <url>] [--insecure-localhost]',
65
+ 'Usage: memoh-cloud-runtime <enroll|run|service|version>',
66
+ ' memoh-cloud-runtime --key <key> [--team-id <uuid>] [--server <url>] [--insecure-localhost]',
53
67
  '',
54
68
  'Connects this machine to Memoh Cloud as a remote runtime.',
69
+ 'Use <command> --help for enrollment and user-service commands.',
70
+ 'Running without connection flags reads the saved enrollment.',
55
71
  '',
56
72
  ` --server defaults to ${cloudDefaultServerUrl}`,
57
73
  ' (or $MEMOH_RUNTIME_SERVER when exported)',