@executor-js/sdk 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/README.md +125 -107
  2. package/dist/blob.d.ts +48 -0
  3. package/dist/blob.d.ts.map +1 -0
  4. package/dist/blob.test.d.ts +2 -0
  5. package/dist/blob.test.d.ts.map +1 -0
  6. package/dist/chunk-2WV7VSNL.js +4440 -0
  7. package/dist/chunk-2WV7VSNL.js.map +1 -0
  8. package/dist/client.d.ts +135 -0
  9. package/dist/client.d.ts.map +1 -0
  10. package/dist/client.js +87 -0
  11. package/dist/client.js.map +1 -0
  12. package/dist/client.test.d.ts +2 -0
  13. package/dist/client.test.d.ts.map +1 -0
  14. package/dist/config.d.ts +24 -0
  15. package/dist/config.d.ts.map +1 -0
  16. package/dist/connections.d.ts +107 -0
  17. package/dist/connections.d.ts.map +1 -0
  18. package/dist/connections.test.d.ts +2 -0
  19. package/dist/connections.test.d.ts.map +1 -0
  20. package/dist/core-schema.d.ts +372 -0
  21. package/dist/core-schema.d.ts.map +1 -0
  22. package/dist/core.js +296 -57
  23. package/dist/core.js.map +1 -1
  24. package/dist/elicitation.d.ts +18 -34
  25. package/dist/elicitation.d.ts.map +1 -1
  26. package/dist/error-handling.test.d.ts +2 -0
  27. package/dist/error-handling.test.d.ts.map +1 -0
  28. package/dist/errors.d.ts +95 -24
  29. package/dist/errors.d.ts.map +1 -1
  30. package/dist/executor.d.ts +107 -48
  31. package/dist/executor.d.ts.map +1 -1
  32. package/dist/executor.test.d.ts +2 -0
  33. package/dist/executor.test.d.ts.map +1 -0
  34. package/dist/ids.d.ts +6 -4
  35. package/dist/ids.d.ts.map +1 -1
  36. package/dist/index.d.ts +24 -16
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +80 -308
  39. package/dist/index.js.map +1 -1
  40. package/dist/oauth-discovery.d.ts +138 -0
  41. package/dist/oauth-discovery.d.ts.map +1 -0
  42. package/dist/oauth-discovery.test.d.ts +2 -0
  43. package/dist/oauth-discovery.test.d.ts.map +1 -0
  44. package/dist/oauth-helpers.d.ts +89 -0
  45. package/dist/oauth-helpers.d.ts.map +1 -0
  46. package/dist/oauth-helpers.test.d.ts +2 -0
  47. package/dist/oauth-helpers.test.d.ts.map +1 -0
  48. package/dist/oauth-popup-types.d.ts +14 -0
  49. package/dist/oauth-popup-types.d.ts.map +1 -0
  50. package/dist/oauth-service.d.ts +33 -0
  51. package/dist/oauth-service.d.ts.map +1 -0
  52. package/dist/oauth.d.ts +275 -0
  53. package/dist/oauth.d.ts.map +1 -0
  54. package/dist/plugin.d.ts +318 -28
  55. package/dist/plugin.d.ts.map +1 -1
  56. package/dist/policies.d.ts +56 -64
  57. package/dist/policies.d.ts.map +1 -1
  58. package/dist/policies.test.d.ts +2 -0
  59. package/dist/policies.test.d.ts.map +1 -0
  60. package/dist/promise-executor.d.ts +26 -128
  61. package/dist/promise-executor.d.ts.map +1 -1
  62. package/dist/promise.d.ts +12 -6
  63. package/dist/promise.d.ts.map +1 -1
  64. package/dist/promise.test.d.ts +2 -0
  65. package/dist/promise.test.d.ts.map +1 -0
  66. package/dist/schema-types.d.ts +6 -5
  67. package/dist/schema-types.d.ts.map +1 -1
  68. package/dist/scope.d.ts +5 -15
  69. package/dist/scope.d.ts.map +1 -1
  70. package/dist/scoped-adapter.d.ts +13 -0
  71. package/dist/scoped-adapter.d.ts.map +1 -0
  72. package/dist/scoped-adapter.test.d.ts +2 -0
  73. package/dist/scoped-adapter.test.d.ts.map +1 -0
  74. package/dist/secret-backed-value.d.ts +27 -0
  75. package/dist/secret-backed-value.d.ts.map +1 -0
  76. package/dist/secrets.d.ts +52 -106
  77. package/dist/secrets.d.ts.map +1 -1
  78. package/dist/testing.d.ts +5 -3
  79. package/dist/testing.d.ts.map +1 -1
  80. package/dist/types.d.ts +84 -0
  81. package/dist/types.d.ts.map +1 -0
  82. package/package.json +28 -4
  83. package/dist/chunk-D7CT3UMO.js +0 -1386
  84. package/dist/chunk-D7CT3UMO.js.map +0 -1
  85. package/dist/in-memory/policy-engine.d.ts +0 -10
  86. package/dist/in-memory/policy-engine.d.ts.map +0 -1
  87. package/dist/in-memory/secret-store.d.ts +0 -16
  88. package/dist/in-memory/secret-store.d.ts.map +0 -1
  89. package/dist/in-memory/tool-registry.d.ts +0 -35
  90. package/dist/in-memory/tool-registry.d.ts.map +0 -1
  91. package/dist/index.test.d.ts +0 -2
  92. package/dist/index.test.d.ts.map +0 -1
  93. package/dist/plugin-kv.d.ts +0 -48
  94. package/dist/plugin-kv.d.ts.map +0 -1
  95. package/dist/plugins/in-memory-tools.d.ts +0 -42
  96. package/dist/plugins/in-memory-tools.d.ts.map +0 -1
  97. package/dist/runtime-tools.d.ts +0 -41
  98. package/dist/runtime-tools.d.ts.map +0 -1
  99. package/dist/sources.d.ts +0 -130
  100. package/dist/sources.d.ts.map +0 -1
  101. package/dist/tools.d.ts +0 -219
  102. package/dist/tools.d.ts.map +0 -1
