@sixb/cli 0.1.11 → 0.1.13
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 +4 -2
- package/dist/commands/api.d.ts +1 -0
- package/dist/commands/api.d.ts.map +1 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/logout.d.ts.map +1 -1
- package/dist/commands/worker-group.d.ts.map +1 -1
- package/dist/commands/worker.d.ts.map +1 -1
- package/dist/lib/command-line.d.ts +5 -0
- package/dist/lib/command-line.d.ts.map +1 -1
- package/dist/lib/profiles.d.ts +6 -0
- package/dist/lib/profiles.d.ts.map +1 -1
- package/dist/lib/runtime.d.ts.map +1 -1
- package/dist/lib/worker-registry.d.ts +6 -1
- package/dist/lib/worker-registry.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/commands/api.tsx +6 -0
- package/src/commands/login.tsx +29 -86
- package/src/commands/logout.tsx +7 -2
- package/src/commands/profile.tsx +2 -2
- package/src/commands/worker-group.tsx +2 -0
- package/src/commands/worker.tsx +8 -3
- package/src/index.tsx +1 -0
- package/src/lib/command-line.ts +7 -1
- package/src/lib/profiles.ts +90 -15
- package/src/lib/runtime.ts +5 -8
- package/src/lib/worker-registry.ts +32 -14
package/README.md
CHANGED
|
@@ -243,8 +243,10 @@ sixb objects inspect Customer customer-123
|
|
|
243
243
|
|
|
244
244
|
An auth-disabled local API stores a tokenless profile. Authenticated APIs use a short-lived device
|
|
245
245
|
code: the browser approves the request through the existing session, and the CLI stores the
|
|
246
|
-
|
|
247
|
-
|
|
246
|
+
session's tokens only after validating them against `/api/project`. The access token lasts 15
|
|
247
|
+
minutes; each command renews it with the refresh token when it is about to expire, so one login
|
|
248
|
+
lasts until the session goes unused past its idle timeout (30 days by default). `sixb logout` ends
|
|
249
|
+
the session on the server. Use `--token-stdin` for automation or when you already have a token.
|
|
248
250
|
|
|
249
251
|
Remote target resolution is deterministic:
|
|
250
252
|
|
package/dist/commands/api.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/commands/api.tsx"],"names":[],"mappings":"AAUA,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/commands/api.tsx"],"names":[],"mappings":"AAUA,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,wBAAsB,MAAM,CAAC,OAAO,GAAE,UAAe,iBAgGpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.tsx"],"names":[],"mappings":"AAOA,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,wBAAsB,QAAQ,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyD/E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,wBAAsB,SAAS,CAAC,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8BjF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-group.d.ts","sourceRoot":"","sources":["../../src/commands/worker-group.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"worker-group.d.ts","sourceRoot":"","sources":["../../src/commands/worker-group.tsx"],"names":[],"mappings":"AAsBA,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC/B,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAChC;AAED,wBAAsB,cAAc,CAAC,OAAO,GAAE,kBAAuB,iBAsGpE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/commands/worker.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/commands/worker.tsx"],"names":[],"mappings":"AAsBA,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,wBAAsB,SAAS,CAAC,OAAO,GAAE,aAAkB,iBAoF1D"}
|
|
@@ -54,6 +54,11 @@ export declare const CLI_OPTION_DEFINITIONS: {
|
|
|
54
54
|
readonly summary: "Public custom app origin";
|
|
55
55
|
readonly kind: "string";
|
|
56
56
|
};
|
|
57
|
+
readonly "trusted-proxies": {
|
|
58
|
+
readonly syntax: "--trusted-proxies <ranges>";
|
|
59
|
+
readonly summary: "Proxies trusted for client addresses (default: private)";
|
|
60
|
+
readonly kind: "string";
|
|
61
|
+
};
|
|
57
62
|
readonly profile: {
|
|
58
63
|
readonly syntax: "--profile <name>";
|
|
59
64
|
readonly summary: "Use a saved API profile";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-line.d.ts","sourceRoot":"","sources":["../../src/lib/command-line.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,sBAAsB
|
|
1
|
+
{"version":3,"file":"command-line.d.ts","sourceRoot":"","sources":["../../src/lib/command-line.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4GuD,CAAA;AAE1F,MAAM,MAAM,aAAa,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AAS,MAAM,EAAE,CAAA;CAAE,GAC/D;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAA;IAC3B,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;IAChC,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;IACvC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAA;CACnC,CAAA;AAEL,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,QAAQ,KAAI;gBAET,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;CAK3C;AAED,eAAO,MAAM,SAAS,EAAE,OAavB,CAAA;AAED,eAAO,MAAM,YAAY,yxBAyBf,CAAA;AAEV,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAkB/D;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAG/F;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAErF;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,aAAa,GAAG,SAAS,MAAM,EAAE,CAGhG;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAKpE"}
|
package/dist/lib/profiles.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { type SixbSessionStore, type SixbSessionTokens } from "@sixb/client";
|
|
1
2
|
export interface SixbProfile {
|
|
2
3
|
readonly apiUrl: string;
|
|
3
4
|
readonly projectId: string;
|
|
5
|
+
/** A personal access token, for scripts and CI (`sixb login --token-stdin`). */
|
|
4
6
|
readonly token?: string;
|
|
7
|
+
/** The session `sixb login` signs in through the browser. */
|
|
8
|
+
readonly session?: SixbSessionTokens;
|
|
5
9
|
}
|
|
6
10
|
export interface SixbConfigFile {
|
|
7
11
|
readonly version: 1;
|
|
@@ -31,4 +35,6 @@ export declare function updateConfig(update: (config: SixbConfigFile) => SixbCon
|
|
|
31
35
|
export declare function resolveProfile(input?: ResolveProfileInput): Promise<ResolvedProfile>;
|
|
32
36
|
export declare function requireProfile(config: SixbConfigFile, name: string): SixbProfile;
|
|
33
37
|
export declare function assertProfileName(name: string): void;
|
|
38
|
+
/** A profile's session, as the store the client SDK refreshes and signs out through. */
|
|
39
|
+
export declare function profileSessionStore(profile: string, options?: ProfileStoreOptions): SixbSessionStore;
|
|
34
40
|
//# sourceMappingURL=profiles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../src/lib/profiles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../src/lib/profiles.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACvB,MAAM,cAAc,CAAA;AAOrB,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,gFAAgF;IAChF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,6DAA6D;IAC7D,QAAQ,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAA;CACrC;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;IACnB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAA;CACzD;AAED,MAAM,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AM,GAAG,WAAW,CAKhF;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAMpD;AA8BD,wFAAwF;AACxF,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,mBAAwB,GAChC,gBAAgB,CAclB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/lib/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAShD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAA;AAGzD,OAAO,EAGL,kBAAkB,EACnB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/lib/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAShD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAA;AAGzD,OAAO,EAGL,kBAAkB,EACnB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC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GAAE,uBAA4B,GACpC,OAAO,CAAC,kBAAkB,CAAC,CAqH7B;AAmBD,wBAAsB,cAAc,CAAC,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBnF"}
|
|
@@ -46,8 +46,9 @@ export declare function resolveWorkerTypeToStart(requestedWorker?: string): Work
|
|
|
46
46
|
* Why this worker cannot be constructed with these options, or `null` when it can. Exported
|
|
47
47
|
* for `sixb worker`, which has to answer this before it migrates storage.
|
|
48
48
|
*/
|
|
49
|
-
export declare function unmetWorkerRequirement(workerType: string, options: WorkerCreationOptions): string | null;
|
|
49
|
+
export declare function unmetWorkerRequirement(workerType: string, options: WorkerCreationOptions, agentApiRequired: boolean): string | null;
|
|
50
50
|
export interface WorkerGroupInputs {
|
|
51
|
+
readonly agentApiRequired: boolean;
|
|
51
52
|
readonly workerTypes: readonly string[];
|
|
52
53
|
readonly options: WorkerCreationOptions;
|
|
53
54
|
/**
|
|
@@ -64,4 +65,8 @@ export interface WorkerGroupInputs {
|
|
|
64
65
|
*/
|
|
65
66
|
export declare function assertWorkerInputs(input: WorkerGroupInputs): void;
|
|
66
67
|
export declare function resolveRegisteredWorkerTypes(sixb: LoadedSixbHost): readonly WorkerType[];
|
|
68
|
+
/** Explicit model calls can enqueue accounting recovery without a model catalog. */
|
|
69
|
+
export declare function agentWorkerRequired(sixb: LoadedSixbHost): boolean;
|
|
70
|
+
/** Only agent execution needs a sandbox and an API origin; accounting recovery does not. */
|
|
71
|
+
export declare function agentRuntimeRequired(definitions: LoadedSixbHost["definitions"]): boolean;
|
|
67
72
|
//# sourceMappingURL=worker-registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-registry.d.ts","sourceRoot":"","sources":["../../src/lib/worker-registry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAA;AAMzD,OAAO,KAAK,EAAE,cAAc,E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IAAI,EAAE,cAAc,GAAG,SAAS,UAAU,EAAE,CA4BxF;AAsBD,oFAAoF;AACpF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAIjE;AAED,4FAA4F;AAC5F,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,cAAc,CAAC,aAAa,CAAC,GAAG,OAAO,CAOxF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sixb/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "Command-line interface for Sixb projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sixb",
|
|
@@ -29,20 +29,20 @@
|
|
|
29
29
|
"prepack": "bun run build"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@sixb/action-worker": "0.1.
|
|
33
|
-
"@sixb/agent-worker": "0.1.
|
|
34
|
-
"@sixb/app": "^0.1.
|
|
35
|
-
"@sixb/atlas": "^0.1.
|
|
36
|
-
"@sixb/client": "^0.1.
|
|
37
|
-
"@sixb/core": "0.1.
|
|
38
|
-
"@sixb/cli-core": "^0.1.
|
|
39
|
-
"@sixb/orchestrator": "0.1.
|
|
40
|
-
"@sixb/pipeline-worker": "0.1.
|
|
41
|
-
"@sixb/projection-worker": "0.1.
|
|
42
|
-
"@sixb/rules-worker": "0.1.
|
|
43
|
-
"@sixb/server": "0.1.
|
|
44
|
-
"@sixb/sync-worker": "0.1.
|
|
45
|
-
"@sixb/workflow-worker": "0.1.
|
|
32
|
+
"@sixb/action-worker": "0.1.13",
|
|
33
|
+
"@sixb/agent-worker": "0.1.13",
|
|
34
|
+
"@sixb/app": "^0.1.9",
|
|
35
|
+
"@sixb/atlas": "^0.1.11",
|
|
36
|
+
"@sixb/client": "^0.1.13",
|
|
37
|
+
"@sixb/core": "0.1.13",
|
|
38
|
+
"@sixb/cli-core": "^0.1.6",
|
|
39
|
+
"@sixb/orchestrator": "0.1.13",
|
|
40
|
+
"@sixb/pipeline-worker": "0.1.13",
|
|
41
|
+
"@sixb/projection-worker": "0.1.13",
|
|
42
|
+
"@sixb/rules-worker": "0.1.13",
|
|
43
|
+
"@sixb/server": "0.1.13",
|
|
44
|
+
"@sixb/sync-worker": "0.1.13",
|
|
45
|
+
"@sixb/workflow-worker": "0.1.13",
|
|
46
46
|
"create-sixb": "^0.1.3",
|
|
47
47
|
"ink": "^6.0.0",
|
|
48
48
|
"react": "^19.0.0",
|
package/src/commands/api.tsx
CHANGED
|
@@ -18,6 +18,7 @@ export interface ApiOptions {
|
|
|
18
18
|
apiPublicOrigin?: string
|
|
19
19
|
atlasPublicOrigin?: string
|
|
20
20
|
appPublicOrigin?: string
|
|
21
|
+
trustedProxies?: string
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
export async function runApi(options: ApiOptions = {}) {
|
|
@@ -66,6 +67,10 @@ export async function runApi(options: ApiOptions = {}) {
|
|
|
66
67
|
hasCustomApp,
|
|
67
68
|
})
|
|
68
69
|
|
|
70
|
+
const trustedProxies = (options.trustedProxies ?? process.env.SIXB_TRUSTED_PROXIES ?? "")
|
|
71
|
+
.split(",")
|
|
72
|
+
.map((entry) => entry.trim())
|
|
73
|
+
.filter(Boolean)
|
|
69
74
|
server = createSixbServer({
|
|
70
75
|
host: sixb,
|
|
71
76
|
port: topology.apiPort,
|
|
@@ -76,6 +81,7 @@ export async function runApi(options: ApiOptions = {}) {
|
|
|
76
81
|
allowedOrigins: topology.allowedBrowserOrigins,
|
|
77
82
|
},
|
|
78
83
|
...(hasAuthExperience ? { authExperience: { outdir: authExperienceOutdir } } : {}),
|
|
84
|
+
...(trustedProxies.length > 0 ? { trustedProxies } : {}),
|
|
79
85
|
})
|
|
80
86
|
await server.start()
|
|
81
87
|
|
package/src/commands/login.tsx
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { hostname } from "node:os"
|
|
1
2
|
import { CliError, createInstanceApiClient, writeJson } from "@sixb/cli-core"
|
|
3
|
+
import { type SixbSessionTokens, startSixbDeviceLogin } from "@sixb/client"
|
|
2
4
|
import { normalizeApiUrl } from "../lib/api-client"
|
|
3
5
|
import { assertProfileName, updateConfig } from "../lib/profiles"
|
|
4
6
|
import { KeyValueResultView, renderStatic } from "../ui"
|
|
@@ -17,16 +19,19 @@ export async function runLogin(options: LoginCommandOptions = {}): Promise<void>
|
|
|
17
19
|
|
|
18
20
|
const apiUrl = normalizeApiUrl(options.apiUrl)
|
|
19
21
|
let token: string | undefined
|
|
22
|
+
let session: SixbSessionTokens | undefined
|
|
20
23
|
let projectId: string
|
|
21
24
|
|
|
22
25
|
try {
|
|
23
26
|
projectId = await fetchProject(apiUrl)
|
|
24
27
|
} catch (error) {
|
|
25
28
|
if (!isAuthorizationError(error)) throw error
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
if (options.tokenStdin) {
|
|
30
|
+
token = await readTokenFromStdin()
|
|
31
|
+
} else {
|
|
32
|
+
session = await authorizeDevice(apiUrl)
|
|
33
|
+
}
|
|
34
|
+
projectId = await fetchProject(apiUrl, token ?? session?.accessToken)
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
const profile = options.profile?.trim() || projectId
|
|
@@ -36,11 +41,16 @@ export async function runLogin(options: LoginCommandOptions = {}): Promise<void>
|
|
|
36
41
|
currentProfile: profile,
|
|
37
42
|
profiles: {
|
|
38
43
|
...config.profiles,
|
|
39
|
-
[profile]: {
|
|
44
|
+
[profile]: {
|
|
45
|
+
apiUrl,
|
|
46
|
+
projectId,
|
|
47
|
+
...(token ? { token } : {}),
|
|
48
|
+
...(session ? { session } : {}),
|
|
49
|
+
},
|
|
40
50
|
},
|
|
41
51
|
}))
|
|
42
52
|
|
|
43
|
-
const result = { profile, projectId, apiUrl, authenticated: Boolean(token) }
|
|
53
|
+
const result = { profile, projectId, apiUrl, authenticated: Boolean(token ?? session) }
|
|
44
54
|
if (options.json) {
|
|
45
55
|
writeJson(result)
|
|
46
56
|
return
|
|
@@ -52,92 +62,25 @@ export async function runLogin(options: LoginCommandOptions = {}): Promise<void>
|
|
|
52
62
|
items={[
|
|
53
63
|
{ label: "Project", value: projectId },
|
|
54
64
|
{ label: "API", value: apiUrl },
|
|
55
|
-
{
|
|
65
|
+
{
|
|
66
|
+
label: "Authentication",
|
|
67
|
+
value: session ? "signed in" : token ? "stored token" : "not required",
|
|
68
|
+
},
|
|
56
69
|
]}
|
|
57
70
|
/>
|
|
58
71
|
)
|
|
59
72
|
}
|
|
60
73
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async function authorizeDevice(apiUrl: string, tokenName: string): Promise<string> {
|
|
70
|
-
const api = createInstanceApiClient({ kind: "local", baseUrl: apiUrl })
|
|
71
|
-
const start = parseDeviceAuthorizationStart(
|
|
72
|
-
await api.post("/api/auth/device-authorizations", {
|
|
73
|
-
clientName: "sixb CLI",
|
|
74
|
-
tokenName,
|
|
75
|
-
expiresIn: "90d",
|
|
76
|
-
}),
|
|
77
|
-
apiUrl
|
|
78
|
-
)
|
|
79
|
-
process.stderr.write(`Opening ${start.verificationUriComplete}\n`)
|
|
80
|
-
process.stderr.write(`Confirm code: ${start.userCode}\n`)
|
|
81
|
-
await openBrowser(start.verificationUriComplete)
|
|
74
|
+
async function authorizeDevice(apiUrl: string): Promise<SixbSessionTokens> {
|
|
75
|
+
const login = await startSixbDeviceLogin({
|
|
76
|
+
baseUrl: apiUrl,
|
|
77
|
+
clientName: `sixb CLI on ${hostname()}`,
|
|
78
|
+
})
|
|
79
|
+
process.stderr.write(`Opening ${login.verificationUriComplete}\n`)
|
|
80
|
+
process.stderr.write(`Confirm code: ${login.userCode}\n`)
|
|
81
|
+
await openBrowser(login.verificationUriComplete)
|
|
82
82
|
process.stderr.write("Waiting for browser authorization...\n")
|
|
83
|
-
|
|
84
|
-
const serverDeadline = new Date(start.expiresAt).getTime()
|
|
85
|
-
const deadline = Math.min(serverDeadline, Date.now() + 15 * 60 * 1000)
|
|
86
|
-
const intervalMs = Math.max(1, Math.min(10, start.interval)) * 1000
|
|
87
|
-
while (Date.now() < deadline) {
|
|
88
|
-
const result = await api.post("/api/auth/device-authorizations/token", {
|
|
89
|
-
deviceCode: start.deviceCode,
|
|
90
|
-
})
|
|
91
|
-
if (!isRecord(result) || typeof result.status !== "string") {
|
|
92
|
-
throw new Error("[SixbCLI] The Sixb API returned an invalid device authorization response.")
|
|
93
|
-
}
|
|
94
|
-
if (result.status === "approved" && typeof result.accessToken === "string") {
|
|
95
|
-
return requireToken(result.accessToken)
|
|
96
|
-
}
|
|
97
|
-
if (result.status === "denied") {
|
|
98
|
-
throw new Error("[SixbCLI] Browser authorization was denied.")
|
|
99
|
-
}
|
|
100
|
-
if (result.status === "expired") {
|
|
101
|
-
throw new Error("[SixbCLI] Browser authorization expired. Run `sixb login` again.")
|
|
102
|
-
}
|
|
103
|
-
if (result.status !== "pending") {
|
|
104
|
-
throw new Error("[SixbCLI] The Sixb API returned an unknown authorization status.")
|
|
105
|
-
}
|
|
106
|
-
await Bun.sleep(intervalMs)
|
|
107
|
-
}
|
|
108
|
-
throw new Error("[SixbCLI] Browser authorization expired. Run `sixb login` again.")
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function parseDeviceAuthorizationStart(value: unknown, apiUrl: string): DeviceAuthorizationStart {
|
|
112
|
-
if (
|
|
113
|
-
!isRecord(value) ||
|
|
114
|
-
typeof value.deviceCode !== "string" ||
|
|
115
|
-
!value.deviceCode ||
|
|
116
|
-
value.deviceCode.length > 1_024 ||
|
|
117
|
-
typeof value.userCode !== "string" ||
|
|
118
|
-
!value.userCode ||
|
|
119
|
-
typeof value.verificationUriComplete !== "string" ||
|
|
120
|
-
typeof value.expiresAt !== "string" ||
|
|
121
|
-
typeof value.interval !== "number" ||
|
|
122
|
-
!Number.isFinite(value.interval) ||
|
|
123
|
-
!Number.isFinite(new Date(value.expiresAt).getTime())
|
|
124
|
-
) {
|
|
125
|
-
throw new Error("[SixbCLI] The Sixb API returned an invalid device authorization.")
|
|
126
|
-
}
|
|
127
|
-
const verificationUrl = new URL(value.verificationUriComplete)
|
|
128
|
-
if (
|
|
129
|
-
verificationUrl.origin !== new URL(apiUrl).origin ||
|
|
130
|
-
(verificationUrl.protocol !== "http:" && verificationUrl.protocol !== "https:")
|
|
131
|
-
) {
|
|
132
|
-
throw new Error("[SixbCLI] The device verification URL does not match the Sixb API origin.")
|
|
133
|
-
}
|
|
134
|
-
return {
|
|
135
|
-
deviceCode: value.deviceCode,
|
|
136
|
-
userCode: value.userCode,
|
|
137
|
-
verificationUriComplete: value.verificationUriComplete,
|
|
138
|
-
expiresAt: value.expiresAt,
|
|
139
|
-
interval: value.interval,
|
|
140
|
-
}
|
|
83
|
+
return login.complete()
|
|
141
84
|
}
|
|
142
85
|
|
|
143
86
|
async function openBrowser(url: string): Promise<void> {
|
package/src/commands/logout.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { writeJson } from "@sixb/cli-core"
|
|
2
|
-
import {
|
|
2
|
+
import { signOutSixbSession } from "@sixb/client"
|
|
3
|
+
import { profileSessionStore, readConfig, requireProfile, updateConfig } from "../lib/profiles"
|
|
3
4
|
import { KeyValueResultView, renderStatic } from "../ui"
|
|
4
5
|
|
|
5
6
|
export interface LogoutCommandOptions {
|
|
@@ -11,7 +12,11 @@ export async function runLogout(options: LogoutCommandOptions = {}): Promise<voi
|
|
|
11
12
|
const current = await readConfig()
|
|
12
13
|
const name = options.profile?.trim() || current.currentProfile
|
|
13
14
|
if (!name) throw new Error("[SixbCLI] No current profile to remove.")
|
|
14
|
-
requireProfile(current, name)
|
|
15
|
+
const stored = requireProfile(current, name)
|
|
16
|
+
// End the session on the server too, so a copy of its tokens stops working.
|
|
17
|
+
if (stored.session) {
|
|
18
|
+
await signOutSixbSession({ baseUrl: stored.apiUrl, store: profileSessionStore(name) })
|
|
19
|
+
}
|
|
15
20
|
|
|
16
21
|
await updateConfig((config) => {
|
|
17
22
|
const profiles = { ...config.profiles }
|
package/src/commands/profile.tsx
CHANGED
|
@@ -25,7 +25,7 @@ async function listProfiles(options: ProfileCommandOptions): Promise<void> {
|
|
|
25
25
|
current: name === config.currentProfile,
|
|
26
26
|
projectId: profile.projectId,
|
|
27
27
|
apiUrl: profile.apiUrl,
|
|
28
|
-
authenticated: Boolean(profile.token),
|
|
28
|
+
authenticated: Boolean(profile.token ?? profile.session),
|
|
29
29
|
}))
|
|
30
30
|
|
|
31
31
|
if (options.json) {
|
|
@@ -59,7 +59,7 @@ async function showProfile(options: ProfileCommandOptions): Promise<void> {
|
|
|
59
59
|
current: name === config.currentProfile,
|
|
60
60
|
projectId: profile.projectId,
|
|
61
61
|
apiUrl: profile.apiUrl,
|
|
62
|
-
authenticated: Boolean(profile.token),
|
|
62
|
+
authenticated: Boolean(profile.token ?? profile.session),
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
if (options.json) {
|
|
@@ -11,6 +11,7 @@ import { assertShareableProviders } from "../lib/shareable-providers"
|
|
|
11
11
|
import { migrateStorageForRole } from "../lib/storage-migration"
|
|
12
12
|
import { resolveWorkerConcurrency } from "../lib/worker-concurrency"
|
|
13
13
|
import {
|
|
14
|
+
agentRuntimeRequired,
|
|
14
15
|
assertWorkerInputs,
|
|
15
16
|
createWorkerForType,
|
|
16
17
|
type QueueWorkerProcess,
|
|
@@ -65,6 +66,7 @@ export async function runWorkerGroup(options: WorkerGroupOptions = {}) {
|
|
|
65
66
|
// had taken every other worker down. And before the migration, which used to run first and
|
|
66
67
|
// leave a schema behind on a command that then refused.
|
|
67
68
|
assertWorkerInputs({
|
|
69
|
+
agentApiRequired: agentRuntimeRequired(sixb.definitions),
|
|
68
70
|
workerTypes,
|
|
69
71
|
options: { agentApiBaseUrl: options.apiPublicOrigin },
|
|
70
72
|
autoSelected: requestedTypes.length === 0,
|
package/src/commands/worker.tsx
CHANGED
|
@@ -12,6 +12,7 @@ import { assertShareableProviders } from "../lib/shareable-providers"
|
|
|
12
12
|
import { migrateStorageForRole } from "../lib/storage-migration"
|
|
13
13
|
import { resolveSingleWorkerConcurrency } from "../lib/worker-concurrency"
|
|
14
14
|
import {
|
|
15
|
+
agentRuntimeRequired,
|
|
15
16
|
createWorkerForType,
|
|
16
17
|
type QueueWorkerProcess,
|
|
17
18
|
resolveWorkerTypeToStart,
|
|
@@ -50,9 +51,13 @@ export async function runWorker(options: WorkerOptions = {}) {
|
|
|
50
51
|
|
|
51
52
|
// Before the migration, which is the first thing here that changes something: this used to
|
|
52
53
|
// bring the schema up to date and then refuse to run.
|
|
53
|
-
const unmet = unmetWorkerRequirement(
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
const unmet = unmetWorkerRequirement(
|
|
55
|
+
workerType,
|
|
56
|
+
{
|
|
57
|
+
agentApiBaseUrl: options.apiPublicOrigin,
|
|
58
|
+
},
|
|
59
|
+
agentRuntimeRequired(sixb.definitions)
|
|
60
|
+
)
|
|
56
61
|
if (unmet) {
|
|
57
62
|
throw new SixbCliError(`[SixbCLI] \`sixb worker ${workerType}\` cannot start: it ${unmet}.`)
|
|
58
63
|
}
|
package/src/index.tsx
CHANGED
|
@@ -148,6 +148,7 @@ async function main(): Promise<void> {
|
|
|
148
148
|
apiPublicOrigin: getFlag("api-public-origin"),
|
|
149
149
|
atlasPublicOrigin: getFlag("atlas-public-origin"),
|
|
150
150
|
appPublicOrigin: getFlag("app-public-origin"),
|
|
151
|
+
trustedProxies: getFlag("trusted-proxies"),
|
|
151
152
|
})
|
|
152
153
|
break
|
|
153
154
|
}
|
package/src/lib/command-line.ts
CHANGED
|
@@ -54,6 +54,11 @@ export const CLI_OPTION_DEFINITIONS = {
|
|
|
54
54
|
summary: "Public custom app origin",
|
|
55
55
|
kind: "string",
|
|
56
56
|
},
|
|
57
|
+
"trusted-proxies": {
|
|
58
|
+
syntax: "--trusted-proxies <ranges>",
|
|
59
|
+
summary: "Proxies trusted for client addresses (default: private)",
|
|
60
|
+
kind: "string",
|
|
61
|
+
},
|
|
57
62
|
profile: { syntax: "--profile <name>", summary: "Use a saved API profile", kind: "string" },
|
|
58
63
|
"api-url": {
|
|
59
64
|
syntax: "--api-url <url>",
|
|
@@ -227,6 +232,7 @@ const commandTree: readonly CommandNode[] = [
|
|
|
227
232
|
"api-public-origin",
|
|
228
233
|
"atlas-public-origin",
|
|
229
234
|
"app-public-origin",
|
|
235
|
+
"trusted-proxies",
|
|
230
236
|
],
|
|
231
237
|
}),
|
|
232
238
|
command("atlas", "Start production Atlas UI server", {
|
|
@@ -388,7 +394,7 @@ const commandTree: readonly CommandNode[] = [
|
|
|
388
394
|
rootHelpLabel: "worker-group [types...]",
|
|
389
395
|
}),
|
|
390
396
|
command("check", "Validate project configuration and health", { options: ["entry"] }),
|
|
391
|
-
command("typegen", "Generate ontology types for
|
|
397
|
+
command("typegen", "Generate ontology types for typed queries", { options: ["entry"] }),
|
|
392
398
|
command("build", "Build runtime and production UI/app assets", { options: ["entry", "outdir"] }),
|
|
393
399
|
{
|
|
394
400
|
name: "db",
|
package/src/lib/profiles.ts
CHANGED
|
@@ -2,6 +2,12 @@ import { randomUUID } from "node:crypto"
|
|
|
2
2
|
import { chmod, mkdir, readFile, rename, rm, writeFile } from "node:fs/promises"
|
|
3
3
|
import { homedir } from "node:os"
|
|
4
4
|
import { dirname, isAbsolute, join } from "node:path"
|
|
5
|
+
import {
|
|
6
|
+
getSixbSessionAccessToken,
|
|
7
|
+
SixbSessionEndedError,
|
|
8
|
+
type SixbSessionStore,
|
|
9
|
+
type SixbSessionTokens,
|
|
10
|
+
} from "@sixb/client"
|
|
5
11
|
import { normalizeApiUrl } from "./api-client"
|
|
6
12
|
|
|
7
13
|
const CONFIG_DIRECTORY_MODE = 0o700
|
|
@@ -11,7 +17,10 @@ const PROFILE_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/
|
|
|
11
17
|
export interface SixbProfile {
|
|
12
18
|
readonly apiUrl: string
|
|
13
19
|
readonly projectId: string
|
|
20
|
+
/** A personal access token, for scripts and CI (`sixb login --token-stdin`). */
|
|
14
21
|
readonly token?: string
|
|
22
|
+
/** The session `sixb login` signs in through the browser. */
|
|
23
|
+
readonly session?: SixbSessionTokens
|
|
15
24
|
}
|
|
16
25
|
|
|
17
26
|
export interface SixbConfigFile {
|
|
@@ -118,7 +127,7 @@ export async function resolveProfile(input: ResolveProfileInput = {}): Promise<R
|
|
|
118
127
|
const explicitProfile = nonblank(input.profile)
|
|
119
128
|
if (explicitProfile) {
|
|
120
129
|
const stored = requireProfile(config, explicitProfile)
|
|
121
|
-
return resolvedStoredProfile(stored, explicitProfile, "profile-flag", explicitToken)
|
|
130
|
+
return resolvedStoredProfile(stored, explicitProfile, "profile-flag", explicitToken, input)
|
|
122
131
|
}
|
|
123
132
|
|
|
124
133
|
const environmentApiUrl = nonblank(env.SIXB_API_URL) ?? nonblank(env.SIXB_API_PUBLIC_ORIGIN)
|
|
@@ -136,12 +145,24 @@ export async function resolveProfile(input: ResolveProfileInput = {}): Promise<R
|
|
|
136
145
|
const environmentProfile = nonblank(env.SIXB_PROFILE)
|
|
137
146
|
if (environmentProfile) {
|
|
138
147
|
const stored = requireProfile(config, environmentProfile)
|
|
139
|
-
return resolvedStoredProfile(
|
|
148
|
+
return resolvedStoredProfile(
|
|
149
|
+
stored,
|
|
150
|
+
environmentProfile,
|
|
151
|
+
"profile-environment",
|
|
152
|
+
explicitToken,
|
|
153
|
+
input
|
|
154
|
+
)
|
|
140
155
|
}
|
|
141
156
|
|
|
142
157
|
if (config.currentProfile) {
|
|
143
158
|
const stored = requireProfile(config, config.currentProfile)
|
|
144
|
-
return resolvedStoredProfile(
|
|
159
|
+
return resolvedStoredProfile(
|
|
160
|
+
stored,
|
|
161
|
+
config.currentProfile,
|
|
162
|
+
"current-profile",
|
|
163
|
+
explicitToken,
|
|
164
|
+
input
|
|
165
|
+
)
|
|
145
166
|
}
|
|
146
167
|
|
|
147
168
|
return {
|
|
@@ -166,21 +187,51 @@ export function assertProfileName(name: string): void {
|
|
|
166
187
|
}
|
|
167
188
|
}
|
|
168
189
|
|
|
169
|
-
function resolvedStoredProfile(
|
|
190
|
+
async function resolvedStoredProfile(
|
|
170
191
|
stored: SixbProfile,
|
|
171
192
|
profile: string,
|
|
172
193
|
source: "profile-flag" | "profile-environment" | "current-profile",
|
|
173
|
-
explicitToken: string | undefined
|
|
174
|
-
|
|
194
|
+
explicitToken: string | undefined,
|
|
195
|
+
options: ProfileStoreOptions
|
|
196
|
+
): Promise<ResolvedProfile> {
|
|
197
|
+
const { session, ...rest } = stored
|
|
198
|
+
const base = { ...rest, profile, source }
|
|
199
|
+
if (explicitToken) return { ...base, token: explicitToken, tokenSource: "--token" }
|
|
200
|
+
if (session) {
|
|
201
|
+
const token = await getSixbSessionAccessToken({
|
|
202
|
+
baseUrl: stored.apiUrl,
|
|
203
|
+
store: profileSessionStore(profile, options),
|
|
204
|
+
}).catch((error: unknown) => {
|
|
205
|
+
if (!(error instanceof SixbSessionEndedError)) throw error
|
|
206
|
+
return null
|
|
207
|
+
})
|
|
208
|
+
if (!token) {
|
|
209
|
+
throw new Error(
|
|
210
|
+
`[SixbCLI] The sign-in for profile '${profile}' has ended. Run \`sixb login ${stored.apiUrl} --profile ${profile}\` again.`
|
|
211
|
+
)
|
|
212
|
+
}
|
|
213
|
+
return { ...base, token, tokenSource: "profile" }
|
|
214
|
+
}
|
|
215
|
+
return stored.token ? { ...base, tokenSource: "profile" } : base
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** A profile's session, as the store the client SDK refreshes and signs out through. */
|
|
219
|
+
export function profileSessionStore(
|
|
220
|
+
profile: string,
|
|
221
|
+
options: ProfileStoreOptions = {}
|
|
222
|
+
): SixbSessionStore {
|
|
223
|
+
const update = (change: (stored: SixbProfile) => SixbProfile) =>
|
|
224
|
+
updateConfig(
|
|
225
|
+
(config) => ({
|
|
226
|
+
...config,
|
|
227
|
+
profiles: { ...config.profiles, [profile]: change(requireProfile(config, profile)) },
|
|
228
|
+
}),
|
|
229
|
+
options
|
|
230
|
+
)
|
|
175
231
|
return {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
...(explicitToken
|
|
180
|
-
? { token: explicitToken, tokenSource: "--token" }
|
|
181
|
-
: stored.token
|
|
182
|
-
? { tokenSource: "profile" }
|
|
183
|
-
: {}),
|
|
232
|
+
load: async () => requireProfile(await readConfig(options), profile).session ?? null,
|
|
233
|
+
save: async (session) => void (await update((stored) => ({ ...stored, session }))),
|
|
234
|
+
clear: async () => void (await update(({ session: _ended, ...stored }) => stored)),
|
|
184
235
|
}
|
|
185
236
|
}
|
|
186
237
|
|
|
@@ -210,13 +261,21 @@ function parseConfig(value: unknown, path: string): SixbConfigFile {
|
|
|
210
261
|
const apiUrl = nonblankString(profile.apiUrl)
|
|
211
262
|
const projectId = nonblankString(profile.projectId)
|
|
212
263
|
const token = profile.token === undefined ? undefined : nonblankString(profile.token)
|
|
213
|
-
|
|
264
|
+
const session = profile.session === undefined ? undefined : parseStoredSession(profile.session)
|
|
265
|
+
if (
|
|
266
|
+
!apiUrl ||
|
|
267
|
+
!projectId ||
|
|
268
|
+
(profile.token !== undefined && !token) ||
|
|
269
|
+
(profile.session !== undefined && !session) ||
|
|
270
|
+
(token && session)
|
|
271
|
+
) {
|
|
214
272
|
throw invalidConfig(path)
|
|
215
273
|
}
|
|
216
274
|
profiles[name] = {
|
|
217
275
|
apiUrl: normalizeApiUrl(apiUrl),
|
|
218
276
|
projectId,
|
|
219
277
|
...(token ? { token } : {}),
|
|
278
|
+
...(session ? { session } : {}),
|
|
220
279
|
}
|
|
221
280
|
}
|
|
222
281
|
|
|
@@ -236,6 +295,22 @@ function parseConfig(value: unknown, path: string): SixbConfigFile {
|
|
|
236
295
|
}
|
|
237
296
|
}
|
|
238
297
|
|
|
298
|
+
function parseStoredSession(value: unknown): SixbSessionTokens | undefined {
|
|
299
|
+
const record = asRecord(value)
|
|
300
|
+
const accessToken = nonblankString(record.accessToken)
|
|
301
|
+
const refreshToken = nonblankString(record.refreshToken)
|
|
302
|
+
const accessExpiresAt = nonblankString(record.accessExpiresAt)
|
|
303
|
+
if (
|
|
304
|
+
!accessToken ||
|
|
305
|
+
!refreshToken ||
|
|
306
|
+
!accessExpiresAt ||
|
|
307
|
+
Number.isNaN(Date.parse(accessExpiresAt))
|
|
308
|
+
) {
|
|
309
|
+
return undefined
|
|
310
|
+
}
|
|
311
|
+
return { accessToken, refreshToken, accessExpiresAt }
|
|
312
|
+
}
|
|
313
|
+
|
|
239
314
|
function invalidConfig(path: string): Error {
|
|
240
315
|
return new Error(`[SixbCLI] Profile config '${path}' has an invalid shape.`)
|
|
241
316
|
}
|
package/src/lib/runtime.ts
CHANGED
|
@@ -24,6 +24,7 @@ import { SyncWorker } from "@sixb/sync-worker"
|
|
|
24
24
|
import { WorkflowWorker } from "@sixb/workflow-worker"
|
|
25
25
|
import type { LoadedSixbHost } from "./loadSixb"
|
|
26
26
|
import type { WorkerConcurrency } from "./worker-registry"
|
|
27
|
+
import { agentRuntimeRequired, agentWorkerRequired } from "./worker-registry"
|
|
27
28
|
|
|
28
29
|
export function waitForWorkerFailure(worker: Worker | null | undefined): Promise<never> {
|
|
29
30
|
return new Promise<never>((_resolve, reject) => {
|
|
@@ -243,15 +244,11 @@ export async function startSixbRuntime(
|
|
|
243
244
|
await actionWorker.start()
|
|
244
245
|
}
|
|
245
246
|
|
|
246
|
-
if (
|
|
247
|
-
(sixb.definitions.models !== undefined ||
|
|
248
|
-
sixb.definitions.workflows
|
|
249
|
-
.list()
|
|
250
|
-
.some((workflow) => workflow.nodes.some((node) => node.type === "agent"))) &&
|
|
251
|
-
sixb.storage.agents
|
|
252
|
-
) {
|
|
247
|
+
if (agentWorkerRequired(sixb)) {
|
|
253
248
|
agentWorker = new AgentWorker(sixb, {
|
|
254
|
-
apiBaseUrl:
|
|
249
|
+
apiBaseUrl: agentRuntimeRequired(sixb.definitions)
|
|
250
|
+
? requireAgentApiBaseUrl(options.agentApiBaseUrl)
|
|
251
|
+
: undefined,
|
|
255
252
|
concurrency: options.workerConcurrency?.agent,
|
|
256
253
|
turnTimeoutMs: options.agentTurnTimeoutMs,
|
|
257
254
|
})
|
|
@@ -56,7 +56,10 @@ interface WorkerFactory {
|
|
|
56
56
|
* A malformed input throws instead of answering: it is one bad value rather than one
|
|
57
57
|
* unsatisfied worker, and the list of workers it took down would say nothing about it.
|
|
58
58
|
*/
|
|
59
|
-
readonly unmetRequirement?: (
|
|
59
|
+
readonly unmetRequirement?: (
|
|
60
|
+
options: WorkerCreationOptions,
|
|
61
|
+
agentApiRequired: boolean
|
|
62
|
+
) => string | null
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
const AGENT_ORIGIN_REQUIRED =
|
|
@@ -73,12 +76,14 @@ const workerFactories: Record<WorkerType, WorkerFactory> = {
|
|
|
73
76
|
agent: {
|
|
74
77
|
create: (sixb, options) =>
|
|
75
78
|
new AgentWorker(sixb, {
|
|
76
|
-
apiBaseUrl:
|
|
79
|
+
apiBaseUrl: agentRuntimeRequired(sixb.definitions)
|
|
80
|
+
? resolveAgentApiBaseUrl(options.agentApiBaseUrl)
|
|
81
|
+
: undefined,
|
|
77
82
|
concurrency: options.workerConcurrency?.agent,
|
|
78
83
|
turnTimeoutMs: options.agentTurnTimeoutMs,
|
|
79
84
|
}),
|
|
80
|
-
unmetRequirement: (options) =>
|
|
81
|
-
agentApiBaseUrl(options.agentApiBaseUrl) ? null : AGENT_ORIGIN_REQUIRED,
|
|
85
|
+
unmetRequirement: (options, agentApiRequired) =>
|
|
86
|
+
!agentApiRequired || agentApiBaseUrl(options.agentApiBaseUrl) ? null : AGENT_ORIGIN_REQUIRED,
|
|
82
87
|
},
|
|
83
88
|
pipeline: {
|
|
84
89
|
create: (sixb, options) =>
|
|
@@ -127,14 +132,16 @@ export function resolveWorkerTypeToStart(requestedWorker?: string): WorkerType {
|
|
|
127
132
|
*/
|
|
128
133
|
export function unmetWorkerRequirement(
|
|
129
134
|
workerType: string,
|
|
130
|
-
options: WorkerCreationOptions
|
|
135
|
+
options: WorkerCreationOptions,
|
|
136
|
+
agentApiRequired: boolean
|
|
131
137
|
): string | null {
|
|
132
138
|
return isWorkerType(workerType)
|
|
133
|
-
? (workerFactories[workerType].unmetRequirement?.(options) ?? null)
|
|
139
|
+
? (workerFactories[workerType].unmetRequirement?.(options, agentApiRequired) ?? null)
|
|
134
140
|
: null
|
|
135
141
|
}
|
|
136
142
|
|
|
137
143
|
export interface WorkerGroupInputs {
|
|
144
|
+
readonly agentApiRequired: boolean
|
|
138
145
|
readonly workerTypes: readonly string[]
|
|
139
146
|
readonly options: WorkerCreationOptions
|
|
140
147
|
/**
|
|
@@ -154,7 +161,7 @@ export function assertWorkerInputs(input: WorkerGroupInputs): void {
|
|
|
154
161
|
const unmet = input.workerTypes
|
|
155
162
|
.map((workerType) => ({
|
|
156
163
|
workerType,
|
|
157
|
-
reason: unmetWorkerRequirement(workerType, input.options),
|
|
164
|
+
reason: unmetWorkerRequirement(workerType, input.options, input.agentApiRequired),
|
|
158
165
|
}))
|
|
159
166
|
.filter((entry): entry is { workerType: string; reason: string } => entry.reason !== null)
|
|
160
167
|
|
|
@@ -200,13 +207,7 @@ export function resolveRegisteredWorkerTypes(sixb: LoadedSixbHost): readonly Wor
|
|
|
200
207
|
workerTypes.push("action")
|
|
201
208
|
}
|
|
202
209
|
|
|
203
|
-
if (
|
|
204
|
-
(sixb.definitions.models !== undefined ||
|
|
205
|
-
sixb.definitions.workflows
|
|
206
|
-
.list()
|
|
207
|
-
.some((workflow) => workflow.nodes.some((node) => node.type === "agent"))) &&
|
|
208
|
-
sixb.storage.agents
|
|
209
|
-
) {
|
|
210
|
+
if (agentWorkerRequired(sixb)) {
|
|
210
211
|
workerTypes.push("agent")
|
|
211
212
|
}
|
|
212
213
|
|
|
@@ -236,3 +237,20 @@ function resolveAgentApiBaseUrl(value: string | undefined): string {
|
|
|
236
237
|
}
|
|
237
238
|
return apiBaseUrl
|
|
238
239
|
}
|
|
240
|
+
|
|
241
|
+
/** Explicit model calls can enqueue accounting recovery without a model catalog. */
|
|
242
|
+
export function agentWorkerRequired(sixb: LoadedSixbHost): boolean {
|
|
243
|
+
const { storage } = sixb
|
|
244
|
+
const canRecoverAccounting = Boolean(storage.aiUsage && storage.aiCosts && storage.aiLimits)
|
|
245
|
+
return canRecoverAccounting || (agentRuntimeRequired(sixb.definitions) && Boolean(storage.agents))
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** Only agent execution needs a sandbox and an API origin; accounting recovery does not. */
|
|
249
|
+
export function agentRuntimeRequired(definitions: LoadedSixbHost["definitions"]): boolean {
|
|
250
|
+
return (
|
|
251
|
+
definitions.models?.language !== undefined ||
|
|
252
|
+
definitions.workflows
|
|
253
|
+
.list()
|
|
254
|
+
.some((workflow) => workflow.nodes.some((node) => node.type === "agent"))
|
|
255
|
+
)
|
|
256
|
+
}
|