@executor-js/sdk 1.5.13 → 1.5.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -19,6 +19,8 @@ import {
19
19
  ORG_SUBJECT,
20
20
  StorageError,
21
21
  TOOL_POLICY_ACTIONS,
22
+ ToolFileJsonSchema,
23
+ ToolFileSchema,
22
24
  ToolResult,
23
25
  UniqueViolationError,
24
26
  annotateToolResultOutcome,
@@ -36,6 +38,7 @@ import {
36
38
  executorOwnerPolicyName,
37
39
  executorUnscopedPolicyName,
38
40
  isStorageFailure,
41
+ isToolFile,
39
42
  isToolPolicyAction,
40
43
  isToolResult,
41
44
  jsonColumn,
@@ -53,7 +56,7 @@ import {
53
56
  textColumn,
54
57
  tool,
55
58
  toolAddress
56
- } from "./chunk-WKKKHDH2.js";
59
+ } from "./chunk-QEKKFEJL.js";
57
60
  import {
58
61
  ConnectionNotFoundError,
59
62
  CredentialProviderNotRegisteredError,
@@ -347,6 +350,8 @@ export {
347
350
  Tenant,
348
351
  ToolAddress,
349
352
  ToolBlockedError,
353
+ ToolFileJsonSchema,
354
+ ToolFileSchema,
350
355
  ToolInvocationError,
351
356
  ToolName,
352
357
  ToolNotFoundError,
@@ -383,6 +388,7 @@ export {
383
388
  isConnectionIdentifier,
384
389
  isOAuthPopupResult,
385
390
  isStorageFailure,
391
+ isToolFile,
386
392
  isToolPolicyAction,
387
393
  isToolResult,
388
394
  isValidPattern,
package/dist/core.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/integration.ts","../src/sqlite-data-migrations.ts","../src/sqlite-config-blob-migration.ts","../src/auth-tool-failure.ts"],"sourcesContent":["// ---------------------------------------------------------------------------\n// @executor-js/sdk — public surface (v2)\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`.\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// FumaDB integration.\nexport { fumadb } from \"@executor-js/fumadb\";\nexport type { FumaDB } from \"@executor-js/fumadb\";\nexport type { AbstractQuery, Condition, ConditionBuilder } from \"@executor-js/fumadb/query\";\nexport { column, idColumn, schema as fumaSchema, table } from \"@executor-js/fumadb/schema\";\nexport type {\n AnyColumn,\n AnySchema,\n AnyTable,\n Column,\n Schema as FumaSchema,\n} from \"@executor-js/fumadb/schema\";\n\nexport type {\n FumaDb,\n FumaQuery,\n FumaRow,\n FumaTables,\n IFumaClient,\n StorageFailure,\n} from \"./fuma-runtime\";\nexport { StorageError, UniqueViolationError, isStorageFailure } from \"./fuma-runtime\";\n\n// IDs (branded) — the v2 set.\nexport {\n IntegrationSlug,\n AuthTemplateSlug,\n ConnectionName,\n OAuthClientSlug,\n OAuthState,\n ProviderKey,\n ProviderItemId,\n ConnectionAddress,\n ToolAddress,\n ToolName,\n ElicitationId,\n PolicyId,\n Tenant,\n Subject,\n Owner,\n} from \"./ids\";\nexport { connectionIdentifier, isConnectionIdentifier } from \"./connection-name-identifier\";\n\n// Errors (tagged) — the ExecuteError set + integration lifecycle.\nexport {\n ToolNotFoundError,\n ToolInvocationError,\n ToolBlockedError,\n NoHandlerError,\n PluginNotLoadedError,\n IntegrationNotFoundError,\n IntegrationAlreadyExistsError,\n IntegrationRemovalNotAllowedError,\n ConnectionNotFoundError,\n CredentialProviderNotRegisteredError,\n CredentialResolutionError,\n type ExecuteError,\n type ExecutorError,\n} from \"./errors\";\n\n// Integration / connection / tool domain contracts.\nexport type {\n AuthMethodDescriptor,\n AuthMethodOAuthDescriptor,\n AuthPlacementDescriptor,\n Integration,\n IntegrationConfig,\n IntegrationDisplayDescriptor,\n RegisterIntegrationInput,\n} from \"./integration\";\nexport { freshCustomAuthSlug, mergeAuthTemplates } from \"./integration\";\nexport type {\n Connection,\n ConnectionRef,\n ConnectionValueInput,\n CreateConnectionInput,\n UpdateConnectionInput,\n} from \"./connection\";\nexport type { Tool, ToolDef, ToolListFilter, ToolAnnotations } from \"./tool\";\n\n// Credential providers.\nexport type { CredentialProvider, ProviderEntry } from \"./provider\";\n\n// Public projections / detection.\nexport { ToolSchemaView, IntegrationDetectionResult } from \"./types\";\n\n// Core schema.\nexport {\n bigintColumn,\n boolColumn,\n coreSchema,\n coreTables,\n dateColumn,\n isToolPolicyAction,\n jsonColumn,\n keyColumn,\n nullableBigintColumn,\n nullableJsonColumn,\n nullableKeyColumn,\n nullableTextColumn,\n textColumn,\n TOOL_POLICY_ACTIONS,\n type CoreSchema,\n type IntegrationRow,\n type ConnectionRow,\n type OAuthClientRow,\n type OAuthSessionRow,\n type ToolRow,\n type ToolInvocationRow,\n type DefinitionRow,\n type ToolPolicyRow,\n type PluginStorageRow,\n type BlobRow,\n type ToolPolicyAction,\n} from \"./core-schema\";\n\n// Owner policy.\nexport {\n ORG_SUBJECT,\n executorOwnerPolicyName,\n executorUnscopedPolicyName,\n type ExecutorOwnerPolicyContext,\n} from \"./owner-policy\";\n\n// Tool policies.\nexport {\n matchPattern,\n isValidPattern,\n effectivePolicyFromSorted,\n ToolPolicyActionSchema,\n type ToolPolicy,\n type CreateToolPolicyInput,\n type UpdateToolPolicyInput,\n type RemoveToolPolicyInput,\n type PolicyMatch,\n type EffectivePolicy,\n type PolicySource,\n} from \"./policies\";\n\n// Elicitation.\nexport {\n FormElicitation,\n UrlElicitation,\n ElicitationAction,\n ElicitationResponse,\n ElicitationDeclinedError,\n type ElicitationRequest,\n type ElicitationHandler,\n type ElicitationContext,\n type OnElicitation,\n type InvokeOptions,\n} from \"./elicitation\";\n\n// Blob store — the plugin-facing contract (`BlobStore`/`PluginBlobStore`)\n// plus the platform-neutral backends (`makeFumaBlobStore` default,\n// `makeInMemoryBlobStore` for tests). Platform-specific backends live with\n// their host (R2: `@executor-js/cloudflare/blob-store`).\nexport {\n pluginBlobStore,\n makeInMemoryBlobStore,\n makeFumaBlobStore,\n sha256Hex,\n type BlobStore,\n type PluginBlobStore,\n type OwnerPartitions,\n} from \"./blob\";\n\n// Plugin storage.\nexport {\n definePluginStorageCollection,\n pluginStorageId,\n type PluginStorageCollectionDefinition,\n type PluginStorageCollectionFacade,\n type PluginStorageCollectionIndexedField,\n type PluginStorageCollectionKeyInput,\n type PluginStorageCollectionListInput,\n type PluginStorageCollectionOrderBy,\n type PluginStorageCollectionPutInput,\n type PluginStorageCollectionQueryInput,\n type PluginStorageCollectionScopedKeyInput,\n type PluginStorageCollectionWhere,\n type PluginStorageConfig,\n type PluginStorageEntry,\n type PluginStorageFacade,\n type PluginStorageIndexField,\n type PluginStorageIndexSpec,\n type PluginStorageKeyInput,\n type PluginStorageListInput,\n type PluginStoragePutInput,\n type PluginStorageRuntimeCollectionDefinition,\n type PluginStorageRuntimeIndexSpec,\n type PluginStorageSchema,\n type PluginStorageSchemaType,\n type PluginStorageScopedKeyInput,\n type PluginStorageWhereFilter,\n type PluginStorageWhereValue,\n} from \"./plugin-storage\";\n\n// OAuth (v2 contracts).\nexport { OAUTH2_PROVIDER_KEY, OAUTH2_SESSION_TTL_MS } from \"./oauth\";\nexport {\n OAuthStartError,\n OAuthCompleteError,\n OAuthProbeError,\n OAuthRegisterDynamicError,\n OAuthSessionNotFoundError,\n type OAuthGrant,\n type OAuthAuthentication,\n type OAuthClient,\n type OAuthClientSummary,\n type CreateOAuthClientInput,\n type RegisterDynamicClientInput,\n type ConnectResult,\n type OAuthStartInput,\n type OAuthCompleteInput,\n type OAuthProbeInput,\n type OAuthProbeResult,\n type OAuthService,\n} from \"./oauth-client\";\n\n// NOTE: the OAuth 2.1 implementation helpers (`./oauth-helpers`,\n// `makeOAuthService` in `./oauth-service`, discovery in `./oauth-discovery`)\n// are SDK-internal — consumed only by `createExecutor`. The hosted HTTP client\n// builder is host-internal and reachable via `@executor-js/sdk/host-internal`.\n\nexport {\n DEFAULT_EXECUTOR_SERVER_ORIGIN,\n DEFAULT_EXECUTOR_SERVER_USERNAME,\n apiBaseUrlForServerOrigin,\n getExecutorServerAuthorizationHeader,\n normalizeExecutorServerConnection,\n normalizeExecutorServerOrigin,\n originFromApiBaseUrl,\n type ExecutorServerAuth,\n type ExecutorServerConnection,\n type ExecutorServerConnectionInput,\n type ExecutorServerConnectionKind,\n} from \"./server-connection\";\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 OwnerBinding,\n type IntegrationRecord,\n type StaticSourceDecl,\n type StaticToolDecl,\n type StaticToolSchema,\n type StaticToolExecuteContext,\n type StaticToolHandlerInput,\n type StaticToolInput,\n type ConfigureIntegrationHandlerInput,\n type InvokeToolInput,\n type ConnectionLifecycleInput,\n type IntegrationConfigureDecl,\n type IntegrationConfigureSchema,\n type IntegrationPreset,\n type IntegrationPresetCatalogEntry,\n type ResolveToolsInput,\n type ResolveToolsResult,\n type ToolInvocationCredential,\n type Elicit,\n definePlugin,\n tool,\n} from \"./plugin\";\n\n// Executor.\n//\n// `collectTables` is host/tooling-only (cli schema cmd, kernel worker,\n// local/cloud DB bring-up). Its definition stays here because `createExecutor`\n// uses it; the host surface (`@executor-js/api/server`) re-exports it.\nexport {\n type Executor,\n type ExecutorConfig,\n type ExecutorDb,\n type ExecutorDbFactory,\n type ExecutorDbInput,\n type ParsedToolAddress,\n createExecutor,\n collectTables,\n parseToolAddress,\n connectionAddress,\n toolAddress,\n} from \"./executor\";\n\n// CLI / runtime config.\nexport {\n defineExecutorConfig,\n type ExecutorCliConfig,\n type ExecutorPluginsFactory,\n} from \"./config\";\n\n// The one TS-preview generator plugins assert against.\nexport { buildToolTypeScriptPreview } from \"./schema-types\";\n\n// Wire-level HTTP error schemas usable by plugin HttpApiGroup definitions.\nexport { InternalError } from \"./api-errors\";\n\n// ToolResult — typed value-based discriminated union for tool outcomes.\nexport {\n ToolResult,\n annotateToolResultOutcome,\n isToolResult,\n type ToolError,\n type ToolHttpMeta,\n} from \"./tool-result\";\n\n// Stamped boot-time data-migration ledger for the libSQL-backed apps.\nexport {\n DataMigrationError,\n DuplicateDataMigrationError,\n runSqliteDataMigrations,\n sqliteDataMigration,\n type SqliteDataMigration,\n type SqliteDataMigrationClient,\n} from \"./sqlite-data-migrations\";\n// Shared inline-config-field → blob-table migration body; the protocol\n// plugins bind their field names and export the ledger entries.\nexport {\n runSqliteConfigBlobMigration,\n type SqliteConfigBlobMigrationOptions,\n} from \"./sqlite-config-blob-migration\";\nexport {\n authToolFailure,\n type AuthToolFailureCode,\n type AuthToolFailureInput,\n} from \"./auth-tool-failure\";\n","import type { IntegrationSlug } from \"./ids\";\n\n/* Core knows only an integration's catalog identity — slug + description + which\n * plugin (`kind`) owns it. The type-specific shape (openapi auth templates + spec,\n * an mcp url, …) lives in the plugin and is stored as an opaque `config` blob core\n * never parses. An integration is one API surface; multi-API providers (Google)\n * are bundled into a single integration by their plugin, so one credential covers\n * the whole provider. */\n\n// ---------------------------------------------------------------------------\n// Declared auth methods — a plugin-agnostic projection of an integration's\n// stored `config` into the catalog response. Each plugin derives these from its\n// own opaque config (`describeAuthMethods`); core never parses config itself.\n// The client renders these as the integration's selectable auth methods, so the\n// catalog is authoritative even when the integration has zero connections.\n//\n// This is a DERIVED projection — there is no DB column. A plugin that declares\n// no projector contributes `[]`, and the client falls through to its existing\n// connection-inference behavior (no regression).\n// ---------------------------------------------------------------------------\n\nexport interface IntegrationDisplayDescriptor {\n /** Non-secret URL suitable for display metadata such as favicons. */\n readonly url?: string;\n}\n\n/** Where a credential value is carried on the outbound request. Mirrors the\n * client's `Placement`. */\nexport interface AuthPlacementDescriptor {\n readonly carrier: \"header\" | \"query\";\n readonly name: string;\n /** Literal prepended to the value (e.g. `\"Bearer \"`). Empty when bare. */\n readonly prefix: string;\n /** The input variable this placement renders from. `token` for single-input\n * methods; a distinct name per input for multi-input ones (e.g. Datadog).\n * Absent → treated as `token`. */\n readonly variable?: string;\n /** Set when the placement renders this exact value instead of a credential\n * (a static header/param the method carries). Such placements reference no\n * input variable. */\n readonly literal?: string;\n}\n\n/** OAuth specifics for an `oauth` auth method. For probe-at-connect providers\n * (MCP) only `discoveryUrl` + `supportsDynamicRegistration` are known up front;\n * the authorize/token endpoints are discovered live at connect time. For\n * providers that store endpoints (OpenAPI) the resolved URLs are carried. */\nexport interface AuthMethodOAuthDescriptor {\n /** For probe-at-connect providers (MCP): the endpoint to discover metadata\n * from (RFC 9728 PRM → RFC 8414 AS metadata). */\n readonly discoveryUrl?: string;\n readonly authorizationUrl?: string;\n readonly tokenUrl?: string;\n readonly scopes?: readonly string[];\n readonly registrationEndpoint?: string;\n /** True when the integration is known to support RFC 7591 dynamic client\n * registration (drives the transparent auto-register connect flow). */\n readonly supportsDynamicRegistration?: boolean;\n}\n\n/** A single declared auth method on an integration's catalog response. */\nexport interface AuthMethodDescriptor {\n /** Stable id within the integration (e.g. the auth template slug). */\n readonly id: string;\n readonly label: string;\n readonly kind: \"oauth\" | \"apikey\" | \"header\" | \"none\";\n /** The auth-template slug a connection binds against. */\n readonly template: string;\n readonly placements?: readonly AuthPlacementDescriptor[];\n readonly oauth?: AuthMethodOAuthDescriptor;\n}\n\n/** Public projection of an integration — what `integrations.list/get` return.\n * Carries no credentials and no plugin-internal config. */\nexport interface Integration {\n readonly slug: IntegrationSlug;\n /** Display name. Pre-split rows stored the name in `description`; readers\n * fall back, so this is always populated. */\n readonly name: string;\n /** Agent-visible context (\"what this API is and when to reach for it\").\n * Distinct from the display name; may equal it on legacy rows. */\n readonly description: string;\n /** The plugin that owns this integration kind (e.g. \"openapi\", \"mcp\"). */\n readonly kind: string;\n /** Whether the user can remove this integration from the catalog. `false`\n * for static / built-in integrations declared by a plugin at startup. */\n readonly canRemove: boolean;\n /** Whether the owning plugin supports re-resolving a connection's tools\n * (`connections.refresh`). */\n readonly canRefresh: boolean;\n /** Declared auth methods derived from the owning plugin's stored config (a\n * derived projection, not a DB column). Always present, possibly empty. */\n readonly authMethods: readonly AuthMethodDescriptor[];\n /** Non-secret display URL derived by the owning plugin from opaque config.\n * Used for catalog favicons; never includes credentials or plugin config. */\n readonly displayUrl?: string;\n}\n\n/** Plugin-owned, opaque-to-core configuration stored on the integration row. The\n * owning plugin writes it at register time and reads it back at execute time to\n * render auth / produce tools. Core treats it as an opaque JSON blob. */\nexport type IntegrationConfig = unknown;\n\n// ---------------------------------------------------------------------------\n// Auth-template merge — shared by every plugin whose config carries a slugged\n// `authenticationTemplate` array (openapi, graphql, mcp). The custom-method\n// flow merge-appends: an incoming entry with a matching slug replaces the\n// existing entry in place; entries lacking a slug (or colliding with another\n// entry added in the same call) get a fresh `custom_<id>` slug.\n// ---------------------------------------------------------------------------\n\nconst shortId = (): string => Math.random().toString(36).slice(2, 8);\n\nexport const freshCustomAuthSlug = (taken: ReadonlySet<string>): string => {\n let candidate = `custom_${shortId()}`;\n while (taken.has(candidate)) candidate = `custom_${shortId()}`;\n return candidate;\n};\n\nexport const mergeAuthTemplates = <T extends { readonly slug: string }>(\n existing: readonly T[],\n incoming: readonly T[],\n): readonly T[] => {\n const result: T[] = existing.map((entry: T) => entry);\n const taken = new Set<string>(result.map((entry: T) => String(entry.slug)));\n for (const entry of incoming) {\n // `slug` may be branded-required in the plugin's schema, but JSON callers\n // can submit it empty/blank — read defensively and backfill so every\n // stored template has a stable slug.\n const rawSlug = (entry as { readonly slug?: unknown }).slug;\n const requested = typeof rawSlug === \"string\" ? rawSlug.trim() : \"\";\n const existingIndex = result.findIndex((current: T) => String(current.slug) === requested);\n if (requested.length > 0 && existingIndex >= 0) {\n result[existingIndex] = entry;\n continue;\n }\n const slug =\n requested.length > 0 && !taken.has(requested) ? requested : freshCustomAuthSlug(taken);\n taken.add(slug);\n result.push({ ...entry, slug } as T);\n }\n return result;\n};\n\n/** What a plugin's extension method passes to `ctx.core.integrations.register`.\n * The v2 analog of v1's `SourceInput`, minus the per-source tool list (tools are\n * produced per-connection now). */\nexport interface RegisterIntegrationInput {\n readonly slug: IntegrationSlug;\n /** Display name. Falls back to `description` then the slug when omitted\n * (legacy callers registered with description-as-name). */\n readonly name?: string;\n readonly description: string;\n /** Opaque plugin config (auth templates, spec ref, mcp url, …). */\n readonly config: IntegrationConfig;\n readonly canRemove?: boolean;\n readonly canRefresh?: boolean;\n}\n","// ---------------------------------------------------------------------------\n// Stamped data-migration ledger for the libSQL-backed apps (local boot,\n// selfhost boot). Cloud runs schema + data migrations through its drizzle\n// chain out-of-band; the local apps have no operator, so their migrations\n// run at boot — and before this ledger existed, each one re-scanned its\n// tables on every startup to decide \"did I already run?\" by data shape.\n// That accumulates (N migrations = N full-table scans per boot, forever)\n// and makes idempotence a per-migration proof obligation.\n//\n// This is the rail instead: a `data_migration` table (name → completion\n// time), an ordered registry the app composes, and a runner that executes\n// each pending migration once and stamps it. Stamped names are skipped\n// without touching the data.\n//\n// Write migrations idempotently anyway (defense in depth — the support\n// remedy for a half-applied state is deleting the stamp row and\n// rebooting). One deliberate semantics change from the scan-every-boot\n// era: after a migration is stamped, rows written later by an OLDER binary\n// (downgrade, then re-upgrade) are NOT re-healed. That matches the cloud\n// chain's semantics; the stamp row, not the data shape, is the source of\n// truth.\n// ---------------------------------------------------------------------------\n\nimport { Data, Effect } from \"effect\";\n\n/** Structural client interface so this module stays dependency-free;\n * `@libsql/client` satisfies it. */\nexport interface SqliteDataMigrationClient {\n execute(\n stmt: string | { readonly sql: string; readonly args: readonly unknown[] },\n ): Promise<{ readonly rows: readonly Record<string, unknown>[] }>;\n}\n\nexport class DataMigrationError extends Data.TaggedError(\"DataMigrationError\")<{\n /** The migration that failed, or null when the ledger itself did. */\n readonly migration: string | null;\n readonly cause: unknown;\n}> {}\n\nexport class DuplicateDataMigrationError extends Data.TaggedError(\"DuplicateDataMigrationError\")<{\n readonly name: string;\n}> {}\n\nexport interface SqliteDataMigration {\n /** Stable unique id, date-prefixed so the registry reads in order\n * (e.g. \"2026-06-05-auth-config-placements\"). Renaming an applied\n * migration re-runs it — never rename. */\n readonly name: string;\n readonly run: (client: SqliteDataMigrationClient) => Effect.Effect<void, DataMigrationError>;\n}\n\nconst LEDGER_TABLE = \"data_migration\";\n\nconst execute = (\n client: SqliteDataMigrationClient,\n stmt: string | { readonly sql: string; readonly args: readonly unknown[] },\n migration: string | null,\n) =>\n Effect.tryPromise({\n try: () => client.execute(stmt),\n catch: (cause) => new DataMigrationError({ migration, cause }),\n });\n\n/** Wrap a promise-shaped migration body as a registry entry. */\nexport const sqliteDataMigration = (\n name: string,\n run: (client: SqliteDataMigrationClient) => Promise<unknown>,\n): SqliteDataMigration => ({\n name,\n run: (client) =>\n Effect.tryPromise({\n try: () => run(client),\n catch: (cause) => new DataMigrationError({ migration: name, cause }),\n }).pipe(Effect.asVoid),\n});\n\n/**\n * Run every registry entry whose name has no stamp row, in registry order,\n * stamping each on success. Returns the applied names.\n *\n * Atomicity is the migration's own job (the existing migrations run their\n * rewrites inside BEGIN…COMMIT), so the runner does not wrap them — SQLite\n * has no nested transactions. The stamp is written after the migration\n * succeeds; a crash between the two re-runs the (idempotent) migration on\n * the next boot, which is a no-op. A failed migration leaves no stamp and\n * fails the boot.\n */\nexport const runSqliteDataMigrations = (\n client: SqliteDataMigrationClient,\n migrations: readonly SqliteDataMigration[],\n): Effect.Effect<readonly string[], DataMigrationError | DuplicateDataMigrationError> =>\n Effect.gen(function* () {\n const names = new Set<string>();\n for (const migration of migrations) {\n if (names.has(migration.name)) {\n return yield* new DuplicateDataMigrationError({ name: migration.name });\n }\n names.add(migration.name);\n }\n\n yield* execute(\n client,\n `CREATE TABLE IF NOT EXISTS ${LEDGER_TABLE} (name TEXT PRIMARY KEY, time_completed INTEGER NOT NULL)`,\n null,\n );\n const stamped = yield* execute(client, `SELECT name FROM ${LEDGER_TABLE}`, null);\n const completed = new Set(\n stamped.rows.map((row) => row.name).filter((name) => typeof name === \"string\"),\n );\n\n const applied: string[] = [];\n for (const migration of migrations) {\n if (completed.has(migration.name)) continue;\n yield* migration.run(client);\n yield* execute(\n client,\n {\n sql: `INSERT INTO ${LEDGER_TABLE} (name, time_completed) VALUES (?, ?)`,\n args: [migration.name, Date.now()],\n },\n migration.name,\n );\n applied.push(migration.name);\n }\n return applied;\n });\n","// ---------------------------------------------------------------------------\n// Data migration: move an oversized inline `integration.config` field into\n// the blob table. The shape both protocol plugins need is identical — only\n// the field names differ — so the body lives here and each plugin exports a\n// ledger entry that binds its constants (openapi: spec → specHash under\n// `spec/<hash>`; graphql: introspectionJson → introspectionHash under\n// `introspection/<hash>`).\n//\n// Blob rows are written with the EXACT naming `makeFumaBlobStore` +\n// `pluginBlobStore` read back at runtime: namespace `o:<tenant>/<pluginId>`\n// (the org partition — integration configs are catalog-level), key\n// `<prefix>/<sha256>`, id `JSON.stringify([namespace, key])`. That makes it\n// correct ONLY for hosts whose runtime blob backend is the FumaDB store\n// (local, selfhost) — a host that reads blobs elsewhere (the D1 host reads\n// R2) must not register it, or the rewritten pointers would dangle.\n//\n// Idempotent: pointer-shaped configs (no inline field) plan zero updates,\n// and blob writes are content-addressed upserts.\n// ---------------------------------------------------------------------------\n\nimport { Effect, Option, Schema } from \"effect\";\n\nimport { sha256Hex } from \"./blob\";\nimport { DataMigrationError, type SqliteDataMigrationClient } from \"./sqlite-data-migrations\";\n\nexport interface SqliteConfigBlobMigrationOptions {\n /** The ledger entry name, for error attribution. */\n readonly migrationName: string;\n /** Rows whose `plugin_id` equals this are candidates. */\n readonly pluginId: string;\n /** The config field holding the inline text to move (e.g. `spec`). */\n readonly inlineField: string;\n /** The config field that will carry the content hash (e.g. `specHash`). */\n readonly hashField: string;\n /** Blob key prefix; the key is `<prefix>/<sha256>` (e.g. `spec`). */\n readonly blobKeyPrefix: string;\n}\n\nconst decodeJsonOption = Schema.decodeUnknownOption(Schema.UnknownFromJsonString);\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n/**\n * Move every inline `options.inlineField` in this plugin's integration\n * configs into the blob table and rewrite the config to carry\n * `options.hashField`. Returns the number of rows rewritten. The\n * `integration` table may not exist yet on a fresh database — that counts\n * as nothing to migrate.\n */\nexport const runSqliteConfigBlobMigration = (\n client: SqliteDataMigrationClient,\n options: SqliteConfigBlobMigrationOptions,\n): Effect.Effect<number, DataMigrationError> =>\n Effect.gen(function* () {\n const execute = (stmt: string | { readonly sql: string; readonly args: readonly unknown[] }) =>\n Effect.tryPromise({\n try: () => client.execute(stmt),\n catch: (cause) => new DataMigrationError({ migration: options.migrationName, cause }),\n });\n\n const exists = yield* execute(\n \"SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'integration'\",\n );\n if (exists.rows.length === 0) return 0;\n\n const result = yield* execute({\n sql: \"SELECT row_id, tenant, config FROM integration WHERE plugin_id = ? AND config IS NOT NULL\",\n args: [options.pluginId],\n });\n\n interface PlannedMove {\n readonly rowId: string;\n readonly namespace: string;\n readonly key: string;\n readonly blobId: string;\n readonly inlineText: string;\n readonly nextConfig: string;\n }\n const moves: PlannedMove[] = [];\n for (const row of result.rows) {\n if (typeof row.row_id !== \"string\" || typeof row.tenant !== \"string\") continue;\n if (typeof row.config !== \"string\") continue;\n const decoded = decodeJsonOption(row.config);\n if (Option.isNone(decoded) || !isRecord(decoded.value)) continue;\n const inline = decoded.value[options.inlineField];\n if (typeof inline !== \"string\") continue;\n\n const hash = yield* sha256Hex(inline);\n const namespace = `o:${row.tenant}/${options.pluginId}`;\n const key = `${options.blobKeyPrefix}/${hash}`;\n const { [options.inlineField]: _removed, ...rest } = decoded.value;\n moves.push({\n rowId: row.row_id,\n namespace,\n key,\n blobId: JSON.stringify([namespace, key]),\n inlineText: inline,\n nextConfig: JSON.stringify({ ...rest, [options.hashField]: hash }),\n });\n }\n if (moves.length === 0) return 0;\n\n const applyAll = Effect.gen(function* () {\n for (const move of moves) {\n const existing = yield* execute({\n sql: \"SELECT row_id FROM blob WHERE id = ?\",\n args: [move.blobId],\n });\n if (existing.rows.length === 0) {\n yield* execute({\n sql: \"INSERT INTO blob (namespace, key, value, row_id, id) VALUES (?, ?, ?, ?, ?)\",\n args: [move.namespace, move.key, move.inlineText, crypto.randomUUID(), move.blobId],\n });\n } else {\n yield* execute({\n sql: \"UPDATE blob SET value = ? WHERE id = ?\",\n args: [move.inlineText, move.blobId],\n });\n }\n yield* execute({\n sql: \"UPDATE integration SET config = ? WHERE row_id = ?\",\n args: [move.nextConfig, move.rowId],\n });\n }\n yield* execute(\"COMMIT\");\n });\n\n yield* execute(\"BEGIN\");\n yield* applyAll.pipe(Effect.tapError(() => execute(\"ROLLBACK\").pipe(Effect.ignore)));\n return moves.length;\n });\n","import { ToolResult, type ToolError } from \"./tool-result\";\n\nexport type AuthToolFailureCode =\n | \"connection_value_missing\"\n | \"connection_rejected\"\n | \"oauth_connection_missing\"\n | \"oauth_refresh_failed\"\n | \"oauth_reauth_required\";\n\nexport type AuthToolFailureInput = {\n readonly code: AuthToolFailureCode;\n readonly message: string;\n readonly source?: {\n readonly id: string;\n readonly scope?: string;\n };\n readonly credential?: {\n readonly kind: \"secret\" | \"oauth\" | \"upstream\";\n readonly label?: string;\n readonly slotKey?: string;\n readonly secretId?: string;\n readonly connectionId?: string;\n };\n readonly status?: number;\n readonly upstream?: {\n readonly status?: number;\n readonly details?: unknown;\n };\n readonly recovery?: {\n readonly configureSourceTool?: string;\n };\n};\n\n// In v1.5 a connection IS the credential: there is no standalone secret to\n// \"bind\" to a source afterward. Manually-entered credentials are created via\n// the connection handoff (the user enters the value in the web UI, which\n// creates the bound connection in one step); OAuth credentials are minted by\n// the OAuth start flow. These strings are read by the agent resolving the\n// failure, so they must name tools that actually exist on the executor.\nconst authRecovery = (input?: AuthToolFailureInput[\"recovery\"]) => ({\n createConnectionTool: \"executor.coreTools.connections.createHandoff\",\n startOAuthTool: \"executor.coreTools.oauth.start\",\n listConnectionsTool: \"executor.coreTools.connections.list\",\n ...(input?.configureSourceTool ? { configureSourceTool: input.configureSourceTool } : {}),\n connectionInstructions:\n \"For API keys and tokens, call createConnectionTool for the integration to get a browser URL; the user enters the credential there, which creates the bound connection. Do not ask the user to paste secrets into chat. Then call listConnectionsTool to confirm the connection exists before retrying this tool.\",\n oauthInstructions:\n \"For OAuth credentials, call startOAuthTool and give the returned authorizationUrl to the user. The completed connection binds automatically, then retry the tool.\",\n});\n\nexport const authToolFailure = <T = never>(input: AuthToolFailureInput): ToolResult<T> => {\n const error: ToolError = {\n code: input.code,\n message: input.message,\n retryable: false,\n ...(input.status !== undefined ? { status: input.status } : {}),\n details: {\n category: \"authentication\",\n ...(input.source ? { source: input.source } : {}),\n ...(input.credential ? { credential: input.credential } : {}),\n ...(input.upstream ? { upstream: input.upstream } : {}),\n recovery: authRecovery(input.recovery),\n },\n };\n return ToolResult.fail(error);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,SAAS,SAAS,UAAAA,SAAQ,OAAO,UAAAC,SAAQ,QAAAC,OAAM,UAAAC,eAAc;AAC7D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,cAAc;AAGvB,SAAS,QAAQ,UAAoB,QAAY,aAAa;;;AC0F9D,IAAM,UAAU,MAAc,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,CAAC;AAE5D,IAAM,sBAAsB,CAAC,UAAuC;AACzE,MAAI,YAAY,UAAU,QAAQ,CAAC;AACnC,SAAO,MAAM,IAAI,SAAS,EAAG,aAAY,UAAU,QAAQ,CAAC;AAC5D,SAAO;A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,CAAC;AAAA,MAC3D,GAAI,MAAM,WAAW,EAAE,UAAU,MAAM,SAAS,IAAI,CAAC;AAAA,MACrD,UAAU,aAAa,MAAM,QAAQ;AAAA,IACvC;AAAA,EACF;AACA,SAAO,WAAW,KAAK,KAAK;AAC9B;","names":["Effect","Schema","Data","Option","Effect","Effect","execute"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/integration.ts","../src/sqlite-data-migrations.ts","../src/sqlite-config-blob-migration.ts","../src/auth-tool-failure.ts"],"sourcesContent":["// ---------------------------------------------------------------------------\n// @executor-js/sdk — public surface (v2)\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`.\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// FumaDB integration.\nexport { fumadb } from \"@executor-js/fumadb\";\nexport type { FumaDB } from \"@executor-js/fumadb\";\nexport type { AbstractQuery, Condition, ConditionBuilder } from \"@executor-js/fumadb/query\";\nexport { column, idColumn, schema as fumaSchema, table } from \"@executor-js/fumadb/schema\";\nexport type {\n AnyColumn,\n AnySchema,\n AnyTable,\n Column,\n Schema as FumaSchema,\n} from \"@executor-js/fumadb/schema\";\n\nexport type {\n FumaDb,\n FumaQuery,\n FumaRow,\n FumaTables,\n IFumaClient,\n StorageFailure,\n} from \"./fuma-runtime\";\nexport { StorageError, UniqueViolationError, isStorageFailure } from \"./fuma-runtime\";\n\n// IDs (branded) — the v2 set.\nexport {\n IntegrationSlug,\n AuthTemplateSlug,\n ConnectionName,\n OAuthClientSlug,\n OAuthState,\n ProviderKey,\n ProviderItemId,\n ConnectionAddress,\n ToolAddress,\n ToolName,\n ElicitationId,\n PolicyId,\n Tenant,\n Subject,\n Owner,\n} from \"./ids\";\nexport { connectionIdentifier, isConnectionIdentifier } from \"./connection-name-identifier\";\n\n// Errors (tagged) — the ExecuteError set + integration lifecycle.\nexport {\n ToolNotFoundError,\n ToolInvocationError,\n ToolBlockedError,\n NoHandlerError,\n PluginNotLoadedError,\n IntegrationNotFoundError,\n IntegrationAlreadyExistsError,\n IntegrationRemovalNotAllowedError,\n ConnectionNotFoundError,\n CredentialProviderNotRegisteredError,\n CredentialResolutionError,\n type ExecuteError,\n type ExecutorError,\n} from \"./errors\";\n\n// Integration / connection / tool domain contracts.\nexport type {\n AuthMethodDescriptor,\n AuthMethodOAuthDescriptor,\n AuthPlacementDescriptor,\n Integration,\n IntegrationConfig,\n IntegrationDisplayDescriptor,\n RegisterIntegrationInput,\n} from \"./integration\";\nexport { freshCustomAuthSlug, mergeAuthTemplates } from \"./integration\";\nexport type {\n Connection,\n ConnectionRef,\n ConnectionValueInput,\n CreateConnectionInput,\n UpdateConnectionInput,\n} from \"./connection\";\nexport type { Tool, ToolDef, ToolListFilter, ToolAnnotations } from \"./tool\";\n\n// Credential providers.\nexport type { CredentialProvider, ProviderEntry } from \"./provider\";\n\n// Public projections / detection.\nexport { ToolSchemaView, IntegrationDetectionResult } from \"./types\";\n\n// Core schema.\nexport {\n bigintColumn,\n boolColumn,\n coreSchema,\n coreTables,\n dateColumn,\n isToolPolicyAction,\n jsonColumn,\n keyColumn,\n nullableBigintColumn,\n nullableJsonColumn,\n nullableKeyColumn,\n nullableTextColumn,\n textColumn,\n TOOL_POLICY_ACTIONS,\n type CoreSchema,\n type IntegrationRow,\n type ConnectionRow,\n type OAuthClientRow,\n type OAuthSessionRow,\n type ToolRow,\n type ToolInvocationRow,\n type DefinitionRow,\n type ToolPolicyRow,\n type PluginStorageRow,\n type BlobRow,\n type ToolPolicyAction,\n} from \"./core-schema\";\n\n// Owner policy.\nexport {\n ORG_SUBJECT,\n executorOwnerPolicyName,\n executorUnscopedPolicyName,\n type ExecutorOwnerPolicyContext,\n} from \"./owner-policy\";\n\n// Tool policies.\nexport {\n matchPattern,\n isValidPattern,\n effectivePolicyFromSorted,\n ToolPolicyActionSchema,\n type ToolPolicy,\n type CreateToolPolicyInput,\n type UpdateToolPolicyInput,\n type RemoveToolPolicyInput,\n type PolicyMatch,\n type EffectivePolicy,\n type PolicySource,\n} from \"./policies\";\n\n// Elicitation.\nexport {\n FormElicitation,\n UrlElicitation,\n ElicitationAction,\n ElicitationResponse,\n ElicitationDeclinedError,\n type ElicitationRequest,\n type ElicitationHandler,\n type ElicitationContext,\n type OnElicitation,\n type InvokeOptions,\n} from \"./elicitation\";\n\n// Blob store — the plugin-facing contract (`BlobStore`/`PluginBlobStore`)\n// plus the platform-neutral backends (`makeFumaBlobStore` default,\n// `makeInMemoryBlobStore` for tests). Platform-specific backends live with\n// their host (R2: `@executor-js/cloudflare/blob-store`).\nexport {\n pluginBlobStore,\n makeInMemoryBlobStore,\n makeFumaBlobStore,\n sha256Hex,\n type BlobStore,\n type PluginBlobStore,\n type OwnerPartitions,\n} from \"./blob\";\n\n// Plugin storage.\nexport {\n definePluginStorageCollection,\n pluginStorageId,\n type PluginStorageCollectionDefinition,\n type PluginStorageCollectionFacade,\n type PluginStorageCollectionIndexedField,\n type PluginStorageCollectionKeyInput,\n type PluginStorageCollectionListInput,\n type PluginStorageCollectionOrderBy,\n type PluginStorageCollectionPutInput,\n type PluginStorageCollectionQueryInput,\n type PluginStorageCollectionScopedKeyInput,\n type PluginStorageCollectionWhere,\n type PluginStorageConfig,\n type PluginStorageEntry,\n type PluginStorageFacade,\n type PluginStorageIndexField,\n type PluginStorageIndexSpec,\n type PluginStorageKeyInput,\n type PluginStorageListInput,\n type PluginStoragePutInput,\n type PluginStorageRuntimeCollectionDefinition,\n type PluginStorageRuntimeIndexSpec,\n type PluginStorageSchema,\n type PluginStorageSchemaType,\n type PluginStorageScopedKeyInput,\n type PluginStorageWhereFilter,\n type PluginStorageWhereValue,\n} from \"./plugin-storage\";\n\n// OAuth (v2 contracts).\nexport { OAUTH2_PROVIDER_KEY, OAUTH2_SESSION_TTL_MS } from \"./oauth\";\nexport {\n OAuthStartError,\n OAuthCompleteError,\n OAuthProbeError,\n OAuthRegisterDynamicError,\n OAuthSessionNotFoundError,\n type OAuthGrant,\n type OAuthAuthentication,\n type OAuthClient,\n type OAuthClientSummary,\n type CreateOAuthClientInput,\n type RegisterDynamicClientInput,\n type ConnectResult,\n type OAuthStartInput,\n type OAuthCompleteInput,\n type OAuthProbeInput,\n type OAuthProbeResult,\n type OAuthService,\n} from \"./oauth-client\";\n\n// NOTE: the OAuth 2.1 implementation helpers (`./oauth-helpers`,\n// `makeOAuthService` in `./oauth-service`, discovery in `./oauth-discovery`)\n// are SDK-internal — consumed only by `createExecutor`. The hosted HTTP client\n// builder is host-internal and reachable via `@executor-js/sdk/host-internal`.\n\nexport {\n DEFAULT_EXECUTOR_SERVER_ORIGIN,\n DEFAULT_EXECUTOR_SERVER_USERNAME,\n apiBaseUrlForServerOrigin,\n getExecutorServerAuthorizationHeader,\n normalizeExecutorServerConnection,\n normalizeExecutorServerOrigin,\n originFromApiBaseUrl,\n type ExecutorServerAuth,\n type ExecutorServerConnection,\n type ExecutorServerConnectionInput,\n type ExecutorServerConnectionKind,\n} from \"./server-connection\";\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 OwnerBinding,\n type IntegrationRecord,\n type StaticSourceDecl,\n type StaticToolDecl,\n type StaticToolSchema,\n type StaticToolExecuteContext,\n type StaticToolHandlerInput,\n type StaticToolInput,\n type ConfigureIntegrationHandlerInput,\n type InvokeToolInput,\n type ConnectionLifecycleInput,\n type IntegrationConfigureDecl,\n type IntegrationConfigureSchema,\n type IntegrationPreset,\n type IntegrationPresetCatalogEntry,\n type ResolveToolsInput,\n type ResolveToolsResult,\n type ToolInvocationCredential,\n type Elicit,\n definePlugin,\n tool,\n} from \"./plugin\";\n\n// Executor.\n//\n// `collectTables` is host/tooling-only (cli schema cmd, kernel worker,\n// local/cloud DB bring-up). Its definition stays here because `createExecutor`\n// uses it; the host surface (`@executor-js/api/server`) re-exports it.\nexport {\n type Executor,\n type ExecutorConfig,\n type ExecutorDb,\n type ExecutorDbFactory,\n type ExecutorDbInput,\n type ParsedToolAddress,\n createExecutor,\n collectTables,\n parseToolAddress,\n connectionAddress,\n toolAddress,\n} from \"./executor\";\n\n// CLI / runtime config.\nexport {\n defineExecutorConfig,\n type ExecutorCliConfig,\n type ExecutorPluginsFactory,\n} from \"./config\";\n\n// The one TS-preview generator plugins assert against.\nexport { buildToolTypeScriptPreview } from \"./schema-types\";\n\n// Wire-level HTTP error schemas usable by plugin HttpApiGroup definitions.\nexport { InternalError } from \"./api-errors\";\n\n// ToolResult — typed value-based discriminated union for tool outcomes.\nexport {\n ToolFileSchema,\n ToolFileJsonSchema,\n ToolResult,\n annotateToolResultOutcome,\n isToolFile,\n isToolResult,\n type ToolFile,\n type ToolFile as ToolFileValue,\n type ToolError,\n type ToolHttpMeta,\n} from \"./tool-result\";\n\n// Stamped boot-time data-migration ledger for the libSQL-backed apps.\nexport {\n DataMigrationError,\n DuplicateDataMigrationError,\n runSqliteDataMigrations,\n sqliteDataMigration,\n type SqliteDataMigration,\n type SqliteDataMigrationClient,\n} from \"./sqlite-data-migrations\";\n// Shared inline-config-field → blob-table migration body; the protocol\n// plugins bind their field names and export the ledger entries.\nexport {\n runSqliteConfigBlobMigration,\n type SqliteConfigBlobMigrationOptions,\n} from \"./sqlite-config-blob-migration\";\nexport {\n authToolFailure,\n type AuthToolFailureCode,\n type AuthToolFailureInput,\n} from \"./auth-tool-failure\";\n","import type { IntegrationSlug } from \"./ids\";\n\n/* Core knows only an integration's catalog identity — slug + description + which\n * plugin (`kind`) owns it. The type-specific shape (openapi auth templates + spec,\n * an mcp url, …) lives in the plugin and is stored as an opaque `config` blob core\n * never parses. An integration is one API surface; multi-API providers (Google)\n * are bundled into a single integration by their plugin, so one credential covers\n * the whole provider. */\n\n// ---------------------------------------------------------------------------\n// Declared auth methods — a plugin-agnostic projection of an integration's\n// stored `config` into the catalog response. Each plugin derives these from its\n// own opaque config (`describeAuthMethods`); core never parses config itself.\n// The client renders these as the integration's selectable auth methods, so the\n// catalog is authoritative even when the integration has zero connections.\n//\n// This is a DERIVED projection — there is no DB column. A plugin that declares\n// no projector contributes `[]`, and the client falls through to its existing\n// connection-inference behavior (no regression).\n// ---------------------------------------------------------------------------\n\nexport interface IntegrationDisplayDescriptor {\n /** Non-secret URL suitable for display metadata such as favicons. */\n readonly url?: string;\n}\n\n/** Where a credential value is carried on the outbound request. Mirrors the\n * client's `Placement`. */\nexport interface AuthPlacementDescriptor {\n readonly carrier: \"header\" | \"query\";\n readonly name: string;\n /** Literal prepended to the value (e.g. `\"Bearer \"`). Empty when bare. */\n readonly prefix: string;\n /** The input variable this placement renders from. `token` for single-input\n * methods; a distinct name per input for multi-input ones (e.g. Datadog).\n * Absent → treated as `token`. */\n readonly variable?: string;\n /** Set when the placement renders this exact value instead of a credential\n * (a static header/param the method carries). Such placements reference no\n * input variable. */\n readonly literal?: string;\n}\n\n/** OAuth specifics for an `oauth` auth method. For probe-at-connect providers\n * (MCP) only `discoveryUrl` + `supportsDynamicRegistration` are known up front;\n * the authorize/token endpoints are discovered live at connect time. For\n * providers that store endpoints (OpenAPI) the resolved URLs are carried. */\nexport interface AuthMethodOAuthDescriptor {\n /** For probe-at-connect providers (MCP): the endpoint to discover metadata\n * from (RFC 9728 PRM → RFC 8414 AS metadata). */\n readonly discoveryUrl?: string;\n readonly authorizationUrl?: string;\n readonly tokenUrl?: string;\n readonly scopes?: readonly string[];\n readonly registrationEndpoint?: string;\n /** True when the integration is known to support RFC 7591 dynamic client\n * registration (drives the transparent auto-register connect flow). */\n readonly supportsDynamicRegistration?: boolean;\n}\n\n/** A single declared auth method on an integration's catalog response. */\nexport interface AuthMethodDescriptor {\n /** Stable id within the integration (e.g. the auth template slug). */\n readonly id: string;\n readonly label: string;\n readonly kind: \"oauth\" | \"apikey\" | \"header\" | \"none\";\n /** The auth-template slug a connection binds against. */\n readonly template: string;\n readonly placements?: readonly AuthPlacementDescriptor[];\n readonly oauth?: AuthMethodOAuthDescriptor;\n}\n\n/** Public projection of an integration — what `integrations.list/get` return.\n * Carries no credentials and no plugin-internal config. */\nexport interface Integration {\n readonly slug: IntegrationSlug;\n /** Display name. Pre-split rows stored the name in `description`; readers\n * fall back, so this is always populated. */\n readonly name: string;\n /** Agent-visible context (\"what this API is and when to reach for it\").\n * Distinct from the display name; may equal it on legacy rows. */\n readonly description: string;\n /** The plugin that owns this integration kind (e.g. \"openapi\", \"mcp\"). */\n readonly kind: string;\n /** Whether the user can remove this integration from the catalog. `false`\n * for static / built-in integrations declared by a plugin at startup. */\n readonly canRemove: boolean;\n /** Whether the owning plugin supports re-resolving a connection's tools\n * (`connections.refresh`). */\n readonly canRefresh: boolean;\n /** Declared auth methods derived from the owning plugin's stored config (a\n * derived projection, not a DB column). Always present, possibly empty. */\n readonly authMethods: readonly AuthMethodDescriptor[];\n /** Non-secret display URL derived by the owning plugin from opaque config.\n * Used for catalog favicons; never includes credentials or plugin config. */\n readonly displayUrl?: string;\n}\n\n/** Plugin-owned, opaque-to-core configuration stored on the integration row. The\n * owning plugin writes it at register time and reads it back at execute time to\n * render auth / produce tools. Core treats it as an opaque JSON blob. */\nexport type IntegrationConfig = unknown;\n\n// ---------------------------------------------------------------------------\n// Auth-template merge — shared by every plugin whose config carries a slugged\n// `authenticationTemplate` array (openapi, graphql, mcp). The custom-method\n// flow merge-appends: an incoming entry with a matching slug replaces the\n// existing entry in place; entries lacking a slug (or colliding with another\n// entry added in the same call) get a fresh `custom_<id>` slug.\n// ---------------------------------------------------------------------------\n\nconst shortId = (): string => Math.random().toString(36).slice(2, 8);\n\nexport const freshCustomAuthSlug = (taken: ReadonlySet<string>): string => {\n let candidate = `custom_${shortId()}`;\n while (taken.has(candidate)) candidate = `custom_${shortId()}`;\n return candidate;\n};\n\nexport const mergeAuthTemplates = <T extends { readonly slug: string }>(\n existing: readonly T[],\n incoming: readonly T[],\n): readonly T[] => {\n const result: T[] = existing.map((entry: T) => entry);\n const taken = new Set<string>(result.map((entry: T) => String(entry.slug)));\n for (const entry of incoming) {\n // `slug` may be branded-required in the plugin's schema, but JSON callers\n // can submit it empty/blank — read defensively and backfill so every\n // stored template has a stable slug.\n const rawSlug = (entry as { readonly slug?: unknown }).slug;\n const requested = typeof rawSlug === \"string\" ? rawSlug.trim() : \"\";\n const existingIndex = result.findIndex((current: T) => String(current.slug) === requested);\n if (requested.length > 0 && existingIndex >= 0) {\n result[existingIndex] = entry;\n continue;\n }\n const slug =\n requested.length > 0 && !taken.has(requested) ? requested : freshCustomAuthSlug(taken);\n taken.add(slug);\n result.push({ ...entry, slug } as T);\n }\n return result;\n};\n\n/** What a plugin's extension method passes to `ctx.core.integrations.register`.\n * The v2 analog of v1's `SourceInput`, minus the per-source tool list (tools are\n * produced per-connection now). */\nexport interface RegisterIntegrationInput {\n readonly slug: IntegrationSlug;\n /** Display name. Falls back to `description` then the slug when omitted\n * (legacy callers registered with description-as-name). */\n readonly name?: string;\n readonly description: string;\n /** Opaque plugin config (auth templates, spec ref, mcp url, …). */\n readonly config: IntegrationConfig;\n readonly canRemove?: boolean;\n readonly canRefresh?: boolean;\n}\n","// ---------------------------------------------------------------------------\n// Stamped data-migration ledger for the libSQL-backed apps (local boot,\n// selfhost boot). Cloud runs schema + data migrations through its drizzle\n// chain out-of-band; the local apps have no operator, so their migrations\n// run at boot — and before this ledger existed, each one re-scanned its\n// tables on every startup to decide \"did I already run?\" by data shape.\n// That accumulates (N migrations = N full-table scans per boot, forever)\n// and makes idempotence a per-migration proof obligation.\n//\n// This is the rail instead: a `data_migration` table (name → completion\n// time), an ordered registry the app composes, and a runner that executes\n// each pending migration once and stamps it. Stamped names are skipped\n// without touching the data.\n//\n// Write migrations idempotently anyway (defense in depth — the support\n// remedy for a half-applied state is deleting the stamp row and\n// rebooting). One deliberate semantics change from the scan-every-boot\n// era: after a migration is stamped, rows written later by an OLDER binary\n// (downgrade, then re-upgrade) are NOT re-healed. That matches the cloud\n// chain's semantics; the stamp row, not the data shape, is the source of\n// truth.\n// ---------------------------------------------------------------------------\n\nimport { Data, Effect } from \"effect\";\n\n/** Structural client interface so this module stays dependency-free;\n * `@libsql/client` satisfies it. */\nexport interface SqliteDataMigrationClient {\n execute(\n stmt: string | { readonly sql: string; readonly args: readonly unknown[] },\n ): Promise<{ readonly rows: readonly Record<string, unknown>[] }>;\n}\n\nexport class DataMigrationError extends Data.TaggedError(\"DataMigrationError\")<{\n /** The migration that failed, or null when the ledger itself did. */\n readonly migration: string | null;\n readonly cause: unknown;\n}> {}\n\nexport class DuplicateDataMigrationError extends Data.TaggedError(\"DuplicateDataMigrationError\")<{\n readonly name: string;\n}> {}\n\nexport interface SqliteDataMigration {\n /** Stable unique id, date-prefixed so the registry reads in order\n * (e.g. \"2026-06-05-auth-config-placements\"). Renaming an applied\n * migration re-runs it — never rename. */\n readonly name: string;\n readonly run: (client: SqliteDataMigrationClient) => Effect.Effect<void, DataMigrationError>;\n}\n\nconst LEDGER_TABLE = \"data_migration\";\n\nconst execute = (\n client: SqliteDataMigrationClient,\n stmt: string | { readonly sql: string; readonly args: readonly unknown[] },\n migration: string | null,\n) =>\n Effect.tryPromise({\n try: () => client.execute(stmt),\n catch: (cause) => new DataMigrationError({ migration, cause }),\n });\n\n/** Wrap a promise-shaped migration body as a registry entry. */\nexport const sqliteDataMigration = (\n name: string,\n run: (client: SqliteDataMigrationClient) => Promise<unknown>,\n): SqliteDataMigration => ({\n name,\n run: (client) =>\n Effect.tryPromise({\n try: () => run(client),\n catch: (cause) => new DataMigrationError({ migration: name, cause }),\n }).pipe(Effect.asVoid),\n});\n\n/**\n * Run every registry entry whose name has no stamp row, in registry order,\n * stamping each on success. Returns the applied names.\n *\n * Atomicity is the migration's own job (the existing migrations run their\n * rewrites inside BEGIN…COMMIT), so the runner does not wrap them — SQLite\n * has no nested transactions. The stamp is written after the migration\n * succeeds; a crash between the two re-runs the (idempotent) migration on\n * the next boot, which is a no-op. A failed migration leaves no stamp and\n * fails the boot.\n */\nexport const runSqliteDataMigrations = (\n client: SqliteDataMigrationClient,\n migrations: readonly SqliteDataMigration[],\n): Effect.Effect<readonly string[], DataMigrationError | DuplicateDataMigrationError> =>\n Effect.gen(function* () {\n const names = new Set<string>();\n for (const migration of migrations) {\n if (names.has(migration.name)) {\n return yield* new DuplicateDataMigrationError({ name: migration.name });\n }\n names.add(migration.name);\n }\n\n yield* execute(\n client,\n `CREATE TABLE IF NOT EXISTS ${LEDGER_TABLE} (name TEXT PRIMARY KEY, time_completed INTEGER NOT NULL)`,\n null,\n );\n const stamped = yield* execute(client, `SELECT name FROM ${LEDGER_TABLE}`, null);\n const completed = new Set(\n stamped.rows.map((row) => row.name).filter((name) => typeof name === \"string\"),\n );\n\n const applied: string[] = [];\n for (const migration of migrations) {\n if (completed.has(migration.name)) continue;\n yield* migration.run(client);\n yield* execute(\n client,\n {\n sql: `INSERT INTO ${LEDGER_TABLE} (name, time_completed) VALUES (?, ?)`,\n args: [migration.name, Date.now()],\n },\n migration.name,\n );\n applied.push(migration.name);\n }\n return applied;\n });\n","// ---------------------------------------------------------------------------\n// Data migration: move an oversized inline `integration.config` field into\n// the blob table. The shape both protocol plugins need is identical — only\n// the field names differ — so the body lives here and each plugin exports a\n// ledger entry that binds its constants (openapi: spec → specHash under\n// `spec/<hash>`; graphql: introspectionJson → introspectionHash under\n// `introspection/<hash>`).\n//\n// Blob rows are written with the EXACT naming `makeFumaBlobStore` +\n// `pluginBlobStore` read back at runtime: namespace `o:<tenant>/<pluginId>`\n// (the org partition — integration configs are catalog-level), key\n// `<prefix>/<sha256>`, id `JSON.stringify([namespace, key])`. That makes it\n// correct ONLY for hosts whose runtime blob backend is the FumaDB store\n// (local, selfhost) — a host that reads blobs elsewhere (the D1 host reads\n// R2) must not register it, or the rewritten pointers would dangle.\n//\n// Idempotent: pointer-shaped configs (no inline field) plan zero updates,\n// and blob writes are content-addressed upserts.\n// ---------------------------------------------------------------------------\n\nimport { Effect, Option, Schema } from \"effect\";\n\nimport { sha256Hex } from \"./blob\";\nimport { DataMigrationError, type SqliteDataMigrationClient } from \"./sqlite-data-migrations\";\n\nexport interface SqliteConfigBlobMigrationOptions {\n /** The ledger entry name, for error attribution. */\n readonly migrationName: string;\n /** Rows whose `plugin_id` equals this are candidates. */\n readonly pluginId: string;\n /** The config field holding the inline text to move (e.g. `spec`). */\n readonly inlineField: string;\n /** The config field that will carry the content hash (e.g. `specHash`). */\n readonly hashField: string;\n /** Blob key prefix; the key is `<prefix>/<sha256>` (e.g. `spec`). */\n readonly blobKeyPrefix: string;\n}\n\nconst decodeJsonOption = Schema.decodeUnknownOption(Schema.UnknownFromJsonString);\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n/**\n * Move every inline `options.inlineField` in this plugin's integration\n * configs into the blob table and rewrite the config to carry\n * `options.hashField`. Returns the number of rows rewritten. The\n * `integration` table may not exist yet on a fresh database — that counts\n * as nothing to migrate.\n */\nexport const runSqliteConfigBlobMigration = (\n client: SqliteDataMigrationClient,\n options: SqliteConfigBlobMigrationOptions,\n): Effect.Effect<number, DataMigrationError> =>\n Effect.gen(function* () {\n const execute = (stmt: string | { readonly sql: string; readonly args: readonly unknown[] }) =>\n Effect.tryPromise({\n try: () => client.execute(stmt),\n catch: (cause) => new DataMigrationError({ migration: options.migrationName, cause }),\n });\n\n const exists = yield* execute(\n \"SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'integration'\",\n );\n if (exists.rows.length === 0) return 0;\n\n const result = yield* execute({\n sql: \"SELECT row_id, tenant, config FROM integration WHERE plugin_id = ? AND config IS NOT NULL\",\n args: [options.pluginId],\n });\n\n interface PlannedMove {\n readonly rowId: string;\n readonly namespace: string;\n readonly key: string;\n readonly blobId: string;\n readonly inlineText: string;\n readonly nextConfig: string;\n }\n const moves: PlannedMove[] = [];\n for (const row of result.rows) {\n if (typeof row.row_id !== \"string\" || typeof row.tenant !== \"string\") continue;\n if (typeof row.config !== \"string\") continue;\n const decoded = decodeJsonOption(row.config);\n if (Option.isNone(decoded) || !isRecord(decoded.value)) continue;\n const inline = decoded.value[options.inlineField];\n if (typeof inline !== \"string\") continue;\n\n const hash = yield* sha256Hex(inline);\n const namespace = `o:${row.tenant}/${options.pluginId}`;\n const key = `${options.blobKeyPrefix}/${hash}`;\n const { [options.inlineField]: _removed, ...rest } = decoded.value;\n moves.push({\n rowId: row.row_id,\n namespace,\n key,\n blobId: JSON.stringify([namespace, key]),\n inlineText: inline,\n nextConfig: JSON.stringify({ ...rest, [options.hashField]: hash }),\n });\n }\n if (moves.length === 0) return 0;\n\n const applyAll = Effect.gen(function* () {\n for (const move of moves) {\n const existing = yield* execute({\n sql: \"SELECT row_id FROM blob WHERE id = ?\",\n args: [move.blobId],\n });\n if (existing.rows.length === 0) {\n yield* execute({\n sql: \"INSERT INTO blob (namespace, key, value, row_id, id) VALUES (?, ?, ?, ?, ?)\",\n args: [move.namespace, move.key, move.inlineText, crypto.randomUUID(), move.blobId],\n });\n } else {\n yield* execute({\n sql: \"UPDATE blob SET value = ? WHERE id = ?\",\n args: [move.inlineText, move.blobId],\n });\n }\n yield* execute({\n sql: \"UPDATE integration SET config = ? WHERE row_id = ?\",\n args: [move.nextConfig, move.rowId],\n });\n }\n yield* execute(\"COMMIT\");\n });\n\n yield* execute(\"BEGIN\");\n yield* applyAll.pipe(Effect.tapError(() => execute(\"ROLLBACK\").pipe(Effect.ignore)));\n return moves.length;\n });\n","import { ToolResult, type ToolError } from \"./tool-result\";\n\nexport type AuthToolFailureCode =\n | \"connection_value_missing\"\n | \"connection_rejected\"\n | \"oauth_connection_missing\"\n | \"oauth_refresh_failed\"\n | \"oauth_reauth_required\";\n\nexport type AuthToolFailureInput = {\n readonly code: AuthToolFailureCode;\n readonly message: string;\n readonly source?: {\n readonly id: string;\n readonly scope?: string;\n };\n readonly credential?: {\n readonly kind: \"secret\" | \"oauth\" | \"upstream\";\n readonly label?: string;\n readonly slotKey?: string;\n readonly secretId?: string;\n readonly connectionId?: string;\n };\n readonly status?: number;\n readonly upstream?: {\n readonly status?: number;\n readonly details?: unknown;\n };\n readonly recovery?: {\n readonly configureSourceTool?: string;\n };\n};\n\n// In v1.5 a connection IS the credential: there is no standalone secret to\n// \"bind\" to a source afterward. Manually-entered credentials are created via\n// the connection handoff (the user enters the value in the web UI, which\n// creates the bound connection in one step); OAuth credentials are minted by\n// the OAuth start flow. These strings are read by the agent resolving the\n// failure, so they must name tools that actually exist on the executor.\nconst authRecovery = (input?: AuthToolFailureInput[\"recovery\"]) => ({\n createConnectionTool: \"executor.coreTools.connections.createHandoff\",\n startOAuthTool: \"executor.coreTools.oauth.start\",\n listConnectionsTool: \"executor.coreTools.connections.list\",\n ...(input?.configureSourceTool ? { configureSourceTool: input.configureSourceTool } : {}),\n connectionInstructions:\n \"For API keys and tokens, call createConnectionTool for the integration to get a browser URL; the user enters the credential there, which creates the bound connection. Do not ask the user to paste secrets into chat. Then call listConnectionsTool to confirm the connection exists before retrying this tool.\",\n oauthInstructions:\n \"For OAuth credentials, call startOAuthTool and give the returned authorizationUrl to the user. The completed connection binds automatically, then retry the tool.\",\n});\n\nexport const authToolFailure = <T = never>(input: AuthToolFailureInput): ToolResult<T> => {\n const error: ToolError = {\n code: input.code,\n message: input.message,\n retryable: false,\n ...(input.status !== undefined ? { status: input.status } : {}),\n details: {\n category: \"authentication\",\n ...(input.source ? { source: input.source } : {}),\n ...(input.credential ? { credential: input.credential } : {}),\n ...(input.upstream ? { upstream: input.upstream } : {}),\n recovery: authRecovery(input.recovery),\n },\n };\n return ToolResult.fail(error);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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FH,IAAM,eAAe,CAAC,WAA8C;AAAA,EAClE,sBAAsB;AAAA,EACtB,gBAAgB;AAAA,EAChB,qBAAqB;AAAA,EACrB,GAAI,OAAO,sBAAsB,EAAE,qBAAqB,MAAM,oBAAoB,IAAI,CAAC;AAAA,EACvF,wBACE;AAAA,EACF,mBACE;AACJ;AAEO,IAAM,kBAAkB,CAAY,UAA+C;AACxF,QAAM,QAAmB;AAAA,IACvB,MAAM,MAAM;AAAA,IACZ,SAAS,MAAM;AAAA,IACf,WAAW;AAAA,IACX,GAAI,MAAM,WAAW,SAAY,EAAE,QAAQ,MAAM,OAAO,IAAI,CAAC;AAAA,IAC7D,SAAS;AAAA,MACP,UAAU;AAAA,MACV,GAAI,MAAM,SAAS,EAAE,QAAQ,MAAM,OAAO,IAAI,CAAC;AAAA,MAC/C,GAAI,MAAM,aAAa,EAAE,YAAY,MAAM,WAAW,IAAI,CAAC;AAAA,MAC3D,GAAI,MAAM,WAAW,EAAE,UAAU,MAAM,SAAS,IAAI,CAAC;AAAA,MACrD,UAAU,aAAa,MAAM,QAAQ;AAAA,IACvC;AAAA,EACF;AACA,SAAO,WAAW,KAAK,KAAK;AAC9B;","names":["Effect","Schema","Data","Option","Effect","Effect","execute"]}
package/dist/index.d.ts CHANGED
@@ -31,7 +31,7 @@ export { type Executor, type ExecutorConfig, type ExecutorDb, type ExecutorDbFac
31
31
  export { defineExecutorConfig, type ExecutorCliConfig, type ExecutorPluginsFactory, } from "./config";
32
32
  export { buildToolTypeScriptPreview } from "./schema-types";
33
33
  export { InternalError } from "./api-errors";
34
- export { ToolResult, annotateToolResultOutcome, isToolResult, type ToolError, type ToolHttpMeta, } from "./tool-result";
34
+ export { ToolFileSchema, ToolFileJsonSchema, ToolResult, annotateToolResultOutcome, isToolFile, isToolResult, type ToolFile, type ToolFile as ToolFileValue, type ToolError, type ToolHttpMeta, } from "./tool-result";
35
35
  export { DataMigrationError, DuplicateDataMigrationError, runSqliteDataMigrations, sqliteDataMigration, type SqliteDataMigration, type SqliteDataMigrationClient, } from "./sqlite-data-migrations";
36
36
  export { runSqliteConfigBlobMigration, type SqliteConfigBlobMigrationOptions, } from "./sqlite-config-blob-migration";
37
37
  export { authToolFailure, type AuthToolFailureCode, type AuthToolFailureInput, } from "./auth-tool-failure";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtE,OAAO,EACL,OAAO,EACP,cAAc,EACd,aAAa,EACb,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,aAAa,GACd,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,YAAY,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC5F,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,UAAU,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAC3F,YAAY,EACV,SAAS,EACT,SAAS,EACT,QAAQ,EACR,MAAM,EACN,MAAM,IAAI,UAAU,GACrB,MAAM,4BAA4B,CAAC;AAEpC,YAAY,EACV,MAAM,EACN,SAAS,EACT,OAAO,EACP,UAAU,EACV,WAAW,EACX,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGtF,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,UAAU,EACV,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,MAAM,EACN,OAAO,EAC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AE,MAAM,cAAc,CAAC;AAG7C,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,yBAAyB,EACzB,UAAU,EACV,YAAY,EACZ,KAAK,QAAQ,EACb,KAAK,QAAQ,IAAI,aAAa,EAC9B,KAAK,SAAS,EACd,KAAK,YAAY,GAClB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,uBAAuB,EACvB,mBAAmB,EACnB,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,GAC/B,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,4BAA4B,EAC5B,KAAK,gCAAgC,GACtC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,eAAe,EACf,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,GAC1B,MAAM,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  collectTables,
6
6
  createExecutor
7
- } from "./chunk-WKKKHDH2.js";
7
+ } from "./chunk-QEKKFEJL.js";
8
8
  import {
9
9
  ConnectionNotFoundError,
10
10
  CredentialProviderNotRegisteredError,
package/dist/testing.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  collectTables,
6
6
  createExecutor,
7
7
  definePlugin
8
- } from "./chunk-WKKKHDH2.js";
8
+ } from "./chunk-QEKKFEJL.js";
9
9
  import "./chunk-6EED5LAL.js";
10
10
  import "./chunk-I3X6242Q.js";
11
11
  import "./chunk-EIHWBY6T.js";
@@ -18,6 +18,16 @@ export declare const ToolHttpMetaSchema: Schema.Struct<{
18
18
  * headers) remain reachable for callers that need them.
19
19
  */
20
20
  export type ToolHttpMeta = typeof ToolHttpMetaSchema.Type;
21
+ export declare const ToolFileSchema: Schema.TaggedStruct<"ToolFile", {
22
+ readonly name: Schema.optional<Schema.String>;
23
+ readonly mimeType: Schema.String;
24
+ readonly encoding: Schema.Literal<"base64">;
25
+ readonly data: Schema.String;
26
+ readonly byteLength: Schema.Int;
27
+ }>;
28
+ export type ToolFile = typeof ToolFileSchema.Type;
29
+ export declare const ToolFileJsonSchema: import("effect/JsonSchema").JsonSchema;
30
+ export declare const isToolFile: (value: unknown) => value is ToolFile;
21
31
  export type ToolResult<T> = {
22
32
  readonly ok: true;
23
33
  readonly data: T;
@@ -1 +1 @@
1
- {"version":3,"file":"tool-result.d.ts","sourceRoot":"","sources":["../src/tool-result.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,eAAO,MAAM,eAAe;;;;;;EAM1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,OAAO,eAAe,CAAC,IAAI,CAAC;AAEpD,eAAO,MAAM,kBAAkB;;;EAG7B,CAAC;AAEH;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,kBAAkB,CAAC,IAAI,CAAC;AAE1D,MAAM,MAAM,UAAU,CAAC,CAAC,IACpB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,CAAA;CAAE,GACrE;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC;AAEtD,eAAO,MAAM,UAAU;kBAChB,CAAC,QAAQ,CAAC,SAAS;QAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,CAAA;KAAE,KAAG,UAAU,CAAC,CAAC,CAAC;oBAKjE,CAAC,iBAAiB,SAAS,KAAG,UAAU,CAAC,CAAC,CAAC;CAC1C,CAAC;AAaX,eAAO,MAAM,YAAY,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,UAAU,CAAC,OAAO,CAC7C,CAAC;AAE7B;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,yBAAyB,GAAI,OAAO,OAAO,K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B;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,yBAAyB,GAAI,OAAO,OAAO,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAS5E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@executor-js/sdk",
3
- "version": "1.5.13",
3
+ "version": "1.5.15",
4
4
  "homepage": "https://github.com/RhysSullivan/executor/tree/main/packages/core/sdk",
5
5
  "bugs": {
6
6
  "url": "https://github.com/RhysSullivan/executor/issues"