@agent-native/dispatch 0.10.3 → 0.10.4

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 (38) hide show
  1. package/dist/actions/delete-staged-dataset.d.ts +8 -0
  2. package/dist/actions/delete-staged-dataset.d.ts.map +1 -0
  3. package/dist/actions/delete-staged-dataset.js +31 -0
  4. package/dist/actions/delete-staged-dataset.js.map +1 -0
  5. package/dist/actions/index.d.ts.map +1 -1
  6. package/dist/actions/index.js +6 -0
  7. package/dist/actions/index.js.map +1 -1
  8. package/dist/actions/list-staged-datasets.d.ts +13 -0
  9. package/dist/actions/list-staged-datasets.d.ts.map +1 -0
  10. package/dist/actions/list-staged-datasets.js +33 -0
  11. package/dist/actions/list-staged-datasets.js.map +1 -0
  12. package/dist/actions/provider-api-catalog.d.ts +1 -1
  13. package/dist/actions/provider-api-catalog.js +1 -1
  14. package/dist/actions/provider-api-catalog.js.map +1 -1
  15. package/dist/actions/provider-api-request.d.ts +14 -1
  16. package/dist/actions/provider-api-request.d.ts.map +1 -1
  17. package/dist/actions/provider-api-request.js +88 -5
  18. package/dist/actions/provider-api-request.js.map +1 -1
  19. package/dist/actions/query-staged-dataset.d.ts +28 -0
  20. package/dist/actions/query-staged-dataset.d.ts.map +1 -0
  21. package/dist/actions/query-staged-dataset.js +105 -0
  22. package/dist/actions/query-staged-dataset.js.map +1 -0
  23. package/dist/server/lib/provider-api.d.ts +2 -1
  24. package/dist/server/lib/provider-api.d.ts.map +1 -1
  25. package/dist/server/lib/provider-api.js +2 -1
  26. package/dist/server/lib/provider-api.js.map +1 -1
  27. package/dist/server/plugins/agent-chat.d.ts.map +1 -1
  28. package/dist/server/plugins/agent-chat.js +2 -0
  29. package/dist/server/plugins/agent-chat.js.map +1 -1
  30. package/package.json +1 -1
  31. package/src/actions/delete-staged-dataset.ts +39 -0
  32. package/src/actions/index.ts +6 -0
  33. package/src/actions/list-staged-datasets.ts +36 -0
  34. package/src/actions/provider-api-catalog.ts +1 -1
  35. package/src/actions/provider-api-request.ts +118 -5
  36. package/src/actions/query-staged-dataset.ts +125 -0
  37. package/src/server/lib/provider-api.ts +2 -1
  38. package/src/server/plugins/agent-chat.ts +2 -0
