@ebay-dt/bonfire-core 0.1.0-alpha.0 → 0.1.0-alpha.2

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.
Files changed (43) hide show
  1. package/README.md +54 -6
  2. package/dist/agent.d.ts +48 -0
  3. package/dist/agent.d.ts.map +1 -0
  4. package/dist/agent.js +96 -0
  5. package/dist/agent.js.map +1 -0
  6. package/dist/auth-model.d.ts.map +1 -1
  7. package/dist/auth-model.js.map +1 -1
  8. package/dist/config.d.ts +2 -0
  9. package/dist/config.d.ts.map +1 -1
  10. package/dist/config.js +15 -1
  11. package/dist/config.js.map +1 -1
  12. package/dist/identity.d.ts.map +1 -1
  13. package/dist/identity.js.map +1 -1
  14. package/dist/index.d.ts +5 -3
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +4 -2
  17. package/dist/index.js.map +1 -1
  18. package/dist/internal/types.d.ts.map +1 -1
  19. package/dist/internal/types.js.map +1 -1
  20. package/dist/internal/utils.d.ts.map +1 -1
  21. package/dist/internal/utils.js.map +1 -1
  22. package/dist/lifecycle-input.d.ts +10 -5
  23. package/dist/lifecycle-input.d.ts.map +1 -1
  24. package/dist/lifecycle-input.js +49 -25
  25. package/dist/lifecycle-input.js.map +1 -1
  26. package/dist/lifecycle.d.ts +23 -1
  27. package/dist/lifecycle.d.ts.map +1 -1
  28. package/dist/lifecycle.js +13 -0
  29. package/dist/lifecycle.js.map +1 -1
  30. package/dist/prototype-catalog.d.ts +4 -0
  31. package/dist/prototype-catalog.d.ts.map +1 -1
  32. package/dist/prototype-catalog.js.map +1 -1
  33. package/dist/prototype-metadata.d.ts +6 -1
  34. package/dist/prototype-metadata.d.ts.map +1 -1
  35. package/dist/prototype-metadata.js +17 -1
  36. package/dist/prototype-metadata.js.map +1 -1
  37. package/dist/prototype-ref.d.ts.map +1 -1
  38. package/dist/prototype-ref.js.map +1 -1
  39. package/dist/theme.d.ts +43 -0
  40. package/dist/theme.d.ts.map +1 -0
  41. package/dist/theme.js +210 -0
  42. package/dist/theme.js.map +1 -0
  43. package/package.json +2 -2
package/README.md CHANGED
@@ -28,6 +28,39 @@ configuration is deeply frozen.
28
28
  The package also exports the `BonfireIdentity` and
29
29
  `GitHubCliLoginPageModel` types used by the Node, Next.js, and React packages.
30
30
 
31
+ ## Generic theme contracts
32
+
33
+ Themes are optional instance configuration. A registry declares the themes an
34
+ application can render and the color schemes each theme supports:
35
+
36
+ ```ts
37
+ import type { BonfireConfigInput } from "@ebay-dt/bonfire-core";
38
+
39
+ const config = {
40
+ appId: "my-app",
41
+ name: "My App",
42
+ themes: {
43
+ definitions: [
44
+ {
45
+ id: "alpha",
46
+ label: "Alpha",
47
+ allowedColorSchemes: ["system", "light", "dark"],
48
+ },
49
+ { id: "beta", label: "Beta", allowedColorSchemes: ["dark"] },
50
+ ],
51
+ defaultTheme: "alpha",
52
+ defaultColorScheme: "system",
53
+ },
54
+ } satisfies BonfireConfigInput;
55
+ ```
56
+
57
+ `ThemeDefinition`, `ThemeRegistry`, and `PrototypeTheme` are generic contracts;
58
+ Bonfire does not assign meaning to theme IDs or own their CSS. Prototype
59
+ metadata may narrow the registry to a default theme, allowed themes, a default
60
+ scheme, and allowed schemes. All registry and metadata values are normalized,
61
+ validated, and deeply frozen. `parsePrototypeThemeSelection` expands the
62
+ create/edit dialog's switching permissions into a validated `PrototypeTheme`.
63
+
31
64
  ## Prototype catalog contracts
32
65
 
33
66
  Prototype references use a validated login and lowercase kebab-case slug:
