@agent-native/dispatch 0.8.27 → 0.8.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -212,7 +212,9 @@ npx @agent-native/core@latest code resume --last "check the auth edge cases next
212
212
 
213
213
  Slash goals can run from the interactive shell or directly from the command line, and `agent-native code goals` shows the goals registered in your checkout. A bare prompt starts a local coding-agent session, streams work, records transcript/status/tool events, and accepts follow-up prompts; `/migrate` is one specialized capability inside that general Code workspace. Project-specific slash commands live in `.agents/commands/*.md`, so teams can add prompts such as `/release-check` or `/migrate-commerce` without changing the framework. Installed `agent-native` with no arguments launches the Code workspace; `agent-native "fix tests"` starts an Agent-Native Code task directly. Use `agent-native create` when you want to create apps or workspaces.
214
214
 
215
- Working inside this repository? Use `pnpm dev:cli ...` to run the source CLI without building first, for example `pnpm dev:cli --help` or `pnpm dev:cli code goals`.
215
+ Working inside this repository? Use `pnpm dev` for the lazy framework dev gateway. It exposes the core templates on one local origin and starts each app only when you visit it, which keeps memory usage much lower than booting every server at once. To focus on specific templates, pass `--apps`, for example `pnpm dev -- --apps analytics,brain`. Use `pnpm dev:eager` only when you intentionally want the older eager mode that starts the selected template servers, frame, docs, and core watcher immediately. The old `pnpm dev:all` name still works as an alias for eager mode.
216
+
217
+ Use `pnpm dev:cli ...` to run the source CLI without building first, for example `pnpm dev:cli --help` or `pnpm dev:cli code goals`.
216
218
 
217
219
  The Code workspace uses the familiar Codex/Claude-style session loop: pick a previous session, list runs, check status, attach to live output, print logs, stop work, resume with context, open the local UI, and continue the same run from Desktop or CLI. The Desktop Code tab, `agent-native code ui`, background sessions, and sub-agent sessions all converge on the shared run harness/controller model instead of separate ad hoc runners. The primary modes are intentionally simple:
218
220
 
@@ -1,2 +1,17 @@
1
- export declare function resolveCatchAllTarget(appId: string): string | null;
1
+ interface WorkspaceAppManifestEntry {
2
+ id?: string;
3
+ path?: unknown;
4
+ url?: unknown;
5
+ }
6
+ interface BuiltinAgentEntry {
7
+ id: string;
8
+ url?: string | null;
9
+ }
10
+ interface ResolveCatchAllTargetOptions {
11
+ workspaceApps?: WorkspaceAppManifestEntry[] | null;
12
+ builtinAgents?: BuiltinAgentEntry[] | null;
13
+ }
14
+ export declare function resolveCatchAllTarget(appId: string, options?: ResolveCatchAllTargetOptions): string | null;
15
+ export declare function resolveServerCatchAllTarget(appId: string): Promise<string | null>;
16
+ export {};
2
17
  //# sourceMappingURL=catch-all-target.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"catch-all-target.d.ts","sourceRoot":"","sources":["../../src/lib/catch-all-target.ts"],"names":[],"mappings":"AAoDA,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA8ClE"}
1
+ {"version":3,"file":"catch-all-target.d.ts","sourceRoot":"","sources":["../../src/lib/catch-all-target.ts"],"names":[],"mappings":"AAAA,UAAU,yBAAyB;IACjC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,UAAU,iBAAiB;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,UAAU,4BAA4B;IACpC,aAAa,CAAC,EAAE,yBAAyB,EAAE,GAAG,IAAI,CAAC;IACnD,aAAa,CAAC,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC;CAC5C;AAiDD,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,4BAAiC,GACzC,MAAM,GAAG,IAAI,CA8Cf;AAED,wBAAsB,2BAA2B,CAC/C,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQxB"}
@@ -1,4 +1,3 @@
1
- import { getBuiltinAgents, loadWorkspaceAppsManifest, } from "@agent-native/core/server/agent-discovery";
2
1
  /**
3
2
  * Resolve where `/dispatch/<appId>` should bounce to when it doesn't match
4
3
  * an explicit dispatch route. Used by the `$appId` catch-all route loader.
@@ -11,7 +10,7 @@ import { getBuiltinAgents, loadWorkspaceAppsManifest, } from "@agent-native/core
11
10
  * present.
12
11
  * - Otherwise the `app.path` mounted under the workspace gateway is
13
12
  * used. Path is normalized to a leading slash if missing
14
- * (e.g. manifest entry `path: "my-forms"` `/my-forms`), so an app
13
+ * (e.g. manifest entry `path: "my-forms"` -> `/my-forms`), so an app
15
14
  * whose mounted path differs from its id ends up at the right place
16
15
  * instead of being silently rewritten to `/${appId}`.
17
16
  * - Bare entry with no path / url falls back to `/${appId}`.
@@ -47,8 +46,8 @@ function validatedAbsoluteUrl(value) {
47
46
  return undefined;
48
47
  }
49
48
  }
50
- export function resolveCatchAllTarget(appId) {
51
- const apps = loadWorkspaceAppsManifest();
49
+ export function resolveCatchAllTarget(appId, options = {}) {
50
+ const apps = options.workspaceApps;
52
51
  if (apps) {
53
52
  const app = apps.find((entry) => entry?.id === appId);
54
53
  if (app) {
@@ -78,7 +77,7 @@ export function resolveCatchAllTarget(appId) {
78
77
  // `\/evil.example` — same idea, leading-backslash variant.
79
78
  //
80
79
  // The manifest parser only checks `startsWith("/")` for the first
81
- // case, and even that allows `//evil…`. Defend in depth here by
80
+ // case, and even that allows `//evil...`. Defend in depth here by
82
81
  // collapsing any run of leading slashes-or-backslashes to one
83
82
  // forward slash. Same phishing vector that `validatedAbsoluteUrl`
84
83
  // closes for `app.url`.
@@ -89,7 +88,16 @@ export function resolveCatchAllTarget(appId) {
89
88
  return `/${appId}`;
90
89
  }
91
90
  }
92
- const builtin = getBuiltinAgents("dispatch").find((agent) => agent.id === appId);
91
+ const builtin = (options.builtinAgents ?? []).find((agent) => agent.id === appId);
93
92
  return builtin?.url ?? null;
94
93
  }
94
+ export async function resolveServerCatchAllTarget(appId) {
95
+ if (!import.meta.env.SSR)
96
+ return null;
97
+ const { getBuiltinAgents, loadWorkspaceAppsManifest } = await import("@agent-native/core/server/agent-discovery");
98
+ return resolveCatchAllTarget(appId, {
99
+ workspaceApps: loadWorkspaceAppsManifest(),
100
+ builtinAgents: getBuiltinAgents("dispatch"),
101
+ });
102
+ }
95
103
  //# sourceMappingURL=catch-all-target.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"catch-all-target.js","sourceRoot":"","sources":["../../src/lib/catch-all-target.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,2CAA2C,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH;;;;;;;;GAQG;AACH,SAAS,oBAAoB,CAAC,KAAc;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;QAAE,OAAO,SAAS,CAAC;IACjE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QACrC,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAChE,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC9C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,KAAa;IACjD,MAAM,IAAI,GAAG,yBAAyB,EAAE,CAAC;IACzC,IAAI,IAAI,EAAE,CAAC;QACT,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,KAAK,KAAK,CAAC,CAAC;QACtD,IAAI,GAAG,EAAE,CAAC;YACR,kEAAkE;YAClE,iEAAiE;YACjE,iEAAiE;YACjE,kEAAkE;YAClE,+DAA+D;YAC/D,mEAAmE;YACnE,MAAM,GAAG,GAAG,oBAAoB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC1C,IAAI,GAAG,EAAE,CAAC;gBACR,OAAO,GAAG,CAAC;YACb,CAAC;YACD,kEAAkE;YAClE,4DAA4D;YAC5D,iEAAiE;YACjE,mEAAmE;YACnE,EAAE;YACF,kEAAkE;YAClE,6DAA6D;YAC7D,iCAAiC;YACjC,EAAE;YACF,mEAAmE;YACnE,0DAA0D;YAC1D,mEAAmE;YACnE,kEAAkE;YAClE,+DAA+D;YAC/D,EAAE;YACF,kEAAkE;YAClE,gEAAgE;YAChE,8DAA8D;YAC9D,kEAAkE;YAClE,wBAAwB;YACxB,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;gBACpD,MAAM,UAAU,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;gBAC3D,OAAO,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,UAAU,EAAE,CAAC;YACpE,CAAC;YACD,OAAO,IAAI,KAAK,EAAE,CAAC;QACrB,CAAC;IACH,CAAC;IACD,MAAM,OAAO,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC,IAAI,CAC/C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,CAC9B,CAAC;IACF,OAAO,OAAO,EAAE,GAAG,IAAI,IAAI,CAAC;AAC9B,CAAC","sourcesContent":["import {\n getBuiltinAgents,\n loadWorkspaceAppsManifest,\n} from \"@agent-native/core/server/agent-discovery\";\n\n/**\n * Resolve where `/dispatch/<appId>` should bounce to when it doesn't match\n * an explicit dispatch route. Used by the `$appId` catch-all route loader.\n *\n * Resolution order:\n *\n * 1. Workspace apps manifest (env, .agent-native/workspace-apps.json, or a\n * filesystem scan of `apps/`).\n * - `app.url` (absolute URL — externally hosted workspace app) wins if\n * present.\n * - Otherwise the `app.path` mounted under the workspace gateway is\n * used. Path is normalized to a leading slash if missing\n * (e.g. manifest entry `path: \"my-forms\"` `/my-forms`), so an app\n * whose mounted path differs from its id ends up at the right place\n * instead of being silently rewritten to `/${appId}`.\n * - Bare entry with no path / url falls back to `/${appId}`.\n * 2. First-party template registry. When no workspace manifest matches\n * (framework dev with each template on its own port, hosted dispatch\n * with no sibling apps), return the matching template's deploy URL —\n * dev URL in development (e.g. http://localhost:8084 for forms), prod\n * URL in production (e.g. https://forms.agent-native.com).\n *\n * Returns `null` if neither lookup matches, letting the route render its\n * \"Page not found\" pane.\n */\n/**\n * Validate `app.url` is an absolute http(s) URL before we trust it as a\n * redirect target. A bare hostname (`\"forms.example.com\"`) or a\n * `javascript:` scheme would otherwise get returned verbatim from\n * `resolveCatchAllTarget` and produce a broken redirect (or a phishing\n * vector). Mirrors `normalizeWorkspaceAppUrl` in\n * `packages/core/src/deploy/workspace-deploy.ts` — but inlined to avoid\n * pulling the deploy CLI module into a runtime path.\n */\nfunction validatedAbsoluteUrl(value: unknown): string | undefined {\n if (typeof value !== \"string\" || !value.trim()) return undefined;\n try {\n const parsed = new URL(value.trim());\n if (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n return undefined;\n }\n return parsed.toString().replace(/\\/$/, \"\");\n } catch {\n return undefined;\n }\n}\n\nexport function resolveCatchAllTarget(appId: string): string | null {\n const apps = loadWorkspaceAppsManifest();\n if (apps) {\n const app = apps.find((entry) => entry?.id === appId);\n if (app) {\n // Explicit externally-hosted URL wins. Workspaces that point at a\n // remote deploy (e.g. a sibling app on Netlify) set `url` and we\n // should bounce the user there rather than mounting a local path\n // that doesn't exist inside the gateway. Validate the URL first —\n // a bare hostname or non-http(s) scheme would produce a broken\n // redirect (and a `javascript:` value would be a phishing vector).\n const url = validatedAbsoluteUrl(app.url);\n if (url) {\n return url;\n }\n // Fall back to the mounted path. Normalize to leading slash so an\n // entry whose path differs from its id (e.g. `id: \"forms\"`,\n // `path: \"my-forms\"`) still lands on the correct gateway mount —\n // not on `/${appId}`, which would silently route to the wrong app.\n //\n // Reject scheme-relative paths. Three variants reach this point —\n // all of them get collapsed to a single leading slash so the\n // redirect stays on the gateway:\n //\n // `//evil.example` — network-path reference, browser treats as\n // absolute (https://evil.example).\n // `/\\evil.example` — browsers normalize backslashes to forward\n // slashes during URL parsing, same result.\n // `\\/evil.example` — same idea, leading-backslash variant.\n //\n // The manifest parser only checks `startsWith(\"/\")` for the first\n // case, and even that allows `//evil…`. Defend in depth here by\n // collapsing any run of leading slashes-or-backslashes to one\n // forward slash. Same phishing vector that `validatedAbsoluteUrl`\n // closes for `app.url`.\n if (typeof app.path === \"string\" && app.path.trim()) {\n const normalized = app.path.trim().replace(/^[/\\\\]+/, \"/\");\n return normalized.startsWith(\"/\") ? normalized : `/${normalized}`;\n }\n return `/${appId}`;\n }\n }\n const builtin = getBuiltinAgents(\"dispatch\").find(\n (agent) => agent.id === appId,\n );\n return builtin?.url ?? null;\n}\n"]}
