unoverse 0.1.222 → 0.1.224
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 +0 -1
- package/bin/unoverse.mjs +14 -41
- package/lib/workspace.mjs +2 -2
- package/operator/lib/db-verify.sh +13 -4
- package/operator/lib/help.sh +11 -6
- package/package.json +1 -1
- package/vendor/base/items/collect.js +26 -0
- package/vendor/base/lint/design/vocabulary.mjs +11 -1
- package/vendor/base/lint/nodes/_schema/api.schema.json +45 -0
- package/vendor/base/lint/objects/_schema/agents/agent.schema.json +11 -1
- package/vendor/base/lint/objects/_schema/objects/dataset.schema.json +3 -0
- package/vendor/base/lint/objects/_schema/objects/object.schema.json +2 -2
- package/vendor/base/lint/objects/_schema/objects/props.schema.json +13 -2
- package/vendor/base/lint/objects/_schema/pipelines/layout.schema.json +49 -4
- package/vendor/base/lint/objects/_schema/pipelines/pipeline.schema.json +5 -0
- package/vendor/base/lint/objects/_schema/pipelines/test.schema.json +4 -0
- package/vendor/base/lint/objects/index.mjs +41 -0
- package/vendor/base/lint/objects/rules.mjs +64 -6
- package/lib/login.mjs +0 -274
- package/lib/session.mjs +0 -100
package/README.md
CHANGED
|
@@ -21,7 +21,6 @@ unoverse start # run it (--pull for the latest images)
|
|
|
21
21
|
unoverse check # is it healthy
|
|
22
22
|
unoverse logs # what is it doing
|
|
23
23
|
unoverse where # its addresses, local and deployed, probed live
|
|
24
|
-
unoverse deploy # ship it to your server
|
|
25
24
|
unoverse stop
|
|
26
25
|
```
|
|
27
26
|
|
package/bin/unoverse.mjs
CHANGED
|
@@ -44,7 +44,9 @@ function findUniverse() {
|
|
|
44
44
|
|
|
45
45
|
/** Run an operator command in the universe we are standing in. */
|
|
46
46
|
function operator(u, args) {
|
|
47
|
-
|
|
47
|
+
// UNOVERSE_CLI tells the operator's help it is printed by the CLI, which no longer lists the
|
|
48
|
+
// VM deploy commands (they stay in the runbook, scripts/operator.sh).
|
|
49
|
+
const r = spawnSync("bash", [u.script, ...args], { stdio: "inherit", cwd: u.root, env: { ...process.env, UNOVERSE_CLI: "1" } });
|
|
48
50
|
process.exit(r.status ?? 0);
|
|
49
51
|
}
|
|
50
52
|
|
|
@@ -58,14 +60,19 @@ const UNIVERSE = findUniverse();
|
|
|
58
60
|
// type it to update the CLI far more often than to refresh a local universe's images,
|
|
59
61
|
// and that refresh now belongs to `start --pull`.
|
|
60
62
|
const OPERATOR_COMMANDS = new Set([
|
|
61
|
-
"start", "stop", "check", "logs", "
|
|
63
|
+
"start", "stop", "check", "logs", "db-allow",
|
|
62
64
|
// kept working, not advertised. `publish` is NOT here: it has its own case below,
|
|
63
65
|
// because ONE VERB serves two lanes and the folder decides which (LOCAL_STUDIO.md
|
|
64
66
|
// §Publish is terminal-only) — an asset workspace publishes item rows, a universe
|
|
65
67
|
// publishes the platform via the operator.
|
|
66
|
-
"
|
|
68
|
+
"dev", "build",
|
|
67
69
|
]);
|
|
68
70
|
|
|
71
|
+
// DEPLOYING A UNIVERSE TO A VM IS RETIRED FROM THE CLI (owner, 2026-11-13). The platform ships as
|
|
72
|
+
// cells on Kubernetes (docs/saas-architecture) and a developer's work ships by a push to the org's
|
|
73
|
+
// Git repo. The runbook for a universe still on a VM stays in the platform repo, scripts/operator.sh.
|
|
74
|
+
// `deploy`, `destroy` and `ground` answer with that, in their own case below.
|
|
75
|
+
|
|
69
76
|
const [, , cmd, ...args] = process.argv;
|
|
70
77
|
|
|
71
78
|
// FIRST CONTACT. Someone who has never seen this reads it, so it answers two questions
|
|
@@ -97,10 +104,6 @@ const HELP = [
|
|
|
97
104
|
` ${bold("After that")}`,
|
|
98
105
|
row("studio", "Design components, nodes and agent skills"),
|
|
99
106
|
row("lint", "Check your components, nodes and skills, the same way your universe does"),
|
|
100
|
-
row("deploy", "Put a universe on a cloud"),
|
|
101
|
-
` ${dim("deploy aws your universe → AWS")}`,
|
|
102
|
-
` ${dim("deploy digitalocean your universe → DigitalOcean")}`,
|
|
103
|
-
row("login", "Sign in to a universe (deploy asks by itself when needed)"),
|
|
104
107
|
row("update", "Update this CLI"),
|
|
105
108
|
"",
|
|
106
109
|
].join("\n");
|
|
@@ -251,40 +254,10 @@ switch (cmd) {
|
|
|
251
254
|
break;
|
|
252
255
|
}
|
|
253
256
|
|
|
254
|
-
case "
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
let target = args[0];
|
|
259
|
-
if (!target) {
|
|
260
|
-
// No URL typed: the workspace's committed target is the obvious answer.
|
|
261
|
-
const { findWorkspace, readConfig } = await import("../lib/workspace.mjs");
|
|
262
|
-
const ws = findWorkspace();
|
|
263
|
-
if (ws?.kind === "assets" || ws?.kind === "org") target = (await readConfig(ws.root)).universe;
|
|
264
|
-
}
|
|
265
|
-
if (!target) {
|
|
266
|
-
console.error(`\n Which universe? unoverse login <url>\n ${dim("(or run it from a workspace whose unoverse.yaml names one)")}\n`);
|
|
267
|
-
process.exit(1);
|
|
268
|
-
}
|
|
269
|
-
try {
|
|
270
|
-
await login(normaliseUrl(target));
|
|
271
|
-
} catch (e) {
|
|
272
|
-
console.error(`\n ✗ ${e.message}\n`);
|
|
273
|
-
process.exit(1);
|
|
274
|
-
}
|
|
275
|
-
break;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
case "deploy": {
|
|
279
|
-
// THE OPERATOR'S CLOUD DEPLOY: puts a universe on a cloud. A developer's own work never
|
|
280
|
-
// ships this way; it reaches a universe through the org's Git repo (RELEASE_LIFECYCLE.md §3).
|
|
281
|
-
// A word that is not a cloud is refused here, before the operator runs anything.
|
|
282
|
-
if (args[0] && !args[0].startsWith("-") && !["aws", "amazon", "digitalocean", "do"].includes(args[0])) {
|
|
283
|
-
console.log(`\n 'deploy ${args[0]}' is not a cloud. Use: unoverse deploy aws, or unoverse deploy digitalocean.\n Your own work ships by a push to your org's Git repo.\n`);
|
|
284
|
-
process.exit(1);
|
|
285
|
-
}
|
|
286
|
-
if (UNIVERSE) operator(UNIVERSE, ["deploy", ...args]);
|
|
287
|
-
console.log(`\n '${["deploy", args[0]].filter(Boolean).join(" ")}' operates a universe, and this folder is not one.\n cd into your universe. To ship your own work, push it to your org's Git repo.\n`);
|
|
257
|
+
case "deploy":
|
|
258
|
+
case "destroy":
|
|
259
|
+
case "ground": {
|
|
260
|
+
console.log(`\n '${cmd}' is retired from the CLI. The platform ships as cells on Kubernetes,\n and your own work ships by a push to your org's Git repo.\n ${dim("A universe still on a VM: the runbook is scripts/operator.sh in the platform repo.")}\n`);
|
|
288
261
|
process.exit(1);
|
|
289
262
|
}
|
|
290
263
|
|
package/lib/workspace.mjs
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* `unoverse.yaml` at the workspace root is the COMMITTED project config: `universe:`, the
|
|
10
10
|
* default deploy target, and `environments:`, named targets (`uat`, `production`) that CI
|
|
11
11
|
* picks with `--env`. It is config, not a secret: the whole team and CI deploy to the same
|
|
12
|
-
* places, which is exactly why it belongs in the repo. Credentials never live here
|
|
13
|
-
*
|
|
12
|
+
* places, which is exactly why it belongs in the repo. Credentials never live here, and the
|
|
13
|
+
* CLI holds none: work ships by a push to the org's Git repo, so Git decides who may ship.
|
|
14
14
|
*/
|
|
15
15
|
import { existsSync, renameSync, readFileSync, writeFileSync } from "node:fs";
|
|
16
16
|
import { join, resolve } from "node:path";
|
|
@@ -54,7 +54,10 @@ cmd_db_verify() {
|
|
|
54
54
|
"error", "created_at", "fingerprint"
|
|
55
55
|
],
|
|
56
56
|
credentials: [
|
|
57
|
-
"id", "name", "type", "scope", "data", "created_at", "updated_at", "ref"
|
|
57
|
+
"id", "name", "type", "scope", "data", "created_at", "updated_at", "ref", "org", "copied_from"
|
|
58
|
+
],
|
|
59
|
+
credential_links: [
|
|
60
|
+
"credential_id", "org", "linked_by", "linked_at"
|
|
58
61
|
],
|
|
59
62
|
token_usage: [
|
|
60
63
|
"id", "workflow_id", "execution_id", "node_id", "node_type",
|
|
@@ -74,7 +77,7 @@ cmd_db_verify() {
|
|
|
74
77
|
"id", "user_id", "org", "workflow_id", "memory_id", "content",
|
|
75
78
|
"source_conversation_id", "created_at", "updated_at", "type",
|
|
76
79
|
"domain", "certainty", "reinforcement_count", "last_reinforced",
|
|
77
|
-
"supports", "contradicts", "supersedes"
|
|
80
|
+
"supports", "contradicts", "supersedes", "company_id"
|
|
78
81
|
],
|
|
79
82
|
analytics_events: [
|
|
80
83
|
"id", "user_id", "workflow_id", "memory_id", "actual_user_id",
|
|
@@ -207,7 +210,7 @@ cmd_db_verify() {
|
|
|
207
210
|
],
|
|
208
211
|
agent_runs: [
|
|
209
212
|
"run_id", "agent_ref", "woken_by", "instruction", "state", "outcome",
|
|
210
|
-
"started_at", "ended_at"
|
|
213
|
+
"started_at", "ended_at", "org", "conversation"
|
|
211
214
|
],
|
|
212
215
|
dictionary_mentions: [
|
|
213
216
|
"id", "org", "job_id", "source", "object_type", "fields", "document_id",
|
|
@@ -216,7 +219,13 @@ cmd_db_verify() {
|
|
|
216
219
|
people: [
|
|
217
220
|
"person_id", "org", "stage", "email", "linkedin", "user_id", "crm_provider",
|
|
218
221
|
"crm_id", "name", "company", "role", "observed", "understood", "inferred",
|
|
219
|
-
"researched", "created_at", "updated_at"
|
|
222
|
+
"researched", "created_at", "updated_at", "company_id"
|
|
223
|
+
],
|
|
224
|
+
accounts: [
|
|
225
|
+
"sub", "name", "email", "picture", "first_seen", "last_seen"
|
|
226
|
+
],
|
|
227
|
+
companies: [
|
|
228
|
+
"company_id", "org", "name", "domain", "website", "researched", "created_at", "updated_at"
|
|
220
229
|
],
|
|
221
230
|
dictionary_merges: [
|
|
222
231
|
"id", "org", "survivor_id", "gone_id", "name", "snapshot", "changed", "by",
|
package/operator/lib/help.sh
CHANGED
|
@@ -16,10 +16,13 @@ cmd_help() {
|
|
|
16
16
|
echo -e " ${BOLD}Anywhere${NC}"
|
|
17
17
|
echo -e " ${GREEN}create${NC} Start something new, here"
|
|
18
18
|
echo -e " ${GREEN}studio${NC} Author components, nodes, agent skills"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
# THE VM DEPLOY COMMANDS ARE THE RUNBOOK'S ONLY (owner, 2026-11-13): the CLI no longer runs
|
|
20
|
+
# them (it sets UNOVERSE_CLI), so its help does not list them; scripts/operator.sh still does.
|
|
21
|
+
if [ -z "${UNOVERSE_CLI:-}" ]; then
|
|
22
|
+
echo -e " ${GREEN}deploy${NC} Put a universe on a cloud"
|
|
23
|
+
echo -e " ${DIM}deploy aws your universe → AWS${NC}"
|
|
24
|
+
echo -e " ${DIM}deploy digitalocean your universe → DigitalOcean${NC}"
|
|
25
|
+
fi
|
|
23
26
|
echo -e " ${GREEN}where${NC} Links to your universe ${DIM}(Canvas, API), checked live${NC}"
|
|
24
27
|
echo -e " ${GREEN}update${NC} Update this CLI"
|
|
25
28
|
echo ""
|
|
@@ -34,8 +37,10 @@ cmd_help() {
|
|
|
34
37
|
# SHOW THE COMMAND, not a description of it. "aws or digitalocean" told a reader the
|
|
35
38
|
# clouds exist without telling them what to type, so the shape of the command still had
|
|
36
39
|
# to be guessed. Print the line they will actually run.
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
if [ -z "${UNOVERSE_CLI:-}" ]; then
|
|
41
|
+
echo -e " ${GREEN}destroy${NC} Take it down ${DIM}(shows what goes, and what stays)${NC}"
|
|
42
|
+
echo -e " ${DIM}destroy aws · destroy digitalocean${NC}"
|
|
43
|
+
fi
|
|
39
44
|
echo -e " ${GREEN}db-allow${NC} Let this machine reach the database ${DIM}(run it when you change network)${NC}"
|
|
40
45
|
echo ""
|
|
41
46
|
# Owner-only lane. Printed ONLY when publish.sh is present, so a starter kit never
|
package/package.json
CHANGED
|
@@ -55,6 +55,23 @@ export function readOrgName(dir) {
|
|
|
55
55
|
return null;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* DOES THIS ORG OFFER ITS AGENTS to other orgs as a team (docs/unoverseCopilot/ORG_BUILDER.md § 0c;
|
|
60
|
+
* owner, 2026-11-15: "should be part of the org yaml, not a switch")? Only `offerAgents: true` in its
|
|
61
|
+
* unoverse.yaml says yes; absent, or anything else, is no. Declared in Git, so it changes by a
|
|
62
|
+
* reviewed commit, and no Agent can write it (unoverse.yaml is outside every org folder).
|
|
63
|
+
*/
|
|
64
|
+
export function readOrgOffersAgents(dir) {
|
|
65
|
+
const file = join(dir, "unoverse.yaml");
|
|
66
|
+
if (!existsSync(file))
|
|
67
|
+
return false;
|
|
68
|
+
try {
|
|
69
|
+
return parseYaml(readFileSync(file, "utf8"))?.offerAgents === true;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
58
75
|
/** This folder as an org repo, or null. */
|
|
59
76
|
export function orgRepo(dir) {
|
|
60
77
|
const org = readOrgName(dir);
|
|
@@ -65,6 +82,15 @@ function orgDesignSystemDir(dir) {
|
|
|
65
82
|
return join(dir, "plugins", "node_modules", "@unoverse-platform", "marketplace", "definitions");
|
|
66
83
|
}
|
|
67
84
|
/** Collect an org repo into items: the same walk as a monorepo project, rooted at the repo. */
|
|
85
|
+
/**
|
|
86
|
+
* EVERY KIND THE WALK READS from an org's folder. A sync that reads a folder with this walk
|
|
87
|
+
* knows each of these completely: none of a kind in the folder means none in the org, so the
|
|
88
|
+
* sync may remove what is gone. A kind not listed (a recipe) is never read here, so a sync
|
|
89
|
+
* never removes it.
|
|
90
|
+
*/
|
|
91
|
+
export const COLLECTED_KINDS = new Set([
|
|
92
|
+
"component", "app", "template", "atom", "identity", "agent", "object", "pipeline", "style", "skill", "prompt-block", "node",
|
|
93
|
+
]);
|
|
68
94
|
export function collectOrg(home) {
|
|
69
95
|
return collectFrom(home.dir, home.org, orgDesignSystemDir(home.dir));
|
|
70
96
|
}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
// ── ground truth (mirrors packages/docs/schemas/design/unoverse.schema.json + server guards) ──
|
|
14
14
|
export const PRIMITIVES = new Set([
|
|
15
15
|
"Box", "Stack", "Row", "Column", "Each", "Switch", "ComponentSlot", "Timeline",
|
|
16
|
-
"Text", "Image", "Button", "Input", "Select", "Markdown", "Skeleton", "Icon", "Ref", "Orb", "Template", "Place",
|
|
16
|
+
"Text", "Image", "Button", "Input", "Select", "Markdown", "Skeleton", "Icon", "Ref", "Orb", "TalkingHead", "Spline", "Template", "Place",
|
|
17
17
|
]);
|
|
18
18
|
export const CONDITION_KEYS = new Set(["field", "eq", "ne", "in"]);
|
|
19
19
|
|
|
@@ -82,6 +82,15 @@ export const PRIMITIVE_PROPS = {
|
|
|
82
82
|
Icon: ["icon", "name"],
|
|
83
83
|
Skeleton: ["variant"],
|
|
84
84
|
Orb: ["state", "size"],
|
|
85
|
+
// THE FACE: a talking head that moves its mouth to the voice the page is playing. Its code
|
|
86
|
+
// and files are fetched from the unoverse server the first time one is drawn.
|
|
87
|
+
TalkingHead: ["avatar", "size", "lipsync", "state"],
|
|
88
|
+
// A 3D SCENE made in Spline, drawn by Spline's own player. `src` is the scene's address. Every
|
|
89
|
+
// `bind` key but `src` names a variable in the scene, so it has no fixed bind list (below).
|
|
90
|
+
// Its `action` runs when an object in the scene is pressed, with that object's name as
|
|
91
|
+
// `target`. The player loads the first time one is drawn: from the unoverse server when it
|
|
92
|
+
// carries a copy, otherwise from Spline's own public address.
|
|
93
|
+
Spline: ["src"],
|
|
85
94
|
Button: ["children", "value", "label", "icon", "disabledWhen"],
|
|
86
95
|
Input: ["placeholder", "inputType", "disabledWhen", "maxLength", "multiline", "rows",
|
|
87
96
|
"inputMode", "autoComplete", "advanceOnFill"],
|
|
@@ -106,6 +115,7 @@ export const PRIMITIVE_BINDS = {
|
|
|
106
115
|
Text: ["value"], Image: ["src", "alt"], Markdown: ["value"], Icon: ["name"],
|
|
107
116
|
Button: ["label"], Input: ["value", "placeholder"], Select: ["options", "value"],
|
|
108
117
|
Each: ["items"],
|
|
118
|
+
TalkingHead: ["avatar", "size", "lipsync", "state"],
|
|
109
119
|
};
|
|
110
120
|
// the portable style vocabulary — every key the SDK interpreter maps (sdk/style.ts).
|
|
111
121
|
// Each is a neutral intent every native renderer (iOS/Android/RN/Flutter) implements;
|
|
@@ -927,6 +927,51 @@
|
|
|
927
927
|
},
|
|
928
928
|
"additionalProperties": false
|
|
929
929
|
},
|
|
930
|
+
"conversation": {
|
|
931
|
+
"type": "object",
|
|
932
|
+
"required": [
|
|
933
|
+
"remember",
|
|
934
|
+
"user",
|
|
935
|
+
"assistant"
|
|
936
|
+
],
|
|
937
|
+
"description": "CONVERSATION MEMORY FOR A VENDOR THAT KEEPS NOTHING BETWEEN REQUESTS (Anthropic's Messages API keeps a chat for 5 minutes at most and asks the application to keep its own copy). The same job `continuity` does for a vendor that keeps the chat itself (OpenAI's Responses API). The loop keeps what was said in the conversation, one user message and the final answer per run, and exposes it to the request as `history`, which the manifest spreads ahead of the new message:\n\n messages: history.concat([{ role: 'user', content: config.prompt }]).concat(transcript)\n\nWhat is kept is what was SAID, never a turn's tool calls or thinking, so no earlier turn is replayed in a form the vendor checks.",
|
|
938
|
+
"properties": {
|
|
939
|
+
"remember": {
|
|
940
|
+
"type": "object",
|
|
941
|
+
"required": [
|
|
942
|
+
"key"
|
|
943
|
+
],
|
|
944
|
+
"description": "Where the conversation is held, and whether it is this run. Key on the CONVERSATION, not the turn.",
|
|
945
|
+
"properties": {
|
|
946
|
+
"when": {
|
|
947
|
+
"type": "string",
|
|
948
|
+
"description": "Expression: keep and send the conversation only when this is true (the node's own switch)."
|
|
949
|
+
},
|
|
950
|
+
"key": {
|
|
951
|
+
"type": "string",
|
|
952
|
+
"description": "State key the conversation is held under, templated against the run's scope."
|
|
953
|
+
}
|
|
954
|
+
},
|
|
955
|
+
"additionalProperties": false
|
|
956
|
+
},
|
|
957
|
+
"user": {
|
|
958
|
+
"type": "string",
|
|
959
|
+
"description": "Expression: this run's message from the person, in the vendor's message shape. Has `config` and `scope`."
|
|
960
|
+
},
|
|
961
|
+
"assistant": {
|
|
962
|
+
"type": "string",
|
|
963
|
+
"description": "Expression: the final answer, in the vendor's message shape. Has `text`."
|
|
964
|
+
},
|
|
965
|
+
"keep": {
|
|
966
|
+
"type": [
|
|
967
|
+
"number",
|
|
968
|
+
"string"
|
|
969
|
+
],
|
|
970
|
+
"description": "How many messages to keep, newest last; the oldest fall off whole. Default 40."
|
|
971
|
+
}
|
|
972
|
+
},
|
|
973
|
+
"additionalProperties": false
|
|
974
|
+
},
|
|
930
975
|
"transcript": {
|
|
931
976
|
"type": "object",
|
|
932
977
|
"additionalProperties": false,
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"type": "array",
|
|
125
125
|
"items": {
|
|
126
126
|
"type": "string",
|
|
127
|
-
"pattern": "^unoverse://tasks/[a-z0-9][a-z0-9-]*/[A-Za-z0-9][A-Za-z0-9._-]
|
|
127
|
+
"pattern": "^unoverse://(tasks/[a-z0-9][a-z0-9-]*/[A-Za-z0-9][A-Za-z0-9._-]*|agents/[a-z0-9][a-z0-9-]*/[a-z0-9][a-z0-9-]*)$"
|
|
128
128
|
},
|
|
129
129
|
"description": "The tasks it may call, each by its one URI. A marketplace MCP is a task too: unoverse://tasks/marketplace/signal-save hands over every tool it offers (MCP_TASKS.md § 2a)."
|
|
130
130
|
},
|
|
@@ -183,6 +183,16 @@
|
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
},
|
|
186
|
+
"signal": {
|
|
187
|
+
"type": "object",
|
|
188
|
+
"additionalProperties": false,
|
|
189
|
+
"properties": {
|
|
190
|
+
"addsPeople": {
|
|
191
|
+
"type": "boolean",
|
|
192
|
+
"description": "false: its own save updates people Signal holds and never adds one; a new person comes in only through a lane's fixed save. Left out, it may add."
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
},
|
|
186
196
|
"askWhenUnsure": {
|
|
187
197
|
"type": "string"
|
|
188
198
|
}
|
|
@@ -112,6 +112,9 @@
|
|
|
112
112
|
"within": { "type": "object", "required": ["link"], "properties": { "link": { "type": "string" }, "field": { "type": "string" } }, "description": "How a subject sits inside another: the link to its parent (subFundOf) and the field naming the parent (umbrella)." },
|
|
113
113
|
"part": { "type": "object", "required": ["object", "column", "level", "name", "of"], "properties": { "object": { "type": "string" }, "column": { "type": "string" }, "level": { "type": "string" }, "name": { "type": "string" }, "of": { "type": "string" } }, "description": "Its parts (a fund's share classes): their object, column, `level` value, name field and the field naming their subject." },
|
|
114
114
|
"none": { "type": "string", "description": "The `level` value for a document about no subject (market)." },
|
|
115
|
+
"relative": { "type": "array", "items": { "type": "string" }, "description": "The measures that are a subject's figure against its comparison (excess return: the return above the benchmark's): a row of one that names no subject of its own is the subject the table's own rows name, when they name exactly one; with two or more it names none. Each is one of the measure column's `enum`." },
|
|
116
|
+
"held": { "type": "string", "description": "The measure a list of what the subject holds states for each position (exposure): a percentage column of such a list that no word names is each position's figure of it. Absent, none is assumed." },
|
|
117
|
+
"vehicles": { "type": "array", "items": { "type": "string" }, "description": "The words a name of the subject's kind carries when it names one (fund; a segregated portfolio's portfolio): an allocation table's row whose name holds one of them, with words of its own, is a holding, a line from the subject to it (pipelines/tables.md 3c rule 3); a row of words alone is a heading. Absent, the word fund." },
|
|
115
118
|
"terms": { "type": "array", "items": { "type": "string" }, "description": "The measures that are a record's standing terms, never figures over time (fee): a rate of one is a field of the subject's or part's record, read by the layout, and never a row; an amount of money of one (fees charged over a period) stays a row. Each is one of the measure column's `enum`." }
|
|
116
119
|
}
|
|
117
120
|
}
|
|
@@ -240,7 +240,7 @@
|
|
|
240
240
|
"remember": { "type": "string", "description": "One of names, a list: where a name confirmed by the judge or a person is added, so the next one matches at once." },
|
|
241
241
|
"evidence": { "type": "array", "items": { "type": "string" }, "description": "Fields shown to the judge beside each candidate, to tell like names apart." },
|
|
242
242
|
"ruleOut": { "type": "array", "items": { "type": "string" }, "description": "Fields that, filled on both and different as words, mean never the same thing." },
|
|
243
|
-
"judge": { "type": "string", "description": "The node that decides a name the rules leave open, choosing among the candidates or none (TypeSafeChoice). Absent, an open name goes to review." },
|
|
243
|
+
"judge": { "oneOf": [ { "type": "string" }, { "type": "object", "required": ["node"], "properties": { "node": { "type": "string" }, "config": { "type": "object" } }, "additionalProperties": false } ], "description": "The node that decides a name the rules leave open, choosing among the candidates or none (TypeSafeChoice). Absent, an open name goes to review." },
|
|
244
244
|
"link": {
|
|
245
245
|
"type": "object",
|
|
246
246
|
"additionalProperties": false,
|
|
@@ -248,7 +248,7 @@
|
|
|
248
248
|
"description": "The node that scores the name against each candidate's names before the judge (Splink on Beam): sure the same, linked; sure different, none; between, the judge.",
|
|
249
249
|
"properties": { "node": { "type": "string", "minLength": 1 }, "config": { "type": "object" } }
|
|
250
250
|
},
|
|
251
|
-
"review": { "type": "object", "additionalProperties": false, "
|
|
251
|
+
"review": { "type": "object", "additionalProperties": false, "minProperties": 1, "description": "The last look at every name a run left open, with what the documents say where the name is used: a decision node (OpenAIDecision) with its config, or `task`, one of the org's own tasks by name, answered by the org's agent (2026-10-31). Sure, it decides as a person would, with Undo (a task: a new record on a createFrom line); not sure, the name stays open for a person. Absent, the judge looks.", "properties": { "node": { "type": "string", "minLength": 1 }, "config": { "type": "object" }, "task": { "type": "string", "minLength": 1 } }, "oneOf": [ { "required": ["node"] }, { "required": ["task"] } ] },
|
|
252
252
|
"createFrom": { "type": "array", "items": { "type": "string" }, "description": "The lines, by name (a document's about), whose name the judge is sure is no record held makes the record. A mention on any other line, or a name of one word, never does." }
|
|
253
253
|
}
|
|
254
254
|
},
|
|
@@ -86,8 +86,8 @@
|
|
|
86
86
|
"description": "The field's id in the org's field list (one org's list is openfunds: OFST452010). A table's column or row named by this field's wordings, or by the standard field's own name, fills it (docs/unoverse/data/pipelines/tables.md)."
|
|
87
87
|
},
|
|
88
88
|
"format": {
|
|
89
|
-
"enum": ["date", "country"],
|
|
90
|
-
"description": "date: the field is a date, written yyyy-mm-dd. A date a document prints another way (31/Mar/2025, 21 October 2024) is written so; one that could be read two ways (03/04/2025) is left, never guessed. country: the field is a country, held by its one name from ISO 3166-1 (its code named by the CLDR English region names) however a document prints it (UK, GB and United Kingdom are United Kingdom); a value no country fits stays as printed."
|
|
89
|
+
"enum": ["date", "country", "currency"],
|
|
90
|
+
"description": "date: the field is a date, written yyyy-mm-dd. A date a document prints another way (31/Mar/2025, 21 October 2024) is written so; one that could be read two ways (03/04/2025) is left, never guessed. country: the field is a country, held by its one name from ISO 3166-1 (its code named by the CLDR English region names) however a document prints it (UK, GB and United Kingdom are United Kingdom); a value no country fits stays as printed. currency: the field is a currency, held by its ISO 4217 code (named by the CLDR English currency names, one and many, and its country's names before the unit) however a document prints it (U.S. Dollars, US dollar and United States Dollars are USD); a value no currency fits, or two fit (Dollars), stays as printed."
|
|
91
91
|
},
|
|
92
92
|
"pattern": {
|
|
93
93
|
"type": "string",
|
|
@@ -100,6 +100,17 @@
|
|
|
100
100
|
"items": { "type": "string", "minLength": 1 },
|
|
101
101
|
"description": "The words documents print for this field (management related fees, mgmt fee), matched exactly after lower case. A new wording is proposed, approved by a person, then added here (docs/unoverse/data/pipelines/tables.md)."
|
|
102
102
|
},
|
|
103
|
+
"wordingsIn": {
|
|
104
|
+
"type": "object",
|
|
105
|
+
"minProperties": 1,
|
|
106
|
+
"additionalProperties": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } },
|
|
107
|
+
"description": "Words that name this field in one kind of document only, as { <document type>: [<words>] }, where one type prints for this field the words another prints for another field (an offering document's management fee is its maximum). The scoped words win over the plain wordings for that type."
|
|
108
|
+
},
|
|
109
|
+
"onlyWith": {
|
|
110
|
+
"type": "string",
|
|
111
|
+
"minLength": 1,
|
|
112
|
+
"description": "Another field of this object that this one is a term of; where a record states that field as none, this one is not kept (a hurdle only with a performance fee)."
|
|
113
|
+
},
|
|
103
114
|
"none": {
|
|
104
115
|
"description": "The value a table cell that states there is none (\"None\", \"N/A\", \"-\", \"Nil\") stands for (0 for a fee), kept as stated; without it such a cell fills nothing. Never a default: a field the documents do not state stays empty."
|
|
105
116
|
},
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
|
|
14
14
|
"description": "Equals the file name."
|
|
15
15
|
},
|
|
16
|
+
"figures": { "enum": ["none"], "description": "A type whose figures are never metrics (a letter, a market note): every number stays in its table, where search finds it." },
|
|
16
17
|
"reportType": {
|
|
17
18
|
"type": "string",
|
|
18
19
|
"pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
|
|
@@ -65,6 +66,17 @@
|
|
|
65
66
|
"type": "array",
|
|
66
67
|
"items": { "$ref": "#/definitions/never" },
|
|
67
68
|
"description": "Names this type prints that are never records. Structured so the confirm step can apply them."
|
|
69
|
+
},
|
|
70
|
+
"codes": {
|
|
71
|
+
"type": "object",
|
|
72
|
+
"additionalProperties": false,
|
|
73
|
+
"required": ["column", "rules"],
|
|
74
|
+
"description": "A FIXED TEMPLATE READ BY ITS PRINTED CELL CODES (owner 2026-10-26): a type whose every figure cell carries the template's own code (its item number and a bracketed tag naming its column, \"1.2.3 (AB)\") is read by this map alone, never by the general figure reader. A table whose header holds `column` is a coded table: each figure is paired with its code; every rule whose code and tag match applies, in order, a later one over an earlier; a figure whose code gets no measure and unit stays in its table with the reason. Written once from the published template (its sections, its tags as its header rows print them), never from one document. Names no fund, firm or document.",
|
|
75
|
+
"properties": {
|
|
76
|
+
"column": { "type": "string", "minLength": 1, "description": "The header of the column holding each row's codes (a regular expression). The parser writes one slot per value column, in column order, ' | ' between them, '' for a column with no code; a row whose codes are printed elsewhere keeps them as a list." },
|
|
77
|
+
"pattern": { "type": "string", "minLength": 1, "description": "How a code is printed: group 1 the number, group 2 the tag. Default ^(\\d+(?:\\.\\d+)+)(?:\\s*\\(\\s*([^)]*?)\\s*\\))?$." },
|
|
78
|
+
"rules": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/codeRule" } }
|
|
79
|
+
}
|
|
68
80
|
}
|
|
69
81
|
},
|
|
70
82
|
"definitions": {
|
|
@@ -156,11 +168,22 @@
|
|
|
156
168
|
"group": { "type": "integer", "minimum": 1, "description": "The group of `pattern` that is the value; alone, in a record's `fields`, the group of the record's name match (\"Minimum Initial Subscription for (Class B) Shares: (250,000)\" gives the class and its minimum)." },
|
|
157
169
|
"case": { "type": "string", "enum": ["any"], "description": "`any`: the pattern matches whatever the case of the page's words (a heading in capitals, the same words in a sentence)." },
|
|
158
170
|
"scope": { "type": "string", "enum": ["section", "document"], "description": "Where the pattern is searched: the section (default) or the whole document, for a value printed outside its section (an umbrella named only in the notices)." },
|
|
159
|
-
"cell": { "type": "string", "enum": ["value", "label"], "description": "With `table` and `row`: take the value cell (default) or the row's label (a class named in the label, 'ISIN - Base Shares')." },
|
|
160
|
-
"line": { "type": "string", "enum": ["after-heading", "first-heading", "first", "last"] },
|
|
171
|
+
"cell": { "type": "string", "enum": ["value", "label", "each"], "description": "With `table` and `row`: take the value cell (default) or the row's label (a class named in the label, 'ISIN - Base Shares'). `each`, as a record's `name` with `table` and `pattern`: every cell of the table that matches `pattern` is its own record (a returns table heading one column per class)." },
|
|
172
|
+
"line": { "type": "string", "enum": ["after-heading", "first-heading", "first", "last", "title"], "description": "`title`: the document's own title (a workbook may name its class only there)." },
|
|
161
173
|
"table": { "type": "string", "minLength": 1 },
|
|
162
174
|
"row": { "type": "string", "minLength": 1 },
|
|
163
|
-
"column": {
|
|
175
|
+
"column": {
|
|
176
|
+
"oneOf": [{ "type": "integer", "minimum": 1 }, { "const": "own" }],
|
|
177
|
+
"description": "With `table` and `row`: the cell at this position. `own`, as a field of a record found by `cell: each`: the cell in that record's own column. `{name}` in such a field's `row` stands for the record's name ('Inception Date for {name}')."
|
|
178
|
+
},
|
|
179
|
+
"classes": {
|
|
180
|
+
"oneOf": [
|
|
181
|
+
{ "type": "integer", "minimum": 1 },
|
|
182
|
+
{ "const": "other" },
|
|
183
|
+
{ "type": "object", "properties": { "column": { "type": "string", "minLength": 1 }, "is": { "type": "string", "minLength": 1 } }, "required": ["column", "is"], "additionalProperties": false }
|
|
184
|
+
],
|
|
185
|
+
"description": "A term a section instance states for SOME of its classes, given as a `kind.prop` field of another kind: it is only those classes'. A number: that group of `pattern` is a printed list of designations ('For I, IA and IB shares: <term>'; a run is each class), and the term is each listed class's. `other`: every class of the instance that no list in the same field named ('For all other shares: <term>'), only where a list matched. `{ column, is }`: every class whose row, in a class table of the instance, holds `is` in the column headed `column` (both regular expressions; 'For Share Classes subject to a performance fee: <term>' and the table's Performance Fee column saying Yes). Applied before the terms stated for every class; a class's own value is never replaced."
|
|
186
|
+
},
|
|
164
187
|
"na": { "description": "The value when the page prints N/A or 'none'." },
|
|
165
188
|
"map": {
|
|
166
189
|
"type": "object",
|
|
@@ -178,7 +201,7 @@
|
|
|
178
201
|
"name": { "oneOf": [ { "$ref": "#/definitions/finder" }, { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/finder" } } ] },
|
|
179
202
|
"role": { "type": "string", "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$" },
|
|
180
203
|
"country": { "oneOf": [ { "type": "string" }, { "type": "object", "properties": { "group": { "type": "integer", "minimum": 1 } }, "required": ["group"], "additionalProperties": false } ], "description": "The country the provider serves: a word, or a group of the name pattern that prints it beside the name." },
|
|
181
|
-
"split": { "type": "string", "minLength": 1, "description": "Breaks one match into several records." },
|
|
204
|
+
"split": { "type": "string", "minLength": 1, "description": "Breaks one match into several records: a separator the match is split on (\"; \"), or `run`: a run of designations (\"X1-X5\", \"X1-6\", \"X1 to X3\": a letter code and a number, the second end larger) is one record per designation, each with the fields of the run's match. A match that is no run stays one record." },
|
|
182
205
|
"trim": { "type": "string", "minLength": 1, "description": "After `split`, a pattern applied to each part; group 1 is the name (the words before the address)." },
|
|
183
206
|
"fields": {
|
|
184
207
|
"type": "object",
|
|
@@ -207,6 +230,28 @@
|
|
|
207
230
|
{ "type": "string", "minLength": 1 },
|
|
208
231
|
{ "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } }
|
|
209
232
|
]
|
|
233
|
+
},
|
|
234
|
+
"codeRule": {
|
|
235
|
+
"type": "object",
|
|
236
|
+
"additionalProperties": false,
|
|
237
|
+
"minProperties": 2,
|
|
238
|
+
"description": "What the cells of a code are. `code`: a prefix ('1.2': the item and every item under it) or a regular expression (opening with ^); `tag`: the bracketed column tag, case ignored. Without `code` a rule holds for every code with its tag; without `tag`, for every column. Values are the org dataset's own (measure, unit, side, adjustment, dimension, period), checked by the lint; null clears what an earlier rule gave.",
|
|
239
|
+
"properties": {
|
|
240
|
+
"code": { "$ref": "#/definitions/oneOrMore" },
|
|
241
|
+
"tag": { "$ref": "#/definitions/oneOrMore" },
|
|
242
|
+
"measure": { "type": ["string", "null"] },
|
|
243
|
+
"unit": { "type": ["string", "null"] },
|
|
244
|
+
"currency": { "type": ["string", "null"], "description": "Which money, an ISO code, when the unit is an amount; null for a share or a count." },
|
|
245
|
+
"adjustment": { "type": ["string", "null"] },
|
|
246
|
+
"scale": { "type": "number", "description": "A bare cell times this, in decimal arithmetic (a fraction stored bare takes 100); a cell printing its own '%' is read as it shows." },
|
|
247
|
+
"side": { "type": ["string", "null"] },
|
|
248
|
+
"dimension": { "type": ["string", "null"], "description": "The slicing the code's section is. The category is the row's own label resolved to the dimension's standard value (the dataset's category wordings), else the label as printed." },
|
|
249
|
+
"category": { "enum": ["label", "none"], "description": "`none`: the slicing without a category (a whole)." },
|
|
250
|
+
"about": { "type": "string", "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$", "description": "Whose the figure is when not the document's subject: the dataset's `whose.owner.object` (filed at the owner's level) or `whose.part.object` (the one class the layout names)." },
|
|
251
|
+
"period": { "type": "string" },
|
|
252
|
+
"annualised": { "type": "boolean" },
|
|
253
|
+
"skip": { "type": "string", "minLength": 1, "description": "These cells are no metric: the reason, kept with the number in its table." }
|
|
254
|
+
}
|
|
210
255
|
}
|
|
211
256
|
}
|
|
212
257
|
}
|
|
@@ -108,6 +108,11 @@
|
|
|
108
108
|
"content": {
|
|
109
109
|
"type": "object",
|
|
110
110
|
"description": "What the row carries instead of the item as listed, each value over item, index, config and collect."
|
|
111
|
+
},
|
|
112
|
+
"about": {
|
|
113
|
+
"type": "object",
|
|
114
|
+
"description": "Whose the row is: names to references over the run (collect, config, item), written as `about` on every record the row's reads make; never an identity (SIGNAL.md § 4b).",
|
|
115
|
+
"additionalProperties": { "type": "string" }
|
|
111
116
|
}
|
|
112
117
|
},
|
|
113
118
|
"additionalProperties": {
|
|
@@ -26,6 +26,10 @@
|
|
|
26
26
|
},
|
|
27
27
|
"description": "Per collect step name, the node's outputs as if it had run."
|
|
28
28
|
},
|
|
29
|
+
"inputs": {
|
|
30
|
+
"type": "object",
|
|
31
|
+
"description": "What the caller hands the pipeline's Input Trigger (pipelines README, collect), for a pipeline that opens with one; its output under test is this, stamped with a timestamp."
|
|
32
|
+
},
|
|
29
33
|
"expect": {
|
|
30
34
|
"type": "object",
|
|
31
35
|
"additionalProperties": {
|
|
@@ -458,6 +458,47 @@ export function lintObjects(designRoot, options = {}) {
|
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
460
|
|
|
461
|
+
/**
|
|
462
|
+
* A STEP'S SKILL IS IN THE ORG (docs.unoverse.ai/design/tasks, "A step carries its skill"). A
|
|
463
|
+
* step of a template or a component may name the skill its caller follows, `skill: skills/<name>`:
|
|
464
|
+
* a path in the task's own org, never a full address. The skill must be there, in the org's
|
|
465
|
+
* skills/ or the marketplace's, or the step would hand out an address nothing answers.
|
|
466
|
+
*/
|
|
467
|
+
for (const tier of tiers) {
|
|
468
|
+
if (!tier.org) continue;
|
|
469
|
+
for (const kind of ["templates", "components"]) {
|
|
470
|
+
for (const n of foldersIn(tier.dir, kind)) {
|
|
471
|
+
const file = join(tier.dir, kind, n, `${n}.yaml`);
|
|
472
|
+
const doc = readYaml(file);
|
|
473
|
+
if (!isRecord(doc) || !isRecord(doc.states)) continue;
|
|
474
|
+
for (const [stateName, state] of Object.entries(doc.states)) {
|
|
475
|
+
if (!isRecord(state) || !isRecord(state.states)) continue;
|
|
476
|
+
for (const [stepName, step] of Object.entries(state.states)) {
|
|
477
|
+
if (!isRecord(step)) continue;
|
|
478
|
+
const where = `task ${tier.org}/${n}: step ${stateName}.${stepName}`;
|
|
479
|
+
// A STEP'S LISTED ANSWERS ARE THE TASK'S OWN ("A step asks only its own answers"): each
|
|
480
|
+
// name in `asks` is one of the task's `outputs`, or the step asks for nothing anyone declared.
|
|
481
|
+
if (step.asks !== undefined) {
|
|
482
|
+
const declared = isRecord(doc.outputs) ? Object.keys(doc.outputs) : [];
|
|
483
|
+
if (!Array.isArray(step.asks) || step.asks.some((k) => typeof k !== "string")) {
|
|
484
|
+
report("error", rel(file), `${where} lists its answers as ${JSON.stringify(step.asks)}; write a list of output names, asks: [name, name]`);
|
|
485
|
+
} else {
|
|
486
|
+
for (const k of step.asks) if (!declared.includes(k)) report("error", rel(file), `${where} asks for "${k}", which is not one of the task's outputs`);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
if (step.skill === undefined) continue;
|
|
490
|
+
const m = typeof step.skill === "string" ? /^skills\/([a-z0-9][a-z0-9-]*)$/.exec(step.skill) : null;
|
|
491
|
+
if (!m) {
|
|
492
|
+
report("error", rel(file), `${where} names its skill as ${JSON.stringify(step.skill)}; write it as a path in the org, skill: skills/<name>`);
|
|
493
|
+
} else if (!existsSync(join(tier.dir, "skills", m[1], "SKILL.md")) && !existsSync(join(marketplace, "skills", m[1], "SKILL.md"))) {
|
|
494
|
+
report("error", rel(file), `${where} names the skill "${m[1]}", which is not in skills/`);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
461
502
|
const rank = { error: 0, warn: 1, hint: 2 };
|
|
462
503
|
const sorted = [...problems].sort((a, b) => rank[a.level] - rank[b.level] || a.file.localeCompare(b.file));
|
|
463
504
|
return { problems: sorted, objectCount, pipelineCount, agentCount, designRoot: ROOT };
|
|
@@ -31,7 +31,7 @@ export const FACE_KEYS = ["title", "description", "whenToUse", "category", "vers
|
|
|
31
31
|
/** The prop grammar of UNOVERSE_AUTHORING 3b plus the object's one word, `from` (README 4c). */
|
|
32
32
|
// `none` IS NO DEFAULT (2026-10-15): it is what a cell that STATES there is none ("None", "N/A") stands for, so a
|
|
33
33
|
// stated "no performance fee" is 0 and a fee nobody states stays empty.
|
|
34
|
-
export const PROP_KEYS = new Set(["type", "input", "description", "from", "hydrate", "enum", "oneOf", "minLength", "maxLength", "minItems", "maxItems", "items", "reuse", "answeredBy", "standard", "wordings", "format", "pattern", "none"]);
|
|
34
|
+
export const PROP_KEYS = new Set(["type", "input", "description", "from", "hydrate", "enum", "oneOf", "minLength", "maxLength", "minItems", "maxItems", "items", "reuse", "answeredBy", "standard", "wordings", "wordingsIn", "onlyWith", "format", "pattern", "none"]);
|
|
35
35
|
export const LIMIT_KEYS = ["minLength", "maxLength", "minItems", "maxItems"];
|
|
36
36
|
|
|
37
37
|
/** Words that left the object grammar and must not come back (README 11.7, 12.3, 12.4). */
|
|
@@ -120,7 +120,9 @@ export function envelopeFindings(name, envelope, file = `${name}.yaml`) {
|
|
|
120
120
|
for (const k of ["ids", "evidence", "ruleOut"]) if (m[k] != null && !fields(m[k])) refuse(`object ${name}: matching: ${k} is a list of field names`);
|
|
121
121
|
if (m.createFrom != null && !fields(m.createFrom)) refuse(`object ${name}: matching: createFrom is a list of line names (about)`);
|
|
122
122
|
if (m.remember != null && (typeof m.remember !== "string" || !(m.names ?? []).includes(m.remember))) refuse(`object ${name}: matching: remember names one of names, the list a confirmed name is added to`);
|
|
123
|
-
|
|
123
|
+
// A JUDGE IS A NODE BY ITS TYPE, OR A DECISION NODE WITH ITS CONFIG as `review` is ({ node: OpenAIDecision, config: { model } }).
|
|
124
|
+
const judgeNode = isRecord(m.judge) ? m.judge.node : m.judge;
|
|
125
|
+
if (m.judge != null && (typeof judgeNode !== "string" || !/^[A-Z][A-Za-z0-9]*$/.test(judgeNode) || (isRecord(m.judge) && m.judge.config != null && !isRecord(m.judge.config)))) refuse(`object ${name}: matching: judge names a node by its type (TypeSafeChoice), or a decision node with its config ({ node: OpenAIDecision, config: { model } })`);
|
|
124
126
|
for (const k of Object.keys(m)) if (!["ids", "names", "remember", "evidence", "ruleOut", "judge", "link", "review", "createFrom"].includes(k)) say(`object ${name}: matching: "${k}" is not a word here`);
|
|
125
127
|
}
|
|
126
128
|
}
|
|
@@ -169,7 +171,14 @@ export function propsFindings(name, ownProps, parentProps = null, base = null, f
|
|
|
169
171
|
if (raw.standard != null && (typeof raw.standard !== "string" || !raw.standard.trim())) say(`object ${name}: prop "${k}": standard is the field's id in the org's field list, one word (OFST452010)`);
|
|
170
172
|
if (raw.wordings != null && (!Array.isArray(raw.wordings) || !raw.wordings.length || raw.wordings.some((w) => typeof w !== "string" || !w.trim()))) say(`object ${name}: prop "${k}": wordings is a list of the words documents print for this field, e.g. [management fee, mgmt fee]`);
|
|
171
173
|
if (raw.pattern != null) { try { if (typeof raw.pattern !== "string" || !raw.pattern.trim()) throw 0; new RegExp(raw.pattern); } catch { say(`object ${name}: prop "${k}": pattern is the regular expression a value must match, e.g. ^[A-Z]{2}[A-Z0-9]{9}[0-9]$; a value that does not match is never saved`); } }
|
|
172
|
-
if (raw.format != null && raw.format !== "date" && raw.format !== "country") say(`object ${name}: prop "${k}": format is date, country, or nothing (a date is written yyyy-mm-dd; a country is held by its one name from ISO 3166, "UK" saved as United Kingdom)`);
|
|
174
|
+
if (raw.format != null && raw.format !== "date" && raw.format !== "country" && raw.format !== "currency") say(`object ${name}: prop "${k}": format is date, country, currency, or nothing (a date is written yyyy-mm-dd; a country is held by its one name from ISO 3166, "UK" saved as United Kingdom; a currency by its ISO 4217 code, "U.S. Dollars" saved as USD)`);
|
|
175
|
+
// A WORDING SCOPED TO ONE KIND OF DOCUMENT (2026-10-26): `wordingsIn` lists, under a document type, the words that name
|
|
176
|
+
// this field in that type only, where one type prints for this field the words another prints for another field.
|
|
177
|
+
if (raw.wordingsIn != null && (!isRecord(raw.wordingsIn) || !Object.keys(raw.wordingsIn).length || Object.values(raw.wordingsIn).some((ws) => !Array.isArray(ws) || !ws.length || ws.some((w) => typeof w !== "string" || !w.trim())))) say(`object ${name}: prop "${k}": wordingsIn lists, under each document type, the words that name this field in that type only, as { <document type>: [<words>] }`);
|
|
178
|
+
if (raw.wordingsIn != null && raw.input !== true) say(`object ${name}: prop "${k}" says wordingsIn but not input: true; only a field read from documents is filled from a table`);
|
|
179
|
+
// A TERM OF ANOTHER FIELD (2026-10-26): `onlyWith` names the field this one is a term of; where that field is none,
|
|
180
|
+
// this one is not kept.
|
|
181
|
+
if (raw.onlyWith != null && (typeof raw.onlyWith !== "string" || raw.onlyWith === k || !(raw.onlyWith in ownProps || (parentProps && raw.onlyWith in parentProps)))) say(`object ${name}: prop "${k}": onlyWith names another field of this object that this one is a term of, and is kept only where that field is not none`);
|
|
173
182
|
if ((raw.standard != null || raw.wordings != null) && raw.input !== true) say(`object ${name}: prop "${k}" says standard or wordings but not input: true; only a field read from documents is filled from a table`);
|
|
174
183
|
}
|
|
175
184
|
// FILLED FROM DOCUMENTS, EVERY FIELD SAYS WHICH (proved-before-built.md, ruled 2026-10-07): an
|
|
@@ -319,7 +328,7 @@ export function objectTestFindings(name, test, service, file = "test.yaml") {
|
|
|
319
328
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
320
329
|
|
|
321
330
|
/** What an entry under `each` says about its row; every other key is an object that row becomes. */
|
|
322
|
-
export const PIPELINE_READ_KEYS = new Set(["each", "sourceUrl", "sourceId", "content"]);
|
|
331
|
+
export const PIPELINE_READ_KEYS = new Set(["each", "sourceUrl", "sourceId", "content", "about"]);
|
|
323
332
|
/** Words the 2026-09-15 shape dropped (docs/unoverse/data/pipelines/history.md), refused with a pointer. */
|
|
324
333
|
const DROPPED_MAKE_KEYS = ["partsOf", "by", "under", "when", "from", "any", "index"];
|
|
325
334
|
|
|
@@ -491,7 +500,7 @@ export function pipelineFolderFindings(name, { file, config, test }, { nodeTypes
|
|
|
491
500
|
*/
|
|
492
501
|
/** A legal form as one word of a name, in any jurisdiction's spelling: the mark of a firm's or a fund's name. */
|
|
493
502
|
const LEGAL_FORM_WORD = /^(?:Ltd|Limited|LLC|LLP|L\.?P\.?|LP|plc|PLC|Inc\.?|Corp\.?|Co\.?|GmbH|AG|S\.?A\.?|S\.?C\.?A\.?|S\.?p\.?A\.?|SpA|B\.?V\.?|BV|N\.?V\.?|NV|S\.?à\.?r\.?l\.?|SARL|Sàrl|Pte\.?|Pty\.?|KGaA|KG|ApS|AB|AS|Oy|SE|SAS|SL|SRL|Srl|V)\.?$/;
|
|
494
|
-
const LAYOUT_TEXT_KEYS = new Set(["pattern", "after", "heading", "text", "row", "table", "say", "describe", "trim", "split"]);
|
|
503
|
+
const LAYOUT_TEXT_KEYS = new Set(["pattern", "after", "heading", "text", "row", "table", "say", "describe", "trim", "split", "column", "is"]);
|
|
495
504
|
const LAYOUT_NAME_KEYS = new Set(["names", "sameAs", "neverMerge", "aliases"]);
|
|
496
505
|
/** Every capitalised run of two or more words in a string, regex syntax and escapes aside. */
|
|
497
506
|
function capitalisedRuns(str) {
|
|
@@ -507,7 +516,7 @@ const LITERAL_CODE = /\b(?:[A-Z]{2}[A-Z0-9]{9}\d|[A-Z]{4,}\s[A-Z]{2}|[A-Z]+\d+[A
|
|
|
507
516
|
* a code with digits or an identifier's shape is refused as everywhere.
|
|
508
517
|
*/
|
|
509
518
|
const LITERAL_CODE_ANY_CASE = /\b(?:[A-Z]{2}[A-Z0-9]{9}\d|[A-Z]+\d+[A-Z]+|TL-[A-Z]\d*)\b|(?<![A-Za-z][\s-]?)\b[A-Z]{4,}\s[A-Z]{2}\b(?![\s-]?[A-Za-z])/;
|
|
510
|
-
export function layoutFindings(name, file, fileName = `${name}.yaml
|
|
519
|
+
export function layoutFindings(name, file, fileName = `${name}.yaml`, { columns = null } = {}) {
|
|
511
520
|
const out = [];
|
|
512
521
|
const refuse = (msg) => out.push({ file: fileName, msg, refuses: true });
|
|
513
522
|
if (!isRecord(file)) return [{ file: fileName, msg: `layout ${name}: ${fileName} must be a record`, refuses: true }];
|
|
@@ -543,6 +552,55 @@ export function layoutFindings(name, file, fileName = `${name}.yaml`) {
|
|
|
543
552
|
if ((anyCase ? LITERAL_CODE_ANY_CASE : LITERAL_CODE).test(str.replace(/\[[^\]]*\]|\{[^}]*\}|\\[A-Za-z]/g, " "))) refuse(`layout ${name}: "${str.slice(0, 60)}" at ${path} spells out a code or ticker; a layout names no document (document-map.md, 2026-10-21)`);
|
|
544
553
|
};
|
|
545
554
|
walk(file, "");
|
|
555
|
+
// A TERM FOR SOME CLASSES (`classes`, 2026-10-28): a list group the pattern has, `other`, or a column and the words that mark a
|
|
556
|
+
// class in it; anything else would give the term to no class, or every class, silently.
|
|
557
|
+
const compiles = (re) => { try { new RegExp(re); return true; } catch { return false; } };
|
|
558
|
+
const classesOf = (v, path) => {
|
|
559
|
+
if (Array.isArray(v)) { v.forEach((x, i) => classesOf(x, `${path}[${i}]`)); return; }
|
|
560
|
+
if (!isRecord(v)) return;
|
|
561
|
+
if ("classes" in v && "pattern" in v) {
|
|
562
|
+
const c = v.classes, groups = compiles(v.pattern) ? new RegExp(`${v.pattern}|`).exec("").length - 1 : 0;
|
|
563
|
+
if (typeof c === "number" ? !(Number.isInteger(c) && c >= 1 && c <= groups && c !== (v.group ?? 1)) : c === "other" ? false : !(isRecord(c) && typeof c.column === "string" && typeof c.is === "string" && compiles(c.column) && compiles(c.is)))
|
|
564
|
+
refuse(`layout ${name}: classes at ${path} must be a group of the pattern holding the list (not the value's group), "other", or { column, is } as regular expressions`);
|
|
565
|
+
}
|
|
566
|
+
for (const [k, x] of Object.entries(v)) if (k !== "map") classesOf(x, path ? `${path}.${k}` : k);
|
|
567
|
+
};
|
|
568
|
+
classesOf(file, "");
|
|
569
|
+
out.push(...codeMapFindings(name, file.codes, fileName, columns));
|
|
570
|
+
return out;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* A TYPE'S CODE MAP (layout `codes`, layout.schema.json; owner 2026-10-26): a fixed template read by its printed cell
|
|
575
|
+
* codes. Its patterns must compile (a bad one would stop every read of the type: refused). Each rule names a code or a tag
|
|
576
|
+
* (a rule naming neither speaks for every cell), and a rule that skips gives no measure. With the org's metric dataset
|
|
577
|
+
* (`columns`, its dataset.yaml), every measure, unit, side, adjustment, dimension and period a rule gives is one the
|
|
578
|
+
* dataset declares: a word it does not know would file figures under nothing. Structure only: the map names no document.
|
|
579
|
+
*/
|
|
580
|
+
export function codeMapFindings(name, codes, fileName = `${name}.yaml`, columns = null) {
|
|
581
|
+
const out = [];
|
|
582
|
+
if (codes == null) return out;
|
|
583
|
+
const at = (i) => `layout ${name}: codes.rules[${i}]`;
|
|
584
|
+
if (!isRecord(codes) || typeof codes.column !== "string" || !Array.isArray(codes.rules)) return [{ file: fileName, msg: `layout ${name}: codes needs a column (the header of the code column) and rules`, refuses: true }];
|
|
585
|
+
const compiles = (re) => { try { new RegExp(re); return true; } catch { return false; } };
|
|
586
|
+
for (const [k, re] of [["column", codes.column], ["pattern", codes.pattern]]) if (re != null && !compiles(re)) out.push({ file: fileName, msg: `layout ${name}: codes.${k} "${re}" is no regular expression`, refuses: true });
|
|
587
|
+
const declared = new Map();
|
|
588
|
+
for (const c of Array.isArray(columns) ? columns : []) {
|
|
589
|
+
if (!isRecord(c) || typeof c.name !== "string") continue;
|
|
590
|
+
const words = new Set([...(Array.isArray(c.enum) ? c.enum : []), ...(isRecord(c.values) ? Object.keys(c.values) : [])].map(String));
|
|
591
|
+
if (words.size) declared.set(c.name, words);
|
|
592
|
+
}
|
|
593
|
+
codes.rules.forEach((r, i) => {
|
|
594
|
+
if (!isRecord(r)) { out.push({ file: fileName, msg: `${at(i)} must be a record` }); return; }
|
|
595
|
+
if (r.code == null && r.tag == null) out.push({ file: fileName, msg: `${at(i)} names no code and no tag, so it speaks for every cell; give the code or the tag it is for` });
|
|
596
|
+
for (const p of [].concat(r.code ?? [])) if (typeof p === "string" && p.startsWith("^") && !compiles(p)) out.push({ file: fileName, msg: `${at(i)}: code "${p}" is no regular expression`, refuses: true });
|
|
597
|
+
if (r.skip != null && r.measure != null) out.push({ file: fileName, msg: `${at(i)} both skips and gives a measure; a skipped cell is no metric` });
|
|
598
|
+
for (const key of ["measure", "unit", "side", "adjustment", "dimension", "period"]) {
|
|
599
|
+
const v = r[key];
|
|
600
|
+
if (v == null || !declared.has(key)) continue;
|
|
601
|
+
if (!declared.get(key).has(String(v))) out.push({ file: fileName, msg: `${at(i)}: ${key} "${v}" is not one the org's dataset declares (dataset.yaml ${key}); a code's figures are filed in the dataset's own words` });
|
|
602
|
+
}
|
|
603
|
+
});
|
|
546
604
|
return out;
|
|
547
605
|
}
|
|
548
606
|
|
package/lib/login.mjs
DELETED
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* unoverse login — the Stripe-shaped browser handshake.
|
|
3
|
-
*
|
|
4
|
-
* A UNIVERSE NAMES ITS OWN IDENTITY PROVIDER. Nothing here hardcodes an issuer or a
|
|
5
|
-
* vendor: the CLI asks the universe at /.well-known/unoverse-universe, then asks that
|
|
6
|
-
* issuer's own /.well-known/openid-configuration for its endpoints. Auth0, Cognito,
|
|
7
|
-
* Okta, Entra and Keycloak all answer the second document, which is why the flow is
|
|
8
|
-
* Authorization Code + PKCE with a loopback redirect and NOT the device flow (Cognito
|
|
9
|
-
* has no device flow; every OIDC provider has this).
|
|
10
|
-
*
|
|
11
|
-
* THE CALLBACK PORT IS FIXED (4109) because IdPs match redirect URIs exactly — an
|
|
12
|
-
* ephemeral port could never be registered. 4109 continues the platform's sequence
|
|
13
|
-
* (4105 public listener, 4106 runtime, 4107 unoverse-runtime, 4108 Studio) and is held
|
|
14
|
-
* only for the seconds the browser takes. ground.sh registers it as an allowed callback.
|
|
15
|
-
*
|
|
16
|
-
* This is the ONLY human authentication on the platform (LOCAL_STUDIO.md §Publish is
|
|
17
|
-
* terminal-only). Keys are for CI; humans get a browser and their normal account.
|
|
18
|
-
*/
|
|
19
|
-
import { createServer } from "node:http";
|
|
20
|
-
import { createHash, randomBytes } from "node:crypto";
|
|
21
|
-
import { spawn } from "node:child_process";
|
|
22
|
-
import { getSession, saveSession, freshToken } from "./session.mjs";
|
|
23
|
-
|
|
24
|
-
export const DISCOVERY_PATH = "/.well-known/unoverse-universe";
|
|
25
|
-
export const CALLBACK_PORT = 4109;
|
|
26
|
-
const CALLBACK_URL = `http://127.0.0.1:${CALLBACK_PORT}/callback`;
|
|
27
|
-
const LOGIN_TIMEOUT_MS = 300_000;
|
|
28
|
-
|
|
29
|
-
/** What a developer typed → an origin. Mirrors studio's universes.ts. */
|
|
30
|
-
export function normaliseUrl(input) {
|
|
31
|
-
const trimmed = (input ?? "").trim();
|
|
32
|
-
if (!trimmed) throw new Error("Enter a universe address");
|
|
33
|
-
const isLocal = /^(https?:\/\/)?(localhost|127\.0\.0\.1)(:|\/|$)/i.test(trimmed);
|
|
34
|
-
const withScheme = /^https?:\/\//i.test(trimmed) ? trimmed : `${isLocal ? "http" : "https"}://${trimmed}`;
|
|
35
|
-
let parsed;
|
|
36
|
-
try {
|
|
37
|
-
parsed = new URL(withScheme);
|
|
38
|
-
} catch {
|
|
39
|
-
throw new Error(`"${input}" is not a valid address`);
|
|
40
|
-
}
|
|
41
|
-
return parsed.origin;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Ask a universe how to log in. Failure is the common case (wrong address, universe
|
|
46
|
-
* down, a plain website), and each gets a message a developer can act on.
|
|
47
|
-
*/
|
|
48
|
-
export async function discover(origin) {
|
|
49
|
-
let response;
|
|
50
|
-
try {
|
|
51
|
-
response = await fetch(`${origin}${DISCOVERY_PATH}`, { headers: { accept: "application/json" } });
|
|
52
|
-
} catch {
|
|
53
|
-
throw new Error(`Could not reach ${origin}. Check the address, and that the universe is running.`);
|
|
54
|
-
}
|
|
55
|
-
if (response.status === 404) throw new Error(`Something answered at ${origin}, but it is not a universe.`);
|
|
56
|
-
if (!response.ok) throw new Error(`${origin} answered with an error (${response.status}).`);
|
|
57
|
-
let body;
|
|
58
|
-
try {
|
|
59
|
-
body = await response.json();
|
|
60
|
-
} catch {
|
|
61
|
-
throw new Error(`${origin} answered, but not like a universe. If it is one, it may need restarting.`);
|
|
62
|
-
}
|
|
63
|
-
if (typeof body?.authEnabled !== "boolean") {
|
|
64
|
-
throw new Error(`${origin} answered, but not like a universe. If it is one, it may need restarting.`);
|
|
65
|
-
}
|
|
66
|
-
return {
|
|
67
|
-
authEnabled: body.authEnabled,
|
|
68
|
-
issuer: body.issuer ?? null,
|
|
69
|
-
clientId: body.clientId ?? null,
|
|
70
|
-
audience: body.audience ?? null,
|
|
71
|
-
publishPermission: body.publishPermission ?? "marketplace:publish",
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/** The issuer's own endpoint document. Standard OIDC; both Auth0 and Cognito serve it. */
|
|
76
|
-
export async function oidcEndpoints(issuer) {
|
|
77
|
-
const base = issuer.replace(/\/+$/, "");
|
|
78
|
-
let response;
|
|
79
|
-
try {
|
|
80
|
-
response = await fetch(`${base}/.well-known/openid-configuration`, { headers: { accept: "application/json" } });
|
|
81
|
-
} catch {
|
|
82
|
-
throw new Error(`Could not reach the identity provider at ${issuer}.`);
|
|
83
|
-
}
|
|
84
|
-
if (!response.ok) throw new Error(`The identity provider at ${issuer} answered with an error (${response.status}).`);
|
|
85
|
-
const doc = await response.json();
|
|
86
|
-
if (!doc?.authorization_endpoint || !doc?.token_endpoint) {
|
|
87
|
-
throw new Error(`${issuer} does not serve a usable OpenID configuration.`);
|
|
88
|
-
}
|
|
89
|
-
return doc;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const b64url = (buf) => buf.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
93
|
-
|
|
94
|
-
/** Best effort; the URL is always printed so a developer can click it themselves. */
|
|
95
|
-
function openBrowser(url) {
|
|
96
|
-
const [cmd, args] =
|
|
97
|
-
process.platform === "darwin" ? ["open", [url]]
|
|
98
|
-
: process.platform === "win32" ? ["cmd", ["/c", "start", "", url.replace(/&/g, "^&")]]
|
|
99
|
-
: ["xdg-open", [url]];
|
|
100
|
-
try {
|
|
101
|
-
spawn(cmd, args, { stdio: "ignore", detached: true }).unref();
|
|
102
|
-
} catch {
|
|
103
|
-
/* the printed URL is the fallback */
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/** The email inside an id_token, display-only. No verification: nothing trusts it. */
|
|
108
|
-
function emailFrom(idToken) {
|
|
109
|
-
try {
|
|
110
|
-
return JSON.parse(Buffer.from(idToken.split(".")[1], "base64url").toString())?.email ?? null;
|
|
111
|
-
} catch {
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/** One loopback round trip: resolves {code} once the browser lands on /callback. */
|
|
117
|
-
function waitForCallback(state) {
|
|
118
|
-
return new Promise((resolvePromise, rejectPromise) => {
|
|
119
|
-
const server = createServer((req, res) => {
|
|
120
|
-
const url = new URL(req.url, `http://127.0.0.1:${CALLBACK_PORT}`);
|
|
121
|
-
if (url.pathname !== "/callback") {
|
|
122
|
-
res.writeHead(404).end();
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
const finish = (title, body) => {
|
|
126
|
-
res.writeHead(200, { "content-type": "text/html; charset=utf-8" });
|
|
127
|
-
res.end(`<!doctype html><meta charset="utf-8"><title>${title}</title><body style="font-family:system-ui;display:grid;place-items:center;height:100vh;margin:0"><div style="text-align:center"><h1>${title}</h1><p>${body}</p></div>`);
|
|
128
|
-
};
|
|
129
|
-
const err = url.searchParams.get("error");
|
|
130
|
-
if (err) {
|
|
131
|
-
finish("Sign-in failed", url.searchParams.get("error_description") ?? err);
|
|
132
|
-
cleanup();
|
|
133
|
-
rejectPromise(new Error(`The identity provider refused: ${url.searchParams.get("error_description") ?? err}`));
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
if (url.searchParams.get("state") !== state) {
|
|
137
|
-
finish("Sign-in failed", "State mismatch. Close this tab and run the command again.");
|
|
138
|
-
cleanup();
|
|
139
|
-
rejectPromise(new Error("Login state mismatch — the response did not come from this login attempt."));
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
finish("You're signed in", "Return to the terminal.");
|
|
143
|
-
cleanup();
|
|
144
|
-
resolvePromise({ code: url.searchParams.get("code") });
|
|
145
|
-
});
|
|
146
|
-
const timer = setTimeout(() => {
|
|
147
|
-
cleanup();
|
|
148
|
-
rejectPromise(new Error("Login timed out after 5 minutes. Run the command again."));
|
|
149
|
-
}, LOGIN_TIMEOUT_MS);
|
|
150
|
-
function cleanup() {
|
|
151
|
-
clearTimeout(timer);
|
|
152
|
-
server.close();
|
|
153
|
-
}
|
|
154
|
-
server.on("error", (e) => {
|
|
155
|
-
cleanup();
|
|
156
|
-
rejectPromise(
|
|
157
|
-
e.code === "EADDRINUSE"
|
|
158
|
-
? new Error(`Port ${CALLBACK_PORT} is in use (another login in progress?). Free it and retry.`)
|
|
159
|
-
: e,
|
|
160
|
-
);
|
|
161
|
-
});
|
|
162
|
-
server.listen(CALLBACK_PORT, "127.0.0.1");
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Interactive login to one universe. Returns { origin, accessToken, email }.
|
|
168
|
-
* The session is stored for next time; publish calls this only when no session is live.
|
|
169
|
-
*/
|
|
170
|
-
export async function login(universeInput, { log = console.log } = {}) {
|
|
171
|
-
const origin = normaliseUrl(universeInput);
|
|
172
|
-
const config = await discover(origin);
|
|
173
|
-
|
|
174
|
-
if (!config.authEnabled) {
|
|
175
|
-
throw new Error(
|
|
176
|
-
`${origin} has authentication switched off, so there is no account to sign in with.\n` +
|
|
177
|
-
` To deploy there, set UNOVERSE_TOKEN to a publish key minted on the universe itself.`,
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
if (!config.issuer) throw new Error(`${origin} has no identity provider configured.`);
|
|
181
|
-
if (!config.clientId) throw new Error(`${origin} has no client id configured for sign-in.`);
|
|
182
|
-
|
|
183
|
-
const endpoints = await oidcEndpoints(config.issuer);
|
|
184
|
-
|
|
185
|
-
const verifier = b64url(randomBytes(32));
|
|
186
|
-
const challenge = b64url(createHash("sha256").update(verifier).digest());
|
|
187
|
-
const state = b64url(randomBytes(16));
|
|
188
|
-
|
|
189
|
-
// offline_access only where the IdP declares it (Auth0 needs it for a refresh token;
|
|
190
|
-
// Cognito does not know the scope and refuses requests that name it).
|
|
191
|
-
const scopes = ["openid", "profile", "email"];
|
|
192
|
-
if ((endpoints.scopes_supported ?? []).includes("offline_access")) scopes.push("offline_access");
|
|
193
|
-
|
|
194
|
-
const authUrl = new URL(endpoints.authorization_endpoint);
|
|
195
|
-
authUrl.search = new URLSearchParams({
|
|
196
|
-
response_type: "code",
|
|
197
|
-
client_id: config.clientId,
|
|
198
|
-
redirect_uri: CALLBACK_URL,
|
|
199
|
-
scope: scopes.join(" "),
|
|
200
|
-
state,
|
|
201
|
-
code_challenge: challenge,
|
|
202
|
-
code_challenge_method: "S256",
|
|
203
|
-
...(config.audience ? { audience: config.audience } : {}),
|
|
204
|
-
}).toString();
|
|
205
|
-
|
|
206
|
-
const pending = waitForCallback(state);
|
|
207
|
-
log(`\n Opening your browser to sign in to ${origin}`);
|
|
208
|
-
log(` If it does not open: ${authUrl.href}\n`);
|
|
209
|
-
openBrowser(authUrl.href);
|
|
210
|
-
|
|
211
|
-
const { code } = await pending;
|
|
212
|
-
|
|
213
|
-
const exchange = await fetch(endpoints.token_endpoint, {
|
|
214
|
-
method: "POST",
|
|
215
|
-
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
216
|
-
body: new URLSearchParams({
|
|
217
|
-
grant_type: "authorization_code",
|
|
218
|
-
client_id: config.clientId,
|
|
219
|
-
code,
|
|
220
|
-
redirect_uri: CALLBACK_URL,
|
|
221
|
-
code_verifier: verifier,
|
|
222
|
-
}),
|
|
223
|
-
});
|
|
224
|
-
if (!exchange.ok) {
|
|
225
|
-
throw new Error(`The identity provider refused the code exchange (${exchange.status}): ${await exchange.text()}`);
|
|
226
|
-
}
|
|
227
|
-
const tokens = await exchange.json();
|
|
228
|
-
const email = tokens.id_token ? emailFrom(tokens.id_token) : null;
|
|
229
|
-
|
|
230
|
-
saveSession(origin, {
|
|
231
|
-
access_token: tokens.access_token,
|
|
232
|
-
refresh_token: tokens.refresh_token,
|
|
233
|
-
expires_at: tokens.expires_in ? Date.now() + tokens.expires_in * 1000 : undefined,
|
|
234
|
-
email,
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
log(` ✓ Signed in${email ? ` as ${email}` : ""}\n`);
|
|
238
|
-
return { origin, accessToken: tokens.access_token, email };
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* A token for this universe, however it can be had, in the ruled order:
|
|
243
|
-
* UNOVERSE_TOKEN (CI) → live session (refreshing) → interactive login (TTY only).
|
|
244
|
-
*/
|
|
245
|
-
export async function tokenFor(origin, { interactive = true, log = console.log } = {}) {
|
|
246
|
-
if (process.env.UNOVERSE_TOKEN) return process.env.UNOVERSE_TOKEN;
|
|
247
|
-
|
|
248
|
-
const config = await discover(origin);
|
|
249
|
-
if (config.authEnabled && config.issuer && config.clientId) {
|
|
250
|
-
try {
|
|
251
|
-
const endpoints = await oidcEndpoints(config.issuer);
|
|
252
|
-
const live = await freshToken(origin, { tokenEndpoint: endpoints.token_endpoint, clientId: config.clientId });
|
|
253
|
-
if (live) return live;
|
|
254
|
-
} catch {
|
|
255
|
-
/* IdP unreachable: fall through to the interactive path, which explains itself */
|
|
256
|
-
}
|
|
257
|
-
} else if (!config.authEnabled) {
|
|
258
|
-
throw new Error(
|
|
259
|
-
`${origin} has authentication switched off.\n` +
|
|
260
|
-
` To deploy there, set UNOVERSE_TOKEN to a publish key minted on the universe itself.`,
|
|
261
|
-
);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
if (!interactive || !process.stdin.isTTY) {
|
|
265
|
-
throw new Error(
|
|
266
|
-
`No credential for ${origin}. In CI, set UNOVERSE_TOKEN to a publish key.\n` +
|
|
267
|
-
` At a terminal, run: unoverse login ${origin}`,
|
|
268
|
-
);
|
|
269
|
-
}
|
|
270
|
-
const { accessToken } = await login(origin, { log });
|
|
271
|
-
return accessToken;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
export { getSession };
|
package/lib/session.mjs
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Per-machine sessions: ~/.unoverse/sessions.json, keyed by universe origin.
|
|
3
|
-
*
|
|
4
|
-
* THE REPO SAYS WHERE, THE MACHINE PROVES WHO. unoverse.yaml (committed) names the
|
|
5
|
-
* universe; this file (0600, home directory, never inside a project) holds the tokens
|
|
6
|
-
* that prove the developer to it. Same split as .git/config vs ~/.ssh. Nothing under a
|
|
7
|
-
* project folder ever holds a credential, so nothing can be committed or swept into a
|
|
8
|
-
* deploy by accident.
|
|
9
|
-
*
|
|
10
|
-
* A session is whatever the token endpoint returned: access_token, refresh_token when
|
|
11
|
-
* the IdP granted one, expiry, and the email shown in prompts. Refresh happens here so
|
|
12
|
-
* callers only ever ask one question: "a token for this universe, or null".
|
|
13
|
-
*/
|
|
14
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync, chmodSync } from "node:fs";
|
|
15
|
-
import { homedir } from "node:os";
|
|
16
|
-
import { join } from "node:path";
|
|
17
|
-
|
|
18
|
-
const DIR = join(homedir(), ".unoverse");
|
|
19
|
-
const FILE = join(DIR, "sessions.json");
|
|
20
|
-
|
|
21
|
-
function load() {
|
|
22
|
-
if (!existsSync(FILE)) return {};
|
|
23
|
-
try {
|
|
24
|
-
const parsed = JSON.parse(readFileSync(FILE, "utf8"));
|
|
25
|
-
return parsed && typeof parsed === "object" ? parsed : {};
|
|
26
|
-
} catch {
|
|
27
|
-
return {}; // corrupt store: re-login beats a crash
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function save(all) {
|
|
32
|
-
mkdirSync(DIR, { recursive: true, mode: 0o700 });
|
|
33
|
-
writeFileSync(FILE, JSON.stringify(all, null, 2), { mode: 0o600 });
|
|
34
|
-
chmodSync(FILE, 0o600); // writeFileSync mode is ignored when the file already exists
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function getSession(origin) {
|
|
38
|
-
return load()[origin] ?? null;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** Every universe origin this machine holds a session for. */
|
|
42
|
-
export function sessionOrigins() {
|
|
43
|
-
return Object.keys(load());
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function saveSession(origin, session) {
|
|
47
|
-
const all = load();
|
|
48
|
-
all[origin] = session;
|
|
49
|
-
save(all);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function clearSession(origin) {
|
|
53
|
-
const all = load();
|
|
54
|
-
delete all[origin];
|
|
55
|
-
save(all);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** Seconds of slack so a token never expires mid-publish. */
|
|
59
|
-
const EXPIRY_SLACK_MS = 60_000;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* A live access token for this universe, refreshing if the IdP granted a refresh token,
|
|
63
|
-
* or null when the developer has to log in again. `tokenEndpoint`/`clientId` come from
|
|
64
|
-
* the universe's own discovery (login.mjs) — nothing is hardcoded.
|
|
65
|
-
*/
|
|
66
|
-
export async function freshToken(origin, { tokenEndpoint, clientId } = {}) {
|
|
67
|
-
const session = getSession(origin);
|
|
68
|
-
if (!session?.access_token) return null;
|
|
69
|
-
if (session.expires_at && Date.now() < session.expires_at - EXPIRY_SLACK_MS) {
|
|
70
|
-
return session.access_token;
|
|
71
|
-
}
|
|
72
|
-
if (!session.refresh_token || !tokenEndpoint || !clientId) return null;
|
|
73
|
-
|
|
74
|
-
let response;
|
|
75
|
-
try {
|
|
76
|
-
response = await fetch(tokenEndpoint, {
|
|
77
|
-
method: "POST",
|
|
78
|
-
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
79
|
-
body: new URLSearchParams({
|
|
80
|
-
grant_type: "refresh_token",
|
|
81
|
-
client_id: clientId,
|
|
82
|
-
refresh_token: session.refresh_token,
|
|
83
|
-
}),
|
|
84
|
-
});
|
|
85
|
-
} catch {
|
|
86
|
-
return null; // offline: treat as expired, the caller decides what to say
|
|
87
|
-
}
|
|
88
|
-
if (!response.ok) {
|
|
89
|
-
clearSession(origin); // a refused refresh token is dead; keeping it re-fails forever
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
const body = await response.json();
|
|
93
|
-
saveSession(origin, {
|
|
94
|
-
...session,
|
|
95
|
-
access_token: body.access_token,
|
|
96
|
-
refresh_token: body.refresh_token ?? session.refresh_token,
|
|
97
|
-
expires_at: body.expires_in ? Date.now() + body.expires_in * 1000 : session.expires_at,
|
|
98
|
-
});
|
|
99
|
-
return body.access_token;
|
|
100
|
-
}
|