@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.
Files changed (43) hide show
  1. package/dist/actions/delete-staged-dataset.d.ts +3 -1
  2. package/dist/actions/delete-staged-dataset.js +3 -26
  3. package/dist/actions/delete-staged-dataset.js.map +1 -1
  4. package/dist/actions/delete-workspace-resource.d.ts +13 -13
  5. package/dist/actions/list-staged-datasets.d.ts +1 -1
  6. package/dist/actions/list-staged-datasets.js +3 -28
  7. package/dist/actions/list-staged-datasets.js.map +1 -1
  8. package/dist/actions/provider-api-catalog.d.ts +6 -4
  9. package/dist/actions/provider-api-catalog.js +3 -17
  10. package/dist/actions/provider-api-catalog.js.map +1 -1
  11. package/dist/actions/provider-api-docs.d.ts +21 -2
  12. package/dist/actions/provider-api-docs.js +6 -51
  13. package/dist/actions/provider-api-docs.js.map +1 -1
  14. package/dist/actions/provider-api-register.d.ts +39 -15
  15. package/dist/actions/provider-api-register.js +4 -193
  16. package/dist/actions/provider-api-register.js.map +1 -1
  17. package/dist/actions/provider-api-request.d.ts +34 -2
  18. package/dist/actions/provider-api-request.js +6 -171
  19. package/dist/actions/provider-api-request.js.map +1 -1
  20. package/dist/actions/query-staged-dataset.d.ts +18 -1
  21. package/dist/actions/query-staged-dataset.d.ts.map +1 -1
  22. package/dist/actions/query-staged-dataset.js +3 -100
  23. package/dist/actions/query-staged-dataset.js.map +1 -1
  24. package/dist/actions/upsert-destination.d.ts +12 -12
  25. package/dist/components/layout/Layout.d.ts.map +1 -1
  26. package/dist/components/layout/Layout.js +26 -64
  27. package/dist/components/layout/Layout.js.map +1 -1
  28. package/package.json +4 -3
  29. package/src/actions/delete-staged-dataset.ts +3 -33
  30. package/src/actions/list-staged-datasets.ts +3 -30
  31. package/src/actions/provider-api-audit.spec.ts +2 -3
  32. package/src/actions/provider-api-catalog.ts +10 -23
  33. package/src/actions/provider-api-docs.ts +19 -68
  34. package/src/actions/provider-api-register.ts +5 -233
  35. package/src/actions/provider-api-request.ts +19 -232
  36. package/src/actions/query-staged-dataset.ts +3 -119
  37. package/src/components/layout/Layout.spec.tsx +7 -11
  38. package/src/components/layout/Layout.tsx +42 -145
  39. package/dist/actions/provider-api-audit.d.ts +0 -7
  40. package/dist/actions/provider-api-audit.d.ts.map +0 -1
  41. package/dist/actions/provider-api-audit.js +0 -74
  42. package/dist/actions/provider-api-audit.js.map +0 -1
  43. package/src/actions/provider-api-audit.ts +0 -88
