@frontera-sdk/cli 0.1.0 → 1.43.5
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/package.json +4 -2
- package/src/api/apps-api.ts +13 -1
- package/src/api/automation-api.ts +129 -1
- package/src/api/blueprint-authoring-api.ts +574 -0
- package/src/api/dataset-api.ts +199 -0
- package/src/api/platform-api.ts +300 -0
- package/src/automation-template.ts +224 -0
- package/src/blueprint/compile.ts +371 -0
- package/src/blueprint/dataset-revision.ts +33 -0
- package/src/blueprint/diff.ts +223 -0
- package/src/blueprint/model.ts +227 -0
- package/src/blueprint/projection.ts +254 -0
- package/src/blueprint/render.ts +73 -0
- package/src/blueprint/scaffold.ts +79 -0
- package/src/blueprint/tree.ts +121 -0
- package/src/commands/agent/index-commands.ts +87 -1
- package/src/commands/app/deploy.ts +43 -3
- package/src/commands/app/init.ts +23 -1
- package/src/commands/app/pull.ts +12 -35
- package/src/commands/automation/index-commands.ts +42 -1
- package/src/commands/automation/init.ts +52 -0
- package/src/commands/automation/project-root.ts +58 -0
- package/src/commands/automation/pull.ts +124 -0
- package/src/commands/automation/run.ts +271 -0
- package/src/commands/blueprint/authoring.ts +410 -0
- package/src/commands/blueprint/bind.ts +228 -0
- package/src/commands/blueprint/declarative.ts +1052 -0
- package/src/commands/blueprint/grants.ts +164 -0
- package/src/commands/dataset/index-commands.ts +431 -0
- package/src/commands/knowledge/index-commands.ts +278 -27
- package/src/commands/knowledge/upload-batch.ts +146 -0
- package/src/commands/knowledge/upload-plan.ts +127 -0
- package/src/commands/login.ts +49 -11
- package/src/commands/pack/index-commands.ts +373 -0
- package/src/commands/registry.ts +19 -2
- package/src/commands/secret/index-commands.ts +195 -0
- package/src/commands/skill/bundle-commands.ts +327 -0
- package/src/commands/skill/index-commands.ts +36 -42
- package/src/commands/skill/resolve.ts +34 -0
- package/src/dev-env.ts +114 -0
- package/src/flag-help.ts +34 -0
- package/src/harness.ts +30 -3
- package/src/main.ts +10 -3
- package/src/render-evidence.ts +152 -0
- package/src/template.ts +4 -0
- package/src/untar.ts +44 -0
- package/src/vendor/sdk-sources.json +13 -11
- package/src/commands/blueprint/reserved.ts +0 -40
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": {
|
|
3
3
|
"frontera/core/LICENSE": "\n Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n APPENDIX: How to apply the Apache License to your work.\n\n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n\n Copyright 2026 Sebati\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n",
|
|
4
|
+
"frontera/core/create-frontera-app.tsx": "import {\n Component,\n StrictMode,\n createContext,\n useContext,\n useEffect,\n useState,\n type ErrorInfo,\n type ReactNode,\n} from 'react'\nimport { createRoot } from 'react-dom/client'\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query'\n\nimport { connectToHost, type BridgeSession } from './bridge-client'\nimport type { BridgeInit } from './bridge-protocol'\nimport { FronteraClient } from './client'\nimport { applyHostTheme } from './theme'\n\n/**\n * The entry point every app shares.\n *\n * Before this existed, the quickstart asked each author to hand-write the same\n * thirty-five lines: find the parent origin, postMessage `frontera:ready`,\n * listen for `frontera:init`, build a client from the token that arrives, and\n * only then mount. Copied boilerplate is where the origin check gets dropped —\n * and a missing origin check is the whole vulnerability class this architecture\n * exists to close. So it is written once, here.\n *\n * Mounting is DEFERRED until the handshake completes. An app has no data scope\n * until the host tells it who it is, so rendering earlier only produces a flash\n * of unauthorized requests, and every hook would need a \"not ready yet\" branch.\n */\n\nexport interface FronteraAppValue {\n /** Everything the host said at handshake, including `path`. */\n init: BridgeInit\n client: FronteraClient\n /** Ask the platform to change its URL — the counterpart to `init.path`. */\n navigate(path: string): void\n}\n\nconst FronteraAppReactContext = createContext<FronteraAppValue | null>(null)\n\nexport function useFronteraApp(): FronteraAppValue {\n const value = useContext(FronteraAppReactContext)\n if (!value) {\n throw new Error(\n 'useFronteraApp() outside a Frontera app — createFronteraApp() installs this provider.',\n )\n }\n return value\n}\n\n/**\n * A wrapper contributed by a domain package.\n *\n * This is a callback rather than `createFronteraApp` importing the domain\n * clients directly, because `@frontera-sdk/blueprint` already depends on\n * `@frontera-sdk/core` — reaching back the other way would make the two\n * packages mutually dependent. `blueprintProvider` from\n * `@frontera-sdk/blueprint/provider` is one of these.\n */\nexport type FronteraProvider = (value: FronteraAppValue, children: ReactNode) => ReactNode\n\nexport interface CreateFronteraAppOptions {\n /** Element id to mount into. Defaults to `root`. */\n rootId?: string\n providers?: FronteraProvider[]\n queryClient?: QueryClient\n /** How long to wait for the host before reporting a failed mount. */\n timeoutMs?: number\n}\n\ninterface BoundaryProps {\n onError: (error: Error, info: ErrorInfo) => void\n children: ReactNode\n}\n\n/**\n * Report a render crash to the host instead of leaving a blank frame.\n *\n * The platform listens for `frontera:error` and surfaces it next to the app, so\n * the author sees the message rather than an empty rectangle they have to open\n * devtools to explain.\n */\nclass AppErrorBoundary extends Component<BoundaryProps, { error: Error | null }> {\n state: { error: Error | null } = { error: null }\n\n static getDerivedStateFromError(error: Error) {\n return { error }\n }\n\n componentDidCatch(error: Error, info: ErrorInfo) {\n this.props.onError(error, info)\n }\n\n render() {\n if (!this.state.error) return this.props.children\n return diagnostic('This app stopped rendering', this.state.error.message)\n }\n}\n\nfunction diagnostic(title: string, detail: string): ReactNode {\n return (\n <div\n role=\"alert\"\n style={{\n fontFamily: 'var(--font-sans, system-ui, sans-serif)',\n color: 'var(--foreground, #111)',\n padding: 24,\n lineHeight: 1.5,\n }}\n >\n <strong>{title}</strong>\n <div style={{ marginTop: 4, opacity: 0.75, fontSize: 14 }}>{detail}</div>\n </div>\n )\n}\n\n/**\n * Holds what the host can change underneath a running app.\n *\n * The credential is state rather than a captured constant because the host\n * rotates it mid-session; `withCredential` returns a NEW client so requests\n * already in flight keep the one they started with.\n */\nfunction FronteraRoot({\n session,\n app,\n providers,\n}: {\n session: BridgeSession\n app: ReactNode\n providers: FronteraProvider[]\n}) {\n const { init } = session\n const [client, setClient] = useState(\n () =>\n new FronteraClient({\n apiBaseUrl: init.apiBaseUrl,\n orgId: init.orgId ?? undefined,\n workspaceId: init.workspaceId ?? undefined,\n credential: { kind: 'apiKey', key: init.token },\n }),\n )\n\n useEffect(\n () => session.onToken((token) => setClient((c) => c.withCredential({ kind: 'apiKey', key: token }))),\n [session],\n )\n\n useEffect(() => session.onTheme((theme) => applyHostTheme(theme)), [session])\n\n const value: FronteraAppValue = {\n init,\n client,\n navigate: (path) => session.send({ type: 'frontera:navigate', path }),\n }\n\n let tree: ReactNode = app\n // Applied in reverse so the FIRST provider listed ends up outermost, which is\n // the order a reader expects from the array.\n for (const provider of [...providers].reverse()) tree = provider(value, tree)\n\n return (\n <FronteraAppReactContext.Provider value={value}>\n <AppErrorBoundary\n onError={(error) =>\n session.send({ type: 'frontera:error', message: error.message, stack: error.stack })\n }\n >\n {tree}\n </AppErrorBoundary>\n </FronteraAppReactContext.Provider>\n )\n}\n\nexport async function createFronteraApp(\n app: ReactNode,\n options: CreateFronteraAppOptions = {},\n): Promise<void> {\n const rootId = options.rootId ?? 'root'\n const element = document.getElementById(rootId)\n if (!element) {\n throw new Error(`createFronteraApp: no #${rootId} element — check index.html.`)\n }\n\n const root = createRoot(element)\n\n let session: BridgeSession\n try {\n session = await connectToHost({ timeoutMs: options.timeoutMs })\n } catch (err) {\n // NOT a thrown rejection. This is the everyday outcome of running `vite`\n // directly, and an unhandled rejection in the console reads as a crash in\n // the app's own code. A visible panel says what actually happened.\n const detail = err instanceof Error ? err.message : String(err)\n root.render(diagnostic('This app runs inside Frontera', detail))\n return\n }\n\n // Before the first paint, so the app never renders in the wrong palette.\n applyHostTheme(session.init.theme)\n\n const queryClient =\n options.queryClient ??\n new QueryClient({\n // Platform data is read-only here and a mounted app is usually one\n // screen; refetching on every focus change is noise, not freshness.\n defaultOptions: { queries: { refetchOnWindowFocus: false, retry: 1 } },\n })\n\n root.render(\n <StrictMode>\n <QueryClientProvider client={queryClient}>\n <FronteraRoot session={session} app={app} providers={options.providers ?? []} />\n </QueryClientProvider>\n </StrictMode>,\n )\n}\n",
|
|
4
5
|
"frontera/core/theme.ts": "/**\n * Applying the host's palette inside an app.\n *\n * The point is that an app sitting in the platform should not look pasted in —\n * it follows the deployment's colours and its light/dark state without the\n * author wiring anything.\n *\n * The hard part is precedence. An app that has defined its own brand must keep\n * it; the host is supplying DEFAULTS, not a house style. So host tokens are\n * written into a stylesheet inserted as the FIRST child of `<head>`, before the\n * app's own imports. Same `:root` specificity, earlier in the cascade — the\n * app's `brand.css` still wins every token it names, and inherits the rest.\n *\n * Inline styles on the root element would have been simpler and wrong: they\n * beat every stylesheet, so the host would silently overwrite the customer's\n * brand the moment it was mounted.\n */\n\nconst STYLE_ID = 'frontera-host-theme'\n\nexport interface HostTheme {\n tokens: Record<string, string>\n colorScheme?: 'light' | 'dark'\n}\n\n/** CSS custom properties only — never arbitrary declarations from the host. */\nfunction isTokenName(name: string): boolean {\n return /^--[a-zA-Z0-9_-]+$/.test(name)\n}\n\n/**\n * A token value the host sent.\n *\n * Restricted because this string is interpolated into a stylesheet: `}` would\n * close the rule and let anything after it become a new one. The host is\n * trusted, but a value that escapes its rule is a bug class worth closing at\n * the boundary rather than reasoning about.\n */\nfunction isTokenValue(value: string): boolean {\n return typeof value === 'string' && value.length < 200 && !/[{}<>;]/.test(value)\n}\n\nexport function applyHostTheme(theme: HostTheme | undefined): void {\n if (typeof document === 'undefined' || !theme) return\n\n const declarations = Object.entries(theme.tokens ?? {})\n .filter(([name, value]) => isTokenName(name) && isTokenValue(value))\n .map(([name, value]) => `${name}: ${value};`)\n .join('\\n ')\n\n if (declarations) {\n let style = document.getElementById(STYLE_ID) as HTMLStyleElement | null\n if (!style) {\n style = document.createElement('style')\n style.id = STYLE_ID\n // First in <head>, so every app stylesheet that follows can override.\n document.head.prepend(style)\n }\n style.textContent = `:root {\\n ${declarations}\\n}`\n }\n\n if (theme.colorScheme) {\n const dark = theme.colorScheme === 'dark'\n document.documentElement.classList.toggle('dark', dark)\n // Tells the browser to pick the matching form controls and scrollbars,\n // which no amount of custom properties can do.\n document.documentElement.style.colorScheme = dark ? 'dark' : 'light'\n }\n}\n",
|
|
5
|
-
"frontera/core/transport.ts": "import type { FronteraConfig } from './config'\nimport { errorFromResponse } from './errors'\n\nexport interface RequestOptions {\n // PATCH is included because the platform uses it for partial writes —\n // staging an agent draft is one. The transport already passes any method\n // straight to fetch, so its absence here was a type narrower than the\n // runtime, which type-checks a correct call as an error.\n method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'\n body?: unknown\n query?: Record<string, string | number | boolean | undefined>\n signal?: AbortSignal\n}\n\n/**\n * Auth and scope headers for one request.\n *\n * Both credential kinds travel as `Authorization: Bearer`. `x-org-id` and\n * `x-workspace-id` mirror what the web app sends and are what the service's\n * auth middleware reads to scope a session request. A workspace key ignores\n * them and resolves its own scope from the key row, so they can never widen\n * access beyond what the credential already allows.\n */\nexport function authHeaders(config: FronteraConfig): Record<string, string> {\n const token =\n config.credential.kind === 'apiKey' ? config.credential.key : config.credential.token\n const headers: Record<string, string> = { authorization: `Bearer ${token}` }\n if (config.orgId) headers['x-org-id'] = config.orgId\n if (config.workspaceId) headers['x-workspace-id'] = config.workspaceId\n return headers\n}\n\n/**\n * Unwrap the service response envelope when present.\n *\n * `ok()` returns `{ data, message, error: false }`, but several routers — the\n * Blueprint query router among them — return their payload raw. Detect the\n * envelope rather than assuming it.\n */\nexport function unwrap<T>(body: unknown): T {\n if (\n typeof body === 'object' &&\n body !== null &&\n !Array.isArray(body) &&\n (body as { error?: unknown }).error === false &&\n 'data' in body\n ) {\n return (body as { data: T }).data\n }\n return body as T\n}\n\nfunction buildUrl(config: FronteraConfig, path: string, query?: RequestOptions['query']): string {\n const url = new URL(`${config.apiBaseUrl}${path.startsWith('/') ? path : `/${path}`}`)\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined) continue\n url.searchParams.set(key, String(value))\n }\n }\n return url.toString()\n}\n\n/**\n * `fetchImpl` is injectable so tests never touch the network. Production\n * callers omit it and get the platform `fetch`.\n */\nexport async function httpRequest<T>(\n config: FronteraConfig,\n path: string,\n options: RequestOptions = {},\n fetchImpl: typeof fetch = fetch,\n): Promise<T> {\n const headers: Record<string, string> = { ...authHeaders(config), accept: 'application/json' }\n if (options.body !== undefined) headers['content-type'] = 'application/json'\n\n const response = await fetchImpl(buildUrl(config, path, options.query), {\n method: options.method ?? 'GET',\n headers,\n body: options.body === undefined ? undefined : JSON.stringify(options.body),\n signal: options.signal,\n })\n\n const text = await response.text()\n let parsed: unknown = null\n if (text.length > 0) {\n try {\n parsed = JSON.parse(text)\n } catch {\n parsed = text\n }\n }\n\n if (!response.ok) throw errorFromResponse(response.status, parsed)\n return unwrap<T>(parsed)\n}\n",
|
|
6
|
-
"frontera/core/bridge-client.ts": "import { isHostMessage, type BridgeInit, type AppMessage } from './bridge-protocol'\nimport { readRuntimeGlobal } from './config'\nimport type { HostTheme } from './theme'\n\n/**\n * App side of the bridge.\n *\n * The app announces itself with `frontera:ready` and waits for `frontera:init`,\n * which carries the API credential. It does NOT read the credential from its\n * own URL — the only thing there is the narrow asset token, and treating that\n * as a data credential would turn a loggable URL into data access.\n *\n * `event.origin` is checked against the parent's origin on every message.\n */\nexport interface BridgeSession {\n init: BridgeInit\n /** Send a message to the host. */\n send(message: AppMessage): void\n /** Subscribe to shared-state updates pushed by the host. */\n onState(handler: (state: Record<string, unknown>) => void): () => void\n /** Subscribe to credential refreshes. */\n onToken(handler: (token: string) => void): () => void\n /** Subscribe to host palette / colour-scheme changes. */\n onTheme(handler: (theme: HostTheme) => void): () => void\n dispose(): void\n}\n\nexport interface ConnectOptions {\n /**\n * Origin of the embedding platform. Defaults to the injected runtime config,\n * then `document.referrer`.\n */\n parentOrigin?: string\n timeoutMs?: number\n}\n\n/**\n * Who is framing us.\n *\n * The injected runtime config comes FIRST and `document.referrer` is only a\n * fallback, which is the opposite of the original order and the reason the\n * handshake could not complete in production: app responses are served with\n * `referrer-policy: no-referrer`, so the referrer is empty exactly where it\n * mattered. `platformOrigin` exists in the injected config for this purpose.\n */\nfunction resolveParentOrigin(explicit?: string): string | null {\n if (explicit) return explicit\n const injected = readRuntimeGlobal().platformOrigin\n if (injected) return injected\n if (typeof document === 'undefined') return null\n try {\n return document.referrer ? new URL(document.referrer).origin : null\n } catch {\n return null\n }\n}\n\n/**\n * Complete the handshake.\n *\n * Rejects rather than hanging if the host never answers: a frame that waits\n * forever looks identical to a slow network, and an author debugging a broken\n * mount deserves a real error.\n */\nexport function connectToHost(options: ConnectOptions = {}): Promise<BridgeSession> {\n const parentOrigin = resolveParentOrigin(options.parentOrigin)\n const timeoutMs = options.timeoutMs ?? 10_000\n\n if (typeof window === 'undefined' || window.parent === window) {\n return Promise.reject(\n new Error('Not running inside a Frontera host frame — connectToHost() needs a parent window.'),\n )\n }\n if (!parentOrigin) {\n return Promise.reject(\n new Error('Could not determine the host origin; pass parentOrigin explicitly.'),\n )\n }\n\n const stateHandlers = new Set<(s: Record<string, unknown>) => void>()\n const tokenHandlers = new Set<(t: string) => void>()\n const themeHandlers = new Set<(t: HostTheme) => void>()\n\n return new Promise<BridgeSession>((resolve, reject) => {\n let settled = false\n\n const send = (message: AppMessage) => window.parent.postMessage(message, parentOrigin)\n\n const onMessage = (event: MessageEvent) => {\n if (event.origin !== parentOrigin) return\n if (!isHostMessage(event.data)) return\n const message = event.data\n\n switch (message.type) {\n case 'frontera:init':\n if (settled) return\n settled = true\n clearTimeout(timer)\n resolve({\n init: message,\n send,\n onState(handler) {\n stateHandlers.add(handler)\n return () => stateHandlers.delete(handler)\n },\n onToken(handler) {\n tokenHandlers.add(handler)\n return () => tokenHandlers.delete(handler)\n },\n onTheme(handler) {\n themeHandlers.add(handler)\n return () => themeHandlers.delete(handler)\n },\n dispose() {\n window.removeEventListener('message', onMessage)\n stateHandlers.clear()\n tokenHandlers.clear()\n themeHandlers.clear()\n },\n })\n break\n case 'frontera:state':\n for (const handler of stateHandlers) handler(message.state)\n break\n case 'frontera:token':\n for (const handler of tokenHandlers) handler(message.token)\n break\n // The host pushes this on every platform theme change — a system\n // dark-mode switch, a surface that forces its own scheme. Without a\n // handler the message was received and dropped, so an app followed the\n // palette it was mounted with and then never again.\n case 'frontera:theme':\n for (const handler of themeHandlers) {\n handler({ tokens: message.tokens, colorScheme: message.colorScheme })\n }\n break\n default:\n break\n }\n }\n\n const timer = setTimeout(() => {\n if (settled) return\n settled = true\n window.removeEventListener('message', onMessage)\n reject(new Error(`Frontera host did not respond within ${timeoutMs}ms`))\n }, timeoutMs)\n\n window.addEventListener('message', onMessage)\n send({ type: 'frontera:ready' })\n })\n}\n",
|
|
7
6
|
"frontera/core/config.ts": "import { FronteraError } from './errors'\n\n/**\n * How a caller proves who it is.\n *\n * `apiKey` is a long-lived `sk-ws-` workspace key, used by servers and CLIs.\n * `token` is a short-lived credential minted by the platform and handed to an\n * app at bridge handshake. Both travel as `Authorization: Bearer`; they are\n * distinct variants because refresh behaviour differs and callers branch on it.\n */\nexport type FronteraCredential =\n | { kind: 'apiKey'; key: string }\n | { kind: 'token'; token: string }\n\nexport interface FronteraConfig {\n /** Origin of the Frontera API, without a trailing slash. */\n apiBaseUrl: string\n orgId?: string\n workspaceId?: string\n credential: FronteraCredential\n}\n\n/**\n * Shape the app runtime injects into the page at serve time.\n *\n * This mirrors `RuntimeConfig` on the serving side, in full. It was previously\n * narrowed to the three fields `resolveConfig` reads, which made the other two\n * invisible to every caller — and `platformOrigin` is the one an app cannot do\n * without: responses carry `referrer-policy: no-referrer`, so `document.referrer`\n * is empty and this is the ONLY way to learn who is framing you.\n */\nexport interface FronteraRuntimeGlobal {\n apiBaseUrl?: string\n orgId?: string\n workspaceId?: string\n appId?: string\n version?: string\n platformOrigin?: string\n}\n\nexport function readRuntimeGlobal(): FronteraRuntimeGlobal {\n const injected = (globalThis as { __FRONTERA_CONFIG__?: FronteraRuntimeGlobal })\n .__FRONTERA_CONFIG__\n return injected ?? {}\n}\n\nfunction readGlobal(): FronteraRuntimeGlobal {\n return readRuntimeGlobal()\n}\n\nfunction missing(field: string): never {\n throw new FronteraError(\n `Frontera SDK is not configured: ${field} is missing. Pass it explicitly, or set the matching FRONTERA_* environment variable.`,\n { code: 'CONFIG_MISSING' },\n )\n}\n\n/**\n * Resolve configuration from, in order of precedence: explicit argument, the\n * runtime global injected into an app page, then environment variables.\n *\n * `env` is a parameter rather than a direct `process.env` read so tests never\n * mutate global state, and so this works unchanged in a browser bundle where\n * `process` does not exist.\n */\nexport function resolveConfig(\n explicit?: Partial<FronteraConfig>,\n env: Record<string, string | undefined> = typeof process === 'undefined' ? {} : process.env,\n): FronteraConfig {\n const injected = readGlobal()\n\n const rawBaseUrl = explicit?.apiBaseUrl ?? injected.apiBaseUrl ?? env.FRONTERA_API_URL\n if (!rawBaseUrl) missing('apiBaseUrl')\n\n const credential: FronteraCredential | undefined =\n explicit?.credential ??\n (env.FRONTERA_TOKEN ? { kind: 'apiKey', key: env.FRONTERA_TOKEN } : undefined)\n if (!credential) missing('credential')\n\n return {\n apiBaseUrl: rawBaseUrl.replace(/\\/+$/, ''),\n orgId: explicit?.orgId ?? injected.orgId ?? env.FRONTERA_ORG_ID,\n workspaceId: explicit?.workspaceId ?? injected.workspaceId ?? env.FRONTERA_WORKSPACE_ID,\n credential,\n }\n}\n",
|
|
8
|
-
"frontera/core/
|
|
7
|
+
"frontera/core/bridge-client.ts": "import { isHostMessage, type BridgeInit, type AppMessage } from './bridge-protocol'\nimport { readRuntimeGlobal } from './config'\nimport type { HostTheme } from './theme'\n\n/**\n * App side of the bridge.\n *\n * The app announces itself with `frontera:ready` and waits for `frontera:init`,\n * which carries the API credential. It does NOT read the credential from its\n * own URL — the only thing there is the narrow asset token, and treating that\n * as a data credential would turn a loggable URL into data access.\n *\n * `event.origin` is checked against the parent's origin on every message.\n */\nexport interface BridgeSession {\n init: BridgeInit\n /** Send a message to the host. */\n send(message: AppMessage): void\n /** Subscribe to shared-state updates pushed by the host. */\n onState(handler: (state: Record<string, unknown>) => void): () => void\n /** Subscribe to credential refreshes. */\n onToken(handler: (token: string) => void): () => void\n /** Subscribe to host palette / colour-scheme changes. */\n onTheme(handler: (theme: HostTheme) => void): () => void\n dispose(): void\n}\n\nexport interface ConnectOptions {\n /**\n * Origin of the embedding platform. Defaults to the injected runtime config,\n * then `document.referrer`.\n */\n parentOrigin?: string\n timeoutMs?: number\n}\n\n/**\n * Who is framing us.\n *\n * The injected runtime config comes FIRST and `document.referrer` is only a\n * fallback, which is the opposite of the original order and the reason the\n * handshake could not complete in production: app responses are served with\n * `referrer-policy: no-referrer`, so the referrer is empty exactly where it\n * mattered. `platformOrigin` exists in the injected config for this purpose.\n */\nfunction resolveParentOrigin(explicit?: string): string | null {\n if (explicit) return explicit\n const injected = readRuntimeGlobal().platformOrigin\n if (injected) return injected\n if (typeof document === 'undefined') return null\n try {\n return document.referrer ? new URL(document.referrer).origin : null\n } catch {\n return null\n }\n}\n\n/**\n * Complete the handshake.\n *\n * Rejects rather than hanging if the host never answers: a frame that waits\n * forever looks identical to a slow network, and an author debugging a broken\n * mount deserves a real error.\n */\nexport function connectToHost(options: ConnectOptions = {}): Promise<BridgeSession> {\n const parentOrigin = resolveParentOrigin(options.parentOrigin)\n const timeoutMs = options.timeoutMs ?? 10_000\n\n if (typeof window === 'undefined' || window.parent === window) {\n return Promise.reject(\n new Error('Not running inside a Frontera host frame — connectToHost() needs a parent window.'),\n )\n }\n if (!parentOrigin) {\n return Promise.reject(\n new Error('Could not determine the host origin; pass parentOrigin explicitly.'),\n )\n }\n\n const stateHandlers = new Set<(s: Record<string, unknown>) => void>()\n const tokenHandlers = new Set<(t: string) => void>()\n const themeHandlers = new Set<(t: HostTheme) => void>()\n\n return new Promise<BridgeSession>((resolve, reject) => {\n let settled = false\n\n const send = (message: AppMessage) => window.parent.postMessage(message, parentOrigin)\n\n const onMessage = (event: MessageEvent) => {\n if (event.origin !== parentOrigin) return\n if (!isHostMessage(event.data)) return\n const message = event.data\n\n switch (message.type) {\n case 'frontera:init':\n if (settled) return\n settled = true\n clearTimeout(timer)\n resolve({\n init: message,\n send,\n onState(handler) {\n stateHandlers.add(handler)\n return () => stateHandlers.delete(handler)\n },\n onToken(handler) {\n tokenHandlers.add(handler)\n return () => tokenHandlers.delete(handler)\n },\n onTheme(handler) {\n themeHandlers.add(handler)\n return () => themeHandlers.delete(handler)\n },\n dispose() {\n window.removeEventListener('message', onMessage)\n stateHandlers.clear()\n tokenHandlers.clear()\n themeHandlers.clear()\n },\n })\n break\n case 'frontera:state':\n for (const handler of stateHandlers) handler(message.state)\n break\n case 'frontera:token':\n for (const handler of tokenHandlers) handler(message.token)\n break\n // The host pushes this on every platform theme change — a system\n // dark-mode switch, a surface that forces its own scheme. Without a\n // handler the message was received and dropped, so an app followed the\n // palette it was mounted with and then never again.\n case 'frontera:theme':\n for (const handler of themeHandlers) {\n handler({ tokens: message.tokens, colorScheme: message.colorScheme })\n }\n break\n default:\n break\n }\n }\n\n const timer = setTimeout(() => {\n if (settled) return\n settled = true\n window.removeEventListener('message', onMessage)\n reject(new Error(`Frontera host did not respond within ${timeoutMs}ms`))\n }, timeoutMs)\n\n window.addEventListener('message', onMessage)\n send({ type: 'frontera:ready' })\n })\n}\n",
|
|
9
8
|
"frontera/core/bridge-protocol.ts": "/**\n * postMessage protocol between the platform host and an app iframe.\n *\n * The app runs on its own origin (`<appId>.apps.<domain>`), so postMessage is\n * the ONLY channel. Both sides validate `event.origin` on every message: Luigi,\n * a mature framework with this same architecture, carries an open issue for\n * omitting exactly that check, and the consequence is any page being able to\n * drive an embedded app.\n */\n\nexport interface BridgeInit {\n type: 'frontera:init'\n /** Scoped API credential. Arrives here, never in a URL. */\n token: string\n apiBaseUrl: string\n appId: string\n version: string\n orgId: string | null\n workspaceId: string | null\n /**\n * The host's palette and light/dark state.\n *\n * Defaults, not a house style: `applyHostTheme` writes them behind the app's\n * own stylesheets so a customer's brand still wins.\n */\n theme: { tokens: Record<string, string>; colorScheme?: 'light' | 'dark'; fontCss?: string }\n /** Current shared app state, already validated by the host. */\n state: Record<string, unknown>\n /**\n * Where the app should open, taken from the platform URL.\n *\n * The counterpart to `frontera:navigate`: without it a shared link to\n * `/apps/<slug>/shipments` mounts the app at its home page, and the address\n * bar describes a view the user is not looking at. Absent means the app's\n * own default.\n */\n path?: string\n}\n\nexport type HostMessage =\n | BridgeInit\n | { type: 'frontera:state'; state: Record<string, unknown> }\n | {\n type: 'frontera:theme'\n tokens: Record<string, string>\n colorScheme?: 'light' | 'dark'\n fontCss?: string\n }\n | { type: 'frontera:token'; token: string }\n\nexport type AppMessage =\n | { type: 'frontera:ready' }\n | { type: 'frontera:navigate'; path: string }\n | { type: 'frontera:resize'; height: number }\n | { type: 'frontera:state-write'; patch: Record<string, unknown> }\n | { type: 'frontera:error'; message: string; stack?: string }\n | { type: 'frontera:state-repair'; keys: string[] }\n\nexport function isHostMessage(data: unknown): data is HostMessage {\n if (!data || typeof data !== 'object') return false\n const m = data as Record<string, unknown>\n switch (m.type) {\n case 'frontera:init':\n return typeof m.token === 'string' && typeof m.apiBaseUrl === 'string' && typeof m.appId === 'string'\n case 'frontera:state':\n return typeof m.state === 'object' && m.state !== null\n case 'frontera:theme':\n return typeof m.tokens === 'object' && m.tokens !== null\n case 'frontera:token':\n return typeof m.token === 'string'\n default:\n return false\n }\n}\n\nexport function isAppMessage(data: unknown): data is AppMessage {\n if (!data || typeof data !== 'object') return false\n const m = data as Record<string, unknown>\n switch (m.type) {\n case 'frontera:ready':\n return true\n case 'frontera:navigate':\n return typeof m.path === 'string'\n case 'frontera:resize':\n return typeof m.height === 'number' && Number.isFinite(m.height)\n case 'frontera:state-write':\n return typeof m.patch === 'object' && m.patch !== null\n case 'frontera:error':\n return typeof m.message === 'string'\n case 'frontera:state-repair':\n return Array.isArray(m.keys)\n default:\n return false\n }\n}\n",
|
|
10
|
-
"frontera/core/client.ts": "import { resolveConfig, type FronteraConfig, type FronteraCredential } from './config'\nimport { httpRequest, type RequestOptions } from './transport'\n\n/**\n * The transport-level entry point. Domain clients (`@frontera-sdk/blueprint`, and\n * later chat and automation) take one of these rather than reimplementing\n * auth, URL building, or error mapping.\n *\n * `withCredential` exists because a bridge-hosted app receives a refreshed\n * token mid-session: swapping produces a new client rather than mutating one\n * that in-flight requests may still hold.\n */\nexport class FronteraClient {\n readonly config: FronteraConfig\n private readonly fetchImpl: typeof fetch\n\n constructor(config: Partial<FronteraConfig>, fetchImpl: typeof fetch = fetch) {\n this.config = resolveConfig(config)\n this.fetchImpl = fetchImpl\n }\n\n request<T>(path: string, options: RequestOptions = {}): Promise<T> {\n return httpRequest<T>(this.config, path, options, this.fetchImpl)\n }\n\n withCredential(credential: FronteraCredential): FronteraClient {\n return new FronteraClient({ ...this.config, credential }, this.fetchImpl)\n }\n}\n",
|
|
11
9
|
"frontera/core/app-state.ts": "/**\n * Shared app state: typed, validated, and legible to a mounted agent.\n *\n * Free-form JSON was explicitly rejected. It types as `any`, so a typo compiles,\n * and a write from a stale app version or a guessing agent can put a string\n * where the app expects an object and take the render down — worse than V1,\n * where a schema made invalid state unrepresentable.\n *\n * One declaration does three jobs: it types `useAppState` via inference, it\n * validates every read and write at runtime, and the build emits it as JSON\n * Schema so the agent receives a typed tool rather than a free-form object.\n */\n\n/** Minimal structural type for a Zod-like schema, so this file has no Zod dependency. */\nexport interface StandardSchema<T> {\n safeParse(value: unknown): { success: true; data: T } | { success: false; error: unknown }\n}\n\nexport interface AppStateDefinition<T extends Record<string, unknown>> {\n schema: StandardSchema<T>\n defaults: T\n /** Per-key schemas, when available, enable per-key recovery. */\n shape?: Record<string, StandardSchema<unknown>>\n}\n\nexport interface DefineAppStateInput<T extends Record<string, unknown>> {\n schema: StandardSchema<T> & { shape?: Record<string, StandardSchema<unknown>> }\n defaults: T\n}\n\nexport function defineAppState<T extends Record<string, unknown>>(\n input: DefineAppStateInput<T>,\n): AppStateDefinition<T> {\n return {\n schema: input.schema,\n defaults: input.defaults,\n shape: (input.schema as { shape?: Record<string, StandardSchema<unknown>> }).shape,\n }\n}\n\nexport interface RecoveryResult<T> {\n state: T\n /** Keys that failed validation and were reset to their default. */\n repaired: string[]\n /** Keys present in storage but absent from the schema — hidden, not dropped. */\n unknown: string[]\n}\n\n/**\n * Parse a stored state document into something the app can render.\n *\n * **Invariant: this never throws.** Recovery is per key — a malformed or\n * missing key resets to its default while valid keys survive — so the app\n * always receives a well-formed, correctly-typed object. Unknown keys (written\n * by a newer version, or invented by an agent) are hidden from the app but\n * PRESERVED by the caller in storage, so a rollback does not lose them.\n *\n * Whole-document validation is tried first because it is the common path and\n * cheap; per-key recovery is the fallback that keeps a single bad field from\n * blanking everything else.\n */\nexport function parseAppState<T extends Record<string, unknown>>(\n definition: AppStateDefinition<T>,\n stored: unknown,\n): RecoveryResult<T> {\n const document = (typeof stored === 'object' && stored !== null ? stored : {}) as Record<string, unknown>\n\n const whole = definition.schema.safeParse(document)\n if (whole.success) {\n // Project onto known keys explicitly rather than trusting the schema to\n // strip: a `.passthrough()` (or any hand-rolled) schema would otherwise\n // hand the app a key it has no type for.\n const projected = {} as Record<string, unknown>\n for (const key of Object.keys(definition.defaults)) {\n projected[key] = (whole.data as Record<string, unknown>)[key] ?? definition.defaults[key]\n }\n return {\n state: projected as T,\n repaired: [],\n unknown: Object.keys(document).filter((k) => !(k in definition.defaults)),\n }\n }\n\n const state = { ...definition.defaults } as Record<string, unknown>\n const repaired: string[] = []\n const unknownKeys: string[] = []\n\n for (const key of Object.keys(document)) {\n if (!(key in definition.defaults)) {\n unknownKeys.push(key)\n continue\n }\n const keySchema = definition.shape?.[key]\n if (!keySchema) {\n // No per-key schema available: accept only if it matches the default's\n // primitive shape, otherwise fall back. Cheap, and better than trusting it.\n const sameShape = typeof document[key] === typeof definition.defaults[key]\n if (sameShape) state[key] = document[key]\n else repaired.push(key)\n continue\n }\n const parsed = keySchema.safeParse(document[key])\n if (parsed.success) state[key] = parsed.data\n else repaired.push(key)\n }\n\n // Keys the document omitted entirely already hold their default.\n return { state: state as T, repaired, unknown: unknownKeys }\n}\n",
|
|
12
10
|
"frontera/core/errors.ts": "/**\n * Error taxonomy for the Frontera SDK.\n *\n * `code` mirrors the service's `ErrorCode` enum\n * (packages/service/src/lib/errors.ts) so callers branch on the same strings\n * the API emits. Codes are deliberately not enumerated here — the service adds\n * new ones, and an SDK that rejected unknown codes would need a release every\n * time it did.\n */\nexport class FronteraError extends Error {\n readonly code: string\n readonly status?: number\n readonly details?: unknown\n\n constructor(message: string, opts: { code: string; status?: number; details?: unknown }) {\n super(message)\n this.name = 'FronteraError'\n this.code = opts.code\n this.status = opts.status\n this.details = opts.details\n }\n}\n\n/** Codes used when the response body carries no envelope of its own. */\nconst STATUS_FALLBACK: Record<number, string> = {\n 400: 'BAD_REQUEST',\n 401: 'UNAUTHORIZED',\n 403: 'FORBIDDEN',\n 404: 'NOT_FOUND',\n 409: 'CONFLICT',\n 429: 'RATE_LIMITED',\n}\n\nfunction isErrorEnvelope(body: unknown): body is { error: true; code?: string; message?: string } {\n return typeof body === 'object' && body !== null && (body as { error?: unknown }).error === true\n}\n\n/** Turn a non-2xx response body into a `FronteraError`. */\nexport function errorFromResponse(status: number, body: unknown): FronteraError {\n if (isErrorEnvelope(body)) {\n return new FronteraError(body.message ?? `request failed with ${status}`, {\n code: body.code ?? STATUS_FALLBACK[status] ?? 'INTERNAL_ERROR',\n status,\n details: body,\n })\n }\n return new FronteraError(`request failed with ${status}`, {\n code: STATUS_FALLBACK[status] ?? 'INTERNAL_ERROR',\n status,\n details: body ?? undefined,\n })\n}\n",
|
|
11
|
+
"frontera/core/transport.ts": "import type { FronteraConfig } from './config'\nimport { errorFromResponse } from './errors'\n\nexport interface RequestOptions {\n // PATCH is included because the platform uses it for partial writes —\n // staging an agent draft is one. The transport already passes any method\n // straight to fetch, so its absence here was a type narrower than the\n // runtime, which type-checks a correct call as an error.\n method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'\n body?: unknown\n query?: Record<string, string | number | boolean | undefined>\n signal?: AbortSignal\n}\n\n/**\n * Auth and scope headers for one request.\n *\n * Both credential kinds travel as `Authorization: Bearer`. `x-org-id` and\n * `x-workspace-id` mirror what the web app sends and are what the service's\n * auth middleware reads to scope a session request. A workspace key ignores\n * them and resolves its own scope from the key row, so they can never widen\n * access beyond what the credential already allows.\n */\nexport function authHeaders(config: FronteraConfig): Record<string, string> {\n const token =\n config.credential.kind === 'apiKey' ? config.credential.key : config.credential.token\n const headers: Record<string, string> = { authorization: `Bearer ${token}` }\n if (config.orgId) headers['x-org-id'] = config.orgId\n if (config.workspaceId) headers['x-workspace-id'] = config.workspaceId\n return headers\n}\n\n/**\n * Unwrap the service response envelope when present.\n *\n * `ok()` returns `{ data, message, error: false }`, but several routers — the\n * Blueprint query router among them — return their payload raw. Detect the\n * envelope rather than assuming it.\n */\nexport function unwrap<T>(body: unknown): T {\n if (\n typeof body === 'object' &&\n body !== null &&\n !Array.isArray(body) &&\n (body as { error?: unknown }).error === false &&\n 'data' in body\n ) {\n return (body as { data: T }).data\n }\n return body as T\n}\n\nfunction buildUrl(config: FronteraConfig, path: string, query?: RequestOptions['query']): string {\n const url = new URL(`${config.apiBaseUrl}${path.startsWith('/') ? path : `/${path}`}`)\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined) continue\n url.searchParams.set(key, String(value))\n }\n }\n return url.toString()\n}\n\n/**\n * `fetchImpl` is injectable so tests never touch the network. Production\n * callers omit it and get the platform `fetch`.\n */\nexport async function httpRequest<T>(\n config: FronteraConfig,\n path: string,\n options: RequestOptions = {},\n fetchImpl: typeof fetch = fetch,\n): Promise<T> {\n const headers: Record<string, string> = { ...authHeaders(config), accept: 'application/json' }\n if (options.body !== undefined) headers['content-type'] = 'application/json'\n\n const response = await fetchImpl(buildUrl(config, path, options.query), {\n method: options.method ?? 'GET',\n headers,\n body: options.body === undefined ? undefined : JSON.stringify(options.body),\n signal: options.signal,\n })\n\n const text = await response.text()\n let parsed: unknown = null\n if (text.length > 0) {\n try {\n parsed = JSON.parse(text)\n } catch {\n parsed = text\n }\n }\n\n if (!response.ok) throw errorFromResponse(response.status, parsed)\n return unwrap<T>(parsed)\n}\n",
|
|
12
|
+
"frontera/core/client.ts": "import { resolveConfig, type FronteraConfig, type FronteraCredential } from './config'\nimport { httpRequest, type RequestOptions } from './transport'\n\n/**\n * The transport-level entry point. Domain clients (`@frontera-sdk/blueprint`, and\n * later chat and automation) take one of these rather than reimplementing\n * auth, URL building, or error mapping.\n *\n * `withCredential` exists because a bridge-hosted app receives a refreshed\n * token mid-session: swapping produces a new client rather than mutating one\n * that in-flight requests may still hold.\n */\nexport class FronteraClient {\n readonly config: FronteraConfig\n private readonly fetchImpl: typeof fetch\n\n constructor(config: Partial<FronteraConfig>, fetchImpl: typeof fetch = fetch) {\n this.config = resolveConfig(config)\n this.fetchImpl = fetchImpl\n }\n\n request<T>(path: string, options: RequestOptions = {}): Promise<T> {\n return httpRequest<T>(this.config, path, options, this.fetchImpl)\n }\n\n withCredential(credential: FronteraCredential): FronteraClient {\n return new FronteraClient({ ...this.config, credential }, this.fetchImpl)\n }\n}\n",
|
|
13
13
|
"frontera/blueprint/LICENSE": "\n Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n APPENDIX: How to apply the Apache License to your work.\n\n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n\n Copyright 2026 Sebati\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n",
|
|
14
|
-
"frontera/blueprint/provider.tsx": "import type { ReactNode } from 'react'\nimport type { FronteraClient } from '@frontera-sdk/core/client'\n\nimport { BlueprintClient } from './blueprint-client'\nimport { FronteraBlueprintContext } from './hooks'\n\n/**\n * Plug Blueprint reads into `createFronteraApp`.\n *\n * The dependency runs one way — `@frontera-sdk/blueprint` knows about\n * `@frontera-sdk/core`, never the reverse — so the app entry point composes the\n * two rather than sdk-core importing a domain package it should not know exists.\n * That is why this is a callback the entry passes in:\n *\n * ```tsx\n * createFronteraApp(<App />, { providers: [blueprintProvider] })\n * ```\n *\n * The client is rebuilt whenever the host rotates the credential, because the\n * `FronteraClient` it wraps is replaced rather than mutated.\n */\nexport function blueprintProvider(\n value: { client: FronteraClient },\n children: ReactNode,\n): ReactNode {\n return (\n <FronteraBlueprintContext.Provider value={new BlueprintClient(value.client)}>\n {children}\n </FronteraBlueprintContext.Provider>\n )\n}\n",
|
|
15
|
-
"frontera/blueprint/blueprint-client.ts": "import type { FronteraClient } from '@frontera-sdk/core/client'\nimport type {\n AggregateGroupBy,\n AggregateRequest,\n AggregateResponse,\n MetricQueryRequest,\n ObjectInstance,\n QueryRequest,\n QueryResponse,\n} from './types'\n\n/**\n * Typed client for the Blueprint read API.\n *\n * Every method is workspace-scoped by the credential on the underlying\n * `FronteraClient`. An object type the workspace has not been granted is absent\n * from the server's catalog snapshot, so the query compiler raises\n * `UNKNOWN_OBJECT_TYPE` — grant violations arrive as a 404, not a 403, and that\n * is intentional: the caller cannot distinguish \"does not exist\" from \"not\n * granted\", which is the point.\n */\nexport class BlueprintClient {\n constructor(private readonly client: FronteraClient) {}\n\n query<TRow = Record<string, unknown>>(request: QueryRequest): Promise<QueryResponse<TRow>> {\n return this.client.request<QueryResponse<TRow>>('/v1/blueprint/query', {\n method: 'POST',\n body: request,\n })\n }\n\n queryObjectSet<TRow = Record<string, unknown>>(\n objectSetId: string,\n request: Omit<QueryRequest, 'objectSet'> = {},\n ): Promise<QueryResponse<TRow>> {\n return this.client.request<QueryResponse<TRow>>(\n `/v1/blueprint/object-sets/${encodeURIComponent(objectSetId)}/query`,\n { method: 'POST', body: request },\n )\n }\n\n /**\n * Run an aggregation.\n *\n * `groupBy` is required by the service; it is defaulted here so a grand\n * total reads as `aggregate({ objectSet, aggregations })` rather than\n * forcing every caller to remember an empty array.\n */\n aggregate(\n request: Omit<AggregateRequest, 'groupBy'> & { groupBy?: AggregateGroupBy[] },\n ): Promise<AggregateResponse> {\n return this.client.request<AggregateResponse>('/v1/blueprint/aggregate', {\n method: 'POST',\n // Default AFTER the spread: an explicit `undefined` in the request must\n // not win over the fallback.\n body: { ...request, groupBy: request.groupBy ?? [] },\n })\n }\n\n instance<TProps = Record<string, unknown>>(\n objectType: string,\n pk: string,\n ): Promise<ObjectInstance<TProps>> {\n return this.client.request<ObjectInstance<TProps>>(\n `/v1/blueprint/object-types/${encodeURIComponent(objectType)}/instances/${encodeURIComponent(pk)}`,\n )\n }\n\n propertyValues(objectType: string, property: string): Promise<string[]> {\n return this.client.request<string[]>(\n `/v1/blueprint/object-types/${encodeURIComponent(objectType)}/properties/${encodeURIComponent(property)}/values`,\n )\n }\n\n metricQuery(apiName: string, request: MetricQueryRequest = {}): Promise<AggregateResponse> {\n return this.client.request<AggregateResponse>(\n `/v1/blueprint/metrics/${encodeURIComponent(apiName)}/query`,\n { method: 'POST', body: request },\n )\n }\n}\n",
|
|
16
14
|
"frontera/blueprint/hooks.ts": "import { createContext, useContext } from 'react'\nimport { useQuery, type UseQueryOptions, type UseQueryResult } from '@tanstack/react-query'\n\nimport type { BlueprintClient } from './blueprint-client'\nimport { objectsOf } from './types'\nimport type {\n AggregateRequest,\n AggregateResponse,\n ObjectInstance,\n QueryRequest,\n QueryResponse,\n WhereNode,\n} from './types'\n\n/**\n * Query-key factory.\n *\n * Requests are serialised into the key so two structurally equal requests share\n * a cache entry. Key order therefore matters: callers must build request\n * objects consistently, which they do because these hooks construct them.\n */\nexport const blueprintKeys = {\n all: ['blueprint'] as const,\n query: (request: QueryRequest) => ['blueprint', 'query', JSON.stringify(request)] as const,\n aggregate: (request: AggregateRequest) =>\n ['blueprint', 'aggregate', JSON.stringify(request)] as const,\n instance: (objectType: string, pk: string) =>\n ['blueprint', 'instance', objectType, pk] as const,\n}\n\nexport const FronteraBlueprintContext = createContext<BlueprintClient | null>(null)\n\nexport function useBlueprintClient(): BlueprintClient {\n const client = useContext(FronteraBlueprintContext)\n if (!client) {\n throw new Error(\n 'No BlueprintClient in context. Wrap the tree in FronteraBlueprintContext.Provider — createFronteraApp does this for you in a Frontera app.',\n )\n }\n return client\n}\n\ntype ReadOptions<TData> = Omit<UseQueryOptions<TData, Error>, 'queryKey' | 'queryFn'>\n\n/** Run an arbitrary object-set query. */\nexport function useObjectQuery<TRow = Record<string, unknown>>(\n request: QueryRequest,\n options: ReadOptions<QueryResponse<TRow>> = {},\n): UseQueryResult<QueryResponse<TRow>, Error> {\n const client = useBlueprintClient()\n return useQuery({\n queryKey: blueprintKeys.query(request),\n queryFn: () => client.query<TRow>(request),\n ...options,\n })\n}\n\n/**\n * One object type, optionally filtered.\n *\n * `where` compiles into the object-set expression, so the SERVER filters and\n * pages. Filtering the returned rows in the component instead is the classic\n * mistake: it narrows only the page you happened to fetch, so a facet showing\n * 8,961 matches renders 5 rows and claims \"Page 1 of 1\".\n */\nexport function useObjects<TRow = Record<string, unknown>>(\n objectType: string,\n options: ReadOptions<QueryResponse<TRow>> &\n Omit<QueryRequest, 'objectSet'> & { where?: WhereNode } = {},\n): UseQueryResult<QueryResponse<TRow>, Error> {\n const { select, orderBy, page, pageSize, where, ...queryOptions } = options\n return useObjectQuery<TRow>(\n { objectSet: objectsOf(objectType, where), select, orderBy, page, pageSize },\n queryOptions,\n )\n}\n\nexport function useAggregate(\n request: AggregateRequest,\n options: ReadOptions<AggregateResponse> = {},\n): UseQueryResult<AggregateResponse, Error> {\n const client = useBlueprintClient()\n return useQuery({\n queryKey: blueprintKeys.aggregate(request),\n queryFn: () => client.aggregate(request),\n ...options,\n })\n}\n\nexport function useObjectInstance<TProps = Record<string, unknown>>(\n objectType: string,\n pk: string | null | undefined,\n options: ReadOptions<ObjectInstance<TProps>> = {},\n): UseQueryResult<ObjectInstance<TProps>, Error> {\n const client = useBlueprintClient()\n return useQuery({\n queryKey: blueprintKeys.instance(objectType, pk ?? ''),\n queryFn: () => client.instance<TProps>(objectType, pk as string),\n enabled: Boolean(pk) && options.enabled !== false,\n ...options,\n })\n}\n",
|
|
17
15
|
"frontera/blueprint/types.ts": "/**\n * Request and response types for the Blueprint read API.\n *\n * `ObjectSetExpr` is deliberately loose. The service validates the expression\n * tree in `query/validate.ts` with error messages far better than a structural\n * type could produce, and mirroring that grammar here would mean shipping an\n * SDK release every time the service gained a node kind. The common shapes are\n * named so callers get completion for what they actually write.\n */\n/**\n * Condition operators, mirroring the service's `ConditionOp`.\n *\n * Filtering belongs in the object-set expression, NOT in the app: a client-side\n * `.filter()` over a fetched page silently reduces \"8,961 cancelled shipments\"\n * to \"the cancelled ones that happened to be in the last 200 rows\", and the\n * counts stop matching the table.\n */\nexport type ConditionOp =\n | 'eq' | 'ne' | 'in' | 'notIn' | 'contains' | 'startsWith'\n | 'isNull' | 'isNotNull'\n | 'gt' | 'gte' | 'lt' | 'lte' | 'between'\n | 'dateRange'\n\nexport type DatePreset =\n | 'TODAY' | 'YESTERDAY' | 'LAST_7_DAYS' | 'LAST_30_DAYS' | 'LAST_90_DAYS'\n | 'THIS_MONTH' | 'LAST_MONTH' | 'THIS_QUARTER' | 'THIS_YEAR'\n\nexport interface PropertyCondition {\n property: string\n op: ConditionOp\n value?: unknown\n values?: unknown[]\n /** `dateRange` only — resolved to [start, end) server-side. */\n preset?: DatePreset\n timezone?: string\n}\n\nexport type WhereNode =\n | PropertyCondition\n | { and: WhereNode[] }\n | { or: WhereNode[] }\n | { not: WhereNode }\n\nexport type ObjectSetExpr =\n | { type: 'base'; objectType: string }\n | { type: 'filter'; objectSet: ObjectSetExpr; where: WhereNode }\n | { type: 'searchAround'; objectSet: ObjectSetExpr; link: string }\n | { type: 'union' | 'intersect' | 'subtract'; objectSets: ObjectSetExpr[] }\n | { type: 'reference'; objectSetId: string }\n | { type: 'static'; objectType: string; pks: Array<string | number> }\n | { type: string; [key: string]: unknown }\n\nexport interface OrderBy {\n property: string\n dir: 'asc' | 'desc'\n}\n\nexport interface QueryRequest {\n objectSet: ObjectSetExpr\n select?: string[]\n orderBy?: OrderBy[]\n page?: number\n pageSize?: number\n}\n\n/**\n * `properties` is the FULL projection for the object type regardless of what\n * `select` asked for — filter display columns client-side rather than assuming\n * this list matches `select`.\n */\nexport interface QueryResponse<TRow = Record<string, unknown>> {\n rows: TRow[]\n properties: Array<{ apiName: string; displayName?: string; dataType?: string }>\n totalCount?: number\n}\n\nexport const AGGREGATE_FUNCTIONS = [\n 'count',\n 'sum',\n 'avg',\n 'min',\n 'max',\n 'countDistinct',\n] as const\n\nexport type AggregateFunction = (typeof AGGREGATE_FUNCTIONS)[number]\n\nexport type TimeGrain = 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year'\n\nexport interface AggregateSpec {\n /**\n * Result column name.\n *\n * `alias`, not `name` — this mirrors the service's `aggregateBody` schema\n * exactly (blueprint-query-router.ts). Getting it wrong produces a 400 that\n * says only \"Expected required property\", which is a miserable thing to\n * debug from inside an app.\n */\n alias: string\n fn: AggregateFunction\n property?: string\n /** Per-aggregation filter expression, validated server-side. */\n filters?: unknown\n}\n\nexport interface AggregateGroupBy {\n property: string\n /** Set for a temporal property to bucket by grain; the service aliases the\n * result column as `${property}_${grain}`. */\n bucket?: TimeGrain\n}\n\nexport interface AggregateRequest {\n objectSet: ObjectSetExpr\n aggregations: AggregateSpec[]\n /** REQUIRED by the service — pass `[]` for a grand total. */\n groupBy: AggregateGroupBy[]\n having?: unknown\n sort?: Array<{ alias: string; dir: 'asc' | 'desc' }>\n limit?: number\n}\n\nexport interface AggregateResponse {\n rows: Array<Record<string, unknown>>\n}\n\nexport interface MetricQueryRequest {\n measures?: string[]\n dimensions?: string[]\n grain?: TimeGrain\n limit?: number\n}\n\n/**\n * One object, as the service returns it: the property bag itself.\n *\n * NOT wrapped in `{ objectType, primaryKey, properties }` — the instance route\n * responds with the properties flat under the envelope's `data`, so a wrapper\n * type here would make `.properties` permanently undefined and render an empty\n * detail panel with no error to explain it.\n */\nexport type ObjectInstance<TProps = Record<string, unknown>> = TProps\n\n/** Wrap an object set in a filter. `where` undefined returns the set unchanged. */\nexport function filtered(objectSet: ObjectSetExpr, where?: WhereNode): ObjectSetExpr {\n return where ? { type: 'filter', objectSet, where } : objectSet\n}\n\n/** The common case: one object type, optionally filtered. */\nexport function objectsOf(objectType: string, where?: WhereNode): ObjectSetExpr {\n return filtered({ type: 'base', objectType }, where)\n}\n",
|
|
16
|
+
"frontera/blueprint/provider.tsx": "import type { ReactNode } from 'react'\nimport type { FronteraClient } from '@frontera-sdk/core/client'\n\nimport { BlueprintClient } from './blueprint-client'\nimport { FronteraBlueprintContext } from './hooks'\n\n/**\n * Plug Blueprint reads into `createFronteraApp`.\n *\n * The dependency runs one way — `@frontera-sdk/blueprint` knows about\n * `@frontera-sdk/core`, never the reverse — so the app entry point composes the\n * two rather than sdk-core importing a domain package it should not know exists.\n * That is why this is a callback the entry passes in:\n *\n * ```tsx\n * createFronteraApp(<App />, { providers: [blueprintProvider] })\n * ```\n *\n * The client is rebuilt whenever the host rotates the credential, because the\n * `FronteraClient` it wraps is replaced rather than mutated.\n */\nexport function blueprintProvider(\n value: { client: FronteraClient },\n children: ReactNode,\n): ReactNode {\n return (\n <FronteraBlueprintContext.Provider value={new BlueprintClient(value.client)}>\n {children}\n </FronteraBlueprintContext.Provider>\n )\n}\n",
|
|
17
|
+
"frontera/blueprint/blueprint-client.ts": "import type { FronteraClient } from '@frontera-sdk/core/client'\nimport type {\n AggregateGroupBy,\n AggregateRequest,\n AggregateResponse,\n MetricQueryRequest,\n ObjectInstance,\n QueryRequest,\n QueryResponse,\n} from './types'\n\n/**\n * Typed client for the Blueprint read API.\n *\n * Every method is workspace-scoped by the credential on the underlying\n * `FronteraClient`. An object type the workspace has not been granted is absent\n * from the server's catalog snapshot, so the query compiler raises\n * `UNKNOWN_OBJECT_TYPE` — grant violations arrive as a 404, not a 403, and that\n * is intentional: the caller cannot distinguish \"does not exist\" from \"not\n * granted\", which is the point.\n */\nexport class BlueprintClient {\n constructor(private readonly client: FronteraClient) {}\n\n query<TRow = Record<string, unknown>>(request: QueryRequest): Promise<QueryResponse<TRow>> {\n return this.client.request<QueryResponse<TRow>>('/v1/blueprint/query', {\n method: 'POST',\n body: request,\n })\n }\n\n queryObjectSet<TRow = Record<string, unknown>>(\n objectSetId: string,\n request: Omit<QueryRequest, 'objectSet'> = {},\n ): Promise<QueryResponse<TRow>> {\n return this.client.request<QueryResponse<TRow>>(\n `/v1/blueprint/object-sets/${encodeURIComponent(objectSetId)}/query`,\n { method: 'POST', body: request },\n )\n }\n\n /**\n * Run an aggregation.\n *\n * `groupBy` is required by the service; it is defaulted here so a grand\n * total reads as `aggregate({ objectSet, aggregations })` rather than\n * forcing every caller to remember an empty array.\n */\n aggregate(\n request: Omit<AggregateRequest, 'groupBy'> & { groupBy?: AggregateGroupBy[] },\n ): Promise<AggregateResponse> {\n return this.client.request<AggregateResponse>('/v1/blueprint/aggregate', {\n method: 'POST',\n // Default AFTER the spread: an explicit `undefined` in the request must\n // not win over the fallback.\n body: { ...request, groupBy: request.groupBy ?? [] },\n })\n }\n\n instance<TProps = Record<string, unknown>>(\n objectType: string,\n pk: string,\n ): Promise<ObjectInstance<TProps>> {\n return this.client.request<ObjectInstance<TProps>>(\n `/v1/blueprint/object-types/${encodeURIComponent(objectType)}/instances/${encodeURIComponent(pk)}`,\n )\n }\n\n propertyValues(objectType: string, property: string): Promise<string[]> {\n return this.client.request<string[]>(\n `/v1/blueprint/object-types/${encodeURIComponent(objectType)}/properties/${encodeURIComponent(property)}/values`,\n )\n }\n\n metricQuery(apiName: string, request: MetricQueryRequest = {}): Promise<AggregateResponse> {\n return this.client.request<AggregateResponse>(\n `/v1/blueprint/metrics/${encodeURIComponent(apiName)}/query`,\n { method: 'POST', body: request },\n )\n }\n}\n",
|
|
18
18
|
"frontera/automation/LICENSE": "\n Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n APPENDIX: How to apply the Apache License to your work.\n\n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n\n Copyright 2026 Sebati\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n",
|
|
19
|
-
"frontera/automation/
|
|
20
|
-
"frontera/automation/
|
|
21
|
-
"frontera/automation/
|
|
22
|
-
"frontera/automation/types.ts": "// `import type`, so this is erased at compile time and adds no runtime import —\n// but `@frontera-sdk/blueprint` is still a real `dependencies` entry, because\n// `WhereNode` is part of this package's PUBLIC type surface: anyone consuming\n// `AutomationContext` needs it to resolve. See the packaging note in\n// docs/superpowers/specs/2026-07-29-automations-ctx-blueprint-query-design.md —\n// a subset install that cannot resolve it aborts `bun install` outright.\nimport type { WhereNode } from '@frontera-sdk/blueprint/types'\n\n/**\n * Cron and manual only for now; event and webhook land with Event Triggers.\n *\n * The `?: never` members are load-bearing. Without them `{ cron, manual }`\n * typechecks — TypeScript's excess-property check admits any key present on\n * *some* member of a union — and the runner would have to decide at runtime\n * what a both-shaped trigger means.\n */\nexport type AutomationTrigger =\n | { cron: string; manual?: never }\n | { cron?: never; manual: true }\n\n/**\n * An author-time affordance, not a validation gate.\n *\n * `blueprint:read` is a literal, so the compiler completes it and offers \"Did\n * you mean 'blueprint:read'?\" on a typo. `agent:${string}:run` admits any slug\n * — including one that names no agent — so the union cannot be read as proof\n * that a grant is well-formed. The runtime gate is `validateManifest` in\n * `manifest.ts`; this exists to guide the author as they type.\n *\n * Widening it later (adding `notify:*`, `governed:*` with Governed Writes) is a\n * non-breaking change. Narrowing `string` to a union later would break every\n * automation already written, so it starts narrow.\n */\nexport type Grant =\n | 'blueprint:read'\n | `agent:${string}:run`\n\nexport interface AutomationManifest {\n name: string\n trigger: AutomationTrigger\n grants?: readonly Grant[]\n concurrency?: number\n description?: string\n}\n\n/**\n * What `automation()` guarantees once defaults are applied — nothing optional\n * left for a consumer to re-handle. Downstream code takes this, not\n * `AutomationManifest`, so it never re-derives a fact already established.\n */\nexport interface ResolvedAutomationManifest extends AutomationManifest {\n // Every member is readonly, not just the two with defaults. `Object.freeze`\n // in `define.ts` freezes the whole object at runtime, so leaving `name` or\n // `description` mutable in the type means `d.manifest.name = 'x'` compiles\n // and then throws — the same compile-clean/throw-at-runtime gap that the\n // removed `as string[]` cast used to create.\n readonly name: string\n readonly trigger: Readonly<AutomationTrigger>\n readonly grants: readonly Grant[]\n readonly concurrency: number\n readonly description?: string\n}\n\nexport interface AgentHandle {\n run(prompt: string): Promise<{ text: string }>\n}\n\n/** Read-only for now. `governed`/`notify` arrive with Governed Writes. */\nexport interface AutomationContext {\n runId: string\n workspaceId: string\n /** Never rejects — telemetry must not be able to fail a run. */\n log(message: string, data?: Record<string, unknown>): Promise<void>\n agent(slug: string): AgentHandle\n blueprint: {\n query<T = Record<string, unknown>>(\n objectType: string,\n options?: BlueprintQueryOptions,\n ): Promise<BlueprintQueryResult<T>>\n }\n}\n\nexport interface BlueprintQueryOptions {\n /** The real Blueprint filter DSL, not a shorthand — `and`/`or`/`not`, ranges\n * and date presets all work. A convenience subset with no escape hatch is the\n * thing the first \"overdue OR flagged\" automation would have to work around. */\n where?: WhereNode\n select?: string[]\n /** `dir`, not `direction` — matches `QueryRequest` exactly. */\n orderBy?: Array<{ property: string; dir: 'asc' | 'desc' }>\n /** Default 100, clamped to 1000. Exceeding the cap sets `hasMore`; it never\n * truncates silently. */\n limit?: number\n /** Opaque. Pass back the previous result's `nextPageToken`; absent means the\n * first page. Cursor-based, so a scan stays correct while the table moves\n * underneath it — which a cron-driven automation's table always does. */\n pageToken?: string\n}\n\nexport interface BlueprintQueryResult<T = Record<string, unknown>> {\n rows: T[]\n /** True when the query matched more rows than were returned. */\n hasMore: boolean\n /** Present iff `hasMore`. Feed to the next call's `pageToken`.\n *\n * Forwarded rather than narrowed away on purpose: `hasMore` on its own is a\n * fact the author can do nothing about, which is how a digest over the first\n * 500 of 5,000 rows reports success. */\n nextPageToken?: string\n}\n\nexport type AutomationHandler = (ctx: AutomationContext) => Promise<unknown>\n\nexport interface AutomationDescriptor {\n readonly manifest: ResolvedAutomationManifest\n readonly handler: AutomationHandler\n}\n",
|
|
23
|
-
"theme.css": "/* GENERATED from packages/web/src/app/globals.css — do not edit.\n * Refresh with `frontera app add theme`.\n *\n * Gives an app the same Tailwind utilities and design tokens the platform\n * uses, so copied components look native rather than unstyled. Import this\n * once from your entry (`import './theme.css'`).\n */\n@import \"tailwindcss\";\n\n@custom-variant dark (&:is(.dark *));\n\n@theme inline {\n --color-background: hsl(var(--background));\n --color-foreground: hsl(var(--foreground));\n --color-dot: var(--dot-foreground);\n --color-card: var(--card);\n --color-card-foreground: var(--card-foreground);\n --color-popover: var(--popover);\n --color-popover-foreground: var(--popover-foreground);\n --color-primary: var(--primary);\n --color-primary-foreground: var(--primary-foreground);\n --color-secondary: var(--secondary);\n --color-secondary-foreground: var(--secondary-foreground);\n --color-muted: var(--muted);\n --color-muted-foreground: var(--muted-foreground);\n --color-accent: var(--accent);\n --color-accent-foreground: var(--accent-foreground);\n --color-destructive: var(--destructive);\n --color-destructive-foreground: var(--destructive-foreground);\n --color-success: var(--success);\n --color-success-foreground: var(--success-foreground);\n --color-warning: var(--warning);\n --color-warning-foreground: var(--warning-foreground);\n --color-info: var(--info);\n --color-info-foreground: var(--info-foreground);\n --color-border: var(--border);\n --color-border-secondary: var(--border-secondary);\n --color-input: var(--input);\n --color-ring: var(--ring);\n --color-sidebar: var(--sidebar);\n --color-sidebar-foreground: var(--sidebar-foreground);\n --color-sidebar-primary: var(--sidebar-primary);\n --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);\n --color-sidebar-accent: var(--sidebar-accent);\n --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);\n --color-sidebar-border: var(--sidebar-border);\n --color-sidebar-ring: var(--sidebar-ring);\n --color-chart-1: var(--chart-1);\n --color-chart-2: var(--chart-2);\n --color-chart-3: var(--chart-3);\n --color-chart-4: var(--chart-4);\n --color-chart-5: var(--chart-5);\n --color-chart-6: var(--chart-6);\n --color-chart-7: var(--chart-7);\n --color-chart-8: var(--chart-8);\n --color-chart-9: var(--chart-9);\n --color-chart-10: var(--chart-10);\n --color-chart-11: var(--chart-11);\n --color-chart-12: var(--chart-12);\n --radius-sm: calc(var(--radius) - 4px);\n --radius-md: calc(var(--radius) - 2px);\n --radius-lg: var(--radius);\n --radius-xl: calc(var(--radius) + 4px);\n --radius-2xl: calc(var(--radius) + 8px);\n\n /* Shadow elevation tokens — Attio-inspired multi-layer */\n /* --shadow-xs: var(--elevation-xs);\n --shadow-sm: var(--elevation-sm);\n --shadow-md: var(--elevation-md);\n --shadow-lg: var(--elevation-lg);\n --shadow-xl: var(--elevation-xl); */\n\n /* Surface elevation tokens */\n --color-surface-inset-deep: var(--surface-inset-deep);\n --color-surface-inset-deep-hover: var(--surface-inset-deep-hover);\n --color-surface-inset-deep-active: var(--surface-inset-deep-active);\n --color-surface-inset: var(--surface-inset);\n --color-surface-inset-hover: var(--surface-inset-hover);\n --color-surface-inset-active: var(--surface-inset-active);\n --color-surface: var(--surface);\n --color-surface-chat: var(--surface-chat);\n --color-surface-hover: var(--surface-hover);\n --color-surface-active: var(--surface-active);\n --color-surface-raised: var(--surface-raised);\n --color-surface-raised-hover: var(--surface-raised-hover);\n --color-surface-raised-active: var(--surface-raised-active);\n /* --color-surface-overlay: var(--surface-raised);\n --color-surface-overlay-hover: var(--surface-raised-hover);\n --color-surface-overlay-active: var(--surface-raised-active); */\n --color-surface-overlay: var(--surface-overlay);\n --color-surface-overlay-hover: var(--surface-overlay-hover);\n --color-surface-overlay-active: var(--surface-overlay-active);\n}\n\n:root {\n --radius: 0.625rem;\n\n /* Widest a config-row chip (skill / pack / app / context) may grow before\n its label truncates. Roughly 28 characters at text-xs — long enough to\n read a name, short enough that one chip can't monopolise the row. */\n --chip-max-width: 13rem;\n\n --background: 0 0% 100%;\n\n /* React flow canvas tokens */\n --dot-foreground: #c9c9c9;\n\n /* ── Surface elevation tokens ──────────────────── */\n --surface-inset-deep: hsl(0 0% 93%);\n --surface-inset-deep-hover: hsl(0 0% 89%);\n --surface-inset-deep-active: hsl(0 0% 86%);\n --surface-inset: hsl(0 0% 96%);\n --surface-inset-hover: hsl(0 0% 91%);\n --surface-inset-active: hsl(0 0% 88%);\n --surface: hsl(0 0% 98%);\n /* Chat-view backdrop — slightly warmer off-white than --surface, light only. */\n --surface-chat: #f9f9f9;\n --surface-hover: hsl(0 0% 96%);\n --surface-active: hsl(0 0% 94%);\n --surface-raised: hsl(0 0% 100%);\n --surface-raised-hover: hsl(0 0% 96%);\n --surface-raised-active: hsl(0 0% 94%);\n --surface-overlay: hsl(0 0% 100%);\n --surface-overlay-hover: hsl(0 0% 95%);\n --surface-overlay-active: hsl(0 0% 91%);\n\n /* ── Shadow elevations: (light) ───── */\n --elevation-xs: 0px 0px 0px 1px rgba(42, 28, 0, 0.07);\n\n --elevation-sm:\n 0px 2px 4px 0px rgba(0, 0, 0, 0.04), 0px 0px 0px 1px rgba(42, 28, 0, 0.07);\n\n --elevation-md:\n 0px 8px 12px 0px rgba(25, 25, 25, 0.027),\n 0px 2px 6px 0px rgba(25, 25, 25, 0.027),\n 0px 0px 0px 1px rgba(42, 28, 0, 0.07);\n\n --elevation-lg:\n 0px 20px 24px 0px rgba(25, 25, 25, 0.05),\n 0px 5px 8px 0px rgba(25, 25, 25, 0.027),\n 0px 0px 0px 1px rgba(42, 28, 0, 0.07);\n\n --elevation-xl:\n 0px 24px 48px 0px rgba(25, 25, 25, 0.24),\n 0px 4px 12px 0px rgba(25, 25, 25, 0.14),\n 0px 0px 0px 1px rgba(42, 28, 0, 0.07);\n\n --foreground: 47 13% 14%;\n --card: var(--surface-raised);\n --card-foreground: 47 13% 14%;\n --popover: oklch(1 0 0);\n --popover-foreground: 47 13% 14%;\n --primary: oklch(0.21 0.006 285.885);\n --primary-foreground: oklch(0.985 0 0);\n --secondary: oklch(0.967 0.001 286.375);\n --secondary-foreground: oklch(0.21 0.006 285.885);\n --muted: oklch(0.967 0.001 286.375);\n --muted-foreground: oklch(0.5 0.016 285.938);\n --accent: oklch(0.967 0.001 286.375);\n --accent-foreground: 47 13% 14%;\n --destructive: oklch(0.577 0.245 27.325);\n --destructive-foreground: oklch(0.985 0 0);\n --success: oklch(0.627 0.194 149.214);\n --success-foreground: oklch(0.985 0 0);\n --warning: oklch(0.735 0.166 70.67);\n --warning-foreground: oklch(0.21 0.006 285.885);\n --info: oklch(0.6 0.15 240);\n --info-foreground: oklch(0.985 0 0);\n --border: hsl(240 100 6 / 0.05);\n --border-secondary: hsl(214 32% 96%);\n --input: oklch(0.92 0.004 286.32 / 0.75);\n --ring: oklch(0.705 0.015 286.067);\n --chart-1: #5b8dee;\n --chart-2: #3dab82;\n --chart-3: #e8883e;\n --chart-4: #9b7ef5;\n --chart-5: #e05c78;\n --chart-6: #3ab5cc;\n --chart-7: #a4b83a;\n --chart-8: #d47a4a;\n --chart-9: #748cd4;\n --chart-10: #4cad6a;\n /* Dashboard analytics series — extends the fixed chart palette. */\n --chart-11: #3b82f6;\n --chart-12: #10b981;\n --sidebar: oklch(0.985 0 0);\n --sidebar-foreground: oklch(0.141 0.005 285.823);\n --sidebar-primary: oklch(0.21 0.006 285.885);\n --sidebar-primary-foreground: oklch(0.985 0 0);\n --sidebar-accent: oklch(0.967 0.001 286.375);\n --sidebar-accent-foreground: oklch(0.21 0.006 285.885);\n --sidebar-border: oklch(0.92 0.004 286.32);\n --sidebar-ring: oklch(0.705 0.015 286.067);\n}\n\n.dark {\n --background: 0 0% 2%;\n\n /* React flow canvas tokens */\n --dot-foreground: #363636;\n\n /* ── Shadow elevations (dark) ───────────────────── */\n --elevation-xs: 0 0 0 1px #383836;\n\n --elevation-sm: 0 0 0 1px #383836, 0 2px 4px 0 rgba(0, 0, 0, 0.18);\n\n --elevation-md:\n 0 0 0 1px #383836, 0 8px 16px -4px rgba(0, 0, 0, 0.36),\n 0 2px 6px -2px rgba(0, 0, 0, 0.28);\n\n --elevation-lg:\n 0 0 0 1px #383836, 0 14px 28px -6px rgba(0, 0, 0, 0.44),\n 0 2px 4px -1px rgba(0, 0, 0, 0.28);\n\n --elevation-xl:\n 0 0 0 1px #383836, 0 24px 48px 0 rgba(0, 0, 0, 0.56),\n 0 4px 12px 0 rgba(0, 0, 0, 0.4);\n\n /* ── Surface elevation tokens ──────────────────── */\n --surface-inset-deep: hsl(0, 0%, 6%);\n --surface-inset-deep-hover: hsl(0 0% 8%);\n --surface-inset-deep-active: hsl(0 0% 11%);\n --surface-inset: hsl(0 0% 7.5%);\n --surface-inset-hover: hsl(0 0% 10%);\n --surface-inset-active: hsl(0 0% 12%);\n --surface: hsl(0 0% 9%);\n /* Dark mirrors --surface — chat backdrop is only retuned in light. */\n --surface-chat: hsl(0 0% 9%);\n --surface-hover: hsl(0 0% 14%);\n --surface-active: hsl(0 0% 17%);\n --surface-raised: hsl(0 0% 13%);\n --surface-raised-hover: hsl(0 0% 15%);\n --surface-raised-active: hsl(0 0% 17%);\n --surface-overlay: hsl(0 0% 9%);\n --surface-overlay-hover: hsl(0 0% 15%);\n --surface-overlay-active: hsl(0 0% 19%);\n\n --foreground: 0 0% 83%;\n --card: var(--surface-raised);\n --card-foreground: hsl(0 0% 98%);\n --popover: hsl(0 0% 7%);\n --popover-foreground: hsl(0 0% 98%);\n --primary: hsl(0 0% 90%);\n --primary-foreground: hsl(0 0% 5%);\n --secondary: hsl(0 0% 12%);\n --secondary-foreground: hsl(0 0% 98%);\n --muted: hsl(0 0% 9%);\n --muted-foreground: hsl(0 0% 52%);\n --accent: hsl(0 0% 9%);\n --accent-foreground: hsl(0 0% 98%);\n --destructive: oklch(0.704 0.191 22.216);\n --destructive-foreground: oklch(0.985 0 0);\n --success: oklch(0.723 0.191 142.542);\n --success-foreground: oklch(0.985 0 0);\n --warning: oklch(0.815 0.152 78.2);\n --warning-foreground: oklch(0.21 0.006 285.885);\n --info: oklch(0.7 0.15 240);\n --info-foreground: oklch(0.985 0 0);\n --border: oklch(0.9296 0.007 106.53 / 0.08);\n --border-secondary: oklch(0.9296 0.007 106.53 / 0.03);\n --input: oklch(1 0 0 / 10%);\n --ring: oklch(0.552 0.016 285.938);\n --chart-1: #5b8dee;\n --chart-2: #3dab82;\n --chart-3: #e8883e;\n --chart-4: #9b7ef5;\n --chart-5: #e05c78;\n --chart-6: #3ab5cc;\n --chart-7: #a4b83a;\n --chart-8: #d47a4a;\n --chart-9: #748cd4;\n --chart-10: #4cad6a;\n --chart-11: #3b82f6;\n --chart-12: #10b981;\n --sidebar: oklch(0.21 0.006 285.885);\n --sidebar-foreground: oklch(0.985 0 0);\n --sidebar-primary: oklch(0.488 0.243 264.376);\n --sidebar-primary-foreground: oklch(0.985 0 0);\n --sidebar-accent: oklch(0.274 0.006 286.033);\n --sidebar-accent-foreground: oklch(0.985 0 0);\n --sidebar-border: oklch(1 0 0 / 10%);\n --sidebar-ring: oklch(0.552 0.016 285.938);\n}\n\n@layer base {\n * {\n border-color: var(--border);\n }\n body {\n background: var(--app-canvas, var(--surface));\n color: var(--foreground);\n font-family: var(--font-sans, ui-sans-serif, system-ui, sans-serif);\n -webkit-font-smoothing: antialiased;\n }\n}\n\n/* ── Make it the CUSTOMER'S app, not ours ────────────────────────────────\n *\n * Everything above is a DEFAULT, not a house style. A Frontera app should\n * look like the product it belongs to, so override any token below in your\n * own stylesheet, imported after this file:\n *\n * :root {\n * --primary: #0b5fff; [your brand]\n * --radius: 0.25rem; [your shape]\n * --font-sans: \"Inter\", sans-serif;\n * --app-canvas: #f7f8fa; [page background]\n * --app-gutter: 2rem; [page padding]\n * --app-radius: 0.25rem; [card and tile corners]\n * --app-section-gap: 2rem; [vertical rhythm]\n * }\n *\n * The components read tokens, never literals, so redefining these restyles\n * the whole app without forking a single component. The app-* tokens are the\n * layout knobs the app-kit exposes; the rest are the shared semantic set.\n */\n"
|
|
19
|
+
"frontera/automation/messages.ts": "/**\n * The two things an author reads when the platform turns their code away.\n *\n * They live in the SDK, not in the runner, because three surfaces have to say\n * exactly the same sentence: the runner refusing a call before it makes it, the\n * service refusing it after, and `createTestContext` refusing it on the author's\n * own machine. Three copies of a message drift, and a test that fails with\n * different words than production is a test that teaches the wrong lesson.\n */\n\n/**\n * A `ctx` call the manifest does not permit.\n *\n * Names the fix, not the verdict: the author is looking at CLI output, and\n * \"missing grant\" without the remedy costs them a round trip through the docs.\n */\nexport function missingGrantMessage(grant: string): string {\n return `Automation is missing the \"${grant}\" grant. Add it to the manifest and redeploy.`\n}\n\n/**\n * One step name used twice in a run.\n *\n * The platform memoizes by name, so the second call would return the FIRST\n * step's result — no error, no warning, a wrong value flowing on. The remedy\n * names THIS step rather than a placeholder, because a hint that reads as code\n * to paste gets pasted.\n */\nexport function duplicateStepMessage(name: string): string {\n return (\n `Duplicate automation step name \"${name}\". Step names must be unique within a run — ` +\n \"the platform memoizes by name, so this call would return the first step's result \" +\n 'instead of running again. If this is a loop, add the index: ' +\n `ctx.step.run(\\`${name}:\\${i}\\`, ...)`\n )\n}\n",
|
|
20
|
+
"frontera/automation/testing.ts": "import { duplicateStepMessage, missingGrantMessage } from './messages'\nimport type {\n AutomationContext,\n BlueprintQueryOptions,\n BlueprintQueryResult,\n Grant,\n HttpRequest,\n HttpResponse,\n} from './types'\n\n/**\n * A `ctx` you can hand your handler in a unit test.\n *\n * Until this existed the only way to find out whether an automation worked was\n * to deploy it and run it — a loop measured in tens of seconds, against real\n * data, for a question as small as \"does the empty branch return the right\n * shape\".\n *\n * It enforces what the platform enforces, in the platform's own words: a\n * missing grant and a repeated step name fail here exactly as they fail in\n * production, so a green test means something.\n *\n * What it does NOT simulate is resumption. In production a handler is re-entered\n * after every step, so code outside a step runs many times; here the handler is\n * called once, straight through. Steps still memoize by name within the run, and\n * everything the handler did is recorded on `calls`.\n */\n\nexport interface TestCall {\n kind: 'step' | 'log' | 'agent' | 'http' | 'blueprint'\n /** Step name, log message, agent slug, URL, or object type. */\n label: string\n /** Present on a step: how it ended. */\n status?: 'ok' | 'error'\n}\n\nexport interface TestContextOptions {\n runId?: string\n workspaceId?: string\n /**\n * The grants the manifest declares.\n *\n * Given, they are enforced — which is the point: a missing grant is one of\n * the few automation bugs that only shows up in a deployed run, and it is\n * exactly the kind a unit test should catch.\n *\n * Omitted, nothing is refused, so an existing test does not have to enumerate\n * grants to keep passing.\n */\n grants?: readonly Grant[]\n /** Per-slug agent answers. An unstubbed agent throws rather than answering. */\n agents?: Record<string, (prompt: string) => Promise<{ text: string }> | { text: string }>\n /** Answers outbound requests. Unstubbed, `ctx.http.fetch` throws. */\n http?: (req: HttpRequest) => Promise<HttpResponse> | HttpResponse\n /** Rows per object type. An unstubbed type returns no rows, which is a real\n * answer and usually the branch worth testing. */\n blueprint?: Record<string, BlueprintQueryResult<never> | BlueprintQueryResult<Record<string, unknown>>>\n}\n\nexport interface TestContext {\n ctx: AutomationContext\n /** Everything the handler did, in order. */\n calls: TestCall[]\n /** Step names, in the order they ran. */\n steps: string[]\n logs: Array<{ message: string; data?: Record<string, unknown> }>\n}\n\nexport function createTestContext(options: TestContextOptions = {}): TestContext {\n const calls: TestCall[] = []\n const steps: string[] = []\n const logs: TestContext['logs'] = []\n const seenNames = new Set<string>()\n\n const requireGrant = (grant: string): void => {\n // No grant list means the test is not about grants. Enforcing an empty list\n // would fail every existing test for a reason its author never chose.\n if (!options.grants) return\n if (!options.grants.includes(grant as Grant)) throw new Error(missingGrantMessage(grant))\n }\n\n const ctx: AutomationContext = {\n runId: options.runId ?? 'test-run',\n workspaceId: options.workspaceId ?? 'test-workspace',\n\n step: {\n async run<T>(name: string, fn: () => Promise<T>): Promise<T> {\n if (seenNames.has(name)) throw new Error(duplicateStepMessage(name))\n seenNames.add(name)\n steps.push(name)\n try {\n const out = await fn()\n calls.push({ kind: 'step', label: name, status: 'ok' })\n return out\n } catch (err) {\n calls.push({ kind: 'step', label: name, status: 'error' })\n throw err\n }\n },\n },\n\n async log(message, data) {\n logs.push({ message, ...(data ? { data } : {}) })\n calls.push({ kind: 'log', label: message })\n },\n\n agent(slug: string) {\n return {\n async run(prompt: string) {\n requireGrant(`agent:${slug}:run`)\n calls.push({ kind: 'agent', label: slug })\n const stub = options.agents?.[slug]\n // Throwing beats answering with an empty string: a test whose agent\n // silently returns '' passes while asserting nothing about the step\n // that matters most.\n if (!stub) {\n throw new Error(\n `No agent stub for \"${slug}\". Pass agents: { '${slug}': () => ({ text: '…' }) } ` +\n 'to createTestContext.',\n )\n }\n return await stub(prompt)\n },\n }\n },\n\n http: {\n async fetch(req: HttpRequest) {\n let host: string\n try {\n host = new URL(req.url).hostname.toLowerCase()\n } catch {\n throw new Error(`ctx.http: invalid URL ${req.url}`)\n }\n requireGrant(`http:${host}`)\n calls.push({ kind: 'http', label: req.url })\n // Same reasoning as the agent: a fabricated 200 is a false pass.\n if (!options.http) {\n throw new Error(\n `No http stub. Pass http: (req) => ({ status: 200, headers: {}, body: '' }) ` +\n 'to createTestContext.',\n )\n }\n return await options.http(req)\n },\n },\n\n blueprint: {\n async query<T = Record<string, unknown>>(\n objectType: string,\n _options?: BlueprintQueryOptions,\n ): Promise<BlueprintQueryResult<T>> {\n requireGrant('blueprint:read')\n calls.push({ kind: 'blueprint', label: objectType })\n const stub = options.blueprint?.[objectType]\n // Empty is a real answer, and the branch an author most often forgets\n // to test — so this one defaults rather than throwing.\n return (stub ?? { rows: [], hasMore: false }) as BlueprintQueryResult<T>\n },\n },\n }\n\n return { ctx, calls, steps, logs }\n}\n",
|
|
21
|
+
"frontera/automation/manifest.ts": "import { CronExpressionParser } from 'cron-parser'\n\nconst SEGMENT = '[a-z][a-z0-9]*(?:-[a-z0-9]+)*'\nconst NAME_RE = new RegExp(`^${SEGMENT}$`)\n\n/**\n * Runtime gate for a grant: `<namespace>:<name>[:<action>]`, every segment\n * sharing NAME_RE's grammar so the whole vocabulary is consistent.\n *\n * WIDER than the `Grant` union on namespaces — a server must not reject\n * `notify:email` merely because this build predates it. NARROWER than the\n * union's `agent:${string}:run` arm on the slug, which admits `agent::run` and\n * `agent:AGENT:run`; both are rejected here. No legitimate slug is affected —\n * this repo's agent slugs are already lowercase-kebab.\n */\nconst GRANT_RE = new RegExp(`^${SEGMENT}:${SEGMENT}(?::${SEGMENT})?$`)\n\n/**\n * `http:<host>` and `secret:<NAME>` need their own grammars, because SEGMENT is\n * lowercase-kebab and neither value is.\n *\n * A host contains DOTS (`api.stripe.com`); a secret name is conventionally\n * SCREAMING_SNAKE_CASE (`STRIPE_KEY`). Validating them with SEGMENT rejected both\n * realistic forms — found by deploying an automation that used them.\n *\n * Deliberately not solved by widening SEGMENT: that governs agent slugs too, and\n * loosening it there would admit `agent:AGENT:run`, which the comment above says\n * is rejected on purpose.\n */\nconst HOST_RE = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)*$/\n// Matches SECRET_NAME_PATTERN in workspace-secrets-router exactly. Being MORE\n// permissive here would let a manifest declare `secret:myKey`, validate cleanly,\n// and then never be satisfiable — no such secret can be created. A validator that\n// accepts the unsatisfiable is worse than one that is strict.\nconst SECRET_NAME_RE = /^[A-Z][A-Z0-9_]*$/\n\n/** Namespaces whose value is not a SEGMENT. */\nconst TYPED_NAMESPACES: Record<string, { re: RegExp; hint: string }> = {\n http: { re: HOST_RE, hint: 'a hostname, e.g. \"http:api.stripe.com\" (no scheme, no path, no wildcard)' },\n secret: { re: SECRET_NAME_RE, hint: 'a workspace secret name, e.g. \"secret:STRIPE_KEY\"' },\n}\n\nconst KNOWN_KEYS = new Set([\n 'name', 'trigger', 'grants', 'concurrency', 'retries', 'description',\n])\n\nexport interface ValidationResult {\n valid: boolean\n errors: string[]\n /**\n * Non-fatal. An unknown manifest key lands here rather than in `errors`:\n * a newer SDK must be able to add a field without an older service refusing\n * the deploy. The CLI prints these, so a typo like `concurrancy: 100` — which\n * would otherwise deploy \"successfully\" with the default of 1 — is caught at\n * author time, where the SDK and the manifest are the same version.\n */\n warnings: string[]\n}\n\n/**\n * Takes `unknown`, on purpose.\n *\n * The authoritative call site is the service, validating a manifest that\n * arrived over HTTP — untrusted, and not yet known to have any shape. Typing\n * the parameter as `AutomationManifest` would force every honest caller to\n * launder untrusted input through a cast, which is how a validator ends up\n * trusting the thing it exists to check.\n *\n * The regexes here are deliberately wider than the `Grant` union in `types.ts`:\n * that union is an author-time affordance, this is a runtime gate, and a server\n * must not reject a grant merely because this build predates it.\n */\nexport function validateManifest(input: unknown): ValidationResult {\n const errors: string[] = []\n const warnings: string[] = []\n const m = (input ?? {}) as {\n name?: unknown\n trigger?: unknown\n grants?: unknown\n concurrency?: unknown\n retries?: unknown\n }\n\n if (typeof m.name !== 'string' || !NAME_RE.test(m.name)) {\n errors.push('name must be lowercase kebab-case')\n } else if (m.name.length > 64) {\n errors.push('name must be 64 characters or fewer')\n }\n\n const trigger = m.trigger as { cron?: string; manual?: boolean } | undefined\n if (!trigger || (trigger.cron === undefined && trigger.manual !== true)) {\n errors.push('trigger must be { cron } or { manual: true }')\n } else if (trigger.cron !== undefined) {\n if (typeof trigger.cron !== 'string') {\n errors.push('invalid cron expression: must be a string')\n } else {\n // Both field-count branches exist because `cron-parser` accepts an\n // off-count expression rather than throwing, so neither case would ever\n // reach the `catch` below:\n // `* * * * * *` -> reads field 1 as SECONDS and fires sub-minute.\n // `0 7 * *` -> left-pads, scheduling something the author never wrote.\n // Only an exactly-5-field expression means what it looks like it means.\n const fields = trigger.cron.trim().split(/\\s+/).length\n if (fields !== 5) {\n // One message shape for one class of fault. Splitting it meant a\n // 7-field expression was told it was \"sub-minute\" — a diagnosis\n // asserted rather than derived — while a 4-field one got no diagnosis\n // at all.\n errors.push(\n `invalid cron expression: expected 5 fields, got ${fields}` +\n (fields > 5 ? '; sub-minute schedules are not supported' : ''),\n )\n } else {\n try {\n CronExpressionParser.parse(trigger.cron, { tz: 'UTC' })\n } catch (err) {\n errors.push(`invalid cron expression: ${(err as Error).message}`)\n }\n }\n }\n }\n\n if (m.grants !== undefined && !Array.isArray(m.grants)) {\n errors.push('grants must be an array')\n } else {\n for (const g of (m.grants as unknown[]) ?? []) {\n // String(g), not `${g}` — a template literal THROWS on a symbol, and a\n // validator that exists to absorb hostile input must not have a throwing\n // path. The message names the fix, not just the verdict.\n if (typeof g !== 'string') {\n errors.push(\n `malformed grant \"${String(g)}\" — expected \"<namespace>:<action>\", ` +\n 'e.g. \"blueprint:read\" or \"agent:risk-analyst:run\"',\n )\n continue\n }\n const colon = g.indexOf(':')\n const typed = colon > 0 ? TYPED_NAMESPACES[g.slice(0, colon)] : undefined\n if (typed) {\n // A typed namespace validates its OWN value grammar. `http:` and\n // `secret:` carry hosts and secret names, neither of which is a SEGMENT.\n if (!typed.re.test(g.slice(colon + 1))) {\n errors.push(`malformed grant \"${g}\" — the part after the colon must be ${typed.hint}`)\n }\n continue\n }\n if (!GRANT_RE.test(g)) {\n errors.push(\n `malformed grant \"${String(g)}\" — expected \"<namespace>:<action>\", ` +\n 'e.g. \"blueprint:read\" or \"agent:risk-analyst:run\"',\n )\n }\n }\n }\n\n const c = m.concurrency\n if (c !== undefined && (!Number.isInteger(c) || (c as number) < 1 || (c as number) > 50)) {\n errors.push('concurrency must be an integer between 1 and 50')\n }\n\n // Capped at 5. Above that it is not a retry policy, it is a loop — and every\n // attempt re-runs whatever side effects the previous one already performed.\n const r = m.retries\n if (r !== undefined && (!Number.isInteger(r) || (r as number) < 0 || (r as number) > 5)) {\n errors.push('retries must be an integer between 0 and 5')\n }\n\n if (input && typeof input === 'object' && !Array.isArray(input)) {\n for (const key of Object.keys(input)) {\n if (!KNOWN_KEYS.has(key)) {\n warnings.push(`unknown manifest key \"${key}\" — ignored`)\n }\n }\n }\n\n return { valid: errors.length === 0, errors, warnings }\n}\n",
|
|
22
|
+
"frontera/automation/types.ts": "// `import type`, so this is erased at compile time and adds no runtime import —\n// but `@frontera-sdk/blueprint` is still a real `dependencies` entry, because\n// `WhereNode` is part of this package's PUBLIC type surface: anyone consuming\n// `AutomationContext` needs it to resolve. See the packaging note in\n// docs/superpowers/specs/2026-07-29-automations-ctx-blueprint-query-design.md —\n// a subset install that cannot resolve it aborts `bun install` outright.\nimport type { WhereNode } from '@frontera-sdk/blueprint/types'\n\n/**\n * Cron and manual only for now; event and webhook land with Event Triggers.\n *\n * The `?: never` members are load-bearing. Without them `{ cron, manual }`\n * typechecks — TypeScript's excess-property check admits any key present on\n * *some* member of a union — and the runner would have to decide at runtime\n * what a both-shaped trigger means.\n */\nexport type AutomationTrigger =\n | { cron: string; manual?: never }\n | { cron?: never; manual: true }\n\n/**\n * An author-time affordance, not a validation gate.\n *\n * `blueprint:read` is a literal, so the compiler completes it and offers \"Did\n * you mean 'blueprint:read'?\" on a typo. `agent:${string}:run` admits any slug\n * — including one that names no agent — so the union cannot be read as proof\n * that a grant is well-formed. The runtime gate is `validateManifest` in\n * `manifest.ts`; this exists to guide the author as they type.\n *\n * Widening it later (adding `notify:*`, `governed:*` with Governed Writes) is a\n * non-breaking change. Narrowing `string` to a union later would break every\n * automation already written, so it starts narrow.\n */\nexport type Grant =\n | 'blueprint:read'\n | `agent:${string}:run`\n /** One EXACT host, no wildcards. `http:api.stripe.com` matches that host and\n * nothing else — a wildcard would ask a reviewer to reason about\n * subdomain-takeover risk, and the answer is usually wrong. */\n | `http:${string}`\n /** The NAME of a workspace secret. Its VALUE never enters this process: you\n * name it, the platform injects it server-side. */\n | `secret:${string}`\n\nexport interface AutomationManifest {\n name: string\n trigger: AutomationTrigger\n grants?: readonly Grant[]\n concurrency?: number\n /**\n * Times the platform may retry a run that FAILED. Default 0, and the opt-in\n * is the contract.\n *\n * Setting this asserts your handler is safe to run twice. With `ctx.http` that\n * is a real claim rather than a formality — a retried run that charged a card\n * charges it again, and the platform cannot check idempotency on your behalf.\n * Per-automation, not global, because you are the only one who knows.\n *\n * Retries do NOT extend the ctx call budget: each attempt is a separate run\n * with its own meter.\n *\n * With steps, this is a bound on RUN attempts, and a step that fails is what\n * consumes one. Completed steps are not re-executed on the next attempt —\n * they return their stored results — so a retry resumes from the failure\n * rather than starting the work again. That is the point of putting a call\n * that costs something inside a step: `retries: 2` on a handler whose work is\n * all in steps re-runs only the step that failed, while the same setting on a\n * handler with no steps re-runs everything.\n */\n retries?: number\n description?: string\n}\n\n/**\n * What `automation()` guarantees once defaults are applied — nothing optional\n * left for a consumer to re-handle. Downstream code takes this, not\n * `AutomationManifest`, so it never re-derives a fact already established.\n */\nexport interface ResolvedAutomationManifest extends AutomationManifest {\n // Every member is readonly, not just the two with defaults. `Object.freeze`\n // in `define.ts` freezes the whole object at runtime, so leaving `name` or\n // `description` mutable in the type means `d.manifest.name = 'x'` compiles\n // and then throws — the same compile-clean/throw-at-runtime gap that the\n // removed `as string[]` cast used to create.\n readonly name: string\n readonly trigger: Readonly<AutomationTrigger>\n readonly grants: readonly Grant[]\n readonly concurrency: number\n readonly retries: number\n readonly description?: string\n}\n\nexport interface AgentHandle {\n run(prompt: string): Promise<{ text: string }>\n}\n\n/**\n * Durable steps.\n *\n * A step is the unit the platform can memoize, retry and draw. Work inside one\n * runs at most once per run; work outside one runs again every time the\n * platform resumes the handler, which it does after every step completes.\n *\n * That resumption is the whole model and it is what the three rules below are\n * about — none of them is a style preference.\n */\nexport interface StepApi {\n /**\n * Run `fn` as a durable step and return its result.\n *\n * Three rules, all enforced or observable rather than advisory:\n *\n * 1. **`name` must be unique within a run.** The platform memoizes by it, so a\n * repeated name would silently hand back the FIRST call's result. Inside a\n * loop, put the index in the name — `` `submit:${i}` ``. A repeat fails the\n * run naming the collision rather than returning the wrong value.\n * 2. **The result must be JSON-serializable.** It is stored and replayed, so a\n * `Date` comes back as a string and a class instance comes back as a plain\n * object. Return data, not objects with behaviour.\n * 3. **Code outside a step re-executes.** After each step the handler restarts\n * from the top with completed steps returning their stored results. A\n * `ctx.http` call sitting outside a step therefore fires once per step, and\n * spends its call budget every time. The Console flags such calls on a run\n * that used steps.\n */\n run<T>(name: string, fn: () => Promise<T>): Promise<T>\n}\n\n/** Read-only for now. `governed`/`notify` arrive with Governed Writes. */\nexport interface AutomationContext {\n runId: string\n workspaceId: string\n /** Never rejects — telemetry must not be able to fail a run. */\n log(message: string, data?: Record<string, unknown>): Promise<void>\n agent(slug: string): AgentHandle\n http: {\n /**\n * Call an allowlisted host, optionally with a workspace secret injected\n * server-side.\n *\n * Requires an `http:<host>` grant, and an `secret:<name>` grant when `auth`\n * is used. The secret's VALUE never enters this process — that is deliberate:\n * a credential this process never held cannot be leaked by a stray\n * `ctx.log`, an exception serialiser, or a dependency, and step details are\n * rendered verbatim in the Console.\n *\n * An upstream 4xx/5xx comes back as `status`, not as a throw. An API\n * answering 404 is data; only failures of the mechanism reject.\n */\n fetch(req: HttpRequest): Promise<HttpResponse>\n }\n blueprint: {\n query<T = Record<string, unknown>>(\n objectType: string,\n options?: BlueprintQueryOptions,\n ): Promise<BlueprintQueryResult<T>>\n }\n /**\n * Durable steps. See `StepApi`.\n *\n * Present on every automation — a handler that uses no steps behaves exactly\n * as it did before this existed, because a run with no steps is never\n * resumed.\n */\n step: StepApi\n}\n\nexport interface HttpRequest {\n url: string\n method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'\n headers?: Record<string, string>\n /** String only — no streaming, no binary. */\n body?: string\n /** Inject a workspace secret into one header. Needs a `secret:<name>` grant. */\n auth?: { header: string; secret: string; prefix?: string }\n}\n\nexport interface HttpResponse {\n status: number\n headers: Record<string, string>\n /** Capped at 1 MB. Exceeding the cap is an error, never a truncation — a\n * silently shortened response is a wrong answer that looks right. */\n body: string\n}\n\nexport interface BlueprintQueryOptions {\n /** The real Blueprint filter DSL, not a shorthand — `and`/`or`/`not`, ranges\n * and date presets all work. A convenience subset with no escape hatch is the\n * thing the first \"overdue OR flagged\" automation would have to work around. */\n where?: WhereNode\n select?: string[]\n /** `dir`, not `direction` — matches `QueryRequest` exactly. */\n orderBy?: Array<{ property: string; dir: 'asc' | 'desc' }>\n /** Default 100, clamped to 1000. Exceeding the cap sets `hasMore`; it never\n * truncates silently. */\n limit?: number\n /** Opaque. Pass back the previous result's `nextPageToken`; absent means the\n * first page. Cursor-based, so a scan stays correct while the table moves\n * underneath it — which a cron-driven automation's table always does. */\n pageToken?: string\n}\n\nexport interface BlueprintQueryResult<T = Record<string, unknown>> {\n rows: T[]\n /** True when the query matched more rows than were returned. */\n hasMore: boolean\n /** Present iff `hasMore`. Feed to the next call's `pageToken`.\n *\n * Forwarded rather than narrowed away on purpose: `hasMore` on its own is a\n * fact the author can do nothing about, which is how a digest over the first\n * 500 of 5,000 rows reports success. */\n nextPageToken?: string\n}\n\nexport type AutomationHandler = (ctx: AutomationContext) => Promise<unknown>\n\nexport interface AutomationDescriptor {\n readonly manifest: ResolvedAutomationManifest\n readonly handler: AutomationHandler\n}\n",
|
|
23
|
+
"frontera/automation/index.ts": "export { automation } from './define'\nexport { validateManifest } from './manifest'\nexport type { ValidationResult } from './manifest'\nexport { duplicateStepMessage, missingGrantMessage } from './messages'\nexport { createTestContext } from './testing'\nexport type { TestCall, TestContext, TestContextOptions } from './testing'\nexport type * from './types'\n",
|
|
24
|
+
"frontera/automation/define.ts": "import type {\n AutomationDescriptor,\n AutomationHandler,\n AutomationManifest,\n AutomationTrigger,\n} from './types'\n\nexport function automation(\n manifest: AutomationManifest,\n handler: AutomationHandler,\n): AutomationDescriptor {\n if (!manifest?.name) throw new Error('Automation name is required')\n if (typeof handler !== 'function') throw new Error('Automation handler must be a function')\n\n // Copied, not aliased. `{ ...manifest }` is shallow, so without this the\n // frozen manifest would still hold a live reference to the caller's trigger\n // object — and a later mutation of it would silently change the schedule the\n // runner registers.\n const trigger: AutomationTrigger = { ...manifest.trigger }\n\n return Object.freeze({\n manifest: Object.freeze({\n ...manifest,\n trigger: Object.freeze(trigger),\n grants: Object.freeze([...(manifest.grants ?? [])]),\n concurrency: manifest.concurrency ?? 1,\n retries: manifest.retries ?? 0,\n }),\n handler,\n })\n}\n",
|
|
25
|
+
"theme.css": "/* GENERATED from packages/web/src/app/globals.css — do not edit.\n * Refresh with `frontera app add theme`.\n *\n * Gives an app the same Tailwind utilities and design tokens the platform\n * uses, so copied components look native rather than unstyled. Import this\n * once from your entry (`import './theme.css'`).\n */\n@import \"tailwindcss\";\n\n@custom-variant dark (&:is(.dark *));\n\n@theme inline {\n --color-background: hsl(var(--background));\n --color-foreground: hsl(var(--foreground));\n --color-dot: var(--dot-foreground);\n --color-card: var(--card);\n --color-card-foreground: var(--card-foreground);\n --color-popover: var(--popover);\n --color-popover-foreground: var(--popover-foreground);\n --color-primary: var(--primary);\n --color-primary-foreground: var(--primary-foreground);\n --color-secondary: var(--secondary);\n --color-secondary-foreground: var(--secondary-foreground);\n --color-muted: var(--muted);\n --color-muted-foreground: var(--muted-foreground);\n --color-accent: var(--accent);\n --color-accent-foreground: var(--accent-foreground);\n --color-destructive: var(--destructive);\n --color-destructive-foreground: var(--destructive-foreground);\n --color-success: var(--success);\n --color-success-foreground: var(--success-foreground);\n --color-warning: var(--warning);\n --color-warning-foreground: var(--warning-foreground);\n --color-info: var(--info);\n --color-info-foreground: var(--info-foreground);\n --color-border: var(--border);\n --color-border-secondary: var(--border-secondary);\n --color-input: var(--input);\n --color-ring: var(--ring);\n --color-sidebar: var(--sidebar);\n --color-sidebar-foreground: var(--sidebar-foreground);\n --color-sidebar-primary: var(--sidebar-primary);\n --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);\n --color-sidebar-accent: var(--sidebar-accent);\n --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);\n --color-sidebar-border: var(--sidebar-border);\n --color-sidebar-ring: var(--sidebar-ring);\n --color-chart-1: var(--chart-1);\n --color-chart-2: var(--chart-2);\n --color-chart-3: var(--chart-3);\n --color-chart-4: var(--chart-4);\n --color-chart-5: var(--chart-5);\n --color-chart-6: var(--chart-6);\n --color-chart-7: var(--chart-7);\n --color-chart-8: var(--chart-8);\n --color-chart-9: var(--chart-9);\n --color-chart-10: var(--chart-10);\n --color-chart-11: var(--chart-11);\n --color-chart-12: var(--chart-12);\n --radius-sm: calc(var(--radius) - 4px);\n --radius-md: calc(var(--radius) - 2px);\n --radius-lg: var(--radius);\n --radius-xl: calc(var(--radius) + 4px);\n --radius-2xl: calc(var(--radius) + 8px);\n\n /* Shadow elevation tokens — Attio-inspired multi-layer */\n /* --shadow-xs: var(--elevation-xs);\n --shadow-sm: var(--elevation-sm);\n --shadow-md: var(--elevation-md);\n --shadow-lg: var(--elevation-lg);\n --shadow-xl: var(--elevation-xl); */\n\n /* Surface elevation tokens */\n --color-surface-inset-deep: var(--surface-inset-deep);\n --color-surface-inset-deep-hover: var(--surface-inset-deep-hover);\n --color-surface-inset-deep-active: var(--surface-inset-deep-active);\n --color-surface-inset: var(--surface-inset);\n --color-surface-inset-hover: var(--surface-inset-hover);\n --color-surface-inset-active: var(--surface-inset-active);\n --color-surface: var(--surface);\n --color-surface-chat: var(--surface-chat);\n --color-surface-hover: var(--surface-hover);\n --color-surface-active: var(--surface-active);\n --color-surface-raised: var(--surface-raised);\n --color-surface-raised-hover: var(--surface-raised-hover);\n --color-surface-raised-active: var(--surface-raised-active);\n /* --color-surface-overlay: var(--surface-raised);\n --color-surface-overlay-hover: var(--surface-raised-hover);\n --color-surface-overlay-active: var(--surface-raised-active); */\n --color-surface-overlay: var(--surface-overlay);\n --color-surface-overlay-hover: var(--surface-overlay-hover);\n --color-surface-overlay-active: var(--surface-overlay-active);\n /* Quint-out. For transitions long enough (250ms+) that Tailwind's `ease-out`\n — cubic-bezier(0, 0, 0.2, 1) — reads as near-constant motion: this covers\n 58% of the distance in the first 15% of the time against ease-out's 37%,\n so the element commits immediately and then settles. Use it for a surface\n opening or expanding; keep `ease-out` for short state changes, where the\n difference isn't perceptible. */\n --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);\n\n /* Image lightbox chrome sits over arbitrary pixels while still matching the\n active light/dark theme. */\n --color-image-overlay-scrim: var(--image-overlay-scrim);\n --color-image-overlay-control: var(--image-overlay-control);\n --color-image-overlay-control-hover: var(--image-overlay-control-hover);\n --color-image-overlay-border: var(--image-overlay-border);\n --color-image-overlay-foreground: var(--image-overlay-foreground);\n --color-image-overlay-muted: var(--image-overlay-muted);\n --color-image-overlay-thumb: var(--image-overlay-thumb);\n}\n\n:root {\n --radius: 0.625rem;\n\n /* Widest a config-row chip (skill / pack / app / context) may grow before\n its label truncates. Roughly 28 characters at text-xs — long enough to\n read a name, short enough that one chip can't monopolise the row. */\n --chip-max-width: 13rem;\n\n --background: 0 0% 100%;\n\n /* React flow canvas tokens */\n --dot-foreground: #c9c9c9;\n\n /* ── Surface elevation tokens ──────────────────── */\n --surface-inset-deep: hsl(0 0% 93%);\n --surface-inset-deep-hover: hsl(0 0% 89%);\n --surface-inset-deep-active: hsl(0 0% 86%);\n --surface-inset: hsl(0 0% 96%);\n --surface-inset-hover: hsl(0 0% 91%);\n --surface-inset-active: hsl(0 0% 88%);\n --surface: hsl(0 0% 98%);\n /* Chat-view backdrop — slightly warmer off-white than --surface, light only. */\n --surface-chat: #f9f9f9;\n --surface-hover: hsl(0 0% 96%);\n --surface-active: hsl(0 0% 94%);\n --surface-raised: hsl(0 0% 100%);\n --surface-raised-hover: hsl(0 0% 96%);\n --surface-raised-active: hsl(0 0% 94%);\n --surface-overlay: hsl(0 0% 100%);\n --surface-overlay-hover: hsl(0 0% 95%);\n --surface-overlay-active: hsl(0 0% 91%);\n --image-overlay-scrim: hsl(0 0% 0% / 70%);\n --image-overlay-control: var(--surface-overlay);\n --image-overlay-control-hover: var(--surface-overlay-hover);\n --image-overlay-border: var(--border);\n --image-overlay-foreground: hsl(var(--foreground));\n --image-overlay-muted: var(--muted-foreground);\n --image-overlay-thumb: var(--surface-inset);\n\n /* ── Shadow elevations: (light) ───── */\n --elevation-xs: 0px 0px 0px 1px rgba(42, 28, 0, 0.07);\n\n --elevation-sm:\n 0px 2px 4px 0px rgba(0, 0, 0, 0.04), 0px 0px 0px 1px rgba(42, 28, 0, 0.07);\n\n --elevation-md:\n 0px 8px 12px 0px rgba(25, 25, 25, 0.027),\n 0px 2px 6px 0px rgba(25, 25, 25, 0.027),\n 0px 0px 0px 1px rgba(42, 28, 0, 0.07);\n\n --elevation-lg:\n 0px 20px 24px 0px rgba(25, 25, 25, 0.05),\n 0px 5px 8px 0px rgba(25, 25, 25, 0.027),\n 0px 0px 0px 1px rgba(42, 28, 0, 0.07);\n\n --elevation-xl:\n 0px 24px 48px 0px rgba(25, 25, 25, 0.24),\n 0px 4px 12px 0px rgba(25, 25, 25, 0.14),\n 0px 0px 0px 1px rgba(42, 28, 0, 0.07);\n\n --foreground: 47 13% 14%;\n --card: var(--surface-raised);\n --card-foreground: 47 13% 14%;\n --popover: oklch(1 0 0);\n --popover-foreground: 47 13% 14%;\n --primary: oklch(0.21 0.006 285.885);\n --primary-foreground: oklch(0.985 0 0);\n --secondary: oklch(0.967 0.001 286.375);\n --secondary-foreground: oklch(0.21 0.006 285.885);\n --muted: oklch(0.967 0.001 286.375);\n --muted-foreground: oklch(0.5 0.016 285.938);\n --accent: oklch(0.967 0.001 286.375);\n --accent-foreground: 47 13% 14%;\n --destructive: oklch(0.577 0.245 27.325);\n --destructive-foreground: oklch(0.985 0 0);\n --success: oklch(0.627 0.194 149.214);\n --success-foreground: oklch(0.985 0 0);\n --warning: oklch(0.735 0.166 70.67);\n --warning-foreground: oklch(0.21 0.006 285.885);\n --info: oklch(0.6 0.15 240);\n --info-foreground: oklch(0.985 0 0);\n --border: hsl(240 100 6 / 0.05);\n --border-secondary: hsl(214 32% 96%);\n --input: oklch(0.92 0.004 286.32 / 0.75);\n --ring: oklch(0.705 0.015 286.067);\n --chart-1: #5b8dee;\n --chart-2: #3dab82;\n --chart-3: #e8883e;\n --chart-4: #9b7ef5;\n --chart-5: #e05c78;\n --chart-6: #3ab5cc;\n --chart-7: #a4b83a;\n --chart-8: #d47a4a;\n --chart-9: #748cd4;\n --chart-10: #4cad6a;\n /* Dashboard analytics series — extends the fixed chart palette. */\n --chart-11: #3b82f6;\n --chart-12: #10b981;\n --sidebar: oklch(0.985 0 0);\n --sidebar-foreground: oklch(0.141 0.005 285.823);\n --sidebar-primary: oklch(0.21 0.006 285.885);\n --sidebar-primary-foreground: oklch(0.985 0 0);\n --sidebar-accent: oklch(0.967 0.001 286.375);\n --sidebar-accent-foreground: oklch(0.21 0.006 285.885);\n --sidebar-border: oklch(0.92 0.004 286.32);\n --sidebar-ring: oklch(0.705 0.015 286.067);\n}\n\n.dark {\n --background: 0 0% 2%;\n\n /* React flow canvas tokens */\n --dot-foreground: #363636;\n\n /* ── Shadow elevations (dark) ───────────────────── */\n --elevation-xs: 0 0 0 1px #383836;\n\n --elevation-sm: 0 0 0 1px #383836, 0 2px 4px 0 rgba(0, 0, 0, 0.18);\n\n --elevation-md:\n 0 0 0 1px #383836, 0 8px 16px -4px rgba(0, 0, 0, 0.36),\n 0 2px 6px -2px rgba(0, 0, 0, 0.28);\n\n --elevation-lg:\n 0 0 0 1px #383836, 0 14px 28px -6px rgba(0, 0, 0, 0.44),\n 0 2px 4px -1px rgba(0, 0, 0, 0.28);\n\n --elevation-xl:\n 0 0 0 1px #383836, 0 24px 48px 0 rgba(0, 0, 0, 0.56),\n 0 4px 12px 0 rgba(0, 0, 0, 0.4);\n\n /* ── Surface elevation tokens ──────────────────── */\n --surface-inset-deep: hsl(0, 0%, 6%);\n --surface-inset-deep-hover: hsl(0 0% 8%);\n --surface-inset-deep-active: hsl(0 0% 11%);\n --surface-inset: hsl(0 0% 7.5%);\n --surface-inset-hover: hsl(0 0% 10%);\n --surface-inset-active: hsl(0 0% 12%);\n --surface: hsl(0 0% 9%);\n /* Dark mirrors --surface — chat backdrop is only retuned in light. */\n --surface-chat: hsl(0 0% 9%);\n --surface-hover: hsl(0 0% 14%);\n --surface-active: hsl(0 0% 17%);\n --surface-raised: hsl(0 0% 13%);\n --surface-raised-hover: hsl(0 0% 15%);\n --surface-raised-active: hsl(0 0% 17%);\n --surface-overlay: hsl(0 0% 9%);\n --surface-overlay-hover: hsl(0 0% 15%);\n --surface-overlay-active: hsl(0 0% 19%);\n --image-overlay-scrim: hsl(0 0% 0% / 70%);\n --image-overlay-control: hsl(0 0% 12% / 96%);\n --image-overlay-control-hover: hsl(0 0% 18% / 98%);\n --image-overlay-border: hsl(0 0% 100% / 12%);\n --image-overlay-foreground: hsl(0 0% 100%);\n --image-overlay-muted: hsl(0 0% 100% / 65%);\n --image-overlay-thumb: hsl(0 0% 0% / 35%);\n\n --foreground: 0 0% 83%;\n --card: var(--surface-raised);\n --card-foreground: hsl(0 0% 98%);\n --popover: hsl(0 0% 7%);\n --popover-foreground: hsl(0 0% 98%);\n --primary: hsl(0 0% 90%);\n --primary-foreground: hsl(0 0% 5%);\n --secondary: hsl(0 0% 12%);\n --secondary-foreground: hsl(0 0% 98%);\n --muted: hsl(0 0% 9%);\n --muted-foreground: hsl(0 0% 52%);\n --accent: hsl(0 0% 9%);\n --accent-foreground: hsl(0 0% 98%);\n --destructive: oklch(0.704 0.191 22.216);\n --destructive-foreground: oklch(0.985 0 0);\n --success: oklch(0.723 0.191 142.542);\n --success-foreground: oklch(0.985 0 0);\n --warning: oklch(0.815 0.152 78.2);\n --warning-foreground: oklch(0.21 0.006 285.885);\n --info: oklch(0.7 0.15 240);\n --info-foreground: oklch(0.985 0 0);\n --border: oklch(0.9296 0.007 106.53 / 0.08);\n --border-secondary: oklch(0.9296 0.007 106.53 / 0.03);\n --input: oklch(1 0 0 / 10%);\n --ring: oklch(0.552 0.016 285.938);\n --chart-1: #5b8dee;\n --chart-2: #3dab82;\n --chart-3: #e8883e;\n --chart-4: #9b7ef5;\n --chart-5: #e05c78;\n --chart-6: #3ab5cc;\n --chart-7: #a4b83a;\n --chart-8: #d47a4a;\n --chart-9: #748cd4;\n --chart-10: #4cad6a;\n --chart-11: #3b82f6;\n --chart-12: #10b981;\n --sidebar: oklch(0.21 0.006 285.885);\n --sidebar-foreground: oklch(0.985 0 0);\n --sidebar-primary: oklch(0.488 0.243 264.376);\n --sidebar-primary-foreground: oklch(0.985 0 0);\n --sidebar-accent: oklch(0.274 0.006 286.033);\n --sidebar-accent-foreground: oklch(0.985 0 0);\n --sidebar-border: oklch(1 0 0 / 10%);\n --sidebar-ring: oklch(0.552 0.016 285.938);\n}\n\n@layer base {\n * {\n border-color: var(--border);\n }\n body {\n background: var(--app-canvas, var(--surface));\n color: var(--foreground);\n font-family: var(--font-sans, ui-sans-serif, system-ui, sans-serif);\n -webkit-font-smoothing: antialiased;\n }\n}\n\n/* ── Make it the CUSTOMER'S app, not ours ────────────────────────────────\n *\n * Everything above is a DEFAULT, not a house style. A Frontera app should\n * look like the product it belongs to, so override any token below in your\n * own stylesheet, imported after this file:\n *\n * :root {\n * --primary: #0b5fff; [your brand]\n * --radius: 0.25rem; [your shape]\n * --font-sans: \"Inter\", sans-serif;\n * --app-canvas: #f7f8fa; [page background]\n * --app-gutter: 2rem; [page padding]\n * --app-radius: 0.25rem; [card and tile corners]\n * --app-section-gap: 2rem; [vertical rhythm]\n * }\n *\n * The components read tokens, never literals, so redefining these restyles\n * the whole app without forking a single component. The app-* tokens are the\n * layout knobs the app-kit exposes; the rest are the shared semantic set.\n */\n"
|
|
24
26
|
}
|
|
25
27
|
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { Command } from '../types'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Blueprint AUTHORING is not built yet.
|
|
5
|
-
*
|
|
6
|
-
* Reserved in the command table rather than left out, and this is the whole
|
|
7
|
-
* point of the distinction: a caller that reads "unknown command" concludes it
|
|
8
|
-
* mistyped and retries, while one that reads the real reason picks another
|
|
9
|
-
* route. An absent command and a deliberately withheld one are different
|
|
10
|
-
* facts.
|
|
11
|
-
*
|
|
12
|
-
* What is not ready is the organization-level shared draft — its revision
|
|
13
|
-
* lifecycle, adoption and grant model — not the noun. Reading ships today.
|
|
14
|
-
*/
|
|
15
|
-
const MESSAGE =
|
|
16
|
-
'blueprint authoring is not available in this release; ' +
|
|
17
|
-
'`frontera blueprint list` and `frontera blueprint get` are read-only'
|
|
18
|
-
|
|
19
|
-
const RESERVED_VERBS = [
|
|
20
|
-
{ verb: 'create', summary: 'Create an object type on the shared draft' },
|
|
21
|
-
{ verb: 'apply', summary: 'Apply a Blueprint document to the shared draft' },
|
|
22
|
-
{ verb: 'grant', summary: 'Grant Blueprint access to a workspace or agent' },
|
|
23
|
-
{ verb: 'publish', summary: 'Publish the shared draft as a release' },
|
|
24
|
-
] as const
|
|
25
|
-
|
|
26
|
-
export const blueprintReserved: Command[] = RESERVED_VERBS.map(({ verb, summary }) => ({
|
|
27
|
-
meta: {
|
|
28
|
-
noun: 'blueprint',
|
|
29
|
-
verb,
|
|
30
|
-
args: [],
|
|
31
|
-
flags: {},
|
|
32
|
-
summary,
|
|
33
|
-
examples: [`frontera blueprint ${verb}`],
|
|
34
|
-
reserved: MESSAGE,
|
|
35
|
-
},
|
|
36
|
-
async run() {
|
|
37
|
-
// Unreachable: the shell refuses a reserved command before dispatch.
|
|
38
|
-
throw new Error(MESSAGE)
|
|
39
|
-
},
|
|
40
|
-
}))
|