@agent-native/core 0.17.1 → 0.18.0
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/dist/action.d.ts +27 -0
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js +2 -0
- package/dist/action.js.map +1 -1
- package/dist/agent/production-agent.d.ts +4 -0
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/cli/index.js +16 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/mcp.d.ts +16 -0
- package/dist/cli/mcp.d.ts.map +1 -0
- package/dist/cli/mcp.js +583 -0
- package/dist/cli/mcp.js.map +1 -0
- package/dist/db/client.d.ts +27 -0
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +62 -19
- package/dist/db/client.js.map +1 -1
- package/dist/db/create-get-db.d.ts.map +1 -1
- package/dist/db/create-get-db.js +6 -9
- package/dist/db/create-get-db.js.map +1 -1
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +2 -1
- package/dist/db/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/build-server.d.ts +135 -0
- package/dist/mcp/build-server.d.ts.map +1 -0
- package/dist/mcp/build-server.js +274 -0
- package/dist/mcp/build-server.js.map +1 -0
- package/dist/mcp/builtin-tools.d.ts +32 -0
- package/dist/mcp/builtin-tools.d.ts.map +1 -0
- package/dist/mcp/builtin-tools.js +299 -0
- package/dist/mcp/builtin-tools.js.map +1 -0
- package/dist/mcp/index.d.ts +7 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +8 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/server.d.ts +3 -13
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +21 -175
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/stdio.d.ts +44 -0
- package/dist/mcp/stdio.d.ts.map +1 -0
- package/dist/mcp/stdio.js +208 -0
- package/dist/mcp/stdio.js.map +1 -0
- package/dist/mcp/workspace-resolve.d.ts +68 -0
- package/dist/mcp/workspace-resolve.d.ts.map +1 -0
- package/dist/mcp/workspace-resolve.js +205 -0
- package/dist/mcp/workspace-resolve.js.map +1 -0
- package/dist/server/action-discovery.d.ts.map +1 -1
- package/dist/server/action-discovery.js +3 -0
- package/dist/server/action-discovery.js.map +1 -1
- package/dist/server/auth.d.ts +9 -0
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +25 -0
- package/dist/server/auth.js.map +1 -1
- package/dist/server/better-auth-instance.d.ts.map +1 -1
- package/dist/server/better-auth-instance.js +15 -10
- package/dist/server/better-auth-instance.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts +5 -0
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +9 -0
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/deep-link.d.ts +55 -0
- package/dist/server/deep-link.d.ts.map +1 -0
- package/dist/server/deep-link.js +69 -0
- package/dist/server/deep-link.js.map +1 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +2 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/open-route.d.ts +12 -0
- package/dist/server/open-route.d.ts.map +1 -0
- package/dist/server/open-route.js +128 -0
- package/dist/server/open-route.js.map +1 -0
- package/docs/content/external-agents.md +177 -0
- package/package.json +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep-link helpers — the single source of truth for the
|
|
3
|
+
* `/_agent-native/open` URL format.
|
|
4
|
+
*
|
|
5
|
+
* Every artifact-producing / list action that wants an external agent (MCP /
|
|
6
|
+
* A2A) to surface an "Open in <app> →" link returns
|
|
7
|
+
* `{ url: buildDeepLink(...), label }` from its `link` builder. The MCP layer
|
|
8
|
+
* turns the relative path into an absolute web URL (and an `agentnative://`
|
|
9
|
+
* desktop URL) using the request origin.
|
|
10
|
+
*
|
|
11
|
+
* The `/_agent-native/open` route (see `open-route.ts`) consumes these: it
|
|
12
|
+
* resolves the *browser session's* identity, writes the existing one-shot
|
|
13
|
+
* `navigate` application-state command, and 302-redirects to the rendered SPA
|
|
14
|
+
* view so any browser / inline webview lands on the right screen with the
|
|
15
|
+
* record focused. We never invent a new navigation mechanism — this just
|
|
16
|
+
* bridges external surfaces to the `navigate`/`application_state` contract the
|
|
17
|
+
* UI already drains every 2s.
|
|
18
|
+
*/
|
|
19
|
+
/** Path of the framework deep-link route, relative to the route prefix. */
|
|
20
|
+
export declare const OPEN_ROUTE_SUBPATH = "/open";
|
|
21
|
+
/** Custom URL scheme the desktop app registers (`agentnative://open?...`). */
|
|
22
|
+
export declare const DESKTOP_OPEN_URL = "agentnative://open";
|
|
23
|
+
export interface DeepLinkInput {
|
|
24
|
+
/** App id (informational + multi-app/desktop routing), e.g. "mail". */
|
|
25
|
+
app?: string;
|
|
26
|
+
/** Target view — maps to the `navigate` command `view`. */
|
|
27
|
+
view: string;
|
|
28
|
+
/** Record-focus + filter params, e.g. `{ threadId }`, `{ eventId, date }`,
|
|
29
|
+
* `{ dashboardId }`. `undefined`/`null`/`""` values are dropped. */
|
|
30
|
+
params?: Record<string, string | number | boolean | null | undefined>;
|
|
31
|
+
/** Explicit client-side path override (must be a same-origin, leading-slash
|
|
32
|
+
* relative path — enforced by the open route). */
|
|
33
|
+
to?: string;
|
|
34
|
+
/** Base64url-encoded JSON compose draft (mail's `compose-{id}` contract). */
|
|
35
|
+
compose?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Build the app-relative deep-link path:
|
|
39
|
+
* `/_agent-native/open?app=mail&view=inbox&threadId=abc`.
|
|
40
|
+
* Per-app `link` builders call this; never hand-format the URL.
|
|
41
|
+
*/
|
|
42
|
+
export declare function buildDeepLink(input: DeepLinkInput): string;
|
|
43
|
+
/**
|
|
44
|
+
* Resolve a (possibly relative) deep link to an absolute web URL using the
|
|
45
|
+
* inbound request origin. Absolute URLs pass through unchanged.
|
|
46
|
+
*/
|
|
47
|
+
export declare function toAbsoluteOpenUrl(urlOrPath: string, origin: string | undefined): string;
|
|
48
|
+
/**
|
|
49
|
+
* Rewrite a deep link to the desktop `agentnative://open?...` scheme so the
|
|
50
|
+
* desktop app's existing `handleDeepLink` opens it inside the app webview.
|
|
51
|
+
* Accepts either an app-relative `/_agent-native/open?...` path or an absolute
|
|
52
|
+
* web URL; preserves the query string.
|
|
53
|
+
*/
|
|
54
|
+
export declare function toDesktopOpenUrl(urlOrPath: string): string;
|
|
55
|
+
//# sourceMappingURL=deep-link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-link.d.ts","sourceRoot":"","sources":["../../src/server/deep-link.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,2EAA2E;AAC3E,eAAO,MAAM,kBAAkB,UAAU,CAAC;AAE1C,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,uBAAuB,CAAC;AAErD,MAAM,WAAW,aAAa;IAC5B,uEAAuE;IACvE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb;yEACqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IACtE;uDACmD;IACnD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAeD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAE1D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,MAAM,CAIR;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAI1D"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep-link helpers — the single source of truth for the
|
|
3
|
+
* `/_agent-native/open` URL format.
|
|
4
|
+
*
|
|
5
|
+
* Every artifact-producing / list action that wants an external agent (MCP /
|
|
6
|
+
* A2A) to surface an "Open in <app> →" link returns
|
|
7
|
+
* `{ url: buildDeepLink(...), label }` from its `link` builder. The MCP layer
|
|
8
|
+
* turns the relative path into an absolute web URL (and an `agentnative://`
|
|
9
|
+
* desktop URL) using the request origin.
|
|
10
|
+
*
|
|
11
|
+
* The `/_agent-native/open` route (see `open-route.ts`) consumes these: it
|
|
12
|
+
* resolves the *browser session's* identity, writes the existing one-shot
|
|
13
|
+
* `navigate` application-state command, and 302-redirects to the rendered SPA
|
|
14
|
+
* view so any browser / inline webview lands on the right screen with the
|
|
15
|
+
* record focused. We never invent a new navigation mechanism — this just
|
|
16
|
+
* bridges external surfaces to the `navigate`/`application_state` contract the
|
|
17
|
+
* UI already drains every 2s.
|
|
18
|
+
*/
|
|
19
|
+
/** Path of the framework deep-link route, relative to the route prefix. */
|
|
20
|
+
export const OPEN_ROUTE_SUBPATH = "/open";
|
|
21
|
+
/** Custom URL scheme the desktop app registers (`agentnative://open?...`). */
|
|
22
|
+
export const DESKTOP_OPEN_URL = "agentnative://open";
|
|
23
|
+
function buildQuery(input) {
|
|
24
|
+
const sp = new URLSearchParams();
|
|
25
|
+
if (input.app)
|
|
26
|
+
sp.set("app", input.app);
|
|
27
|
+
sp.set("view", input.view);
|
|
28
|
+
if (input.to)
|
|
29
|
+
sp.set("to", input.to);
|
|
30
|
+
if (input.compose)
|
|
31
|
+
sp.set("compose", input.compose);
|
|
32
|
+
for (const [k, v] of Object.entries(input.params ?? {})) {
|
|
33
|
+
if (v === undefined || v === null || v === "")
|
|
34
|
+
continue;
|
|
35
|
+
sp.set(k, String(v));
|
|
36
|
+
}
|
|
37
|
+
return sp.toString();
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Build the app-relative deep-link path:
|
|
41
|
+
* `/_agent-native/open?app=mail&view=inbox&threadId=abc`.
|
|
42
|
+
* Per-app `link` builders call this; never hand-format the URL.
|
|
43
|
+
*/
|
|
44
|
+
export function buildDeepLink(input) {
|
|
45
|
+
return `/_agent-native${OPEN_ROUTE_SUBPATH}?${buildQuery(input)}`;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Resolve a (possibly relative) deep link to an absolute web URL using the
|
|
49
|
+
* inbound request origin. Absolute URLs pass through unchanged.
|
|
50
|
+
*/
|
|
51
|
+
export function toAbsoluteOpenUrl(urlOrPath, origin) {
|
|
52
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(urlOrPath))
|
|
53
|
+
return urlOrPath;
|
|
54
|
+
if (!origin)
|
|
55
|
+
return urlOrPath;
|
|
56
|
+
return `${origin.replace(/\/+$/, "")}${urlOrPath.startsWith("/") ? "" : "/"}${urlOrPath}`;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Rewrite a deep link to the desktop `agentnative://open?...` scheme so the
|
|
60
|
+
* desktop app's existing `handleDeepLink` opens it inside the app webview.
|
|
61
|
+
* Accepts either an app-relative `/_agent-native/open?...` path or an absolute
|
|
62
|
+
* web URL; preserves the query string.
|
|
63
|
+
*/
|
|
64
|
+
export function toDesktopOpenUrl(urlOrPath) {
|
|
65
|
+
const qIdx = urlOrPath.indexOf("?");
|
|
66
|
+
const query = qIdx >= 0 ? urlOrPath.slice(qIdx + 1) : "";
|
|
67
|
+
return query ? `${DESKTOP_OPEN_URL}?${query}` : DESKTOP_OPEN_URL;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=deep-link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-link.js","sourceRoot":"","sources":["../../src/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BAA0B,CAAC,IAAI,CAAC,SAAS,CAAC;QAAE,OAAO,SAAS,CAAC;IACjE,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC9B,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,SAAS,EAAE,CAAC;AAC5F,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAiB;IAChD,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACzD,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,gBAAgB,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC;AACnE,CAAC","sourcesContent":["/**\n * Deep-link helpers — the single source of truth for the\n * `/_agent-native/open` URL format.\n *\n * Every artifact-producing / list action that wants an external agent (MCP /\n * A2A) to surface an \"Open in <app> →\" link returns\n * `{ url: buildDeepLink(...), label }` from its `link` builder. The MCP layer\n * turns the relative path into an absolute web URL (and an `agentnative://`\n * desktop URL) using the request origin.\n *\n * The `/_agent-native/open` route (see `open-route.ts`) consumes these: it\n * resolves the *browser session's* identity, writes the existing one-shot\n * `navigate` application-state command, and 302-redirects to the rendered SPA\n * view so any browser / inline webview lands on the right screen with the\n * record focused. We never invent a new navigation mechanism — this just\n * bridges external surfaces to the `navigate`/`application_state` contract the\n * UI already drains every 2s.\n */\n\n/** Path of the framework deep-link route, relative to the route prefix. */\nexport const OPEN_ROUTE_SUBPATH = \"/open\";\n\n/** Custom URL scheme the desktop app registers (`agentnative://open?...`). */\nexport const DESKTOP_OPEN_URL = \"agentnative://open\";\n\nexport interface DeepLinkInput {\n /** App id (informational + multi-app/desktop routing), e.g. \"mail\". */\n app?: string;\n /** Target view — maps to the `navigate` command `view`. */\n view: string;\n /** Record-focus + filter params, e.g. `{ threadId }`, `{ eventId, date }`,\n * `{ dashboardId }`. `undefined`/`null`/`\"\"` values are dropped. */\n params?: Record<string, string | number | boolean | null | undefined>;\n /** Explicit client-side path override (must be a same-origin, leading-slash\n * relative path — enforced by the open route). */\n to?: string;\n /** Base64url-encoded JSON compose draft (mail's `compose-{id}` contract). */\n compose?: string;\n}\n\nfunction buildQuery(input: DeepLinkInput): string {\n const sp = new URLSearchParams();\n if (input.app) sp.set(\"app\", input.app);\n sp.set(\"view\", input.view);\n if (input.to) sp.set(\"to\", input.to);\n if (input.compose) sp.set(\"compose\", input.compose);\n for (const [k, v] of Object.entries(input.params ?? {})) {\n if (v === undefined || v === null || v === \"\") continue;\n sp.set(k, String(v));\n }\n return sp.toString();\n}\n\n/**\n * Build the app-relative deep-link path:\n * `/_agent-native/open?app=mail&view=inbox&threadId=abc`.\n * Per-app `link` builders call this; never hand-format the URL.\n */\nexport function buildDeepLink(input: DeepLinkInput): string {\n return `/_agent-native${OPEN_ROUTE_SUBPATH}?${buildQuery(input)}`;\n}\n\n/**\n * Resolve a (possibly relative) deep link to an absolute web URL using the\n * inbound request origin. Absolute URLs pass through unchanged.\n */\nexport function toAbsoluteOpenUrl(\n urlOrPath: string,\n origin: string | undefined,\n): string {\n if (/^[a-z][a-z0-9+.-]*:\\/\\//i.test(urlOrPath)) return urlOrPath;\n if (!origin) return urlOrPath;\n return `${origin.replace(/\\/+$/, \"\")}${urlOrPath.startsWith(\"/\") ? \"\" : \"/\"}${urlOrPath}`;\n}\n\n/**\n * Rewrite a deep link to the desktop `agentnative://open?...` scheme so the\n * desktop app's existing `handleDeepLink` opens it inside the app webview.\n * Accepts either an app-relative `/_agent-native/open?...` path or an absolute\n * web URL; preserves the query string.\n */\nexport function toDesktopOpenUrl(urlOrPath: string): string {\n const qIdx = urlOrPath.indexOf(\"?\");\n const query = qIdx >= 0 ? urlOrPath.slice(qIdx + 1) : \"\";\n return query ? `${DESKTOP_OPEN_URL}?${query}` : DESKTOP_OPEN_URL;\n}\n"]}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { createServer, upsertEnvFile, type CreateServerOptions, type EnvKeyConfig, } from "./create-server.js";
|
|
2
2
|
export { readBody, streamFile } from "./h3-helpers.js";
|
|
3
|
+
export { buildDeepLink, toAbsoluteOpenUrl, toDesktopOpenUrl, OPEN_ROUTE_SUBPATH, DESKTOP_OPEN_URL, type DeepLinkInput, } from "./deep-link.js";
|
|
4
|
+
export { createOpenRouteHandler, type OpenRouteOptions } from "./open-route.js";
|
|
3
5
|
export { createSSEHandler, type SSEHandlerOptions } from "./sse.js";
|
|
4
6
|
export { mountAuthMiddleware, autoMountAuth, getSession, addSession, removeSession, getSessionEmail, runAuthGuard, setDesktopExchange, setDesktopExchangeError, safeReturnPath, type DesktopExchangeErrorPayload, type AuthSession, type AuthOptions, } from "./auth.js";
|
|
5
7
|
export { requireEnvKey, type MissingKeyResponse } from "./missing-key.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,aAAa,EACb,KAAK,mBAAmB,EACxB,KAAK,YAAY,GAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,UAAU,EACV,aAAa,EACb,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EACd,KAAK,2BAA2B,EAChC,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,GACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,YAAY,IAAI,2BAA2B,GACjD,MAAM,wBAAwB,CAAC;AAUhC,MAAM,MAAM,cAAc,GAAG,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACrE,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,cAAc,GAAG,cAAc,CAErE"}
|
package/dist/server/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { createServer, upsertEnvFile, } from "./create-server.js";
|
|
2
2
|
export { readBody, streamFile } from "./h3-helpers.js";
|
|
3
|
+
export { buildDeepLink, toAbsoluteOpenUrl, toDesktopOpenUrl, OPEN_ROUTE_SUBPATH, DESKTOP_OPEN_URL, } from "./deep-link.js";
|
|
4
|
+
export { createOpenRouteHandler } from "./open-route.js";
|
|
3
5
|
export { createSSEHandler } from "./sse.js";
|
|
4
6
|
export { mountAuthMiddleware, autoMountAuth, getSession, addSession, removeSession, getSessionEmail, runAuthGuard, setDesktopExchange, setDesktopExchangeError, safeReturnPath, } from "./auth.js";
|
|
5
7
|
export { requireEnvKey } from "./missing-key.js";
|
package/dist/server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,aAAa,GAGd,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAA0B,MAAM,UAAU,CAAC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jB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,WAAW,EACX,WAAW,EACX,SAAS,GAIV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,mBAAmB,EACnB,qBAAqB,GAGtB,MAAM,wBAAwB,CAAC;AAWhC,MAAM,UAAU,iBAAiB,CAAC,GAAmB;IACnD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["export {\n createServer,\n upsertEnvFile,\n type CreateServerOptions,\n type EnvKeyConfig,\n} from \"./create-server.js\";\n\nexport { readBody, streamFile } from \"./h3-helpers.js\";\nexport { createSSEHandler, type SSEHandlerOptions } from \"./sse.js\";\nexport {\n mountAuthMiddleware,\n autoMountAuth,\n getSession,\n addSession,\n removeSession,\n getSessionEmail,\n runAuthGuard,\n setDesktopExchange,\n setDesktopExchangeError,\n safeReturnPath,\n type DesktopExchangeErrorPayload,\n type AuthSession,\n type AuthOptions,\n} from \"./auth.js\";\nexport { requireEnvKey, type MissingKeyResponse } from \"./missing-key.js\";\nexport { verifyCaptcha, type CaptchaVerifyResult } from \"./captcha.js\";\nexport {\n createProductionAgentHandler,\n type ActionEntry,\n type ScriptEntry,\n type ProductionAgentOptions,\n type ActionTool,\n type ScriptTool,\n type AgentMessage,\n type AgentChatRequest,\n type AgentChatEvent,\n type AgentChatAttachment,\n type AgentChatReference,\n type MentionProvider,\n type MentionProviderItem,\n type AgentLoopFinalResponseGuard,\n type AgentLoopFinalResponseGuardContext,\n type AgentLoopFinalResponseGuardResult,\n type AgentLoopToolCallSummary,\n type AgentLoopToolResultSummary,\n} from \"../agent/index.js\";\nexport {\n actionsToEngineTools,\n getOwnerActiveApiKey,\n runAgentLoop,\n} from \"../agent/production-agent.js\";\nexport {\n getStoredModelForEngine,\n resolveEngine,\n} from \"../agent/engine/index.js\";\nexport { createDevScriptRegistry } from \"../scripts/dev/index.js\";\n\nexport {\n createPollHandler,\n recordChange,\n getVersion,\n getChangesSince,\n getPollEmitter,\n canSeeChangeForUser,\n POLL_CHANGE_EVENT,\n} from \"./poll.js\";\nexport { createPollEventsHandler } from \"./poll-events.js\";\nexport { createAuthPlugin, defaultAuthPlugin } from \"./auth-plugin.js\";\nexport {\n initServerSentry,\n isServerSentryEnabled,\n setSentryUserForRequest,\n captureRouteError,\n type RouteErrorContext,\n} from \"./sentry.js\";\nexport {\n captureError,\n captureServerError,\n registerErrorCaptureProvider,\n type CaptureErrorContext,\n type CaptureErrorProvider,\n} from \"./capture-error.js\";\nexport { createSentryPlugin, defaultSentryPlugin } from \"./sentry-plugin.js\";\n// Re-export the org plugin so the auto-discovery's DEFAULT_PLUGIN_REGISTRY\n// (which references \"defaultOrgPlugin\" from @agent-native/core/server) can\n// resolve it during the deploy build worker-entry generation.\nexport { createOrgPlugin, defaultOrgPlugin } from \"../org/plugin.js\";\nexport {\n createGoogleAuthPlugin,\n type GoogleAuthPluginOptions,\n} from \"./google-auth-plugin.js\";\nexport type { GoogleAuthMode } from \"./google-auth-mode.js\";\nexport {\n createAgentChatPlugin,\n defaultAgentChatPlugin,\n type AgentChatPluginOptions,\n} from \"./agent-chat-plugin.js\";\nexport {\n configureAgentNativeEmbeddedEnvironment,\n createAgentNativeEmbeddedAuthOptions,\n createAgentNativeEmbeddedPlugin,\n mountAgentNativeEmbedded,\n normalizeAgentNativeEmbeddedSession,\n type AgentNativeEmbeddedAuthOptions,\n type AgentNativeEmbeddedGetSession,\n type AgentNativeEmbeddedHostSession,\n type AgentNativeEmbeddedPluginOptions,\n} from \"./embedded.js\";\nexport {\n createThread,\n getThread,\n listThreads,\n updateThreadData,\n deleteThread,\n setThreadScope,\n type ChatThread,\n type ChatThreadScope,\n type ChatThreadSummary,\n type ListThreadsOptions,\n} from \"../chat-threads/store.js\";\nexport {\n createResourcesPlugin,\n defaultResourcesPlugin,\n} from \"./resources-plugin.js\";\nexport {\n createCoreRoutesPlugin,\n defaultCoreRoutesPlugin,\n FRAMEWORK_ROUTE_PREFIX,\n type CoreRoutesPluginOptions,\n} from \"./core-routes-plugin.js\";\nexport {\n createBrowserSessionActionEntries,\n type CreateBrowserSessionActionEntriesOptions,\n} from \"../browser-sessions/actions.js\";\nexport {\n DEFAULT_BROWSER_SESSION_REQUEST_POLL_MS,\n DEFAULT_BROWSER_SESSION_REQUEST_TIMEOUT_MS,\n DEFAULT_BROWSER_SESSION_TTL_MS,\n callBrowserSession,\n claimBrowserSessionRequest,\n completeBrowserSessionRequest,\n createBrowserSessionRequest,\n disconnectBrowserSession,\n getBrowserSession,\n getBrowserSessionRequest,\n listBrowserSessions,\n registerBrowserSession,\n waitForBrowserSessionRequest,\n} from \"../browser-sessions/store.js\";\nexport {\n mountBrowserSessionRoutes,\n type MountBrowserSessionRoutesOptions,\n} from \"../browser-sessions/routes.js\";\nexport type {\n AgentNativeBrowserSession,\n AgentNativeBrowserSessionAction,\n AgentNativeBrowserSessionRecord,\n AgentNativeBrowserSessionRequest,\n AgentNativeBrowserSessionRequestStatus,\n AgentNativeBrowserSessionRequestType,\n CreateAgentNativeBrowserSessionRequestInput,\n RegisterAgentNativeBrowserSessionInput,\n} from \"../browser-sessions/types.js\";\nexport {\n createTerminalPlugin,\n defaultTerminalPlugin,\n type TerminalPluginOptions,\n} from \"../terminal/terminal-plugin.js\";\nexport {\n createCollabPlugin,\n type CollabPluginOptions,\n} from \"./collab-plugin.js\";\n\nexport {\n spawnTask,\n getTask,\n getTaskByThread,\n listTasks,\n sendToTask,\n markTaskErrored,\n type AgentTask,\n type SpawnTaskOptions,\n} from \"./agent-teams.js\";\nexport { isOAuthConnected, getOAuthAccounts } from \"./oauth-helpers.js\";\nexport { wrapWithAnalytics } from \"./analytics.js\";\nexport {\n getH3App,\n awaitBootstrap,\n type H3AppShim,\n} from \"./framework-request-handler.js\";\nexport {\n autoDiscoverActions,\n autoDiscoverScripts,\n loadActionsFromStaticRegistry,\n mergeCoreSharingActions,\n registerPackageActions,\n} from \"./action-discovery.js\";\nexport {\n mountActionRoutes,\n type MountActionRoutesOptions,\n} from \"./action-routes.js\";\nexport {\n runWithRequestContext,\n hasRequestContext,\n getRequestContext,\n getRequestUserEmail,\n getRequestUserName,\n getRequestOrgId,\n getRequestTimezone,\n getRequestRunContext,\n getCredentialContext,\n isIntegrationCallerRequest,\n type RequestContext,\n type RequestRunContext,\n} from \"./request-context.js\";\nexport { formatDateInTimezone, todayInTimezone } from \"./date-utils.js\";\n\nexport {\n createOnboardingPlugin,\n defaultOnboardingPlugin,\n} from \"../onboarding/plugin.js\";\n\nexport {\n registerFileUploadProvider,\n unregisterFileUploadProvider,\n listFileUploadProviders,\n getActiveFileUploadProvider,\n uploadFile,\n builderFileUploadProvider,\n type FileUploadInput,\n type FileUploadProvider,\n type FileUploadResult,\n} from \"../file-upload/index.js\";\n\nexport {\n createIntegrationsPlugin,\n defaultIntegrationsPlugin,\n enqueueRemoteCommand,\n slackAdapter,\n telegramAdapter,\n whatsappAdapter,\n emailAdapter,\n type PlatformAdapter,\n type IncomingMessage,\n type OutgoingMessage,\n type IntegrationStatus,\n type IntegrationsPluginOptions,\n} from \"../integrations/index.js\";\n\nexport {\n isElectron,\n isMobile,\n getOrigin,\n getAppBasePath,\n getAppUrl,\n resolveOAuthRedirectUri,\n isAllowedOAuthRedirectUri,\n encodeOAuthState,\n decodeOAuthState,\n resolveOAuthOwner,\n createOAuthSession,\n oauthCallbackResponse,\n oauthErrorPage,\n oauthDesktopExchangePage,\n type OAuthStatePayload,\n type OAuthOwnerResult,\n type OAuthSessionResult,\n} from \"./google-oauth.js\";\n\nexport {\n FeatureNotConfiguredError,\n hasBuilderPrivateKey,\n isBuilderEnvManaged,\n getBuilderProxyOrigin,\n getBuilderImageGenerationBaseUrl,\n getBuilderAuthHeader,\n resolveBuilderPrivateKey,\n resolveBuilderAuthHeader,\n resolveHasBuilderPrivateKey,\n resolveBuilderCredentials,\n resolveBuilderCredential,\n writeBuilderCredentials,\n deleteBuilderCredentials,\n resolveSecret,\n} from \"./credential-provider.js\";\nexport {\n getBuilderBranchProjectId,\n isBuilderBranchingEnabled,\n resolveBuilderBranchProjectId,\n resolveIsBuilderBranchingEnabled,\n runBuilderAgent,\n type RunBuilderAgentResult,\n} from \"./builder-browser.js\";\n\nexport {\n sendEmail,\n isEmailConfigured,\n getEmailProvider,\n type EmailProvider,\n type SendEmailArgs,\n} from \"./email.js\";\nexport {\n renderEmail,\n emailStrong,\n emailLink,\n type RenderEmailArgs,\n type RenderedEmail,\n type EmailCta,\n} from \"./email-template.js\";\nexport { getAppProductionUrl, getFirstPartyProdUrl } from \"./app-url.js\";\nexport {\n getConfiguredAppBasePath,\n normalizeAppBasePath,\n withConfiguredAppBasePath,\n} from \"./app-base-path.js\";\nexport {\n signShortLivedToken,\n verifyShortLivedToken,\n type ShortLivedTokenClaims,\n type VerifyResult as ShortLivedTokenVerifyResult,\n} from \"./short-lived-token.js\";\n\n// SSR handler is NOT re-exported here — it uses a virtual module\n// (virtual:react-router/server-build) that only exists at Vite dev/build time.\n// Including it in this barrel would break the esbuild CF Pages bundler.\n// Templates import directly: import { ssrHandler } from \"@agent-native/core/server/ssr-handler\"\n\n// Nitro plugin helper — re-exported so templates don't need nitro as a direct dependency.\n// defineNitroPlugin is an identity function; this typed wrapper lets templates use it\n// without resolving `nitro/runtime` (which requires Nitro's virtual modules at runtime).\nexport type NitroPluginDef = (nitroApp: any) => void | Promise<void>;\nexport function defineNitroPlugin(def: NitroPluginDef): NitroPluginDef {\n return def;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,aAAa,GAGd,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAC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,aAAa,GACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,6BAA6B,EAC7B,gCAAgC,EAChC,eAAe,GAEhB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,gBAAgB,GAGjB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,WAAW,EACX,WAAW,EACX,SAAS,GAIV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,mBAAmB,EACnB,qBAAqB,GAGtB,MAAM,wBAAwB,CAAC;AAWhC,MAAM,UAAU,iBAAiB,CAAC,GAAmB;IACnD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["export {\n createServer,\n upsertEnvFile,\n type CreateServerOptions,\n type EnvKeyConfig,\n} from \"./create-server.js\";\n\nexport { readBody, streamFile } from \"./h3-helpers.js\";\nexport {\n buildDeepLink,\n toAbsoluteOpenUrl,\n toDesktopOpenUrl,\n OPEN_ROUTE_SUBPATH,\n DESKTOP_OPEN_URL,\n type DeepLinkInput,\n} from \"./deep-link.js\";\nexport { createOpenRouteHandler, type OpenRouteOptions } from \"./open-route.js\";\nexport { createSSEHandler, type SSEHandlerOptions } from \"./sse.js\";\nexport {\n mountAuthMiddleware,\n autoMountAuth,\n getSession,\n addSession,\n removeSession,\n getSessionEmail,\n runAuthGuard,\n setDesktopExchange,\n setDesktopExchangeError,\n safeReturnPath,\n type DesktopExchangeErrorPayload,\n type AuthSession,\n type AuthOptions,\n} from \"./auth.js\";\nexport { requireEnvKey, type MissingKeyResponse } from \"./missing-key.js\";\nexport { verifyCaptcha, type CaptchaVerifyResult } from \"./captcha.js\";\nexport {\n createProductionAgentHandler,\n type ActionEntry,\n type ScriptEntry,\n type ProductionAgentOptions,\n type ActionTool,\n type ScriptTool,\n type AgentMessage,\n type AgentChatRequest,\n type AgentChatEvent,\n type AgentChatAttachment,\n type AgentChatReference,\n type MentionProvider,\n type MentionProviderItem,\n type AgentLoopFinalResponseGuard,\n type AgentLoopFinalResponseGuardContext,\n type AgentLoopFinalResponseGuardResult,\n type AgentLoopToolCallSummary,\n type AgentLoopToolResultSummary,\n} from \"../agent/index.js\";\nexport {\n actionsToEngineTools,\n getOwnerActiveApiKey,\n runAgentLoop,\n} from \"../agent/production-agent.js\";\nexport {\n getStoredModelForEngine,\n resolveEngine,\n} from \"../agent/engine/index.js\";\nexport { createDevScriptRegistry } from \"../scripts/dev/index.js\";\n\nexport {\n createPollHandler,\n recordChange,\n getVersion,\n getChangesSince,\n getPollEmitter,\n canSeeChangeForUser,\n POLL_CHANGE_EVENT,\n} from \"./poll.js\";\nexport { createPollEventsHandler } from \"./poll-events.js\";\nexport { createAuthPlugin, defaultAuthPlugin } from \"./auth-plugin.js\";\nexport {\n initServerSentry,\n isServerSentryEnabled,\n setSentryUserForRequest,\n captureRouteError,\n type RouteErrorContext,\n} from \"./sentry.js\";\nexport {\n captureError,\n captureServerError,\n registerErrorCaptureProvider,\n type CaptureErrorContext,\n type CaptureErrorProvider,\n} from \"./capture-error.js\";\nexport { createSentryPlugin, defaultSentryPlugin } from \"./sentry-plugin.js\";\n// Re-export the org plugin so the auto-discovery's DEFAULT_PLUGIN_REGISTRY\n// (which references \"defaultOrgPlugin\" from @agent-native/core/server) can\n// resolve it during the deploy build worker-entry generation.\nexport { createOrgPlugin, defaultOrgPlugin } from \"../org/plugin.js\";\nexport {\n createGoogleAuthPlugin,\n type GoogleAuthPluginOptions,\n} from \"./google-auth-plugin.js\";\nexport type { GoogleAuthMode } from \"./google-auth-mode.js\";\nexport {\n createAgentChatPlugin,\n defaultAgentChatPlugin,\n type AgentChatPluginOptions,\n} from \"./agent-chat-plugin.js\";\nexport {\n configureAgentNativeEmbeddedEnvironment,\n createAgentNativeEmbeddedAuthOptions,\n createAgentNativeEmbeddedPlugin,\n mountAgentNativeEmbedded,\n normalizeAgentNativeEmbeddedSession,\n type AgentNativeEmbeddedAuthOptions,\n type AgentNativeEmbeddedGetSession,\n type AgentNativeEmbeddedHostSession,\n type AgentNativeEmbeddedPluginOptions,\n} from \"./embedded.js\";\nexport {\n createThread,\n getThread,\n listThreads,\n updateThreadData,\n deleteThread,\n setThreadScope,\n type ChatThread,\n type ChatThreadScope,\n type ChatThreadSummary,\n type ListThreadsOptions,\n} from \"../chat-threads/store.js\";\nexport {\n createResourcesPlugin,\n defaultResourcesPlugin,\n} from \"./resources-plugin.js\";\nexport {\n createCoreRoutesPlugin,\n defaultCoreRoutesPlugin,\n FRAMEWORK_ROUTE_PREFIX,\n type CoreRoutesPluginOptions,\n} from \"./core-routes-plugin.js\";\nexport {\n createBrowserSessionActionEntries,\n type CreateBrowserSessionActionEntriesOptions,\n} from \"../browser-sessions/actions.js\";\nexport {\n DEFAULT_BROWSER_SESSION_REQUEST_POLL_MS,\n DEFAULT_BROWSER_SESSION_REQUEST_TIMEOUT_MS,\n DEFAULT_BROWSER_SESSION_TTL_MS,\n callBrowserSession,\n claimBrowserSessionRequest,\n completeBrowserSessionRequest,\n createBrowserSessionRequest,\n disconnectBrowserSession,\n getBrowserSession,\n getBrowserSessionRequest,\n listBrowserSessions,\n registerBrowserSession,\n waitForBrowserSessionRequest,\n} from \"../browser-sessions/store.js\";\nexport {\n mountBrowserSessionRoutes,\n type MountBrowserSessionRoutesOptions,\n} from \"../browser-sessions/routes.js\";\nexport type {\n AgentNativeBrowserSession,\n AgentNativeBrowserSessionAction,\n AgentNativeBrowserSessionRecord,\n AgentNativeBrowserSessionRequest,\n AgentNativeBrowserSessionRequestStatus,\n AgentNativeBrowserSessionRequestType,\n CreateAgentNativeBrowserSessionRequestInput,\n RegisterAgentNativeBrowserSessionInput,\n} from \"../browser-sessions/types.js\";\nexport {\n createTerminalPlugin,\n defaultTerminalPlugin,\n type TerminalPluginOptions,\n} from \"../terminal/terminal-plugin.js\";\nexport {\n createCollabPlugin,\n type CollabPluginOptions,\n} from \"./collab-plugin.js\";\n\nexport {\n spawnTask,\n getTask,\n getTaskByThread,\n listTasks,\n sendToTask,\n markTaskErrored,\n type AgentTask,\n type SpawnTaskOptions,\n} from \"./agent-teams.js\";\nexport { isOAuthConnected, getOAuthAccounts } from \"./oauth-helpers.js\";\nexport { wrapWithAnalytics } from \"./analytics.js\";\nexport {\n getH3App,\n awaitBootstrap,\n type H3AppShim,\n} from \"./framework-request-handler.js\";\nexport {\n autoDiscoverActions,\n autoDiscoverScripts,\n loadActionsFromStaticRegistry,\n mergeCoreSharingActions,\n registerPackageActions,\n} from \"./action-discovery.js\";\nexport {\n mountActionRoutes,\n type MountActionRoutesOptions,\n} from \"./action-routes.js\";\nexport {\n runWithRequestContext,\n hasRequestContext,\n getRequestContext,\n getRequestUserEmail,\n getRequestUserName,\n getRequestOrgId,\n getRequestTimezone,\n getRequestRunContext,\n getCredentialContext,\n isIntegrationCallerRequest,\n type RequestContext,\n type RequestRunContext,\n} from \"./request-context.js\";\nexport { formatDateInTimezone, todayInTimezone } from \"./date-utils.js\";\n\nexport {\n createOnboardingPlugin,\n defaultOnboardingPlugin,\n} from \"../onboarding/plugin.js\";\n\nexport {\n registerFileUploadProvider,\n unregisterFileUploadProvider,\n listFileUploadProviders,\n getActiveFileUploadProvider,\n uploadFile,\n builderFileUploadProvider,\n type FileUploadInput,\n type FileUploadProvider,\n type FileUploadResult,\n} from \"../file-upload/index.js\";\n\nexport {\n createIntegrationsPlugin,\n defaultIntegrationsPlugin,\n enqueueRemoteCommand,\n slackAdapter,\n telegramAdapter,\n whatsappAdapter,\n emailAdapter,\n type PlatformAdapter,\n type IncomingMessage,\n type OutgoingMessage,\n type IntegrationStatus,\n type IntegrationsPluginOptions,\n} from \"../integrations/index.js\";\n\nexport {\n isElectron,\n isMobile,\n getOrigin,\n getAppBasePath,\n getAppUrl,\n resolveOAuthRedirectUri,\n isAllowedOAuthRedirectUri,\n encodeOAuthState,\n decodeOAuthState,\n resolveOAuthOwner,\n createOAuthSession,\n oauthCallbackResponse,\n oauthErrorPage,\n oauthDesktopExchangePage,\n type OAuthStatePayload,\n type OAuthOwnerResult,\n type OAuthSessionResult,\n} from \"./google-oauth.js\";\n\nexport {\n FeatureNotConfiguredError,\n hasBuilderPrivateKey,\n isBuilderEnvManaged,\n getBuilderProxyOrigin,\n getBuilderImageGenerationBaseUrl,\n getBuilderAuthHeader,\n resolveBuilderPrivateKey,\n resolveBuilderAuthHeader,\n resolveHasBuilderPrivateKey,\n resolveBuilderCredentials,\n resolveBuilderCredential,\n writeBuilderCredentials,\n deleteBuilderCredentials,\n resolveSecret,\n} from \"./credential-provider.js\";\nexport {\n getBuilderBranchProjectId,\n isBuilderBranchingEnabled,\n resolveBuilderBranchProjectId,\n resolveIsBuilderBranchingEnabled,\n runBuilderAgent,\n type RunBuilderAgentResult,\n} from \"./builder-browser.js\";\n\nexport {\n sendEmail,\n isEmailConfigured,\n getEmailProvider,\n type EmailProvider,\n type SendEmailArgs,\n} from \"./email.js\";\nexport {\n renderEmail,\n emailStrong,\n emailLink,\n type RenderEmailArgs,\n type RenderedEmail,\n type EmailCta,\n} from \"./email-template.js\";\nexport { getAppProductionUrl, getFirstPartyProdUrl } from \"./app-url.js\";\nexport {\n getConfiguredAppBasePath,\n normalizeAppBasePath,\n withConfiguredAppBasePath,\n} from \"./app-base-path.js\";\nexport {\n signShortLivedToken,\n verifyShortLivedToken,\n type ShortLivedTokenClaims,\n type VerifyResult as ShortLivedTokenVerifyResult,\n} from \"./short-lived-token.js\";\n\n// SSR handler is NOT re-exported here — it uses a virtual module\n// (virtual:react-router/server-build) that only exists at Vite dev/build time.\n// Including it in this barrel would break the esbuild CF Pages bundler.\n// Templates import directly: import { ssrHandler } from \"@agent-native/core/server/ssr-handler\"\n\n// Nitro plugin helper — re-exported so templates don't need nitro as a direct dependency.\n// defineNitroPlugin is an identity function; this typed wrapper lets templates use it\n// without resolving `nitro/runtime` (which requires Nitro's virtual modules at runtime).\nexport type NitroPluginDef = (nitroApp: any) => void | Promise<void>;\nexport function defineNitroPlugin(def: NitroPluginDef): NitroPluginDef {\n return def;\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface OpenRouteOptions {
|
|
2
|
+
/** Per-template override that turns the parsed deep-link params into the
|
|
3
|
+
* client-side SPA path to redirect to. Return `null` to use the default
|
|
4
|
+
* (`/<view>`). Filter params (`f_*`) are appended automatically. */
|
|
5
|
+
resolveOpenPath?: (params: {
|
|
6
|
+
app?: string;
|
|
7
|
+
view?: string;
|
|
8
|
+
params: Record<string, string>;
|
|
9
|
+
}) => string | null | undefined;
|
|
10
|
+
}
|
|
11
|
+
export declare function createOpenRouteHandler(options?: OpenRouteOptions): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<Response>>;
|
|
12
|
+
//# sourceMappingURL=open-route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-route.d.ts","sourceRoot":"","sources":["../../src/server/open-route.ts"],"names":[],"mappings":"AAmCA,MAAM,WAAW,gBAAgB;IAC/B;;yEAEqE;IACrE,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE;QACzB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAChC,KAAK,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACjC;AA+BD,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,gBAAqB,2FA4FpE"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { defineEventHandler, getMethod } from "h3";
|
|
2
|
+
import { getSession, getConfiguredLoginHtml } from "./auth.js";
|
|
3
|
+
import { appStatePut } from "../application-state/store.js";
|
|
4
|
+
/** Query keys that are route control, not navigation payload. */
|
|
5
|
+
const RESERVED = new Set(["app", "view", "to", "compose"]);
|
|
6
|
+
// Control-char guard (NUL..US + DEL). Defined via codepoints so the source
|
|
7
|
+
// file stays plain ASCII.
|
|
8
|
+
const CONTROL_CHARS = new RegExp("[\\u0000-\\u001f\\u007f]");
|
|
9
|
+
function getRequestUrl(event) {
|
|
10
|
+
return event.node?.req?.url ?? event.path ?? "/";
|
|
11
|
+
}
|
|
12
|
+
/** Decode a base64url string to UTF-8 (Node Buffer; this route is Node-only). */
|
|
13
|
+
function decodeBase64Url(input) {
|
|
14
|
+
return Buffer.from(input, "base64url").toString("utf8");
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Normalize a candidate redirect path to a safe, same-origin, leading-slash
|
|
18
|
+
* relative path. Rejects absolute URLs, scheme-relative `//host`, and control
|
|
19
|
+
* chars (open-redirect guard). Returns `null` when unsafe.
|
|
20
|
+
*/
|
|
21
|
+
function safeRelativePath(raw) {
|
|
22
|
+
if (!raw)
|
|
23
|
+
return null;
|
|
24
|
+
if (CONTROL_CHARS.test(raw))
|
|
25
|
+
return null;
|
|
26
|
+
if (!raw.startsWith("/"))
|
|
27
|
+
return null;
|
|
28
|
+
if (raw.startsWith("//") || raw.startsWith("/\\"))
|
|
29
|
+
return null;
|
|
30
|
+
if (/^\/[a-z][a-z0-9+.-]*:/i.test(raw))
|
|
31
|
+
return null;
|
|
32
|
+
return raw;
|
|
33
|
+
}
|
|
34
|
+
function redirect(location) {
|
|
35
|
+
// Native web Response (not h3 v2's reworked sendRedirect) — matches the
|
|
36
|
+
// redirect pattern used elsewhere in auth.ts.
|
|
37
|
+
return new Response("", { status: 302, headers: { Location: location } });
|
|
38
|
+
}
|
|
39
|
+
export function createOpenRouteHandler(options = {}) {
|
|
40
|
+
return defineEventHandler(async (event) => {
|
|
41
|
+
const method = getMethod(event);
|
|
42
|
+
if (method !== "GET" && method !== "HEAD") {
|
|
43
|
+
return new Response(JSON.stringify({ error: "Method not allowed" }), {
|
|
44
|
+
status: 405,
|
|
45
|
+
headers: { "Content-Type": "application/json" },
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
const rawUrl = getRequestUrl(event);
|
|
49
|
+
let search;
|
|
50
|
+
try {
|
|
51
|
+
search = new URL(rawUrl, "http://an.invalid").searchParams;
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
search = new URLSearchParams();
|
|
55
|
+
}
|
|
56
|
+
const app = search.get("app") ?? undefined;
|
|
57
|
+
const view = search.get("view") ?? undefined;
|
|
58
|
+
const toParam = search.get("to") ?? undefined;
|
|
59
|
+
const compose = search.get("compose") ?? undefined;
|
|
60
|
+
// Resolve the BROWSER session. When unauthenticated, serve the same login
|
|
61
|
+
// form the guard would — at this URL — so the post-login reload returns
|
|
62
|
+
// here authenticated.
|
|
63
|
+
const session = await getSession(event);
|
|
64
|
+
if (!session?.email) {
|
|
65
|
+
const html = getConfiguredLoginHtml(event);
|
|
66
|
+
if (html) {
|
|
67
|
+
return new Response(html, {
|
|
68
|
+
status: 200,
|
|
69
|
+
headers: { "Content-Type": "text/html; charset=utf-8" },
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
// No auth guard configured (fully open app) — best effort: still send
|
|
73
|
+
// the user to the view; nothing to scope the navigate write to.
|
|
74
|
+
}
|
|
75
|
+
// Build the navigation payload from every non-reserved query param
|
|
76
|
+
// (record ids + filters: threadId, eventId, dashboardId, f_*, ...).
|
|
77
|
+
const navParams = {};
|
|
78
|
+
for (const [k, v] of search.entries()) {
|
|
79
|
+
if (RESERVED.has(k))
|
|
80
|
+
continue;
|
|
81
|
+
navParams[k] = v;
|
|
82
|
+
}
|
|
83
|
+
const navPayload = { ...navParams };
|
|
84
|
+
if (view)
|
|
85
|
+
navPayload.view = view;
|
|
86
|
+
if (session?.email) {
|
|
87
|
+
try {
|
|
88
|
+
await appStatePut(session.email, "navigate", navPayload, {
|
|
89
|
+
requestSource: "deep-link",
|
|
90
|
+
});
|
|
91
|
+
if (compose) {
|
|
92
|
+
try {
|
|
93
|
+
const draft = JSON.parse(decodeBase64Url(compose));
|
|
94
|
+
if (draft && typeof draft === "object" && draft.id) {
|
|
95
|
+
await appStatePut(session.email, `compose-${draft.id}`, draft, {
|
|
96
|
+
requestSource: "deep-link",
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
// Malformed compose payload — skip; the view still opens.
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
// App-state write failure shouldn't 500 the click; the redirect
|
|
107
|
+
// below still lands the user on the right view.
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Resolve the SPA path to redirect to.
|
|
111
|
+
let target = safeRelativePath(toParam) ??
|
|
112
|
+
safeRelativePath(options.resolveOpenPath?.({ app, view, params: navParams }) ??
|
|
113
|
+
(view ? `/${view}` : null)) ??
|
|
114
|
+
"/";
|
|
115
|
+
// Forward filter params (f_*) onto the redirect so dashboards/lists open
|
|
116
|
+
// pre-filtered even before the navigate command is drained.
|
|
117
|
+
const filters = new URLSearchParams();
|
|
118
|
+
for (const [k, v] of search.entries()) {
|
|
119
|
+
if (k.startsWith("f_"))
|
|
120
|
+
filters.set(k, v);
|
|
121
|
+
}
|
|
122
|
+
const fq = filters.toString();
|
|
123
|
+
if (fq)
|
|
124
|
+
target += (target.includes("?") ? "&" : "?") + fq;
|
|
125
|
+
return redirect(target);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=open-route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-route.js","sourceRoot":"","sources":["../../src/server/open-route.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,WAAW,E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MAAM,CAAC;gBACP,gEAAgE;gBAChE,gDAAgD;YAClD,CAAC;QACH,CAAC;QAED,uCAAuC;QACvC,IAAI,MAAM,GACR,gBAAgB,CAAC,OAAO,CAAC;YACzB,gBAAgB,CACd,OAAO,CAAC,eAAe,EAAE,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;gBACzD,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAC7B;YACD,GAAG,CAAC;QAEN,yEAAyE;QACzE,4DAA4D;QAC5D,MAAM,OAAO,GAAG,IAAI,eAAe,EAAE,CAAC;QACtC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;YACtC,IAAI,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC;gBAAE,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5C,CAAC;QACD,MAAM,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC9B,IAAI,EAAE;YAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;QAE1D,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * `/_agent-native/open` — the stable deep-link route.\n *\n * An external coding agent (Claude Code / Cowork / Codex) surfaces an\n * \"Open in <app> →\" link (built by an action's `link` builder, see\n * `deep-link.ts`). When the user clicks it in any browser / inline webview,\n * this route:\n * 1. Resolves the *browser* session (NOT the agent token) — so the record\n * always lands where the human is logged in.\n * 2. When unauthenticated, serves the same sign-in form the auth guard\n * would, *at this same URL*. The login form's success handler reloads\n * `window.location.href`, so the now-authenticated request re-enters\n * this route and proceeds. No `?next=` plumbing needed.\n * 3. Writes the existing one-shot `navigate` application-state command (the\n * exact key the UI already drains every 2s — we don't invent a new\n * navigation mechanism, we bridge to it), plus an optional `compose-<id>`\n * draft.\n * 4. 302-redirects to the rendered SPA view so the page loads immediately;\n * the polled `navigate` command then applies record-level focus.\n *\n * The link itself is a pure pointer (view + record ids + filters) and carries\n * no privileged state.\n */\nimport type { H3Event } from \"h3\";\nimport { defineEventHandler, getMethod } from \"h3\";\nimport { getSession, getConfiguredLoginHtml } from \"./auth.js\";\nimport { appStatePut } from \"../application-state/store.js\";\n\n/** Query keys that are route control, not navigation payload. */\nconst RESERVED = new Set([\"app\", \"view\", \"to\", \"compose\"]);\n\n// Control-char guard (NUL..US + DEL). Defined via codepoints so the source\n// file stays plain ASCII.\nconst CONTROL_CHARS = new RegExp(\"[\\\\u0000-\\\\u001f\\\\u007f]\");\n\nexport interface OpenRouteOptions {\n /** Per-template override that turns the parsed deep-link params into the\n * client-side SPA path to redirect to. Return `null` to use the default\n * (`/<view>`). Filter params (`f_*`) are appended automatically. */\n resolveOpenPath?: (params: {\n app?: string;\n view?: string;\n params: Record<string, string>;\n }) => string | null | undefined;\n}\n\nfunction getRequestUrl(event: H3Event): string {\n return (event as any).node?.req?.url ?? (event as any).path ?? \"/\";\n}\n\n/** Decode a base64url string to UTF-8 (Node Buffer; this route is Node-only). */\nfunction decodeBase64Url(input: string): string {\n return Buffer.from(input, \"base64url\").toString(\"utf8\");\n}\n\n/**\n * Normalize a candidate redirect path to a safe, same-origin, leading-slash\n * relative path. Rejects absolute URLs, scheme-relative `//host`, and control\n * chars (open-redirect guard). Returns `null` when unsafe.\n */\nfunction safeRelativePath(raw: string | undefined | null): string | null {\n if (!raw) return null;\n if (CONTROL_CHARS.test(raw)) return null;\n if (!raw.startsWith(\"/\")) return null;\n if (raw.startsWith(\"//\") || raw.startsWith(\"/\\\\\")) return null;\n if (/^\\/[a-z][a-z0-9+.-]*:/i.test(raw)) return null;\n return raw;\n}\n\nfunction redirect(location: string): Response {\n // Native web Response (not h3 v2's reworked sendRedirect) — matches the\n // redirect pattern used elsewhere in auth.ts.\n return new Response(\"\", { status: 302, headers: { Location: location } });\n}\n\nexport function createOpenRouteHandler(options: OpenRouteOptions = {}) {\n return defineEventHandler(async (event: H3Event) => {\n const method = getMethod(event);\n if (method !== \"GET\" && method !== \"HEAD\") {\n return new Response(JSON.stringify({ error: \"Method not allowed\" }), {\n status: 405,\n headers: { \"Content-Type\": \"application/json\" },\n });\n }\n\n const rawUrl = getRequestUrl(event);\n let search: URLSearchParams;\n try {\n search = new URL(rawUrl, \"http://an.invalid\").searchParams;\n } catch {\n search = new URLSearchParams();\n }\n\n const app = search.get(\"app\") ?? undefined;\n const view = search.get(\"view\") ?? undefined;\n const toParam = search.get(\"to\") ?? undefined;\n const compose = search.get(\"compose\") ?? undefined;\n\n // Resolve the BROWSER session. When unauthenticated, serve the same login\n // form the guard would — at this URL — so the post-login reload returns\n // here authenticated.\n const session = await getSession(event);\n if (!session?.email) {\n const html = getConfiguredLoginHtml(event);\n if (html) {\n return new Response(html, {\n status: 200,\n headers: { \"Content-Type\": \"text/html; charset=utf-8\" },\n });\n }\n // No auth guard configured (fully open app) — best effort: still send\n // the user to the view; nothing to scope the navigate write to.\n }\n\n // Build the navigation payload from every non-reserved query param\n // (record ids + filters: threadId, eventId, dashboardId, f_*, ...).\n const navParams: Record<string, string> = {};\n for (const [k, v] of search.entries()) {\n if (RESERVED.has(k)) continue;\n navParams[k] = v;\n }\n const navPayload: Record<string, unknown> = { ...navParams };\n if (view) navPayload.view = view;\n\n if (session?.email) {\n try {\n await appStatePut(session.email, \"navigate\", navPayload, {\n requestSource: \"deep-link\",\n });\n if (compose) {\n try {\n const draft = JSON.parse(decodeBase64Url(compose));\n if (draft && typeof draft === \"object\" && draft.id) {\n await appStatePut(session.email, `compose-${draft.id}`, draft, {\n requestSource: \"deep-link\",\n });\n }\n } catch {\n // Malformed compose payload — skip; the view still opens.\n }\n }\n } catch {\n // App-state write failure shouldn't 500 the click; the redirect\n // below still lands the user on the right view.\n }\n }\n\n // Resolve the SPA path to redirect to.\n let target =\n safeRelativePath(toParam) ??\n safeRelativePath(\n options.resolveOpenPath?.({ app, view, params: navParams }) ??\n (view ? `/${view}` : null),\n ) ??\n \"/\";\n\n // Forward filter params (f_*) onto the redirect so dashboards/lists open\n // pre-filtered even before the navigate command is drained.\n const filters = new URLSearchParams();\n for (const [k, v] of search.entries()) {\n if (k.startsWith(\"f_\")) filters.set(k, v);\n }\n const fq = filters.toString();\n if (fq) target += (target.includes(\"?\") ? \"&\" : \"?\") + fq;\n\n return redirect(target);\n });\n}\n"]}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "External Agents"
|
|
3
|
+
description: "Connect Claude Code, Cowork, and Codex to an agent-native app over MCP — with deep links that drop the user back into the running UI and live artifact round-trip."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# External Agents
|
|
7
|
+
|
|
8
|
+
An agent-native app is reachable by any external coding agent — Claude Code (desktop & CLI), Claude Cowork, Codex — over [MCP](/docs/mcp-protocol). External agents are great at producing artifacts (a draft, an event, a dashboard) but they live in a terminal or another app. Without a bridge, the user gets a wall of JSON and has to go find the thing.
|
|
9
|
+
|
|
10
|
+
The external-agent bridge closes the loop: the agent does the work over MCP, then hands the user a single **"Open in <app> →"** link that opens the real app focused on exactly what was produced. It reuses the existing `navigate` / `application_state` contract the UI already drains every 2s (see [Context Awareness](/docs/context-awareness)) — there is no second navigation mechanism.
|
|
11
|
+
|
|
12
|
+
## Overview {#overview}
|
|
13
|
+
|
|
14
|
+
- **One-command setup** — `agent-native mcp install --client <c>` writes the client config and provisions a token.
|
|
15
|
+
- **`link` builder** — any action that produces or lists a navigable resource returns a deep link; MCP/A2A surfaces auto-append an "Open in … →" link.
|
|
16
|
+
- **`/_agent-native/open` route** — a pure pointer (view + record ids + filters); the record-focusing write is always scoped to the **browser session**, never the agent's token.
|
|
17
|
+
- **Ingest actions** — GET + `readOnly` + `publicAgent` actions let an external agent pull **live** app state into its own context.
|
|
18
|
+
- **Generic cross-app verbs** — a stable verb set (`list_apps`, `open_app`, `ask_app`, `create_workspace_app`, `list_templates`) so an external agent has a predictable surface without guessing per-app action names.
|
|
19
|
+
|
|
20
|
+
## Connect an external agent {#connect}
|
|
21
|
+
|
|
22
|
+
The framework already mounts an HTTP MCP endpoint at `/_agent-native/mcp` (see [MCP Protocol](/docs/mcp-protocol)). Every `defineAction` is exposed as an MCP tool, plus the `ask-agent` meta-tool that runs the full agent loop (the same entry point [A2A](/docs/a2a-protocol) uses). Hosted apps point an external agent at that URL with a bearer token (`ACCESS_TOKEN`, or an `A2A_SECRET` JWT carrying the caller's `sub` + `org_domain` so tool runs stay tenant-scoped).
|
|
23
|
+
|
|
24
|
+
For local Claude Code / Codex / Cowork, one command writes the client config:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
agent-native mcp install --client claude-code|claude-code-cli|codex|cowork \
|
|
28
|
+
[--app <id>] [--scope user|project]
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
It provisions a token (a random `ACCESS_TOKEN` into the workspace `.env` for local dev, or a signed JWT for a detected hosted deployment) and writes an idempotent stdio server entry:
|
|
32
|
+
|
|
33
|
+
- **claude-code / claude-code-cli** — an `mcpServers` entry in `.mcp.json` (project scope, default) or `~/.claude.json` (`--scope user`).
|
|
34
|
+
- **cowork** — the same Claude Code JSON shape in `~/.cowork/mcp.json`.
|
|
35
|
+
- **codex** — an `[mcp_servers.<name>]` block in `~/.codex/config.toml`.
|
|
36
|
+
|
|
37
|
+
The entry runs `agent-native mcp serve --app <id>`, which by default is a **thin stdio proxy** to the running local app's `/_agent-native/mcp` — so the live action registry, HMR, and correct deep links stay the single source of truth. Pass `--standalone` to build the registry in-process instead. When `agent-native mcp install` detects a hosted origin (a non-localhost `APP_URL` / `BETTER_AUTH_URL` / `AGENT_NATIVE_MCP_URL` in the workspace `.env`), it writes an `http` client entry pointing at `<origin>/_agent-native/mcp` with a `Bearer` JWT instead of a stdio entry.
|
|
38
|
+
|
|
39
|
+
Companion subcommands:
|
|
40
|
+
|
|
41
|
+
| Command | What it does |
|
|
42
|
+
| ----------------------------------------- | ------------------------------------------------------------------- |
|
|
43
|
+
| `agent-native mcp serve [--app <id>]` | Run the MCP stdio transport (what client configs spawn). |
|
|
44
|
+
| `agent-native mcp install --client <c>` | Provision a token + write the client's MCP config (idempotent). |
|
|
45
|
+
| `agent-native mcp uninstall --client <c>` | Remove the named MCP entry from a client's config (idempotent). |
|
|
46
|
+
| `agent-native mcp status` | Show resolved MCP URL/port, token state, and per-client entries. |
|
|
47
|
+
| `agent-native mcp token [--rotate]` | Print (or rotate) the local `ACCESS_TOKEN` in the workspace `.env`. |
|
|
48
|
+
|
|
49
|
+
Restart the client after `install` so it picks up the new MCP server.
|
|
50
|
+
|
|
51
|
+
## The `link` builder {#link-builder}
|
|
52
|
+
|
|
53
|
+
`defineAction` accepts an optional `link` builder. When set, every MCP/A2A result for that tool auto-appends a markdown `[label →](absoluteUrl)` block and a structured `_meta["agent-native/openLink"] = { label, view, webUrl, desktopUrl }`. `tools/list` adds `annotations["agent-native/producesOpenLink"]` and a description suffix so the external agent knows the tool yields an openable link and should surface it.
|
|
54
|
+
|
|
55
|
+
Build the URL with `buildDeepLink(...)` — it is the single source of truth for the open-route format. Never hand-format the `/_agent-native/open` URL.
|
|
56
|
+
|
|
57
|
+
Real example — mail's `manage-draft` (`templates/mail/actions/manage-draft.ts`):
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { buildDeepLink } from "@agent-native/core/server";
|
|
61
|
+
|
|
62
|
+
function composeDeepLink(draft: Record<string, string>): string {
|
|
63
|
+
return buildDeepLink({
|
|
64
|
+
app: "mail",
|
|
65
|
+
view: "inbox",
|
|
66
|
+
compose: encodeComposeDraft(draft), // base64url JSON → compose-<id> draft
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default defineAction({
|
|
71
|
+
// ...schema, run...
|
|
72
|
+
link: ({ result }) => {
|
|
73
|
+
if (!result || typeof result !== "object") return null;
|
|
74
|
+
const draft = (result as { draft?: Record<string, string> }).draft;
|
|
75
|
+
const id = (result as { id?: string }).id;
|
|
76
|
+
if (!draft || !id) return null;
|
|
77
|
+
return {
|
|
78
|
+
url: composeDeepLink(draft),
|
|
79
|
+
label: "Open draft in Mail",
|
|
80
|
+
view: "inbox",
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
List/search actions point at a record-focused view the same way — e.g. calendar's `create-event` returns `buildDeepLink({ app: "calendar", view: "calendar", params: { eventId, date } })` with label `"Open event in Calendar"`.
|
|
87
|
+
|
|
88
|
+
### The `link` contract {#link-contract}
|
|
89
|
+
|
|
90
|
+
The `link` builder is **pure and synchronous — no I/O, no awaits**. It runs best-effort: a throw, `null`, or `undefined` is swallowed and **never** fails the tool call. It only reads the call's `args` and `result`; it must not query the DB, read app-state, or call other actions. Return `null` when there's nothing to open.
|
|
91
|
+
|
|
92
|
+
`buildDeepLink({ app, view, params?, to?, compose? })` returns the app-relative path `/_agent-native/open?app=…&view=…&<recordId>=…`. The MCP layer turns that into an absolute web URL (`toAbsoluteOpenUrl`, using the request origin) and a desktop `agentnative://open?…` URL (`toDesktopOpenUrl`); the markdown link uses the desktop URL when the client signals `target: "desktop"`.
|
|
93
|
+
|
|
94
|
+
## The `/_agent-native/open` route {#open-route}
|
|
95
|
+
|
|
96
|
+
When the user clicks the link in any browser or inline webview, `GET /_agent-native/open` (`createOpenRouteHandler`, mounted by the core routes plugin):
|
|
97
|
+
|
|
98
|
+
1. Resolves the **browser** session via `getSession` (the auth guard bypasses the exact path `/_agent-native/open`).
|
|
99
|
+
2. If unauthenticated, serves the configured login HTML **at the same URL**; the form's success handler reloads `window.location`, re-entering the route authenticated — no `?next=` plumbing.
|
|
100
|
+
3. Writes the existing one-shot `navigate` application-state command (payload = every non-reserved query param + `view`) scoped to the browser session's email with `requestSource: "deep-link"`, and decodes a `compose` base64url draft into a `compose-<id>` key.
|
|
101
|
+
4. 302-redirects to a safe same-origin relative path (`to=`, else `/<view>`, else a per-template `resolveOpenPath`), forwarding `f_*` filter params so lists/dashboards open pre-filtered before the `navigate` command is even drained.
|
|
102
|
+
|
|
103
|
+
Cross-origin, scheme-relative `//host`, and control-char redirects are rejected (open-redirect guard). The route can be disabled per app via `disableOpenRoute`.
|
|
104
|
+
|
|
105
|
+
### The browser-session identity rule {#identity-rule}
|
|
106
|
+
|
|
107
|
+
The link carries **no privileged state** — it is just `view` + record ids + filters. The record-focusing `navigate` write is scoped to whoever is logged into the **browser**, never the external agent's MCP token. So an agent authenticated as one identity can hand a user a link, and when that user clicks it the record opens where _the user_ is logged in. This is what makes the deep link safe to surface in a terminal or chat transcript. See [Context Awareness](/docs/context-awareness) for the `navigate` / `application_state` contract this bridges to.
|
|
108
|
+
|
|
109
|
+
## Ingest actions {#ingest}
|
|
110
|
+
|
|
111
|
+
An action an external agent reads to pull live app state into its own context must be:
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
export default defineAction({
|
|
115
|
+
description: "…",
|
|
116
|
+
schema: z.object({ id: z.string() }),
|
|
117
|
+
http: { method: "GET" },
|
|
118
|
+
readOnly: true,
|
|
119
|
+
publicAgent: { expose: true, readOnly: true, requiresAuth: true },
|
|
120
|
+
run: async ({ id }) => {
|
|
121
|
+
/* read LIVE state, not the stale DB snapshot column */
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`GET` + `readOnly` keeps the action side-effect-free and out of the screen-refresh poll. `publicAgent` is the **explicit opt-in** — a public web route never implies public MCP/A2A exposure; see [Actions](/docs/actions). Design/content ingest actions MUST read **live** state (the Yjs collaborative document, not the stale DB snapshot column) so the external agent sees what the user actually has on screen. Content's `pull-document` flushes any open live collab session to SQL first; design's `get-design-snapshot` returns the live Yjs file contents plus the user's resolved tweak values.
|
|
127
|
+
|
|
128
|
+
## Generic cross-app verbs + scaffolding {#cross-app}
|
|
129
|
+
|
|
130
|
+
On top of the per-action tools the MCP server exposes a stable verb set so an external agent has a predictable surface without guessing per-app action names:
|
|
131
|
+
|
|
132
|
+
| Tool | Side effects | Returns |
|
|
133
|
+
| ------------------------------------------ | ------------ | ------------------------------------------------------------------------------------ |
|
|
134
|
+
| `list_apps` | none | workspace apps + their dev URLs / running state |
|
|
135
|
+
| `open_app({ app, view, params? })` | none | a `buildDeepLink` URL (surfaces as an "Open …" link) |
|
|
136
|
+
| `ask_app({ app, message })` | agent loop | routes a natural-language task to that app's in-app agent (delegates to `ask-agent`) |
|
|
137
|
+
| `create_workspace_app({ name, template })` | scaffolds | a new app booted via the workspace path, plus its running URL + deep link |
|
|
138
|
+
| `list_templates` | none | the allow-listed templates only |
|
|
139
|
+
|
|
140
|
+
`create_workspace_app` rejects any non-allow-listed template — the public template allow-list in `packages/shared-app-config/templates.ts` is authoritative and CI-guarded; an external agent cannot widen it. A same-named template action overrides a builtin (template-over-core precedence). Disable the whole set with `MCPConfig.builtinCrossAppTools: false`.
|
|
141
|
+
|
|
142
|
+
## Per-app tour {#tour}
|
|
143
|
+
|
|
144
|
+
Every allow-listed template that produces or lists a navigable resource ships a `link` builder, and the ingest-heavy ones ship a GET + `publicAgent` action:
|
|
145
|
+
|
|
146
|
+
- **Mail** — `manage-draft` returns a `compose`-encoded deep link; clicking it opens the inbox with the draft restored into a `compose-<id>`. `list-emails` / `search-emails` point at a filtered inbox view.
|
|
147
|
+
- **Calendar** — `create-event` returns `buildDeepLink({ app: "calendar", view: "calendar", params: { eventId, date } })`; the click lands on the calendar with that event focused on its date.
|
|
148
|
+
- **Analytics** — `update-dashboard` / `save-analysis` return `buildDeepLink({ app: "analytics", view: "adhoc", params: { dashboardId } })`; the agent builds a dashboard over MCP and hands back "Open dashboard in Analytics".
|
|
149
|
+
- **Design** — `get-design-snapshot` is the GET + `publicAgent` ingest action: it returns the **live** Yjs file contents plus the resolved tweak values so the agent continues from the tuned design, not the original tokens. `apply-tweaks` round-trips back with an "Open design" editor link.
|
|
150
|
+
- **Content** — `pull-document` is the GET + `publicAgent` ingest action: it flushes any open live collaborative session to SQL first so the external agent ingests exactly what the user sees, then surfaces a deep link to the document.
|
|
151
|
+
- **Brain** — `ask-brain` / `search-everything` return a cited answer plus a deep link to the underlying knowledge/capture, so a terminal agent's lookup links straight back into the source in the running app.
|
|
152
|
+
|
|
153
|
+
## Do / Don't {#do-dont}
|
|
154
|
+
|
|
155
|
+
**Do**
|
|
156
|
+
|
|
157
|
+
- Add a `link` builder to any action that produces or lists a navigable resource (draft, event, dashboard, document).
|
|
158
|
+
- Build the URL with `buildDeepLink(...)` — the single source of truth for the open-route format.
|
|
159
|
+
- Keep `link` pure and synchronous; return `null` when there's nothing to open.
|
|
160
|
+
- Make external-agent ingest actions GET + `readOnly` + `publicAgent`, and read live (Yjs) state, not the stale DB column.
|
|
161
|
+
- Let the open route resolve the browser session; pass record ids as deep-link params and let the UI focus them via the polled `navigate` command.
|
|
162
|
+
|
|
163
|
+
**Don't**
|
|
164
|
+
|
|
165
|
+
- Hand-format the `/_agent-native/open` URL — always go through `buildDeepLink`.
|
|
166
|
+
- Do I/O, awaits, DB reads, or app-state reads inside a `link` builder.
|
|
167
|
+
- Scope the `navigate` write to the agent token, or pass privileged state through the deep link — it's a pure pointer.
|
|
168
|
+
- Invent a new navigation mechanism; bridge to the existing `navigate` / `application_state` contract.
|
|
169
|
+
- Widen the public template allow-list when scaffolding an app from an external agent — the allow-list is authoritative and guarded.
|
|
170
|
+
|
|
171
|
+
## Related {#related}
|
|
172
|
+
|
|
173
|
+
- [MCP Protocol](/docs/mcp-protocol) — the auto-mounted MCP server and `ask-agent` meta-tool.
|
|
174
|
+
- [MCP Clients](/docs/mcp-clients) — the symmetric direction: your app consuming local/remote MCP servers.
|
|
175
|
+
- [A2A Protocol](/docs/a2a-protocol) — the `ask-agent` meta-tool and JSON-RPC peer calls.
|
|
176
|
+
- [Actions](/docs/actions) — defining actions, `publicAgent`, GET / `readOnly`.
|
|
177
|
+
- [Context Awareness](/docs/context-awareness) — the `navigate` / `application_state` contract the open route bridges to.
|