@@ -0,0 +1,135 @@
1
+ import { createElement, type ComponentType, type ReactNode } from "react";
2
+ import type { HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
3
+ import * as AtomHttpApi from "effect/unstable/reactivity/AtomHttpApi";
4
+ export { Schema } from "effect";
5
+ export { HttpApi, HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
6
+ export * as AsyncResult from "effect/unstable/reactivity/AsyncResult";
7
+ export * as Atom from "effect/unstable/reactivity/Atom";
8
+ export * as AtomHttpApi from "effect/unstable/reactivity/AtomHttpApi";
9
+ export { useAtomValue, useAtomSet, useAtomMount, useAtomRefresh, } from "@effect/atom-react";
10
+ export interface PageDecl {
11
+ /** Path relative to the plugin's mount point, e.g. `/`, `/edit/$id`. */
12
+ readonly path: string;
13
+ readonly component: ComponentType;
14
+ /** Optional sidebar nav metadata — the host renders these alongside its
15
+ * own nav links. Omit to register a page without a nav entry. */
16
+ readonly nav?: {
17
+ readonly label: string;
18
+ readonly section?: string;
19
+ };
20
+ }
21
+ export interface WidgetProps {
22
+ readonly scopeId?: string;
23
+ }
24
+ export interface WidgetDecl {
25
+ readonly id: string;
26
+ readonly component: ComponentType<WidgetProps>;
27
+ readonly size?: "half" | "full";
28
+ }
29
+ /**
30
+ * Open record of host-defined slot components a plugin can fill. Slot
31
+ * names are part of the host UI contract — plugins opt in by registering
32
+ * a component for the slot they care about. Adding a slot is a host-side
33
+ * change; plugin authors don't define new slots.
34
+ */
35
+ export type SlotComponent = ComponentType<Record<string, unknown>>;
36
+ export interface SourcePreset {
37
+ /** Unique id (e.g. "stripe", "github-graphql"). */
38
+ readonly id: string;
39
+ readonly name: string;
40
+ readonly summary: string;
41
+ /** URL passed as `initialUrl` to the add form. Omit for presets that
42
+ * don't use a URL (e.g. stdio MCP presets). */
43
+ readonly url?: string;
44
+ /** Optional icon URL (favicon, logo). */
45
+ readonly icon?: string;
46
+ /** Shown in the top-level grid on the sources page when true. */
47
+ readonly featured?: boolean;
48
+ }
49
+ export interface SourcePlugin {
50
+ /** Unique key matching the SDK plugin id (e.g. "openapi"). */
51
+ readonly key: string;
52
+ readonly label: string;
53
+ readonly add: ComponentType<{
54
+ readonly onComplete: () => void;
55
+ readonly onCancel: () => void;
56
+ readonly initialUrl?: string;
57
+ readonly initialPreset?: string;
58
+ readonly initialNamespace?: string;
59
+ }>;
60
+ readonly edit: ComponentType<{
61
+ readonly sourceId: string;
62
+ readonly onSave: () => void;
63
+ }>;
64
+ readonly summary?: ComponentType<{
65
+ readonly sourceId: string;
66
+ readonly variant?: "badge" | "panel";
67
+ readonly onAction?: () => void;
68
+ }>;
69
+ readonly signIn?: ComponentType<{
70
+ readonly sourceId: string;
71
+ }>;
72
+ readonly presets?: readonly SourcePreset[];
73
+ /** Trigger early download of the plugin's lazy component chunks (add/edit/etc.).
74
+ * Call from the host on intent (hover/focus) so the chunks land before the
75
+ * user navigates into the add page. Idempotent. */
76
+ readonly preload?: () => void;
77
+ }
78
+ export interface SecretProviderPlugin {
79
+ /** Unique key matching the SDK plugin id (e.g. "onepassword"). */
80
+ readonly key: string;
81
+ readonly label: string;
82
+ readonly settings: ComponentType<Record<string, never>>;
83
+ }
84
+ export interface ClientPluginSpec<TId extends string = string> {
85
+ readonly id: TId;
86
+ readonly pages?: readonly PageDecl[];
87
+ readonly widgets?: readonly WidgetDecl[];
88
+ readonly slots?: Record<string, SlotComponent>;
89
+ /** Source plugin contribution — populated by plugins that expose
90
+ * `kind` rows in the core `source` table (openapi, mcp, graphql,
91
+ * google-discovery). The host's sources page derives its provider
92
+ * list from the union of every loaded plugin's `sourcePlugin`. */
93
+ readonly sourcePlugin?: SourcePlugin;
94
+ /** Secret provider plugin contribution — populated by plugins that
95
+ * also ship a `secretProviders` (or related) server-side capability
96
+ * AND want to expose a settings card on the host's secrets page. */
97
+ readonly secretProviderPlugin?: SecretProviderPlugin;
98
+ }
99
+ /**
100
+ * Identity factory — returns the spec unchanged but pins the inferred
101
+ * literal type of `id` so the host can index plugin records by id with
102
+ * full autocomplete. Plugins export this as their package's default
103
+ * (or named) export from `./client`.
104
+ */
105
+ export declare const defineClientPlugin: <const TId extends string>(spec: ClientPluginSpec<TId>) => ClientPluginSpec<TId>;
106
+ export interface CreatePluginAtomClientOptions {
107
+ /** Override the base URL. Defaults to `/api` (host strips this prefix
108
+ * when forwarding to the Effect handler) — same convention as the
109
+ * core `ExecutorApiClient`. */
110
+ readonly baseUrl?: string;
111
+ }
112
+ /**
113
+ * Build a typed reactive client for a plugin's HttpApiGroup.
114
+ *
115
+ * const FooClient = createPluginAtomClient(FooApi)
116
+ * export const fooThings = FooClient.query("foo", "listThings", { ... })
117
+ * export const fooSync = FooClient.mutation("foo", "syncThing")
118
+ *
119
+ * Each plugin gets a private service Tag (`Plugin_<id>Client`) keyed by
120
+ * the group's `identifier`, so multiple plugins coexist in the same
121
+ * React tree without colliding.
122
+ */
123
+ export declare const createPluginAtomClient: <G extends HttpApiGroup.HttpApiGroup<string, HttpApiEndpoint.Any, boolean>>(group: G, options?: CreatePluginAtomClientOptions) => AtomHttpApi.AtomHttpApiClient<`Plugin_${G["identifier"]}Client`, `Plugin_${string}Client`, G>;
124
+ export interface ExecutorPluginsProviderProps {
125
+ readonly plugins: readonly ClientPluginSpec[];
126
+ readonly children: ReactNode;
127
+ }
128
+ export declare function ExecutorPluginsProvider(props: ExecutorPluginsProviderProps): ReturnType<typeof createElement>;
129
+ /** Full list of loaded `ClientPluginSpec` values. */
130
+ export declare const useClientPlugins: () => readonly ClientPluginSpec[];
131
+ /** Source plugins extracted from `clientPlugins[].sourcePlugin`. */
132
+ export declare const useSourcePlugins: () => readonly SourcePlugin[];
133
+ /** Secret-provider plugins extracted from `clientPlugins[].secretProviderPlugin`. */
134
+ export declare const useSecretProviderPlugins: () => readonly SecretProviderPlugin[];
135
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAWA,OAAO,EAEL,aAAa,EAIb,KAAK,aAAa,EAClB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE7E,OAAO,KAAK,WAAW,MAAM,wCAAwC,CAAC;AAOtE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEjF,OAAO,KAAK,WAAW,MAAM,wCAAwC,CAAC;AACtE,OAAO,KAAK,IAAI,MAAM,iCAAiC,CAAC;AACxD,OAAO,KAAK,WAAW,MAAM,wCAAwC,CAAC;AAEtE,OAAO,EACL,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,cAAc,GACf,MAAM,oBAAoB,CAAC;AAW5B,MAAM,WAAW,QAAQ;IACvB,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,MAA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createElement,
5
+ useContext,
6
+ useEffect,
7
+ useMemo
8
+ } from "react";
9
+ import { HttpApi } from "effect/unstable/httpapi";
10
+ import { FetchHttpClient } from "effect/unstable/http";
11
+ import * as AtomHttpApi from "effect/unstable/reactivity/AtomHttpApi";
12
+ import { Schema } from "effect";
13
+ import { HttpApi as HttpApi2, HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
14
+ import * as AsyncResult from "effect/unstable/reactivity/AsyncResult";
15
+ import * as Atom from "effect/unstable/reactivity/Atom";
16
+ import * as AtomHttpApi2 from "effect/unstable/reactivity/AtomHttpApi";
17
+ import {
18
+ useAtomValue,
19
+ useAtomSet,
20
+ useAtomMount,
21
+ useAtomRefresh
22
+ } from "@effect/atom-react";
23
+ var defineClientPlugin = (spec) => spec;
24
+ var createPluginAtomClient = (group, options = {}) => {
25
+ const { baseUrl = "/api" } = options;
26
+ const pluginId = group.identifier;
27
+ const bundle = HttpApi.make(`plugin-${pluginId}`).add(group);
28
+ return AtomHttpApi.Service()(
29
+ `Plugin_${pluginId}Client`,
30
+ {
31
+ api: bundle,
32
+ httpClient: FetchHttpClient.layer,
33
+ baseUrl
34
+ }
35
+ );
36
+ };
37
+ var ExecutorPluginsContext = createContext(null);
38
+ ExecutorPluginsContext.displayName = "ExecutorPluginsContext";
39
+ function ExecutorPluginsProvider(props) {
40
+ const { plugins, children } = props;
41
+ const value = useMemo(
42
+ () => ({
43
+ plugins,
44
+ sourcePlugins: plugins.flatMap((p) => p.sourcePlugin ? [p.sourcePlugin] : []),
45
+ secretProviderPlugins: plugins.flatMap(
46
+ (p) => p.secretProviderPlugin ? [p.secretProviderPlugin] : []
47
+ )
48
+ }),
49
+ [plugins]
50
+ );
51
+ useEffect(() => {
52
+ for (const sp of value.sourcePlugins) sp.preload?.();
53
+ }, [value.sourcePlugins]);
54
+ return createElement(ExecutorPluginsContext.Provider, { value }, children);
55
+ }
56
+ var usePluginsCtx = (hookName) => {
57
+ const ctx = useContext(ExecutorPluginsContext);
58
+ if (!ctx) {
59
+ throw new Error(
60
+ `${hookName} must be called inside an <ExecutorPluginsProvider>.`
61
+ );
62
+ }
63
+ return ctx;
64
+ };
65
+ var useClientPlugins = () => usePluginsCtx("useClientPlugins").plugins;
66
+ var useSourcePlugins = () => usePluginsCtx("useSourcePlugins").sourcePlugins;
67
+ var useSecretProviderPlugins = () => usePluginsCtx("useSecretProviderPlugins").secretProviderPlugins;
68
+ export {
69
+ AsyncResult,
70
+ Atom,
71
+ AtomHttpApi2 as AtomHttpApi,
72
+ ExecutorPluginsProvider,
73
+ HttpApi2 as HttpApi,
74
+ HttpApiEndpoint,
75
+ HttpApiGroup,
76
+ Schema,
77
+ createPluginAtomClient,
78
+ defineClientPlugin,
79
+ useAtomMount,
80
+ useAtomRefresh,
81
+ useAtomSet,
82
+ useAtomValue,
83
+ useClientPlugins,
84
+ useSecretProviderPlugins,
85
+ useSourcePlugins
86
+ };
87
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client.ts"],"sourcesContent":["// ---------------------------------------------------------------------------\n// @executor-js/sdk/client — frontend half of the plugin SDK.\n//\n// Plugins import from this entry to register pages/widgets and consume\n// their own typed reactive client. Server bundles must NOT import this\n// module — it pulls in React + @effect/atom-react. Plugin packages should\n// keep React/atom imports inside `./client.tsx` and Effect/Node imports\n// inside `./server.ts`; shared schema definitions go in `./shared.ts` and\n// can be imported from both halves.\n// ---------------------------------------------------------------------------\n\nimport {\n createContext,\n createElement,\n useContext,\n useEffect,\n useMemo,\n type ComponentType,\n type ReactNode,\n} from \"react\";\nimport { HttpApi } from \"effect/unstable/httpapi\";\nimport type { HttpApiEndpoint, HttpApiGroup } from \"effect/unstable/httpapi\";\nimport { FetchHttpClient } from \"effect/unstable/http\";\nimport * as AtomHttpApi from \"effect/unstable/reactivity/AtomHttpApi\";\n\n// ---------------------------------------------------------------------------\n// Re-exports — the curated set of primitives a plugin author needs to\n// build a typed reactive UI without reaching into `effect/*` directly.\n// ---------------------------------------------------------------------------\n\nexport { Schema } from \"effect\";\nexport { HttpApi, HttpApiEndpoint, HttpApiGroup } from \"effect/unstable/httpapi\";\n\nexport * as AsyncResult from \"effect/unstable/reactivity/AsyncResult\";\nexport * as Atom from \"effect/unstable/reactivity/Atom\";\nexport * as AtomHttpApi from \"effect/unstable/reactivity/AtomHttpApi\";\n\nexport {\n useAtomValue,\n useAtomSet,\n useAtomMount,\n useAtomRefresh,\n} from \"@effect/atom-react\";\n\n// ---------------------------------------------------------------------------\n// defineClientPlugin — declarative spec for the frontend half of a plugin.\n//\n// Mirror of `definePlugin` on the server, but everything here is React /\n// browser-only. The host treats the value as data: collects routes,\n// widgets, and slot components from every loaded plugin and mounts them\n// alongside the host's own UI.\n// ---------------------------------------------------------------------------\n\nexport interface PageDecl {\n /** Path relative to the plugin's mount point, e.g. `/`, `/edit/$id`. */\n readonly path: string;\n readonly component: ComponentType;\n /** Optional sidebar nav metadata — the host renders these alongside its\n * own nav links. Omit to register a page without a nav entry. */\n readonly nav?: {\n readonly label: string;\n readonly section?: string;\n };\n}\n\nexport interface WidgetProps {\n readonly scopeId?: string;\n}\n\nexport interface WidgetDecl {\n readonly id: string;\n readonly component: ComponentType<WidgetProps>;\n readonly size?: \"half\" | \"full\";\n}\n\n/**\n * Open record of host-defined slot components a plugin can fill. Slot\n * names are part of the host UI contract — plugins opt in by registering\n * a component for the slot they care about. Adding a slot is a host-side\n * change; plugin authors don't define new slots.\n */\nexport type SlotComponent = ComponentType<Record<string, unknown>>;\n\n// ---------------------------------------------------------------------------\n// SourcePlugin / SourcePreset — UI contract for plugins that expose\n// \"sources\" (OpenAPI specs, MCP servers, GraphQL endpoints, etc.). The\n// host owns the source list / detail chrome; the plugin owns the\n// add-flow, edit form, and (optional) summary + sign-in buttons.\n//\n// Lives here, not in `@executor-js/react`, so it's part of the plugin\n// contract: a plugin's `./client` entry assembles its `sourcePlugin`\n// alongside `pages`/`widgets`, and the host derives the union list\n// from `virtual:executor/plugins-client`.\n// ---------------------------------------------------------------------------\n\nexport interface SourcePreset {\n /** Unique id (e.g. \"stripe\", \"github-graphql\"). */\n readonly id: string;\n readonly name: string;\n readonly summary: string;\n /** URL passed as `initialUrl` to the add form. Omit for presets that\n * don't use a URL (e.g. stdio MCP presets). */\n readonly url?: string;\n /** Optional icon URL (favicon, logo). */\n readonly icon?: string;\n /** Shown in the top-level grid on the sources page when true. */\n readonly featured?: boolean;\n}\n\nexport interface SourcePlugin {\n /** Unique key matching the SDK plugin id (e.g. \"openapi\"). */\n readonly key: string;\n readonly label: string;\n readonly add: ComponentType<{\n readonly onComplete: () => void;\n readonly onCancel: () => void;\n readonly initialUrl?: string;\n readonly initialPreset?: string;\n readonly initialNamespace?: string;\n }>;\n readonly edit: ComponentType<{\n readonly sourceId: string;\n readonly onSave: () => void;\n }>;\n readonly summary?: ComponentType<{\n readonly sourceId: string;\n readonly variant?: \"badge\" | \"panel\";\n readonly onAction?: () => void;\n }>;\n readonly signIn?: ComponentType<{\n readonly sourceId: string;\n }>;\n readonly presets?: readonly SourcePreset[];\n /** Trigger early download of the plugin's lazy component chunks (add/edit/etc.).\n * Call from the host on intent (hover/focus) so the chunks land before the\n * user navigates into the add page. Idempotent. */\n readonly preload?: () => void;\n}\n\n// ---------------------------------------------------------------------------\n// SecretProviderPlugin — UI contract for plugins that contribute secret\n// providers (1Password, WorkOS Vault, etc.). The host owns the secrets\n// page chrome; the plugin owns the settings card rendered inside.\n// ---------------------------------------------------------------------------\n\nexport interface SecretProviderPlugin {\n /** Unique key matching the SDK plugin id (e.g. \"onepassword\"). */\n readonly key: string;\n readonly label: string;\n readonly settings: ComponentType<Record<string, never>>;\n}\n\nexport interface ClientPluginSpec<TId extends string = string> {\n readonly id: TId;\n readonly pages?: readonly PageDecl[];\n readonly widgets?: readonly WidgetDecl[];\n readonly slots?: Record<string, SlotComponent>;\n /** Source plugin contribution — populated by plugins that expose\n * `kind` rows in the core `source` table (openapi, mcp, graphql,\n * google-discovery). The host's sources page derives its provider\n * list from the union of every loaded plugin's `sourcePlugin`. */\n readonly sourcePlugin?: SourcePlugin;\n /** Secret provider plugin contribution — populated by plugins that\n * also ship a `secretProviders` (or related) server-side capability\n * AND want to expose a settings card on the host's secrets page. */\n readonly secretProviderPlugin?: SecretProviderPlugin;\n}\n\n/**\n * Identity factory — returns the spec unchanged but pins the inferred\n * literal type of `id` so the host can index plugin records by id with\n * full autocomplete. Plugins export this as their package's default\n * (or named) export from `./client`.\n */\nexport const defineClientPlugin = <const TId extends string>(\n spec: ClientPluginSpec<TId>,\n): ClientPluginSpec<TId> => spec;\n\n// ---------------------------------------------------------------------------\n// createPluginAtomClient — typed reactive HTTP client for one plugin.\n//\n// Wraps the plugin's `HttpApiGroup` in a per-plugin `HttpApi`, then\n// hands back an `AtomHttpApi.Service` keyed to that bundle. The\n// resulting service exposes `.query(\"group\", \"endpoint\", opts)` and\n// `.mutation(\"group\", \"endpoint\")` factories — same shape as the host's\n// existing `ExecutorApiClient` (see packages/react/src/api/client.tsx).\n// Per-endpoint payload/response/error types flow through from the\n// imported group, so plugin client code typechecks without codegen.\n//\n// The plugin id (used for the Service Tag and the synthetic API id) is\n// read from `group.identifier` — the same string the plugin passed to\n// `HttpApiGroup.make(\"foo\")`. No second-source duplication.\n// ---------------------------------------------------------------------------\n\nexport interface CreatePluginAtomClientOptions {\n /** Override the base URL. Defaults to `/api` (host strips this prefix\n * when forwarding to the Effect handler) — same convention as the\n * core `ExecutorApiClient`. */\n readonly baseUrl?: string;\n}\n\n/**\n * Build a typed reactive client for a plugin's HttpApiGroup.\n *\n * const FooClient = createPluginAtomClient(FooApi)\n * export const fooThings = FooClient.query(\"foo\", \"listThings\", { ... })\n * export const fooSync = FooClient.mutation(\"foo\", \"syncThing\")\n *\n * Each plugin gets a private service Tag (`Plugin_<id>Client`) keyed by\n * the group's `identifier`, so multiple plugins coexist in the same\n * React tree without colliding.\n */\nexport const createPluginAtomClient = <\n G extends HttpApiGroup.HttpApiGroup<string, HttpApiEndpoint.Any, boolean>,\n>(\n group: G,\n options: CreatePluginAtomClientOptions = {},\n) => {\n const { baseUrl = \"/api\" } = options;\n const pluginId = group.identifier;\n const bundle = HttpApi.make(`plugin-${pluginId}`).add(group);\n return AtomHttpApi.Service<`Plugin_${G[\"identifier\"]}Client`>()(\n `Plugin_${pluginId}Client`,\n {\n api: bundle,\n httpClient: FetchHttpClient.layer,\n baseUrl,\n },\n );\n};\n\n// ---------------------------------------------------------------------------\n// ExecutorPluginsProvider + hooks — host-level distribution of the loaded\n// `ClientPluginSpec[]` via React context.\n//\n// The host wraps once at the root of its tree (typically reading from\n// `virtual:executor/plugins-client`); pages and shared components consume\n// via the focused hooks (`useSourcePlugins` etc.) so they don't import\n// from any host-app aggregator file. Pages stay portable across hosts —\n// the same component renders against whatever plugin set the surrounding\n// `<ExecutorPluginsProvider>` provides.\n//\n// Hooks throw if no provider is in scope so missing setup fails loudly;\n// matches the pattern of `useScope` / `useAuth` already in the codebase.\n// ---------------------------------------------------------------------------\n\ninterface ExecutorPluginsContextValue {\n readonly plugins: readonly ClientPluginSpec[];\n readonly sourcePlugins: readonly SourcePlugin[];\n readonly secretProviderPlugins: readonly SecretProviderPlugin[];\n}\n\nconst ExecutorPluginsContext = createContext<\n ExecutorPluginsContextValue | null\n>(null);\nExecutorPluginsContext.displayName = \"ExecutorPluginsContext\";\n\nexport interface ExecutorPluginsProviderProps {\n readonly plugins: readonly ClientPluginSpec[];\n readonly children: ReactNode;\n}\n\nexport function ExecutorPluginsProvider(\n props: ExecutorPluginsProviderProps,\n): ReturnType<typeof createElement> {\n const { plugins, children } = props;\n const value = useMemo<ExecutorPluginsContextValue>(\n () => ({\n plugins,\n sourcePlugins: plugins.flatMap((p) => (p.sourcePlugin ? [p.sourcePlugin] : [])),\n secretProviderPlugins: plugins.flatMap((p) =>\n p.secretProviderPlugin ? [p.secretProviderPlugin] : [],\n ),\n }),\n [plugins],\n );\n // Kick off lazy chunk downloads for every source plugin once the host\n // mounts, so navigating into an add/edit page doesn't suspend.\n useEffect(() => {\n for (const sp of value.sourcePlugins) sp.preload?.();\n }, [value.sourcePlugins]);\n return createElement(ExecutorPluginsContext.Provider, { value }, children);\n}\n\nconst usePluginsCtx = (hookName: string): ExecutorPluginsContextValue => {\n const ctx = useContext(ExecutorPluginsContext);\n if (!ctx) {\n throw new Error(\n `${hookName} must be called inside an <ExecutorPluginsProvider>.`,\n );\n }\n return ctx;\n};\n\n/** Full list of loaded `ClientPluginSpec` values. */\nexport const useClientPlugins = (): readonly ClientPluginSpec[] =>\n usePluginsCtx(\"useClientPlugins\").plugins;\n\n/** Source plugins extracted from `clientPlugins[].sourcePlugin`. */\nexport const useSourcePlugins = (): readonly SourcePlugin[] =>\n usePluginsCtx(\"useSourcePlugins\").sourcePlugins;\n\n/** Secret-provider plugins extracted from `clientPlugins[].secretProviderPlugin`. */\nexport const useSecretProviderPlugins = (): readonly SecretProviderPlugin[] =>\n usePluginsCtx(\"useSecretProviderPlugins\").secretProviderPlugins;\n"],"mappings":";AAWA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,eAAe;AAExB,SAAS,uBAAuB;AAChC,YAAY,iBAAiB;AAO7B,SAAS,cAAc;AACvB,SAAS,WAAAA,UAAS,iBAAiB,oBAAoB;AAEvD,YAAY,iBAAiB;AAC7B,YAAY,UAAU;AACtB,YAAYC,kBAAiB;AAE7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAoIA,IAAM,qBAAqB,CAChC,SAC0B;AAoCrB,IAAM,yBAAyB,CAGpC,OACA,UAAyC,CAAC,MACvC;AACH,QAAM,EAAE,UAAU,OAAO,IAAI;AAC7B,QAAM,WAAW,MAAM;AACvB,QAAM,SAAS,QAAQ,KAAK,UAAU,QAAQ,EAAE,EAAE,IAAI,KAAK;AAC3D,SAAmB,oBAA2C;AAAA,IAC5D,UAAU,QAAQ;AAAA,IAClB;AAAA,MACE,KAAK;AAAA,MACL,YAAY,gBAAgB;AAAA,MAC5B;AAAA,IACF;AAAA,EACF;AACF;AAuBA,IAAM,yBAAyB,cAE7B,IAAI;AACN,uBAAuB,cAAc;AAO9B,SAAS,wBACd,OACkC;AAClC,QAAM,EAAE,SAAS,SAAS,IAAI;AAC9B,QAAM,QAAQ;AAAA,IACZ,OAAO;AAAA,MACL;AAAA,MACA,eAAe,QAAQ,QAAQ,CAAC,MAAO,EAAE,eAAe,CAAC,EAAE,YAAY,IAAI,CAAC,CAAE;AAAA,MAC9E,uBAAuB,QAAQ;AAAA,QAAQ,CAAC,MACtC,EAAE,uBAAuB,CAAC,EAAE,oBAAoB,IAAI,CAAC;AAAA,MACvD;AAAA,IACF;AAAA,IACA,CAAC,OAAO;AAAA,EACV;AAGA,YAAU,MAAM;AACd,eAAW,MAAM,MAAM,cAAe,IAAG,UAAU;AAAA,EACrD,GAAG,CAAC,MAAM,aAAa,CAAC;AACxB,SAAO,cAAc,uBAAuB,UAAU,EAAE,MAAM,GAAG,QAAQ;AAC3E;AAEA,IAAM,gBAAgB,CAAC,aAAkD;AACvE,QAAM,MAAM,WAAW,sBAAsB;AAC7C,MAAI,CAAC,KAAK;AACR,UAAM,IAAI;AAAA,MACR,GAAG,QAAQ;AAAA,IACb;AAAA,EACF;AACA,SAAO;AACT;AAGO,IAAM,mBAAmB,MAC9B,cAAc,kBAAkB,EAAE;AAG7B,IAAM,mBAAmB,MAC9B,cAAc,kBAAkB,EAAE;AAG7B,IAAM,2BAA2B,MACtC,cAAc,0BAA0B,EAAE;","names":["HttpApi","AtomHttpApi"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=client.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.test.d.ts","sourceRoot":"","sources":["../src/client.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ import type { AnyPlugin } from "./plugin";
2
+ export type ExecutorDialect = "pg" | "sqlite" | "mysql";
3
+ export type ExecutorPluginsFactory<TDeps extends object = object, TPlugins extends readonly AnyPlugin[] = readonly AnyPlugin[]> = (deps?: TDeps) => TPlugins;
4
+ export interface ExecutorCliConfig<TDeps extends object = object, TPlugins extends readonly AnyPlugin[] = readonly AnyPlugin[]> {
5
+ readonly dialect: ExecutorDialect;
6
+ readonly plugins: ExecutorPluginsFactory<TDeps, TPlugins>;
7
+ }
8
+ /**
9
+ * Declare an executor config. The CLI imports this file via jiti and
10
+ * reads `plugins` + `dialect` to generate the drizzle schema; the host
11
+ * runtime imports the same file to instantiate plugins. Plugin runtime
12
+ * credentials passed to the factory may be stubs from the CLI — only
13
+ * `plugin.schema` is read there.
14
+ *
15
+ * The `const TPlugins` modifier preserves the tuple-literal inference
16
+ * from the factory's return so per-plugin extension typing flows through
17
+ * (`ReturnType<typeof config.plugins>` keeps `[OpenApi, Mcp, ...]`).
18
+ *
19
+ * `TDeps` is inferred from the factory's parameter — apps annotate
20
+ * the destructure (e.g., `({ configFile }: { configFile?: ConfigFileSink })`)
21
+ * directly. No global module augmentation needed.
22
+ */
23
+ export declare const defineExecutorConfig: <TDeps extends object, const TPlugins extends readonly AnyPlugin[]>(config: ExecutorCliConfig<TDeps, TPlugins>) => ExecutorCliConfig<TDeps, TPlugins>;
24
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,QAAQ,GAAG,OAAO,CAAC;AAExD,MAAM,MAAM,sBAAsB,CAChC,KAAK,SAAS,MAAM,GAAG,MAAM,EAC7B,QAAQ,SAAS,SAAS,SAAS,EAAE,GAAG,SAAS,SAAS,EAAE,IAC1D,CAAC,IAAI,CAAC,EAAE,KAAK,KAAK,QAAQ,CAAC;AAE/B,MAAM,WAAW,iBAAiB,CAChC,KAAK,SAAS,MAAM,GAAG,MAAM,EAC7B,QAAQ,SAAS,SAAS,SAAS,EAAE,GAAG,SAAS,SAAS,EAAE;IAE5D,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;CAC3D;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,GAC/B,KAAK,SAAS,MAAM,EACpB,KAAK,CAAC,QAAQ,SAAS,SAAS,SAAS,EAAE,EAE3C,QAAQ,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,KACzC,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAW,CAAC"}
@@ -0,0 +1,107 @@
1
+ import { Effect, Schema } from "effect";
2
+ import { ConnectionId, ScopeId } from "./ids";
3
+ /** Minimal JSON-object carrier for the plugin-owned `providerState`
4
+ * blob. The SDK never inspects its shape; plugins encode/decode their
5
+ * own structure. Never sensitive — that's what the secret rows are
6
+ * for. */
7
+ export declare const ConnectionProviderState: Schema.$Record<Schema.String, Schema.Unknown>;
8
+ export type ConnectionProviderState = typeof ConnectionProviderState.Type;
9
+ declare const ConnectionRef_base: Schema.Class<ConnectionRef, Schema.Struct<{
10
+ readonly id: Schema.brand<Schema.String, "ConnectionId">;
11
+ readonly scopeId: Schema.brand<Schema.String, "ScopeId">;
12
+ readonly provider: Schema.String;
13
+ readonly identityLabel: Schema.NullOr<Schema.String>;
14
+ readonly accessTokenSecretId: Schema.brand<Schema.String, "SecretId">;
15
+ readonly refreshTokenSecretId: Schema.NullOr<Schema.brand<Schema.String, "SecretId">>;
16
+ /** Epoch ms when the access token expires; null if not declared. */
17
+ readonly expiresAt: Schema.NullOr<Schema.Number>;
18
+ /** OAuth-style scope string as returned by the token endpoint. Named
19
+ * `oauthScope` to avoid collision with the executor scope id. */
20
+ readonly oauthScope: Schema.NullOr<Schema.String>;
21
+ readonly providerState: Schema.NullOr<Schema.$Record<Schema.String, Schema.Unknown>>;
22
+ readonly createdAt: Schema.Date;
23
+ readonly updatedAt: Schema.Date;
24
+ }>, {}>;
25
+ export declare class ConnectionRef extends ConnectionRef_base {
26
+ }
27
+ declare const TokenMaterial_base: Schema.Class<TokenMaterial, Schema.Struct<{
28
+ /** Target secret id. Plugins typically derive this from the source id
29
+ * + a stable suffix (e.g. `${sourceId}.access_token`). */
30
+ readonly secretId: Schema.brand<Schema.String, "SecretId">;
31
+ /** Display name stamped on the secret row. Only visible to code — the
32
+ * Connections UI hides connection-owned secrets. */
33
+ readonly name: Schema.String;
34
+ readonly value: Schema.String;
35
+ }>, {}>;
36
+ export declare class TokenMaterial extends TokenMaterial_base {
37
+ }
38
+ declare const CreateConnectionInput_base: Schema.Class<CreateConnectionInput, Schema.Struct<{
39
+ readonly id: Schema.brand<Schema.String, "ConnectionId">;
40
+ /** Executor scope id that will own this connection + its backing
41
+ * secrets. This is the sharing boundary: a user scope is personal,
42
+ * an org/workspace scope is shared with descendants. */
43
+ readonly scope: Schema.brand<Schema.String, "ScopeId">;
44
+ readonly provider: Schema.String;
45
+ readonly identityLabel: Schema.NullOr<Schema.String>;
46
+ readonly accessToken: typeof TokenMaterial;
47
+ readonly refreshToken: Schema.NullOr<typeof TokenMaterial>;
48
+ readonly expiresAt: Schema.NullOr<Schema.Number>;
49
+ /** OAuth-style scope string. Distinct from the executor scope above. */
50
+ readonly oauthScope: Schema.NullOr<Schema.String>;
51
+ readonly providerState: Schema.NullOr<Schema.$Record<Schema.String, Schema.Unknown>>;
52
+ }>, {}>;
53
+ export declare class CreateConnectionInput extends CreateConnectionInput_base {
54
+ }
55
+ declare const ConnectionRefreshError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
56
+ readonly _tag: "ConnectionRefreshError";
57
+ } & Readonly<A>;
58
+ export declare class ConnectionRefreshError extends ConnectionRefreshError_base<{
59
+ readonly connectionId: ConnectionId;
60
+ readonly message: string;
61
+ /**
62
+ * Set by providers when the refresh failed in a way that the stored
63
+ * refresh token cannot recover from (RFC 6749 §5.2 `invalid_grant`
64
+ * — the AS has revoked the grant, the user changed their password,
65
+ * the refresh token rotated out from under us, ...). The SDK
66
+ * translates this into a `ConnectionReauthRequiredError` so callers
67
+ * can prompt the user to sign in again instead of silently retrying.
68
+ */
69
+ readonly reauthRequired?: boolean;
70
+ readonly cause?: unknown;
71
+ }> {
72
+ }
73
+ export interface ConnectionRefreshInput {
74
+ readonly connectionId: ConnectionId;
75
+ readonly scopeId: ScopeId;
76
+ readonly identityLabel: string | null;
77
+ /** Resolved refresh token value, or null if the connection has none. */
78
+ readonly refreshToken: string | null;
79
+ /** Plugin-owned blob persisted at create / previous refresh. */
80
+ readonly providerState: ConnectionProviderState | null;
81
+ /** OAuth scope string from the last token issuance. */
82
+ readonly oauthScope: string | null;
83
+ }
84
+ export interface ConnectionRefreshResult {
85
+ readonly accessToken: string;
86
+ readonly refreshToken?: string | null;
87
+ readonly expiresAt?: number | null;
88
+ readonly oauthScope?: string | null;
89
+ readonly providerState?: ConnectionProviderState | null;
90
+ }
91
+ export interface ConnectionProvider {
92
+ readonly key: string;
93
+ readonly refresh?: (input: ConnectionRefreshInput) => Effect.Effect<ConnectionRefreshResult, ConnectionRefreshError>;
94
+ }
95
+ declare const UpdateConnectionTokensInput_base: Schema.Class<UpdateConnectionTokensInput, Schema.Struct<{
96
+ readonly id: Schema.brand<Schema.String, "ConnectionId">;
97
+ readonly accessToken: Schema.String;
98
+ readonly refreshToken: Schema.optional<Schema.NullOr<Schema.String>>;
99
+ readonly expiresAt: Schema.optional<Schema.NullOr<Schema.Number>>;
100
+ readonly oauthScope: Schema.optional<Schema.NullOr<Schema.String>>;
101
+ readonly providerState: Schema.optional<Schema.NullOr<Schema.$Record<Schema.String, Schema.Unknown>>>;
102
+ readonly identityLabel: Schema.optional<Schema.NullOr<Schema.String>>;
103
+ }>, {}>;
104
+ export declare class UpdateConnectionTokensInput extends UpdateConnectionTokensInput_base {
105
+ }
106
+ export {};
107
+ //# sourceMappingURL=connections.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../src/connections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,OAAO,EAAY,MAAM,OAAO,CAAC;AAWxD;;;WAGW;AACX,eAAO,MAAM,uBAAuB,+CAA+C,CAAC;AACpF,MAAM,MAAM,uBAAuB,GAAG,OAAO,uBAAuB,CAAC,IAAI,CAAC;;;;;;;;IAexE,oEAAoE;;IAEpE;sEACkE;;;;;;AAVpE,qBAAa,aAAc,SAAQ,kBAejC;CAAG;;IAeH;+DAC2D;;IAE3D;yDACqD;;;;AALvD,qBAAa,aAAc,SAAQ,kBAQjC;CAAG;;;IAMH;;6DAEyD;;;;;;;IAOzD,wEAAwE;;;;AAb1E,qBAAa,qBAAsB,SAAQ,0BAgBzC;CAAG;;;;AAQL,qBAAa,sBAAuB,SAAQ,4BAE1C;IACA,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;;;;;;OAOG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;CAAG;AASL,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,wEAAwE;IACxE,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,gEAAgE;IAChE,QAAQ,CAAC,aAAa,EAAE,uBAAuB,GAAG,IAAI,CAAC;IACvD,uDAAuD;IACvD,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAaD,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,aAAa,CAAC,EAAE,uBAAuB,GAAG,IAAI,CAAC;CACzD;AAcD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,CAAC,EAAE,CACjB,KAAK,EAAE,sBAAsB,KAC1B,MAAM,CAAC,MAAM,CAAC,uBAAuB,EAAE,sBAAsB,CAAC,CAAC;CACrE;;;;;;;;;;AASD,qBAAa,2BAA4B,SAAQ,gCAU/C;CAAG"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=connections.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connections.test.d.ts","sourceRoot":"","sources":["../src/connections.test.ts"],"names":[],"mappings":""}