@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
package/dist/core.js CHANGED
@@ -1,111 +1,350 @@
1
1
  import {
2
+ ConnectionId,
3
+ ConnectionNotFoundError,
4
+ ConnectionProviderNotRegisteredError,
5
+ ConnectionProviderState,
6
+ ConnectionReauthRequiredError,
7
+ ConnectionRef,
8
+ ConnectionRefreshError,
9
+ ConnectionRefreshNotSupportedError,
10
+ CreateConnectionInput,
2
11
  ElicitationAction,
3
12
  ElicitationDeclinedError,
4
13
  ElicitationResponse,
5
14
  FormElicitation,
6
- Policy,
7
- PolicyAction,
8
- PolicyCheckInput,
9
- PolicyDeniedError,
10
- PolicyEngine,
15
+ NoHandlerError,
16
+ OAUTH2_DEFAULT_TIMEOUT_MS,
17
+ OAUTH2_PROVIDER_KEY,
18
+ OAUTH2_REFRESH_SKEW_MS,
19
+ OAUTH2_SESSION_TTL_MS,
20
+ OAuth2Error,
21
+ OAuthAuthorizationCodeStrategy,
22
+ OAuthAuthorizationServerMetadataSchema,
23
+ OAuthClientCredentialsStrategy,
24
+ OAuthClientInformationSchema,
25
+ OAuthCompleteError,
26
+ OAuthDiscoveryError,
27
+ OAuthDynamicDcrStrategy,
28
+ OAuthProbeError,
29
+ OAuthProtectedResourceMetadataSchema,
30
+ OAuthProviderState,
31
+ OAuthSessionNotFoundError,
32
+ OAuthStartError,
33
+ OAuthStrategy,
34
+ PluginNotLoadedError,
11
35
  PolicyId,
12
36
  Scope,
13
37
  ScopeId,
38
+ SecretBackedMap,
39
+ SecretBackedValue,
14
40
  SecretId,
15
41
  SecretNotFoundError,
42
+ SecretOwnedByConnectionError,
16
43
  SecretRef,
17
44
  SecretResolutionError,
18
- SecretStore,
19
45
  SetSecretInput,
20
- Source,
21
46
  SourceDetectionResult,
22
- SourceRegistry,
23
- ToolAnnotations,
47
+ SourceNotFoundError,
48
+ SourceRemovalNotAllowedError,
49
+ TOOL_POLICY_ACTIONS,
50
+ TokenMaterial,
51
+ ToolBlockedError,
24
52
  ToolId,
25
53
  ToolInvocationError,
26
- ToolInvocationResult,
27
- ToolListFilter,
28
- ToolMetadata,
29
54
  ToolNotFoundError,
30
- ToolRegistration,
31
- ToolRegistry,
55
+ ToolPolicyActionSchema,
32
56
  ToolSchema,
57
+ UpdateConnectionTokensInput,
33
58
  UrlElicitation,
59
+ beginDynamicAuthorization,
60
+ buildAuthorizationUrl,
34
61
  buildToolTypeScriptPreview,
35
- collectRefs,
62
+ collectSchemas,
63
+ coreSchema,
36
64
  createExecutor,
37
- definePlugin,
38
- hoistDefinitions,
39
- inMemoryToolsPlugin,
40
- makeInMemoryPolicyEngine,
41
- makeInMemoryScopedKv,
42
- makeInMemorySecretProvider,
43
- makeInMemorySecretStore,
44
- makeInMemorySourceRegistry,
45
- makeInMemoryToolRegistry,
46
- makeTestConfig,
47
- normalizeRefs,
48
- reattachDefs,
49
- registerRuntimeTools,
50
- runtimeTool,
65
+ createPkceCodeChallenge,
66
+ createPkceCodeVerifier,
67
+ defineExecutorConfig,
68
+ discoverAuthorizationServerMetadata,
69
+ discoverProtectedResourceMetadata,
70
+ effectivePolicyFromSorted,
71
+ exchangeAuthorizationCode,
72
+ exchangeClientCredentials,
73
+ isSecretBackedRef,
74
+ isToolPolicyAction,
75
+ isValidPattern,
76
+ makeInMemoryBlobStore,
77
+ makeOAuth2Service,
78
+ matchPattern,
79
+ pluginBlobStore,
80
+ refreshAccessToken,
81
+ registerDynamicClient,
82
+ resolveEffectivePolicy,
83
+ resolveSecretBackedMap,
84
+ resolveToolPolicy,
85
+ rowToToolPolicy,
51
86
  schemaToTypeScriptPreview,
52
87
  schemaToTypeScriptPreviewWithDefs,
53
- scopeKv,
54
- tool
55
- } from "./chunk-D7CT3UMO.js";
88
+ shouldRefreshToken
89
+ } from "./chunk-2WV7VSNL.js";
90
+
91
+ // src/index.ts
92
+ import { Context, Effect, Layer, Schema, Data, Option } from "effect";
93
+ import {
94
+ HttpApi,
95
+ HttpApiBuilder,
96
+ HttpApiClient,
97
+ HttpApiEndpoint,
98
+ HttpApiGroup,
99
+ HttpApiMiddleware,
100
+ HttpApiSchema
101
+ } from "effect/unstable/httpapi";
102
+ import { typedAdapter } from "@executor-js/storage-core";
103
+ import { StorageError, UniqueViolationError } from "@executor-js/storage-core";
104
+
105
+ // src/oauth-popup-types.ts
106
+ var OAUTH_POPUP_MESSAGE_TYPE = "executor:oauth-result";
107
+ var isOAuthPopupResult = (value) => typeof value === "object" && value !== null && value.type === OAUTH_POPUP_MESSAGE_TYPE;
108
+
109
+ // src/plugin.ts
110
+ var defineSchema = (schema) => schema;
111
+ function definePlugin(authorFactory) {
112
+ return (options) => {
113
+ const {
114
+ storage: storageOverride,
115
+ ...rest
116
+ } = options ?? {};
117
+ const hasAuthorOptions = Object.keys(rest).length > 0;
118
+ const spec = authorFactory(
119
+ hasAuthorOptions ? rest : void 0
120
+ );
121
+ return {
122
+ ...spec,
123
+ storage: storageOverride ?? spec.storage
124
+ };
125
+ };
126
+ }
127
+
128
+ // src/testing.ts
129
+ import { makeMemoryAdapter } from "@executor-js/storage-core/testing/memory";
130
+ var makeTestConfig = (options) => {
131
+ const scopes = options?.scopes ?? [
132
+ new Scope({
133
+ id: ScopeId.make("test-scope"),
134
+ name: options?.scopeName ?? "test",
135
+ createdAt: /* @__PURE__ */ new Date()
136
+ })
137
+ ];
138
+ const schema = collectSchemas(options?.plugins ?? []);
139
+ return {
140
+ scopes,
141
+ adapter: makeMemoryAdapter({ schema }),
142
+ blobs: makeInMemoryBlobStore(),
143
+ plugins: options?.plugins,
144
+ // Tests default to auto-accepting elicitation prompts. Override via
145
+ // a wrapping spread if a test exercises a real handler:
146
+ // { ...makeTestConfig(...), onElicitation: customHandler }
147
+ onElicitation: "accept-all"
148
+ };
149
+ };
150
+
151
+ // src/schema-refs.ts
152
+ var REF_PATTERN = /^#\/(?:\$defs|definitions)\/(.+)$/;
153
+ var parseRefName = (ref) => ref.match(REF_PATTERN)?.[1];
154
+ var normalizeRefs = (node) => {
155
+ if (node == null || typeof node !== "object") return node;
156
+ if (Array.isArray(node)) {
157
+ let changed2 = false;
158
+ const out = node.map((item) => {
159
+ const n = normalizeRefs(item);
160
+ if (n !== item) changed2 = true;
161
+ return n;
162
+ });
163
+ return changed2 ? out : node;
164
+ }
165
+ const obj = node;
166
+ if (typeof obj.$ref === "string") {
167
+ const name = parseRefName(obj.$ref);
168
+ if (name) {
169
+ const canonical = `#/$defs/${name}`;
170
+ return canonical !== obj.$ref ? { ...obj, $ref: canonical } : obj;
171
+ }
172
+ return obj;
173
+ }
174
+ let changed = false;
175
+ const result = {};
176
+ for (const [k, v] of Object.entries(obj)) {
177
+ const n = normalizeRefs(v);
178
+ if (n !== v) changed = true;
179
+ result[k] = n;
180
+ }
181
+ return changed ? result : obj;
182
+ };
183
+ var hoistDefinitions = (schema) => {
184
+ if (schema == null || typeof schema !== "object") {
185
+ return { stripped: schema, defs: {} };
186
+ }
187
+ const obj = schema;
188
+ const defs = {};
189
+ if (obj.$defs && typeof obj.$defs === "object") {
190
+ for (const [k, v] of Object.entries(obj.$defs)) {
191
+ defs[k] = v;
192
+ }
193
+ }
194
+ if (obj.definitions && typeof obj.definitions === "object") {
195
+ for (const [k, v] of Object.entries(obj.definitions)) {
196
+ defs[k] = v;
197
+ }
198
+ }
199
+ const { $defs: _a, definitions: _b, ...rest } = obj;
200
+ return { stripped: rest, defs };
201
+ };
202
+ var collectRefs = (node, defs, found = /* @__PURE__ */ new Set()) => {
203
+ if (node == null || typeof node !== "object") return found;
204
+ const obj = node;
205
+ if (typeof obj.$ref === "string") {
206
+ const name = parseRefName(obj.$ref);
207
+ if (name && !found.has(name)) {
208
+ found.add(name);
209
+ const def = defs.get(name);
210
+ if (def) collectRefs(def, defs, found);
211
+ }
212
+ return found;
213
+ }
214
+ for (const v of Object.values(obj)) {
215
+ if (v && typeof v === "object") {
216
+ if (Array.isArray(v)) {
217
+ for (const item of v) collectRefs(item, defs, found);
218
+ } else {
219
+ collectRefs(v, defs, found);
220
+ }
221
+ }
222
+ }
223
+ return found;
224
+ };
225
+ var reattachDefs = (schema, defs) => {
226
+ if (schema == null || typeof schema !== "object") return schema;
227
+ const refs = collectRefs(schema, defs);
228
+ if (refs.size === 0) return schema;
229
+ const attached = {};
230
+ for (const name of refs) {
231
+ const def = defs.get(name);
232
+ if (def) attached[name] = def;
233
+ }
234
+ return { ...schema, $defs: attached };
235
+ };
56
236
  export {
237
+ ConnectionId,
238
+ ConnectionNotFoundError,
239
+ ConnectionProviderNotRegisteredError,
240
+ ConnectionProviderState,
241
+ ConnectionReauthRequiredError,
242
+ ConnectionRef,
243
+ ConnectionRefreshError,
244
+ ConnectionRefreshNotSupportedError,
245
+ Context,
246
+ CreateConnectionInput,
247
+ Data,
248
+ Effect,
57
249
  ElicitationAction,
58
250
  ElicitationDeclinedError,
59
251
  ElicitationResponse,
60
252
  FormElicitation,
61
- Policy,
62
- PolicyAction,
63
- PolicyCheckInput,
64
- PolicyDeniedError,
65
- PolicyEngine,
253
+ HttpApi,
254
+ HttpApiBuilder,
255
+ HttpApiClient,
256
+ HttpApiEndpoint,
257
+ HttpApiGroup,
258
+ HttpApiMiddleware,
259
+ HttpApiSchema,
260
+ Layer,
261
+ NoHandlerError,
262
+ OAUTH2_DEFAULT_TIMEOUT_MS,
263
+ OAUTH2_PROVIDER_KEY,
264
+ OAUTH2_REFRESH_SKEW_MS,
265
+ OAUTH2_SESSION_TTL_MS,
266
+ OAUTH_POPUP_MESSAGE_TYPE,
267
+ OAuth2Error,
268
+ OAuthAuthorizationCodeStrategy as OAuthAuthorizationCodeStrategySchema,
269
+ OAuthAuthorizationServerMetadataSchema,
270
+ OAuthClientCredentialsStrategy as OAuthClientCredentialsStrategySchema,
271
+ OAuthClientInformationSchema,
272
+ OAuthCompleteError,
273
+ OAuthDiscoveryError,
274
+ OAuthDynamicDcrStrategy as OAuthDynamicDcrStrategySchema,
275
+ OAuthProbeError,
276
+ OAuthProtectedResourceMetadataSchema,
277
+ OAuthProviderState as OAuthProviderStateSchema,
278
+ OAuthSessionNotFoundError,
279
+ OAuthStartError,
280
+ OAuthStrategy as OAuthStrategySchema,
281
+ Option,
282
+ PluginNotLoadedError,
66
283
  PolicyId,
284
+ Schema,
67
285
  Scope,
68
286
  ScopeId,
287
+ SecretBackedMap,
288
+ SecretBackedValue,
69
289
  SecretId,
70
290
  SecretNotFoundError,
291
+ SecretOwnedByConnectionError,
71
292
  SecretRef,
72
293
  SecretResolutionError,
73
- SecretStore,
74
294
  SetSecretInput,
75
- Source,
76
295
  SourceDetectionResult,
77
- SourceRegistry,
78
- ToolAnnotations,
296
+ SourceNotFoundError,
297
+ SourceRemovalNotAllowedError,
298
+ StorageError,
299
+ TOOL_POLICY_ACTIONS,
300
+ TokenMaterial,
301
+ ToolBlockedError,
79
302
  ToolId,
80
303
  ToolInvocationError,
81
- ToolInvocationResult,
82
- ToolListFilter,
83
- ToolMetadata,
84
304
  ToolNotFoundError,
85
- ToolRegistration,
86
- ToolRegistry,
305
+ ToolPolicyActionSchema,
87
306
  ToolSchema,
307
+ UniqueViolationError,
308
+ UpdateConnectionTokensInput,
88
309
  UrlElicitation,
310
+ beginDynamicAuthorization,
311
+ buildAuthorizationUrl,
89
312
  buildToolTypeScriptPreview,
90
313
  collectRefs,
314
+ collectSchemas,
315
+ coreSchema,
91
316
  createExecutor,
317
+ createPkceCodeChallenge,
318
+ createPkceCodeVerifier,
319
+ defineExecutorConfig,
92
320
  definePlugin,
321
+ defineSchema,
322
+ discoverAuthorizationServerMetadata,
323
+ discoverProtectedResourceMetadata,
324
+ effectivePolicyFromSorted,
325
+ exchangeAuthorizationCode,
326
+ exchangeClientCredentials,
93
327
  hoistDefinitions,
94
- inMemoryToolsPlugin,
95
- makeInMemoryPolicyEngine,
96
- makeInMemoryScopedKv,
97
- makeInMemorySecretProvider,
98
- makeInMemorySecretStore,
99
- makeInMemorySourceRegistry,
100
- makeInMemoryToolRegistry,
328
+ isOAuthPopupResult,
329
+ isSecretBackedRef,
330
+ isToolPolicyAction,
331
+ isValidPattern,
332
+ makeInMemoryBlobStore,
333
+ makeOAuth2Service,
101
334
  makeTestConfig,
335
+ matchPattern,
102
336
  normalizeRefs,
337
+ pluginBlobStore,
103
338
  reattachDefs,
104
- registerRuntimeTools,
105
- runtimeTool,
339
+ refreshAccessToken,
340
+ registerDynamicClient,
341
+ resolveEffectivePolicy,
342
+ resolveSecretBackedMap,
343
+ resolveToolPolicy,
344
+ rowToToolPolicy,
106
345
  schemaToTypeScriptPreview,
107
346
  schemaToTypeScriptPreviewWithDefs,
108
- scopeKv,
109
- tool
347
+ shouldRefreshToken,
348
+ typedAdapter
110
349
  };