@@ -93,18 +126,33 @@ if (!result.ok) {
93
126
  ```
94
127
 
95
128
  Create and duplicate inputs normalize title/description and validate all
96
- prototype references. Save and discard use the same normalized `PrototypeRef`
97
- command input. Destination identity and slug are intentionally absent from
98
- browser input; trusted services derive them from the authenticated identity and
99
- normalized title. Create, duplicate, save, and discard are development-only
129
+ prototype references. Edit normalizes the title/description together with the
130
+ owned prototype ref; delete uses the same normalized `PrototypeRef` command
131
+ input. Destination identity and slug are intentionally absent from browser
132
+ input; trusted services derive them from the authenticated identity and
133
+ normalized title. Create, duplicate, edit, and delete are development-only
100
134
  mutation contracts; production adapters remain public and read-only.
101
135
 
102
136
  Dirty observation is represented by the finite `clean` and `dirty` statuses. It
103
137
  is an observation of the repository, not durable client state.
104
- Save and discard return explicit success values and never expose filesystem
105
- paths, Git output, or framework values.
138
+ Edit and delete return explicit success values and never expose filesystem
139
+ paths, Git output, or framework values. Edit preserves the existing ref and
140
+ URL; delete represents removal of the complete owned prototype directory,
141
+ including uncommitted files.
106
142
 
107
143
  Lifecycle errors contain only stable codes, never filesystem paths, Git output,
108
144
  GitHub CLI output, or secrets. Hosts own user-facing copy for codes such as
109
145
  `invalid-input`, `already-exists`, `repository-busy`, `working-tree-conflict`,
110
146
  `git-failure`, and `filesystem-failure`.
147
+
148
+ Deployment uses the same validated `PrototypeCommandInput` as other
149
+ reference-only lifecycle commands. A successful `DeploymentValue` contains the
150
+ owned prototype ref, canonical `previewUrl`, `deploymentId`, `readyState`, and
151
+ an optional warning. Ready states are finite: `BLOCKED`, `BUILDING`, `CANCELED`,
152
+ `ERROR`, `INITIALIZING`, `QUEUED`, and `READY`. A ready state is the provider's
153
+ reported state; Bonfire does not poll the deployment ID.
154
+
155
+ Deployment is optional and development-only. Core does not define a service
156
+ endpoint, credentials, deployment target, or `{ owner, branch }` input; trusted
157
+ Node/Next adapters derive the application ID and login from server configuration
158
+ and authenticated identity.
@@ -0,0 +1,48 @@
1
+ import { type PrototypeRef } from "./prototype-ref.js";
2
+ export type Agent = "cursor" | "claude-code";
3
+ export type TerminalApp = "terminal" | "iterm" | "warp";
4
+ export type AgentCommand = "cursor" | "claude" | "osascript";
5
+ export type OpenInAgentInput = {
6
+ ref: PrototypeRef;
7
+ };
8
+ export type OpenInClaudeCodeInput = OpenInAgentInput & {
9
+ terminal?: TerminalApp;
10
+ };
11
+ export type UserPreferences = {
12
+ preferredTerminal?: TerminalApp;
13
+ };
14
+ export type AgentActionErrorCode = "unauthenticated" | "forbidden" | "not-found" | "invalid-input" | "needs-terminal" | "missing-command" | "unsupported-platform" | "launch-failed";
15
+ export type AgentActionError = {
16
+ code: AgentActionErrorCode;
17
+ agent?: Agent;
18
+ command?: AgentCommand;
19
+ terminal?: TerminalApp;
20
+ };
21
+ export type AgentLaunchValue = {
22
+ agent: Agent;
23
+ };
24
+ export type AgentActionResult<Value = AgentLaunchValue> = {
25
+ ok: true;
26
+ value: Value;
27
+ } | {
28
+ ok: false;
29
+ error: AgentActionError;
30
+ };
31
+ export declare class AgentInputError extends Error {
32
+ readonly code: "invalid-input";
33
+ readonly path: string;
34
+ constructor(path: string);
35
+ }
36
+ export declare function parseAgent(value: unknown): Agent;
37
+ export declare function parseTerminalApp(value: unknown): TerminalApp;
38
+ export declare function parseAgentCommand(value: unknown): AgentCommand;
39
+ export declare function parseOpenInAgentInput(value: unknown): {
40
+ ref: PrototypeRef;
41
+ };
42
+ export declare function parseOpenInClaudeCodeInput(value: unknown): OpenInClaudeCodeInput;
43
+ /**
44
+ * Preference documents are intentionally forward-compatible: unknown keys are
45
+ * ignored and an invalid terminal value means that no terminal is configured.
46
+ */
47
+ export declare function parseUserPreferences(value: unknown): UserPreferences;
48
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,KAAK,GAAG,QAAQ,GAAG,aAAa,CAAC;AAC7C,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;AACxD,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,CAAC;AAU7D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,YAAY,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,GAAG;IACrD,QAAQ,C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E","sourcesContent":["import { asRecord, deepFreeze, findUnknownKey } from \"./internal/utils.js\";\nimport {\n definePrototypeRef,\n PrototypeRefError,\n type PrototypeRef,\n} from \"./prototype-ref.js\";\n\nexport type Agent = \"cursor\" | \"claude-code\";\nexport type TerminalApp = \"terminal\" | \"iterm\" | \"warp\";\nexport type AgentCommand = \"cursor\" | \"claude\" | \"osascript\";\n\nconst AGENTS: readonly Agent[] = [\"cursor\", \"claude-code\"];\nconst TERMINALS: readonly TerminalApp[] = [\"terminal\", \"iterm\", \"warp\"];\nconst AGENT_COMMANDS: readonly AgentCommand[] = [\n \"cursor\",\n \"claude\",\n \"osascript\",\n];\n\nexport type OpenInAgentInput = {\n ref: PrototypeRef;\n};\n\nexport type OpenInClaudeCodeInput = OpenInAgentInput & {\n terminal?: TerminalApp;\n};\n\nexport type UserPreferences = {\n preferredTerminal?: TerminalApp;\n};\n\nexport type AgentActionErrorCode =\n | \"unauthenticated\"\n | \"forbidden\"\n | \"not-found\"\n | \"invalid-input\"\n | \"needs-terminal\"\n | \"missing-command\"\n | \"unsupported-platform\"\n | \"launch-failed\";\n\nexport type AgentActionError = {\n code: AgentActionErrorCode;\n agent?: Agent;\n command?: AgentCommand;\n terminal?: TerminalApp;\n};\n\nexport type AgentLaunchValue = {\n agent: Agent;\n};\n\nexport type AgentActionResult<Value = AgentLaunchValue> =\n { ok: true; value: Value } | { ok: false; error: AgentActionError };\n\nexport class AgentInputError extends Error {\n readonly code = \"invalid-input\" as const;\n readonly path: string;\n\n constructor(path: string) {\n super(\"Invalid agent input\");\n this.name = \"AgentInputError\";\n this.path = path;\n }\n}\n\nfunction parseEnum<Value extends string>(\n value: unknown,\n values: readonly Value[],\n path: string,\n) {\n if (typeof value === \"string\" && values.includes(value as Value)) {\n return value as Value;\n }\n\n throw new AgentInputError(path);\n}\n\nexport function parseAgent(value: unknown) {\n return parseEnum(value, AGENTS, \"agent\");\n}\n\nexport function parseTerminalApp(value: unknown) {\n return parseEnum(value, TERMINALS, \"terminal\");\n}\n\nexport function parseAgentCommand(value: unknown) {\n return parseEnum(value, AGENT_COMMANDS, \"command\");\n}\n\nfunction parseInputRef(record: Record<string, unknown>) {\n if (!Object.hasOwn(record, \"ref\")) {\n throw new AgentInputError(\"ref\");\n }\n\n try {\n return definePrototypeRef(record.ref);\n } catch (error) {\n if (error instanceof PrototypeRefError) {\n throw new AgentInputError(\"ref\");\n }\n throw error;\n }\n}\n\nfunction requireInputRecord(value: unknown) {\n const record = asRecord(value);\n if (record === null) throw new AgentInputError(\"input\");\n return record;\n}\n\nexport function parseOpenInAgentInput(value: unknown) {\n const record = requireInputRecord(value);\n if (findUnknownKey(record, [\"ref\"])) {\n throw new AgentInputError(\"input\");\n }\n\n return deepFreeze({ ref: parseInputRef(record) }) satisfies OpenInAgentInput;\n}\n\nexport function parseOpenInClaudeCodeInput(value: unknown) {\n const record = requireInputRecord(value);\n if (findUnknownKey(record, [\"ref\", \"terminal\"])) {\n throw new AgentInputError(\"input\");\n }\n\n const input: OpenInClaudeCodeInput = {\n ref: parseInputRef(record),\n };\n if (record.terminal !== undefined) {\n input.terminal = parseTerminalApp(record.terminal);\n }\n\n return deepFreeze(input) satisfies OpenInClaudeCodeInput;\n}\n\n/**\n * Preference documents are intentionally forward-compatible: unknown keys are\n * ignored and an invalid terminal value means that no terminal is configured.\n */\nexport function parseUserPreferences(value: unknown): UserPreferences {\n const record = asRecord(value);\n if (record === null || !Object.hasOwn(record, \"preferredTerminal\")) {\n return Object.freeze({});\n }\n\n if (record.preferredTerminal === undefined) return Object.freeze({});\n\n try {\n return Object.freeze({\n preferredTerminal: parseTerminalApp(record.preferredTerminal),\n });\n } catch (error) {\n if (error instanceof AgentInputError) return Object.freeze({});\n throw error;\n }\n}\n"]}
package/dist/agent.js ADDED
@@ -0,0 +1,96 @@
1
+ import { asRecord, deepFreeze, findUnknownKey } from "./internal/utils.js";
2
+ import { definePrototypeRef, PrototypeRefError, } from "./prototype-ref.js";
3
+ const AGENTS = ["cursor", "claude-code"];
4
+ const TERMINALS = ["terminal", "iterm", "warp"];
5
+ const AGENT_COMMANDS = [
6
+ "cursor",
7
+ "claude",
8
+ "osascript",
9
+ ];
10
+ export class AgentInputError extends Error {
11
+ code = "invalid-input";
12
+ path;
13
+ constructor(path) {
14
+ super("Invalid agent input");
15
+ this.name = "AgentInputError";
16
+ this.path = path;
17
+ }
18
+ }
19
+ function parseEnum(value, values, path) {
20
+ if (typeof value === "string" && values.includes(value)) {
21
+ return value;
22
+ }
23
+ throw new AgentInputError(path);
24
+ }
25
+ export function parseAgent(value) {
26
+ return parseEnum(value, AGENTS, "agent");
27
+ }
28
+ export function parseTerminalApp(value) {
29
+ return parseEnum(value, TERMINALS, "terminal");
30
+ }
31
+ export function parseAgentCommand(value) {
32
+ return parseEnum(value, AGENT_COMMANDS, "command");
33
+ }
34
+ function parseInputRef(record) {
35
+ if (!Object.hasOwn(record, "ref")) {
36
+ throw new AgentInputError("ref");
37
+ }
38
+ try {
39
+ return definePrototypeRef(record.ref);
40
+ }
41
+ catch (error) {
42
+ if (error instanceof PrototypeRefError) {
43
+ throw new AgentInputError("ref");
44
+ }
45
+ throw error;
46
+ }
47
+ }
48
+ function requireInputRecord(value) {
49
+ const record = asRecord(value);
50
+ if (record === null)
51
+ throw new AgentInputError("input");
52
+ return record;
53
+ }
54
+ export function parseOpenInAgentInput(value) {
55
+ const record = requireInputRecord(value);
56
+ if (findUnknownKey(record, ["ref"])) {
57
+ throw new AgentInputError("input");
58
+ }
59
+ return deepFreeze({ ref: parseInputRef(record) });
60
+ }
61
+ export function parseOpenInClaudeCodeInput(value) {
62
+ const record = requireInputRecord(value);
63
+ if (findUnknownKey(record, ["ref", "terminal"])) {
64
+ throw new AgentInputError("input");
65
+ }
66
+ const input = {
67
+ ref: parseInputRef(record),
68
+ };
69
+ if (record.terminal !== undefined) {
70
+ input.terminal = parseTerminalApp(record.terminal);
71
+ }
72
+ return deepFreeze(input);
73
+ }
74
+ /**
75
+ * Preference documents are intentionally forward-compatible: unknown keys are
76
+ * ignored and an invalid terminal value means that no terminal is configured.
77
+ */
78
+ export function parseUserPreferences(value) {
79
+ const record = asRecord(value);
80
+ if (record === null || !Object.hasOwn(record, "preferredTerminal")) {
81
+ return Object.freeze({});
82
+ }
83
+ if (record.preferredTerminal === undefined)
84
+ return Object.freeze({});
85
+ try {
86
+ return Object.freeze({
87
+ preferredTerminal: parseTerminalApp(record.preferredTerminal),
88
+ });
89
+ }
90
+ catch (error) {
91
+ if (error instanceof AgentInputError)
92
+ return Object.freeze({});
93
+ throw error;
94
+ }
95
+ }
96
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EACL,kBAAkB,EAClB,iBAAiB,GAElB,MAAM,oBAAoB,CAAC;AAM5B,MAAM,MAAM,GAAqB,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;AAC3D,MAAM,SAAS,GAA2B,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AACxE,MAAM,cAAc,GAA4B;IAC9C,QAAQ;IACR,QAAQ;IACR,WAAW;CACZ,CAAC;AAsCF,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAC/B,IAAI,GAAG,eAAwB,CAAC;IAChC,IAAI,CAAS;IAEtB,YAAY,IAAY;QACtB,KAAK,CAAC,qBAAqB,CAAC,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,SAAS,SAAS,CAChB,KAAc,EACd,MAAwB,EACxB,IAAY;IAEZ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAc,CAAC,EAAE,CAAC;QACjE,OA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AAI,KAAK,YAAY,eAAe;YAAE,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC/D,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import { asRecord, deepFreeze, findUnknownKey } from \"./internal/utils.js\";\nimport {\n definePrototypeRef,\n PrototypeRefError,\n type PrototypeRef,\n} from \"./prototype-ref.js\";\n\nexport type Agent = \"cursor\" | \"claude-code\";\nexport type TerminalApp = \"terminal\" | \"iterm\" | \"warp\";\nexport type AgentCommand = \"cursor\" | \"claude\" | \"osascript\";\n\nconst AGENTS: readonly Agent[] = [\"cursor\", \"claude-code\"];\nconst TERMINALS: readonly TerminalApp[] = [\"terminal\", \"iterm\", \"warp\"];\nconst AGENT_COMMANDS: readonly AgentCommand[] = [\n \"cursor\",\n \"claude\",\n \"osascript\",\n];\n\nexport type OpenInAgentInput = {\n ref: PrototypeRef;\n};\n\nexport type OpenInClaudeCodeInput = OpenInAgentInput & {\n terminal?: TerminalApp;\n};\n\nexport type UserPreferences = {\n preferredTerminal?: TerminalApp;\n};\n\nexport type AgentActionErrorCode =\n | \"unauthenticated\"\n | \"forbidden\"\n | \"not-found\"\n | \"invalid-input\"\n | \"needs-terminal\"\n | \"missing-command\"\n | \"unsupported-platform\"\n | \"launch-failed\";\n\nexport type AgentActionError = {\n code: AgentActionErrorCode;\n agent?: Agent;\n command?: AgentCommand;\n terminal?: TerminalApp;\n};\n\nexport type AgentLaunchValue = {\n agent: Agent;\n};\n\nexport type AgentActionResult<Value = AgentLaunchValue> =\n { ok: true; value: Value } | { ok: false; error: AgentActionError };\n\nexport class AgentInputError extends Error {\n readonly code = \"invalid-input\" as const;\n readonly path: string;\n\n constructor(path: string) {\n super(\"Invalid agent input\");\n this.name = \"AgentInputError\";\n this.path = path;\n }\n}\n\nfunction parseEnum<Value extends string>(\n value: unknown,\n values: readonly Value[],\n path: string,\n) {\n if (typeof value === \"string\" && values.includes(value as Value)) {\n return value as Value;\n }\n\n throw new AgentInputError(path);\n}\n\nexport function parseAgent(value: unknown) {\n return parseEnum(value, AGENTS, \"agent\");\n}\n\nexport function parseTerminalApp(value: unknown) {\n return parseEnum(value, TERMINALS, \"terminal\");\n}\n\nexport function parseAgentCommand(value: unknown) {\n return parseEnum(value, AGENT_COMMANDS, \"command\");\n}\n\nfunction parseInputRef(record: Record<string, unknown>) {\n if (!Object.hasOwn(record, \"ref\")) {\n throw new AgentInputError(\"ref\");\n }\n\n try {\n return definePrototypeRef(record.ref);\n } catch (error) {\n if (error instanceof PrototypeRefError) {\n throw new AgentInputError(\"ref\");\n }\n throw error;\n }\n}\n\nfunction requireInputRecord(value: unknown) {\n const record = asRecord(value);\n if (record === null) throw new AgentInputError(\"input\");\n return record;\n}\n\nexport function parseOpenInAgentInput(value: unknown) {\n const record = requireInputRecord(value);\n if (findUnknownKey(record, [\"ref\"])) {\n throw new AgentInputError(\"input\");\n }\n\n return deepFreeze({ ref: parseInputRef(record) }) satisfies OpenInAgentInput;\n}\n\nexport function parseOpenInClaudeCodeInput(value: unknown) {\n const record = requireInputRecord(value);\n if (findUnknownKey(record, [\"ref\", \"terminal\"])) {\n throw new AgentInputError(\"input\");\n }\n\n const input: OpenInClaudeCodeInput = {\n ref: parseInputRef(record),\n };\n if (record.terminal !== undefined) {\n input.terminal = parseTerminalApp(record.terminal);\n }\n\n return deepFreeze(input) satisfies OpenInClaudeCodeInput;\n}\n\n/**\n * Preference documents are intentionally forward-compatible: unknown keys are\n * ignored and an invalid terminal value means that no terminal is configured.\n */\nexport function parseUserPreferences(value: unknown): UserPreferences {\n const record = asRecord(value);\n if (record === null || !Object.hasOwn(record, \"preferredTerminal\")) {\n return Object.freeze({});\n }\n\n if (record.preferredTerminal === undefined) return Object.freeze({});\n\n try {\n return Object.freeze({\n preferredTerminal: parseTerminalApp(record.preferredTerminal),\n });\n } catch (error) {\n if (error instanceof AgentInputError) return Object.freeze({});\n throw error;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"auth-model.d.ts","sourceRoot":"","sources":["../src/auth-model.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAAG,eAAe,GAAG,uBAAuB,CAAC;AAEhF,MAAM,MAAM,uBAAuB,GAAG;IACpC,wCAAwC;IACxC,eAAe,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,cAAc,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,eAAe,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,sDAAsD;IACtD,aAAa,EAAE,OAAO,CAAC;IACvB,2CAA2C;IAC3C,KAAK,EAAE,uBAAuB,GAAG,IAAI,CAAC;CACvC,CAAC"}
1
+ {"version":3,"file":"auth-model.d.ts","sourceRoot":"","sources":["../src/auth-model.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAAG,eAAe,GAAG,uBAAuB,CAAC;AAEhF,MAAM,MAAM,uBAAuB,GAAG;IACpC,wCAAwC;IACxC,eAAe,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,cAAc,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,eAAe,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,sDAAsD;IACtD,aAAa,EAAE,OAAO,CAAC;IACvB,2CAA2C;IAC3C,KAAK,EAAE,uBAAuB,GAAG,IAAI,CAAC;CACvC,CAAC","sourcesContent":["export type GitHubCliLoginPageError = \"gh_cli_failed\" | \"branch_prepare_failed\";\n\nexport type GitHubCliLoginPageModel = {\n /** App name shown in the login page. */\n applicationName: string;\n /** Configured GitHub or GitHub Enterprise hostname. */\n githubHostname: string;\n /** Endpoint invoked by the Continue button. */\n loginUrl: string;\n /** Endpoint polled during device authentication. */\n statusUrl: string;\n /** Destination after successful authentication. */\n returnUrl: string;\n /** GitHub device activation link. */\n deviceUrl: string;\n /** Safe fallback command for manually starting GitHub CLI login. */\n fallbackCommand: string;\n /** One-time device code, when the CLI provides one. */\n deviceCode: string | null;\n /** Whether the client should begin status polling. */\n pollingActive: boolean;\n /** Generic login failure state, if any. */\n error: GitHubCliLoginPageError | null;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"auth-model.js","sourceRoot":"","sources":["../src/auth-model.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"auth-model.js","sourceRoot":"","sources":["../src/auth-model.ts"],"names":[],"mappings":"","sourcesContent":["export type GitHubCliLoginPageError = \"gh_cli_failed\" | \"branch_prepare_failed\";\n\nexport type GitHubCliLoginPageModel = {\n /** App name shown in the login page. */\n applicationName: string;\n /** Configured GitHub or GitHub Enterprise hostname. */\n githubHostname: string;\n /** Endpoint invoked by the Continue button. */\n loginUrl: string;\n /** Endpoint polled during device authentication. */\n statusUrl: string;\n /** Destination after successful authentication. */\n returnUrl: string;\n /** GitHub device activation link. */\n deviceUrl: string;\n /** Safe fallback command for manually starting GitHub CLI login. */\n fallbackCommand: string;\n /** One-time device code, when the CLI provides one. */\n deviceCode: string | null;\n /** Whether the client should begin status polling. */\n pollingActive: boolean;\n /** Generic login failure state, if any. */\n error: GitHubCliLoginPageError | null;\n};\n"]}
package/dist/config.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { type ThemeRegistry } from "./theme.js";
1
2
  import type { DeepReadonly } from "./internal/types.js";
2
3
  export type BonfireConfigInput = {
3
4
  appId: string;
@@ -7,6 +8,7 @@ export type BonfireConfigInput = {
7
8
  hostname: string;
8
9
  };
9
10
  };
11
+ themes?: ThemeRegistry;
10
12
  };
11
13
  export type BonfireConfig = DeepReadonly<BonfireConfigInput>;
12
14
  export declare class BonfireConfigError extends Error {
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAQxD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE;QACJ,MAAM,EAAE;YACN,QAAQ,EAAE,MAAM,CAAC;SAClB,CAAC;KACH,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,YAAY,CAAC,kBAAkB,CAAC,CAAC;AAE7D,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,YAAY,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAIxC;CACF;AAsGD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,kBAAkB,GAAG,aAAa,CA8BrE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,UAEjD"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAQxD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE;QACJ,MAAM,EAAE;YACN,QAAQ,EAAE,MAAM,CAAC;SAClB,CAAC;KACH,CAAC;IACF,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,YAAY,CAAC,kBAAkB,CAAC,CAAC;AAE7D,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,YAAY,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAIxC;CACF;AAsGD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,kBAAkB,GAAG,aAAa,CA2CrE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,UAEjD","sourcesContent":["import {\n asRecord,\n deepFreeze,\n findUnknownKey,\n readRequiredString,\n} from \"./internal/utils.js\";\nimport {\n parseThemeRegistry,\n ThemeValidationError,\n type ThemeRegistry,\n} from \"./theme.js\";\nimport type { DeepReadonly } from \"./internal/types.js\";\n\nconst APP_ID_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\nconst HOSTNAME_LABEL_PATTERN = /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)$/;\nconst MAX_APP_ID_LENGTH = 63;\nconst MAX_HOSTNAME_LENGTH = 253;\nconst SESSION_COOKIE_PREFIX = \"bf_session_\";\n\nexport type BonfireConfigInput = {\n appId: string;\n name: string;\n auth: {\n github: {\n hostname: string;\n };\n };\n themes?: ThemeRegistry;\n};\n\nexport type BonfireConfig = DeepReadonly<BonfireConfigInput>;\n\nexport class BonfireConfigError extends Error {\n readonly path: string;\n\n constructor(path: string, message: string) {\n super(`Invalid Bonfire configuration at ${path}: ${message}`);\n this.name = \"BonfireConfigError\";\n this.path = path;\n }\n}\n\nfunction configRecord(value: unknown, path: string) {\n const record = asRecord(value);\n if (record === null) {\n throw new BonfireConfigError(path, \"must be an object\");\n }\n\n return record;\n}\n\nfunction configRequiredString(\n record: Record<string, unknown>,\n key: string,\n path: string,\n) {\n const result = readRequiredString(record, key);\n if (result.status === \"missing\") {\n throw new BonfireConfigError(`${path}.${key}`, \"is required\");\n }\n if (result.status === \"invalid\") {\n throw new BonfireConfigError(`${path}.${key}`, \"must be a string\");\n }\n\n return result.value;\n}\n\nfunction rejectConfigUnknownKeys(\n record: Record<string, unknown>,\n allowedKeys: readonly string[],\n path: string,\n) {\n const unknownKey = findUnknownKey(record, allowedKeys);\n if (unknownKey) {\n throw new BonfireConfigError(`${path}.${unknownKey}`, \"is not supported\");\n }\n}\n\nfunction validateAppId(value: unknown, path: string) {\n if (typeof value !== \"string\") {\n throw new BonfireConfigError(path, \"must be a string\");\n }\n\n if (value.length === 0) {\n throw new BonfireConfigError(path, \"must not be empty\");\n }\n\n if (value.length > MAX_APP_ID_LENGTH) {\n throw new BonfireConfigError(\n path,\n `must be at most ${MAX_APP_ID_LENGTH} characters`,\n );\n }\n\n if (!APP_ID_PATTERN.test(value)) {\n throw new BonfireConfigError(\n path,\n \"must contain lowercase letters, numbers, and single hyphens between segments\",\n );\n }\n\n return value;\n}\n\nfunction validateName(value: unknown, path: string) {\n if (typeof value !== \"string\") {\n throw new BonfireConfigError(path, \"must be a string\");\n }\n\n const normalized = value.trim();\n if (normalized.length === 0) {\n throw new BonfireConfigError(path, \"must not be empty\");\n }\n\n return normalized;\n}\n\nfunction validateHostname(value: unknown, path: string) {\n if (typeof value !== \"string\") {\n throw new BonfireConfigError(path, \"must be a string\");\n }\n\n const normalized = value.toLowerCase();\n const labels = normalized.endsWith(\".\")\n ? normalized.slice(0, -1).split(\".\")\n : normalized.split(\".\");\n\n if (\n value.length === 0 ||\n value !== value.trim() ||\n value.length > MAX_HOSTNAME_LENGTH ||\n labels.some((label) => !HOSTNAME_LABEL_PATTERN.test(label))\n ) {\n throw new BonfireConfigError(\n path,\n \"must be a plain hostname without protocols, credentials, ports, paths, queries, fragments, or whitespace\",\n );\n }\n\n return normalized;\n}\n\nexport function parseHostname(value: unknown): string {\n return validateHostname(value, \"hostname\");\n}\n\nexport function defineConfig(input: BonfireConfigInput): BonfireConfig {\n const root = configRecord(input, \"config\");\n rejectConfigUnknownKeys(root, [\"appId\", \"name\", \"auth\", \"themes\"], \"config\");\n\n const appId = validateAppId(root.appId, \"config.appId\");\n const name = validateName(\n configRequiredString(root, \"name\", \"config\"),\n \"config.name\",\n );\n const auth = configRecord(root.auth, \"config.auth\");\n rejectConfigUnknownKeys(auth, [\"github\"], \"config.auth\");\n\n const github = configRecord(auth.github, \"config.auth.github\");\n rejectConfigUnknownKeys(github, [\"hostname\"], \"config.auth.github\");\n const hostname = validateHostname(\n configRequiredString(github, \"hostname\", \"config.auth.github\"),\n \"config.auth.github.hostname\",\n );\n\n let themes: ThemeRegistry | undefined;\n if (Object.hasOwn(root, \"themes\")) {\n try {\n themes = parseThemeRegistry(root.themes, \"config.themes\");\n } catch (error) {\n if (error instanceof ThemeValidationError) {\n throw new BonfireConfigError(error.path, error.reason);\n }\n throw error;\n }\n }\n\n const normalized = {\n appId,\n name,\n auth: {\n github: {\n hostname,\n },\n },\n ...(themes === undefined ? {} : { themes }),\n } satisfies BonfireConfig;\n\n return deepFreeze(normalized);\n}\n\nexport function getSessionCookieName(appId: string) {\n return `${SESSION_COOKIE_PREFIX}${validateAppId(appId, \"appId\")}`;\n}\n"]}
package/dist/config.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { asRecord, deepFreeze, findUnknownKey, readRequiredString, } from "./internal/utils.js";
2
+ import { parseThemeRegistry, ThemeValidationError, } from "./theme.js";
2
3
  const APP_ID_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
3
4
  const HOSTNAME_LABEL_PATTERN = /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)$/;