@@ -0,0 +1,125 @@
1
+ import { defineAction } from "@agent-native/core";
2
+ import { runAggregateQuery } from "@agent-native/core/provider-api/staged-datasets-aggregate";
3
+ import {
4
+ getStagedDatasetMeta,
5
+ getStagedDatasetRows,
6
+ } from "@agent-native/core/provider-api/staged-datasets-store";
7
+ import { getCredentialContext } from "@agent-native/core/server/request-context";
8
+ import { z } from "zod";
9
+ import { DISPATCH_APP_ID } from "../server/lib/provider-api.js";
10
+
11
+ const WhereSchema = z.object({
12
+ column: z.string().min(1),
13
+ op: z.enum([
14
+ "equals",
15
+ "not_equals",
16
+ "contains",
17
+ "not_contains",
18
+ "gt",
19
+ "gte",
20
+ "lt",
21
+ "lte",
22
+ "exists",
23
+ "not_exists",
24
+ ]),
25
+ value: z.unknown().optional(),
26
+ });
27
+
28
+ const AggregateFieldSchema = z.object({
29
+ column: z.string().min(1).describe("Column to aggregate."),
30
+ op: z
31
+ .enum(["sum", "avg", "count", "min", "max", "count_distinct"])
32
+ .describe("Aggregation function."),
33
+ as: z
34
+ .string()
35
+ .optional()
36
+ .describe("Output column name. Default: {op}_{column}."),
37
+ });
38
+
39
+ export default defineAction({
40
+ description:
41
+ "Run a filter/aggregate/project query over a staged dataset previously written by provider-api-request (stageAs). Use after staging provider records, messages, documents, issues, events, or search results to count, group, filter, or project rows without re-fetching provider APIs.",
42
+ schema: z.object({
43
+ datasetId: z
44
+ .string()
45
+ .min(1)
46
+ .describe(
47
+ "Dataset id from provider-api-request stageAs result, or from list-staged-datasets.",
48
+ ),
49
+ where: z
50
+ .array(WhereSchema)
51
+ .optional()
52
+ .describe(
53
+ "Row-level filters (AND). Ops: equals, not_equals, contains, not_contains, gt, gte, lt, lte, exists, not_exists.",
54
+ ),
55
+ groupBy: z
56
+ .array(z.string().min(1))
57
+ .optional()
58
+ .describe(
59
+ "Column(s) to group by. Omit for a single aggregate over all rows.",
60
+ ),
61
+ aggregate: z
62
+ .array(AggregateFieldSchema)
63
+ .optional()
64
+ .describe(
65
+ "Aggregation operations. When set, non-group columns are aggregated. Omit to return raw rows.",
66
+ ),
67
+ select: z
68
+ .array(z.string().min(1))
69
+ .optional()
70
+ .describe("Column projection when aggregate is empty."),
71
+ orderBy: z.string().optional().describe("Sort output by this column."),
72
+ orderDir: z
73
+ .enum(["asc", "desc"])
74
+ .optional()
75
+ .describe("Sort direction (default asc)."),
76
+ limit: z.coerce
77
+ .number()
78
+ .int()
79
+ .min(1)
80
+ .max(10_000)
81
+ .optional()
82
+ .describe("Maximum rows to return (default all, max 10000)."),
83
+ }),
84
+ http: false,
85
+ readOnly: true,
86
+ run: async (args) => {
87
+ const ctx = getCredentialContext();
88
+ if (!ctx) {
89
+ throw new Error("No authenticated context for query-staged-dataset.");
90
+ }
91
+
92
+ const meta = await getStagedDatasetMeta({
93
+ id: args.datasetId,
94
+ appId: DISPATCH_APP_ID,
95
+ ownerEmail: ctx.userEmail,
96
+ });
97
+ if (!meta) {
98
+ throw new Error(
99
+ `Dataset ${args.datasetId} not found (or belongs to a different owner/app).`,
100
+ );
101
+ }
102
+
103
+ const rows = await getStagedDatasetRows({
104
+ id: args.datasetId,
105
+ appId: DISPATCH_APP_ID,
106
+ ownerEmail: ctx.userEmail,
107
+ });
108
+
109
+ const result = runAggregateQuery(rows, {
110
+ where: args.where,
111
+ groupBy: args.groupBy,
112
+ aggregate: args.aggregate,
113
+ select: args.select,
114
+ orderBy: args.orderBy,
115
+ orderDir: args.orderDir,
116
+ limit: args.limit,
117
+ });
118
+
119
+ return {
120
+ dataset: { id: meta.id, name: meta.name, totalRows: meta.rowCount },
121
+ rowCount: result.length,
122
+ rows: result,
123
+ };
124
+ },
125
+ });
@@ -8,6 +8,7 @@ import {
8
8
  } from "@agent-native/core/provider-api";
9
9
  import { getCredentialContext } from "@agent-native/core/server";
10
10
 
11
+ export const DISPATCH_APP_ID = "dispatch";
11
12
  export const DISPATCH_PROVIDER_API_IDS = PROVIDER_API_IDS;
12
13
  export type DispatchProviderApiId = ProviderApiId;
13
14
  export type { ProviderApiMethod, ProviderApiRequestArgs };
@@ -23,7 +24,7 @@ function requireCtx(action: string) {
23
24
  }
24
25
 
25
26
  const runtime = createProviderApiRuntime({
26
- appId: "dispatch",
27
+ appId: DISPATCH_APP_ID,
27
28
  localCredentialSource: "dispatch_local",
28
29
  getCredentialContext: () => requireCtx("requests"),
29
30
  getCustomProviders: async () => {
@@ -15,6 +15,7 @@ export default createAgentChatPlugin({
15
15
  // a build-time-generated `.generated/actions-registry.ts` (the latter is a
16
16
  // template-only construct that the Vite plugin emits next to actions/).
17
17
  actions: dispatchActions,
18
+ codeExecution: { production: "sandboxed" },
18
19
  systemPrompt: `You are the central dispatch for this workspace.
19
20
 
20
21
  Default posture:
@@ -33,6 +34,7 @@ Use the standard workspace primitives:
33
34
  - If the starter template is used, treat it as scaffolding only: the finished app must be branded as the requested app with its own home screen/navigation/package metadata/manifest, and must not leave visible "Starter", "Blank app", or "New app" UI behind.
34
35
  - Treat first-party apps such as Mail, Calendar, Analytics, Brain, Assets, 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.
35
36
  - Integration grants are not provider capability limits. For ad hoc provider inspection, querying, reporting, or troubleshooting, call provider-api-catalog/provider-api-docs, then provider-api-request against the provider's real HTTP API. Use connectionId for a specific shared grant and accountId for a specific OAuth account. Never expose secret values or silently widen app access while doing this.
37
+ - For broad provider searches, joins, classification, corpus counts, or absence claims, fetch every relevant page or an explicitly bounded cohort, stage/save large responses with stageAs/saveToFile/fetchAllPages, and reduce them with query-staged-dataset or run-code. Report source, filters, row counts, pagination, truncation, failed pages, and uncovered gaps.
36
38
 
37
39
  When a user asks for something like a digest, reminder, routing rule, or saved behavior:
38
40
  - First decide whether it should be a resource, a recurring job, a destination, or a delegated task.