111
350
  //# sourceMappingURL=core.js.map
package/dist/core.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/oauth-popup-types.ts","../src/plugin.ts","../src/testing.ts","../src/schema-refs.ts"],"sourcesContent":["// ---------------------------------------------------------------------------\n// @executor-js/sdk — public surface\n// ---------------------------------------------------------------------------\n\n// Re-export the Effect/Schema/HttpApi primitives plugin authors need so a\n// plugin can be written importing only from `@executor-js/sdk`. Authors who\n// want to reach for additional Effect APIs keep importing from `effect/*`\n// directly — these re-exports are the curated minimum.\nexport { Context, Effect, Layer, Schema, Data, Option } from \"effect\";\nexport {\n HttpApi,\n HttpApiBuilder,\n HttpApiClient,\n HttpApiEndpoint,\n HttpApiGroup,\n HttpApiMiddleware,\n HttpApiSchema,\n} from \"effect/unstable/httpapi\";\n\n// Storage adapter interface types (re-exported from @executor-js/storage-core\n// so plugin authors can write adapters against a single public surface\n// without depending on storage-core directly).\nexport type {\n DBAdapter,\n DBSchema,\n DBFieldAttribute,\n DBFieldType,\n StorageFailure,\n TypedAdapter,\n Where,\n WhereOperator,\n} from \"@executor-js/storage-core\";\n\nexport { typedAdapter } from \"@executor-js/storage-core\";\n\n// Storage-layer typed errors (re-exported so plugin code can catchTag\n// `UniqueViolationError` without importing storage-core directly).\nexport { StorageError, UniqueViolationError } from \"@executor-js/storage-core\";\n\n// IDs (branded)\nexport { ScopeId, ToolId, SecretId, PolicyId, ConnectionId } from \"./ids\";\n\n// Scope\nexport { Scope } from \"./scope\";\n\n// Errors (tagged)\nexport {\n ToolNotFoundError,\n ToolInvocationError,\n ToolBlockedError,\n NoHandlerError,\n SourceNotFoundError,\n SourceRemovalNotAllowedError,\n PluginNotLoadedError,\n SecretNotFoundError,\n SecretResolutionError,\n SecretOwnedByConnectionError,\n ConnectionNotFoundError,\n ConnectionProviderNotRegisteredError,\n ConnectionRefreshNotSupportedError,\n ConnectionReauthRequiredError,\n type ExecutorError,\n} from \"./errors\";\n\n// Public projections\nexport {\n ToolSchema,\n SourceDetectionResult,\n type Source,\n type Tool,\n type ToolListFilter,\n} from \"./types\";\n\n// Core schema\nexport {\n coreSchema,\n isToolPolicyAction,\n TOOL_POLICY_ACTIONS,\n type CoreSchema,\n type SourceInput,\n type SourceInputTool,\n type SourceRow,\n type ToolRow,\n type DefinitionRow,\n type SecretRow,\n type ConnectionRow,\n type ToolPolicyRow,\n type ToolPolicyAction,\n type DefinitionsInput,\n type ToolAnnotations,\n} from \"./core-schema\";\n\n// Tool policies\nexport {\n matchPattern,\n isValidPattern,\n resolveToolPolicy,\n resolveEffectivePolicy,\n effectivePolicyFromSorted,\n rowToToolPolicy,\n ToolPolicyActionSchema,\n type ToolPolicy,\n type CreateToolPolicyInput,\n type UpdateToolPolicyInput,\n type PolicyMatch,\n type EffectivePolicy,\n type PolicySource,\n} from \"./policies\";\n\n// Secrets\nexport { SecretRef, SetSecretInput, type SecretProvider } from \"./secrets\";\n\nexport {\n SecretBackedMap,\n SecretBackedValue,\n isSecretBackedRef,\n resolveSecretBackedMap,\n type ResolveSecretBackedMapOptions,\n} from \"./secret-backed-value\";\n\n// Connections\nexport {\n ConnectionRef,\n ConnectionProviderState,\n CreateConnectionInput,\n UpdateConnectionTokensInput,\n TokenMaterial,\n ConnectionRefreshError,\n type ConnectionProvider,\n type ConnectionRefreshInput,\n type ConnectionRefreshResult,\n} from \"./connections\";\n\n// Elicitation\nexport {\n FormElicitation,\n UrlElicitation,\n ElicitationAction,\n ElicitationResponse,\n ElicitationDeclinedError,\n type ElicitationRequest,\n type ElicitationHandler,\n type ElicitationContext,\n} from \"./elicitation\";\n\n// Blob store\nexport {\n type BlobStore,\n type PluginBlobStore,\n pluginBlobStore,\n makeInMemoryBlobStore,\n} from \"./blob\";\n\n// OAuth 2.1\nexport {\n type OAuthService,\n type OAuthStrategy,\n type OAuthDynamicDcrStrategy,\n type OAuthAuthorizationCodeStrategy,\n type OAuthClientCredentialsStrategy,\n type OAuthProviderState,\n type OAuthProbeInput,\n type OAuthProbeResult,\n type OAuthStartInput,\n type OAuthStartResult,\n type OAuthCompleteInput,\n type OAuthCompleteResult,\n OAuthProbeError,\n OAuthStartError,\n OAuthCompleteError,\n OAuthSessionNotFoundError,\n OAUTH2_PROVIDER_KEY,\n OAUTH2_SESSION_TTL_MS,\n OAuthStrategy as OAuthStrategySchema,\n OAuthProviderState as OAuthProviderStateSchema,\n OAuthDynamicDcrStrategy as OAuthDynamicDcrStrategySchema,\n OAuthAuthorizationCodeStrategy as OAuthAuthorizationCodeStrategySchema,\n OAuthClientCredentialsStrategy as OAuthClientCredentialsStrategySchema,\n} from \"./oauth\";\n\nexport {\n OAuth2Error,\n OAUTH2_DEFAULT_TIMEOUT_MS,\n OAUTH2_REFRESH_SKEW_MS,\n buildAuthorizationUrl,\n createPkceCodeChallenge,\n createPkceCodeVerifier,\n exchangeAuthorizationCode,\n exchangeClientCredentials,\n refreshAccessToken,\n shouldRefreshToken,\n type OAuth2TokenResponse,\n type BuildAuthorizationUrlInput,\n type ClientAuthMethod,\n type ExchangeAuthorizationCodeInput,\n type ExchangeClientCredentialsInput,\n type RefreshAccessTokenInput,\n} from \"./oauth-helpers\";\n\nexport { makeOAuth2Service, type OAuthServiceDeps } from \"./oauth-service\";\n\nexport {\n OAuthDiscoveryError,\n OAuthAuthorizationServerMetadataSchema,\n OAuthClientInformationSchema,\n OAuthProtectedResourceMetadataSchema,\n beginDynamicAuthorization,\n discoverAuthorizationServerMetadata,\n discoverProtectedResourceMetadata,\n registerDynamicClient,\n type BeginDynamicAuthorizationInput,\n type DiscoveryRequestOptions,\n type DynamicAuthorizationState,\n type DynamicAuthorizationStartResult,\n type DynamicClientMetadata,\n type OAuthAuthorizationServerMetadata,\n type OAuthClientInformation,\n type OAuthProtectedResourceMetadata,\n type RegisterDynamicClientInput,\n} from \"./oauth-discovery\";\n\nexport {\n OAUTH_POPUP_MESSAGE_TYPE,\n type OAuthPopupResult,\n isOAuthPopupResult,\n} from \"./oauth-popup-types\";\n\n// Plugin definition\nexport {\n type Plugin,\n type PluginSpec,\n type PluginCtx,\n type PluginExtensions,\n type ConfiguredPlugin,\n type AnyPlugin,\n type StorageDeps,\n type StaticSourceDecl,\n type StaticToolDecl,\n type StaticToolHandlerInput,\n type InvokeToolInput,\n type SourceLifecycleInput,\n type SecretListEntry,\n type Elicit,\n definePlugin,\n defineSchema,\n} from \"./plugin\";\n\n// Executor\nexport {\n type Executor,\n type ExecutorConfig,\n type OnElicitation,\n type InvokeOptions,\n createExecutor,\n collectSchemas,\n} from \"./executor\";\n\n// CLI / runtime config\nexport {\n defineExecutorConfig,\n type ExecutorCliConfig,\n type ExecutorDialect,\n type ExecutorPluginsFactory,\n} from \"./config\";\n\n// Test helper\nexport { makeTestConfig } from \"./testing\";\n\n// JSON schema $ref helpers (used by openapi for $defs handling)\nexport { hoistDefinitions, collectRefs, reattachDefs, normalizeRefs } from \"./schema-refs\";\n\n// TypeScript preview generation from JSON schemas\nexport {\n schemaToTypeScriptPreview,\n schemaToTypeScriptPreviewWithDefs,\n buildToolTypeScriptPreview,\n type TypeScriptRenderOptions,\n type TypeScriptSchemaPreview,\n} from \"./schema-types\";\n","// ---------------------------------------------------------------------------\n// OAuth popup result — the message shape exchanged between the popup window\n// (opened during authorization) and the opener (the onboarding UI). Both the\n// server-side HTML generator and the client-side popup opener agree on this\n// shape so that success / failure can be communicated reliably via both\n// `postMessage` and `BroadcastChannel`.\n// ---------------------------------------------------------------------------\n\n/** Message type literal used to identify our popup results. */\nexport const OAUTH_POPUP_MESSAGE_TYPE = \"executor:oauth-result\" as const;\n\nexport type OAuthPopupResult<TAuth> =\n | ({\n readonly type: typeof OAUTH_POPUP_MESSAGE_TYPE;\n readonly ok: true;\n readonly sessionId: string;\n } & TAuth)\n | {\n readonly type: typeof OAUTH_POPUP_MESSAGE_TYPE;\n readonly ok: false;\n readonly sessionId: string | null;\n readonly error: string;\n };\n\nexport const isOAuthPopupResult = <TAuth>(\n value: unknown,\n): value is OAuthPopupResult<TAuth> =>\n typeof value === \"object\" &&\n value !== null &&\n (value as { type?: unknown }).type === OAUTH_POPUP_MESSAGE_TYPE;\n","import type { Context, Effect, Layer } from \"effect\";\nimport type { HttpApiGroup } from \"effect/unstable/httpapi\";\nimport type {\n DBAdapter,\n DBSchema,\n StorageFailure,\n TypedAdapter,\n} from \"@executor-js/storage-core\";\n\nimport type { PluginBlobStore } from \"./blob\";\nimport type {\n ConnectionProvider,\n ConnectionRef,\n ConnectionRefreshError,\n CreateConnectionInput,\n UpdateConnectionTokensInput,\n} from \"./connections\";\nimport type {\n DefinitionsInput,\n SourceInput,\n ToolAnnotations,\n ToolRow,\n} from \"./core-schema\";\nimport type { SourceDetectionResult } from \"./types\";\nimport type {\n ElicitationDeclinedError,\n ElicitationHandler,\n ElicitationRequest,\n ElicitationResponse,\n} from \"./elicitation\";\nimport type {\n ConnectionNotFoundError,\n ConnectionProviderNotRegisteredError,\n ConnectionReauthRequiredError,\n ConnectionRefreshNotSupportedError,\n SecretOwnedByConnectionError,\n} from \"./errors\";\nimport type { OAuthService } from \"./oauth\";\nimport type { Scope } from \"./scope\";\nimport type { SecretProvider, SecretRef, SetSecretInput } from \"./secrets\";\n\n// ---------------------------------------------------------------------------\n// StorageDeps — backing passed to a plugin's `storage` factory. The only\n// place a plugin ever sees storage; `PluginCtx` does not carry it. The\n// `adapter` field is a `TypedAdapter<TSchema>` view narrowed by the\n// plugin's own declared `schema` — plugins never import or construct\n// a typed adapter themselves, the executor infers TSchema from the\n// `schema` field on their spec and hands back a typed view.\n//\n// Plugins with no schema (secret-provider-only plugins, etc.) get a\n// bare `DBAdapter` they can ignore.\n// ---------------------------------------------------------------------------\n\nexport interface StorageDeps<TSchema extends DBSchema | undefined = undefined> {\n /**\n * Precedence-ordered scope stack visible to this executor. Innermost\n * first. Reads on scoped tables walk every scope; writes require the\n * plugin to name a target scope explicitly (via `scope_id` on the\n * adapter payload, via `options.scope` on the blob store).\n */\n readonly scopes: readonly Scope[];\n /**\n * Plugin-facing typed adapter. Failures surface as raw `StorageFailure`\n * (`StorageError` | `UniqueViolationError`). Plugins can\n * `catchTag(\"UniqueViolationError\", …)` to translate to their own\n * user-facing errors. `StorageError` bubbles up; the HTTP edge (see\n * `@executor-js/api` `withCapture`) is the one place that\n * translates it to the opaque `InternalError({ traceId })`.\n */\n readonly adapter: TSchema extends DBSchema\n ? TypedAdapter<TSchema, StorageFailure>\n : DBAdapter;\n readonly blobs: PluginBlobStore;\n}\n\n// ---------------------------------------------------------------------------\n// defineSchema — sugar around `as const satisfies DBSchema`. Preserves\n// literal types via the `const` type parameter modifier so plugins can\n// just write `const mySchema = defineSchema({ ... })` without annotation\n// ceremony.\n// ---------------------------------------------------------------------------\n\nexport const defineSchema = <const S extends DBSchema>(schema: S): S => schema;\n\n// ---------------------------------------------------------------------------\n// Elicit — suspends the fiber, calls the invoke-time elicitation\n// handler, resumes with the user's response. Available on both static\n// tool handlers and dynamic `invokeTool` handlers. Threaded through\n// the executor from `createExecutor({ onElicitation })`.\n// ---------------------------------------------------------------------------\n\nexport type Elicit = (\n request: ElicitationRequest,\n) => Effect.Effect<ElicitationResponse, ElicitationDeclinedError>;\n\n// ---------------------------------------------------------------------------\n// PluginCtx — threaded into every extension method, static tool handler,\n// and dynamic tool handler. No raw adapter, no raw blobs. Core writes\n// go through `core.sources.register` / `core.definitions.register`.\n// ---------------------------------------------------------------------------\n\nexport interface PluginCtx<TStore = unknown> {\n /**\n * Precedence-ordered scope stack visible to this executor. Innermost\n * first. Plugins that write scoped rows must pick an element of\n * `scopes` as the `scope`/`scope_id` they stamp; reads through the\n * adapter or `ctx.secrets` automatically fall through the stack.\n */\n readonly scopes: readonly Scope[];\n readonly storage: TStore;\n\n readonly core: {\n readonly sources: {\n readonly register: (\n input: SourceInput,\n ) => Effect.Effect<void, StorageFailure>;\n readonly unregister: (\n sourceId: string,\n ) => Effect.Effect<void, StorageFailure>;\n readonly update: (input: {\n readonly id: string;\n readonly scope: string;\n readonly name?: string;\n readonly url?: string | null;\n }) => Effect.Effect<void, StorageFailure>;\n };\n /** Register shared JSON-schema `$defs` for a source. Tool\n * input/output schemas registered via `sources.register` can carry\n * `$ref: \"#/$defs/X\"` pointers; `executor.tools.schema(toolId)`\n * attaches matching defs to the returned schema. Call inside the\n * same `ctx.transaction` as `sources.register` for atomicity.\n * Replaces any existing defs for the given sourceId. */\n readonly definitions: {\n readonly register: (\n input: DefinitionsInput,\n ) => Effect.Effect<void, StorageFailure>;\n };\n };\n\n readonly secrets: {\n readonly get: (\n id: string,\n ) => Effect.Effect<string | null, SecretOwnedByConnectionError | StorageFailure>;\n /** List user-visible secrets. Connection-owned secrets (rows with\n * `owned_by_connection_id` set) are filtered out so they don't\n * clutter the UI — users see the Connection instead. */\n readonly list: () => Effect.Effect<\n readonly { readonly id: string; readonly name: string; readonly provider: string }[],\n StorageFailure\n >;\n /** Write a secret value through a provider. Used by plugins that\n * mint secrets on behalf of the user (OAuth2 token storage,\n * interactive onboarding flows). Normally writes go through\n * `executor.secrets.set` on the host surface, but OAuth2 refresh\n * and one-shot token capture from plugin-owned flows need it here\n * too. Same routing rules as the host-level setter. */\n readonly set: (\n input: SetSecretInput,\n ) => Effect.Effect<SecretRef, StorageFailure>;\n /** Delete a secret from its pinned provider and the core table.\n * Rejects with `SecretOwnedByConnectionError` if the row is owned\n * by a connection — callers must go through `connections.remove`\n * to drop the whole sign-in. */\n readonly remove: (\n id: string,\n ) => Effect.Effect<void, SecretOwnedByConnectionError | StorageFailure>;\n };\n\n /** Connections — product-level sign-in state. Owns backing secret\n * rows via `secret.owned_by_connection_id`. Plugins call\n * `connections.accessToken(id)` at invoke time to get a guaranteed-\n * fresh token (the SDK handles refresh via the registered provider\n * keyed by `connection.provider`). */\n readonly connections: {\n readonly get: (\n id: string,\n ) => Effect.Effect<ConnectionRef | null, StorageFailure>;\n readonly list: () => Effect.Effect<readonly ConnectionRef[], StorageFailure>;\n readonly create: (\n input: CreateConnectionInput,\n ) => Effect.Effect<\n ConnectionRef,\n ConnectionProviderNotRegisteredError | StorageFailure\n >;\n readonly updateTokens: (\n input: UpdateConnectionTokensInput,\n ) => Effect.Effect<\n ConnectionRef,\n ConnectionNotFoundError | StorageFailure\n >;\n readonly setIdentityLabel: (\n id: string,\n label: string | null,\n ) => Effect.Effect<void, ConnectionNotFoundError | StorageFailure>;\n /** Get a guaranteed-fresh access token. Calls the provider's\n * `refresh` handler if `expires_at` is in the past / within the\n * refresh skew window. */\n readonly accessToken: (\n id: string,\n ) => Effect.Effect<\n string,\n | ConnectionNotFoundError\n | ConnectionProviderNotRegisteredError\n | ConnectionRefreshNotSupportedError\n | ConnectionReauthRequiredError\n | ConnectionRefreshError\n | StorageFailure\n >;\n readonly remove: (id: string) => Effect.Effect<void, StorageFailure>;\n };\n\n /** Shared OAuth service. Plugins use this to probe/start/complete OAuth\n * flows; invocation should still resolve tokens via `connections.accessToken`. */\n readonly oauth: OAuthService;\n\n /** Run `effect` inside a database transaction. Wraps the underlying\n * adapter's transaction method. Use this in extension methods that\n * need atomicity across plugin storage writes AND core source/tool\n * registration. */\n readonly transaction: <A, E>(\n effect: Effect.Effect<A, E>,\n ) => Effect.Effect<A, E | StorageFailure>;\n}\n\n// ---------------------------------------------------------------------------\n// Static tool / source declarations. Pure data + handlers declared at\n// plugin-definition time.\n//\n// Importantly, `StaticToolDecl.handler` does NOT reference TExtension.\n// If it did, the nested generic would break inference for the whole\n// PluginSpec (TS would fall back to the `object` constraint on TExtension).\n// `self: NoInfer<TExtension>` lives on `staticSources` one level up\n// instead, and plugin authors close over it via the arrow-function\n// closure when they write their handler.\n// ---------------------------------------------------------------------------\n\nexport interface StaticToolHandlerInput<TStore = unknown> {\n readonly ctx: PluginCtx<TStore>;\n readonly args: unknown;\n /** Suspend the fiber to request user input. The handler passed to\n * `createExecutor({ onElicitation })` is called. */\n readonly elicit: Elicit;\n}\n\nexport interface StaticToolDecl<TStore = unknown> {\n readonly name: string;\n readonly description: string;\n readonly inputSchema?: unknown;\n readonly outputSchema?: unknown;\n /** Default-policy annotations — `requiresApproval`, `approvalDescription`,\n * `mayElicit`. Enforced by the executor before the handler runs.\n * Inline because static tools have no plugin storage to resolve from;\n * the plugin author literally writes this at definition time. */\n readonly annotations?: ToolAnnotations;\n readonly handler: (\n input: StaticToolHandlerInput<TStore>,\n ) => Effect.Effect<unknown, unknown>;\n}\n\nexport interface StaticSourceDecl<TStore = unknown> {\n readonly id: string;\n readonly kind: string;\n readonly name: string;\n readonly url?: string;\n /** Static sources default to `canRemove: false` — they represent\n * plugin-provided control surfaces and shouldn't be user-removable.\n * Override only if you really want that. */\n readonly canRemove?: boolean;\n readonly canRefresh?: boolean;\n readonly canEdit?: boolean;\n readonly tools: readonly StaticToolDecl<TStore>[];\n}\n\n// ---------------------------------------------------------------------------\n// Dynamic invoke / source lifecycle inputs.\n// ---------------------------------------------------------------------------\n\nexport interface InvokeToolInput<TStore = unknown> {\n readonly ctx: PluginCtx<TStore>;\n /** Already-loaded tool row. Plugin doesn't need to re-fetch or parse\n * the tool id. Carries source_id, name, input/output schemas,\n * annotations. */\n readonly toolRow: ToolRow;\n readonly args: unknown;\n /** Elicitation handle for plugins that need mid-invocation user input\n * (onepassword auth prompt, interactive MCP tools, etc.). */\n readonly elicit: Elicit;\n}\n\nexport interface SourceLifecycleInput<TStore = unknown> {\n readonly ctx: PluginCtx<TStore>;\n readonly sourceId: string;\n /**\n * Scope of the source row being removed/refreshed — resolved by the\n * SDK's `sources.remove` / `sources.refresh` via innermost-wins lookup\n * across the executor's scope stack. Plugins that own a side table\n * keyed by (id, scope_id) must pin their own cleanup to this scope;\n * relying on the scoped adapter's `scope_id IN (stack)` fall-through\n * would widen the mutation across the whole stack and wipe a\n * shadowed outer-scope row.\n */\n readonly scope: string;\n}\n\n// ---------------------------------------------------------------------------\n// PluginSpec — what a `definePlugin(factory)` call returns.\n// ---------------------------------------------------------------------------\n\n// Defaults are `any` for slots that surface in contravariant positions\n// (storage/extension callbacks consume `TStore`/`TSchema`; `staticSources`\n// closes over `TExtension` via `NoInfer`). `any` is bivariant, so\n// `Plugin<string>` is a structural supertype of every concrete plugin\n// — `AnyPlugin = Plugin<string>` keeps the generic explosion contained\n// to this single declaration. Concrete specs ignore the defaults; TS\n// infers each slot from the literal returned by the author factory.\n//\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface PluginSpec<\n TId extends string = string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TExtension extends object = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TStore = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TSchema extends DBSchema | undefined = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TExtensionService extends Context.Service<any, any> | undefined = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n THandlersLayer extends Layer.Layer<any, any, any> = any,\n TGroup extends HttpApiGroup.Any = HttpApiGroup.Any,\n> {\n readonly id: TId;\n /** npm package name. The Vite plugin uses this to derive the\n * `./client` import path for the frontend bundle (so the same\n * `executor.config.ts` drives both server and client) — `${packageName}/client`\n * is what gets bundled. The author writes the same string they\n * publish to npm; no transforms, no scope conventions. Required for\n * plugins that ship a `./client` entry; can be omitted for SDK-only\n * plugins (no client bundle = nothing to resolve). */\n readonly packageName?: string;\n /** Plugin-declared schema. Merged with coreSchema and other plugins'\n * schemas at executor startup via `collectSchemas`. The type flows\n * into the `storage` factory's `deps.adapter` as a `TypedAdapter<TSchema>`\n * so plugins get narrowed model names + typed rows for free. */\n readonly schema?: TSchema;\n /** Build the plugin's typed store from backing. `deps.adapter` is\n * already narrowed to this plugin's schema; `deps.blobs` is already\n * scoped to the plugin id so key collisions across plugins are\n * structurally impossible. */\n readonly storage: (deps: StorageDeps<TSchema>) => TStore;\n\n /** Build the plugin's extension API. The returned object becomes\n * `executor[plugin.id]` and is also the `self` passed to\n * `staticSources`. Field order matters: `extension` MUST appear\n * before `staticSources` so TS infers TExtension from this\n * factory's return BEFORE type-checking `self: NoInfer<TExtension>`. */\n readonly extension?: (ctx: PluginCtx<TStore>) => TExtension;\n\n /** Static sources contributed by this plugin with inline tool\n * handlers. Lives entirely in memory — no DB writes at startup.\n * Handlers close over `self` via the closure, so a control tool\n * that delegates to the plugin's real API is a one-liner:\n * `({ args }) => self.addSpec(args)`. */\n readonly staticSources?: (\n self: NoInfer<TExtension>,\n ) => readonly StaticSourceDecl<TStore>[];\n\n /** HttpApiGroup contributed by this plugin. Composed into the host's\n * `HttpApi` via the `addGroup` helper at runtime. The host mounts\n * the group at `/_executor/plugins/{id}/...` (or wherever the\n * plugin declares its base path) with the host's auth + scope\n * middleware applied. Endpoints automatically appear in the\n * executor OpenAPI doc and the typed reactive client.\n *\n * TGroup is inferred from the plugin's own group declaration so the\n * precise group identity flows through `composePluginApi(plugins)` —\n * the host's typed `HttpApi<\"executor\", CoreGroups | PluginGroups>`\n * is derived from the plugin tuple alone, with no per-plugin Group\n * imports at the host. Per-endpoint typing already lives inside the\n * plugin — its `handlers` Layer is built against its own bundled\n * `HttpApi.make(\"foo\").add(FooApi)` for full `.handle(\"name\", ...)`\n * inference, and its client imports the same group directly. */\n readonly routes?: () => TGroup;\n\n /** Handlers Layer for this plugin's group. Built by the plugin against\n * its own bundled API for full type safety on `.handle(\"name\", ...)`,\n * composes into the host's runtime `FullApi` because\n * `HttpApiBuilder.group` keys the layer by group identity, not by the\n * surrounding API.\n *\n * Late-binding: the layer leaves the plugin's extension as a Service\n * Tag requirement (see `extensionService` below). The host satisfies\n * it however its runtime wants:\n * - local: at boot via `Layer.succeed(extensionService)(executor[id])`\n * (see `composePluginHandlers`)\n * - cloud: per-request via `Effect.provideService(extensionService,\n * requestExecutor[id])` in the auth middleware\n *\n * The Layer's channels are typed `any` because `Layer<RIn, E, ROut>`'s\n * `ROut` is contravariant — the host accepts any layer here and merges\n * them; per-plugin requirements flow through the merge. */\n readonly handlers?: () => THandlersLayer;\n\n /** Service tag the plugin's `handlers` layer requires. Set by plugins\n * whose handlers consume their extension via a `Context.Service` tag\n * (the established pattern: `*Handlers` reads `*ExtensionService`).\n * The host binds the tag to the live extension — at boot for local,\n * per request for cloud. Pairs with `handlers`; either both fields\n * are set or neither.\n *\n * Inferred via the `TExtensionService` generic so the per-plugin\n * Service class identity propagates through `composePluginHandlers`,\n * `composePluginHandlerLayer`, and `providePluginExtensions` —\n * cloud's per-request middleware needs the precise tag for layer\n * satisfaction. */\n readonly extensionService?: TExtensionService;\n\n /** Invoke a dynamic tool. Called when the executor's static-handler\n * map doesn't have the toolId. The plugin reads its own enrichment\n * via `ctx.storage` and returns the result. Optional — plugins with\n * only static tools can omit it. */\n readonly invokeTool?: (\n input: InvokeToolInput<TStore>,\n ) => Effect.Effect<unknown, unknown>;\n\n /** Bulk resolve annotations (requiresApproval, approvalDescription,\n * mayElicit) for a set of tool rows under a single source. Called\n * by the executor:\n * - at invoke time with a single-element `toolRows` array, to\n * enforce approval on the about-to-run tool\n * - at list time with every dynamic tool row under each source,\n * grouped by source_id, to populate `Tool.annotations` for UI\n *\n * The expected implementation for most plugins is: read plugin\n * storage once for the given source/rows, derive annotations from\n * the same data that was used to build the tool (HTTP method +\n * path for openapi, introspection kind for graphql, etc.), return\n * a map keyed by tool id.\n *\n * Omit if the plugin has no annotations to contribute — executor\n * treats tools from that plugin as auto-approved with no\n * elicitation. */\n readonly resolveAnnotations?: (input: {\n readonly ctx: PluginCtx<TStore>;\n readonly sourceId: string;\n readonly toolRows: readonly ToolRow[];\n }) => Effect.Effect<Record<string, ToolAnnotations>, unknown>;\n\n /** Called when `executor.sources.remove(id)` targets a source owned\n * by this plugin. Plugin-side cleanup only; the executor deletes\n * the core source/tool rows after this callback returns, inside\n * the same transaction. */\n readonly removeSource?: (\n input: SourceLifecycleInput<TStore>,\n ) => Effect.Effect<void, unknown>;\n\n readonly refreshSource?: (\n input: SourceLifecycleInput<TStore>,\n ) => Effect.Effect<void, unknown>;\n\n /** URL autodetection hook. When the user pastes a URL in the\n * onboarding UI, `executor.sources.detect(url)` fans out to every\n * plugin's `detect`. Return a `SourceDetectionResult` if you\n * recognize the URL, `null` otherwise. Implementations should be\n * defensive — swallow fetch errors and return null rather than\n * throwing. First high-confidence match wins. */\n readonly detect?: (input: {\n readonly ctx: PluginCtx<TStore>;\n readonly url: string;\n }) => Effect.Effect<SourceDetectionResult | null, unknown>;\n\n /** Secret providers contributed by this plugin. Either a static\n * array, a function of ctx (for providers that need per-instance\n * state like the keychain's scope-derived service name), or a\n * function returning an Effect so plugins can probe for backend\n * availability at startup and register conditionally. Called once\n * at executor startup after `storage` and `extension` have been\n * built. */\n readonly secretProviders?:\n | readonly SecretProvider[]\n | ((ctx: PluginCtx<TStore>) => readonly SecretProvider[])\n | ((\n ctx: PluginCtx<TStore>,\n ) => Effect.Effect<readonly SecretProvider[]>);\n\n /** Connection providers contributed by this plugin. Same registration\n * shape as `secretProviders`. Each provider's `key` is what\n * `connection.provider` references in the core table; the `refresh`\n * handler is the SDK's single entry point for token lifecycle —\n * plugins don't run their own refresh loops anymore. */\n readonly connectionProviders?:\n | readonly ConnectionProvider[]\n | ((ctx: PluginCtx<TStore>) => readonly ConnectionProvider[])\n | ((\n ctx: PluginCtx<TStore>,\n ) => Effect.Effect<readonly ConnectionProvider[]>);\n\n readonly close?: () => Effect.Effect<void, unknown>;\n}\n\nexport interface Plugin<\n TId extends string = string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TExtension extends object = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TStore = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TSchema extends DBSchema | undefined = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TExtensionService extends Context.Service<any, any> | undefined = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n THandlersLayer extends Layer.Layer<any, any, any> = any,\n TGroup extends HttpApiGroup.Any = HttpApiGroup.Any,\n> extends PluginSpec<\n TId,\n TExtension,\n TStore,\n TSchema,\n TExtensionService,\n THandlersLayer,\n TGroup\n > {}\n\n// ---------------------------------------------------------------------------\n// definePlugin — factory-returning-spec. Options from the author factory\n// are merged with a storage override so consumers can swap the default\n// store implementation without touching plugin internals.\n// ---------------------------------------------------------------------------\n\nexport type ConfiguredPlugin<\n TId extends string,\n TExtension extends object,\n TStore,\n TOptions extends object,\n TSchema extends DBSchema | undefined,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TExtensionService extends Context.Service<any, any> | undefined = undefined,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n THandlersLayer extends Layer.Layer<any, any, any> = Layer.Layer<unknown, never, never>,\n TGroup extends HttpApiGroup.Any = HttpApiGroup.Any,\n> = (\n options?: TOptions & {\n readonly storage?: (deps: StorageDeps<TSchema>) => TStore;\n },\n) => Plugin<\n TId,\n TExtension,\n TStore,\n TSchema,\n TExtensionService,\n THandlersLayer,\n TGroup\n>;\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function definePlugin<\n TId extends string,\n TExtension extends object,\n TStore,\n TSchema extends DBSchema | undefined = undefined,\n TOptions extends object = {},\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TExtensionService extends Context.Service<any, any> | undefined = undefined,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n THandlersLayer extends Layer.Layer<any, any, any> = Layer.Layer<unknown, never, never>,\n TGroup extends HttpApiGroup.Any = HttpApiGroup.Any,\n>(\n authorFactory: (\n options?: TOptions,\n ) => PluginSpec<\n TId,\n TExtension,\n TStore,\n TSchema,\n TExtensionService,\n THandlersLayer,\n TGroup\n >,\n): ConfiguredPlugin<\n TId,\n TExtension,\n TStore,\n TOptions,\n TSchema,\n TExtensionService,\n THandlersLayer,\n TGroup\n> {\n return (options) => {\n const {\n storage: storageOverride,\n ...rest\n }: {\n storage?: (deps: StorageDeps<TSchema>) => TStore;\n [key: string]: unknown;\n } = options ?? {};\n\n const hasAuthorOptions = Object.keys(rest).length > 0;\n const spec = authorFactory(\n hasAuthorOptions ? (rest as TOptions) : undefined,\n );\n\n return {\n ...spec,\n storage: storageOverride ?? spec.storage,\n };\n };\n}\n\n// ---------------------------------------------------------------------------\n// AnyPlugin / PluginExtensions — type-level glue for the Executor surface.\n// ---------------------------------------------------------------------------\n\n// `Plugin<string>` (with all subsequent slots taking their wide defaults)\n// is structurally any concrete plugin — the `any` cascade stays inside\n// the spec's defaults instead of leaking into every consumer.\nexport type AnyPlugin = Plugin<string>;\n\nexport type PluginExtensions<TPlugins extends readonly AnyPlugin[]> = {\n readonly [P in TPlugins[number] as P[\"id\"]]: P extends Plugin<\n string,\n infer TExt\n >\n ? TExt\n : never;\n};\n\n/** Lightweight projection of a secret entry as returned by `ctx.secrets.list`. */\nexport interface SecretListEntry {\n readonly id: string;\n readonly name: string;\n readonly provider: string;\n}\n\n// Re-exported for consumers that check the elicitation handler type.\nexport type { ElicitationHandler };\n","import { makeMemoryAdapter } from \"@executor-js/storage-core/testing/memory\";\n\nimport { makeInMemoryBlobStore } from \"./blob\";\nimport type { ExecutorConfig } from \"./executor\";\nimport { collectSchemas } from \"./executor\";\nimport { ScopeId } from \"./ids\";\nimport type { AnyPlugin } from \"./plugin\";\nimport { Scope } from \"./scope\";\n\n// ---------------------------------------------------------------------------\n// makeTestConfig — build an ExecutorConfig backed by in-memory adapter +\n// blob store. For unit tests, plugin authors validating their plugin,\n// REPL experimentation. No persistence.\n//\n// Defaults to a single-element scope stack (\"test-scope\") — tests that\n// need multi-scope behavior can pass `scopes` explicitly.\n// ---------------------------------------------------------------------------\n\nexport const makeTestConfig = <\n const TPlugins extends readonly AnyPlugin[] = [],\n>(options?: {\n readonly scopeName?: string;\n readonly scopes?: readonly Scope[];\n readonly plugins?: TPlugins;\n}): ExecutorConfig<TPlugins> => {\n const scopes =\n options?.scopes ?? [\n new Scope({\n id: ScopeId.make(\"test-scope\"),\n name: options?.scopeName ?? \"test\",\n createdAt: new Date(),\n }),\n ];\n\n const schema = collectSchemas(options?.plugins ?? []);\n\n return {\n scopes,\n adapter: makeMemoryAdapter({ schema }),\n blobs: makeInMemoryBlobStore(),\n plugins: options?.plugins,\n // Tests default to auto-accepting elicitation prompts. Override via\n // a wrapping spread if a test exercises a real handler:\n // { ...makeTestConfig(...), onElicitation: customHandler }\n onElicitation: \"accept-all\",\n };\n};\n","// ---------------------------------------------------------------------------\n// JSON Schema $ref hoisting and re-attachment\n//\n// Core logic for deduplicating shared definitions across tools.\n// Used by any ToolRegistry implementation (in-memory, database-backed, etc.)\n//\n// Only handles standard JSON Schema formats ($defs, definitions).\n// Plugin-specific formats (e.g. OpenAPI components/schemas) must be\n// normalized by the plugin before calling registerDefinitions/register.\n// ---------------------------------------------------------------------------\n\ntype Obj = Record<string, unknown>;\n\n/** Standard JSON Schema $ref patterns. */\nconst REF_PATTERN = /^#\\/(?:\\$defs|definitions)\\/(.+)$/;\n\n/** Extract the definition name from a standard $ref pointer. */\nconst parseRefName = (ref: string): string | undefined => ref.match(REF_PATTERN)?.[1];\n\n/**\n * Recursively rewrite `#/definitions/<name>` pointers to `#/$defs/<name>`.\n * Returns the input unchanged if no rewrites are needed.\n */\nexport const normalizeRefs = (node: unknown): unknown => {\n if (node == null || typeof node !== \"object\") return node;\n if (Array.isArray(node)) {\n let changed = false;\n const out = node.map((item) => {\n const n = normalizeRefs(item);\n if (n !== item) changed = true;\n return n;\n });\n return changed ? out : node;\n }\n\n const obj = node as Obj;\n\n if (typeof obj.$ref === \"string\") {\n const name = parseRefName(obj.$ref);\n if (name) {\n const canonical = `#/$defs/${name}`;\n return canonical !== obj.$ref ? { ...obj, $ref: canonical } : obj;\n }\n return obj;\n }\n\n let changed = false;\n const result: Obj = {};\n for (const [k, v] of Object.entries(obj)) {\n const n = normalizeRefs(v);\n if (n !== v) changed = true;\n result[k] = n;\n }\n return changed ? result : obj;\n};\n\n/**\n * Extract `$defs` and `definitions` from a JSON Schema,\n * returning { stripped, defs } where `stripped` is the schema without local\n * definitions and `defs` is a flat map of definition name → schema.\n */\nexport const hoistDefinitions = (\n schema: unknown,\n): { stripped: unknown; defs: Record<string, unknown> } => {\n if (schema == null || typeof schema !== \"object\") {\n return { stripped: schema, defs: {} };\n }\n const obj = schema as Obj;\n const defs: Record<string, unknown> = {};\n\n if (obj.$defs && typeof obj.$defs === \"object\") {\n for (const [k, v] of Object.entries(obj.$defs as Obj)) {\n defs[k] = v;\n }\n }\n\n if (obj.definitions && typeof obj.definitions === \"object\") {\n for (const [k, v] of Object.entries(obj.definitions as Obj)) {\n defs[k] = v;\n }\n }\n\n const { $defs: _a, definitions: _b, ...rest } = obj;\n return { stripped: rest, defs };\n};\n\n/**\n * Walk a schema and collect all $ref target names transitively.\n * e.g. \"#/$defs/Address\" → \"Address\", and if Address references City, both.\n */\nexport const collectRefs = (\n node: unknown,\n defs: ReadonlyMap<string, unknown>,\n found: Set<string> = new Set(),\n): Set<string> => {\n if (node == null || typeof node !== \"object\") return found;\n const obj = node as Obj;\n\n if (typeof obj.$ref === \"string\") {\n const name = parseRefName(obj.$ref);\n if (name && !found.has(name)) {\n found.add(name);\n const def = defs.get(name);\n if (def) collectRefs(def, defs, found);\n }\n return found;\n }\n\n for (const v of Object.values(obj)) {\n if (v && typeof v === \"object\") {\n if (Array.isArray(v)) {\n for (const item of v) collectRefs(item, defs, found);\n } else {\n collectRefs(v, defs, found);\n }\n }\n }\n return found;\n};\n\n/**\n * Re-attach only the referenced shared definitions into a schema,\n * so the caller gets a self-contained, usable JSON Schema.\n *\n * Assumes all `$ref` pointers and definitions have already been normalized\n * to `#/$defs/<name>` form at registration time.\n */\nexport const reattachDefs = (schema: unknown, defs: ReadonlyMap<string, unknown>): unknown => {\n if (schema == null || typeof schema !== \"object\") return schema;\n const refs = collectRefs(schema, defs);\n if (refs.size === 0) return schema;\n\n const attached: Record<string, unknown> = {};\n for (const name of refs) {\n const def = defs.get(name);\n if (def) attached[name] = def;\n }\n\n return { ...(schema as Record<string, unknown>), $defs: attached };\n};\n"],"mappings":"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","names":["changed"]}
@@ -1,44 +1,30 @@
1
1
  import { Effect, Schema } from "effect";