4
5
  const MAX_APP_ID_LENGTH = 63;
@@ -81,7 +82,7 @@ export function parseHostname(value) {
81
82
  }
82
83
  export function defineConfig(input) {
83
84
  const root = configRecord(input, "config");
84
- rejectConfigUnknownKeys(root, ["appId", "name", "auth"], "config");
85
+ rejectConfigUnknownKeys(root, ["appId", "name", "auth", "themes"], "config");
85
86
  const appId = validateAppId(root.appId, "config.appId");
86
87
  const name = validateName(configRequiredString(root, "name", "config"), "config.name");
87
88
  const auth = configRecord(root.auth, "config.auth");
@@ -89,6 +90,18 @@ export function defineConfig(input) {
89
90
  const github = configRecord(auth.github, "config.auth.github");
90
91
  rejectConfigUnknownKeys(github, ["hostname"], "config.auth.github");
91
92
  const hostname = validateHostname(configRequiredString(github, "hostname", "config.auth.github"), "config.auth.github.hostname");
93
+ let themes;
94
+ if (Object.hasOwn(root, "themes")) {
95
+ try {
96
+ themes = parseThemeRegistry(root.themes, "config.themes");
97
+ }
98
+ catch (error) {
99
+ if (error instanceof ThemeValidationError) {
100
+ throw new BonfireConfigError(error.path, error.reason);
101
+ }
102
+ throw error;
103
+ }
104
+ }
92
105
  const normalized = {
93
106
  appId,
94
107
  name,
@@ -97,6 +110,7 @@ export function defineConfig(input) {
97
110
  hostname,
98
111
  },
99
112
  },
113
+ ...(themes === undefined ? {} : { themes }),
100
114
  };
101
115
  return deepFreeze(normalized);
102
116
  }
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,UAAU,EACV,cAAc,EACd,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAG7B,MAAM,cAAc,GAAG,4BAA4B,CAAC;AACpD,MAAM,sBAAsB,GAAG,4CAA4C,CAAC;AAC5E,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,MAAM,qBAAqB,GAAG,aAAa,CAAC;AAc5C,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAClC,IAAI,CAAS;IAEtB,YAAY,IAAY,EAAE,OAAe;QACvC,KAAK,CAAC,oCAA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oB,CAAC,EAC9D,6BAA6B,CAC9B,CAAC;IAEF,IAAI,MAAiC,CAAC;IACtC,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC;QAClC,IAAI,CAAC;YACH,MAAM,GAAG,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;QAC5D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,oBAAoB,EAAE,CAAC;gBAC1C,MAAM,IAAI,kBAAkB,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YACzD,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,MAAM,UAAU,GAAG;QACjB,KAAK;QACL,IAAI;QACJ,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,QAAQ;aACT;SACF;QACD,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;IAE1B,OAAO,UAAU,CAAC,UAAU,CAAC,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,OAAO,GAAG,qBAAqB,GAAG,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC;AACpE,CAAC","sourcesContent":["import {\n asRecord,\n deepFreeze,\n findUnknownKey,\n readRequiredString,\n} from \"./internal/utils.js\";\nimport {\n parseThemeRegistry,\n ThemeValidationError,\n type ThemeRegistry,\n} from \"./theme.js\";\nimport type { DeepReadonly } from \"./internal/types.js\";\n\nconst APP_ID_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\nconst HOSTNAME_LABEL_PATTERN = /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)$/;\nconst MAX_APP_ID_LENGTH = 63;\nconst MAX_HOSTNAME_LENGTH = 253;\nconst SESSION_COOKIE_PREFIX = \"bf_session_\";\n\nexport type BonfireConfigInput = {\n appId: string;\n name: string;\n auth: {\n github: {\n hostname: string;\n };\n };\n themes?: ThemeRegistry;\n};\n\nexport type BonfireConfig = DeepReadonly<BonfireConfigInput>;\n\nexport class BonfireConfigError extends Error {\n readonly path: string;\n\n constructor(path: string, message: string) {\n super(`Invalid Bonfire configuration at ${path}: ${message}`);\n this.name = \"BonfireConfigError\";\n this.path = path;\n }\n}\n\nfunction configRecord(value: unknown, path: string) {\n const record = asRecord(value);\n if (record === null) {\n throw new BonfireConfigError(path, \"must be an object\");\n }\n\n return record;\n}\n\nfunction configRequiredString(\n record: Record<string, unknown>,\n key: string,\n path: string,\n) {\n const result = readRequiredString(record, key);\n if (result.status === \"missing\") {\n throw new BonfireConfigError(`${path}.${key}`, \"is required\");\n }\n if (result.status === \"invalid\") {\n throw new BonfireConfigError(`${path}.${key}`, \"must be a string\");\n }\n\n return result.value;\n}\n\nfunction rejectConfigUnknownKeys(\n record: Record<string, unknown>,\n allowedKeys: readonly string[],\n path: string,\n) {\n const unknownKey = findUnknownKey(record, allowedKeys);\n if (unknownKey) {\n throw new BonfireConfigError(`${path}.${unknownKey}`, \"is not supported\");\n }\n}\n\nfunction validateAppId(value: unknown, path: string) {\n if (typeof value !== \"string\") {\n throw new BonfireConfigError(path, \"must be a string\");\n }\n\n if (value.length === 0) {\n throw new BonfireConfigError(path, \"must not be empty\");\n }\n\n if (value.length > MAX_APP_ID_LENGTH) {\n throw new BonfireConfigError(\n path,\n `must be at most ${MAX_APP_ID_LENGTH} characters`,\n );\n }\n\n if (!APP_ID_PATTERN.test(value)) {\n throw new BonfireConfigError(\n path,\n \"must contain lowercase letters, numbers, and single hyphens between segments\",\n );\n }\n\n return value;\n}\n\nfunction validateName(value: unknown, path: string) {\n if (typeof value !== \"string\") {\n throw new BonfireConfigError(path, \"must be a string\");\n }\n\n const normalized = value.trim();\n if (normalized.length === 0) {\n throw new BonfireConfigError(path, \"must not be empty\");\n }\n\n return normalized;\n}\n\nfunction validateHostname(value: unknown, path: string) {\n if (typeof value !== \"string\") {\n throw new BonfireConfigError(path, \"must be a string\");\n }\n\n const normalized = value.toLowerCase();\n const labels = normalized.endsWith(\".\")\n ? normalized.slice(0, -1).split(\".\")\n : normalized.split(\".\");\n\n if (\n value.length === 0 ||\n value !== value.trim() ||\n value.length > MAX_HOSTNAME_LENGTH ||\n labels.some((label) => !HOSTNAME_LABEL_PATTERN.test(label))\n ) {\n throw new BonfireConfigError(\n path,\n \"must be a plain hostname without protocols, credentials, ports, paths, queries, fragments, or whitespace\",\n );\n }\n\n return normalized;\n}\n\nexport function parseHostname(value: unknown): string {\n return validateHostname(value, \"hostname\");\n}\n\nexport function defineConfig(input: BonfireConfigInput): BonfireConfig {\n const root = configRecord(input, \"config\");\n rejectConfigUnknownKeys(root, [\"appId\", \"name\", \"auth\", \"themes\"], \"config\");\n\n const appId = validateAppId(root.appId, \"config.appId\");\n const name = validateName(\n configRequiredString(root, \"name\", \"config\"),\n \"config.name\",\n );\n const auth = configRecord(root.auth, \"config.auth\");\n rejectConfigUnknownKeys(auth, [\"github\"], \"config.auth\");\n\n const github = configRecord(auth.github, \"config.auth.github\");\n rejectConfigUnknownKeys(github, [\"hostname\"], \"config.auth.github\");\n const hostname = validateHostname(\n configRequiredString(github, \"hostname\", \"config.auth.github\"),\n \"config.auth.github.hostname\",\n );\n\n let themes: ThemeRegistry | undefined;\n if (Object.hasOwn(root, \"themes\")) {\n try {\n themes = parseThemeRegistry(root.themes, \"config.themes\");\n } catch (error) {\n if (error instanceof ThemeValidationError) {\n throw new BonfireConfigError(error.path, error.reason);\n }\n throw error;\n }\n }\n\n const normalized = {\n appId,\n name,\n auth: {\n github: {\n hostname,\n },\n },\n ...(themes === undefined ? {} : { themes }),\n } satisfies BonfireConfig;\n\n return deepFreeze(normalized);\n}\n\nexport function getSessionCookieName(appId: string) {\n return `${SESSION_COOKIE_PREFIX}${validateAppId(appId, \"appId\")}`;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,YAAY,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAIxC;CACF;AAwDD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO;;;;EAyBlD"}
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,YAAY,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAIxC;CACF;AAwDD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO;;;;EAyBlD","sourcesContent":["import { asRecord, findUnknownKey } from \"./internal/utils.js\";\n\nexport type BonfireIdentity = {\n login: string;\n name: string | null;\n avatar_url: string;\n};\n\nexport class BonfireIdentityError extends Error {\n readonly path: string;\n\n constructor(path: string, message: string) {\n super(`Invalid Bonfire identity at ${path}: ${message}`);\n this.name = \"BonfireIdentityError\";\n this.path = path;\n }\n}\n\nfunction parseLogin(value: unknown) {\n if (typeof value !== \"string\") {\n throw new BonfireIdentityError(\"identity.login\", \"must be a string\");\n }\n\n if (value.length === 0 || /\\s/.test(value)) {\n throw new BonfireIdentityError(\n \"identity.login\",\n \"must be a nonempty GitHub login\",\n );\n }\n\n return value;\n}\n\nfunction parseName(record: Record<string, unknown>) {\n if (!Object.hasOwn(record, \"name\")) return null;\n\n const value = record.name;\n if (value === null) return null;\n if (typeof value !== \"string\") {\n throw new BonfireIdentityError(\"identity.name\", \"must be a string or null\");\n }\n\n return value;\n}\n\nfunction parseAvatarUrl(value: unknown) {\n if (\n typeof value !== \"string\" ||\n value.length === 0 ||\n value !== value.trim()\n ) {\n throw new BonfireIdentityError(\n \"identity.avatar_url\",\n \"must be a valid HTTP(S) URL\",\n );\n }\n\n try {\n const url = new URL(value);\n if (url.protocol !== \"http:\" && url.protocol !== \"https:\") {\n throw new Error(\"unsupported protocol\");\n }\n } catch {\n throw new BonfireIdentityError(\n \"identity.avatar_url\",\n \"must be a valid HTTP(S) URL\",\n );\n }\n\n return value;\n}\n\nexport function parseBonfireIdentity(value: unknown) {\n const record = asRecord(value);\n if (record === null) {\n throw new BonfireIdentityError(\"identity\", \"must be an object\");\n }\n\n const unknownKey = findUnknownKey(record, [\"login\", \"name\", \"avatar_url\"]);\n if (unknownKey) {\n throw new BonfireIdentityError(\n `identity.${unknownKey}`,\n \"is not supported\",\n );\n }\n\n const login = parseLogin(record.login);\n const name = parseName(record);\n const avatar_url = parseAvatarUrl(record.avatar_url);\n\n const identity = {\n login,\n name,\n avatar_url,\n } satisfies BonfireIdentity;\n\n return identity;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAQ/D,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACpC,IAAI,CAAS;IAEtB,YAAY,IAAY,EAAE,OAAe;QACvC,KAAK,CAAC,+BAA+B,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;QACzD,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,IAAI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AAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,oBAAoB,CAC5B,qBAAqB,EACrB,6BAA6B,CAC9B,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC/B,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,oBAAoB,CAAC,UAAU,EAAE,mBAAmB,CAAC,CAAC;IAClE,CAAC;IAED,MAAM,UAAU,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IAC3E,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,IAAI,oBAAoB,CAC5B,YAAY,UAAU,EAAE,EACxB,kBAAkB,CACnB,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvC,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IAC/B,MAAM,UAAU,GAAG,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAErD,MAAM,QAAQ,GAAG;QACf,KAAK;QACL,IAAI;QACJ,UAAU;KACe,CAAC;IAE5B,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { asRecord, findUnknownKey } from \"./internal/utils.js\";\n\nexport type BonfireIdentity = {\n login: string;\n name: string | null;\n avatar_url: string;\n};\n\nexport class BonfireIdentityError extends Error {\n readonly path: string;\n\n constructor(path: string, message: string) {\n super(`Invalid Bonfire identity at ${path}: ${message}`);\n this.name = \"BonfireIdentityError\";\n this.path = path;\n }\n}\n\nfunction parseLogin(value: unknown) {\n if (typeof value !== \"string\") {\n throw new BonfireIdentityError(\"identity.login\", \"must be a string\");\n }\n\n if (value.length === 0 || /\\s/.test(value)) {\n throw new BonfireIdentityError(\n \"identity.login\",\n \"must be a nonempty GitHub login\",\n );\n }\n\n return value;\n}\n\nfunction parseName(record: Record<string, unknown>) {\n if (!Object.hasOwn(record, \"name\")) return null;\n\n const value = record.name;\n if (value === null) return null;\n if (typeof value !== \"string\") {\n throw new BonfireIdentityError(\"identity.name\", \"must be a string or null\");\n }\n\n return value;\n}\n\nfunction parseAvatarUrl(value: unknown) {\n if (\n typeof value !== \"string\" ||\n value.length === 0 ||\n value !== value.trim()\n ) {\n throw new BonfireIdentityError(\n \"identity.avatar_url\",\n \"must be a valid HTTP(S) URL\",\n );\n }\n\n try {\n const url = new URL(value);\n if (url.protocol !== \"http:\" && url.protocol !== \"https:\") {\n throw new Error(\"unsupported protocol\");\n }\n } catch {\n throw new BonfireIdentityError(\n \"identity.avatar_url\",\n \"must be a valid HTTP(S) URL\",\n );\n }\n\n return value;\n}\n\nexport function parseBonfireIdentity(value: unknown) {\n const record = asRecord(value);\n if (record === null) {\n throw new BonfireIdentityError(\"identity\", \"must be an object\");\n }\n\n const unknownKey = findUnknownKey(record, [\"login\", \"name\", \"avatar_url\"]);\n if (unknownKey) {\n throw new BonfireIdentityError(\n `identity.${unknownKey}`,\n \"is not supported\",\n );\n }\n\n const login = parseLogin(record.login);\n const name = parseName(record);\n const avatar_url = parseAvatarUrl(record.avatar_url);\n\n const identity = {\n login,\n name,\n avatar_url,\n } satisfies BonfireIdentity;\n\n return identity;\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1,10 +1,12 @@
1
1
  export { defineConfig, getSessionCookieName, parseHostname, type BonfireConfig, type BonfireConfigInput, } from "./config.js";
