@sixb/cli 0.1.19 → 0.1.21
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 +26 -27
- package/dist/commands/api.d.ts +0 -1
- package/dist/commands/api.d.ts.map +1 -1
- package/dist/commands/app.d.ts.map +1 -1
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/dev-runner.d.ts +12 -1
- package/dist/commands/dev-runner.d.ts.map +1 -1
- package/dist/commands/lake-check.d.ts.map +1 -1
- package/dist/commands/lake-cleanup.d.ts +2 -0
- package/dist/commands/lake-cleanup.d.ts.map +1 -1
- package/dist/commands/worker-group.d.ts +1 -0
- package/dist/commands/worker-group.d.ts.map +1 -1
- package/dist/commands/worker.d.ts +1 -0
- package/dist/commands/worker.d.ts.map +1 -1
- package/dist/lib/browser-topology.d.ts +9 -33
- package/dist/lib/browser-topology.d.ts.map +1 -1
- package/dist/lib/command-line.d.ts +8 -8
- package/dist/lib/command-line.d.ts.map +1 -1
- package/dist/lib/deploy-release.d.ts.map +1 -1
- package/dist/lib/dev-supervisor.d.ts.map +1 -1
- package/dist/lib/dev-watch.d.ts +1 -1
- package/dist/lib/dev-watch.d.ts.map +1 -1
- package/dist/lib/production-roles.d.ts +5 -10
- package/dist/lib/production-roles.d.ts.map +1 -1
- package/dist/lib/production.d.ts +1 -2
- package/dist/lib/production.d.ts.map +1 -1
- package/dist/lib/role-view.d.ts +2 -3
- package/dist/lib/role-view.d.ts.map +1 -1
- package/dist/lib/runtime.d.ts +9 -0
- package/dist/lib/runtime.d.ts.map +1 -1
- package/dist/lib/worker-concurrency.d.ts +5 -0
- package/dist/lib/worker-concurrency.d.ts.map +1 -1
- package/dist/lib/worker-registry.d.ts +1 -0
- package/dist/lib/worker-registry.d.ts.map +1 -1
- package/dist/ui/index.d.ts +16 -5
- package/dist/ui/index.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/commands/api.tsx +1 -5
- package/src/commands/app.tsx +5 -7
- package/src/commands/build.tsx +14 -31
- package/src/commands/check.tsx +50 -4
- package/src/commands/dev-runner.tsx +43 -47
- package/src/commands/lake-check.tsx +15 -2
- package/src/commands/lake-cleanup.tsx +11 -0
- package/src/commands/worker-group.tsx +4 -1
- package/src/commands/worker.tsx +4 -1
- package/src/index.tsx +3 -14
- package/src/lib/browser-topology.ts +28 -135
- package/src/lib/command-line.ts +26 -18
- package/src/lib/deploy-release.ts +0 -3
- package/src/lib/dev-supervisor.ts +7 -6
- package/src/lib/dev-watch.ts +8 -8
- package/src/lib/production-roles.ts +5 -7
- package/src/lib/production.ts +3 -8
- package/src/lib/profiles.ts +1 -1
- package/src/lib/role-lifecycle.ts +2 -2
- package/src/lib/role-view.ts +2 -3
- package/src/lib/runtime.ts +19 -0
- package/src/lib/worker-concurrency.ts +11 -0
- package/src/lib/worker-registry.ts +5 -1
- package/src/ui/index.tsx +46 -19
- package/dist/commands/atlas.d.ts +0 -9
- package/dist/commands/atlas.d.ts.map +0 -1
- package/src/commands/atlas.tsx +0 -71
|
@@ -5,7 +5,7 @@ import { runUntilSignal, stopQuietly } from "../lib/role-lifecycle"
|
|
|
5
5
|
import { recordApiPublicOrigin, stopSixbProviders, waitForWorkerFailure } from "../lib/runtime"
|
|
6
6
|
import { assertShareableProviders } from "../lib/shareable-providers"
|
|
7
7
|
import { migrateStorageForRole } from "../lib/storage-migration"
|
|
8
|
-
import { resolveWorkerConcurrency } from "../lib/worker-concurrency"
|
|
8
|
+
import { resolveVectorConcurrency, resolveWorkerConcurrency } from "../lib/worker-concurrency"
|
|
9
9
|
import {
|
|
10
10
|
agentRuntimeRequired,
|
|
11
11
|
assertWorkerInputs,
|
|
@@ -23,6 +23,7 @@ export interface WorkerGroupOptions {
|
|
|
23
23
|
apiPublicOrigin?: string
|
|
24
24
|
agentTurnTimeout?: string
|
|
25
25
|
concurrency?: readonly string[]
|
|
26
|
+
vectorConcurrency?: string
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
export async function runWorkerGroup(options: WorkerGroupOptions = {}) {
|
|
@@ -33,6 +34,7 @@ export async function runWorkerGroup(options: WorkerGroupOptions = {}) {
|
|
|
33
34
|
const requestedTypes = (options.workerTypes ?? []).map(resolveWorkerTypeToStart)
|
|
34
35
|
const agentTurnTimeoutMs = resolveAgentTurnTimeoutMs(options.agentTurnTimeout)
|
|
35
36
|
const workerConcurrency = resolveWorkerConcurrency(options.concurrency)
|
|
37
|
+
const vectorConcurrency = resolveVectorConcurrency(options.vectorConcurrency)
|
|
36
38
|
const entry = await resolveRuntimeEntry({ entry: options.entry })
|
|
37
39
|
|
|
38
40
|
const app = renderPersistent(
|
|
@@ -92,6 +94,7 @@ export async function runWorkerGroup(options: WorkerGroupOptions = {}) {
|
|
|
92
94
|
agentApiBaseUrl: options.apiPublicOrigin,
|
|
93
95
|
agentTurnTimeoutMs,
|
|
94
96
|
workerConcurrency,
|
|
97
|
+
vectorConcurrency,
|
|
95
98
|
})
|
|
96
99
|
)
|
|
97
100
|
await Promise.all(workers.map((worker) => worker.start()))
|
package/src/commands/worker.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import { runUntilSignal, stopQuietly } from "../lib/role-lifecycle"
|
|
|
6
6
|
import { recordApiPublicOrigin, stopSixbProviders, waitForWorkerFailure } from "../lib/runtime"
|
|
7
7
|
import { assertShareableProviders } from "../lib/shareable-providers"
|
|
8
8
|
import { migrateStorageForRole } from "../lib/storage-migration"
|
|
9
|
-
import { resolveSingleWorkerConcurrency } from "../lib/worker-concurrency"
|
|
9
|
+
import { resolveSingleWorkerConcurrency, resolveVectorConcurrency } from "../lib/worker-concurrency"
|
|
10
10
|
import {
|
|
11
11
|
agentRuntimeRequired,
|
|
12
12
|
createWorkerForType,
|
|
@@ -23,6 +23,7 @@ export interface WorkerOptions {
|
|
|
23
23
|
apiPublicOrigin?: string
|
|
24
24
|
agentTurnTimeout?: string
|
|
25
25
|
concurrency?: string
|
|
26
|
+
vectorConcurrency?: string
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
export async function runWorker(options: WorkerOptions = {}) {
|
|
@@ -31,6 +32,7 @@ export async function runWorker(options: WorkerOptions = {}) {
|
|
|
31
32
|
const workerType = resolveWorkerTypeToStart(options.workerType)
|
|
32
33
|
const agentTurnTimeoutMs = resolveAgentTurnTimeoutMs(options.agentTurnTimeout)
|
|
33
34
|
const workerConcurrency = resolveSingleWorkerConcurrency(workerType, options.concurrency)
|
|
35
|
+
const vectorConcurrency = resolveVectorConcurrency(options.vectorConcurrency)
|
|
34
36
|
const entry = await resolveRuntimeEntry({ entry: options.entry })
|
|
35
37
|
|
|
36
38
|
const app = renderPersistent(
|
|
@@ -76,6 +78,7 @@ export async function runWorker(options: WorkerOptions = {}) {
|
|
|
76
78
|
agentApiBaseUrl: options.apiPublicOrigin,
|
|
77
79
|
agentTurnTimeoutMs,
|
|
78
80
|
workerConcurrency,
|
|
81
|
+
vectorConcurrency,
|
|
79
82
|
})
|
|
80
83
|
await worker.start()
|
|
81
84
|
|
package/src/index.tsx
CHANGED
|
@@ -102,10 +102,10 @@ async function main(): Promise<void> {
|
|
|
102
102
|
apiPort: getFlag("api-port"),
|
|
103
103
|
apiHost: getFlag("api-host"),
|
|
104
104
|
apiPublicOrigin: getFlag("api-public-origin"),
|
|
105
|
-
atlasPublicOrigin: getFlag("atlas-public-origin"),
|
|
106
105
|
appPublicOrigin: getFlag("app-public-origin"),
|
|
107
106
|
agentTurnTimeout: getFlag("agent-turn-timeout"),
|
|
108
107
|
concurrency: getFlags("concurrency"),
|
|
108
|
+
vectorConcurrency: getFlag("vector-concurrency"),
|
|
109
109
|
})
|
|
110
110
|
break
|
|
111
111
|
}
|
|
@@ -119,6 +119,7 @@ async function main(): Promise<void> {
|
|
|
119
119
|
apiPublicOrigin: getFlag("api-public-origin"),
|
|
120
120
|
agentTurnTimeout: getFlag("agent-turn-timeout"),
|
|
121
121
|
concurrency: getFlag("concurrency"),
|
|
122
|
+
vectorConcurrency: getFlag("vector-concurrency"),
|
|
122
123
|
})
|
|
123
124
|
break
|
|
124
125
|
}
|
|
@@ -132,6 +133,7 @@ async function main(): Promise<void> {
|
|
|
132
133
|
apiPublicOrigin: getFlag("api-public-origin"),
|
|
133
134
|
agentTurnTimeout: getFlag("agent-turn-timeout"),
|
|
134
135
|
concurrency: getFlags("concurrency"),
|
|
136
|
+
vectorConcurrency: getFlag("vector-concurrency"),
|
|
135
137
|
})
|
|
136
138
|
break
|
|
137
139
|
}
|
|
@@ -146,25 +148,12 @@ async function main(): Promise<void> {
|
|
|
146
148
|
apiPort: getFlag("api-port"),
|
|
147
149
|
apiHost: getFlag("api-host"),
|
|
148
150
|
apiPublicOrigin: getFlag("api-public-origin"),
|
|
149
|
-
atlasPublicOrigin: getFlag("atlas-public-origin"),
|
|
150
151
|
appPublicOrigin: getFlag("app-public-origin"),
|
|
151
152
|
trustedProxies: getFlag("trusted-proxies"),
|
|
152
153
|
})
|
|
153
154
|
break
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
case "atlas": {
|
|
157
|
-
const { runAtlas } = await import("./commands/atlas")
|
|
158
|
-
await runAtlas({
|
|
159
|
-
entry: getFlag("entry"),
|
|
160
|
-
port: getFlag("port"),
|
|
161
|
-
host: getFlag("host"),
|
|
162
|
-
apiPublicOrigin: getFlag("api-public-origin"),
|
|
163
|
-
atlasPublicOrigin: getFlag("atlas-public-origin"),
|
|
164
|
-
})
|
|
165
|
-
break
|
|
166
|
-
}
|
|
167
|
-
|
|
168
157
|
case "app": {
|
|
169
158
|
const { runApp } = await import("./commands/app")
|
|
170
159
|
await runApp({
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import type { SixbBrowserOrigin } from "@sixb/server"
|
|
2
1
|
import { configuredOrigin } from "./public-origin"
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* The process resolving the topology. One answer settles what used to be four options: whether
|
|
6
|
-
* local defaults apply,
|
|
7
|
-
*
|
|
5
|
+
* local defaults apply, whether the app's origin is required, and whether the process serves the
|
|
6
|
+
* app itself.
|
|
8
7
|
*/
|
|
9
|
-
export type BrowserRole = "dev" | "api" | "
|
|
8
|
+
export type BrowserRole = "dev" | "api" | "app"
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
interface BrowserBindOptions {
|
|
10
|
+
export interface BrowserTopologyOptions {
|
|
11
|
+
readonly role: BrowserRole
|
|
15
12
|
readonly host?: string
|
|
16
13
|
/** `--port`: the port this role binds. See {@link resolveBrowserPorts}. */
|
|
17
14
|
readonly port?: string
|
|
@@ -19,40 +16,18 @@ interface BrowserBindOptions {
|
|
|
19
16
|
readonly apiHost?: string
|
|
20
17
|
readonly apiPort?: string
|
|
21
18
|
readonly apiPublicOrigin?: string
|
|
22
|
-
readonly atlasPublicOrigin?: string
|
|
23
19
|
readonly appPublicOrigin?: string
|
|
24
20
|
}
|
|
25
21
|
|
|
26
|
-
export type BrowserTopologyOptions = BrowserBindOptions &
|
|
27
|
-
(
|
|
28
|
-
| {
|
|
29
|
-
/**
|
|
30
|
-
* Hosts the API, so its allowlist has to name every surface the project actually
|
|
31
|
-
* serves — including the custom app, which exists only when the project has one.
|
|
32
|
-
*/
|
|
33
|
-
readonly role: "dev" | "api"
|
|
34
|
-
readonly hasCustomApp: boolean
|
|
35
|
-
}
|
|
36
|
-
| { readonly role: BrowserSurface }
|
|
37
|
-
)
|
|
38
|
-
|
|
39
22
|
export interface BrowserTopology {
|
|
40
23
|
readonly host: string
|
|
41
24
|
readonly apiHost: string
|
|
42
|
-
readonly atlasPort: number
|
|
43
25
|
readonly appPort: number
|
|
44
26
|
readonly apiPort: number
|
|
45
27
|
readonly apiPublicOrigin: string
|
|
46
|
-
|
|
28
|
+
/** `null` outside `sixb dev` when nobody said where the app is published. */
|
|
47
29
|
readonly appPublicOrigin: string | null
|
|
48
|
-
readonly allowedBrowserOrigins: readonly
|
|
49
|
-
/** The surface this process serves itself, or `null` when it serves none. */
|
|
50
|
-
readonly serves: BrowserSurface | null
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** A topology resolved by a role that serves a surface, so {@link servedUrl} always has one. */
|
|
54
|
-
export interface ServingBrowserTopology extends BrowserTopology {
|
|
55
|
-
readonly serves: BrowserSurface
|
|
30
|
+
readonly allowedBrowserOrigins: readonly string[]
|
|
56
31
|
}
|
|
57
32
|
|
|
58
33
|
interface BrowserHosts {
|
|
@@ -61,14 +36,12 @@ interface BrowserHosts {
|
|
|
61
36
|
}
|
|
62
37
|
|
|
63
38
|
interface BrowserPorts {
|
|
64
|
-
readonly atlasPort: number
|
|
65
39
|
readonly appPort: number
|
|
66
40
|
readonly apiPort: number
|
|
67
41
|
}
|
|
68
42
|
|
|
69
43
|
interface BrowserPublicOrigins {
|
|
70
44
|
readonly apiPublicOrigin: string
|
|
71
|
-
readonly atlasPublicOrigin: string | null
|
|
72
45
|
readonly appPublicOrigin: string | null
|
|
73
46
|
}
|
|
74
47
|
|
|
@@ -80,14 +53,9 @@ interface BrowserPublicOrigins {
|
|
|
80
53
|
*/
|
|
81
54
|
const DEFAULT_PRODUCTION_HOST = "0.0.0.0"
|
|
82
55
|
const DEFAULT_DEVELOPMENT_HOST = "127.0.0.1"
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
const DEFAULT_API_PORT_OFFSET = 2
|
|
56
|
+
const DEFAULT_APP_PORT = 3000
|
|
57
|
+
const DEFAULT_API_PORT_OFFSET = 1
|
|
86
58
|
|
|
87
|
-
export function resolveBrowserTopology(
|
|
88
|
-
options: BrowserBindOptions & { readonly role: BrowserSurface }
|
|
89
|
-
): ServingBrowserTopology
|
|
90
|
-
export function resolveBrowserTopology(options: BrowserTopologyOptions): BrowserTopology
|
|
91
59
|
export function resolveBrowserTopology(options: BrowserTopologyOptions): BrowserTopology {
|
|
92
60
|
const hosts = resolveBrowserHosts(options)
|
|
93
61
|
const ports = resolveBrowserPorts(options)
|
|
@@ -98,25 +66,6 @@ export function resolveBrowserTopology(options: BrowserTopologyOptions): Browser
|
|
|
98
66
|
...ports,
|
|
99
67
|
...origins,
|
|
100
68
|
allowedBrowserOrigins: createAllowedBrowserOrigins(origins),
|
|
101
|
-
serves: servedSurface(options.role),
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/** The surface a role serves itself. For the two roles that serve one, it is the role. */
|
|
106
|
-
function servedSurface(role: BrowserRole): BrowserSurface | null {
|
|
107
|
-
return role === "atlas" || role === "app" ? role : null
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/** The surfaces a role's topology has to resolve an origin for. */
|
|
111
|
-
function surfacesOf(options: BrowserTopologyOptions): Record<BrowserSurface, boolean> {
|
|
112
|
-
switch (options.role) {
|
|
113
|
-
case "dev":
|
|
114
|
-
case "api":
|
|
115
|
-
return { atlas: true, app: options.hasCustomApp }
|
|
116
|
-
case "atlas":
|
|
117
|
-
return { atlas: true, app: false }
|
|
118
|
-
case "app":
|
|
119
|
-
return { atlas: false, app: true }
|
|
120
69
|
}
|
|
121
70
|
}
|
|
122
71
|
|
|
@@ -130,19 +79,18 @@ function resolveBrowserHosts(options: BrowserTopologyOptions): BrowserHosts {
|
|
|
130
79
|
}
|
|
131
80
|
|
|
132
81
|
/**
|
|
133
|
-
* `--port` is the port the role binds. `sixb dev` binds
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
82
|
+
* `--port` is the port the role binds. `sixb dev` binds the app and the API, so there it moves
|
|
83
|
+
* both and the API keeps its offset from the app. Every other role binds exactly one, and `--port`
|
|
84
|
+
* moves only that one — which is why `sixb api --port 4000` listens on 4000 and not one past it.
|
|
85
|
+
* The port a role does not bind keeps its default and is read by nobody.
|
|
137
86
|
*/
|
|
138
87
|
function resolveBrowserPorts(options: BrowserTopologyOptions): BrowserPorts {
|
|
139
88
|
const requested = parsePort(options.port, "port")
|
|
140
|
-
const base = options.role === "dev" ? (requested ??
|
|
89
|
+
const base = options.role === "dev" ? (requested ?? DEFAULT_APP_PORT) : DEFAULT_APP_PORT
|
|
141
90
|
const bound = options.role === "dev" ? undefined : requested
|
|
142
91
|
|
|
143
92
|
return {
|
|
144
|
-
|
|
145
|
-
appPort: (options.role === "app" ? bound : undefined) ?? base + DEFAULT_APP_PORT_OFFSET,
|
|
93
|
+
appPort: (options.role === "app" ? bound : undefined) ?? base,
|
|
146
94
|
apiPort:
|
|
147
95
|
parsePort(options.apiPort, "api-port") ??
|
|
148
96
|
(options.role === "api" ? bound : undefined) ??
|
|
@@ -154,74 +102,24 @@ function resolveBrowserPublicOrigins(
|
|
|
154
102
|
options: BrowserTopologyOptions,
|
|
155
103
|
ports: BrowserPorts
|
|
156
104
|
): BrowserPublicOrigins {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
// Every browser surface sends its requests here, so this one is never inferred in production.
|
|
105
|
+
// The app sends its requests here, so this one is never inferred in production.
|
|
160
106
|
const apiPublicOrigin =
|
|
161
107
|
configuredOrigin(options.apiPublicOrigin, "SIXB_API_PUBLIC_ORIGIN", "API public origin") ??
|
|
162
108
|
localOrigin(options.role, ports.apiPort) ??
|
|
163
109
|
refusePublicOrigin("SIXB_API_PUBLIC_ORIGIN")
|
|
164
110
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
})
|
|
172
|
-
: null
|
|
173
|
-
const appPublicOrigin = surfaces.app
|
|
174
|
-
? resolveSurfaceOrigin(options, "app", {
|
|
175
|
-
value: options.appPublicOrigin,
|
|
176
|
-
envName: "SIXB_APP_PUBLIC_ORIGIN",
|
|
177
|
-
label: "custom app public origin",
|
|
178
|
-
port: ports.appPort,
|
|
179
|
-
})
|
|
180
|
-
: null
|
|
111
|
+
// Never guessed either: on the API it is the whole CORS allowlist. Without one the API admits
|
|
112
|
+
// no browser origin, which is right for a deploy with no app (`services: { app: false }`), and
|
|
113
|
+
// the app role only prints its own origin.
|
|
114
|
+
const appPublicOrigin =
|
|
115
|
+
configuredOrigin(options.appPublicOrigin, "SIXB_APP_PUBLIC_ORIGIN", "app public origin") ??
|
|
116
|
+
localOrigin(options.role, ports.appPort)
|
|
181
117
|
|
|
182
|
-
return {
|
|
183
|
-
apiPublicOrigin,
|
|
184
|
-
atlasPublicOrigin,
|
|
185
|
-
appPublicOrigin,
|
|
186
|
-
}
|
|
118
|
+
return { apiPublicOrigin, appPublicOrigin }
|
|
187
119
|
}
|
|
188
120
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
* optional on the role that serves the surface, which only prints it — refusing to start over a
|
|
192
|
-
* label is a startup an operator has to debug for nothing.
|
|
193
|
-
*/
|
|
194
|
-
function resolveSurfaceOrigin(
|
|
195
|
-
options: BrowserTopologyOptions,
|
|
196
|
-
surface: BrowserSurface,
|
|
197
|
-
input: {
|
|
198
|
-
readonly value: string | undefined
|
|
199
|
-
readonly envName: string
|
|
200
|
-
readonly label: string
|
|
201
|
-
readonly port: number
|
|
202
|
-
}
|
|
203
|
-
): string | null {
|
|
204
|
-
const configured = configuredOrigin(input.value, input.envName, input.label)
|
|
205
|
-
if (configured) return configured
|
|
206
|
-
|
|
207
|
-
const local = localOrigin(options.role, input.port)
|
|
208
|
-
if (local) return local
|
|
209
|
-
|
|
210
|
-
return options.role === surface ? null : refusePublicOrigin(input.envName)
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
function createAllowedBrowserOrigins(origins: BrowserPublicOrigins): readonly SixbBrowserOrigin[] {
|
|
214
|
-
const allowedOrigins: SixbBrowserOrigin[] = []
|
|
215
|
-
|
|
216
|
-
if (origins.atlasPublicOrigin) {
|
|
217
|
-
allowedOrigins.push({ origin: origins.atlasPublicOrigin, audience: "atlas" })
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (origins.appPublicOrigin) {
|
|
221
|
-
allowedOrigins.push({ origin: origins.appPublicOrigin, audience: "app" })
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
return allowedOrigins
|
|
121
|
+
function createAllowedBrowserOrigins(origins: BrowserPublicOrigins): readonly string[] {
|
|
122
|
+
return origins.appPublicOrigin ? [origins.appPublicOrigin] : []
|
|
225
123
|
}
|
|
226
124
|
|
|
227
125
|
/**
|
|
@@ -231,17 +129,12 @@ function createAllowedBrowserOrigins(origins: BrowserPublicOrigins): readonly Si
|
|
|
231
129
|
const WILDCARD_BINDS = new Set(["0.0.0.0", "::", "[::]"])
|
|
232
130
|
|
|
233
131
|
/**
|
|
234
|
-
* What
|
|
132
|
+
* What the app role shows as its own address. The public origin when one is configured,
|
|
235
133
|
* and otherwise the address it actually bound — which is all the process knows, and better than a
|
|
236
134
|
* startup panel with no URL on it.
|
|
237
135
|
*/
|
|
238
|
-
export function servedUrl(topology:
|
|
239
|
-
|
|
240
|
-
topology.serves === "atlas"
|
|
241
|
-
? ([topology.atlasPublicOrigin, topology.atlasPort] as const)
|
|
242
|
-
: ([topology.appPublicOrigin, topology.appPort] as const)
|
|
243
|
-
|
|
244
|
-
return origin ?? `http://${displayHost(topology.host)}:${port}`
|
|
136
|
+
export function servedUrl(topology: BrowserTopology): string {
|
|
137
|
+
return topology.appPublicOrigin ?? `http://${displayHost(topology.host)}:${topology.appPort}`
|
|
245
138
|
}
|
|
246
139
|
|
|
247
140
|
function displayHost(host: string): string {
|
package/src/lib/command-line.ts
CHANGED
|
@@ -13,7 +13,7 @@ export const CLI_OPTION_DEFINITIONS = {
|
|
|
13
13
|
summary: "Start a role without migrating storage (or SIXB_SKIP_MIGRATION=1)",
|
|
14
14
|
kind: "boolean",
|
|
15
15
|
},
|
|
16
|
-
port: { syntax: "--port <port>", summary: "Role port; dev
|
|
16
|
+
port: { syntax: "--port <port>", summary: "Role port; dev: the app port", kind: "string" },
|
|
17
17
|
host: {
|
|
18
18
|
syntax: "--host <host>",
|
|
19
19
|
summary: "Bind host (dev: 127.0.0.1, production roles: 0.0.0.0)",
|
|
@@ -21,7 +21,7 @@ export const CLI_OPTION_DEFINITIONS = {
|
|
|
21
21
|
},
|
|
22
22
|
"api-port": {
|
|
23
23
|
syntax: "--api-port <port>",
|
|
24
|
-
summary: "API port (default:
|
|
24
|
+
summary: "API port (default: app port + 1)",
|
|
25
25
|
kind: "string",
|
|
26
26
|
},
|
|
27
27
|
"api-host": {
|
|
@@ -44,14 +44,14 @@ export const CLI_OPTION_DEFINITIONS = {
|
|
|
44
44
|
summary: "Concurrent jobs: count for worker; repeat type=count for dev/worker-group",
|
|
45
45
|
kind: "string",
|
|
46
46
|
},
|
|
47
|
-
"
|
|
48
|
-
syntax: "--
|
|
49
|
-
summary: "
|
|
47
|
+
"vector-concurrency": {
|
|
48
|
+
syntax: "--vector-concurrency <count>",
|
|
49
|
+
summary: "Concurrent embedding calls for vector indexing (default: 4)",
|
|
50
50
|
kind: "string",
|
|
51
51
|
},
|
|
52
52
|
"app-public-origin": {
|
|
53
53
|
syntax: "--app-public-origin <origin>",
|
|
54
|
-
summary: "Public
|
|
54
|
+
summary: "Public app origin",
|
|
55
55
|
kind: "string",
|
|
56
56
|
},
|
|
57
57
|
"trusted-proxies": {
|
|
@@ -142,7 +142,6 @@ export type CliOptionName = keyof typeof CLI_OPTION_DEFINITIONS
|
|
|
142
142
|
export type LocalCommandId =
|
|
143
143
|
| "dev"
|
|
144
144
|
| "api"
|
|
145
|
-
| "atlas"
|
|
146
145
|
| "app"
|
|
147
146
|
| "login"
|
|
148
147
|
| "logout"
|
|
@@ -245,7 +244,7 @@ const instanceNodes: readonly CommandNode[] = INSTANCE_COMMANDS.map((name) => ({
|
|
|
245
244
|
}))
|
|
246
245
|
|
|
247
246
|
const commandTree: readonly CommandNode[] = [
|
|
248
|
-
command("dev", "Start local development (server +
|
|
247
|
+
command("dev", "Start local development (server + app)", {
|
|
249
248
|
options: [
|
|
250
249
|
"entry",
|
|
251
250
|
"port",
|
|
@@ -255,7 +254,7 @@ const commandTree: readonly CommandNode[] = [
|
|
|
255
254
|
"api-public-origin",
|
|
256
255
|
"agent-turn-timeout",
|
|
257
256
|
"concurrency",
|
|
258
|
-
"
|
|
257
|
+
"vector-concurrency",
|
|
259
258
|
"app-public-origin",
|
|
260
259
|
],
|
|
261
260
|
repeatable: ["concurrency"],
|
|
@@ -269,15 +268,11 @@ const commandTree: readonly CommandNode[] = [
|
|
|
269
268
|
"api-port",
|
|
270
269
|
"api-host",
|
|
271
270
|
"api-public-origin",
|
|
272
|
-
"atlas-public-origin",
|
|
273
271
|
"app-public-origin",
|
|
274
272
|
"trusted-proxies",
|
|
275
273
|
],
|
|
276
274
|
}),
|
|
277
|
-
command("
|
|
278
|
-
options: ["entry", "port", "host", "api-public-origin", "atlas-public-origin"],
|
|
279
|
-
}),
|
|
280
|
-
command("app", "Start production custom app server", {
|
|
275
|
+
command("app", "Start production app server", {
|
|
281
276
|
options: ["entry", "port", "host", "api-public-origin", "app-public-origin"],
|
|
282
277
|
}),
|
|
283
278
|
command("login", "Save and select a local API profile", {
|
|
@@ -416,14 +411,28 @@ const commandTree: readonly CommandNode[] = [
|
|
|
416
411
|
command("rules", "Start production rules runtime", { options: ["entry", "no-migrate"] }),
|
|
417
412
|
command("worker", "Start production queue worker: sync, agent, pipeline, projection, workflow", {
|
|
418
413
|
usage: "sixb worker <sync|agent|pipeline|projection|workflow> [options]",
|
|
419
|
-
options: [
|
|
414
|
+
options: [
|
|
415
|
+
"entry",
|
|
416
|
+
"no-migrate",
|
|
417
|
+
"api-public-origin",
|
|
418
|
+
"agent-turn-timeout",
|
|
419
|
+
"concurrency",
|
|
420
|
+
"vector-concurrency",
|
|
421
|
+
],
|
|
420
422
|
minimumPositionals: 1,
|
|
421
423
|
maximumPositionals: 1,
|
|
422
424
|
rootHelpLabel: "worker <type>",
|
|
423
425
|
}),
|
|
424
426
|
command("worker-group", "Co-host multiple queue workers in one process (constrained resources)", {
|
|
425
427
|
usage: "sixb worker-group [types...] [options]",
|
|
426
|
-
options: [
|
|
428
|
+
options: [
|
|
429
|
+
"entry",
|
|
430
|
+
"no-migrate",
|
|
431
|
+
"api-public-origin",
|
|
432
|
+
"agent-turn-timeout",
|
|
433
|
+
"concurrency",
|
|
434
|
+
"vector-concurrency",
|
|
435
|
+
],
|
|
427
436
|
repeatable: ["concurrency"],
|
|
428
437
|
maximumPositionals: Number.POSITIVE_INFINITY,
|
|
429
438
|
rootHelpLabel: "worker-group [types...]",
|
|
@@ -596,14 +605,13 @@ export const CLI_EXAMPLES = [
|
|
|
596
605
|
"sixb dev",
|
|
597
606
|
"sixb build",
|
|
598
607
|
"sixb api",
|
|
599
|
-
"sixb login http://localhost:
|
|
608
|
+
"sixb login http://localhost:3001 --profile local",
|
|
600
609
|
"sixb ontology list",
|
|
601
610
|
"sixb objects inspect Customer customer-123",
|
|
602
611
|
"sixb token create --name 'Local CLI' --expires-in 90d",
|
|
603
612
|
"sixb service-account create --id svc_sandbox --name 'Sandbox agent' --group agents",
|
|
604
613
|
"sixb service-account token create svc_sandbox --name 'Sandbox token' --expires-in 30d",
|
|
605
614
|
"sixb status",
|
|
606
|
-
"sixb atlas",
|
|
607
615
|
"sixb app",
|
|
608
616
|
"sixb scheduler",
|
|
609
617
|
"sixb orchestrator",
|
|
@@ -27,7 +27,6 @@ import { type ProductionRole, productionRoleFacts } from "./production-roles"
|
|
|
27
27
|
*/
|
|
28
28
|
const ROLE_SERVICES = {
|
|
29
29
|
api: "api",
|
|
30
|
-
atlas: "atlas",
|
|
31
30
|
app: "app",
|
|
32
31
|
orchestrator: "orchestrator",
|
|
33
32
|
scheduler: "scheduler",
|
|
@@ -44,7 +43,6 @@ type RoleOf<Service extends DeployServiceName> = {
|
|
|
44
43
|
/** The role behind each service. A service that no role deploys does not compile. */
|
|
45
44
|
const SERVICE_ROLES: { readonly [Service in DeployServiceName]: RoleOf<Service> } = {
|
|
46
45
|
api: "api",
|
|
47
|
-
atlas: "atlas",
|
|
48
46
|
app: "app",
|
|
49
47
|
orchestrator: "orchestrator",
|
|
50
48
|
scheduler: "scheduler",
|
|
@@ -55,7 +53,6 @@ const SERVICE_ROLES: { readonly [Service in DeployServiceName]: RoleOf<Service>
|
|
|
55
53
|
/** The variable each role reads for a surface's public origin. */
|
|
56
54
|
const PUBLIC_ORIGIN_ENV = {
|
|
57
55
|
api: "SIXB_API_PUBLIC_ORIGIN",
|
|
58
|
-
atlas: "SIXB_ATLAS_PUBLIC_ORIGIN",
|
|
59
56
|
app: "SIXB_APP_PUBLIC_ORIGIN",
|
|
60
57
|
} as const satisfies Record<DeployHttpServiceName, string>
|
|
61
58
|
|
|
@@ -10,7 +10,8 @@ export async function runDevSupervisor(options: DevOptions): Promise<void> {
|
|
|
10
10
|
let stopping = false
|
|
11
11
|
let restarting = false
|
|
12
12
|
let pending = false
|
|
13
|
-
|
|
13
|
+
// While the dev process runs and watches `app/`, its app server reloads app sources itself.
|
|
14
|
+
let appWatched = false
|
|
14
15
|
let started = false
|
|
15
16
|
let timer: ReturnType<typeof setTimeout> | undefined
|
|
16
17
|
let startupTimer: ReturnType<typeof setTimeout> | undefined
|
|
@@ -58,7 +59,7 @@ export async function runDevSupervisor(options: DevOptions): Promise<void> {
|
|
|
58
59
|
while (pending && !stopping) {
|
|
59
60
|
await stopChild()
|
|
60
61
|
if (stopping) break
|
|
61
|
-
|
|
62
|
+
appWatched = false
|
|
62
63
|
if (started) await watcher.refresh()
|
|
63
64
|
else await watcher.ready
|
|
64
65
|
if (stopping) break
|
|
@@ -87,10 +88,10 @@ export async function runDevSupervisor(options: DevOptions): Promise<void> {
|
|
|
87
88
|
if (child !== current || !message || typeof message !== "object") return
|
|
88
89
|
if ("type" in message && message.type === "ready") {
|
|
89
90
|
clearTimeout(startupTimer)
|
|
90
|
-
|
|
91
|
+
appWatched = "watchesApp" in message && message.watchesApp === true
|
|
91
92
|
console.log(`[SixbDev] Ready (pid ${proc.pid}). Watching ${root}`)
|
|
92
93
|
} else if ("type" in message && message.type === "startup-error") {
|
|
93
|
-
|
|
94
|
+
appWatched = false
|
|
94
95
|
}
|
|
95
96
|
})
|
|
96
97
|
child = current
|
|
@@ -106,7 +107,7 @@ export async function runDevSupervisor(options: DevOptions): Promise<void> {
|
|
|
106
107
|
if (child !== current) return
|
|
107
108
|
clearTimeout(startupTimer)
|
|
108
109
|
child = null
|
|
109
|
-
|
|
110
|
+
appWatched = false
|
|
110
111
|
if (!stopping && !restarting) {
|
|
111
112
|
console.error(`[SixbDev] Dev process exited (${code}). Waiting for source changes.`)
|
|
112
113
|
}
|
|
@@ -120,7 +121,7 @@ export async function runDevSupervisor(options: DevOptions): Promise<void> {
|
|
|
120
121
|
|
|
121
122
|
const watcher = watchDevSource(
|
|
122
123
|
root,
|
|
123
|
-
() =>
|
|
124
|
+
() => appWatched,
|
|
124
125
|
(filename) => {
|
|
125
126
|
if (stopping) return
|
|
126
127
|
pending = true
|
package/src/lib/dev-watch.ts
CHANGED
|
@@ -42,7 +42,7 @@ async function statPath(path: string) {
|
|
|
42
42
|
/** Targeted native checks, with a bounded-concurrency async scan for missed events. */
|
|
43
43
|
export function watchDevSource(
|
|
44
44
|
root: string,
|
|
45
|
-
|
|
45
|
+
appWatched: () => boolean,
|
|
46
46
|
onChange: (path: string) => void,
|
|
47
47
|
onError: (error: unknown) => void
|
|
48
48
|
) {
|
|
@@ -100,7 +100,7 @@ export function watchDevSource(
|
|
|
100
100
|
if (closed) return
|
|
101
101
|
let changed: string | undefined
|
|
102
102
|
const markChanged = (path: string) => {
|
|
103
|
-
if (!(
|
|
103
|
+
if (!(appWatched() && isAppSource(path))) changed ??= path
|
|
104
104
|
}
|
|
105
105
|
const inScope = (path: string) =>
|
|
106
106
|
(!directory || path === directory || path.startsWith(`${directory}${sep}`)) &&
|
|
@@ -119,24 +119,24 @@ export function watchDevSource(
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
async function reconcile(notify = true) {
|
|
122
|
-
const skipApp =
|
|
122
|
+
const skipApp = appWatched()
|
|
123
123
|
apply(await snapshot("", skipApp), "", skipApp, notify)
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
async function checkPath(path: string) {
|
|
127
|
-
if (closed || ignored(path) || (
|
|
127
|
+
if (closed || ignored(path) || (appWatched() && isAppSource(path))) return
|
|
128
128
|
const stat = await statPath(resolve(root, path))
|
|
129
129
|
if (stat?.isDirectory()) {
|
|
130
|
-
const skipApp =
|
|
130
|
+
const skipApp = appWatched()
|
|
131
131
|
apply(await snapshot(path, skipApp), path, skipApp, true)
|
|
132
132
|
} else if (stat?.isFile() && isSource(path)) {
|
|
133
133
|
const value = fingerprint(stat)
|
|
134
134
|
if (!closed && previous.get(path) !== value) {
|
|
135
135
|
previous.set(path, value)
|
|
136
|
-
if (!(
|
|
136
|
+
if (!(appWatched() && isAppSource(path))) onChange(path)
|
|
137
137
|
}
|
|
138
138
|
} else if (!stat || stat.isSymbolicLink()) {
|
|
139
|
-
apply(new Map(), path,
|
|
139
|
+
apply(new Map(), path, appWatched(), true)
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
|
|
@@ -154,7 +154,7 @@ export function watchDevSource(
|
|
|
154
154
|
if (closed) return
|
|
155
155
|
if (filename) {
|
|
156
156
|
const path = String(filename)
|
|
157
|
-
if (ignored(path) || (
|
|
157
|
+
if (ignored(path) || (appWatched() && isAppSource(path))) return
|
|
158
158
|
dirty.add(path)
|
|
159
159
|
} else fullCheck = true
|
|
160
160
|
clearTimeout(debounce)
|
|
@@ -11,22 +11,20 @@ const PRODUCTION_ROLES = {
|
|
|
11
11
|
orchestrator: { onEventPlane: true, usesStorageSchema: true },
|
|
12
12
|
worker: { onEventPlane: true, usesStorageSchema: true },
|
|
13
13
|
"worker-group": { onEventPlane: true, usesStorageSchema: true },
|
|
14
|
-
atlas: { onEventPlane: false, usesStorageSchema: false },
|
|
15
14
|
app: { onEventPlane: false, usesStorageSchema: false },
|
|
16
15
|
} as const satisfies Record<string, ProductionRoleFacts>
|
|
17
16
|
|
|
18
17
|
interface ProductionRoleFacts {
|
|
19
18
|
/**
|
|
20
|
-
* Whether the role publishes to or claims from the event plane. `
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* Whether the role publishes to or claims from the event plane. `app` only serves a browser
|
|
20
|
+
* bundle, so refusing to boot it on a process-local provider would block a valid UI-only
|
|
21
|
+
* container.
|
|
23
22
|
*/
|
|
24
23
|
readonly onEventPlane: boolean
|
|
25
24
|
|
|
26
25
|
/**
|
|
27
|
-
* Whether the role should bring the storage schema up to date at startup. `
|
|
28
|
-
*
|
|
29
|
-
* a DDL grant.
|
|
26
|
+
* Whether the role should bring the storage schema up to date at startup. `app` is the tier
|
|
27
|
+
* facing the internet, and a container serving a bundle has no business holding a DDL grant.
|
|
30
28
|
*/
|
|
31
29
|
readonly usesStorageSchema: boolean
|
|
32
30
|
}
|