2
2
  import { ToolId } from "./ids";
3
- declare const FormElicitation_base: Schema.TaggedClass<FormElicitation, "FormElicitation", {
4
- readonly _tag: Schema.tag<"FormElicitation">;
5
- } & {
6
- message: typeof Schema.String;
3
+ declare const FormElicitation_base: Schema.Class<FormElicitation, Schema.TaggedStruct<"FormElicitation", {
4
+ readonly message: Schema.String;
7
5
  /** JSON Schema describing the fields to collect */
8
- requestedSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
9
- }>;
6
+ readonly requestedSchema: Schema.$Record<Schema.String, Schema.Unknown>;
7
+ }>, {}>;
10
8
  /** Tool needs structured input from the user (render a form) */
11
9
  export declare class FormElicitation extends FormElicitation_base {
12
10
  }
13
- declare const UrlElicitation_base: Schema.TaggedClass<UrlElicitation, "UrlElicitation", {
14
- readonly _tag: Schema.tag<"UrlElicitation">;
15
- } & {
16
- message: typeof Schema.String;
17
- url: typeof Schema.String;
11
+ declare const UrlElicitation_base: Schema.Class<UrlElicitation, Schema.TaggedStruct<"UrlElicitation", {
12
+ readonly message: Schema.String;
13
+ readonly url: Schema.String;
18
14
  /** Unique ID so the host can correlate the callback */
19
- elicitationId: typeof Schema.String;
20
- }>;
15
+ readonly elicitationId: Schema.String;
16
+ }>, {}>;
21
17
  /** Tool needs the user to visit a URL (OAuth, approval page, etc.) */