2
+ export { COLOR_SCHEMES, createDefaultPrototypeTheme, parsePrototypeTheme, parsePrototypeThemeSelection, parseThemeRegistry, ThemeValidationError, type ColorScheme, type PrototypeTheme, type PrototypeThemeSelection, type ThemeDefinition, type ThemeRegistry, } from "./theme.js";
2
3
  export { parseBonfireIdentity, BonfireIdentityError, type BonfireIdentity, } from "./identity.js";
4
+ export { AgentInputError, parseAgent, parseAgentCommand, parseOpenInAgentInput, parseOpenInClaudeCodeInput, parseTerminalApp, parseUserPreferences, type Agent, type AgentActionError, type AgentActionErrorCode, type AgentActionResult, type AgentCommand, type AgentLaunchValue, type OpenInAgentInput, type OpenInClaudeCodeInput, type TerminalApp, type UserPreferences, } from "./agent.js";
3
5
  export type { GitHubCliLoginPageModel } from "./auth-model.js";
4
6
  export { definePrototypeRef, getPrototypeUrl, parsePrototypePath, PrototypeRefError, slugifyPrototypeTitle, } from "./prototype-ref.js";
5
7
  export type { PrototypeRef } from "./prototype-ref.js";
6
- export { definePrototypeSummary, parsePrototypeMetadata, PrototypeMetadataError, type PrototypeMetadata, type PrototypeSummary, } from "./prototype-metadata.js";
8
+ export { definePrototypeSummary, parsePrototypeMetadata, PrototypeMetadataError, type PrototypeMetadata, type PrototypeSummary, type PrototypeMetadataParseOptions, } from "./prototype-metadata.js";
7
9
  export { filterPrototypes, getPrototypeAuthorOptions, sortPrototypes, type PrototypeAuthorOption, type PrototypeAuthorSelection, type PrototypeCatalogQuery, type PrototypeDashboardModel, type PrototypeSort, } from "./prototype-catalog.js";