@@ -1,4 +1,6 @@
1
- declare const _default: import("@agent-native/core").ActionDefinition<{
1
+ declare const _default: import("node_modules/@agent-native/core/dist/action.js").ActionDefinition<{
2
+ datasetId: string;
3
+ } | {
2
4
  datasetId: string;
3
5
  }, {
4
6
  deleted: boolean;
@@ -1,31 +1,8 @@
1
- import { defineAction } from "@agent-native/core";
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 defineAction({
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,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAC;AAC5F,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,eAAe,YAAY,CAAC;IAC1B,WAAW,EACT,2LAA2L;IAC7L,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,SAAS,EAAE,CAAC;aACT,MAAM,EAAE;aACR,GAAG,CAAC,CAAC,CAAC;aACN,QAAQ,CACP,0FAA0F,CAC3F;KACJ,CAAC;IACF,IAAI,EAAE,KAAK;IACX,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAClB,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;QACnC,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;QACzE,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC;YACxC,EAAE,EAAE,IAAI,CAAC,SAAS;YAClB,KAAK,EAAE,eAAe;YACtB,UAAU,EAAE,GAAG,CAAC,SAAS;SAC1B,CAAC,CAAC;QAEH,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CACb,WAAW,IAAI,CAAC,SAAS,mDAAmD,CAC7E,CAAC;QACJ,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;IACtD,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { defineAction } from \"@agent-native/core\";\nimport { deleteStagedDataset } from \"@agent-native/core/provider-api/staged-datasets-store\";\nimport { getCredentialContext } from \"@agent-native/core/server/request-context\";\nimport { z } from \"zod\";\n\nimport { DISPATCH_APP_ID } from \"../server/lib/provider-api.js\";\n\nexport default defineAction({\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 schema: z.object({\n datasetId: z\n .string()\n .min(1)\n .describe(\n \"Dataset id to delete (from list-staged-datasets or provider-api-request stageAs result).\",\n ),\n }),\n http: false,\n run: async (args) => {\n const ctx = getCredentialContext();\n if (!ctx) {\n throw new Error(\"No authenticated context for delete-staged-dataset.\");\n }\n\n const deleted = await deleteStagedDataset({\n id: args.datasetId,\n appId: DISPATCH_APP_ID,\n ownerEmail: ctx.userEmail,\n });\n\n if (!deleted) {\n throw new Error(\n `Dataset ${args.datasetId} not found (or belongs to a different owner/app).`,\n );\n }\n\n return { deleted: true, datasetId: args.datasetId };\n },\n});\n"]}
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,4 +1,4 @@
1
- declare const _default: import("@agent-native/core").ActionDefinition<Record<string, never>, {
1
+ declare const _default: import("node_modules/@agent-native/core/dist/action.js").ActionDefinition<Record<string, never>, {
2
2
  datasets: {
3
3
  id: string;
4
4
  name: string;
@@ -1,33 +1,8 @@
1
- import { defineAction } from "@agent-native/core";
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 defineAction({
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,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uDAAuD,CAAC;AAC3F,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,eAAe,YAAY,CAAC;IAC1B,WAAW,EACT,gQAAgQ;IAClQ,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACpB,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;IACvB,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,KAAK,IAAI,EAAE;QACd,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;QACnC,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;QACxE,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC;YACxC,KAAK,EAAE,eAAe;YACtB,UAAU,EAAE,GAAG,CAAC,SAAS;SAC1B,CAAC,CAAC;QAEH,OAAO;YACL,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC7B,EAAE,EAAE,CAAC,CAAC,EAAE;gBACR,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,QAAQ,EAAE,CAAC,CAAC,QAAQ;gBACpB,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,QAAQ,EAAE,CAAC,CAAC,QAAQ;gBACpB,SAAS,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE;aAC/C,CAAC,CAAC;YACH,KAAK,EAAE,QAAQ,CAAC,MAAM;SACvB,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { defineAction } from \"@agent-native/core\";\nimport { listStagedDatasets } from \"@agent-native/core/provider-api/staged-datasets-store\";\nimport { getCredentialContext } from \"@agent-native/core/server/request-context\";\nimport { z } from \"zod\";\n\nimport { DISPATCH_APP_ID } from \"../server/lib/provider-api.js\";\n\nexport default defineAction({\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 schema: z.object({}),\n http: { method: \"GET\" },\n readOnly: true,\n run: async () => {\n const ctx = getCredentialContext();\n if (!ctx) {\n throw new Error(\"No authenticated context for list-staged-datasets.\");\n }\n\n const datasets = await listStagedDatasets({\n appId: DISPATCH_APP_ID,\n ownerEmail: ctx.userEmail,\n });\n\n return {\n datasets: datasets.map((d) => ({\n id: d.id,\n name: d.name,\n rowCount: d.rowCount,\n columns: d.columns,\n byteSize: d.byteSize,\n updatedAt: new Date(d.updatedAt).toISOString(),\n })),\n total: datasets.length,\n };\n },\n});\n"]}
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("@agent-native/core").ActionDefinition<{
2
- provider?: string | undefined;
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("@agent-native/core").WorkspaceConnectionTemplateUse[];
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 { defineAction } from "@agent-native/core";
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 defineAction({
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
- schema: z.object({
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,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,eAAe,YAAY,CAAC;IAC1B,WAAW,EACT,qbAAqb;IACvb,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,QAAQ,EAAE,CAAC;aACR,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CACP,kGAAkG,CACnG;KACJ,CAAC;IACF,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;IACvB,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC1B,MAAM,SAAS,GAAG,MAAM,sBAAsB,CAAC,QAAQ,CAAC,CAAC;QACzD,OAAO;YACL,SAAS;YACT,QAAQ,EACN,kfAAkf;SACrf,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { defineAction } from \"@agent-native/core\";\nimport { z } from \"zod\";\n\nimport { listProviderApiCatalog } from \"../server/lib/provider-api.js\";\n\nexport default defineAction({\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 schema: z.object({\n provider: z\n .string()\n .optional()\n .describe(\n \"Optional provider id to inspect (built-in or custom). Omit to list every available provider API.\",\n ),\n }),\n http: { method: \"GET\" },\n readOnly: true,\n run: async ({ provider }) => {\n const providers = await listProviderApiCatalog(provider);\n return {\n providers,\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 };\n },\n});\n"]}
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("@agent-native/core").ActionDefinition<{
2
- provider: string;
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 { defineAction } from "@agent-native/core";
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
- const BooleanFromQuerySchema = z.preprocess((value) => (typeof value === "string" ? value === "true" : value), z.boolean());
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.object({
19
- provider: z
20
- .string()
21
- .min(1)
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":"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","sourcesContent":["import { defineAction } from \"@agent-native/core\";\nimport { z } from \"zod\";\n\nimport { fetchProviderApiDocs } from \"../server/lib/provider-api.js\";\n\nconst BooleanFromQuerySchema = z.preprocess(\n (value) => (typeof value === \"string\" ? value === \"true\" : value),\n z.boolean(),\n);\nconst WebContentSearchSchema = z.object({\n query: z.union([z.string(), z.array(z.string())]).optional(),\n queries: z.array(z.string()).optional(),\n terms: z.array(z.string()).optional(),\n regex: z.string().optional(),\n regexFlags: z.string().optional(),\n source: z.enum([\"extracted\", \"raw\"]).optional(),\n maxMatches: z.coerce.number().int().min(1).max(500).optional(),\n contextChars: z.coerce.number().int().min(0).max(1_000).optional(),\n caseSensitive: BooleanFromQuerySchema.optional(),\n});\n\nexport default defineAction({\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: z.object({\n provider: 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 url: z\n .string()\n .url()\n .optional()\n .describe(\n \"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.\",\n ),\n maxBytes: z.coerce\n .number()\n .int()\n .min(1_000)\n .max(4 * 1024 * 1024)\n .optional()\n .describe(\"Maximum response bytes to read. Default 1MB, max 4MB.\"),\n maxChars: z.coerce\n .number()\n .int()\n .min(1)\n .max(200_000)\n .optional()\n .describe(\"Maximum extracted content characters to return.\"),\n responseMode: z\n .enum([\"auto\", \"raw\", \"text\", \"markdown\", \"links\", \"metadata\", \"matches\"])\n .optional()\n .describe(\n \"How to return fetched docs. Default auto extracts HTML to markdown; use matches with search for compact snippets.\",\n ),\n extract: z\n .enum([\"readability\", \"all-visible\", \"none\"])\n .optional()\n .describe(\"HTML extraction strategy. Default readability.\"),\n includeLinks: BooleanFromQuerySchema.optional().describe(\n \"Include compact links from extracted HTML. Default true.\",\n ),\n search: WebContentSearchSchema.optional().describe(\n \"Optional post-fetch search over extracted content by default. Supports query, queries, terms, regex, source, maxMatches, and contextChars.\",\n ),\n }),\n http: { method: \"GET\" },\n readOnly: true,\n run: async (args) => fetchProviderApiDocs(args),\n});\n"]}
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("@agent-native/core").ActionDefinition<{
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
- found: boolean;
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 { upsertCustomProvider, deleteCustomProvider, listCustomProviders, getCustomProvider, assertCanMutateCustomProviderScope, } from "@agent-native/core/provider-api";
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
- const AuthSchema = z.discriminatedUnion("type", [
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
- schema: z.object({
85
- operation: z
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