@ducking-mind/proxy-app-cli 0.1.1 → 0.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ducking-mind/proxy-app-cli",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "CLI for creating, building and publishing Proxy platform apps",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,16 +25,19 @@
25
25
  },
26
26
  "files": [
27
27
  "proxy-app.mjs",
28
+ "backend-container.mjs",
29
+ "platform-settings.mjs",
28
30
  "local-dev-relay.mjs",
29
31
  "local-dev-credentials.mjs",
32
+ "runtime-sources.mjs",
30
33
  "artifact-security.mjs",
31
34
  "agent-contract.mjs",
32
- "agent-runtime/*.mjs",
33
- "release-runtime/*.mjs",
35
+ "agent-runtime/protocol.mjs",
36
+ "agent-runtime/package-guide.mjs",
34
37
  "prepare-agent-runtime.mjs"
35
38
  ],
36
39
  "scripts": {
37
- "test": "node --check proxy-app.mjs && node --check agent-contract.mjs && node --test *.test.mjs",
40
+ "test": "node --check proxy-app.mjs && node --check agent-contract.mjs && node --check runtime-sources.mjs && node --test *.test.mjs",
38
41
  "prepublishOnly": "npm test",
39
42
  "prepack": "node prepare-agent-runtime.mjs",
40
43
  "pretest": "npm --prefix ../proxy-app-sdk run build"
@@ -43,7 +46,6 @@
43
46
  "access": "public"
44
47
  },
45
48
  "dependencies": {
46
- "@ducking-mind/proxy-app-desktop-runtime": "^0.1.0",
47
49
  "fflate": "^0.8.2"
48
50
  },
49
51
  "engines": {
@@ -0,0 +1,20 @@
1
+ export const DEFAULT_PLATFORM_URL = 'https://www.duckingmind.com'
2
+ export const DEFAULT_PLATFORM_GATEWAY_URL = 'https://api.duckingmind.com/v1'
3
+
4
+ export function platformAPIBaseURL(env = process.env) {
5
+ const explicit = env.PROXY_API_BASE_URL?.trim()
6
+ if (explicit) return explicit.replace(/\/$/, '')
7
+ const platform = env.PROXY_PLATFORM_URL?.trim() || DEFAULT_PLATFORM_URL
8
+ let url
9
+ try { url = new URL(platform) } catch { throw new Error('PROXY_PLATFORM_URL must be a valid platform origin, such as https://platform.example') }
10
+ if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password || url.search || url.hash || url.pathname !== '/') {
11
+ throw new Error('PROXY_PLATFORM_URL must be a platform origin without a path, credentials, query, or hash')
12
+ }
13
+ return `${url.origin}/api`
14
+ }
15
+
16
+ export function platformPortalURL(env = process.env) {
17
+ const explicit = env.PROXY_PORTAL_URL?.trim() || env.PROXY_PUBLIC_URL?.trim()
18
+ if (explicit) return explicit
19
+ return env.PROXY_PLATFORM_URL?.trim() || DEFAULT_PLATFORM_URL
20
+ }
@@ -1,43 +1,10 @@
1
- import { copyFile, mkdir, readFile, readdir, rm, stat, writeFile } from 'node:fs/promises'
1
+ import { access } from 'node:fs/promises'
2
2
 
3
- const source = new URL('../desktop/agent/', import.meta.url)
4
- const destination = new URL('./agent-runtime/', import.meta.url)
5
- const modules = new Set()
6
- async function collect(name) {
7
- if (modules.has(name)) return
8
- if (!/^[a-z][a-z0-9-]*\.mjs$/.test(name)) throw new Error(`Invalid agent runtime module: ${name}`)
9
- modules.add(name)
10
- const content = await readFile(new URL(name, source), 'utf8')
11
- for (const match of content.matchAll(/(?:from\s*|import\s*)['"]\.\/([^'"]+)['"]/g)) await collect(match[1])
12
- await writeFile(new URL(name, destination), content)
3
+ // These modules are deliberately maintained as public, dependency-free copies.
4
+ // They contain the application capability contract and package validation only;
5
+ // the proprietary desktop host and its build scripts are never copied into an
6
+ // npm package.
7
+ for (const file of ['./agent-runtime/protocol.mjs', './agent-runtime/package-guide.mjs']) {
8
+ await access(new URL(file, import.meta.url))
13
9
  }
14
-
15
- // Include the transitive local imports, never the Electron entry points.
16
- // Repacking an installed npm package reuses its already bundled runtime.
17
- const hasSource = await stat(source).then(() => true).catch(error => { if (error.code !== 'ENOENT') throw error; return false })
18
- if (hasSource) {
19
- await mkdir(destination, { recursive: true })
20
- await collect('protocol.mjs')
21
- await collect('package-guide.mjs')
22
- for (const entry of await readdir(destination)) if (!modules.has(entry)) await rm(new URL(entry, destination), { recursive: true, force: true })
23
- } else {
24
- await import(new URL('package-guide.mjs', destination))
25
- }
26
- // The package contract resolver uses this same bundled validation, including
27
- // when it is run as a project's direct build helper.
28
10
  await import(new URL('./agent-contract.mjs', import.meta.url))
29
-
30
- // The standalone CLI also exposes Electron release helpers. Keep a small copy
31
- // in the npm package so an installed CLI does not depend on the monorepo's
32
- // app/desktop directory. Source checkouts still use the live modules below.
33
- const releaseSource = new URL('../desktop/scripts/', import.meta.url)
34
- const releaseDestination = new URL('./release-runtime/', import.meta.url)
35
- const releaseModules = ['release-config.mjs', 'release-target.mjs']
36
- const hasReleaseSource = await stat(new URL(releaseModules[0], releaseSource)).then(() => true).catch(error => {
37
- if (error.code !== 'ENOENT') throw error
38
- return false
39
- })
40
- if (hasReleaseSource) {
41
- await mkdir(releaseDestination, { recursive: true })
42
- for (const name of releaseModules) await copyFile(new URL(name, releaseSource), new URL(name, releaseDestination))
43
- }