8
- export { AutomaticBranchSwitchSettingError, isLifecycleFailure, isLifecycleSuccess, parseAutomaticBranchSwitchSetting, lifecycleFailure, lifecycleSuccess, type AutomaticBranchSwitchMode, type BranchPreparationStatus, type BranchPreparationValue, type CreatePrototypeValue, type DirtyObservationStatus, type DirtyObservationValue, type DiscardPrototypeValue, type DuplicatePrototypeValue, type LifecycleError, type LifecycleErrorCode, type LifecyclePrototypeValue, type LifecycleRemoteStatus, type LifecycleResult, type SavePrototypeValue, } from "./lifecycle.js";
9
- export { LifecycleInputError, parseCreatePrototypeInput, parseDiscardPrototypeInput, parseDuplicatePrototypeInput, parsePrototypeCommandInput, parseSavePrototypeInput, PROTOTYPE_DESCRIPTION_MAX_CODE_POINTS, PROTOTYPE_TITLE_MAX_CODE_POINTS, type CreatePrototypeInput, type DiscardPrototypeInput, type DuplicatePrototypeInput, type PrototypeCommandInput, type SavePrototypeInput, } from "./lifecycle-input.js";
10
+ export { AutomaticBranchSwitchSettingError, DEPLOYMENT_READY_STATES, isDeploymentReadyState, isLifecycleFailure, isLifecycleSuccess, parseAutomaticBranchSwitchSetting, lifecycleFailure, lifecycleSuccess, type AutomaticBranchSwitchMode, type DeploymentReadyState, type DeploymentValue, type DeploymentWarningCode, type BranchPreparationStatus, type BranchPreparationValue, type CreatePrototypeValue, type DeletePrototypeValue, type DirtyObservationStatus, type DirtyObservationValue, type DiscardPrototypeValue, type DuplicatePrototypeValue, type EditPrototypeValue, type LifecycleError, type LifecycleErrorCode, type LifecyclePrototypeValue, type LifecycleRemoteStatus, type LifecycleResult, type SavePrototypeValue, } from "./lifecycle.js";
11
+ export { LifecycleInputError, parseCreatePrototypeInput, parseDuplicatePrototypeInput, parseEditPrototypeInput, parsePrototypeCommandInput, PROTOTYPE_DESCRIPTION_MAX_CODE_POINTS, PROTOTYPE_TITLE_MAX_CODE_POINTS, type CreatePrototypeInput, type DuplicatePrototypeInput, type EditPrototypeInput, type PrototypeCommandInput, } from "./lifecycle-input.js";
10
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,aAAa,EACb,KAAK,aAAa,EAClB,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,eAAe,GACrB,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,YAAY,EAAE,M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AChB,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,kBAAkB,GACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,4BAA4B,EAC5B,uBAAuB,EACvB,0BAA0B,EAC1B,qCAAqC,EACrC,+BAA+B,EAC/B,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,GAC3B,MAAM,sBAAsB,CAAC","sourcesContent":["export {\n defineConfig,\n getSessionCookieName,\n parseHostname,\n type BonfireConfig,\n type BonfireConfigInput,\n} from \"./config.js\";\nexport {\n COLOR_SCHEMES,\n createDefaultPrototypeTheme,\n parsePrototypeTheme,\n parsePrototypeThemeSelection,\n parseThemeRegistry,\n ThemeValidationError,\n type ColorScheme,\n type PrototypeTheme,\n type PrototypeThemeSelection,\n type ThemeDefinition,\n type ThemeRegistry,\n} from \"./theme.js\";\nexport {\n parseBonfireIdentity,\n BonfireIdentityError,\n type BonfireIdentity,\n} from \"./identity.js\";\nexport {\n AgentInputError,\n parseAgent,\n parseAgentCommand,\n parseOpenInAgentInput,\n parseOpenInClaudeCodeInput,\n parseTerminalApp,\n parseUserPreferences,\n type Agent,\n type AgentActionError,\n type AgentActionErrorCode,\n type AgentActionResult,\n type AgentCommand,\n type AgentLaunchValue,\n type OpenInAgentInput,\n type OpenInClaudeCodeInput,\n type TerminalApp,\n type UserPreferences,\n} from \"./agent.js\";\nexport type { GitHubCliLoginPageModel } from \"./auth-model.js\";\nexport {\n definePrototypeRef,\n getPrototypeUrl,\n parsePrototypePath,\n PrototypeRefError,\n slugifyPrototypeTitle,\n} from \"./prototype-ref.js\";\nexport type { PrototypeRef } from \"./prototype-ref.js\";\nexport {\n definePrototypeSummary,\n parsePrototypeMetadata,\n PrototypeMetadataError,\n type PrototypeMetadata,\n type PrototypeSummary,\n type PrototypeMetadataParseOptions,\n} from \"./prototype-metadata.js\";\nexport {\n filterPrototypes,\n getPrototypeAuthorOptions,\n sortPrototypes,\n type PrototypeAuthorOption,\n type PrototypeAuthorSelection,\n type PrototypeCatalogQuery,\n type PrototypeDashboardModel,\n type PrototypeSort,\n} from \"./prototype-catalog.js\";\nexport {\n AutomaticBranchSwitchSettingError,\n DEPLOYMENT_READY_STATES,\n isDeploymentReadyState,\n isLifecycleFailure,\n isLifecycleSuccess,\n parseAutomaticBranchSwitchSetting,\n lifecycleFailure,\n lifecycleSuccess,\n type AutomaticBranchSwitchMode,\n type DeploymentReadyState,\n type DeploymentValue,\n type DeploymentWarningCode,\n type BranchPreparationStatus,\n type BranchPreparationValue,\n type CreatePrototypeValue,\n type DeletePrototypeValue,\n type DirtyObservationStatus,\n type DirtyObservationValue,\n type DiscardPrototypeValue,\n type DuplicatePrototypeValue,\n type EditPrototypeValue,\n type LifecycleError,\n type LifecycleErrorCode,\n type LifecyclePrototypeValue,\n type LifecycleRemoteStatus,\n type LifecycleResult,\n type SavePrototypeValue,\n} from \"./lifecycle.js\";\nexport {\n LifecycleInputError,\n parseCreatePrototypeInput,\n parseDuplicatePrototypeInput,\n parseEditPrototypeInput,\n parsePrototypeCommandInput,\n PROTOTYPE_DESCRIPTION_MAX_CODE_POINTS,\n PROTOTYPE_TITLE_MAX_CODE_POINTS,\n type CreatePrototypeInput,\n type DuplicatePrototypeInput,\n type EditPrototypeInput,\n type PrototypeCommandInput,\n} from \"./lifecycle-input.js\";\n"]}
package/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  export { defineConfig, getSessionCookieName, parseHostname, } from "./config.js";
2
+ export { COLOR_SCHEMES, createDefaultPrototypeTheme, parsePrototypeTheme, parsePrototypeThemeSelection, parseThemeRegistry, ThemeValidationError, } from "./theme.js";
2
3
  export { parseBonfireIdentity, BonfireIdentityError, } from "./identity.js";