1
+ {"version":3,"file":"catch-all-target.js","sourceRoot":"","sources":["../../src/lib/catch-all-target.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH;;;;;;;;GAQG;AACH,SAAS,oBAAoB,CAAC,KAAc;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;QAAE,OAAO,SAAS,CAAC;IACjE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QACrC,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAChE,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,MAAM,CAAC,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IAAI,UAAU,EAAE,CAAC;YACpE,CAAC;YACD,OAAO,IAAI,KAAK,EAAE,CAAC;QACrB,CAAC;IACH,CAAC;IACD,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,IAAI,CAChD,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,CAC9B,CAAC;IACF,OAAO,OAAO,EAAE,GAAG,IAAI,IAAI,CAAC;AAC9B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,KAAa;IAEb,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IACtC,MAAM,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,GACnD,MAAM,MAAM,CAAC,2CAA2C,CAAC,CAAC;IAC5D,OAAO,qBAAqB,CAAC,KAAK,EAAE;QAClC,aAAa,EAAE,yBAAyB,EAAE;QAC1C,aAAa,EAAE,gBAAgB,CAAC,UAAU,CAAC;KAC5C,CAAC,CAAC;AACL,CAAC","sourcesContent":["interface WorkspaceAppManifestEntry {\n id?: string;\n path?: unknown;\n url?: unknown;\n}\n\ninterface BuiltinAgentEntry {\n id: string;\n url?: string | null;\n}\n\ninterface ResolveCatchAllTargetOptions {\n workspaceApps?: WorkspaceAppManifestEntry[] | null;\n builtinAgents?: BuiltinAgentEntry[] | null;\n}\n\n/**\n * Resolve where `/dispatch/<appId>` should bounce to when it doesn't match\n * an explicit dispatch route. Used by the `$appId` catch-all route loader.\n *\n * Resolution order:\n *\n * 1. Workspace apps manifest (env, .agent-native/workspace-apps.json, or a\n * filesystem scan of `apps/`).\n * - `app.url` (absolute URL — externally hosted workspace app) wins if\n * present.\n * - Otherwise the `app.path` mounted under the workspace gateway is\n * used. Path is normalized to a leading slash if missing\n * (e.g. manifest entry `path: \"my-forms\"` -> `/my-forms`), so an app\n * whose mounted path differs from its id ends up at the right place\n * instead of being silently rewritten to `/${appId}`.\n * - Bare entry with no path / url falls back to `/${appId}`.\n * 2. First-party template registry. When no workspace manifest matches\n * (framework dev with each template on its own port, hosted dispatch\n * with no sibling apps), return the matching template's deploy URL —\n * dev URL in development (e.g. http://localhost:8084 for forms), prod\n * URL in production (e.g. https://forms.agent-native.com).\n *\n * Returns `null` if neither lookup matches, letting the route render its\n * \"Page not found\" pane.\n */\n/**\n * Validate `app.url` is an absolute http(s) URL before we trust it as a\n * redirect target. A bare hostname (`\"forms.example.com\"`) or a\n * `javascript:` scheme would otherwise get returned verbatim from\n * `resolveCatchAllTarget` and produce a broken redirect (or a phishing\n * vector). Mirrors `normalizeWorkspaceAppUrl` in\n * `packages/core/src/deploy/workspace-deploy.ts` — but inlined to avoid\n * pulling the deploy CLI module into a runtime path.\n */\nfunction validatedAbsoluteUrl(value: unknown): string | undefined {\n if (typeof value !== \"string\" || !value.trim()) return undefined;\n try {\n const parsed = new URL(value.trim());\n if (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n return undefined;\n }\n return parsed.toString().replace(/\\/$/, \"\");\n } catch {\n return undefined;\n }\n}\n\nexport function resolveCatchAllTarget(\n appId: string,\n options: ResolveCatchAllTargetOptions = {},\n): string | null {\n const apps = options.workspaceApps;\n if (apps) {\n const app = apps.find((entry) => entry?.id === appId);\n if (app) {\n // Explicit externally-hosted URL wins. Workspaces that point at a\n // remote deploy (e.g. a sibling app on Netlify) set `url` and we\n // should bounce the user there rather than mounting a local path\n // that doesn't exist inside the gateway. Validate the URL first —\n // a bare hostname or non-http(s) scheme would produce a broken\n // redirect (and a `javascript:` value would be a phishing vector).\n const url = validatedAbsoluteUrl(app.url);\n if (url) {\n return url;\n }\n // Fall back to the mounted path. Normalize to leading slash so an\n // entry whose path differs from its id (e.g. `id: \"forms\"`,\n // `path: \"my-forms\"`) still lands on the correct gateway mount —\n // not on `/${appId}`, which would silently route to the wrong app.\n //\n // Reject scheme-relative paths. Three variants reach this point —\n // all of them get collapsed to a single leading slash so the\n // redirect stays on the gateway:\n //\n // `//evil.example` — network-path reference, browser treats as\n // absolute (https://evil.example).\n // `/\\evil.example` — browsers normalize backslashes to forward\n // slashes during URL parsing, same result.\n // `\\/evil.example` — same idea, leading-backslash variant.\n //\n // The manifest parser only checks `startsWith(\"/\")` for the first\n // case, and even that allows `//evil...`. Defend in depth here by\n // collapsing any run of leading slashes-or-backslashes to one\n // forward slash. Same phishing vector that `validatedAbsoluteUrl`\n // closes for `app.url`.\n if (typeof app.path === \"string\" && app.path.trim()) {\n const normalized = app.path.trim().replace(/^[/\\\\]+/, \"/\");\n return normalized.startsWith(\"/\") ? normalized : `/${normalized}`;\n }\n return `/${appId}`;\n }\n }\n const builtin = (options.builtinAgents ?? []).find(\n (agent) => agent.id === appId,\n );\n return builtin?.url ?? null;\n}\n\nexport async function resolveServerCatchAllTarget(\n appId: string,\n): Promise<string | null> {\n if (!import.meta.env.SSR) return null;\n const { getBuiltinAgents, loadWorkspaceAppsManifest } =\n await import(\"@agent-native/core/server/agent-discovery\");\n return resolveCatchAllTarget(appId, {\n workspaceApps: loadWorkspaceAppsManifest(),\n builtinAgents: getBuiltinAgents(\"dispatch\"),\n });\n}\n"]}
@@ -2,7 +2,7 @@ import { type ClientLoaderFunctionArgs, type LoaderFunctionArgs } from "react-ro
2
2
  export declare function meta(): {
3
3
  title: string;
4
4
  }[];
5
- export declare function loader({ params }: LoaderFunctionArgs): any;
5
+ export declare function loader({ params }: LoaderFunctionArgs): Promise<any>;
6
6
  export declare function clientLoader({ params, serverLoader, }: ClientLoaderFunctionArgs): Promise<unknown>;
7
7
  export default function WorkspaceAppCatchAllRoute(): import("react/jsx-runtime").JSX.Element;
8
8
  //# sourceMappingURL=$appId.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"$appId.d.ts","sourceRoot":"","sources":["../../../src/routes/pages/$appId.tsx"],"names":[],"mappings":"AACA,OAAO,EAKL,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACxB,MAAM,cAAc,CAAC;AAiBtB,wBAAgB,IAAI;;IAEnB;AA2CD,wBAAgB,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,kBAAkB,OAQpD;AAED,wBAAsB,YAAY,CAAC,EACjC,MAAM,EACN,YAAY,GACb,EAAE,wBAAwB,oBAS1B;AAED,MAAM,CAAC,OAAO,UAAU,yBAAyB,4CAgGhD"}
1
+ {"version":3,"file":"$appId.d.ts","sourceRoot":"","sources":["../../../src/routes/pages/$appId.tsx"],"names":[],"mappings":"AACA,OAAO,EAKL,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACxB,MAAM,cAAc,CAAC;AAiBtB,wBAAgB,IAAI;;IAEnB;AA2CD,wBAAsB,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,kBAAkB,gBAQ1D;AAED,wBAAsB,YAAY,CAAC,EACjC,MAAM,EACN,YAAY,GACb,EAAE,wBAAwB,oBAS1B;AAED,MAAM,CAAC,OAAO,UAAU,yBAAyB,4CAgGhD"}
@@ -7,7 +7,7 @@ import { DispatchShell } from "../../components/dispatch-shell.js";
7
7
  import { Spinner } from "../../components/ui/spinner.js";
8
8
  import { Badge } from "../../components/ui/badge.js";
9
9
  import { Button } from "../../components/ui/button.js";
10
- import { resolveCatchAllTarget } from "../../lib/catch-all-target.js";
10
+ import { resolveServerCatchAllTarget } from "../../lib/catch-all-target.js";
11
11
  import { workspaceAppHref, } from "../../lib/workspace-apps.js";
12
12
  export function meta() {
13
13
  return [{ title: "Workspace app - Dispatch" }];
@@ -53,14 +53,14 @@ function dispatchSelfRedirect(appId) {
53
53
  return appPath("/overview");
54
54
  return null;
55
55
  }
56
- export function loader({ params }) {
56
+ export async function loader({ params }) {
57
57
  const appId = params.appId;
58
58
  if (!appId)
59
59
  return null;
60
60
  const selfTarget = dispatchSelfRedirect(appId);
61
61
  if (selfTarget)
62
62
  throw redirect(selfTarget);
63
- const target = resolveCatchAllTarget(appId);
63
+ const target = await resolveServerCatchAllTarget(appId);
64
64
  if (target)
65
65
  throw redirect(target);
66
66
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"$appId.js","sourceRoot":"","sources":["../../../src/routes/pages/$appId.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,SAAS,GAGV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EACL,gBAAgB,GAEjB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,EAAE,KAAK,EAAE,0BAA0B,EAAE,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,SAAS,oBAAoB,CAAC,KAAyB;IACrD,IAAI,KAAK,KAAK,UAAU;QAAE,OAAO,OAAO,CAAC,WAAW,CAAC,CAAC;IACtD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,EAAE,MAAM,EAAsB;IACnD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;IAC3B,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,MAAM,UAAU,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAC/C,IAAI,UAAU;QA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cAAc,IAAC,IAAI,EAAE,EAAE,GAAI,gBAEtB,IACJ,EACN,aAAG,SAAS,EAAC,+BAA+B,mEACS,GAAG,EACtD,eAAM,SAAS,EAAC,2BAA2B,YAAE,GAAG,CAAC,IAAI,GAAQ,EAAC,GAAG,qEAE/D,EACH,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAChB,aAAG,SAAS,EAAC,+BAA+B,yBACjC,GAAG,CAAC,UAAU,IACrB,CACL,CAAC,CAAC,CAAC,IAAI,EACP,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAChB,KAAC,MAAM,IAAC,OAAO,kBACb,aAAG,IAAI,EAAE,GAAG,CAAC,UAAU,EAAE,MAAM,EAAC,QAAQ,EAAC,GAAG,EAAC,YAAY,oCAEvD,KAAC,gBAAgB,IAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAC,QAAQ,GAAG,IAC/C,GACG,CACV,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC,CAAC,CAAC,CACF,eAAK,SAAS,EAAC,WAAW,aACxB,aAAI,SAAS,EAAC,yCAAyC,+BAElD,EACL,aAAG,SAAS,EAAC,+BAA+B,aAC1C,gBAAM,SAAS,EAAC,2BAA2B,kBAAG,KAAK,IAAQ,mEAEzD,EACJ,KAAC,MAAM,IAAC,OAAO,kBACb,KAAC,IAAI,IAAC,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,4BAAoB,GACvC,IACL,CACP,IACG,GACQ,CACjB,CAAC;AACJ,CAAC","sourcesContent":["import { useEffect, useMemo } from \"react\";\nimport {\n Link,\n Navigate,\n redirect,\n useParams,\n type ClientLoaderFunctionArgs,\n type LoaderFunctionArgs,\n} from \"react-router\";\nimport { useActionQuery, appPath } from \"@agent-native/core/client\";\nimport {\n IconArrowLeft,\n IconArrowUpRight,\n IconClockHour4,\n} from \"@tabler/icons-react\";\nimport { DispatchShell } from \"@/components/dispatch-shell\";\nimport { Spinner } from \"@/components/ui/spinner\";\nimport { Badge } from \"@/components/ui/badge\";\nimport { Button } from \"@/components/ui/button\";\nimport { resolveCatchAllTarget } from \"@/lib/catch-all-target\";\nimport {\n workspaceAppHref,\n type WorkspaceAppSummary,\n} from \"@/lib/workspace-apps\";\n\nexport function meta() {\n return [{ title: \"Workspace app - Dispatch\" }];\n}\n\n/**\n * Catch-all for `/dispatch/<segment>` paths that don't match an explicit\n * Dispatch route. When `<segment>` is the id of a workspace app sibling\n * (e.g. `/dispatch/todo` after Builder.io routes a \"navigate to /todo\"\n * call through Dispatch's mount point), bounce to the absolute `/<appId>`\n * so the user lands on the actual app instead of a 404 inside Dispatch.\n *\n * Server-side redirect: we resolve the workspace app manifest via the\n * shared `loadWorkspaceAppsManifest()` helper, which checks the\n * `AGENT_NATIVE_WORKSPACE_APPS_JSON` env var, then the\n * `.agent-native/workspace-apps.json` file written by `workspace-deploy.ts`,\n * then a live filesystem scan of `apps/` for local dev. We then throw\n * `redirect(\"/<appId>\")`. React Router 7 does not prepend the basename to\n * absolute paths returned from a loader, so the redirect escapes Dispatch's\n * `/dispatch` mount cleanly.\n *\n * Why a catch-all instead of fixing the agent prompt: Builder.io currently\n * resolves \"navigate to /todo\" relative to Dispatch's mount, sending the\n * user to /dispatch/todo. The same wrong path then gets captured as the\n * OAuth callbackURL, so Google sign-in completes back at /dispatch/todo\n * and looks broken. This route fixes both the post-creation navigation\n * and the OAuth round-trip from a single place.\n *\n * Built-in template fallback: when no workspace manifest is available\n * (framework dev with each template on its own port, hosted dispatch with\n * no sibling apps), redirect to the matching first-party template's deploy\n * URL — `http://localhost:<devPort>` in dev, `https://<id>.agent-native.com`\n * in production. Without this, a user visiting `/forms` on dispatch is\n * forced to sign in (auth guard) and then lands on this route's \"Page not\n * found\" pane after the post-login reload.\n *\n * `appId === \"dispatch\"` short-circuit: when the segment matches Dispatch\n * itself (e.g. `/dispatch/dispatch`), we go straight to the overview rather\n * than chaining through `/dispatch` (which polled `useActionQuery` re-fired\n * `window.location.assign` against and looped forever in production).\n */\nfunction dispatchSelfRedirect(appId: string | undefined): string | null {\n if (appId === \"dispatch\") return appPath(\"/overview\");\n return null;\n}\n\nexport function loader({ params }: LoaderFunctionArgs) {\n const appId = params.appId;\n if (!appId) return null;\n const selfTarget = dispatchSelfRedirect(appId);\n if (selfTarget) throw redirect(selfTarget);\n const target = resolveCatchAllTarget(appId);\n if (target) throw redirect(target);\n return null;\n}\n\nexport async function clientLoader({\n params,\n serverLoader,\n}: ClientLoaderFunctionArgs) {\n const selfTarget = dispatchSelfRedirect(params.appId);\n if (selfTarget) throw redirect(selfTarget);\n // Defer to the server loader so the built-in template fallback runs on\n // SPA navigations too (e.g. clicking a `/<template-id>` link inside\n // dispatch). Without this the client side would only check the workspace\n // apps query, which never lists the static first-party templates and so\n // the user would land on the \"Page not found\" pane.\n return serverLoader();\n}\n\nexport default function WorkspaceAppCatchAllRoute() {\n const { appId } = useParams();\n const { data: apps = [], isLoading } = useActionQuery(\n \"list-workspace-apps\",\n { includeAgentCards: false },\n { refetchInterval: 2_000 },\n );\n const app = useMemo(\n () =>\n (apps as WorkspaceAppSummary[]).find((item) => item.id === appId) ?? null,\n [appId, apps],\n );\n const href = app ? workspaceAppHref(app) : null;\n const isSelfReference = appId === \"dispatch\";\n\n useEffect(() => {\n if (isSelfReference) return;\n if (!app || app.status === \"pending\" || !href) return;\n window.location.assign(href);\n }, [app, href, isSelfReference]);\n\n if (isSelfReference) {\n return <Navigate to={appPath(\"/overview\")} replace />;\n }\n\n if ((isLoading && !app) || (app && app.status !== \"pending\" && href)) {\n return (\n <div className=\"flex h-screen w-full items-center justify-center\">\n <Spinner className=\"size-8\" />\n </div>\n );\n }\n\n return (\n <DispatchShell\n title={app?.name || \"Page not found\"}\n description=\"This route is not in the workspace app list yet.\"\n >\n <div className=\"max-w-2xl rounded-lg border bg-card p-5\">\n <Button asChild size=\"sm\" variant=\"ghost\" className=\"-ml-2 mb-4\">\n <Link to={appPath(\"/overview\")}>\n <IconArrowLeft size={15} className=\"mr-1.5\" />\n Overview\n </Link>\n </Button>\n\n {app?.status === \"pending\" ? (\n <div className=\"space-y-4\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <h2 className=\"text-base font-semibold text-foreground\">\n {app.name}\n </h2>\n <Badge\n variant=\"outline\"\n className=\"gap-1 border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300\"\n >\n <IconClockHour4 size={12} />\n Building\n </Badge>\n </div>\n <p className=\"text-sm text-muted-foreground\">\n This app is being created. It will be available at{\" \"}\n <span className=\"font-mono text-foreground\">{app.path}</span>{\" \"}\n after its branch is merged and the workspace deploy finishes.\n </p>\n {app.branchName ? (\n <p className=\"text-xs text-muted-foreground\">\n Branch: {app.branchName}\n </p>\n ) : null}\n {app.builderUrl ? (\n <Button asChild>\n <a href={app.builderUrl} target=\"_blank\" rel=\"noreferrer\">\n Open Builder branch\n <IconArrowUpRight size={15} className=\"ml-1.5\" />\n </a>\n </Button>\n ) : null}\n </div>\n ) : (\n <div className=\"space-y-3\">\n <h2 className=\"text-base font-semibold text-foreground\">\n Page not found\n </h2>\n <p className=\"text-sm text-muted-foreground\">\n <span className=\"font-mono text-foreground\">/{appId}</span> isn't\n a Dispatch tab or a workspace app in this workspace.\n </p>\n <Button asChild>\n <Link to={appPath(\"/apps\")}>Browse apps</Link>\n </Button>\n </div>\n )}\n </div>\n </DispatchShell>\n );\n}\n"]}
1
+ {"version":3,"file":"$appId.js","sourceRoot":"","sources":["../../../src/routes/pages/$appId.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,SAAS,GAGV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aA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AG,CAAC,UAAU,EAAE,MAAM,EAAC,QAAQ,EAAC,GAAG,EAAC,YAAY,oCAEvD,KAAC,gBAAgB,IAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAC,QAAQ,GAAG,IAC/C,GACG,CACV,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC,CAAC,CAAC,CACF,eAAK,SAAS,EAAC,WAAW,aACxB,aAAI,SAAS,EAAC,yCAAyC,+BAElD,EACL,aAAG,SAAS,EAAC,+BAA+B,aAC1C,gBAAM,SAAS,EAAC,2BAA2B,kBAAG,KAAK,IAAQ,mEAEzD,EACJ,KAAC,MAAM,IAAC,OAAO,kBACb,KAAC,IAAI,IAAC,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,4BAAoB,GACvC,IACL,CACP,IACG,GACQ,CACjB,CAAC;AACJ,CAAC","sourcesContent":["import { useEffect, useMemo } from \"react\";\nimport {\n Link,\n Navigate,\n redirect,\n useParams,\n type ClientLoaderFunctionArgs,\n type LoaderFunctionArgs,\n} from \"react-router\";\nimport { useActionQuery, appPath } from \"@agent-native/core/client\";\nimport {\n IconArrowLeft,\n IconArrowUpRight,\n IconClockHour4,\n} from \"@tabler/icons-react\";\nimport { DispatchShell } from \"@/components/dispatch-shell\";\nimport { Spinner } from \"@/components/ui/spinner\";\nimport { Badge } from \"@/components/ui/badge\";\nimport { Button } from \"@/components/ui/button\";\nimport { resolveServerCatchAllTarget } from \"@/lib/catch-all-target\";\nimport {\n workspaceAppHref,\n type WorkspaceAppSummary,\n} from \"@/lib/workspace-apps\";\n\nexport function meta() {\n return [{ title: \"Workspace app - Dispatch\" }];\n}\n\n/**\n * Catch-all for `/dispatch/<segment>` paths that don't match an explicit\n * Dispatch route. When `<segment>` is the id of a workspace app sibling\n * (e.g. `/dispatch/todo` after Builder.io routes a \"navigate to /todo\"\n * call through Dispatch's mount point), bounce to the absolute `/<appId>`\n * so the user lands on the actual app instead of a 404 inside Dispatch.\n *\n * Server-side redirect: we resolve the workspace app manifest via the\n * shared `loadWorkspaceAppsManifest()` helper, which checks the\n * `AGENT_NATIVE_WORKSPACE_APPS_JSON` env var, then the\n * `.agent-native/workspace-apps.json` file written by `workspace-deploy.ts`,\n * then a live filesystem scan of `apps/` for local dev. We then throw\n * `redirect(\"/<appId>\")`. React Router 7 does not prepend the basename to\n * absolute paths returned from a loader, so the redirect escapes Dispatch's\n * `/dispatch` mount cleanly.\n *\n * Why a catch-all instead of fixing the agent prompt: Builder.io currently\n * resolves \"navigate to /todo\" relative to Dispatch's mount, sending the\n * user to /dispatch/todo. The same wrong path then gets captured as the\n * OAuth callbackURL, so Google sign-in completes back at /dispatch/todo\n * and looks broken. This route fixes both the post-creation navigation\n * and the OAuth round-trip from a single place.\n *\n * Built-in template fallback: when no workspace manifest is available\n * (framework dev with each template on its own port, hosted dispatch with\n * no sibling apps), redirect to the matching first-party template's deploy\n * URL — `http://localhost:<devPort>` in dev, `https://<id>.agent-native.com`\n * in production. Without this, a user visiting `/forms` on dispatch is\n * forced to sign in (auth guard) and then lands on this route's \"Page not\n * found\" pane after the post-login reload.\n *\n * `appId === \"dispatch\"` short-circuit: when the segment matches Dispatch\n * itself (e.g. `/dispatch/dispatch`), we go straight to the overview rather\n * than chaining through `/dispatch` (which polled `useActionQuery` re-fired\n * `window.location.assign` against and looped forever in production).\n */\nfunction dispatchSelfRedirect(appId: string | undefined): string | null {\n if (appId === \"dispatch\") return appPath(\"/overview\");\n return null;\n}\n\nexport async function loader({ params }: LoaderFunctionArgs) {\n const appId = params.appId;\n if (!appId) return null;\n const selfTarget = dispatchSelfRedirect(appId);\n if (selfTarget) throw redirect(selfTarget);\n const target = await resolveServerCatchAllTarget(appId);\n if (target) throw redirect(target);\n return null;\n}\n\nexport async function clientLoader({\n params,\n serverLoader,\n}: ClientLoaderFunctionArgs) {\n const selfTarget = dispatchSelfRedirect(params.appId);\n if (selfTarget) throw redirect(selfTarget);\n // Defer to the server loader so the built-in template fallback runs on\n // SPA navigations too (e.g. clicking a `/<template-id>` link inside\n // dispatch). Without this the client side would only check the workspace\n // apps query, which never lists the static first-party templates and so\n // the user would land on the \"Page not found\" pane.\n return serverLoader();\n}\n\nexport default function WorkspaceAppCatchAllRoute() {\n const { appId } = useParams();\n const { data: apps = [], isLoading } = useActionQuery(\n \"list-workspace-apps\",\n { includeAgentCards: false },\n { refetchInterval: 2_000 },\n );\n const app = useMemo(\n () =>\n (apps as WorkspaceAppSummary[]).find((item) => item.id === appId) ?? null,\n [appId, apps],\n );\n const href = app ? workspaceAppHref(app) : null;\n const isSelfReference = appId === \"dispatch\";\n\n useEffect(() => {\n if (isSelfReference) return;\n if (!app || app.status === \"pending\" || !href) return;\n window.location.assign(href);\n }, [app, href, isSelfReference]);\n\n if (isSelfReference) {\n return <Navigate to={appPath(\"/overview\")} replace />;\n }\n\n if ((isLoading && !app) || (app && app.status !== \"pending\" && href)) {\n return (\n <div className=\"flex h-screen w-full items-center justify-center\">\n <Spinner className=\"size-8\" />\n </div>\n );\n }\n\n return (\n <DispatchShell\n title={app?.name || \"Page not found\"}\n description=\"This route is not in the workspace app list yet.\"\n >\n <div className=\"max-w-2xl rounded-lg border bg-card p-5\">\n <Button asChild size=\"sm\" variant=\"ghost\" className=\"-ml-2 mb-4\">\n <Link to={appPath(\"/overview\")}>\n <IconArrowLeft size={15} className=\"mr-1.5\" />\n Overview\n </Link>\n </Button>\n\n {app?.status === \"pending\" ? (\n <div className=\"space-y-4\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <h2 className=\"text-base font-semibold text-foreground\">\n {app.name}\n </h2>\n <Badge\n variant=\"outline\"\n className=\"gap-1 border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300\"\n >\n <IconClockHour4 size={12} />\n Building\n </Badge>\n </div>\n <p className=\"text-sm text-muted-foreground\">\n This app is being created. It will be available at{\" \"}\n <span className=\"font-mono text-foreground\">{app.path}</span>{\" \"}\n after its branch is merged and the workspace deploy finishes.\n </p>\n {app.branchName ? (\n <p className=\"text-xs text-muted-foreground\">\n Branch: {app.branchName}\n </p>\n ) : null}\n {app.builderUrl ? (\n <Button asChild>\n <a href={app.builderUrl} target=\"_blank\" rel=\"noreferrer\">\n Open Builder branch\n <IconArrowUpRight size={15} className=\"ml-1.5\" />\n </a>\n </Button>\n ) : null}\n </div>\n ) : (\n <div className=\"space-y-3\">\n <h2 className=\"text-base font-semibold text-foreground\">\n Page not found\n </h2>\n <p className=\"text-sm text-muted-foreground\">\n <span className=\"font-mono text-foreground\">/{appId}</span> isn't\n a Dispatch tab or a workspace app in this workspace.\n </p>\n <Button asChild>\n <Link to={appPath(\"/apps\")}>Browse apps</Link>\n </Button>\n </div>\n )}\n </div>\n </DispatchShell>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"apps.d.ts","sourceRoot":"","sources":["../../../src/routes/pages/apps.tsx"],"names":[],"mappings":"AAoCA,wBAAgB,IAAI;;IAEnB;AAgCD,MAAM,CAAC,OAAO,UAAU,SAAS,4CAsMhC"}
1
+ {"version":3,"file":"apps.d.ts","sourceRoot":"","sources":["../../../src/routes/pages/apps.tsx"],"names":[],"mappings":"AAqCA,wBAAgB,IAAI;;IAEnB;AAiCD,MAAM,CAAC,OAAO,UAAU,SAAS,4CAsMhC"}
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useState } from "react";
3
3
  import { useActionMutation, useActionQuery } from "@agent-native/core/client";
4
- import { IconApps, IconBrain, IconBrush, IconCalendarMonth, IconChartBar, IconChevronDown, IconClipboardList, IconEyeOff, IconFileText, IconLoader2, IconMail, IconPhoto, IconPlus, IconPresentation, IconScreenShare, IconSparkles, IconStack3, IconVideo, } from "@tabler/icons-react";
4
+ import { IconApps, IconBrain, IconBrush, IconCalendarMonth, IconChartBar, IconChevronDown, IconClipboardList, IconContract, IconEyeOff, IconFileText, IconLoader2, IconMail, IconPhoto, IconPlus, IconPresentation, IconScreenShare, IconSparkles, IconStack3, IconVideo, } from "@tabler/icons-react";
5
5
  import { toast } from "sonner";
6
6
  import { CreateAppPopover } from "../../components/create-app-popover.js";
7
7
  import { DispatchShell } from "../../components/dispatch-shell.js";
@@ -23,6 +23,7 @@ const TEMPLATE_ICONS = {
23
23
  Photo: IconPhoto,
24
24
  ChartBar: IconChartBar,
25
25
  ClipboardList: IconClipboardList,
26
+ Contract: IconContract,
26
27
  Brush: IconBrush,
27
28
  Video: IconVideo,
28
29
  };
@@ -1 +1 @@
1
- {"version":3,"file":"apps.js","sourceRoot":"","sources":["../../../src/routes/pages/apps.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EACL,QAAQ,EACR,SAAS,EACT,SAAS,EACT,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,UAAU,EACV,SAAS,GACV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAGjC,MAAM,UAAU,IAAI;IAClB,OAAO,CA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AI,SAAS,EAAC,gDAAgD,YAC3D,QAAQ,CAAC,KAAK,GACZ,GACD,EACN,YAAG,SAAS,EAAC,iEAAiE,YAC3E,QAAQ,CAAC,IAAI,GACZ,EACJ,cAAK,SAAS,EAAC,cAAc,YAC3B,KAAC,MAAM,IACL,IAAI,EAAC,IAAI,EACT,OAAO,EAAC,SAAS,EACjB,QAAQ,EAAE,QAAQ,CAAC,SAAS,EAC5B,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,YAE1D,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CACpB,8BACE,KAAC,WAAW,IAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAC,qBAAqB,GAAG,iBAExD,CACJ,CAAC,CAAC,CAAC,CACF,8BACE,KAAC,QAAQ,IAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAC,QAAQ,GAAG,wBAExC,CACJ,GACM,GACL,IACF,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useState } from \"react\";\nimport { useActionMutation, useActionQuery } from \"@agent-native/core/client\";\nimport {\n IconApps,\n IconBrain,\n IconBrush,\n IconCalendarMonth,\n IconChartBar,\n IconChevronDown,\n IconClipboardList,\n IconEyeOff,\n IconFileText,\n IconLoader2,\n IconMail,\n IconPhoto,\n IconPlus,\n IconPresentation,\n IconScreenShare,\n IconSparkles,\n IconStack3,\n IconVideo,\n} from \"@tabler/icons-react\";\nimport { toast } from \"sonner\";\nimport { CreateAppPopover } from \"@/components/create-app-popover\";\nimport { DispatchShell } from \"@/components/dispatch-shell\";\nimport { WorkspaceAppCard } from \"@/components/workspace-app-card\";\nimport { Button } from \"@/components/ui/button\";\nimport {\n Collapsible,\n CollapsibleContent,\n CollapsibleTrigger,\n} from \"@/components/ui/collapsible\";\nimport { Skeleton } from \"@/components/ui/skeleton\";\nimport { cn } from \"@/lib/utils\";\nimport type { WorkspaceAppSummary } from \"@/lib/workspace-apps\";\n\nexport function meta() {\n return [{ title: \"Apps — Dispatch\" }];\n}\n\ninterface WorkspaceInfo {\n name: string | null;\n displayName: string | null;\n appCount: number;\n}\n\ninterface AvailableTemplate {\n name: string;\n label: string;\n hint: string;\n icon: string;\n color: string;\n colorRgb: string;\n core: boolean;\n}\n\nconst TEMPLATE_ICONS: Record<string, typeof IconMail> = {\n Mail: IconMail,\n CalendarMonth: IconCalendarMonth,\n FileText: IconFileText,\n Presentation: IconPresentation,\n ScreenShare: IconScreenShare,\n Brain: IconBrain,\n Photo: IconPhoto,\n ChartBar: IconChartBar,\n ClipboardList: IconClipboardList,\n Brush: IconBrush,\n Video: IconVideo,\n};\n\nexport default function AppsRoute() {\n const [showHidden, setShowHidden] = useState(false);\n const [templatesOpen, setTemplatesOpen] = useState(false);\n const { data: apps = [], isLoading: appsLoading } = useActionQuery(\n \"list-workspace-apps\",\n { includeAgentCards: false, includeArchived: true },\n {\n refetchInterval: 2_000,\n },\n );\n const { data: workspace } = useActionQuery(\n \"get-workspace-info\",\n {},\n { staleTime: 60_000 },\n );\n const { data: templates = [], isLoading: templatesLoading } = useActionQuery(\n \"list-available-workspace-templates\",\n {},\n { refetchInterval: 5_000 },\n );\n\n const ws = workspace as WorkspaceInfo | undefined;\n const workspaceLabel = ws?.displayName ?? ws?.name ?? null;\n const allApps = (apps as WorkspaceAppSummary[]).filter(\n (app) => !app.isDispatch,\n );\n const visibleApps = allApps.filter((app) => !app.archived);\n const archivedApps = allApps.filter((app) => app.archived);\n const typedTemplates = templates as AvailableTemplate[];\n const showAppSkeletons = appsLoading && allApps.length === 0;\n\n return (\n <DispatchShell\n title=\"Apps\"\n description={\n workspaceLabel\n ? `Apps in the \"${workspaceLabel}\" workspace. Each app gets its own route under this workspace and shares its database, auth, and agent chat.`\n : \"Open workspace apps and start new app creation from Dispatch.\"\n }\n >\n <div className=\"space-y-8\">\n <section className=\"space-y-3\">\n <div className=\"flex flex-wrap items-end justify-between gap-3\">\n <div className=\"flex min-w-0 items-start gap-2\">\n <IconApps\n size={16}\n className=\"mt-0.5 shrink-0 text-muted-foreground\"\n />\n <div className=\"min-w-0\">\n <h2 className=\"truncate text-sm font-semibold text-foreground\">\n {workspaceLabel\n ? `Apps in ${workspaceLabel}`\n : \"Workspace apps\"}\n </h2>\n <p className=\"mt-0.5 text-xs text-muted-foreground\">\n {visibleApps.length} active\n {archivedApps.length > 0\n ? ` · ${archivedApps.length} hidden`\n : \"\"}\n </p>\n </div>\n </div>\n {visibleApps.length > 0 ? (\n <CreateAppPopover\n align=\"end\"\n trigger={\n <Button size=\"sm\">\n <IconPlus size={15} className=\"mr-1.5\" />\n Create app\n </Button>\n }\n />\n ) : null}\n </div>\n\n {showAppSkeletons ? (\n <AppsSkeletonGrid />\n ) : visibleApps.length > 0 ? (\n <div className=\"grid auto-rows-fr gap-3 md:grid-cols-2 xl:grid-cols-3\">\n {visibleApps.map((app) => (\n <WorkspaceAppCard key={app.id} app={app} className=\"h-full\" />\n ))}\n </div>\n ) : (\n <EmptyAppsState />\n )}\n </section>\n\n {typedTemplates.length > 0 || templatesLoading ? (\n <Collapsible open={templatesOpen} onOpenChange={setTemplatesOpen}>\n <section className=\"space-y-3\">\n <div className=\"flex flex-wrap items-center justify-between gap-3 border-t pt-4\">\n <div className=\"flex min-w-0 items-center gap-2\">\n <IconStack3\n size={16}\n className=\"shrink-0 text-muted-foreground\"\n />\n <div className=\"min-w-0\">\n <h2 className=\"text-sm font-semibold text-foreground\">\n Templates\n </h2>\n <p className=\"text-xs text-muted-foreground\">\n {templatesLoading\n ? \"Checking available templates\"\n : `${typedTemplates.length} available to scaffold`}\n </p>\n </div>\n </div>\n <CollapsibleTrigger asChild>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n className=\"gap-1.5\"\n >\n {templatesOpen ? \"Hide\" : \"Show\"}\n <IconChevronDown\n size={14}\n className={cn(\n \"transition-transform\",\n templatesOpen && \"rotate-180\",\n )}\n />\n </Button>\n </CollapsibleTrigger>\n </div>\n <CollapsibleContent>\n {templatesLoading && typedTemplates.length === 0 ? (\n <AppsSkeletonGrid />\n ) : (\n <div className=\"grid auto-rows-fr gap-3 md:grid-cols-2 xl:grid-cols-3\">\n {typedTemplates.map((template) => (\n <AddTemplateCard\n key={template.name}\n template={template}\n />\n ))}\n </div>\n )}\n </CollapsibleContent>\n </section>\n </Collapsible>\n ) : null}\n\n {archivedApps.length > 0 ? (\n <Collapsible open={showHidden} onOpenChange={setShowHidden}>\n <section className=\"space-y-3\">\n <div className=\"flex flex-wrap items-center justify-between gap-3 border-t pt-4\">\n <div className=\"flex min-w-0 items-center gap-2\">\n <IconEyeOff\n size={16}\n className=\"shrink-0 text-muted-foreground\"\n />\n <div className=\"min-w-0\">\n <h2 className=\"text-sm font-semibold text-foreground\">\n Hidden apps\n </h2>\n <p className=\"text-xs text-muted-foreground\">\n {archivedApps.length} hidden{\" \"}\n {archivedApps.length === 1 ? \"app\" : \"apps\"}\n </p>\n </div>\n </div>\n <CollapsibleTrigger asChild>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n className=\"gap-1.5\"\n >\n {showHidden ? \"Hide\" : \"Show\"}\n <IconChevronDown\n size={14}\n className={cn(\n \"transition-transform\",\n showHidden && \"rotate-180\",\n )}\n />\n </Button>\n </CollapsibleTrigger>\n </div>\n <CollapsibleContent>\n <div className=\"grid auto-rows-fr gap-3 md:grid-cols-2 xl:grid-cols-3\">\n {archivedApps.map((app) => (\n <WorkspaceAppCard\n key={app.id}\n app={app}\n className=\"h-full\"\n />\n ))}\n </div>\n </CollapsibleContent>\n </section>\n </Collapsible>\n ) : null}\n </div>\n </DispatchShell>\n );\n}\n\nfunction AppsSkeletonGrid() {\n return (\n <div className=\"grid gap-3 md:grid-cols-2 xl:grid-cols-3\">\n {Array.from({ length: 3 }).map((_, index) => (\n <div key={index} className=\"rounded-lg border bg-card p-4\">\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"min-w-0 flex-1 space-y-3\">\n <Skeleton className=\"h-4 w-32\" />\n <Skeleton className=\"h-3 w-24\" />\n <div className=\"space-y-2 pt-1\">\n <Skeleton className=\"h-3 w-full\" />\n <Skeleton className=\"h-3 w-2/3\" />\n </div>\n </div>\n <Skeleton className=\"h-7 w-7 rounded-md\" />\n </div>\n </div>\n ))}\n </div>\n );\n}\n\nfunction EmptyAppsState() {\n return (\n <div className=\"rounded-lg border border-dashed bg-card px-4 py-10 text-center\">\n <div className=\"mx-auto flex size-10 items-center justify-center rounded-lg bg-muted text-muted-foreground\">\n <IconApps size={18} />\n </div>\n <h3 className=\"mt-3 text-sm font-semibold text-foreground\">\n No workspace apps yet\n </h3>\n <p className=\"mx-auto mt-1 max-w-sm text-sm text-muted-foreground\">\n Create an app when a workflow needs its own focused place to live.\n </p>\n <div className=\"mt-4\">\n <CreateAppPopover\n trigger={\n <Button size=\"sm\">\n <IconPlus size={15} className=\"mr-1.5\" />\n Create app\n </Button>\n }\n />\n </div>\n </div>\n );\n}\n\nfunction AddTemplateCard({ template }: { template: AvailableTemplate }) {\n const Icon = TEMPLATE_ICONS[template.icon] ?? IconSparkles;\n const scaffold = useActionMutation(\"scaffold-workspace-app\", {\n onSuccess: (result: any) => {\n toast.success(\n `Scaffolded apps/${result?.appId || template.name}. The gateway will pick it up shortly.`,\n );\n },\n onError: (err) => {\n toast.error(\n `Could not scaffold ${template.label}: ${\n err instanceof Error ? err.message : String(err)\n }`,\n );\n },\n });\n\n return (\n <div className=\"group relative flex h-full min-h-36 items-stretch gap-3 rounded-lg border bg-card p-4 transition hover:border-foreground/30\">\n <div\n className=\"flex h-9 w-9 shrink-0 items-center justify-center self-start rounded-md\"\n style={{\n backgroundColor: `rgb(${template.colorRgb} / 0.12)`,\n color: template.color,\n }}\n >\n <Icon size={18} />\n </div>\n <div className=\"flex min-w-0 flex-1 flex-col\">\n <div className=\"flex min-w-0 items-center gap-2\">\n <h3 className=\"truncate text-sm font-semibold text-foreground\">\n {template.label}\n </h3>\n </div>\n <p className=\"mt-1 line-clamp-2 text-xs leading-relaxed text-muted-foreground\">\n {template.hint}\n </p>\n <div className=\"mt-auto pt-3\">\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={scaffold.isPending}\n onClick={() => scaffold.mutate({ template: template.name })}\n >\n {scaffold.isPending ? (\n <>\n <IconLoader2 size={14} className=\"mr-1.5 animate-spin\" />\n Adding...\n </>\n ) : (\n <>\n <IconPlus size={14} className=\"mr-1.5\" />\n Add to workspace\n </>\n )}\n </Button>\n </div>\n </div>\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"apps.js","sourceRoot":"","sources":["../../../src/routes/pages/apps.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EACL,QAAQ,EACR,SAAS,EACT,SAAS,EACT,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,UAAU,EACV,SAAS,GACV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,EAAE,EAAE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AAI,GACd,EACN,eAAK,SAAS,EAAC,8BAA8B,aAC3C,cAAK,SAAS,EAAC,iCAAiC,YAC9C,aAAI,SAAS,EAAC,gDAAgD,YAC3D,QAAQ,CAAC,KAAK,GACZ,GACD,EACN,YAAG,SAAS,EAAC,iEAAiE,YAC3E,QAAQ,CAAC,IAAI,GACZ,EACJ,cAAK,SAAS,EAAC,cAAc,YAC3B,KAAC,MAAM,IACL,IAAI,EAAC,IAAI,EACT,OAAO,EAAC,SAAS,EACjB,QAAQ,EAAE,QAAQ,CAAC,SAAS,EAC5B,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,YAE1D,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CACpB,8BACE,KAAC,WAAW,IAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAC,qBAAqB,GAAG,iBAExD,CACJ,CAAC,CAAC,CAAC,CACF,8BACE,KAAC,QAAQ,IAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAC,QAAQ,GAAG,wBAExC,CACJ,GACM,GACL,IACF,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useState } from \"react\";\nimport { useActionMutation, useActionQuery } from \"@agent-native/core/client\";\nimport {\n IconApps,\n IconBrain,\n IconBrush,\n IconCalendarMonth,\n IconChartBar,\n IconChevronDown,\n IconClipboardList,\n IconContract,\n IconEyeOff,\n IconFileText,\n IconLoader2,\n IconMail,\n IconPhoto,\n IconPlus,\n IconPresentation,\n IconScreenShare,\n IconSparkles,\n IconStack3,\n IconVideo,\n} from \"@tabler/icons-react\";\nimport { toast } from \"sonner\";\nimport { CreateAppPopover } from \"@/components/create-app-popover\";\nimport { DispatchShell } from \"@/components/dispatch-shell\";\nimport { WorkspaceAppCard } from \"@/components/workspace-app-card\";\nimport { Button } from \"@/components/ui/button\";\nimport {\n Collapsible,\n CollapsibleContent,\n CollapsibleTrigger,\n} from \"@/components/ui/collapsible\";\nimport { Skeleton } from \"@/components/ui/skeleton\";\nimport { cn } from \"@/lib/utils\";\nimport type { WorkspaceAppSummary } from \"@/lib/workspace-apps\";\n\nexport function meta() {\n return [{ title: \"Apps — Dispatch\" }];\n}\n\ninterface WorkspaceInfo {\n name: string | null;\n displayName: string | null;\n appCount: number;\n}\n\ninterface AvailableTemplate {\n name: string;\n label: string;\n hint: string;\n icon: string;\n color: string;\n colorRgb: string;\n core: boolean;\n}\n\nconst TEMPLATE_ICONS: Record<string, typeof IconMail> = {\n Mail: IconMail,\n CalendarMonth: IconCalendarMonth,\n FileText: IconFileText,\n Presentation: IconPresentation,\n ScreenShare: IconScreenShare,\n Brain: IconBrain,\n Photo: IconPhoto,\n ChartBar: IconChartBar,\n ClipboardList: IconClipboardList,\n Contract: IconContract,\n Brush: IconBrush,\n Video: IconVideo,\n};\n\nexport default function AppsRoute() {\n const [showHidden, setShowHidden] = useState(false);\n const [templatesOpen, setTemplatesOpen] = useState(false);\n const { data: apps = [], isLoading: appsLoading } = useActionQuery(\n \"list-workspace-apps\",\n { includeAgentCards: false, includeArchived: true },\n {\n refetchInterval: 2_000,\n },\n );\n const { data: workspace } = useActionQuery(\n \"get-workspace-info\",\n {},\n { staleTime: 60_000 },\n );\n const { data: templates = [], isLoading: templatesLoading } = useActionQuery(\n \"list-available-workspace-templates\",\n {},\n { refetchInterval: 5_000 },\n );\n\n const ws = workspace as WorkspaceInfo | undefined;\n const workspaceLabel = ws?.displayName ?? ws?.name ?? null;\n const allApps = (apps as WorkspaceAppSummary[]).filter(\n (app) => !app.isDispatch,\n );\n const visibleApps = allApps.filter((app) => !app.archived);\n const archivedApps = allApps.filter((app) => app.archived);\n const typedTemplates = templates as AvailableTemplate[];\n const showAppSkeletons = appsLoading && allApps.length === 0;\n\n return (\n <DispatchShell\n title=\"Apps\"\n description={\n workspaceLabel\n ? `Apps in the \"${workspaceLabel}\" workspace. Each app gets its own route under this workspace and shares its database, auth, and agent chat.`\n : \"Open workspace apps and start new app creation from Dispatch.\"\n }\n >\n <div className=\"space-y-8\">\n <section className=\"space-y-3\">\n <div className=\"flex flex-wrap items-end justify-between gap-3\">\n <div className=\"flex min-w-0 items-start gap-2\">\n <IconApps\n size={16}\n className=\"mt-0.5 shrink-0 text-muted-foreground\"\n />\n <div className=\"min-w-0\">\n <h2 className=\"truncate text-sm font-semibold text-foreground\">\n {workspaceLabel\n ? `Apps in ${workspaceLabel}`\n : \"Workspace apps\"}\n </h2>\n <p className=\"mt-0.5 text-xs text-muted-foreground\">\n {visibleApps.length} active\n {archivedApps.length > 0\n ? ` · ${archivedApps.length} hidden`\n : \"\"}\n </p>\n </div>\n </div>\n {visibleApps.length > 0 ? (\n <CreateAppPopover\n align=\"end\"\n trigger={\n <Button size=\"sm\">\n <IconPlus size={15} className=\"mr-1.5\" />\n Create app\n </Button>\n }\n />\n ) : null}\n </div>\n\n {showAppSkeletons ? (\n <AppsSkeletonGrid />\n ) : visibleApps.length > 0 ? (\n <div className=\"grid auto-rows-fr gap-3 md:grid-cols-2 xl:grid-cols-3\">\n {visibleApps.map((app) => (\n <WorkspaceAppCard key={app.id} app={app} className=\"h-full\" />\n ))}\n </div>\n ) : (\n <EmptyAppsState />\n )}\n </section>\n\n {typedTemplates.length > 0 || templatesLoading ? (\n <Collapsible open={templatesOpen} onOpenChange={setTemplatesOpen}>\n <section className=\"space-y-3\">\n <div className=\"flex flex-wrap items-center justify-between gap-3 border-t pt-4\">\n <div className=\"flex min-w-0 items-center gap-2\">\n <IconStack3\n size={16}\n className=\"shrink-0 text-muted-foreground\"\n />\n <div className=\"min-w-0\">\n <h2 className=\"text-sm font-semibold text-foreground\">\n Templates\n </h2>\n <p className=\"text-xs text-muted-foreground\">\n {templatesLoading\n ? \"Checking available templates\"\n : `${typedTemplates.length} available to scaffold`}\n </p>\n </div>\n </div>\n <CollapsibleTrigger asChild>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n className=\"gap-1.5\"\n >\n {templatesOpen ? \"Hide\" : \"Show\"}\n <IconChevronDown\n size={14}\n className={cn(\n \"transition-transform\",\n templatesOpen && \"rotate-180\",\n )}\n />\n </Button>\n </CollapsibleTrigger>\n </div>\n <CollapsibleContent>\n {templatesLoading && typedTemplates.length === 0 ? (\n <AppsSkeletonGrid />\n ) : (\n <div className=\"grid auto-rows-fr gap-3 md:grid-cols-2 xl:grid-cols-3\">\n {typedTemplates.map((template) => (\n <AddTemplateCard\n key={template.name}\n template={template}\n />\n ))}\n </div>\n )}\n </CollapsibleContent>\n </section>\n </Collapsible>\n ) : null}\n\n {archivedApps.length > 0 ? (\n <Collapsible open={showHidden} onOpenChange={setShowHidden}>\n <section className=\"space-y-3\">\n <div className=\"flex flex-wrap items-center justify-between gap-3 border-t pt-4\">\n <div className=\"flex min-w-0 items-center gap-2\">\n <IconEyeOff\n size={16}\n className=\"shrink-0 text-muted-foreground\"\n />\n <div className=\"min-w-0\">\n <h2 className=\"text-sm font-semibold text-foreground\">\n Hidden apps\n </h2>\n <p className=\"text-xs text-muted-foreground\">\n {archivedApps.length} hidden{\" \"}\n {archivedApps.length === 1 ? \"app\" : \"apps\"}\n </p>\n </div>\n </div>\n <CollapsibleTrigger asChild>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n className=\"gap-1.5\"\n >\n {showHidden ? \"Hide\" : \"Show\"}\n <IconChevronDown\n size={14}\n className={cn(\n \"transition-transform\",\n showHidden && \"rotate-180\",\n )}\n />\n </Button>\n </CollapsibleTrigger>\n </div>\n <CollapsibleContent>\n <div className=\"grid auto-rows-fr gap-3 md:grid-cols-2 xl:grid-cols-3\">\n {archivedApps.map((app) => (\n <WorkspaceAppCard\n key={app.id}\n app={app}\n className=\"h-full\"\n />\n ))}\n </div>\n </CollapsibleContent>\n </section>\n </Collapsible>\n ) : null}\n </div>\n </DispatchShell>\n );\n}\n\nfunction AppsSkeletonGrid() {\n return (\n <div className=\"grid gap-3 md:grid-cols-2 xl:grid-cols-3\">\n {Array.from({ length: 3 }).map((_, index) => (\n <div key={index} className=\"rounded-lg border bg-card p-4\">\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"min-w-0 flex-1 space-y-3\">\n <Skeleton className=\"h-4 w-32\" />\n <Skeleton className=\"h-3 w-24\" />\n <div className=\"space-y-2 pt-1\">\n <Skeleton className=\"h-3 w-full\" />\n <Skeleton className=\"h-3 w-2/3\" />\n </div>\n </div>\n <Skeleton className=\"h-7 w-7 rounded-md\" />\n </div>\n </div>\n ))}\n </div>\n );\n}\n\nfunction EmptyAppsState() {\n return (\n <div className=\"rounded-lg border border-dashed bg-card px-4 py-10 text-center\">\n <div className=\"mx-auto flex size-10 items-center justify-center rounded-lg bg-muted text-muted-foreground\">\n <IconApps size={18} />\n </div>\n <h3 className=\"mt-3 text-sm font-semibold text-foreground\">\n No workspace apps yet\n </h3>\n <p className=\"mx-auto mt-1 max-w-sm text-sm text-muted-foreground\">\n Create an app when a workflow needs its own focused place to live.\n </p>\n <div className=\"mt-4\">\n <CreateAppPopover\n trigger={\n <Button size=\"sm\">\n <IconPlus size={15} className=\"mr-1.5\" />\n Create app\n </Button>\n }\n />\n </div>\n </div>\n );\n}\n\nfunction AddTemplateCard({ template }: { template: AvailableTemplate }) {\n const Icon = TEMPLATE_ICONS[template.icon] ?? IconSparkles;\n const scaffold = useActionMutation(\"scaffold-workspace-app\", {\n onSuccess: (result: any) => {\n toast.success(\n `Scaffolded apps/${result?.appId || template.name}. The gateway will pick it up shortly.`,\n );\n },\n onError: (err) => {\n toast.error(\n `Could not scaffold ${template.label}: ${\n err instanceof Error ? err.message : String(err)\n }`,\n );\n },\n });\n\n return (\n <div className=\"group relative flex h-full min-h-36 items-stretch gap-3 rounded-lg border bg-card p-4 transition hover:border-foreground/30\">\n <div\n className=\"flex h-9 w-9 shrink-0 items-center justify-center self-start rounded-md\"\n style={{\n backgroundColor: `rgb(${template.colorRgb} / 0.12)`,\n color: template.color,\n }}\n >\n <Icon size={18} />\n </div>\n <div className=\"flex min-w-0 flex-1 flex-col\">\n <div className=\"flex min-w-0 items-center gap-2\">\n <h3 className=\"truncate text-sm font-semibold text-foreground\">\n {template.label}\n </h3>\n </div>\n <p className=\"mt-1 line-clamp-2 text-xs leading-relaxed text-muted-foreground\">\n {template.hint}\n </p>\n <div className=\"mt-auto pt-3\">\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={scaffold.isPending}\n onClick={() => scaffold.mutate({ template: template.name })}\n >\n {scaffold.isPending ? (\n <>\n <IconLoader2 size={14} className=\"mr-1.5 animate-spin\" />\n Adding...\n </>\n ) : (\n <>\n <IconPlus size={14} className=\"mr-1.5\" />\n Add to workspace\n </>\n )}\n </Button>\n </div>\n </div>\n </div>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"app-creation-store.d.ts","sourceRoot":"","sources":["../../../src/server/lib/app-creation-store.ts"],"names":[],"mappings":"AAyCA,KAAK,oBAAoB,GAAG,UAAU,GAAG,QAAQ,CAAC;AAElD,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,k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;CAAE,CAAC,CAuC/D;AA6CD,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,mBAAmB,CAAC,CA6B3E;AAED,wBAAsB,sBAAsB,CAAC,KAAK,EAAE;IAClD,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAe/B;AAqRD,wBAAsB,yBAAyB,CAAC,KAAK,EAAE;IACrD,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuIA"}
@@ -1024,6 +1024,15 @@ const ADDABLE_TEMPLATES = [
1024
1024
  colorRgb: "6 182 212",
1025
1025
  core: true,
1026
1026
  },
1027
+ {
1028
+ name: "contracts",
1029
+ label: "Contracts",
1030
+ hint: "Review assumptions, feedback, and proof for coding-agent work",
1031
+ icon: "Contract",
1032
+ color: "#4F46E5",
1033
+ colorRgb: "79 70 229",
1034
+ core: false,
1035
+ },
1027
1036
  {
1028
1037
  name: "design",
1029
1038
  label: "Design",