@agent-native/dispatch 0.15.2 → 0.15.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.
- package/dist/actions/delete-staged-dataset.d.ts +3 -1
- package/dist/actions/delete-staged-dataset.js +3 -26
- package/dist/actions/delete-staged-dataset.js.map +1 -1
- package/dist/actions/delete-workspace-resource.d.ts +13 -13
- package/dist/actions/list-staged-datasets.d.ts +1 -1
- package/dist/actions/list-staged-datasets.js +3 -28
- package/dist/actions/list-staged-datasets.js.map +1 -1
- package/dist/actions/provider-api-catalog.d.ts +6 -4
- package/dist/actions/provider-api-catalog.js +3 -17
- package/dist/actions/provider-api-catalog.js.map +1 -1
- package/dist/actions/provider-api-docs.d.ts +21 -2
- package/dist/actions/provider-api-docs.js +6 -51
- package/dist/actions/provider-api-docs.js.map +1 -1
- package/dist/actions/provider-api-register.d.ts +39 -15
- package/dist/actions/provider-api-register.js +4 -193
- package/dist/actions/provider-api-register.js.map +1 -1
- package/dist/actions/provider-api-request.d.ts +34 -2
- package/dist/actions/provider-api-request.js +6 -171
- package/dist/actions/provider-api-request.js.map +1 -1
- package/dist/actions/query-staged-dataset.d.ts +18 -1
- package/dist/actions/query-staged-dataset.d.ts.map +1 -1
- package/dist/actions/query-staged-dataset.js +3 -100
- package/dist/actions/query-staged-dataset.js.map +1 -1
- package/dist/actions/upsert-destination.d.ts +12 -12
- package/dist/components/layout/Layout.d.ts.map +1 -1
- package/dist/components/layout/Layout.js +26 -64
- package/dist/components/layout/Layout.js.map +1 -1
- package/package.json +4 -3
- package/src/actions/delete-staged-dataset.ts +3 -33
- package/src/actions/list-staged-datasets.ts +3 -30
- package/src/actions/provider-api-audit.spec.ts +2 -3
- package/src/actions/provider-api-catalog.ts +10 -23
- package/src/actions/provider-api-docs.ts +19 -68
- package/src/actions/provider-api-register.ts +5 -233
- package/src/actions/provider-api-request.ts +19 -232
- package/src/actions/query-staged-dataset.ts +3 -119
- package/src/components/layout/Layout.spec.tsx +7 -11
- package/src/components/layout/Layout.tsx +42 -145
- package/dist/actions/provider-api-audit.d.ts +0 -7
- package/dist/actions/provider-api-audit.d.ts.map +0 -1
- package/dist/actions/provider-api-audit.js +0 -74
- package/dist/actions/provider-api-audit.js.map +0 -1
- package/src/actions/provider-api-audit.ts +0 -88
|
@@ -1,31 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { deleteStagedDataset } from "@agent-native/core/provider-api/staged-datasets-store";
|
|
3
|
-
import { getCredentialContext } from "@agent-native/core/server/request-context";
|
|
4
|
-
import { z } from "zod";
|
|
1
|
+
import { createDeleteStagedDatasetAction } from "@agent-native/core/provider-api/actions/staged-datasets";
|
|
5
2
|
import { DISPATCH_APP_ID } from "../server/lib/provider-api.js";
|
|
6
|
-
export default
|
|
3
|
+
export default createDeleteStagedDatasetAction({
|
|
4
|
+
appId: DISPATCH_APP_ID,
|
|
7
5
|
description: "Delete a staged dataset by id, freeing its scratch storage. Use after analysis is complete or before re-staging under the same name. Only the owner who staged the dataset can delete it.",
|
|
8
|
-
schema: z.object({
|
|
9
|
-
datasetId: z
|
|
10
|
-
.string()
|
|
11
|
-
.min(1)
|
|
12
|
-
.describe("Dataset id to delete (from list-staged-datasets or provider-api-request stageAs result)."),
|
|
13
|
-
}),
|
|
14
6
|
http: false,
|
|
15
|
-
run: async (args) => {
|
|
16
|
-
const ctx = getCredentialContext();
|
|
17
|
-
if (!ctx) {
|
|
18
|
-
throw new Error("No authenticated context for delete-staged-dataset.");
|
|
19
|
-
}
|
|
20
|
-
const deleted = await deleteStagedDataset({
|
|
21
|
-
id: args.datasetId,
|
|
22
|
-
appId: DISPATCH_APP_ID,
|
|
23
|
-
ownerEmail: ctx.userEmail,
|
|
24
|
-
});
|
|
25
|
-
if (!deleted) {
|
|
26
|
-
throw new Error(`Dataset ${args.datasetId} not found (or belongs to a different owner/app).`);
|
|
27
|
-
}
|
|
28
|
-
return { deleted: true, datasetId: args.datasetId };
|
|
29
|
-
},
|
|
30
7
|
});
|
|
31
8
|
//# sourceMappingURL=delete-staged-dataset.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-staged-dataset.js","sourceRoot":"","sources":["../../src/actions/delete-staged-dataset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"delete-staged-dataset.js","sourceRoot":"","sources":["../../src/actions/delete-staged-dataset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,yDAAyD,CAAC;AAE1G,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,eAAe,+BAA+B,CAAC;IAC7C,KAAK,EAAE,eAAe;IACtB,WAAW,EACT,2LAA2L;IAC7L,IAAI,EAAE,KAAK;CACZ,CAAC,CAAC","sourcesContent":["import { createDeleteStagedDatasetAction } from \"@agent-native/core/provider-api/actions/staged-datasets\";\n\nimport { DISPATCH_APP_ID } from \"../server/lib/provider-api.js\";\n\nexport default createDeleteStagedDatasetAction({\n appId: DISPATCH_APP_ID,\n description:\n \"Delete a staged dataset by id, freeing its scratch storage. Use after analysis is complete or before re-staging under the same name. Only the owner who staged the dataset can delete it.\",\n http: false,\n});\n"]}
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
declare const _default: import("@agent-native/core").ActionDefinition<{
|
|
2
2
|
id: string;
|
|
3
3
|
}, {
|
|
4
|
-
id: string;
|
|
5
|
-
ownerEmail: string;
|
|
6
|
-
orgId: string | null;
|
|
7
|
-
kind: string;
|
|
8
|
-
name: string;
|
|
9
|
-
description: string | null;
|
|
10
|
-
path: string;
|
|
11
|
-
content: string;
|
|
12
|
-
scope: string;
|
|
13
|
-
createdBy: string;
|
|
14
|
-
createdAt: number;
|
|
15
|
-
updatedAt: number;
|
|
16
|
-
} | {
|
|
17
4
|
id: string;
|
|
18
5
|
ownerEmail: string;
|
|
19
6
|
orgId: string | null;
|
|
@@ -30,6 +17,19 @@ declare const _default: import("@agent-native/core").ActionDefinition<{
|
|
|
30
17
|
reviewedAt: number | null;
|
|
31
18
|
createdAt: number;
|
|
32
19
|
updatedAt: number;
|
|
20
|
+
} | {
|
|
21
|
+
id: string;
|
|
22
|
+
ownerEmail: string;
|
|
23
|
+
orgId: string | null;
|
|
24
|
+
kind: string;
|
|
25
|
+
name: string;
|
|
26
|
+
description: string | null;
|
|
27
|
+
path: string;
|
|
28
|
+
content: string;
|
|
29
|
+
scope: string;
|
|
30
|
+
createdBy: string;
|
|
31
|
+
createdAt: number;
|
|
32
|
+
updatedAt: number;
|
|
33
33
|
}>;
|
|
34
34
|
export default _default;
|
|
35
35
|
//# sourceMappingURL=delete-workspace-resource.d.ts.map
|
|
@@ -1,33 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { listStagedDatasets } from "@agent-native/core/provider-api/staged-datasets-store";
|
|
3
|
-
import { getCredentialContext } from "@agent-native/core/server/request-context";
|
|
4
|
-
import { z } from "zod";
|
|
1
|
+
import { createListStagedDatasetsAction } from "@agent-native/core/provider-api/actions/staged-datasets";
|
|
5
2
|
import { DISPATCH_APP_ID } from "../server/lib/provider-api.js";
|
|
6
|
-
export default
|
|
3
|
+
export default createListStagedDatasetsAction({
|
|
4
|
+
appId: DISPATCH_APP_ID,
|
|
7
5
|
description: "List staged datasets stored by provider-api-request (stageAs) for the current user. Returns dataset ids, names, row counts, columns, and sizes. Use dataset ids with query-staged-dataset to aggregate, or with delete-staged-dataset to free scratch storage.",
|
|
8
|
-
schema: z.object({}),
|
|
9
6
|
http: { method: "GET" },
|
|
10
|
-
readOnly: true,
|
|
11
|
-
run: async () => {
|
|
12
|
-
const ctx = getCredentialContext();
|
|
13
|
-
if (!ctx) {
|
|
14
|
-
throw new Error("No authenticated context for list-staged-datasets.");
|
|
15
|
-
}
|
|
16
|
-
const datasets = await listStagedDatasets({
|
|
17
|
-
appId: DISPATCH_APP_ID,
|
|
18
|
-
ownerEmail: ctx.userEmail,
|
|
19
|
-
});
|
|
20
|
-
return {
|
|
21
|
-
datasets: datasets.map((d) => ({
|
|
22
|
-
id: d.id,
|
|
23
|
-
name: d.name,
|
|
24
|
-
rowCount: d.rowCount,
|
|
25
|
-
columns: d.columns,
|
|
26
|
-
byteSize: d.byteSize,
|
|
27
|
-
updatedAt: new Date(d.updatedAt).toISOString(),
|
|
28
|
-
})),
|
|
29
|
-
total: datasets.length,
|
|
30
|
-
};
|
|
31
|
-
},
|
|
32
7
|
});
|
|
33
8
|
//# sourceMappingURL=list-staged-datasets.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-staged-datasets.js","sourceRoot":"","sources":["../../src/actions/list-staged-datasets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"list-staged-datasets.js","sourceRoot":"","sources":["../../src/actions/list-staged-datasets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,yDAAyD,CAAC;AAEzG,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,eAAe,8BAA8B,CAAC;IAC5C,KAAK,EAAE,eAAe;IACtB,WAAW,EACT,gQAAgQ;IAClQ,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;CACxB,CAAC,CAAC","sourcesContent":["import { createListStagedDatasetsAction } from \"@agent-native/core/provider-api/actions/staged-datasets\";\n\nimport { DISPATCH_APP_ID } from \"../server/lib/provider-api.js\";\n\nexport default createListStagedDatasetsAction({\n appId: DISPATCH_APP_ID,\n description:\n \"List staged datasets stored by provider-api-request (stageAs) for the current user. Returns dataset ids, names, row counts, columns, and sizes. Use dataset ids with query-staged-dataset to aggregate, or with delete-staged-dataset to free scratch storage.\",\n http: { method: \"GET\" },\n});\n"]}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
declare const _default: import("
|
|
2
|
-
provider?:
|
|
1
|
+
declare const _default: import("node_modules/@agent-native/core/dist/action.js").ActionDefinition<{
|
|
2
|
+
provider?: unknown;
|
|
3
|
+
} | {
|
|
4
|
+
provider?: unknown;
|
|
3
5
|
}, {
|
|
4
6
|
providers: unknown[] | {
|
|
5
7
|
id: "amplitude" | "apollo" | "bigquery" | "clay" | "commonroom" | "dataforseo" | "figma" | "ga4" | "gcloud" | "github" | "gmail" | "gong" | "google_calendar" | "google_drive" | "google_slides" | "grafana" | "granola" | "hubspot" | "jira" | "mixpanel" | "notion" | "posthog" | "prometheus" | "pylon" | "sentry" | "slack" | "stripe" | "twitter";
|
|
6
8
|
label: string;
|
|
7
9
|
defaultBaseUrl: string;
|
|
8
|
-
baseUrlCredentialKey: string;
|
|
10
|
+
baseUrlCredentialKey: string | null;
|
|
9
11
|
auth: string;
|
|
10
12
|
credentialKeys: readonly string[];
|
|
11
13
|
docsUrls: readonly string[];
|
|
@@ -16,7 +18,7 @@ declare const _default: import("@agent-native/core").ActionDefinition<{
|
|
|
16
18
|
examples: readonly import("node_modules/@agent-native/core/dist/provider-api/index.js").ProviderApiExample[];
|
|
17
19
|
notes: readonly string[];
|
|
18
20
|
corpusRecipes: readonly import("node_modules/@agent-native/core/dist/provider-api/index.js").ProviderApiCorpusRecipe[];
|
|
19
|
-
templateUses: readonly import("
|
|
21
|
+
templateUses: readonly import("node_modules/@agent-native/core/dist/index.js").WorkspaceConnectionTemplateUse[];
|
|
20
22
|
}[];
|
|
21
23
|
guidance: string;
|
|
22
24
|
}>;
|
|
@@ -1,22 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { z } from "zod";
|
|
1
|
+
import { createProviderApiCatalogAction } from "@agent-native/core/provider-api/actions/provider-api";
|
|
3
2
|
import { listProviderApiCatalog } from "../server/lib/provider-api.js";
|
|
4
|
-
export default
|
|
3
|
+
export default createProviderApiCatalogAction({ listCatalog: listProviderApiCatalog }, {
|
|
5
4
|
description: "List raw HTTP API capabilities for shared workspace integrations, configured providers, and custom registered providers. Use before provider-api-request when grant/setup metadata is not enough and the provider's actual API must be inspected. Returns base URLs, auth style, credential key names, docs/spec URLs, placeholders, and examples; never returns secret values. Custom providers registered via provider-api-register are included.",
|
|
6
|
-
|
|
7
|
-
provider: z
|
|
8
|
-
.string()
|
|
9
|
-
.optional()
|
|
10
|
-
.describe("Optional provider id to inspect (built-in or custom). Omit to list every available provider API."),
|
|
11
|
-
}),
|
|
5
|
+
guidance: "Workspace integrations and grants are not capability limits. When a provider can answer a question through its HTTP API, inspect docs/spec URLs here and call provider-api-request with the exact provider API method/path/query/body instead of adding a rigid one-off action. For broad searches, joins, classification, or absence claims, stage or save the full bounded corpus and reduce it with query-staged-dataset or run-code. Custom providers registered via provider-api-register also appear here.",
|
|
12
6
|
http: { method: "GET" },
|
|
13
|
-
readOnly: true,
|
|
14
|
-
run: async ({ provider }) => {
|
|
15
|
-
const providers = await listProviderApiCatalog(provider);
|
|
16
|
-
return {
|
|
17
|
-
providers,
|
|
18
|
-
guidance: "Workspace integrations and grants are not capability limits. When a provider can answer a question through its HTTP API, inspect docs/spec URLs here and call provider-api-request with the exact provider API method/path/query/body instead of adding a rigid one-off action. For broad searches, joins, classification, or absence claims, stage or save the full bounded corpus and reduce it with query-staged-dataset or run-code. Custom providers registered via provider-api-register also appear here.",
|
|
19
|
-
};
|
|
20
|
-
},
|
|
21
7
|
});
|
|
22
8
|
//# sourceMappingURL=provider-api-catalog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-api-catalog.js","sourceRoot":"","sources":["../../src/actions/provider-api-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"provider-api-catalog.js","sourceRoot":"","sources":["../../src/actions/provider-api-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,sDAAsD,CAAC;AAEtG,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,eAAe,8BAA8B,CAC3C,EAAE,WAAW,EAAE,sBAAsB,EAAE,EACvC;IACE,WAAW,EACT,qbAAqb;IACvb,QAAQ,EACN,kfAAkf;IACpf,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;CACxB,CACF,CAAC","sourcesContent":["import { createProviderApiCatalogAction } from \"@agent-native/core/provider-api/actions/provider-api\";\n\nimport { listProviderApiCatalog } from \"../server/lib/provider-api.js\";\n\nexport default createProviderApiCatalogAction(\n { listCatalog: listProviderApiCatalog },\n {\n description:\n \"List raw HTTP API capabilities for shared workspace integrations, configured providers, and custom registered providers. Use before provider-api-request when grant/setup metadata is not enough and the provider's actual API must be inspected. Returns base URLs, auth style, credential key names, docs/spec URLs, placeholders, and examples; never returns secret values. Custom providers registered via provider-api-register are included.\",\n guidance:\n \"Workspace integrations and grants are not capability limits. When a provider can answer a question through its HTTP API, inspect docs/spec URLs here and call provider-api-request with the exact provider API method/path/query/body instead of adding a rigid one-off action. For broad searches, joins, classification, or absence claims, stage or save the full bounded corpus and reduce it with query-staged-dataset or run-code. Custom providers registered via provider-api-register also appear here.\",\n http: { method: \"GET\" },\n },\n);\n"]}
|
|
@@ -1,5 +1,24 @@
|
|
|
1
|
-
declare const _default: import("
|
|
2
|
-
provider:
|
|
1
|
+
declare const _default: import("node_modules/@agent-native/core/dist/action.js").ActionDefinition<{
|
|
2
|
+
provider: unknown;
|
|
3
|
+
url?: string | undefined;
|
|
4
|
+
maxBytes?: unknown;
|
|
5
|
+
maxChars?: unknown;
|
|
6
|
+
responseMode?: "auto" | "links" | "markdown" | "matches" | "metadata" | "raw" | "text" | undefined;
|
|
7
|
+
extract?: "all-visible" | "none" | "readability" | undefined;
|
|
8
|
+
includeLinks?: unknown;
|
|
9
|
+
search?: {
|
|
10
|
+
query?: string | string[] | undefined;
|
|
11
|
+
queries?: string[] | undefined;
|
|
12
|
+
terms?: string[] | undefined;
|
|
13
|
+
regex?: string | undefined;
|
|
14
|
+
regexFlags?: string | undefined;
|
|
15
|
+
source?: "extracted" | "raw" | undefined;
|
|
16
|
+
maxMatches?: unknown;
|
|
17
|
+
contextChars?: unknown;
|
|
18
|
+
caseSensitive?: unknown;
|
|
19
|
+
} | undefined;
|
|
20
|
+
} | {
|
|
21
|
+
provider: unknown;
|
|
3
22
|
url?: string | undefined;
|
|
4
23
|
maxBytes?: unknown;
|
|
5
24
|
maxChars?: unknown;
|
|
@@ -1,57 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createProviderApiDocsAction, createProviderApiDocsSchema, } from "@agent-native/core/provider-api/actions/provider-api";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { fetchProviderApiDocs } from "../server/lib/provider-api.js";
|
|
4
|
-
|
|
5
|
-
const WebContentSearchSchema = z.object({
|
|
6
|
-
query: z.union([z.string(), z.array(z.string())]).optional(),
|
|
7
|
-
queries: z.array(z.string()).optional(),
|
|
8
|
-
terms: z.array(z.string()).optional(),
|
|
9
|
-
regex: z.string().optional(),
|
|
10
|
-
regexFlags: z.string().optional(),
|
|
11
|
-
source: z.enum(["extracted", "raw"]).optional(),
|
|
12
|
-
maxMatches: z.coerce.number().int().min(1).max(500).optional(),
|
|
13
|
-
contextChars: z.coerce.number().int().min(0).max(1_000).optional(),
|
|
14
|
-
caseSensitive: BooleanFromQuerySchema.optional(),
|
|
15
|
-
});
|
|
16
|
-
export default defineAction({
|
|
4
|
+
export default createProviderApiDocsAction({ fetchDocs: fetchProviderApiDocs }, {
|
|
17
5
|
description: "Inspect provider API docs/spec metadata, or fetch ANY public API documentation page, OpenAPI spec, changelog, or web page. Registered docs/spec URLs from provider-api-catalog are curated starting points, but any public https/http URL is allowed. Use web-search to find documentation URLs first when uncertain, then fetch them here. SSRF guard still applies — private/internal addresses are blocked.",
|
|
18
|
-
schema: z
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.describe("Provider whose API docs/spec to inspect. Can be a built-in provider id or a custom provider id registered via provider-api-register."),
|
|
23
|
-
url: z
|
|
24
|
-
.string()
|
|
25
|
-
.url()
|
|
26
|
-
.optional()
|
|
27
|
-
.describe("Optional URL to fetch. Can be any public https/http URL — API documentation pages, OpenAPI specs, changelogs, README files, etc. Registered docs/spec URLs from provider-api-catalog are curated starting points."),
|
|
28
|
-
maxBytes: z.coerce
|
|
29
|
-
.number()
|
|
30
|
-
.int()
|
|
31
|
-
.min(1_000)
|
|
32
|
-
.max(4 * 1024 * 1024)
|
|
33
|
-
.optional()
|
|
34
|
-
.describe("Maximum response bytes to read. Default 1MB, max 4MB."),
|
|
35
|
-
maxChars: z.coerce
|
|
36
|
-
.number()
|
|
37
|
-
.int()
|
|
38
|
-
.min(1)
|
|
39
|
-
.max(200_000)
|
|
40
|
-
.optional()
|
|
41
|
-
.describe("Maximum extracted content characters to return."),
|
|
42
|
-
responseMode: z
|
|
43
|
-
.enum(["auto", "raw", "text", "markdown", "links", "metadata", "matches"])
|
|
44
|
-
.optional()
|
|
45
|
-
.describe("How to return fetched docs. Default auto extracts HTML to markdown; use matches with search for compact snippets."),
|
|
46
|
-
extract: z
|
|
47
|
-
.enum(["readability", "all-visible", "none"])
|
|
48
|
-
.optional()
|
|
49
|
-
.describe("HTML extraction strategy. Default readability."),
|
|
50
|
-
includeLinks: BooleanFromQuerySchema.optional().describe("Include compact links from extracted HTML. Default true."),
|
|
51
|
-
search: WebContentSearchSchema.optional().describe("Optional post-fetch search over extracted content by default. Supports query, queries, terms, regex, source, maxMatches, and contextChars."),
|
|
52
|
-
}),
|
|
6
|
+
schema: createProviderApiDocsSchema(z
|
|
7
|
+
.string()
|
|
8
|
+
.min(1)
|
|
9
|
+
.describe("Provider whose API docs/spec to inspect. Can be a built-in provider id or a custom provider id registered via provider-api-register.")),
|
|
53
10
|
http: { method: "GET" },
|
|
54
|
-
readOnly: true,
|
|
55
|
-
run: async (args) => fetchProviderApiDocs(args),
|
|
56
11
|
});
|
|
57
12
|
//# sourceMappingURL=provider-api-docs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-api-docs.js","sourceRoot":"","sources":["../../src/actions/provider-api-docs.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"provider-api-docs.js","sourceRoot":"","sources":["../../src/actions/provider-api-docs.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,GAC5B,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE,eAAe,2BAA2B,CACxC,EAAE,SAAS,EAAE,oBAAoB,EAAE,EACnC;IACE,WAAW,EACT,gZAAgZ;IAClZ,MAAM,EAAE,2BAA2B,CACjC,CAAC;SACE,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CACP,sIAAsI,CACvI,CACJ;IACD,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;CACxB,CACF,CAAC","sourcesContent":["import {\n createProviderApiDocsAction,\n createProviderApiDocsSchema,\n} from \"@agent-native/core/provider-api/actions/provider-api\";\nimport { z } from \"zod\";\n\nimport { fetchProviderApiDocs } from \"../server/lib/provider-api.js\";\n\nexport default createProviderApiDocsAction(\n { fetchDocs: fetchProviderApiDocs },\n {\n description:\n \"Inspect provider API docs/spec metadata, or fetch ANY public API documentation page, OpenAPI spec, changelog, or web page. Registered docs/spec URLs from provider-api-catalog are curated starting points, but any public https/http URL is allowed. Use web-search to find documentation URLs first when uncertain, then fetch them here. SSRF guard still applies — private/internal addresses are blocked.\",\n schema: createProviderApiDocsSchema(\n z\n .string()\n .min(1)\n .describe(\n \"Provider whose API docs/spec to inspect. Can be a built-in provider id or a custom provider id registered via provider-api-register.\",\n ),\n ),\n http: { method: \"GET\" },\n },\n);\n"]}
|
|
@@ -1,4 +1,28 @@
|
|
|
1
|
-
declare const _default: import("
|
|
1
|
+
declare const _default: import("node_modules/@agent-native/core/dist").ActionDefinition<{
|
|
2
|
+
operation?: "delete" | "get" | "list" | "upsert" | undefined;
|
|
3
|
+
id?: string | undefined;
|
|
4
|
+
label?: string | undefined;
|
|
5
|
+
baseUrl?: string | undefined;
|
|
6
|
+
auth?: {
|
|
7
|
+
type: "none";
|
|
8
|
+
} | {
|
|
9
|
+
type: "bearer";
|
|
10
|
+
credentialKey: string;
|
|
11
|
+
} | {
|
|
12
|
+
type: "basic";
|
|
13
|
+
usernameKey: string;
|
|
14
|
+
passwordKey: string;
|
|
15
|
+
} | {
|
|
16
|
+
type: "api-key-header";
|
|
17
|
+
credentialKey: string;
|
|
18
|
+
headerName: string;
|
|
19
|
+
} | undefined;
|
|
20
|
+
docsUrls?: string[] | undefined;
|
|
21
|
+
allowedHostSuffixes?: string[] | undefined;
|
|
22
|
+
defaultHeaders?: Record<string, string> | undefined;
|
|
23
|
+
notes?: string | undefined;
|
|
24
|
+
scope?: "org" | "user" | undefined;
|
|
25
|
+
} | {
|
|
2
26
|
operation?: "delete" | "get" | "list" | "upsert" | undefined;
|
|
3
27
|
id?: string | undefined;
|
|
4
28
|
label?: string | undefined;
|
|
@@ -23,6 +47,9 @@ declare const _default: import("@agent-native/core").ActionDefinition<{
|
|
|
23
47
|
notes?: string | undefined;
|
|
24
48
|
scope?: "org" | "user" | undefined;
|
|
25
49
|
}, {
|
|
50
|
+
id?: undefined;
|
|
51
|
+
found?: undefined;
|
|
52
|
+
deleted?: undefined;
|
|
26
53
|
providers: {
|
|
27
54
|
id: string;
|
|
28
55
|
label: string;
|
|
@@ -33,37 +60,34 @@ declare const _default: import("@agent-native/core").ActionDefinition<{
|
|
|
33
60
|
updatedAt: number;
|
|
34
61
|
}[];
|
|
35
62
|
count: number;
|
|
36
|
-
found?: undefined;
|
|
37
63
|
provider?: undefined;
|
|
38
|
-
deleted?: undefined;
|
|
39
64
|
registered?: undefined;
|
|
40
|
-
id?: undefined;
|
|
41
65
|
label?: undefined;
|
|
42
66
|
message?: undefined;
|
|
43
67
|
} | {
|
|
44
|
-
providers?: undefined;
|
|
45
68
|
count?: undefined;
|
|
46
|
-
|
|
47
|
-
id: string;
|
|
48
|
-
provider?: undefined;
|
|
69
|
+
id?: undefined;
|
|
49
70
|
deleted?: undefined;
|
|
71
|
+
providers?: undefined;
|
|
72
|
+
found: boolean;
|
|
73
|
+
provider: import("node_modules/@agent-native/core/dist/provider-api").CustomProviderConfig;
|
|
50
74
|
registered?: undefined;
|
|
51
75
|
label?: undefined;
|
|
52
76
|
message?: undefined;
|
|
53
77
|
} | {
|
|
54
|
-
providers?: undefined;
|
|
55
78
|
count?: undefined;
|
|
56
|
-
found: boolean;
|
|
57
|
-
provider: import("@agent-native/core/provider-api").CustomProviderConfig;
|
|
58
79
|
deleted?: undefined;
|
|
80
|
+
providers?: undefined;
|
|
81
|
+
provider?: undefined;
|
|
82
|
+
found: boolean;
|
|
83
|
+
id: string;
|
|
59
84
|
registered?: undefined;
|
|
60
|
-
id?: undefined;
|
|
61
85
|
label?: undefined;
|
|
62
86
|
message?: undefined;
|
|
63
87
|
} | {
|
|
64
|
-
providers?: undefined;
|
|
65
88
|
count?: undefined;
|
|
66
89
|
found?: undefined;
|
|
90
|
+
providers?: undefined;
|
|
67
91
|
provider?: undefined;
|
|
68
92
|
deleted: boolean;
|
|
69
93
|
id: string;
|
|
@@ -71,11 +95,11 @@ declare const _default: import("@agent-native/core").ActionDefinition<{
|
|
|
71
95
|
label?: undefined;
|
|
72
96
|
message?: undefined;
|
|
73
97
|
} | {
|
|
74
|
-
providers?: undefined;
|
|
75
98
|
count?: undefined;
|
|
76
99
|
found?: undefined;
|
|
77
|
-
provider?: undefined;
|
|
78
100
|
deleted?: undefined;
|
|
101
|
+
providers?: undefined;
|
|
102
|
+
provider?: undefined;
|
|
79
103
|
registered: boolean;
|
|
80
104
|
id: string;
|
|
81
105
|
label: string;
|
|
@@ -1,27 +1,7 @@
|
|
|
1
|
-
import { defineAction } from "@agent-native/core";
|
|
2
1
|
import { getDbExec } from "@agent-native/core/db";
|
|
3
|
-
import {
|
|
2
|
+
import { createCustomProviderRegistrationAction } from "@agent-native/core/provider-api/actions/custom-provider-registration";
|
|
4
3
|
import { getCredentialContext } from "@agent-native/core/server";
|
|
5
|
-
import { z } from "zod";
|
|
6
|
-
/**
|
|
7
|
-
* Resolve the caller's role in a specific org, straight from `org_members`.
|
|
8
|
-
*
|
|
9
|
-
* `getCredentialContext()` (from `@agent-native/core/server`) only exposes
|
|
10
|
-
* `{ userEmail, orgId }` — no role. `getOrgContext()` (from
|
|
11
|
-
* `@agent-native/core/org`) resolves role but requires an `H3Event`, which
|
|
12
|
-
* `defineAction` handlers are not given. This mirrors the established
|
|
13
|
-
* no-event role-lookup idiom already used for org-admin gating inside
|
|
14
|
-
* agent-callable/background code (see `isCurrentUserOrgAdmin` in
|
|
15
|
-
* `packages/core/src/jobs/tools.ts`, `getViewerOrgRole` in
|
|
16
|
-
* `packages/dispatch/src/server/lib/usage-metrics-store.ts`, and the same
|
|
17
|
-
* query in `packages/core/src/mcp/actions/service-token-access.ts`) — same
|
|
18
|
-
* SQL, same fail-closed-to-null-on-error semantics. Returns null (never an
|
|
19
|
-
* org role) on any lookup error or when the caller has no membership row in
|
|
20
|
-
* this org.
|
|
21
|
-
*/
|
|
22
4
|
async function resolveCallerOrgRole(orgId, email) {
|
|
23
|
-
if (!orgId)
|
|
24
|
-
return null;
|
|
25
5
|
try {
|
|
26
6
|
const client = getDbExec();
|
|
27
7
|
const { rows } = await client.execute({
|
|
@@ -37,41 +17,7 @@ async function resolveCallerOrgRole(orgId, email) {
|
|
|
37
17
|
return null;
|
|
38
18
|
}
|
|
39
19
|
}
|
|
40
|
-
|
|
41
|
-
z.object({
|
|
42
|
-
type: z.literal("none"),
|
|
43
|
-
}),
|
|
44
|
-
z.object({
|
|
45
|
-
type: z.literal("bearer"),
|
|
46
|
-
credentialKey: z
|
|
47
|
-
.string()
|
|
48
|
-
.min(1)
|
|
49
|
-
.describe("Name of the credential key (e.g. MY_API_TOKEN). Must already be saved via app secrets — this action never accepts secret values."),
|
|
50
|
-
}),
|
|
51
|
-
z.object({
|
|
52
|
-
type: z.literal("basic"),
|
|
53
|
-
usernameKey: z
|
|
54
|
-
.string()
|
|
55
|
-
.min(1)
|
|
56
|
-
.describe("Credential key name for the username/login."),
|
|
57
|
-
passwordKey: z
|
|
58
|
-
.string()
|
|
59
|
-
.min(1)
|
|
60
|
-
.describe("Credential key name for the password/secret."),
|
|
61
|
-
}),
|
|
62
|
-
z.object({
|
|
63
|
-
type: z.literal("api-key-header"),
|
|
64
|
-
credentialKey: z
|
|
65
|
-
.string()
|
|
66
|
-
.min(1)
|
|
67
|
-
.describe("Credential key name for the API key value."),
|
|
68
|
-
headerName: z
|
|
69
|
-
.string()
|
|
70
|
-
.min(1)
|
|
71
|
-
.describe("HTTP header name to send the key in (e.g. X-Api-Key)."),
|
|
72
|
-
}),
|
|
73
|
-
]);
|
|
74
|
-
export default defineAction({
|
|
20
|
+
export default createCustomProviderRegistrationAction({
|
|
75
21
|
description: `Register or update a custom API provider so the agent can call it via provider-api-request and look up its docs via provider-api-docs.
|
|
76
22
|
|
|
77
23
|
IMPORTANT — credentials:
|
|
@@ -81,142 +27,7 @@ IMPORTANT — credentials:
|
|
|
81
27
|
google-service-account and oauth-bearer are NOT supported for custom providers.
|
|
82
28
|
|
|
83
29
|
After registration the provider appears in provider-api-catalog and can be used with provider-api-request.`,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
.enum(["upsert", "delete", "list", "get"])
|
|
87
|
-
.default("upsert")
|
|
88
|
-
.describe("Operation: upsert (create or update), delete (remove), list (all custom providers), get (single provider)."),
|
|
89
|
-
id: z
|
|
90
|
-
.string()
|
|
91
|
-
.min(1)
|
|
92
|
-
.max(64)
|
|
93
|
-
.optional()
|
|
94
|
-
.describe("Provider slug (e.g. my-api). Lowercase letters, digits, hyphens only. Required for upsert/delete/get."),
|
|
95
|
-
label: z
|
|
96
|
-
.string()
|
|
97
|
-
.min(1)
|
|
98
|
-
.max(200)
|
|
99
|
-
.optional()
|
|
100
|
-
.describe("Human-readable name (e.g. 'My Analytics API'). Required for upsert."),
|
|
101
|
-
baseUrl: z
|
|
102
|
-
.string()
|
|
103
|
-
.url()
|
|
104
|
-
.optional()
|
|
105
|
-
.describe("Base URL for the API (e.g. https://api.example.com/v1). Required for upsert. Must be a public https/http URL."),
|
|
106
|
-
auth: AuthSchema.optional().describe("Auth configuration. Required for upsert. Use type 'none' for public APIs."),
|
|
107
|
-
docsUrls: z
|
|
108
|
-
.array(z.string().url())
|
|
109
|
-
.optional()
|
|
110
|
-
.describe("Optional list of documentation URLs for this provider."),
|
|
111
|
-
allowedHostSuffixes: z
|
|
112
|
-
.array(z.string())
|
|
113
|
-
.optional()
|
|
114
|
-
.describe("Optional list of additional host suffixes requests may target beyond the base URL origin (e.g. ['example.com'])."),
|
|
115
|
-
defaultHeaders: z
|
|
116
|
-
.record(z.string(), z.string())
|
|
117
|
-
.optional()
|
|
118
|
-
.describe("Optional headers to include on every request (e.g. { 'Accept': 'application/json' })."),
|
|
119
|
-
notes: z
|
|
120
|
-
.string()
|
|
121
|
-
.max(1000)
|
|
122
|
-
.optional()
|
|
123
|
-
.describe("Optional notes about this provider shown in the catalog."),
|
|
124
|
-
scope: z
|
|
125
|
-
.enum(["user", "org"])
|
|
126
|
-
.default("org")
|
|
127
|
-
.describe("Whether to store the provider for the current user only ('user') or for the whole workspace ('org')."),
|
|
128
|
-
}),
|
|
129
|
-
http: false,
|
|
130
|
-
run: async ({ operation, id, label, baseUrl, auth, docsUrls, allowedHostSuffixes, defaultHeaders, notes, scope, }) => {
|
|
131
|
-
const ctx = getCredentialContext();
|
|
132
|
-
if (!ctx) {
|
|
133
|
-
throw new Error("provider-api-register requires an authenticated request context.");
|
|
134
|
-
}
|
|
135
|
-
const scopeId = scope === "org" ? (ctx.orgId ?? ctx.userEmail) : ctx.userEmail;
|
|
136
|
-
// Only upsert/delete mutate state; list/get remain readable by any org
|
|
137
|
-
// member (scoping org-scoped reads is left as a follow-up — see plan
|
|
138
|
-
// 014). Resolve the caller's role in the *target* org (`scopeId`, which
|
|
139
|
-
// for scope === "org" is exactly `ctx.orgId`) and enforce owner/admin
|
|
140
|
-
// before allowing an org-scoped write. `assertCanMutateCustomProviderScope`
|
|
141
|
-
// is the single source of truth for this check and is also enforced a
|
|
142
|
-
// second time inside `upsertCustomProvider`/`deleteCustomProvider`
|
|
143
|
-
// themselves (defense in depth) — calling it here too gives a clear,
|
|
144
|
-
// early error before any other work happens.
|
|
145
|
-
//
|
|
146
|
-
// When the caller has no active org (`ctx.orgId` is null — a solo user,
|
|
147
|
-
// or an app that hasn't wired `resolveOrgId` at all), `scopeId` above
|
|
148
|
-
// already collapsed to `ctx.userEmail`: there is no shared org resource
|
|
149
|
-
// to protect, and no *other* caller can ever address that same scopeId
|
|
150
|
-
// (every other request's fallback is scoped to *its own* email). Treat
|
|
151
|
-
// that case like sole ownership of a personal bucket — consistent with
|
|
152
|
-
// `org/context.ts`'s auto-created personal org, which also assigns the
|
|
153
|
-
// user role "owner" — rather than hard-rejecting scope: "org" (the
|
|
154
|
-
// action's own default) for every solo user or org-less app.
|
|
155
|
-
let orgRole = null;
|
|
156
|
-
if ((operation === "upsert" || operation === "delete") && scope === "org") {
|
|
157
|
-
orgRole = ctx.orgId
|
|
158
|
-
? await resolveCallerOrgRole(ctx.orgId, ctx.userEmail)
|
|
159
|
-
: "owner";
|
|
160
|
-
assertCanMutateCustomProviderScope(scope, scopeId, orgRole);
|
|
161
|
-
}
|
|
162
|
-
if (operation === "list") {
|
|
163
|
-
const providers = await listCustomProviders(scope, scopeId);
|
|
164
|
-
return {
|
|
165
|
-
providers: providers.map((p) => ({
|
|
166
|
-
id: p.id,
|
|
167
|
-
label: p.label,
|
|
168
|
-
baseUrl: p.baseUrl,
|
|
169
|
-
authType: p.auth.type,
|
|
170
|
-
docsUrls: p.docsUrls,
|
|
171
|
-
notes: p.notes,
|
|
172
|
-
updatedAt: p.updatedAt,
|
|
173
|
-
})),
|
|
174
|
-
count: providers.length,
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
if (operation === "get") {
|
|
178
|
-
if (!id)
|
|
179
|
-
throw new Error("id is required for get operation.");
|
|
180
|
-
const provider = await getCustomProvider(scope, scopeId, id);
|
|
181
|
-
if (!provider) {
|
|
182
|
-
return { found: false, id };
|
|
183
|
-
}
|
|
184
|
-
return { found: true, provider };
|
|
185
|
-
}
|
|
186
|
-
if (operation === "delete") {
|
|
187
|
-
if (!id)
|
|
188
|
-
throw new Error("id is required for delete operation.");
|
|
189
|
-
const deleted = await deleteCustomProvider(scope, scopeId, id, orgRole);
|
|
190
|
-
return { deleted, id };
|
|
191
|
-
}
|
|
192
|
-
// upsert
|
|
193
|
-
if (!id)
|
|
194
|
-
throw new Error("id is required for upsert operation.");
|
|
195
|
-
if (!label)
|
|
196
|
-
throw new Error("label is required for upsert operation.");
|
|
197
|
-
if (!baseUrl)
|
|
198
|
-
throw new Error("baseUrl is required for upsert operation.");
|
|
199
|
-
if (!auth)
|
|
200
|
-
throw new Error("auth is required for upsert operation.");
|
|
201
|
-
await upsertCustomProvider({
|
|
202
|
-
scope,
|
|
203
|
-
scopeId,
|
|
204
|
-
id,
|
|
205
|
-
label,
|
|
206
|
-
baseUrl,
|
|
207
|
-
auth,
|
|
208
|
-
docsUrls,
|
|
209
|
-
allowedHostSuffixes,
|
|
210
|
-
defaultHeaders,
|
|
211
|
-
notes,
|
|
212
|
-
orgRole,
|
|
213
|
-
});
|
|
214
|
-
return {
|
|
215
|
-
registered: true,
|
|
216
|
-
id,
|
|
217
|
-
label,
|
|
218
|
-
message: `Custom provider "${id}" registered. Use provider-api-catalog to inspect it and provider-api-request to call it.`,
|
|
219
|
-
};
|
|
220
|
-
},
|
|
30
|
+
getContext: getCredentialContext,
|
|
31
|
+
resolveOrgRole: resolveCallerOrgRole,
|
|
221
32
|
});
|
|
222
33
|
//# sourceMappingURL=provider-api-register.js.map
|