4
+ export { AgentInputError, parseAgent, parseAgentCommand, parseOpenInAgentInput, parseOpenInClaudeCodeInput, parseTerminalApp, parseUserPreferences, } from "./agent.js";
3
5
  export { definePrototypeRef, getPrototypeUrl, parsePrototypePath, PrototypeRefError, slugifyPrototypeTitle, } from "./prototype-ref.js";
4
6
  export { definePrototypeSummary, parsePrototypeMetadata, PrototypeMetadataError, } from "./prototype-metadata.js";
5
7
  export { filterPrototypes, getPrototypeAuthorOptions, sortPrototypes, } from "./prototype-catalog.js";
6
- export { AutomaticBranchSwitchSettingError, isLifecycleFailure, isLifecycleSuccess, parseAutomaticBranchSwitchSetting, lifecycleFailure, lifecycleSuccess, } from "./lifecycle.js";
7
- export { LifecycleInputError, parseCreatePrototypeInput, parseDiscardPrototypeInput, parseDuplicatePrototypeInput, parsePrototypeCommandInput, parseSavePrototypeInput, PROTOTYPE_DESCRIPTION_MAX_CODE_POINTS, PROTOTYPE_TITLE_MAX_CODE_POINTS, } from "./lifecycle-input.js";
8
+ export { AutomaticBranchSwitchSettingError, DEPLOYMENT_READY_STATES, isDeploymentReadyState, isLifecycleFailure, isLifecycleSuccess, parseAutomaticBranchSwitchSetting, lifecycleFailure, lifecycleSuccess, } from "./lifecycle.js";
9
+ export { LifecycleInputError, parseCreatePrototypeInput, parseDuplicatePrototypeInput, parseEditPrototypeInput, parsePrototypeCommandInput, PROTOTYPE_DESCRIPTION_MAX_CODE_POINTS, PROTOTYPE_TITLE_MAX_CODE_POINTS, } from "./lifecycle-input.js";
8
10
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,aAAa,GAGd,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GAErB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,GAGvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,gBAAgB,EAChB,yBAAyB,EACzB,cAAc,GAMf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,iCAAiC,EACjC,kBAAkB,EAClB,kBAAkB,EAClB,iCAAiC,EACjC,gBAAgB,EAChB,gBAAgB,GAejB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,EAC1B,uBAAuB,EACvB,qCAAqC,EACrC,+BAA+B,GAMhC,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,aAAa,GAGd,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,aAAa,EACb,2BAA2B,EAC3B,mBAAmB,EACnB,4BAA4B,EAC5B,kBAAkB,EAClB,oBAAoB,GAMrB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GAErB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EACrB,0BAA0B,EAC1B,gBAAgB,EAChB,oBAAoB,GAWrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,GAIvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,gBAAgB,EAChB,yBAAyB,EACzB,cAAc,GAMf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,iCAAiC,EACjC,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,EAClB,iCAAiC,EACjC,gBAAgB,EAChB,gBAAgB,GAoBjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,4BAA4B,EAC5B,uBAAuB,EACvB,0BAA0B,EAC1B,qCAAqC,EACrC,+BAA+B,GAKhC,MAAM,sBAAsB,CAAC","sourcesContent":["export {\n defineConfig,\n getSessionCookieName,\n parseHostname,\n type BonfireConfig,\n type BonfireConfigInput,\n} from \"./config.js\";\nexport {\n COLOR_SCHEMES,\n createDefaultPrototypeTheme,\n parsePrototypeTheme,\n parsePrototypeThemeSelection,\n parseThemeRegistry,\n ThemeValidationError,\n type ColorScheme,\n type PrototypeTheme,\n type PrototypeThemeSelection,\n type ThemeDefinition,\n type ThemeRegistry,\n} from \"./theme.js\";\nexport {\n parseBonfireIdentity,\n BonfireIdentityError,\n type BonfireIdentity,\n} from \"./identity.js\";\nexport {\n AgentInputError,\n parseAgent,\n parseAgentCommand,\n parseOpenInAgentInput,\n parseOpenInClaudeCodeInput,\n parseTerminalApp,\n parseUserPreferences,\n type Agent,\n type AgentActionError,\n type AgentActionErrorCode,\n type AgentActionResult,\n type AgentCommand,\n type AgentLaunchValue,\n type OpenInAgentInput,\n type OpenInClaudeCodeInput,\n type TerminalApp,\n type UserPreferences,\n} from \"./agent.js\";\nexport type { GitHubCliLoginPageModel } from \"./auth-model.js\";\nexport {\n definePrototypeRef,\n getPrototypeUrl,\n parsePrototypePath,\n PrototypeRefError,\n slugifyPrototypeTitle,\n} from \"./prototype-ref.js\";\nexport type { PrototypeRef } from \"./prototype-ref.js\";\nexport {\n definePrototypeSummary,\n parsePrototypeMetadata,\n PrototypeMetadataError,\n type PrototypeMetadata,\n type PrototypeSummary,\n type PrototypeMetadataParseOptions,\n} from \"./prototype-metadata.js\";\nexport {\n filterPrototypes,\n getPrototypeAuthorOptions,\n sortPrototypes,\n type PrototypeAuthorOption,\n type PrototypeAuthorSelection,\n type PrototypeCatalogQuery,\n type PrototypeDashboardModel,\n type PrototypeSort,\n} from \"./prototype-catalog.js\";\nexport {\n AutomaticBranchSwitchSettingError,\n DEPLOYMENT_READY_STATES,\n isDeploymentReadyState,\n isLifecycleFailure,\n isLifecycleSuccess,\n parseAutomaticBranchSwitchSetting,\n lifecycleFailure,\n lifecycleSuccess,\n type AutomaticBranchSwitchMode,\n type DeploymentReadyState,\n type DeploymentValue,\n type DeploymentWarningCode,\n type BranchPreparationStatus,\n type BranchPreparationValue,\n type CreatePrototypeValue,\n type DeletePrototypeValue,\n type DirtyObservationStatus,\n type DirtyObservationValue,\n type DiscardPrototypeValue,\n type DuplicatePrototypeValue,\n type EditPrototypeValue,\n type LifecycleError,\n type LifecycleErrorCode,\n type LifecyclePrototypeValue,\n type LifecycleRemoteStatus,\n type LifecycleResult,\n type SavePrototypeValue,\n} from \"./lifecycle.js\";\nexport {\n LifecycleInputError,\n parseCreatePrototypeInput,\n parseDuplicatePrototypeInput,\n parseEditPrototypeInput,\n parsePrototypeCommandInput,\n PROTOTYPE_DESCRIPTION_MAX_CODE_POINTS,\n PROTOTYPE_TITLE_MAX_CODE_POINTS,\n type CreatePrototypeInput,\n type DuplicatePrototypeInput,\n type EditPrototypeInput,\n type PrototypeCommandInput,\n} from \"./lifecycle-input.js\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/internal/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,GACjE,CAAC,GACD,CAAC,SAAS,SAAS,OAAO,EAAE,GAC1B,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GACtC,CAAC,SAAS,MAAM,GACd;IAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAC/C,CAAC,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/internal/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,GACjE,CAAC,GACD,CAAC,SAAS,SAAS,OAAO,EAAE,GAC1B,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GACtC,CAAC,SAAS,MAAM,GACd;IAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAC/C,CAAC,CAAC","sourcesContent":["export type DeepReadonly<T> = T extends (...args: never[]) => unknown\n ? T\n : T extends readonly unknown[]\n ? ReadonlyArray<DeepReadonly<T[number]>>\n : T extends object\n ? { readonly [K in keyof T]: DeepReadonly<T[K]> }\n : T;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/internal/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/internal/types.ts"],"names":[],"mappings":"","sourcesContent":["export type DeepReadonly<T> = T extends (...args: never[]) => unknown\n ? T\n : T extends readonly unknown[]\n ? ReadonlyArray<DeepReadonly<T[number]>>\n : T extends object\n ? { readonly [K in keyof T]: DeepReadonly<T[K]> }\n : T;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/internal/utils.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAE/D;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,GAAG,IAAI,CAE7D;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,SAAS,MAAM,EAAE,GAC7B,MAAM,GAAG,SAAS,CAGpB;AAED,MAAM,MAAM,oBAAoB,GAC5B;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GACrB;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACrC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvC,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,aAAa,EACrB,GAAG,EAAE,MAAM,GACV,oBAAoB,CAOtB;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAOzC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/internal/utils.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAE/D;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,GAAG,IAAI,CAE7D;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,SAAS,MAAM,EAAE,GAC7B,MAAM,GAAG,SAAS,CAGpB;AAED,MAAM,MAAM,oBAAoB,GAC5B;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GACrB;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACrC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvC,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,aAAa,EACrB,GAAG,EAAE,MAAM,GACV,oBAAoB,CAOtB;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAOzC","sourcesContent":["export type UnknownRecord = Record<string, unknown>;\n\nexport function isRecord(value: unknown): value is UnknownRecord {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nexport function asRecord(value: unknown): UnknownRecord | null {\n return isRecord(value) ? value : null;\n}\n\nexport function findUnknownKey(\n record: UnknownRecord,\n allowedKeys: readonly string[],\n): string | undefined {\n const allowed = new Set(allowedKeys);\n return Object.keys(record).find((key) => !allowed.has(key));\n}\n\nexport type RequiredStringResult =\n | { status: \"missing\" }\n | { status: \"invalid\"; value: unknown }\n | { status: \"valid\"; value: string };\n\nexport function readRequiredString(\n record: UnknownRecord,\n key: string,\n): RequiredStringResult {\n if (!Object.hasOwn(record, key)) return { status: \"missing\" };\n\n const value = record[key];\n return typeof value === \"string\"\n ? { status: \"valid\", value }\n : { status: \"invalid\", value };\n}\n\nexport function deepFreeze<T>(value: T): T {\n if (typeof value !== \"object\" || value === null) return value;\n if (Object.isFrozen(value)) return value;\n\n Object.freeze(value);\n for (const child of Object.values(value)) deepFreeze(child);\n return value;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/internal/utils.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAA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CAAC;IAEzC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACrB,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;QAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IAC5D,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["export type UnknownRecord = Record<string, unknown>;\n\nexport function isRecord(value: unknown): value is UnknownRecord {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nexport function asRecord(value: unknown): UnknownRecord | null {\n return isRecord(value) ? value : null;\n}\n\nexport function findUnknownKey(\n record: UnknownRecord,\n allowedKeys: readonly string[],\n): string | undefined {\n const allowed = new Set(allowedKeys);\n return Object.keys(record).find((key) => !allowed.has(key));\n}\n\nexport type RequiredStringResult =\n | { status: \"missing\" }\n | { status: \"invalid\"; value: unknown }\n | { status: \"valid\"; value: string };\n\nexport function readRequiredString(\n record: UnknownRecord,\n key: string,\n): RequiredStringResult {\n if (!Object.hasOwn(record, key)) return { status: \"missing\" };\n\n const value = record[key];\n return typeof value === \"string\"\n ? { status: \"valid\", value }\n : { status: \"invalid\", value };\n}\n\nexport function deepFreeze<T>(value: T): T {\n if (typeof value !== \"object\" || value === null) return value;\n if (Object.isFrozen(value)) return value;\n\n Object.freeze(value);\n for (const child of Object.values(value)) deepFreeze(child);\n return value;\n}\n"]}
@@ -1,28 +1,33 @@
1
1
  import { type PrototypeRef } from "./prototype-ref.js";
2
+ import { type PrototypeTheme, type ThemeRegistry } from "./theme.js";
2
3
  export declare const PROTOTYPE_TITLE_MAX_CODE_POINTS = 200;
3
4
  export declare const PROTOTYPE_DESCRIPTION_MAX_CODE_POINTS = 2000;
4
5
  export type CreatePrototypeInput = {
5
6
  title: string;
6
7
  description: string | null;
8
+ theme?: PrototypeTheme;
7
9
  };
8
10
  export type DuplicatePrototypeInput = {
9
11
  source: PrototypeRef;
10
12
  title: string;
11
13
  description: string | null;
12
14
  };
15
+ export type EditPrototypeInput = {
16
+ ref: PrototypeRef;
17
+ title: string;
18
+ description: string | null;
19
+ theme?: PrototypeTheme;
20
+ };
13
21
  export type PrototypeCommandInput = {
14
22
  ref: PrototypeRef;
15
23
  };
16
- export type SavePrototypeInput = PrototypeCommandInput;
17
- export type DiscardPrototypeInput = PrototypeCommandInput;
18
24
  export declare class LifecycleInputError extends Error {
19
25
  readonly code: "invalid-input";
20
26
  readonly path: string;
21
27
  constructor(path: string);
22
28
  }
23
- export declare function parseCreatePrototypeInput(value: unknown): CreatePrototypeInput;
29
+ export declare function parseCreatePrototypeInput(value: unknown, themeRegistry?: ThemeRegistry): CreatePrototypeInput;
24
30
  export declare function parseDuplicatePrototypeInput(value: unknown): DuplicatePrototypeInput;
31
+ export declare function parseEditPrototypeInput(value: unknown, themeRegistry?: ThemeRegistry): EditPrototypeInput;
25
32
  export declare function parsePrototypeCommandInput(value: unknown): PrototypeCommandInput;
26
- export declare function parseSavePrototypeInput(value: unknown): SavePrototypeInput;
27
- export declare function parseDiscardPrototypeInput(value: unknown): DiscardPrototypeInput;
28
33
  //# sourceMappingURL=lifecycle-input.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lifecycle-input.d.ts","sourceRoot":"","sources":["../src/lifecycle-input.ts"],"names":[],"mappings":"AAMA,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,oBAAoB,CAAC;AAE5B,eAAO,MAAM,+BAA+B,MAAM,CAAC;AACnD,eAAO,MAAM,qCAAqC,OAAQ,CAAC;AAE3D,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,GAAG,EAAE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BAAkB,GAAG;IAC/B,GAAG,EAAE,YAAY,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,CAAC,EAAE,cAAc,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,GAAG,EAAE,YAAY,CAAC;CACnB,CAAC;AAEF,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,IAAI,EAAG,eAAe,CAAU;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,YAAY,IAAI,EAAE,MAAM,EAIvB;CACF;AAwGD,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,OAAO,EACd,aAAa,CAAC,EAAE,aAAa,GAC5B,oBAAoB,CActB;AAED,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,OAAO,GACb,uBAAuB,CAazB;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,OAAO,EACd,aAAa,CAAC,EAAE,aAAa,GAC5B,kBAAkB,CAepB;AAED,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,GACb,qBAAqB,CAKvB","sourcesContent":["import {\n asRecord,\n deepFreeze,\n findUnknownKey,\n readRequiredString,\n} from \"./internal/utils.js\";\nimport {\n definePrototypeRef,\n PrototypeRefError,\n slugifyPrototypeTitle,\n type PrototypeRef,\n} from \"./prototype-ref.js\";\nimport {\n parsePrototypeTheme,\n ThemeValidationError,\n type PrototypeTheme,\n type ThemeRegistry,\n} from \"./theme.js\";\n\nexport const PROTOTYPE_TITLE_MAX_CODE_POINTS = 200;\nexport const PROTOTYPE_DESCRIPTION_MAX_CODE_POINTS = 2_000;\n\nexport type CreatePrototypeInput = {\n title: string;\n description: string | null;\n theme?: PrototypeTheme;\n};\n\nexport type DuplicatePrototypeInput = {\n source: PrototypeRef;\n title: string;\n description: string | null;\n};\n\nexport type EditPrototypeInput = {\n ref: PrototypeRef;\n title: string;\n description: string | null;\n theme?: PrototypeTheme;\n};\n\nexport type PrototypeCommandInput = {\n ref: PrototypeRef;\n};\n\nexport class LifecycleInputError extends Error {\n readonly code = \"invalid-input\" as const;\n readonly path: string;\n\n constructor(path: string) {\n super(\"Invalid lifecycle input\");\n this.name = \"LifecycleInputError\";\n this.path = path;\n }\n}\n\nfunction requireRecord(value: unknown, path: string) {\n const record = asRecord(value);\n if (record === null) throw new LifecycleInputError(path);\n return record;\n}\n\nfunction rejectUnknownKey(\n record: Record<string, unknown>,\n allowedKeys: readonly string[],\n path: string,\n) {\n if (findUnknownKey(record, allowedKeys)) {\n throw new LifecycleInputError(path);\n }\n}\n\nfunction parseTitle(record: Record<string, unknown>) {\n const result = readRequiredString(record, \"title\");\n if (result.status !== \"valid\") {\n throw new LifecycleInputError(\"title\");\n }\n\n const title = result.value.trim();\n if (\n title.length === 0 ||\n Array.from(title).length > PROTOTYPE_TITLE_MAX_CODE_POINTS ||\n slugifyPrototypeTitle(title) === null\n ) {\n throw new LifecycleInputError(\"title\");\n }\n\n return title;\n}\n\nfunction parseDescription(record: Record<string, unknown>) {\n if (!Object.hasOwn(record, \"description\") || record.description === null) {\n return null;\n }\n\n if (typeof record.description !== \"string\") {\n throw new LifecycleInputError(\"description\");\n }\n\n const description = record.description.trim();\n if (Array.from(description).length > PROTOTYPE_DESCRIPTION_MAX_CODE_POINTS) {\n throw new LifecycleInputError(\"description\");\n }\n\n return description.length === 0 ? null : description;\n}\n\nfunction parseRef(\n record: Record<string, unknown>,\n key: \"ref\" | \"source\",\n): PrototypeRef {\n if (!Object.hasOwn(record, key)) {\n throw new LifecycleInputError(key);\n }\n\n try {\n return definePrototypeRef(record[key]);\n } catch (error) {\n if (error instanceof PrototypeRefError) {\n throw new LifecycleInputError(key);\n }\n throw error;\n }\n}\n\nfunction parseSource(record: Record<string, unknown>): PrototypeRef {\n return parseRef(record, \"source\");\n}\n\nfunction parseThemeField(\n record: Record<string, unknown>,\n themeRegistry: ThemeRegistry | undefined,\n): PrototypeTheme | undefined {\n if (!Object.hasOwn(record, \"theme\") || record.theme === undefined) {\n return undefined;\n }\n\n if (!themeRegistry) {\n // Theme input has nothing to validate against when the instance has no\n // configured registry; reject rather than silently ignoring it.\n throw new LifecycleInputError(\"theme\");\n }\n\n try {\n // `theme` is already the normalized `PrototypeTheme` shape (the same\n // shape stored in prototype metadata). Callers that offer a simplified\n // authoring UI expand a `PrototypeThemeSelection` into this shape with\n // `parsePrototypeThemeSelection` before submitting it, keeping this\n // parse idempotent for callers that re-validate already-parsed input.\n return parsePrototypeTheme(record.theme, \"theme\", themeRegistry);\n } catch (error) {\n if (error instanceof ThemeValidationError) {\n throw new LifecycleInputError(error.path);\n }\n throw error;\n }\n}\n\nexport function parseCreatePrototypeInput(\n value: unknown,\n themeRegistry?: ThemeRegistry,\n): CreatePrototypeInput {\n const record = requireRecord(value, \"createPrototypeInput\");\n rejectUnknownKey(\n record,\n [\"title\", \"description\", \"theme\"],\n \"createPrototypeInput\",\n );\n const theme = parseThemeField(record, themeRegistry);\n\n return deepFreeze({\n title: parseTitle(record),\n description: parseDescription(record),\n ...(theme === undefined ? {} : { theme }),\n });\n}\n\nexport function parseDuplicatePrototypeInput(\n value: unknown,\n): DuplicatePrototypeInput {\n const record = requireRecord(value, \"duplicatePrototypeInput\");\n rejectUnknownKey(\n record,\n [\"source\", \"title\", \"description\"],\n \"duplicatePrototypeInput\",\n );\n\n return deepFreeze({\n source: parseSource(record),\n title: parseTitle(record),\n description: parseDescription(record),\n });\n}\n\nexport function parseEditPrototypeInput(\n value: unknown,\n themeRegistry?: ThemeRegistry,\n): EditPrototypeInput {\n const record = requireRecord(value, \"editPrototypeInput\");\n rejectUnknownKey(\n record,\n [\"ref\", \"title\", \"description\", \"theme\"],\n \"editPrototypeInput\",\n );\n const theme = parseThemeField(record, themeRegistry);\n\n return deepFreeze({\n ref: parseRef(record, \"ref\"),\n title: parseTitle(record),\n description: parseDescription(record),\n ...(theme === undefined ? {} : { theme }),\n });\n}\n\nexport function parsePrototypeCommandInput(\n value: unknown,\n): PrototypeCommandInput {\n const record = requireRecord(value, \"prototypeCommandInput\");\n rejectUnknownKey(record, [\"ref\"], \"prototypeCommandInput\");\n\n return deepFreeze({ ref: parseRef(record, \"ref\") });\n}\n"]}