@agent-native/dispatch 0.2.11 → 0.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/dist/actions/create-workspace-resource.js +4 -4
  2. package/dist/actions/create-workspace-resource.js.map +1 -1
  3. package/dist/actions/grant-workspace-resources-to-app.d.ts +3 -0
  4. package/dist/actions/grant-workspace-resources-to-app.d.ts.map +1 -0
  5. package/dist/actions/grant-workspace-resources-to-app.js +15 -0
  6. package/dist/actions/grant-workspace-resources-to-app.js.map +1 -0
  7. package/dist/actions/index.d.ts.map +1 -1
  8. package/dist/actions/index.js +4 -0
  9. package/dist/actions/index.js.map +1 -1
  10. package/dist/actions/list-workspace-resource-options.d.ts +3 -0
  11. package/dist/actions/list-workspace-resource-options.d.ts.map +1 -0
  12. package/dist/actions/list-workspace-resource-options.js +15 -0
  13. package/dist/actions/list-workspace-resource-options.js.map +1 -0
  14. package/dist/actions/list-workspace-resources.js +2 -2
  15. package/dist/actions/list-workspace-resources.js.map +1 -1
  16. package/dist/actions/start-workspace-app-creation.d.ts.map +1 -1
  17. package/dist/actions/start-workspace-app-creation.js +6 -1
  18. package/dist/actions/start-workspace-app-creation.js.map +1 -1
  19. package/dist/actions/view-screen.d.ts.map +1 -1
  20. package/dist/actions/view-screen.js +4 -0
  21. package/dist/actions/view-screen.js.map +1 -1
  22. package/dist/components/app-keys-popover.js +3 -3
  23. package/dist/components/app-keys-popover.js.map +1 -1
  24. package/dist/components/create-app-popover.d.ts +1 -1
  25. package/dist/components/create-app-popover.d.ts.map +1 -1
  26. package/dist/components/create-app-popover.js +66 -21
  27. package/dist/components/create-app-popover.js.map +1 -1
  28. package/dist/components/workspace-app-card.d.ts +6 -0
  29. package/dist/components/workspace-app-card.d.ts.map +1 -0
  30. package/dist/components/workspace-app-card.js +12 -0
  31. package/dist/components/workspace-app-card.js.map +1 -0
  32. package/dist/db/schema.js +2 -2
  33. package/dist/db/schema.js.map +1 -1
  34. package/dist/lib/workspace-apps.d.ts +15 -0
  35. package/dist/lib/workspace-apps.d.ts.map +1 -0
  36. package/dist/lib/workspace-apps.js +9 -0
  37. package/dist/lib/workspace-apps.js.map +1 -0
  38. package/dist/routes/pages/apps.$appId.d.ts.map +1 -1
  39. package/dist/routes/pages/apps.$appId.js +1 -5
  40. package/dist/routes/pages/apps.$appId.js.map +1 -1
  41. package/dist/routes/pages/apps.d.ts.map +1 -1
  42. package/dist/routes/pages/apps.js +3 -20
  43. package/dist/routes/pages/apps.js.map +1 -1
  44. package/dist/routes/pages/overview.d.ts.map +1 -1
  45. package/dist/routes/pages/overview.js +2 -20
  46. package/dist/routes/pages/overview.js.map +1 -1
  47. package/dist/routes/pages/workspace.d.ts.map +1 -1
  48. package/dist/routes/pages/workspace.js +17 -6
  49. package/dist/routes/pages/workspace.js.map +1 -1
  50. package/dist/server/lib/app-creation-store.d.ts +1 -0
  51. package/dist/server/lib/app-creation-store.d.ts.map +1 -1
  52. package/dist/server/lib/app-creation-store.js +36 -0
  53. package/dist/server/lib/app-creation-store.js.map +1 -1
  54. package/dist/server/lib/workspace-resources-store.d.ts +29 -1
  55. package/dist/server/lib/workspace-resources-store.d.ts.map +1 -1
  56. package/dist/server/lib/workspace-resources-store.js +46 -0
  57. package/dist/server/lib/workspace-resources-store.js.map +1 -1
  58. package/dist/server/plugins/agent-chat.d.ts.map +1 -1
  59. package/dist/server/plugins/agent-chat.js +1 -0
  60. package/dist/server/plugins/agent-chat.js.map +1 -1
  61. package/dist/server/plugins/integrations.d.ts.map +1 -1
  62. package/dist/server/plugins/integrations.js +2 -0
  63. package/dist/server/plugins/integrations.js.map +1 -1
  64. package/package.json +2 -2
  65. package/src/actions/create-workspace-resource.ts +4 -4
  66. package/src/actions/grant-workspace-resources-to-app.ts +16 -0
  67. package/src/actions/index.ts +4 -0
  68. package/src/actions/list-workspace-resource-options.ts +16 -0
  69. package/src/actions/list-workspace-resources.ts +2 -2
  70. package/src/actions/start-workspace-app-creation.ts +8 -1
  71. package/src/actions/view-screen.ts +4 -0
  72. package/src/components/app-keys-popover.tsx +3 -3
  73. package/src/components/create-app-popover.tsx +155 -22
  74. package/src/components/workspace-app-card.tsx +85 -0
  75. package/src/db/schema.ts +2 -2
  76. package/src/lib/workspace-apps.ts +21 -0
  77. package/src/routes/pages/apps.$appId.tsx +4 -17
  78. package/src/routes/pages/apps.tsx +6 -89
  79. package/src/routes/pages/overview.tsx +5 -84
  80. package/src/routes/pages/workspace.tsx +31 -5
  81. package/src/server/lib/app-creation-store.ts +52 -0
  82. package/src/server/lib/workspace-resources-store.ts +75 -1
  83. package/src/server/plugins/agent-chat.ts +1 -0
  84. package/src/server/plugins/integrations.ts +2 -0