22
18
  export declare class UrlElicitation extends UrlElicitation_base {
23
19
  }
24
20
  export type ElicitationRequest = FormElicitation | UrlElicitation;
25
- export declare const ElicitationAction: Schema.Literal<["accept", "decline", "cancel"]>;
21
+ export declare const ElicitationAction: Schema.Literals<readonly ["accept", "decline", "cancel"]>;
26
22
  export type ElicitationAction = typeof ElicitationAction.Type;
27
- declare const ElicitationResponse_base: Schema.Class<ElicitationResponse, {
28
- action: Schema.Literal<["accept", "decline", "cancel"]>;
23
+ declare const ElicitationResponse_base: Schema.Class<ElicitationResponse, Schema.Struct<{
24
+ readonly action: Schema.Literals<readonly ["accept", "decline", "cancel"]>;
29
25
  /** Present when action is "accept" — the data the user provided */
30
- content: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
31
- }, Schema.Struct.Encoded<{
32
- action: Schema.Literal<["accept", "decline", "cancel"]>;
33
- /** Present when action is "accept" — the data the user provided */
34
- content: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
35
- }>, never, {
36
- readonly action: "accept" | "decline" | "cancel";
37
- } & {
38
- readonly content?: {
39
- readonly [x: string]: unknown;
40
- } | undefined;
41
- }, {}, {}>;
26
+ readonly content: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
27
+ }>, {}>;
42
28
  export declare class ElicitationResponse extends ElicitationResponse_base {
43
29
  }
