primitive-admin 1.2.0-alpha.7 → 1.2.0-alpha.9
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 +8 -2
- package/assets/skill/skills/primitive-platform/SKILL.md +22 -8
- package/dist/src/commands/apps-children.d.ts +1 -1
- package/dist/src/commands/apps-children.js +55 -145
- package/dist/src/commands/apps-children.js.map +1 -1
- package/dist/src/commands/auth.js +107 -33
- package/dist/src/commands/auth.js.map +1 -1
- package/dist/src/commands/database-types.js +13 -313
- package/dist/src/commands/database-types.js.map +1 -1
- package/dist/src/commands/databases.js +13 -1
- package/dist/src/commands/databases.js.map +1 -1
- package/dist/src/commands/documents.js +70 -11
- package/dist/src/commands/documents.js.map +1 -1
- package/dist/src/commands/llm.js +9 -6
- package/dist/src/commands/llm.js.map +1 -1
- package/dist/src/commands/settings.d.ts +12 -9
- package/dist/src/commands/settings.js +31 -79
- package/dist/src/commands/settings.js.map +1 -1
- package/dist/src/commands/sync-app-settings.d.ts +12 -2
- package/dist/src/commands/sync-app-settings.js +35 -10
- package/dist/src/commands/sync-app-settings.js.map +1 -1
- package/dist/src/commands/sync.d.ts +1 -8
- package/dist/src/commands/sync.js +47 -45
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/lib/api-client.d.ts +46 -6
- package/dist/src/lib/api-client.js +156 -64
- package/dist/src/lib/api-client.js.map +1 -1
- package/dist/src/lib/app-settings-descriptor.d.ts +38 -0
- package/dist/src/lib/app-settings-descriptor.js +96 -4
- package/dist/src/lib/app-settings-descriptor.js.map +1 -1
- package/dist/src/lib/child-apps-local.d.ts +0 -46
- package/dist/src/lib/child-apps-local.js +2 -72
- package/dist/src/lib/child-apps-local.js.map +1 -1
- package/dist/src/lib/credentials-home.d.ts +51 -0
- package/dist/src/lib/credentials-home.js +169 -0
- package/dist/src/lib/credentials-home.js.map +1 -0
- package/dist/src/lib/credentials-lock.d.ts +80 -0
- package/dist/src/lib/credentials-lock.js +222 -0
- package/dist/src/lib/credentials-lock.js.map +1 -0
- package/dist/src/lib/credentials-store.d.ts +56 -4
- package/dist/src/lib/credentials-store.js +236 -78
- package/dist/src/lib/credentials-store.js.map +1 -1
- package/dist/src/lib/env-resolver-core.d.ts +1 -1
- package/dist/src/lib/env-resolver-core.js.map +1 -1
- package/dist/src/lib/function-bundle.d.ts +38 -18
- package/dist/src/lib/function-bundle.js +60 -35
- package/dist/src/lib/function-bundle.js.map +1 -1
- package/dist/src/lib/function-document-types.d.ts +5 -3
- package/dist/src/lib/function-document-types.js +10 -14
- package/dist/src/lib/function-document-types.js.map +1 -1
- package/dist/src/lib/function-source-roots.d.ts +67 -0
- package/dist/src/lib/function-source-roots.js +148 -0
- package/dist/src/lib/function-source-roots.js.map +1 -0
- package/dist/src/lib/function-sync.d.ts +27 -0
- package/dist/src/lib/function-sync.js +16 -3
- package/dist/src/lib/function-sync.js.map +1 -1
- package/dist/src/lib/function-triggers.d.ts +15 -3
- package/dist/src/lib/function-triggers.js +72 -10
- package/dist/src/lib/function-triggers.js.map +1 -1
- package/dist/src/lib/function-typecheck.d.ts +37 -2
- package/dist/src/lib/function-typecheck.js +210 -28
- package/dist/src/lib/function-typecheck.js.map +1 -1
- package/dist/src/lib/generated-config-surfaces.d.ts +48 -11
- package/dist/src/lib/generated-config-surfaces.js +178 -49
- package/dist/src/lib/generated-config-surfaces.js.map +1 -1
- package/dist/src/lib/generated-sdk-types.d.ts +1 -1
- package/dist/src/lib/generated-sdk-types.js +1 -1
- package/dist/src/lib/generated-sdk-types.js.map +1 -1
- package/dist/src/lib/generated-workflow-model-fields.d.ts +20 -0
- package/dist/src/lib/generated-workflow-model-fields.js +53 -0
- package/dist/src/lib/generated-workflow-model-fields.js.map +1 -0
- package/dist/src/lib/login-scope-lines.d.ts +1 -1
- package/dist/src/lib/login-scope-lines.js +1 -1
- package/dist/src/lib/login-scope-lines.js.map +1 -1
- package/dist/src/lib/project-config.d.ts +7 -0
- package/dist/src/lib/project-config.js +22 -1
- package/dist/src/lib/project-config.js.map +1 -1
- package/dist/src/lib/prompt-schema-codegen.d.ts +10 -3
- package/dist/src/lib/prompt-schema-codegen.js +52 -14
- package/dist/src/lib/prompt-schema-codegen.js.map +1 -1
- package/dist/src/lib/root-import-decision.d.ts +9 -4
- package/dist/src/lib/root-import-decision.js +24 -3
- package/dist/src/lib/root-import-decision.js.map +1 -1
- package/dist/src/lib/scope-request.d.ts +8 -5
- package/dist/src/lib/scope-request.js +17 -8
- package/dist/src/lib/scope-request.js.map +1 -1
- package/dist/src/lib/swift-codegen/agentGenerator.d.ts +6 -2
- package/dist/src/lib/swift-codegen/agentGenerator.js +56 -4
- package/dist/src/lib/swift-codegen/agentGenerator.js.map +1 -1
- package/dist/src/lib/workflow-field-descriptor.d.ts +91 -0
- package/dist/src/lib/workflow-field-descriptor.js +153 -0
- package/dist/src/lib/workflow-field-descriptor.js.map +1 -0
- package/package.json +2 -2
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
* The scoped-login request `primitive login --scope …` and
|
|
3
3
|
* `primitive token --scope …` send to `GET /admin/api/oauth-cli` (#3889).
|
|
4
4
|
*
|
|
5
|
-
* One builder serves both commands, so they agree on every rule:
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* One builder serves both commands, so they agree on every rule: `--step-up`
|
|
6
|
+
* asks for a step-up holding exactly `--scope` (#4564), and a list holding
|
|
7
|
+
* `admin` is one with or without the flag; a step-up names the current
|
|
8
|
+
* session as its parent and is pinned to the environment's app unless
|
|
9
|
+
* `--app` says otherwise (`--app none` asks for an unpinned one); a printed
|
|
10
|
+
* token carries its lifetime. `primitive auth sessions create` builds its CI-session request
|
|
10
11
|
* here too (#3890). Every mistake is a usage error before any browser opens.
|
|
11
12
|
*
|
|
12
13
|
* Pure: the flags, the environment's app id and the stored session's id are
|
|
@@ -54,6 +55,9 @@ export function buildScopeRequest(input) {
|
|
|
54
55
|
const { command } = input;
|
|
55
56
|
if (command === "sessions")
|
|
56
57
|
return buildCiSessionRequest(input);
|
|
58
|
+
if (input.stepUp && input.scope === undefined) {
|
|
59
|
+
return usage(`--step-up needs the scopes the command needs: primitive ${command} --step-up --scope <list> [--app <ids>]`);
|
|
60
|
+
}
|
|
57
61
|
if (input.scope === undefined) {
|
|
58
62
|
if (input.app !== undefined)
|
|
59
63
|
return usage(`--app needs --scope: primitive ${command} --scope <list> --app <ids>`);
|
|
@@ -75,9 +79,9 @@ export function buildScopeRequest(input) {
|
|
|
75
79
|
if (unknown.length > 0) {
|
|
76
80
|
return usage(`Unknown scope ${unknown.join(", ")}. Scopes are ${ADMIN_SCOPES.join(", ")}.`);
|
|
77
81
|
}
|
|
78
|
-
const stepUp = scopes.includes("admin");
|
|
82
|
+
const stepUp = input.stepUp === true || scopes.includes("admin");
|
|
79
83
|
if (stepUp && !input.parentSid) {
|
|
80
|
-
return usage("
|
|
84
|
+
return usage("A step-up builds on your current login. Run `primitive login` first.");
|
|
81
85
|
}
|
|
82
86
|
let apps;
|
|
83
87
|
if (input.app === "none")
|
|
@@ -92,7 +96,12 @@ export function buildScopeRequest(input) {
|
|
|
92
96
|
}
|
|
93
97
|
else
|
|
94
98
|
apps = stepUp && input.envAppId ? [input.envAppId] : [];
|
|
95
|
-
|
|
99
|
+
// An explicit step-up says so; one holding `admin` is inferred by the
|
|
100
|
+
// server, as it is from older CLIs.
|
|
101
|
+
const query = {
|
|
102
|
+
...(input.stepUp ? { kind: "step-up" } : {}),
|
|
103
|
+
scope: scopes.join(","),
|
|
104
|
+
};
|
|
96
105
|
if (apps.length > 0)
|
|
97
106
|
query.apps = apps.join(",");
|
|
98
107
|
if (stepUp)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope-request.js","sourceRoot":"","sources":["../../../src/lib/scope-request.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"scope-request.js","sourceRoot":"","sources":["../../../src/lib/scope-request.ts"],"names":[],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,CAAC;QAC9B,OAAO,KAAK,CACV,0FAA0F,CAC3F,CAAC;IACJ,CAAC;IAED,OAAO;QACL,EAAE,EAAE,IAAI;QACR,MAAM,EAAE,KAAK;QACb,KAAK,EAAE;YACL,IAAI,EAAE,IAAI;YACV,IAAI;YACJ,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;YACvB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;YACpB,MAAM,EAAE,UAAU;YAClB,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC;SACrB;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -8,9 +8,13 @@
|
|
|
8
8
|
* - `<Key>Tool<Name>Input` / `<Key>Tool<Name>Output` for every CLIENT tool
|
|
9
9
|
* (a server tool's schemas are its function's, typed in that function's
|
|
10
10
|
* own file);
|
|
11
|
-
* - `<Key>
|
|
11
|
+
* - `<Key>Presentation<Name>` for every presentation (`runs =
|
|
12
|
+
* "presentation"`, #4549), from its `inputSchema`;
|
|
13
|
+
* - `<Key>Event<Name>` for every event kind;
|
|
14
|
+
* - `<Key>AgentPresentation`, an enum with one case per presentation that
|
|
15
|
+
* decodes the client's `AgentPresentation` by name; and
|
|
12
16
|
* - `<Key>Agent`, a namespace enum with the key a session is created with
|
|
13
|
-
* and the declared client-tool and event names.
|
|
17
|
+
* and the declared client-tool, presentation and event names.
|
|
14
18
|
*
|
|
15
19
|
* ── Nothing about the agent is re-derived here ───────────────────────────
|
|
16
20
|
*
|
|
@@ -8,9 +8,13 @@
|
|
|
8
8
|
* - `<Key>Tool<Name>Input` / `<Key>Tool<Name>Output` for every CLIENT tool
|
|
9
9
|
* (a server tool's schemas are its function's, typed in that function's
|
|
10
10
|
* own file);
|
|
11
|
-
* - `<Key>
|
|
11
|
+
* - `<Key>Presentation<Name>` for every presentation (`runs =
|
|
12
|
+
* "presentation"`, #4549), from its `inputSchema`;
|
|
13
|
+
* - `<Key>Event<Name>` for every event kind;
|
|
14
|
+
* - `<Key>AgentPresentation`, an enum with one case per presentation that
|
|
15
|
+
* decodes the client's `AgentPresentation` by name; and
|
|
12
16
|
* - `<Key>Agent`, a namespace enum with the key a session is created with
|
|
13
|
-
* and the declared client-tool and event names.
|
|
17
|
+
* and the declared client-tool, presentation and event names.
|
|
14
18
|
*
|
|
15
19
|
* ── Nothing about the agent is re-derived here ───────────────────────────
|
|
16
20
|
*
|
|
@@ -29,6 +33,7 @@ import { fingerprintToml } from "../db-codegen/dbFingerprint.js";
|
|
|
29
33
|
import { describePromptSchema, } from "../prompt-schema-codegen.js";
|
|
30
34
|
import { renderSwiftRootType, SwiftCodegenError } from "./schemaToSwift.js";
|
|
31
35
|
import { swiftKeyLiteral } from "./generator.js";
|
|
36
|
+
import { enumCaseNames } from "./swiftNaming.js";
|
|
32
37
|
import { AGENT_SWIFT_BANNER_PREFIX } from "./banners.js";
|
|
33
38
|
import { parseTopLevelSwiftSymbols } from "./siblingSymbols.js";
|
|
34
39
|
export { AGENT_SWIFT_BANNER_PREFIX };
|
|
@@ -39,6 +44,47 @@ const INDENT = " ";
|
|
|
39
44
|
function nameList(names) {
|
|
40
45
|
return `[${names.map(swiftKeyLiteral).join(", ")}]`;
|
|
41
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* `<Key>AgentPresentation`: one case per presentation carrying its typed
|
|
49
|
+
* input, and `init?(_:)`, which decodes a presentation the session view
|
|
50
|
+
* answers by its name — `nil` for another name or an input that does not
|
|
51
|
+
* decode. An agent with no presentation gets the enum with no case.
|
|
52
|
+
*
|
|
53
|
+
* The decode is a `do`/`catch`, not `try?`: an input schema that admits
|
|
54
|
+
* `null` types the case as an optional, and a decoded `nil` is a presentation
|
|
55
|
+
* the model sent, not a failure (CSO-4549-001).
|
|
56
|
+
*/
|
|
57
|
+
function presentationEnum(typeBaseName, key, presentations) {
|
|
58
|
+
// `_` is a legal agent name and `enumCaseIdentifier` keeps it, but a bare
|
|
59
|
+
// `_` is not a legal case name or member reference (CSO-4549-002).
|
|
60
|
+
const cases = enumCaseNames(presentations.map((presentation) => presentation.name)).map((named, index) => ({
|
|
61
|
+
...named,
|
|
62
|
+
name: named.name === "_" ? "`_`" : named.name,
|
|
63
|
+
typeName: presentations[index].typeName,
|
|
64
|
+
}));
|
|
65
|
+
const lines = [
|
|
66
|
+
`/// A presentation the \`${key}\` agent hands the client with its answer,`,
|
|
67
|
+
`/// typed by name: decode one of \`view.presentations(of:names:)\` with \`init?(_:)\`.`,
|
|
68
|
+
`public enum ${typeBaseName}AgentPresentation: Equatable, Sendable {`,
|
|
69
|
+
];
|
|
70
|
+
for (const { name, typeName } of cases)
|
|
71
|
+
lines.push(`${INDENT}case ${name}(${typeName})`);
|
|
72
|
+
if (cases.length > 0)
|
|
73
|
+
lines.push("");
|
|
74
|
+
lines.push(`${INDENT}/// The presentation's typed input; \`nil\` for a name this agent does not`, `${INDENT}/// declare, or an input its type does not decode.`, `${INDENT}public init?(_ presentation: AgentPresentation) {`);
|
|
75
|
+
if (cases.length === 0) {
|
|
76
|
+
lines.push(`${INDENT}${INDENT}return nil`);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
lines.push(`${INDENT}${INDENT}switch presentation.name {`);
|
|
80
|
+
for (const { name, raw, typeName } of cases) {
|
|
81
|
+
lines.push(`${INDENT}${INDENT}case ${swiftKeyLiteral(raw)}:`, `${INDENT}${INDENT}${INDENT}do { self = .${name}(try presentation.decode(${typeName}.self)) } catch { return nil }`);
|
|
82
|
+
}
|
|
83
|
+
lines.push(`${INDENT}${INDENT}default:`, `${INDENT}${INDENT}${INDENT}return nil`, `${INDENT}${INDENT}}`);
|
|
84
|
+
}
|
|
85
|
+
lines.push(`${INDENT}}`, `}`);
|
|
86
|
+
return lines.join("\n");
|
|
87
|
+
}
|
|
42
88
|
/**
|
|
43
89
|
* Render the full `<key>.agent.generated.swift` content for one agent prompt.
|
|
44
90
|
* Pure — exported so tests can assert on the string directly. Throws a
|
|
@@ -66,6 +112,10 @@ export function renderAgentSwiftFile(source) {
|
|
|
66
112
|
decl: renderSwiftRootType(tool.output.typeName, tool.output.schema, { sourceFile }),
|
|
67
113
|
},
|
|
68
114
|
]),
|
|
115
|
+
...agent.presentations.map((presentation) => ({
|
|
116
|
+
path: `tools.${presentation.name}.inputSchema`,
|
|
117
|
+
decl: renderSwiftRootType(presentation.typeName, presentation.schema, { sourceFile }),
|
|
118
|
+
})),
|
|
69
119
|
...agent.events.map((event) => ({
|
|
70
120
|
path: `events.${event.name}.schema`,
|
|
71
121
|
decl: renderSwiftRootType(event.typeName, event.schema, { sourceFile }),
|
|
@@ -88,12 +138,14 @@ export function renderAgentSwiftFile(source) {
|
|
|
88
138
|
}
|
|
89
139
|
}
|
|
90
140
|
const decls = rendered.map((entry) => entry.decl);
|
|
141
|
+
const presentations = presentationEnum(prompt.typeBaseName, prompt.key, agent.presentations);
|
|
91
142
|
const namespace = [
|
|
92
143
|
`/// The \`${prompt.key}\` agent: the key a session is created with, and the`,
|
|
93
|
-
`/// client tools and event kinds it declares.`,
|
|
144
|
+
`/// client tools, presentations and event kinds it declares.`,
|
|
94
145
|
`public enum ${prompt.typeBaseName}Agent {`,
|
|
95
146
|
`${INDENT}public static let key = ${swiftKeyLiteral(prompt.key)}`,
|
|
96
147
|
`${INDENT}public static let clientToolNames: [String] = ${nameList(agent.clientTools.map((tool) => tool.name))}`,
|
|
148
|
+
`${INDENT}public static let presentationNames: [String] = ${nameList(agent.presentations.map((presentation) => presentation.name))}`,
|
|
97
149
|
`${INDENT}public static let eventNames: [String] = ${nameList(agent.events.map((event) => event.name))}`,
|
|
98
150
|
`}`,
|
|
99
151
|
].join("\n");
|
|
@@ -105,7 +157,7 @@ export function renderAgentSwiftFile(source) {
|
|
|
105
157
|
// `JsBaoClient` for `JSONValue`, which an open schema renders to — the
|
|
106
158
|
// import the function invokers carry too.
|
|
107
159
|
const imports = ["import Foundation", "import JsBaoClient"].join("\n");
|
|
108
|
-
const content = [banner, imports, ...decls, namespace].join("\n\n") + "\n";
|
|
160
|
+
const content = [banner, imports, ...decls, presentations, namespace].join("\n\n") + "\n";
|
|
109
161
|
return {
|
|
110
162
|
key: prompt.key,
|
|
111
163
|
content,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentGenerator.js","sourceRoot":"","sources":["../../../../src/lib/swift-codegen/agentGenerator.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"agentGenerator.js","sourceRoot":"","sources":["../../../../src/lib/swift-codegen/agentGenerator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EACL,oBAAoB,GAErB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,EAAE,yBAAyB,EAAE,CAAC;AAErC,4FAA4F;AAC5F,MAAM,CAAC,MAAM,uBAAuB,GAAG,wBAAwB,CAAC;AAEhE,MAAM,MAAM,GAAG,MAAM,CAAC;AAEtB,yEAAyE;AACzE,SAAS,QAAQ,CAAC,KAAwB;IACxC,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AACtD,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,gBAAgB,CACvB,YAAoB,EACpB,GAAW,EACX,aAAgE;IAEhE,0EAA0E;IAC1E,mEAAmE;IACnE,MAAM,KAAK,GAAG,aAAa,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC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1C,MAAM,OAAO,GAAG,CAAC,mBAAmB,EAAE,oBAAoB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvE,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAC1F,OAAO;QACL,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,OAAO;QACP,kEAAkE;QAClE,oEAAoE;QACpE,2BAA2B;QAC3B,OAAO,EAAE,yBAAyB,CAAC,OAAO,CAAC;KAC5C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Classification of the `WorkflowDefinition` field surface (issue #2326,
|
|
3
|
+
* Phase 1 of #1976).
|
|
4
|
+
*
|
|
5
|
+
* Purpose: give the CLI a mechanical trip-wire for the drift that keeps
|
|
6
|
+
* happening — the server grows a `[workflow]`-level config field (`syncCallable`
|
|
7
|
+
* #807, `accessRule` #571, `runAs` #1081, `capabilities` #1172, `lock` #1518)
|
|
8
|
+
* and the CLI silently drops it on `sync push` / `sync pull`. Every field of the
|
|
9
|
+
* `WorkflowDefinition` model must appear in exactly one of the three groups
|
|
10
|
+
* below. The generated artifact `generated-workflow-model-fields.ts` carries the
|
|
11
|
+
* model's real field list (parsed from `models.yaml` at build time), and
|
|
12
|
+
* `cli/tests/unit/workflow-field-descriptor-drift-guard.test.ts` asserts
|
|
13
|
+
*
|
|
14
|
+
* synced ∪ structural ∪ internal === the model's fields
|
|
15
|
+
*
|
|
16
|
+
* so a new field hard-fails the guard until someone classifies it.
|
|
17
|
+
*
|
|
18
|
+
* ── Scope: declarative classification and coverage ONLY ──────────────────
|
|
19
|
+
* Decision of record (#1976, 2026-07-23): this table records WHICH fields
|
|
20
|
+
* exist, whether each is synced / structural / internal, and its `[workflow]`
|
|
21
|
+
* TOML key. Anything with real BEHAVIOR gets an explicit per-field handler or
|
|
22
|
+
* stays outside the table. In particular this file deliberately does NOT encode
|
|
23
|
+
* as boolean knobs:
|
|
24
|
+
* - the schema fields' native-TOML-table-vs-JSON-string parsing
|
|
25
|
+
* (`buildWorkflowPayloadFromToml` / `safeJsonParse` own that),
|
|
26
|
+
* - `syncCallable`'s deferred second PATCH on update (#807 — `applyWorkflowBody`
|
|
27
|
+
* owns that),
|
|
28
|
+
* - the `metadataManifest` (#1304) and `expr.cel` (#1614) structural side
|
|
29
|
+
* channels, which are attached alongside the steps write and are not
|
|
30
|
+
* `[workflow]`-table keys at all.
|
|
31
|
+
* `cli/src/lib/app-settings-descriptor.ts` is the shape being matched:
|
|
32
|
+
* deliberately narrow.
|
|
33
|
+
*
|
|
34
|
+
* ── What Phase 1 does and does not do ───────────────────────────────────
|
|
35
|
+
* Phase 1 (this file) is the guard only. Making the push builder
|
|
36
|
+
* (`workflow-payload.ts`) and the pull serializer (`serializeWorkflow` in
|
|
37
|
+
* `commands/sync.ts`) *consume* this table is Phase 2 (#2327).
|
|
38
|
+
* `synced` therefore means "belongs in the `[workflow]` TOML table", NOT
|
|
39
|
+
* "already round-trips" — see `SYNCED_NOT_YET_WIRED` below.
|
|
40
|
+
*/
|
|
41
|
+
/** Value shape of a synced `[workflow]` key. Descriptive; behavior lives in the handlers. */
|
|
42
|
+
export type WorkflowFieldType = "string" | "number" | "boolean" | "string[]" | "json";
|
|
43
|
+
export interface WorkflowFieldDescriptor {
|
|
44
|
+
/** `WorkflowDefinition` model field name === the server payload key. */
|
|
45
|
+
field: string;
|
|
46
|
+
/** Key under the `[workflow]` table in workflow TOML (usually === `field`). */
|
|
47
|
+
tomlKey: string;
|
|
48
|
+
/** Value shape, for the Phase 2 handlers and for documentation. */
|
|
49
|
+
type: WorkflowFieldType;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The author-facing `[workflow]`-table config fields — the ones a workflow
|
|
53
|
+
* author manages as code and the CLI must round-trip.
|
|
54
|
+
*/
|
|
55
|
+
export declare const WORKFLOW_FIELD_DESCRIPTOR: readonly WorkflowFieldDescriptor[];
|
|
56
|
+
/**
|
|
57
|
+
* Fields that ARE author-controlled but do not live in the `[workflow]` table —
|
|
58
|
+
* they travel through their own structural channel. Kept distinct from
|
|
59
|
+
* `WORKFLOW_FIELDS_INTERNAL` so "internal" keeps meaning "not author-facing".
|
|
60
|
+
*/
|
|
61
|
+
export declare const WORKFLOW_FIELDS_STRUCTURAL: ReadonlySet<string>;
|
|
62
|
+
/**
|
|
63
|
+
* Fields the server owns: identity, ownership, timestamps, computed pointers,
|
|
64
|
+
* and the deprecated draft/revision slot. None of these are ever sent by the
|
|
65
|
+
* CLI, and none belong in workflow TOML.
|
|
66
|
+
*/
|
|
67
|
+
export declare const WORKFLOW_FIELDS_INTERNAL: ReadonlySet<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Synced fields the CLI does NOT round-trip yet — Phase 2 (#2327) wires them.
|
|
70
|
+
* Recorded explicitly so "classified" is never mistaken for "implemented".
|
|
71
|
+
* `lock` was wired by #1972; `templateMissingMarker` was removed from the
|
|
72
|
+
* platform by #2643, so the set is now empty.
|
|
73
|
+
*/
|
|
74
|
+
export declare const SYNCED_NOT_YET_WIRED: ReadonlySet<string>;
|
|
75
|
+
/** Descriptor `field` names, for coverage/parity checks. */
|
|
76
|
+
export declare const WORKFLOW_SYNCED_FIELDS: ReadonlySet<string>;
|
|
77
|
+
/** Look up a synced field's descriptor by model field name. */
|
|
78
|
+
export declare function getWorkflowFieldDescriptor(field: string): WorkflowFieldDescriptor | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* Model fields that are classified in NONE of synced / structural / internal —
|
|
81
|
+
* i.e. a field someone added to `models.yaml` without deciding how the CLI
|
|
82
|
+
* treats it. Non-empty is a hard failure in the drift guard.
|
|
83
|
+
*/
|
|
84
|
+
export declare function findUnclassifiedWorkflowFields(modelFields: readonly string[]): string[];
|
|
85
|
+
/**
|
|
86
|
+
* Classifications that no longer correspond to a model field — i.e. a field
|
|
87
|
+
* removed from `models.yaml` while the CLI still classifies it. Also a hard
|
|
88
|
+
* failure: a stale classification must not silently pass, or the coverage
|
|
89
|
+
* claim quietly stops meaning anything.
|
|
90
|
+
*/
|
|
91
|
+
export declare function findStaleWorkflowClassifications(modelFields: readonly string[]): string[];
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Classification of the `WorkflowDefinition` field surface (issue #2326,
|
|
3
|
+
* Phase 1 of #1976).
|
|
4
|
+
*
|
|
5
|
+
* Purpose: give the CLI a mechanical trip-wire for the drift that keeps
|
|
6
|
+
* happening — the server grows a `[workflow]`-level config field (`syncCallable`
|
|
7
|
+
* #807, `accessRule` #571, `runAs` #1081, `capabilities` #1172, `lock` #1518)
|
|
8
|
+
* and the CLI silently drops it on `sync push` / `sync pull`. Every field of the
|
|
9
|
+
* `WorkflowDefinition` model must appear in exactly one of the three groups
|
|
10
|
+
* below. The generated artifact `generated-workflow-model-fields.ts` carries the
|
|
11
|
+
* model's real field list (parsed from `models.yaml` at build time), and
|
|
12
|
+
* `cli/tests/unit/workflow-field-descriptor-drift-guard.test.ts` asserts
|
|
13
|
+
*
|
|
14
|
+
* synced ∪ structural ∪ internal === the model's fields
|
|
15
|
+
*
|
|
16
|
+
* so a new field hard-fails the guard until someone classifies it.
|
|
17
|
+
*
|
|
18
|
+
* ── Scope: declarative classification and coverage ONLY ──────────────────
|
|
19
|
+
* Decision of record (#1976, 2026-07-23): this table records WHICH fields
|
|
20
|
+
* exist, whether each is synced / structural / internal, and its `[workflow]`
|
|
21
|
+
* TOML key. Anything with real BEHAVIOR gets an explicit per-field handler or
|
|
22
|
+
* stays outside the table. In particular this file deliberately does NOT encode
|
|
23
|
+
* as boolean knobs:
|
|
24
|
+
* - the schema fields' native-TOML-table-vs-JSON-string parsing
|
|
25
|
+
* (`buildWorkflowPayloadFromToml` / `safeJsonParse` own that),
|
|
26
|
+
* - `syncCallable`'s deferred second PATCH on update (#807 — `applyWorkflowBody`
|
|
27
|
+
* owns that),
|
|
28
|
+
* - the `metadataManifest` (#1304) and `expr.cel` (#1614) structural side
|
|
29
|
+
* channels, which are attached alongside the steps write and are not
|
|
30
|
+
* `[workflow]`-table keys at all.
|
|
31
|
+
* `cli/src/lib/app-settings-descriptor.ts` is the shape being matched:
|
|
32
|
+
* deliberately narrow.
|
|
33
|
+
*
|
|
34
|
+
* ── What Phase 1 does and does not do ───────────────────────────────────
|
|
35
|
+
* Phase 1 (this file) is the guard only. Making the push builder
|
|
36
|
+
* (`workflow-payload.ts`) and the pull serializer (`serializeWorkflow` in
|
|
37
|
+
* `commands/sync.ts`) *consume* this table is Phase 2 (#2327).
|
|
38
|
+
* `synced` therefore means "belongs in the `[workflow]` TOML table", NOT
|
|
39
|
+
* "already round-trips" — see `SYNCED_NOT_YET_WIRED` below.
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* The author-facing `[workflow]`-table config fields — the ones a workflow
|
|
43
|
+
* author manages as code and the CLI must round-trip.
|
|
44
|
+
*/
|
|
45
|
+
export const WORKFLOW_FIELD_DESCRIPTOR = [
|
|
46
|
+
{ field: "name", tomlKey: "name", type: "string" },
|
|
47
|
+
{ field: "status", tomlKey: "status", type: "string" },
|
|
48
|
+
{ field: "description", tomlKey: "description", type: "string" },
|
|
49
|
+
// JSON Schema objects. TOML may present them as an inline table OR as a
|
|
50
|
+
// JSON string; the push builder owns that parse (not a knob here).
|
|
51
|
+
{ field: "inputSchema", tomlKey: "inputSchema", type: "json" },
|
|
52
|
+
{ field: "outputSchema", tomlKey: "outputSchema", type: "json" },
|
|
53
|
+
{ field: "perUserMaxRunning", tomlKey: "perUserMaxRunning", type: "number" },
|
|
54
|
+
{ field: "perUserMaxQueued", tomlKey: "perUserMaxQueued", type: "number" },
|
|
55
|
+
{ field: "perAppMaxRunning", tomlKey: "perAppMaxRunning", type: "number" },
|
|
56
|
+
{ field: "perAppMaxQueued", tomlKey: "perAppMaxQueued", type: "number" },
|
|
57
|
+
{ field: "queueTtlSeconds", tomlKey: "queueTtlSeconds", type: "number" },
|
|
58
|
+
{ field: "dequeueOrder", tomlKey: "dequeueOrder", type: "string" },
|
|
59
|
+
{
|
|
60
|
+
field: "requiresClientApply",
|
|
61
|
+
tomlKey: "requiresClientApply",
|
|
62
|
+
type: "boolean",
|
|
63
|
+
},
|
|
64
|
+
// Create-only on the wire (#807: update sends it as a deferred second PATCH
|
|
65
|
+
// once the new steps are live). That sequencing is the payload builder's job.
|
|
66
|
+
{ field: "syncCallable", tomlKey: "syncCallable", type: "boolean" },
|
|
67
|
+
{ field: "accessRule", tomlKey: "accessRule", type: "string" },
|
|
68
|
+
{ field: "runAs", tomlKey: "runAs", type: "string" },
|
|
69
|
+
// #1518/#1972 — declarative run-scoped lock. `[workflow.lock]` inline table
|
|
70
|
+
// on the TOML side, JSON on the wire; validated server-side by
|
|
71
|
+
// `parseWorkflowLock` (decision of record #6: no client-side mirror validator).
|
|
72
|
+
{ field: "lock", tomlKey: "lock", type: "json" },
|
|
73
|
+
// #1078 Tier 1b — StringSetField on the model, string array in TOML/JSON.
|
|
74
|
+
{ field: "capabilities", tomlKey: "capabilities", type: "string[]" },
|
|
75
|
+
];
|
|
76
|
+
/**
|
|
77
|
+
* Fields that ARE author-controlled but do not live in the `[workflow]` table —
|
|
78
|
+
* they travel through their own structural channel. Kept distinct from
|
|
79
|
+
* `WORKFLOW_FIELDS_INTERNAL` so "internal" keeps meaning "not author-facing".
|
|
80
|
+
*/
|
|
81
|
+
export const WORKFLOW_FIELDS_STRUCTURAL = new Set([
|
|
82
|
+
// The workflow's identity. Comes from the TOML file name / `--key`, and is
|
|
83
|
+
// attached by the caller rather than spread from the `[workflow]` table.
|
|
84
|
+
"workflowKey",
|
|
85
|
+
// #1304 — JSON declared-access manifest, derived from the workflow's CEL
|
|
86
|
+
// fields and attached alongside the steps write, not typed by the author.
|
|
87
|
+
"metadataManifest",
|
|
88
|
+
]);
|
|
89
|
+
/**
|
|
90
|
+
* Fields the server owns: identity, ownership, timestamps, computed pointers,
|
|
91
|
+
* and the deprecated draft/revision slot. None of these are ever sent by the
|
|
92
|
+
* CLI, and none belong in workflow TOML.
|
|
93
|
+
*/
|
|
94
|
+
export const WORKFLOW_FIELDS_INTERNAL = new Set([
|
|
95
|
+
// Identity / ownership / timestamps — assigned by the server.
|
|
96
|
+
"workflowId",
|
|
97
|
+
"appId",
|
|
98
|
+
"createdBy",
|
|
99
|
+
"createdAt",
|
|
100
|
+
"modifiedAt",
|
|
101
|
+
// Pointer to the active WorkflowConfiguration — server-computed on publish.
|
|
102
|
+
"activeConfigId",
|
|
103
|
+
// DEPRECATED in models.yaml: the legacy revision + draft slot, kept for
|
|
104
|
+
// migration/backward compatibility. Server-managed; never author-authored.
|
|
105
|
+
"latestRevision",
|
|
106
|
+
"stepsR2Key",
|
|
107
|
+
"draftStepsR2Key",
|
|
108
|
+
"draftInputSchema",
|
|
109
|
+
"draftOutputSchema",
|
|
110
|
+
"draftModifiedAt",
|
|
111
|
+
]);
|
|
112
|
+
/**
|
|
113
|
+
* Synced fields the CLI does NOT round-trip yet — Phase 2 (#2327) wires them.
|
|
114
|
+
* Recorded explicitly so "classified" is never mistaken for "implemented".
|
|
115
|
+
* `lock` was wired by #1972; `templateMissingMarker` was removed from the
|
|
116
|
+
* platform by #2643, so the set is now empty.
|
|
117
|
+
*/
|
|
118
|
+
export const SYNCED_NOT_YET_WIRED = new Set([]);
|
|
119
|
+
/** Descriptor `field` names, for coverage/parity checks. */
|
|
120
|
+
export const WORKFLOW_SYNCED_FIELDS = new Set(WORKFLOW_FIELD_DESCRIPTOR.map((d) => d.field));
|
|
121
|
+
/** Look up a synced field's descriptor by model field name. */
|
|
122
|
+
export function getWorkflowFieldDescriptor(field) {
|
|
123
|
+
return WORKFLOW_FIELD_DESCRIPTOR.find((d) => d.field === field);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Model fields that are classified in NONE of synced / structural / internal —
|
|
127
|
+
* i.e. a field someone added to `models.yaml` without deciding how the CLI
|
|
128
|
+
* treats it. Non-empty is a hard failure in the drift guard.
|
|
129
|
+
*/
|
|
130
|
+
export function findUnclassifiedWorkflowFields(modelFields) {
|
|
131
|
+
return modelFields
|
|
132
|
+
.filter((f) => !WORKFLOW_SYNCED_FIELDS.has(f) &&
|
|
133
|
+
!WORKFLOW_FIELDS_STRUCTURAL.has(f) &&
|
|
134
|
+
!WORKFLOW_FIELDS_INTERNAL.has(f))
|
|
135
|
+
.sort();
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Classifications that no longer correspond to a model field — i.e. a field
|
|
139
|
+
* removed from `models.yaml` while the CLI still classifies it. Also a hard
|
|
140
|
+
* failure: a stale classification must not silently pass, or the coverage
|
|
141
|
+
* claim quietly stops meaning anything.
|
|
142
|
+
*/
|
|
143
|
+
export function findStaleWorkflowClassifications(modelFields) {
|
|
144
|
+
const known = new Set(modelFields);
|
|
145
|
+
return [
|
|
146
|
+
...WORKFLOW_SYNCED_FIELDS,
|
|
147
|
+
...WORKFLOW_FIELDS_STRUCTURAL,
|
|
148
|
+
...WORKFLOW_FIELDS_INTERNAL,
|
|
149
|
+
]
|
|
150
|
+
.filter((f) => !known.has(f))
|
|
151
|
+
.sort();
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=workflow-field-descriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-field-descriptor.js","sourceRoot":"","sources":["../../../src/lib/workflow-field-descriptor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAmBH;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAuC;IAC3E,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE;IAClD,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,IAA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AAM,CACL,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC;QAC9B,CAAC,0BAA0B,CAAC,GAAG,CAAC,CAAC,CAAC;QAClC,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC,CAAC,CACnC;SACA,IAAI,EAAE,CAAC;AACZ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gCAAgC,CAC9C,WAA8B;IAE9B,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;IACnC,OAAO;QACL,GAAG,sBAAsB;QACzB,GAAG,0BAA0B;QAC7B,GAAG,wBAAwB;KAC5B;SACE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SAC5B,IAAI,EAAE,CAAC;AACZ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "primitive-admin",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.9",
|
|
4
4
|
"description": "CLI for administering Primitive applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"commander": "^12.1.0",
|
|
59
59
|
"esbuild": "0.25.12",
|
|
60
60
|
"inquirer": "^9.2.12",
|
|
61
|
-
"js-bao": "0.12.0-alpha.
|
|
61
|
+
"js-bao": "0.12.0-alpha.9",
|
|
62
62
|
"mime-types": "^2.1.35",
|
|
63
63
|
"open": "^10.0.3",
|
|
64
64
|
"smol-toml": "1.7.0",
|