@@ -54,7 +54,11 @@ function orgFilter<T extends { ownerEmail: any; orgId: any }>(table: T) {
54
54
 
55
55
  // ─── Workspace Resources CRUD ──────────────────────────────────
56
56
 
57
- export type WorkspaceResourceKind = "skill" | "instruction" | "agent";
57
+ export type WorkspaceResourceKind =
58
+ | "skill"
59
+ | "instruction"
60
+ | "agent"
61
+ | "knowledge";
58
62
  export type WorkspaceResourceScope = "all" | "selected";
59
63
 
60
64
  export interface WorkspaceResourceInput {
@@ -66,6 +70,16 @@ export interface WorkspaceResourceInput {
66
70
  scope: WorkspaceResourceScope;
67
71
  }
68
72
 
73
+ export interface WorkspaceResourceOption {
74
+ id: string;
75
+ kind: WorkspaceResourceKind;
76
+ name: string;
77
+ description: string | null;
78
+ path: string;
79
+ scope: WorkspaceResourceScope;
80
+ updatedAt: number;
81
+ }
82
+
69
83
  export async function listWorkspaceResources(filter?: { kind?: string }) {
70
84
  const db = getDb();
71
85
  const conditions = [orgFilter(schema.workspaceResources)];
@@ -79,6 +93,21 @@ export async function listWorkspaceResources(filter?: { kind?: string }) {
79
93
  .orderBy(desc(schema.workspaceResources.updatedAt));
80
94
  }
81
95
 
96
+ export async function listWorkspaceResourceOptions(filter?: {
97
+ kind?: string;
98
+ }): Promise<WorkspaceResourceOption[]> {
99
+ const resources = await listWorkspaceResources(filter);
100
+ return resources.map((resource) => ({
101
+ id: resource.id,
102
+ kind: resource.kind as WorkspaceResourceKind,
103
+ name: resource.name,
104
+ description: resource.description,
105
+ path: resource.path,
106
+ scope: resource.scope as WorkspaceResourceScope,
107
+ updatedAt: resource.updatedAt,
108
+ }));
109
+ }
110
+
82
111
  export async function getWorkspaceResource(
83
112
  resourceId: string,
84
113
  ctx: WorkspaceResourceCtx = requireWorkspaceResourceCtx(),
@@ -248,6 +277,13 @@ export async function createResourceGrant(resourceId: string, appId: string) {
248
277
  const resource = await getWorkspaceResource(resourceId, ctx);
249
278
  if (!resource) throw new Error("Workspace resource not found");
250
279
 
280
+ const activeExisting = (await listResourceGrants({ resourceId, appId })).find(
281
+ (grant) => grant.status === "active",
282
+ );
283
+ if (activeExisting) {
284
+ return activeExisting;
285
+ }
286
+
251
287
  const timestamp = now();
252
288
  const grantId = id();
253
289
  const actor = currentOwnerEmail();
@@ -274,6 +310,42 @@ export async function createResourceGrant(resourceId: string, appId: string) {
274
310
  return getResourceGrant(grantId);
275
311
  }
276
312
 
313
+ export async function grantWorkspaceResourcesToApp(input: {
314
+ appId: string;
315
+ resourceIds: string[];
316
+ }) {
317
+ const uniqueResourceIds = [...new Set(input.resourceIds.filter(Boolean))];
318
+ if (uniqueResourceIds.length === 0) {
319
+ return { appId: input.appId, granted: [], skipped: [] };
320
+ }
321
+
322
+ const granted: Array<{ id: string; resourceId: string; appId: string }> = [];
323
+ const skipped: Array<{ resourceId: string; reason: string }> = [];
324
+
325
+ for (const resourceId of uniqueResourceIds) {
326
+ const resource = await getWorkspaceResource(resourceId).catch(() => null);
327
+ if (!resource) {
328
+ skipped.push({ resourceId, reason: "not-found" });
329
+ continue;
330
+ }
331
+ if (resource.scope === "all") {
332
+ skipped.push({ resourceId, reason: "already-all-apps" });
333
+ continue;
334
+ }
335
+
336
+ const grant = await createResourceGrant(resourceId, input.appId);
337
+ if (grant) {
338
+ granted.push({
339
+ id: grant.id,
340
+ resourceId: grant.resourceId,
341
+ appId: grant.appId,
342
+ });
343
+ }
344
+ }
345
+
346
+ return { appId: input.appId, granted, skipped };
347
+ }
348
+
277
349
  export async function revokeResourceGrant(
278
350
  grantId: string,
279
351
  ctx: WorkspaceResourceCtx = requireWorkspaceResourceCtx(),
@@ -433,12 +505,14 @@ export async function listWorkspaceResourcesOverview() {
433
505
  const skills = resources.filter((r) => r.kind === "skill");
434
506
  const instructions = resources.filter((r) => r.kind === "instruction");
435
507
  const agents = resources.filter((r) => r.kind === "agent");
508
+ const knowledge = resources.filter((r) => r.kind === "knowledge");
436
509
  const activeGrants = grants.filter((g) => g.status === "active");
437
510
 
438
511
  return {
439
512
  skillCount: skills.length,
440
513
  instructionCount: instructions.length,
441
514
  agentCount: agents.length,
515
+ knowledgeCount: knowledge.length,
442
516
  totalResources: resources.length,
443
517
  activeGrantCount: activeGrants.length,
444
518
  };
@@ -29,6 +29,7 @@ Use the standard workspace primitives:
29
29
  - Use custom agent profiles in agents/*.md for local spawned work and remote-agents/*.json for remote A2A apps.
30
30
  - When answering whether workspace apps expose agent cards or A2A endpoints, call list-workspace-apps with includeAgentCards=true. If you have not requested that probe, absence of agent-card fields means unchecked, not unavailable.
31
31
  - When creating a new workspace app, create a separate app under apps/<app-id> with apps/<app-id>/package.json, mount it at /<app-id>, use relative /<app-id> links, never hardcode localhost or dev ports, use shadcn/ui with @tabler/icons-react rather than lucide-react, and ensure the React Router client entry preserves APP_BASE_PATH/VITE_APP_BASE_PATH via appBasePath(). There is no separate workspace app registry to edit.
32
+ - Treat first-party apps such as Mail, Calendar, Analytics, and Dispatch as existing hosted/connected neighbors available through links and A2A/default connected agents. Do not create wrapper apps, child apps, nested routes, or cloned template copies just to give a new app access to them; build only the genuinely new workflow and delegate cross-app work to those existing apps.
32
33
 
33
34
  When a user asks for something like a digest, reminder, routing rule, or saved behavior:
34
35
  - First decide whether it should be a resource, a recurring job, a destination, or a delegated task.
@@ -13,6 +13,7 @@ Default posture:
13
13
  - Heavily delegate domain work to specialized agents through A2A (call-agent) when another app owns the job. Apps you can delegate to include slides (decks/presentations), analytics (data/dashboards), content (docs/articles), videos (Remotion compositions), forms (form builder), clips (screen recordings), design (visual designs), and images (brand image libraries and generated raster imagery).
14
14
  - Use list-connected-agents to see what agents are available before assuming a request must be handled locally.
15
15
  - When asked whether workspace apps expose agent cards or A2A endpoints, call list-workspace-apps with includeAgentCards=true. Without that probe, missing agent-card fields mean unchecked, not unavailable.
16
+ - Treat first-party apps such as Mail, Calendar, Analytics, and Dispatch as existing hosted/connected neighbors available through links and A2A/default connected agents. Do not create wrapper apps, child apps, nested routes, or cloned template copies just to give a new app access to them; build only the genuinely new workflow and delegate cross-app work to those existing apps.
16
17
  - Keep durable memory and operating instructions in resources rather than ephemeral chat.
17
18
  - Reply in the originating thread unless the user explicitly asks you to send to a saved destination.
18
19
 
@@ -21,6 +22,7 @@ When a user asks for something:
21
22
  - After call-agent returns an answer, RELAY IT DIRECTLY to the user with at most a one-line preface — do not rephrase, summarize, or add commentary. The downstream agent already crafted the answer; your job is delivery, not editing. This minimizes round-trips and keeps the user-visible reply fast.
22
23
  - Exception: if the downstream agent reports a missing model/provider credential, do not name exact env vars, Vault keys, tokens, or secrets. Say the target app needs an LLM connection and recommend connecting Builder/managed LLM for that app; keep bring-your-own provider keys as a secondary option only if the user asks.
23
24
  - If the user asks to create, build, make, scaffold, or generate an "agent" from Dispatch chat or by tagging @agent-native in Slack, email, or Telegram, first classify the ask. If it is a simple Dispatch-native behavior like a reminder, digest, monitor, routing rule, saved instruction, or recurring workflow, create or update the recurring job/resource/destination in Dispatch. If it is a robust unique product or teammate that needs its own UI, data model, actions, integrations, or domain workflow, treat it as a new workspace app and call start-workspace-app-creation.
25
+ - If a new-app prompt asks for access to Mail, Calendar, Analytics, or similar first-party app data/agents, keep using the existing hosted/connected app and A2A path. Do not ask Builder to scaffold those apps as children of the new app unless the user explicitly asks for a customized fork/copy.
24
26
  - If the user explicitly asks for a new app or workspace app, call start-workspace-app-creation with their prompt. Do not satisfy a new-app request by adding a route, page, component, or file inside apps/starter or another existing app unless the user explicitly asks to modify that existing app. If the request is too vague to classify, ask one concise follow-up. If the action returns mode "builder", reply with the Builder branch URL; Builder is responsible for creating the separate workspace app under apps/<app-id>, mounting it at /<app-id>, ensuring apps/<app-id>/package.json exists so Dispatch discovers it, using relative /<app-id> links instead of hardcoded localhost/dev ports, and preserving APP_BASE_PATH/VITE_APP_BASE_PATH via appBasePath() in the React Router client entry. There is no separate workspace app registry to edit. If it returns mode "local-agent", tell the user it is ready for the local code agent and include the returned app path/prompt summary. If it returns mode "coming-soon" or "builder-unavailable", explain the missing Builder setup and ask them to connect/configure Builder.
25
27
  - For digests, reminders, or saved behavior, prefer recurring jobs, resources, or destinations over chat replies.
26
28
  - Keep responses concise and operational — messaging platforms have character limits.