44
30
  export interface ElicitationContext {
@@ -52,12 +38,10 @@ export interface ElicitationContext {
52
38
  * The host renders UI / prompts the user / does OAuth / etc.
53
39
  */
54
40
  export type ElicitationHandler = (ctx: ElicitationContext) => Effect.Effect<ElicitationResponse>;
55
- declare const ElicitationDeclinedError_base: Schema.TaggedErrorClass<ElicitationDeclinedError, "ElicitationDeclinedError", {
56
- readonly _tag: Schema.tag<"ElicitationDeclinedError">;
57
- } & {
58
- toolId: Schema.brand<typeof Schema.String, "ToolId">;
59
- action: Schema.Literal<["decline", "cancel"]>;
60
- }>;
41
+ declare const ElicitationDeclinedError_base: Schema.Class<ElicitationDeclinedError, Schema.TaggedStruct<"ElicitationDeclinedError", {
42
+ readonly toolId: Schema.brand<Schema.String, "ToolId">;
43
+ readonly action: Schema.Literals<readonly ["decline", "cancel"]>;
44
+ }>, import("effect/Cause").YieldableError>;
61
45
  export declare class ElicitationDeclinedError extends ElicitationDeclinedError_base {
62
46
  }
63
47
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"elicitation.d.ts","sourceRoot":"","sources":["../src/elicitation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;;;;;IAS7B,mDAAmD;;;AAHrD,gEAAgE;AAChE,qBAAa,eAAgB,SAAQ,oBAInC;CAAG;;;;;;IAMH,uDAAuD;;;AAJzD,sEAAsE;AACtE,qBAAa,cAAe,SAAQ,mBAKlC;CAAG;AAEL,MAAM,MAAM,kBAAkB,GAAG,eAAe,GAAG,cAAc,CAAC;AAMlE,eAAO,MAAM,iBAAiB,iDAAgD,CAAC;AAC/E,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAC,IAAI,CAAC;;;IAI5D,mEAAmE;;;;IAAnE,mEAAmE;;;;;;;;;AAFrE,qBAAa,mBAAoB,SAAQ,wBAIvC;CAAG;AAML,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;CACtC;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,kBAAkB,KAAK,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;;;;;;;AAMjG,qBAAa,wBAAyB,SAAQ,6BAM7C;CAAG"}
1
+ {"version":3,"file":"elicitation.d.ts","sourceRoot":"","sources":["../src/elicitation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;;;IAS7B,mDAAmD;;;AAHrD,gEAAgE;AAChE,qBAAa,eAAgB,SAAQ,oBAInC;CAAG;;;;IAMH,uDAAuD;;;AAJzD,sEAAsE;AACtE,qBAAa,cAAe,SAAQ,mBAKlC;CAAG;AAEL,MAAM,MAAM,kBAAkB,GAAG,eAAe,GAAG,cAAc,CAAC;AAMlE,eAAO,MAAM,iBAAiB,2DAAmD,CAAC;AAClF,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAC,IAAI,CAAC;;;IAI5D,mEAAmE;;;AAFrE,qBAAa,mBAAoB,SAAQ,wBAIvC;CAAG;AAML,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;CACtC;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,kBAAkB,KAAK,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;;;;;AAMjG,qBAAa,wBAAyB,SAAQ,6BAM7C;CAAG"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=error-handling.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handling.test.d.ts","sourceRoot":"","sources":["../src/error-handling.test.ts"],"names":[],"mappings":""}