@agent-native/dispatch 0.24.6 → 0.25.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/README.md +12 -1
- package/dist/actions/connect-external-agent.d.ts +18 -0
- package/dist/actions/connect-external-agent.d.ts.map +1 -0
- package/dist/actions/connect-external-agent.js +68 -0
- package/dist/actions/connect-external-agent.js.map +1 -0
- package/dist/actions/create-workspace-resource.d.ts +14 -14
- package/dist/actions/create-workspace-resource.js +9 -2
- package/dist/actions/create-workspace-resource.js.map +1 -1
- package/dist/actions/create_workspace_app_embed_session.d.ts +13 -0
- package/dist/actions/create_workspace_app_embed_session.d.ts.map +1 -0
- package/dist/actions/create_workspace_app_embed_session.js +30 -0
- package/dist/actions/create_workspace_app_embed_session.js.map +1 -0
- package/dist/actions/import-agent-pack.d.ts +96 -0
- package/dist/actions/import-agent-pack.d.ts.map +1 -0
- package/dist/actions/import-agent-pack.js +116 -0
- package/dist/actions/import-agent-pack.js.map +1 -0
- package/dist/actions/import-agent.d.ts +60 -0
- package/dist/actions/import-agent.d.ts.map +1 -0
- package/dist/actions/import-agent.js +82 -0
- package/dist/actions/import-agent.js.map +1 -0
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/index.js +10 -0
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/list-agent-pack.d.ts +36 -0
- package/dist/actions/list-agent-pack.d.ts.map +1 -0
- package/dist/actions/list-agent-pack.js +32 -0
- package/dist/actions/list-agent-pack.js.map +1 -0
- package/dist/actions/list-workspace-resource-options.d.ts +1 -1
- package/dist/actions/list-workspace-resource-options.js +8 -1
- package/dist/actions/list-workspace-resource-options.js.map +1 -1
- package/dist/actions/list-workspace-resources.d.ts +1 -1
- package/dist/actions/list-workspace-resources.js +8 -1
- package/dist/actions/list-workspace-resources.js.map +1 -1
- package/dist/actions/navigate.js +1 -1
- package/dist/actions/navigate.js.map +1 -1
- package/dist/actions/provider-api-register.d.ts +10 -10
- package/dist/actions/update-workspace-resource.d.ts +13 -13
- package/dist/actions/view-screen.js +18 -1
- package/dist/actions/view-screen.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/layout/Layout.d.ts +1 -8
- package/dist/components/layout/Layout.d.ts.map +1 -1
- package/dist/components/layout/Layout.js +33 -106
- package/dist/components/layout/Layout.js.map +1 -1
- package/dist/components/simple-agents-panel.d.ts +9 -0
- package/dist/components/simple-agents-panel.d.ts.map +1 -0
- package/dist/components/simple-agents-panel.js +405 -0
- package/dist/components/simple-agents-panel.js.map +1 -0
- package/dist/components/workspace-app-host.d.ts +29 -0
- package/dist/components/workspace-app-host.d.ts.map +1 -0
- package/dist/components/workspace-app-host.js +145 -0
- package/dist/components/workspace-app-host.js.map +1 -0
- package/dist/db/migrations.d.ts +2 -4
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +25 -0
- package/dist/db/migrations.js.map +1 -1
- package/dist/db/schema.js +1 -1
- package/dist/db/schema.js.map +1 -1
- package/dist/hooks/use-navigation-state.d.ts +1 -0
- package/dist/hooks/use-navigation-state.d.ts.map +1 -1
- package/dist/hooks/use-navigation-state.js +10 -0
- package/dist/hooks/use-navigation-state.js.map +1 -1
- package/dist/lib/agent-pack.d.ts +31 -0
- package/dist/lib/agent-pack.d.ts.map +1 -0
- package/dist/lib/agent-pack.js +149 -0
- package/dist/lib/agent-pack.js.map +1 -0
- package/dist/lib/simple-agent-profile.d.ts +36 -0
- package/dist/lib/simple-agent-profile.d.ts.map +1 -0
- package/dist/lib/simple-agent-profile.js +183 -0
- package/dist/lib/simple-agent-profile.js.map +1 -0
- package/dist/routes/pages/agents.d.ts.map +1 -1
- package/dist/routes/pages/agents.js +11 -1
- package/dist/routes/pages/agents.js.map +1 -1
- package/dist/routes/pages/apps.$appId.d.ts.map +1 -1
- package/dist/routes/pages/apps.$appId.js +4 -95
- package/dist/routes/pages/apps.$appId.js.map +1 -1
- package/dist/routes/pages/chat.d.ts.map +1 -1
- package/dist/routes/pages/chat.js +62 -10
- package/dist/routes/pages/chat.js.map +1 -1
- package/dist/server/lib/agent-pack-store.d.ts +24 -0
- package/dist/server/lib/agent-pack-store.d.ts.map +1 -0
- package/dist/server/lib/agent-pack-store.js +22 -0
- package/dist/server/lib/agent-pack-store.js.map +1 -0
- package/dist/server/lib/dispatch-store.d.ts.map +1 -1
- package/dist/server/lib/dispatch-store.js +4 -0
- package/dist/server/lib/dispatch-store.js.map +1 -1
- package/dist/server/lib/mcp-gateway.d.ts +11 -0
- package/dist/server/lib/mcp-gateway.d.ts.map +1 -1
- package/dist/server/lib/mcp-gateway.js +155 -9
- package/dist/server/lib/mcp-gateway.js.map +1 -1
- package/dist/server/lib/workspace-resources-store.d.ts +15 -1
- package/dist/server/lib/workspace-resources-store.d.ts.map +1 -1
- package/dist/server/lib/workspace-resources-store.js +11 -2
- package/dist/server/lib/workspace-resources-store.js.map +1 -1
- package/dist/server/plugins/agent-chat.js +13 -0
- package/dist/server/plugins/agent-chat.js.map +1 -1
- package/dist/shared/feature-flags.d.ts +7 -0
- package/dist/shared/feature-flags.d.ts.map +1 -0
- package/dist/shared/feature-flags.js +12 -0
- package/dist/shared/feature-flags.js.map +1 -0
- package/dist/shared/workspace-sso.d.ts +36 -0
- package/dist/shared/workspace-sso.d.ts.map +1 -0
- package/dist/shared/workspace-sso.js +99 -0
- package/dist/shared/workspace-sso.js.map +1 -0
- package/package.json +5 -3
- package/src/actions/connect-external-agent.ts +92 -0
- package/src/actions/create-workspace-resource.ts +9 -2
- package/src/actions/create_workspace_app_embed_session.ts +32 -0
- package/src/actions/import-agent-pack.ts +146 -0
- package/src/actions/import-agent.ts +102 -0
- package/src/actions/index.spec.ts +13 -0
- package/src/actions/index.ts +10 -0
- package/src/actions/list-agent-pack.ts +43 -0
- package/src/actions/list-workspace-resource-options.ts +8 -1
- package/src/actions/list-workspace-resources.ts +8 -1
- package/src/actions/navigate.ts +1 -1
- package/src/actions/view-screen.spec.ts +29 -1
- package/src/actions/view-screen.ts +19 -1
- package/src/components/app-icon.spec.tsx +10 -0
- package/src/components/index.ts +1 -0
- package/src/components/layout/Layout.spec.tsx +2 -0
- package/src/components/layout/Layout.tsx +59 -171
- package/src/components/simple-agents-panel.spec.tsx +73 -0
- package/src/components/simple-agents-panel.tsx +1226 -0
- package/src/components/workspace-app-host.spec.tsx +204 -0
- package/src/components/workspace-app-host.tsx +359 -0
- package/src/db/migrations.spec.ts +5 -1
- package/src/db/migrations.ts +28 -1
- package/src/db/schema.ts +1 -1
- package/src/hooks/use-navigation-state.spec.ts +25 -0
- package/src/hooks/use-navigation-state.ts +11 -0
- package/src/lib/agent-pack.spec.ts +47 -0
- package/src/lib/agent-pack.ts +226 -0
- package/src/lib/simple-agent-profile.spec.ts +77 -0
- package/src/lib/simple-agent-profile.ts +247 -0
- package/src/routes/index.spec.ts +1 -0
- package/src/routes/pages/agents.tsx +21 -1
- package/src/routes/pages/apps.$appId.tsx +3 -240
- package/src/routes/pages/chat.spec.tsx +62 -0
- package/src/routes/pages/chat.tsx +117 -9
- package/src/server/lib/agent-pack-store.ts +35 -0
- package/src/server/lib/dispatch-store.ts +8 -0
- package/src/server/lib/mcp-gateway.spec.ts +141 -0
- package/src/server/lib/mcp-gateway.ts +227 -15
- package/src/server/lib/workspace-resources-store.ts +9 -2
- package/src/server/plugins/agent-chat.ts +13 -0
- package/src/shared/feature-flags.ts +13 -0
- package/src/shared/workspace-sso.ts +118 -0
package/README.md
CHANGED
|
@@ -24,7 +24,8 @@ Powers the `dispatch` template. Provides:
|
|
|
24
24
|
...) to splat into a consumer's `app/routes.ts`
|
|
25
25
|
- **React components** — `DispatchShell`, `Layout`/`NavContent`,
|
|
26
26
|
`CreateAppPopover`/`CreateAppFlow`, `AppKeysPopover`, plus a full
|
|
27
|
-
shadcn/ui-based `components/ui/*` primitive set
|
|
27
|
+
shadcn/ui-based `components/ui/*` primitive set. `SimpleAgentsPanel` is
|
|
28
|
+
also exported for embedding the shared agent manager in another workspace UI.
|
|
28
29
|
- **Styles** — `dispatch.css` Tailwind layer
|
|
29
30
|
|
|
30
31
|
## Install
|
|
@@ -95,6 +96,8 @@ file in the consumer's own `actions/` to override any single action.
|
|
|
95
96
|
| `./routes` | `dispatchRoutes` — a programmatic `RouteConfig[]` covering every Dispatch page (chat, overview, metrics, operations, apps, vault, integrations, agents, workspace, messaging, destinations, identities, approvals, automations, audit, settings, dreams, extensions, thread-debug, team, and a workspace-app catch-all route). |
|
|
96
97
|
| `./routes/pages/*` | Individual compiled page modules the routes above point at (e.g. `./routes/pages/vault.js`). Not normally imported directly. |
|
|
97
98
|
| `./server` | `setupDispatch(config)` plus the Nitro plugin set: `dispatchAuthPlugin`, `dispatchIntegrationsPlugin`, `dispatchAgentChatPlugin`, `dispatchDbPlugin`, `dispatchCoreRoutesPlugin`. Importing this module also side-effect-registers all Dispatch actions. |
|
|
99
|
+
| `./shared/feature-flags` | The default-off `DISPATCH_WORKSPACE_SSO_FLAG` definition used to target browser workspace sign-in safely. |
|
|
100
|
+
| `./shared/workspace-sso` | Exact first-party workspace SSO origins and the additive custom registration parser shared by Dispatch and the identity hub. |
|
|
98
101
|
| `./server/lib/thread-link-preview` | `loadThreadLinkPreview(threadId)` — server-only helper (reads request context and checks thread ownership) that builds link-preview metadata for shared thread URLs. |
|
|
99
102
|
| `./actions` | `dispatchActions` — the flat name → `ActionEntry` map of every Dispatch action (vault, workspace resources, destinations, dream jobs, provider-api catalog/docs/request, connected agents, audit, approvals, platform messaging, and more). |
|
|
100
103
|
| `./db` | `getDb()` / `db()`, the Drizzle `schema` namespace, the Dispatch table exports (`dispatchDestinations`, `dispatchIdentityLinks`, `dispatchLinkTokens`, `dispatchApprovalRequests`, `dispatchAuditEvents`, `dispatchDreams`, `dispatchDreamProposals`, `vaultSecrets`, `vaultGrants`, `vaultRequests`, `vaultAuditLog`, `workspaceResources`, `workspaceResourceGrants`), and migrations. |
|
|
@@ -112,6 +115,14 @@ apps:
|
|
|
112
115
|
scoped per app.
|
|
113
116
|
- **Workspace resources** — cross-app resources (e.g. shared instructions or
|
|
114
117
|
data) with explicit per-app grants and effective-context resolution.
|
|
118
|
+
- **Simple agents and agent packs** — reusable agents keep a Claude-compatible
|
|
119
|
+
Markdown/JSON profile at `agents/<slug>.md` and can own sibling files under
|
|
120
|
+
`agents/<slug>/context/`, `references/`, and `skills/<name>/SKILL.md`. The
|
|
121
|
+
`import-agent-pack` and `list-agent-pack` actions create/read the whole pack;
|
|
122
|
+
`import-agent` remains the fast single-file path. Unsafe capabilities such as
|
|
123
|
+
credentials, hooks, shell commands, and local environment settings are
|
|
124
|
+
stripped or reported as warnings. Pack files are text resources, not an
|
|
125
|
+
execution grant.
|
|
115
126
|
- **Integrations & destinations** — outbound messaging channel setup (Slack,
|
|
116
127
|
Teams, Discord, Telegram, WhatsApp, email, and more) and a destinations
|
|
117
128
|
queue for delivering agent output.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare const _default: import("@agent-native/core").ActionDefinition<{
|
|
2
|
+
url: string;
|
|
3
|
+
name?: string | undefined;
|
|
4
|
+
description?: string | undefined;
|
|
5
|
+
scope?: "personal" | "shared" | undefined;
|
|
6
|
+
}, {
|
|
7
|
+
status: "created";
|
|
8
|
+
resource: import("@agent-native/core/resources/store").Resource;
|
|
9
|
+
agent: {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
description?: string | undefined;
|
|
13
|
+
url: string;
|
|
14
|
+
};
|
|
15
|
+
scope: "personal" | "shared";
|
|
16
|
+
}>;
|
|
17
|
+
export default _default;
|
|
18
|
+
//# sourceMappingURL=connect-external-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect-external-agent.d.ts","sourceRoot":"","sources":["../../src/actions/connect-external-agent.ts"],"names":[],"mappings":";;;;;;YAyFqB,SAAS"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { defineAction } from "@agent-native/core";
|
|
2
|
+
import { getDbExec } from "@agent-native/core/db";
|
|
3
|
+
import { resourceGetByPath, resourcePut, sharedResourceOwner, } from "@agent-native/core/resources/store";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { currentOrgId, currentOwnerEmail, } from "../server/lib/dispatch-store.js";
|
|
6
|
+
function slugify(value) {
|
|
7
|
+
return (value
|
|
8
|
+
.trim()
|
|
9
|
+
.toLowerCase()
|
|
10
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
11
|
+
.replace(/^-+|-+$/g, "") || "agent");
|
|
12
|
+
}
|
|
13
|
+
async function assertCanManageSharedAgent() {
|
|
14
|
+
const orgId = currentOrgId();
|
|
15
|
+
if (!orgId)
|
|
16
|
+
return;
|
|
17
|
+
const actor = currentOwnerEmail().trim().toLowerCase();
|
|
18
|
+
const result = await getDbExec().execute({
|
|
19
|
+
sql: "SELECT role FROM org_members WHERE org_id = ? AND LOWER(email) = ? LIMIT 1",
|
|
20
|
+
args: [orgId, actor],
|
|
21
|
+
});
|
|
22
|
+
const role = result.rows[0]?.role;
|
|
23
|
+
if (role !== "owner" && role !== "admin") {
|
|
24
|
+
throw new Error("Only organization owners and admins can connect shared agents.");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export default defineAction({
|
|
28
|
+
description: "Connect an existing HTTP/A2A agent to Dispatch. This stores only its public endpoint and metadata; authentication remains in the normal A2A/MCP connection flow.",
|
|
29
|
+
schema: z.object({
|
|
30
|
+
url: z.string().min(1).describe("HTTP or HTTPS agent endpoint"),
|
|
31
|
+
name: z.string().max(160).optional().describe("Agent name"),
|
|
32
|
+
description: z.string().max(500).optional().describe("Short description"),
|
|
33
|
+
scope: z
|
|
34
|
+
.enum(["shared", "personal"])
|
|
35
|
+
.default("shared")
|
|
36
|
+
.describe("Share with the workspace or keep the connection personal"),
|
|
37
|
+
}),
|
|
38
|
+
run: async ({ url, name, description, scope }) => {
|
|
39
|
+
const parsed = new URL(url.trim());
|
|
40
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:") {
|
|
41
|
+
throw new Error("Use an http:// or https:// endpoint URL.");
|
|
42
|
+
}
|
|
43
|
+
if (parsed.username || parsed.password) {
|
|
44
|
+
throw new Error("Do not include credentials in the endpoint URL.");
|
|
45
|
+
}
|
|
46
|
+
if (scope === "shared")
|
|
47
|
+
await assertCanManageSharedAgent();
|
|
48
|
+
const agentName = name?.trim() || parsed.hostname.replace(/^www\./, "");
|
|
49
|
+
const id = slugify(agentName);
|
|
50
|
+
const path = `remote-agents/${id}.json`;
|
|
51
|
+
const owner = scope === "shared"
|
|
52
|
+
? sharedResourceOwner(currentOrgId())
|
|
53
|
+
: currentOwnerEmail();
|
|
54
|
+
const existing = await resourceGetByPath(owner, path);
|
|
55
|
+
if (existing) {
|
|
56
|
+
throw new Error(`An external agent already exists at ${path}. Rename it before connecting again.`);
|
|
57
|
+
}
|
|
58
|
+
const manifest = {
|
|
59
|
+
id,
|
|
60
|
+
name: agentName,
|
|
61
|
+
...(description?.trim() ? { description: description.trim() } : {}),
|
|
62
|
+
url: parsed.toString(),
|
|
63
|
+
};
|
|
64
|
+
const resource = await resourcePut(owner, path, JSON.stringify(manifest, null, 2), "application/json");
|
|
65
|
+
return { status: "created", resource, agent: manifest, scope };
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=connect-external-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect-external-agent.js","sourceRoot":"","sources":["../../src/actions/connect-external-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,mBAAmB,GACpB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,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,IAAI,sCAAsC,CAClF,CAAC;QACJ,CAAC;QAED,MAAM,QAAQ,GAAG;YACf,EAAE;YACF,IAAI,EAAE,SAAS;YACf,GAAG,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,WAAW,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACnE,GAAG,EAAE,MAAM,CAAC,QAAQ,EAAE;SACvB,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,WAAW,CAChC,KAAK,EACL,IAAI,EACJ,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EACjC,kBAAkB,CACnB,CAAC;QAEF,OAAO,EAAE,MAAM,EAAE,SAAkB,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAC1E,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { defineAction } from \"@agent-native/core\";\nimport { getDbExec } from \"@agent-native/core/db\";\nimport {\n resourceGetByPath,\n resourcePut,\n sharedResourceOwner,\n} from \"@agent-native/core/resources/store\";\nimport { z } from \"zod\";\n\nimport {\n currentOrgId,\n currentOwnerEmail,\n} from \"../server/lib/dispatch-store.js\";\n\nfunction slugify(value: string): string {\n return (\n value\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\") || \"agent\"\n );\n}\n\nasync function assertCanManageSharedAgent() {\n const orgId = currentOrgId();\n if (!orgId) return;\n const actor = currentOwnerEmail().trim().toLowerCase();\n const result = await getDbExec().execute({\n sql: \"SELECT role FROM org_members WHERE org_id = ? AND LOWER(email) = ? LIMIT 1\",\n args: [orgId, actor],\n });\n const role = result.rows[0]?.role;\n if (role !== \"owner\" && role !== \"admin\") {\n throw new Error(\n \"Only organization owners and admins can connect shared agents.\",\n );\n }\n}\n\nexport default defineAction({\n description:\n \"Connect an existing HTTP/A2A agent to Dispatch. This stores only its public endpoint and metadata; authentication remains in the normal A2A/MCP connection flow.\",\n schema: z.object({\n url: z.string().min(1).describe(\"HTTP or HTTPS agent endpoint\"),\n name: z.string().max(160).optional().describe(\"Agent name\"),\n description: z.string().max(500).optional().describe(\"Short description\"),\n scope: z\n .enum([\"shared\", \"personal\"])\n .default(\"shared\")\n .describe(\"Share with the workspace or keep the connection personal\"),\n }),\n run: async ({ url, name, description, scope }) => {\n const parsed = new URL(url.trim());\n if (parsed.protocol !== \"https:\" && parsed.protocol !== \"http:\") {\n throw new Error(\"Use an http:// or https:// endpoint URL.\");\n }\n if (parsed.username || parsed.password) {\n throw new Error(\"Do not include credentials in the endpoint URL.\");\n }\n\n if (scope === \"shared\") await assertCanManageSharedAgent();\n const agentName = name?.trim() || parsed.hostname.replace(/^www\\./, \"\");\n const id = slugify(agentName);\n const path = `remote-agents/${id}.json`;\n const owner =\n scope === \"shared\"\n ? sharedResourceOwner(currentOrgId())\n : currentOwnerEmail();\n const existing = await resourceGetByPath(owner, path);\n if (existing) {\n throw new Error(\n `An external agent already exists at ${path}. Rename it before connecting again.`,\n );\n }\n\n const manifest = {\n id,\n name: agentName,\n ...(description?.trim() ? { description: description.trim() } : {}),\n url: parsed.toString(),\n };\n const resource = await resourcePut(\n owner,\n path,\n JSON.stringify(manifest, null, 2),\n \"application/json\",\n );\n\n return { status: \"created\" as const, resource, agent: manifest, scope };\n },\n});\n"]}
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
declare const _default: import("@agent-native/core").ActionDefinition<{
|
|
2
|
-
kind: "agent" | "instruction" | "knowledge" | "mcp-server" | "skill";
|
|
2
|
+
kind: "agent" | "agent-file" | "instruction" | "knowledge" | "mcp-server" | "skill";
|
|
3
3
|
name: string;
|
|
4
4
|
description?: string | undefined;
|
|
5
5
|
path: string;
|
|
6
6
|
content: string;
|
|
7
7
|
scope: "all" | "selected";
|
|
8
8
|
}, {
|
|
9
|
+
id: string;
|
|
10
|
+
ownerEmail: string;
|
|
11
|
+
orgId: string | null;
|
|
12
|
+
kind: string;
|
|
13
|
+
name: string;
|
|
14
|
+
description: string | null;
|
|
15
|
+
path: string;
|
|
16
|
+
content: string;
|
|
17
|
+
scope: string;
|
|
18
|
+
createdBy: string;
|
|
19
|
+
createdAt: number;
|
|
20
|
+
updatedAt: number;
|
|
21
|
+
} | {
|
|
9
22
|
id: string;
|
|
10
23
|
ownerEmail: string;
|
|
11
24
|
orgId: string | null;
|
|
@@ -22,19 +35,6 @@ declare const _default: import("@agent-native/core").ActionDefinition<{
|
|
|
22
35
|
reviewedAt: number | null;
|
|
23
36
|
createdAt: number;
|
|
24
37
|
updatedAt: number;
|
|
25
|
-
} | {
|
|
26
|
-
id: string;
|
|
27
|
-
ownerEmail: string;
|
|
28
|
-
orgId: string | null;
|
|
29
|
-
kind: string;
|
|
30
|
-
name: string;
|
|
31
|
-
description: string | null;
|
|
32
|
-
path: string;
|
|
33
|
-
content: string;
|
|
34
|
-
scope: string;
|
|
35
|
-
createdBy: string;
|
|
36
|
-
createdAt: number;
|
|
37
|
-
updatedAt: number;
|
|
38
38
|
}>;
|
|
39
39
|
export default _default;
|
|
40
40
|
//# sourceMappingURL=create-workspace-resource.d.ts.map
|
|
@@ -5,8 +5,15 @@ export default defineAction({
|
|
|
5
5
|
description: 'Create a workspace-wide skill, instruction, agent profile, reference resource, or MCP server. Set scope to "all" for runtime inheritance by every app, or "selected" to grant per-app. When Dispatch approval policy is enabled, All-app creates queue an approval request before taking effect.',
|
|
6
6
|
schema: z.object({
|
|
7
7
|
kind: z
|
|
8
|
-
.enum([
|
|
9
|
-
|
|
8
|
+
.enum([
|
|
9
|
+
"skill",
|
|
10
|
+
"instruction",
|
|
11
|
+
"agent",
|
|
12
|
+
"agent-file",
|
|
13
|
+
"knowledge",
|
|
14
|
+
"mcp-server",
|
|
15
|
+
])
|
|
16
|
+
.describe("Resource kind: skill, instruction, agent, agent-file, knowledge, or mcp-server"),
|
|
10
17
|
name: z.string().describe("Human-readable name"),
|
|
11
18
|
description: z.string().optional().describe("Short description"),
|
|
12
19
|
path: z
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-workspace-resource.js","sourceRoot":"","sources":["../../src/actions/create-workspace-resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AAErF,eAAe,YAAY,CAAC;IAC1B,WAAW,EACT,kSAAkS;IACpS,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,IAAI,EAAE,CAAC;aACJ,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"create-workspace-resource.js","sourceRoot":"","sources":["../../src/actions/create-workspace-resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AAErF,eAAe,YAAY,CAAC;IAC1B,WAAW,EACT,kSAAkS;IACpS,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,IAAI,EAAE,CAAC;aACJ,IAAI,CAAC;YACJ,OAAO;YACP,aAAa;YACb,OAAO;YACP,YAAY;YACZ,WAAW;YACX,YAAY;SACb,CAAC;aACD,QAAQ,CACP,gFAAgF,CACjF;QACH,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC;QAChD,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC;QAChE,IAAI,EAAE,CAAC;aACJ,MAAM,EAAE;aACR,QAAQ,CACP,iRAAiR,CAClR;QACH,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;QACxE,KAAK,EAAE,CAAC;aACL,IAAI,CAAC,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;aACzB,QAAQ,CACP,wFAAwF,CACzF;KACJ,CAAC;IACF,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,uBAAuB,CAAC,IAAI,CAAC;CACnD,CAAC,CAAC","sourcesContent":["import { defineAction } from \"@agent-native/core\";\nimport { z } from \"zod\";\n\nimport { createWorkspaceResource } from \"../server/lib/workspace-resources-store.js\";\n\nexport default defineAction({\n description:\n 'Create a workspace-wide skill, instruction, agent profile, reference resource, or MCP server. Set scope to \"all\" for runtime inheritance by every app, or \"selected\" to grant per-app. When Dispatch approval policy is enabled, All-app creates queue an approval request before taking effect.',\n schema: z.object({\n kind: z\n .enum([\n \"skill\",\n \"instruction\",\n \"agent\",\n \"agent-file\",\n \"knowledge\",\n \"mcp-server\",\n ])\n .describe(\n \"Resource kind: skill, instruction, agent, agent-file, knowledge, or mcp-server\",\n ),\n name: z.string().describe(\"Human-readable name\"),\n description: z.string().optional().describe(\"Short description\"),\n path: z\n .string()\n .describe(\n 'Resource path in target apps. Use \"skills/<name>/SKILL.md\" for skills, \"AGENTS.md\" or \"instructions/<name>.md\" for always-on guardrails, \"context/<name>.md\" for reference resources, \"agents/<name>.md\" for custom agents, and \"mcp-servers/<name>.json\" for HTTP MCP servers.',\n ),\n content: z.string().describe(\"Full resource content (markdown or JSON)\"),\n scope: z\n .enum([\"all\", \"selected\"])\n .describe(\n '\"all\" = inherited by every app at runtime, \"selected\" = only apps with explicit grants',\n ),\n }),\n run: async (args) => createWorkspaceResource(args),\n});\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare const _default: import("@agent-native/core").ActionDefinition<{
|
|
2
|
+
app?: string | undefined;
|
|
3
|
+
url?: string | undefined;
|
|
4
|
+
path?: string | undefined;
|
|
5
|
+
chrome?: "full" | "minimal" | undefined;
|
|
6
|
+
}, {
|
|
7
|
+
startUrl: string;
|
|
8
|
+
targetPath?: string;
|
|
9
|
+
expiresAt?: number;
|
|
10
|
+
app: string;
|
|
11
|
+
}>;
|
|
12
|
+
export default _default;
|
|
13
|
+
//# sourceMappingURL=create_workspace_app_embed_session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create_workspace_app_embed_session.d.ts","sourceRoot":"","sources":["../../src/actions/create_workspace_app_embed_session.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { defineAction } from "@agent-native/core";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { createWorkspaceSsoEmbedSession } from "../server/lib/mcp-gateway.js";
|
|
4
|
+
export default defineAction({
|
|
5
|
+
description: "Create a one-time app-scoped embed session for a workspace app opened inside Dispatch. This browser-only path is rollout-gated and never exposes an app's reusable session to another app.",
|
|
6
|
+
schema: z.object({
|
|
7
|
+
app: z
|
|
8
|
+
.string()
|
|
9
|
+
.optional()
|
|
10
|
+
.describe("Workspace app id when path is app-relative."),
|
|
11
|
+
url: z
|
|
12
|
+
.string()
|
|
13
|
+
.optional()
|
|
14
|
+
.describe("Absolute app URL or app-relative path."),
|
|
15
|
+
path: z
|
|
16
|
+
.string()
|
|
17
|
+
.optional()
|
|
18
|
+
.describe("App-relative path. Requires app when url is not provided."),
|
|
19
|
+
chrome: z
|
|
20
|
+
.enum(["full", "minimal"])
|
|
21
|
+
.optional()
|
|
22
|
+
.describe("Embed chrome preference. Defaults to full."),
|
|
23
|
+
}),
|
|
24
|
+
readOnly: false,
|
|
25
|
+
parallelSafe: false,
|
|
26
|
+
agentTool: false,
|
|
27
|
+
toolCallable: false,
|
|
28
|
+
run: async (args) => createWorkspaceSsoEmbedSession(args),
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=create_workspace_app_embed_session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create_workspace_app_embed_session.js","sourceRoot":"","sources":["../../src/actions/create_workspace_app_embed_session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,8BAA8B,EAAE,MAAM,8BAA8B,CAAC;AAE9E,eAAe,YAAY,CAAC;IAC1B,WAAW,EACT,4LAA4L;IAC9L,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,GAAG,EAAE,CAAC;aACH,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CAAC,6CAA6C,CAAC;QAC1D,GAAG,EAAE,CAAC;aACH,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CAAC,wCAAwC,CAAC;QACrD,IAAI,EAAE,CAAC;aACJ,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CAAC,2DAA2D,CAAC;QACxE,MAAM,EAAE,CAAC;aACN,IAAI,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;aACzB,QAAQ,EAAE;aACV,QAAQ,CAAC,4CAA4C,CAAC;KAC1D,CAAC;IACF,QAAQ,EAAE,KAAK;IACf,YAAY,EAAE,KAAK;IACnB,SAAS,EAAE,KAAK;IAChB,YAAY,EAAE,KAAK;IACnB,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,8BAA8B,CAAC,IAAI,CAAC;CAC1D,CAAC,CAAC","sourcesContent":["import { defineAction } from \"@agent-native/core\";\nimport { z } from \"zod\";\n\nimport { createWorkspaceSsoEmbedSession } from \"../server/lib/mcp-gateway.js\";\n\nexport default defineAction({\n description:\n \"Create a one-time app-scoped embed session for a workspace app opened inside Dispatch. This browser-only path is rollout-gated and never exposes an app's reusable session to another app.\",\n schema: z.object({\n app: z\n .string()\n .optional()\n .describe(\"Workspace app id when path is app-relative.\"),\n url: z\n .string()\n .optional()\n .describe(\"Absolute app URL or app-relative path.\"),\n path: z\n .string()\n .optional()\n .describe(\"App-relative path. Requires app when url is not provided.\"),\n chrome: z\n .enum([\"full\", \"minimal\"])\n .optional()\n .describe(\"Embed chrome preference. Defaults to full.\"),\n }),\n readOnly: false,\n parallelSafe: false,\n agentTool: false,\n toolCallable: false,\n run: async (args) => createWorkspaceSsoEmbedSession(args),\n});\n"]}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
declare const _default: import("@agent-native/core").ActionDefinition<{
|
|
2
|
+
files: {
|
|
3
|
+
path: string;
|
|
4
|
+
content: string;
|
|
5
|
+
}[];
|
|
6
|
+
scope?: "all" | "selected" | undefined;
|
|
7
|
+
}, {
|
|
8
|
+
status: "unchanged";
|
|
9
|
+
resource: {
|
|
10
|
+
id: string;
|
|
11
|
+
ownerEmail: string;
|
|
12
|
+
orgId: string | null;
|
|
13
|
+
kind: string;
|
|
14
|
+
name: string;
|
|
15
|
+
description: string | null;
|
|
16
|
+
path: string;
|
|
17
|
+
content: string;
|
|
18
|
+
scope: string;
|
|
19
|
+
createdBy: string;
|
|
20
|
+
createdAt: number;
|
|
21
|
+
updatedAt: number;
|
|
22
|
+
};
|
|
23
|
+
files: {
|
|
24
|
+
id: string;
|
|
25
|
+
ownerEmail: string;
|
|
26
|
+
orgId: string | null;
|
|
27
|
+
kind: string;
|
|
28
|
+
name: string;
|
|
29
|
+
description: string | null;
|
|
30
|
+
path: string;
|
|
31
|
+
content: string;
|
|
32
|
+
scope: string;
|
|
33
|
+
createdBy: string;
|
|
34
|
+
createdAt: number;
|
|
35
|
+
updatedAt: number;
|
|
36
|
+
}[];
|
|
37
|
+
warnings: string[];
|
|
38
|
+
approval?: undefined;
|
|
39
|
+
} | {
|
|
40
|
+
status: "pending-approval";
|
|
41
|
+
approval: {
|
|
42
|
+
id: string;
|
|
43
|
+
ownerEmail: string;
|
|
44
|
+
orgId: string | null;
|
|
45
|
+
changeType: string;
|
|
46
|
+
targetType: string;
|
|
47
|
+
targetId: string | null;
|
|
48
|
+
status: string;
|
|
49
|
+
summary: string;
|
|
50
|
+
payload: string;
|
|
51
|
+
beforeValue: string | null;
|
|
52
|
+
afterValue: string | null;
|
|
53
|
+
requestedBy: string;
|
|
54
|
+
reviewedBy: string | null;
|
|
55
|
+
reviewedAt: number | null;
|
|
56
|
+
createdAt: number;
|
|
57
|
+
updatedAt: number;
|
|
58
|
+
};
|
|
59
|
+
warnings: string[];
|
|
60
|
+
resource?: undefined;
|
|
61
|
+
files?: undefined;
|
|
62
|
+
} | {
|
|
63
|
+
approval?: undefined;
|
|
64
|
+
status: "created";
|
|
65
|
+
resource: {
|
|
66
|
+
id: string;
|
|
67
|
+
ownerEmail: string;
|
|
68
|
+
orgId: string | null;
|
|
69
|
+
kind: string;
|
|
70
|
+
name: string;
|
|
71
|
+
description: string | null;
|
|
72
|
+
path: string;
|
|
73
|
+
content: string;
|
|
74
|
+
scope: string;
|
|
75
|
+
createdBy: string;
|
|
76
|
+
createdAt: number;
|
|
77
|
+
updatedAt: number;
|
|
78
|
+
};
|
|
79
|
+
files: {
|
|
80
|
+
id: string;
|
|
81
|
+
ownerEmail: string;
|
|
82
|
+
orgId: string | null;
|
|
83
|
+
kind: string;
|
|
84
|
+
name: string;
|
|
85
|
+
description: string | null;
|
|
86
|
+
path: string;
|
|
87
|
+
content: string;
|
|
88
|
+
scope: string;
|
|
89
|
+
createdBy: string;
|
|
90
|
+
createdAt: number;
|
|
91
|
+
updatedAt: number;
|
|
92
|
+
}[];
|
|
93
|
+
warnings: string[];
|
|
94
|
+
}>;
|
|
95
|
+
export default _default;
|
|
96
|
+
//# sourceMappingURL=import-agent-pack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-agent-pack.d.ts","sourceRoot":"","sources":["../../src/actions/import-agent-pack.ts"],"names":[],"mappings":";;;;;;;YA0GgB,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA4BJ,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;YAK3B,SAAS"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import { defineAction } from "@agent-native/core";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { AGENT_PACK_MAX_FILE_BYTES, AGENT_PACK_MAX_FILES, agentPackProfileContent, agentPackRoot, normalizeAgentPack, } from "../lib/agent-pack.js";
|
|
5
|
+
import { validateImportedAgentTools } from "../lib/simple-agent-profile.js";
|
|
6
|
+
import { applyAgentPackCreate } from "../server/lib/agent-pack-store.js";
|
|
7
|
+
import { createApprovalRequest, getApprovalPolicy, } from "../server/lib/dispatch-store.js";
|
|
8
|
+
import { listWorkspaceResources, } from "../server/lib/workspace-resources-store.js";
|
|
9
|
+
const packFileSchema = z.object({
|
|
10
|
+
path: z.string().trim().min(1).max(240),
|
|
11
|
+
content: z.string().max(AGENT_PACK_MAX_FILE_BYTES),
|
|
12
|
+
});
|
|
13
|
+
const schema = z.object({
|
|
14
|
+
files: z
|
|
15
|
+
.array(packFileSchema)
|
|
16
|
+
.min(1)
|
|
17
|
+
.max(AGENT_PACK_MAX_FILES)
|
|
18
|
+
.describe("Text files from an agent folder, including its profile"),
|
|
19
|
+
scope: z
|
|
20
|
+
.enum(["all", "selected"])
|
|
21
|
+
.default("all")
|
|
22
|
+
.describe("Make the pack available to all apps or selected apps"),
|
|
23
|
+
});
|
|
24
|
+
function availableToolNames(dispatchToolNames) {
|
|
25
|
+
return new Set([
|
|
26
|
+
...dispatchToolNames,
|
|
27
|
+
"agent-teams",
|
|
28
|
+
"bash",
|
|
29
|
+
"call-agent",
|
|
30
|
+
"db-query",
|
|
31
|
+
"db-schema",
|
|
32
|
+
"refresh-screen",
|
|
33
|
+
"resources",
|
|
34
|
+
"set-search-params",
|
|
35
|
+
"set-url-path",
|
|
36
|
+
"tool-search",
|
|
37
|
+
"web-request",
|
|
38
|
+
"web-search",
|
|
39
|
+
]);
|
|
40
|
+
}
|
|
41
|
+
export default defineAction({
|
|
42
|
+
description: "Import a folder-backed agent pack from Claude, Cowork, or another agent tool. The pack can include a Markdown/JSON profile, context, references, and skills. Credentials, hooks, shell commands, and local environment settings are never imported.",
|
|
43
|
+
schema,
|
|
44
|
+
run: async ({ files, scope }) => {
|
|
45
|
+
const normalized = normalizeAgentPack(files);
|
|
46
|
+
const { dispatchActions } = await import("./index.js");
|
|
47
|
+
const toolValidation = validateImportedAgentTools(normalized.profile.tools, availableToolNames(Object.keys(dispatchActions)));
|
|
48
|
+
const warnings = [...normalized.warnings, ...toolValidation.warnings];
|
|
49
|
+
const sourceHash = crypto
|
|
50
|
+
.createHash("sha256")
|
|
51
|
+
.update(JSON.stringify(files))
|
|
52
|
+
.digest("hex");
|
|
53
|
+
const profileContent = agentPackProfileContent({
|
|
54
|
+
profile: normalized.profile,
|
|
55
|
+
tools: toolValidation.tools,
|
|
56
|
+
sourceHash,
|
|
57
|
+
importedAt: new Date().toISOString(),
|
|
58
|
+
});
|
|
59
|
+
const root = agentPackRoot(normalized.profile.slug);
|
|
60
|
+
const inputs = [
|
|
61
|
+
{
|
|
62
|
+
kind: "agent",
|
|
63
|
+
name: normalized.profile.name,
|
|
64
|
+
description: normalized.profile.description,
|
|
65
|
+
path: `${root}.md`,
|
|
66
|
+
content: profileContent,
|
|
67
|
+
scope,
|
|
68
|
+
},
|
|
69
|
+
...normalized.files.map((file) => ({
|
|
70
|
+
kind: file.kind,
|
|
71
|
+
name: file.name,
|
|
72
|
+
description: file.description,
|
|
73
|
+
path: `${root}/${file.path}`,
|
|
74
|
+
content: file.content,
|
|
75
|
+
scope,
|
|
76
|
+
})),
|
|
77
|
+
];
|
|
78
|
+
const existing = await listWorkspaceResources();
|
|
79
|
+
const existingProfile = existing.find((resource) => resource.path === `${root}.md`);
|
|
80
|
+
if (existingProfile?.content.includes(`source-hash: ${sourceHash}`)) {
|
|
81
|
+
return {
|
|
82
|
+
status: "unchanged",
|
|
83
|
+
resource: existingProfile,
|
|
84
|
+
files: existing.filter((resource) => resource.path.startsWith(`${root}/`)),
|
|
85
|
+
warnings,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
if (existingProfile) {
|
|
89
|
+
throw new Error(`An agent already exists at ${root}. Rename the source before importing it.`);
|
|
90
|
+
}
|
|
91
|
+
const policy = await getApprovalPolicy();
|
|
92
|
+
if (scope === "all" && policy.enabled) {
|
|
93
|
+
const approval = await createApprovalRequest({
|
|
94
|
+
changeType: "workspace-agent-pack.create",
|
|
95
|
+
targetType: "workspace-agent-pack",
|
|
96
|
+
summary: `Import All-app agent pack "${normalized.profile.name}"`,
|
|
97
|
+
payload: { inputs },
|
|
98
|
+
beforeValue: null,
|
|
99
|
+
afterValue: {
|
|
100
|
+
name: normalized.profile.name,
|
|
101
|
+
path: `${root}.md`,
|
|
102
|
+
fileCount: inputs.length,
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
return { status: "pending-approval", approval, warnings };
|
|
106
|
+
}
|
|
107
|
+
const created = await applyAgentPackCreate(inputs);
|
|
108
|
+
return {
|
|
109
|
+
status: "created",
|
|
110
|
+
resource: created[0] ?? null,
|
|
111
|
+
files: created.slice(1),
|
|
112
|
+
warnings,
|
|
113
|
+
};
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
//# sourceMappingURL=import-agent-pack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-agent-pack.js","sourceRoot":"","sources":["../../src/actions/import-agent-pack.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,uBAAuB,EACvB,aAAa,EACb,kBAAkB,GAEnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,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E,QAAQ,EAAE,QAAQ,EAAE,CAAC;QACrE,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,oBAAoB,CAAC,MAAM,CAAC,CAAC;QACnD,OAAO;YACL,MAAM,EAAE,SAAkB;YAC1B,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI;YAC5B,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;YACvB,QAAQ;SACT,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import crypto from \"node:crypto\";\n\nimport { defineAction } from \"@agent-native/core\";\nimport { z } from \"zod\";\n\nimport {\n AGENT_PACK_MAX_FILE_BYTES,\n AGENT_PACK_MAX_FILES,\n agentPackProfileContent,\n agentPackRoot,\n normalizeAgentPack,\n type AgentPackFileInput,\n} from \"../lib/agent-pack.js\";\nimport { validateImportedAgentTools } from \"../lib/simple-agent-profile.js\";\nimport { applyAgentPackCreate } from \"../server/lib/agent-pack-store.js\";\nimport {\n createApprovalRequest,\n getApprovalPolicy,\n} from \"../server/lib/dispatch-store.js\";\nimport {\n listWorkspaceResources,\n type WorkspaceResourceInput,\n} from \"../server/lib/workspace-resources-store.js\";\n\nconst packFileSchema = z.object({\n path: z.string().trim().min(1).max(240),\n content: z.string().max(AGENT_PACK_MAX_FILE_BYTES),\n});\n\nconst schema = z.object({\n files: z\n .array(packFileSchema)\n .min(1)\n .max(AGENT_PACK_MAX_FILES)\n .describe(\"Text files from an agent folder, including its profile\"),\n scope: z\n .enum([\"all\", \"selected\"])\n .default(\"all\")\n .describe(\"Make the pack available to all apps or selected apps\"),\n});\n\nfunction availableToolNames(dispatchToolNames: string[]): Set<string> {\n return new Set([\n ...dispatchToolNames,\n \"agent-teams\",\n \"bash\",\n \"call-agent\",\n \"db-query\",\n \"db-schema\",\n \"refresh-screen\",\n \"resources\",\n \"set-search-params\",\n \"set-url-path\",\n \"tool-search\",\n \"web-request\",\n \"web-search\",\n ]);\n}\n\nexport default defineAction({\n description:\n \"Import a folder-backed agent pack from Claude, Cowork, or another agent tool. The pack can include a Markdown/JSON profile, context, references, and skills. Credentials, hooks, shell commands, and local environment settings are never imported.\",\n schema,\n run: async ({ files, scope }) => {\n const normalized = normalizeAgentPack(files as AgentPackFileInput[]);\n const { dispatchActions } = await import(\"./index.js\");\n const toolValidation = validateImportedAgentTools(\n normalized.profile.tools,\n availableToolNames(Object.keys(dispatchActions)),\n );\n const warnings = [...normalized.warnings, ...toolValidation.warnings];\n const sourceHash = crypto\n .createHash(\"sha256\")\n .update(JSON.stringify(files))\n .digest(\"hex\");\n const profileContent = agentPackProfileContent({\n profile: normalized.profile,\n tools: toolValidation.tools,\n sourceHash,\n importedAt: new Date().toISOString(),\n });\n const root = agentPackRoot(normalized.profile.slug);\n const inputs: WorkspaceResourceInput[] = [\n {\n kind: \"agent\",\n name: normalized.profile.name,\n description: normalized.profile.description,\n path: `${root}.md`,\n content: profileContent,\n scope,\n },\n ...normalized.files.map((file) => ({\n kind: file.kind,\n name: file.name,\n description: file.description,\n path: `${root}/${file.path}`,\n content: file.content,\n scope,\n })),\n ];\n const existing = await listWorkspaceResources();\n const existingProfile = existing.find(\n (resource) => resource.path === `${root}.md`,\n );\n if (existingProfile?.content.includes(`source-hash: ${sourceHash}`)) {\n return {\n status: \"unchanged\" as const,\n resource: existingProfile,\n files: existing.filter((resource) =>\n resource.path.startsWith(`${root}/`),\n ),\n warnings,\n };\n }\n if (existingProfile) {\n throw new Error(\n `An agent already exists at ${root}. Rename the source before importing it.`,\n );\n }\n\n const policy = await getApprovalPolicy();\n if (scope === \"all\" && policy.enabled) {\n const approval = await createApprovalRequest({\n changeType: \"workspace-agent-pack.create\",\n targetType: \"workspace-agent-pack\",\n summary: `Import All-app agent pack \"${normalized.profile.name}\"`,\n payload: { inputs },\n beforeValue: null,\n afterValue: {\n name: normalized.profile.name,\n path: `${root}.md`,\n fileCount: inputs.length,\n },\n });\n return { status: \"pending-approval\" as const, approval, warnings };\n }\n\n const created = await applyAgentPackCreate(inputs);\n return {\n status: \"created\" as const,\n resource: created[0] ?? null,\n files: created.slice(1),\n warnings,\n };\n },\n});\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
declare const _default: import("@agent-native/core").ActionDefinition<{
|
|
2
|
+
source: string;
|
|
3
|
+
fileName?: string | undefined;
|
|
4
|
+
scope?: "all" | "selected" | undefined;
|
|
5
|
+
}, {
|
|
6
|
+
status: "unchanged";
|
|
7
|
+
resource: {
|
|
8
|
+
id: string;
|
|
9
|
+
ownerEmail: string;
|
|
10
|
+
orgId: string | null;
|
|
11
|
+
kind: string;
|
|
12
|
+
name: string;
|
|
13
|
+
description: string | null;
|
|
14
|
+
path: string;
|
|
15
|
+
content: string;
|
|
16
|
+
scope: string;
|
|
17
|
+
createdBy: string;
|
|
18
|
+
createdAt: number;
|
|
19
|
+
updatedAt: number;
|
|
20
|
+
};
|
|
21
|
+
source: "claude" | "json" | "markdown";
|
|
22
|
+
warnings: string[];
|
|
23
|
+
} | {
|
|
24
|
+
status: "created";
|
|
25
|
+
resource: {
|
|
26
|
+
id: string;
|
|
27
|
+
ownerEmail: string;
|
|
28
|
+
orgId: string | null;
|
|
29
|
+
changeType: string;
|
|
30
|
+
targetType: string;
|
|
31
|
+
targetId: string | null;
|
|
32
|
+
status: string;
|
|
33
|
+
summary: string;
|
|
34
|
+
payload: string;
|
|
35
|
+
beforeValue: string | null;
|
|
36
|
+
afterValue: string | null;
|
|
37
|
+
requestedBy: string;
|
|
38
|
+
reviewedBy: string | null;
|
|
39
|
+
reviewedAt: number | null;
|
|
40
|
+
createdAt: number;
|
|
41
|
+
updatedAt: number;
|
|
42
|
+
} | {
|
|
43
|
+
id: string;
|
|
44
|
+
ownerEmail: string;
|
|
45
|
+
orgId: string | null;
|
|
46
|
+
kind: string;
|
|
47
|
+
name: string;
|
|
48
|
+
description: string | null;
|
|
49
|
+
path: string;
|
|
50
|
+
content: string;
|
|
51
|
+
scope: string;
|
|
52
|
+
createdBy: string;
|
|
53
|
+
createdAt: number;
|
|
54
|
+
updatedAt: number;
|
|
55
|
+
};
|
|
56
|
+
source: "claude" | "json" | "markdown";
|
|
57
|
+
warnings: string[];
|
|
58
|
+
}>;
|
|
59
|
+
export default _default;
|
|
60
|
+
//# sourceMappingURL=import-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-agent.d.ts","sourceRoot":"","sources":["../../src/actions/import-agent.ts"],"names":[],"mappings":";;;;;YA0EkB,WAAW;;;;;;;;;;;;;;;;;;YAqBf,SAAS"}
|