apps 0.0.1-beta.0 → 0.0.1-beta.10

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 (141) hide show
  1. package/README.md +145 -30
  2. package/framework-reference.json +1 -1
  3. package/js/browser-XIPJGLH2.js +65 -0
  4. package/js/{chunk-36DNRFZQ.js → chunk-27F7W2LG.js} +1 -1
  5. package/js/{chunk-VFUZI3NY.js → chunk-57RKNWL2.js} +4 -4
  6. package/js/{chunk-BPEFS4YF.js → chunk-5T57N25Q.js} +122 -18
  7. package/js/chunk-72JNVHPK.js +41 -0
  8. package/js/{chunk-2OTCEKL2.js → chunk-CDL5PM2Q.js} +2643 -1646
  9. package/js/{chunk-KWTCHVLT.js → chunk-CRDWFA74.js} +69 -54
  10. package/js/chunk-CZ7CSFO4.js +39 -0
  11. package/js/{chunk-WIDTG42X.js → chunk-EPT3ZP52.js} +79 -26
  12. package/js/chunk-FL2QR3XW.js +507 -0
  13. package/js/{chunk-3ANFZFCV.js → chunk-IJX4CYZO.js} +15 -18
  14. package/js/chunk-IPI4MFSN.js +78 -0
  15. package/js/chunk-JU7VHODU.js +104 -0
  16. package/js/chunk-KUMBKVJD.js +39 -0
  17. package/js/{chunk-YDR4CPJA.js → chunk-M3B3DE4K.js} +8 -8
  18. package/js/chunk-MKWZPDR6.js +63 -0
  19. package/js/{chunk-7JXHF5IF.js → chunk-N7YDVXYJ.js} +49 -1
  20. package/js/chunk-NKLWZJLE.js +172 -0
  21. package/js/{chunk-OWD2YICM.js → chunk-ODEIDRGW.js} +116 -88
  22. package/js/{chunk-D6BKYP2L.js → chunk-PJJ24GU7.js} +4 -4
  23. package/js/{chunk-EP6AEUZO.js → chunk-PZB6T6KU.js} +1 -1
  24. package/js/chunk-R3EV5FTO.js +97 -0
  25. package/js/chunk-RFVIONFX.js +189 -0
  26. package/js/{chunk-W7Q5EOTS.js → chunk-UK573G7W.js} +32 -32
  27. package/js/chunk-UVL56Z6E.js +6641 -0
  28. package/js/{chunk-Q2FD5IBM.js → chunk-V5KNQVCT.js} +505 -124
  29. package/js/{chunk-SBKHUC5L.js → chunk-VFZKSM3T.js} +5 -25
  30. package/js/{chunk-HP7E42X6.js → chunk-WLE7WX2U.js} +1158 -232
  31. package/js/{chunk-X3YBZCJW.js → chunk-YXQHV65J.js} +58 -62
  32. package/js/chunk-Z5M2LQOZ.js +209 -0
  33. package/js/{chunk-R6JMJSVT.js → chunk-ZQINWV4W.js} +60 -20
  34. package/js/client.js +11 -27
  35. package/js/contracts.js +138 -27
  36. package/js/effect.js +20 -15
  37. package/js/es-APDZKREY.js +40968 -0
  38. package/js/graphql.js +220 -123
  39. package/js/host.js +75 -19
  40. package/js/index.js +261 -117
  41. package/js/mcp/effect.js +24 -17
  42. package/js/mcp/stdio.js +26 -21
  43. package/js/mcp.js +127 -26
  44. package/js/openapi.js +3048 -150
  45. package/js/operations/approval.js +1 -1
  46. package/js/react.js +4 -4
  47. package/js/skills/effect.js +11 -0
  48. package/js/skills.js +893 -0
  49. package/js/storage/facet.js +7 -7
  50. package/js/ui/auth/contracts.js +9 -10
  51. package/js/ui/auth.js +17 -15
  52. package/js/ui/contracts.js +5 -5
  53. package/js/ui/serving.js +14 -13
  54. package/package.json +9 -1
  55. package/runtime.json +1 -1
  56. package/types/app-cache/src/contracts/cache.d.ts +119 -0
  57. package/types/app-cache/src/index.d.ts +93 -0
  58. package/types/app-data/src/contracts/database.d.ts +33 -6
  59. package/types/app-data/src/implementation/schema.d.ts +2 -17
  60. package/types/apps/src/contracts/api-response-error.d.ts +43 -0
  61. package/types/apps/src/contracts/app.d.ts +16 -4
  62. package/types/apps/src/contracts/cache.d.ts +44 -0
  63. package/types/apps/src/contracts/dynamic-skills.d.ts +10 -0
  64. package/types/apps/src/contracts/failure.d.ts +25 -0
  65. package/types/apps/src/contracts/graphql.d.ts +18 -1
  66. package/types/apps/src/contracts/host.d.ts +76 -528
  67. package/types/apps/src/contracts/mcp.d.ts +19 -1
  68. package/types/apps/src/contracts/openapi-compile.d.ts +11 -0
  69. package/types/apps/src/contracts/openapi-document.d.ts +53 -0
  70. package/types/apps/src/contracts/openapi.d.ts +160 -30
  71. package/types/apps/src/contracts/operations.d.ts +0 -5
  72. package/types/apps/src/contracts/protocol-version.d.ts +6 -0
  73. package/types/apps/src/contracts/protocols/1.d.ts +1589 -0
  74. package/types/apps/src/contracts/protocols/2.d.ts +668 -0
  75. package/types/apps/src/contracts/protocols/3.d.ts +676 -0
  76. package/types/apps/src/contracts/protocols/4.d.ts +1229 -0
  77. package/types/apps/src/contracts/protocols/5.d.ts +1090 -0
  78. package/types/apps/src/contracts/provider-error.d.ts +15 -0
  79. package/types/apps/src/contracts/provider.d.ts +69 -6
  80. package/types/apps/src/contracts/router.d.ts +59 -0
  81. package/types/apps/src/contracts/skills.d.ts +122 -0
  82. package/types/apps/src/contracts/storage.d.ts +3 -3
  83. package/types/apps/src/contracts/swagger-client.d.ts +29 -0
  84. package/types/apps/src/contracts/ui-auth.d.ts +6 -14
  85. package/types/apps/src/contracts/workflows.d.ts +34 -3
  86. package/types/apps/src/graphql.d.ts +5 -7
  87. package/types/apps/src/host.d.ts +1 -0
  88. package/types/apps/src/implementation/account-router.d.ts +12 -0
  89. package/types/apps/src/implementation/app.d.ts +5 -4
  90. package/types/apps/src/implementation/cache-session.d.ts +7 -0
  91. package/types/apps/src/implementation/cache.d.ts +8 -0
  92. package/types/apps/src/implementation/catalog-cache.d.ts +36 -0
  93. package/types/apps/src/implementation/dynamic-skills.d.ts +7 -0
  94. package/types/apps/src/implementation/elicitation.d.ts +13 -13
  95. package/types/apps/src/implementation/failure-detail.d.ts +25 -0
  96. package/types/apps/src/implementation/git.d.ts +25 -0
  97. package/types/apps/src/implementation/graphql-catalog.d.ts +7 -0
  98. package/types/apps/src/implementation/graphql.d.ts +81 -3
  99. package/types/apps/src/implementation/inflate.d.ts +16 -0
  100. package/types/apps/src/implementation/input-problems.d.ts +3 -0
  101. package/types/apps/src/implementation/mcp-call.d.ts +3 -2
  102. package/types/apps/src/implementation/mcp-catalog.d.ts +9 -0
  103. package/types/apps/src/implementation/mcp-client.d.ts +39 -22
  104. package/types/apps/src/implementation/mcp-stdio.d.ts +1 -1
  105. package/types/apps/src/implementation/mcp-tools.d.ts +6 -3
  106. package/types/apps/src/implementation/mcp.d.ts +55 -2
  107. package/types/apps/src/implementation/openapi-compile.d.ts +120 -0
  108. package/types/apps/src/implementation/openapi-document.d.ts +51 -0
  109. package/types/apps/src/implementation/openapi-names.d.ts +18 -0
  110. package/types/apps/src/implementation/openapi-request.d.ts +10 -4
  111. package/types/apps/src/implementation/openapi-source.d.ts +36 -0
  112. package/types/apps/src/implementation/openapi.d.ts +39 -3
  113. package/types/apps/src/implementation/operations.d.ts +26 -3
  114. package/types/apps/src/implementation/protocol-operations.d.ts +3 -4
  115. package/types/apps/src/implementation/provider-error.d.ts +10 -0
  116. package/types/apps/src/implementation/provider.d.ts +9 -4
  117. package/types/apps/src/implementation/router-catalog.d.ts +225 -0
  118. package/types/apps/src/implementation/router.d.ts +59 -0
  119. package/types/apps/src/implementation/schema.d.ts +11 -6
  120. package/types/apps/src/implementation/skill-files.d.ts +10 -0
  121. package/types/apps/src/implementation/skills.d.ts +43 -0
  122. package/types/apps/src/implementation/storage.d.ts +5 -3
  123. package/types/apps/src/implementation/swagger-client.d.ts +28 -0
  124. package/types/apps/src/implementation/ui-auth.d.ts +11 -5
  125. package/types/apps/src/implementation/ui-serving.d.ts +4 -2
  126. package/types/apps/src/implementation/webhooks.d.ts +1 -1
  127. package/types/apps/src/implementation/workflow-context.d.ts +11 -3
  128. package/types/apps/src/index.d.ts +11 -3
  129. package/types/apps/src/mcp-stdio.d.ts +2 -5
  130. package/types/apps/src/mcp.d.ts +8 -7
  131. package/types/apps/src/openapi.d.ts +8 -6
  132. package/types/apps/src/skills.d.ts +75 -0
  133. package/types/apps/src/ui-auth.d.ts +2 -2
  134. package/types/telemetry/src/browser-operations.d.ts +5 -2
  135. package/types/telemetry/src/config.d.ts +2 -0
  136. package/js/chunk-22WRQZT7.js +0 -389
  137. package/js/chunk-BKVL7XAJ.js +0 -47
  138. package/js/chunk-C24KEZXR.js +0 -59
  139. package/js/chunk-LOKGDT6B.js +0 -28
  140. package/js/chunk-MLKGABMK.js +0 -9
  141. package/types/apps/src/implementation/account-operations.d.ts +0 -32
@@ -1,11 +1,17 @@
1
- /** HTTP serialization for normalized OpenAPI operations. */
1
+ import { ProviderError } from "../contracts/provider-error.js";
2
+ /** Swagger constructs requests; Effect owns HTTP policy and bounded results. */
2
3
  import { Effect, Schema } from "effect";
3
- import { OpenapiError, type CredentialBinding, type OpenapiOperation, type OpenapiAccount } from "../contracts/openapi.js";
4
+ import { OpenapiResponseError } from "../contracts/api-response-error.js";
5
+ import { OpenapiError, type CredentialBinding, type OpenapiOperation, type OpenapiAccount, type OpenapiErrorResponse } from "../contracts/openapi.js";
6
+ type DeclaredError = OpenapiErrorResponse & {
7
+ readonly decoder: Schema.Decoder<Schema.Json>;
8
+ };
4
9
  /** Create request helpers from credential-free generated authentication metadata. */
5
10
  export declare function createRequest(config: {
6
11
  readonly methods: Readonly<Record<string, readonly CredentialBinding[]>>;
7
12
  readonly oauth: readonly string[];
8
13
  }): {
9
- available: (op: OpenapiOperation, method: string | undefined) => boolean;
10
- call: (op: OpenapiOperation, input: unknown, account: OpenapiAccount | undefined) => Effect.Effect<Schema.Json, OpenapiError, never>;
14
+ available: (op: OpenapiOperation, account: OpenapiAccount | undefined) => boolean;
15
+ call: (op: OpenapiOperation, input: unknown, account: OpenapiAccount | undefined, errors: readonly DeclaredError[]) => Effect.Effect<Schema.Json, ProviderError | OpenapiResponseError | OpenapiError, never>;
11
16
  };
17
+ export {};
@@ -0,0 +1,36 @@
1
+ /** Revisioned OpenAPI sources. Calls read a manifest, one operation and only its schema dependencies. */
2
+ import { Duration } from "effect";
3
+ import type { AppCache } from "../contracts/cache.js";
4
+ import { OpenapiOperation, type OpenapiToolsOptions } from "../contracts/openapi.js";
5
+ import { JsonObject, JsonValue } from "../contracts/schema.js";
6
+ import { type OperationKinds } from "./protocol-operations.js";
7
+ import { type RouterDeclaration } from "./router.js";
8
+ /** Static credential placement and destination are reviewed when the app is authored/imported. */
9
+ export interface OpenapiSourceOptions extends Omit<OpenapiToolsOptions, "operations" | "definitions"> {
10
+ readonly cache: AppCache;
11
+ readonly source: {
12
+ readonly url: string;
13
+ } | {
14
+ readonly document: JsonObject;
15
+ };
16
+ readonly allowedOrigin: string;
17
+ readonly securitySchemes: Readonly<Record<string, JsonObject>>;
18
+ readonly baseUrl?: string;
19
+ readonly freshFor?: Duration.Input;
20
+ readonly staleFor?: Duration.Input;
21
+ /**
22
+ * Query or mutation overrides keyed by the document's operationId. An operation without an
23
+ * operationId is keyed by its generated name without the kind, such as `users.getUsers`.
24
+ */
25
+ readonly kinds?: OperationKinds;
26
+ readonly fallbackSecurity?: OpenapiOperation["request"]["security"];
27
+ readonly patches?: readonly {
28
+ readonly op: "add" | "remove" | "replace";
29
+ readonly path: string;
30
+ readonly value?: JsonValue;
31
+ }[];
32
+ }
33
+ /** JSON-object patches are static app configuration and are reapplied to every revision. */
34
+ export declare function patchOpenapi(root: JsonObject, patches: OpenapiSourceOptions["patches"]): JsonObject;
35
+ /** No I/O during app construction. All accounts share credential-free compilation. */
36
+ export declare const liveOpenapiRouter: (options: OpenapiSourceOptions) => RouterDeclaration;
@@ -1,5 +1,41 @@
1
1
  /** Evaluate normalized metadata into ordinary tools, with account-specific security filtering. */
2
- import { Effect } from "effect";
3
- import { OpenapiError, OpenapiToolsOptions, type OpenapiTools } from "../contracts/openapi.js";
2
+ import { Effect, Schema } from "effect";
3
+ import { OpenapiError, OpenapiToolsOptions, type OpenapiTools, type OpenapiOperation, type OpenapiParameterDefaults } from "../contracts/openapi.js";
4
+ import type { JsonObject, JsonValue } from "../contracts/schema.js";
5
+ /** Names of shared definitions a JSON value references directly as `#/$defs/<name>`. */
6
+ export declare function references(value: JsonValue, found?: Set<string>): Set<string>;
7
+ /**
8
+ * Make a schema self-contained with only the shared definitions it reaches. Cycles stay
9
+ * references to the same definition. A missing definition stays unresolved and fails when
10
+ * the schema compiles. The schema's own `$defs` keep precedence.
11
+ */
12
+ export declare const bundler: (definitions: Readonly<Record<string, JsonObject>>) => (schema: JsonObject) => JsonObject;
13
+ /**
14
+ * Make account-bound parameters optional. Validators omit the values so they stay account-free;
15
+ * the published schema includes them as `default` so callers can see what an omission sends.
16
+ */
17
+ export declare const parameterDefaultsInput: (op: OpenapiOperation, defaults: OpenapiParameterDefaults | undefined, publish: boolean) => JsonObject;
18
+ /** Account-free validators can be reused inside a Worker for one immutable revision. */
19
+ export declare const prepareOpenapiOperation: (op: OpenapiOperation, definitions: Readonly<Record<string, JsonObject>>, defaults?: OpenapiParameterDefaults) => Effect.Effect<{
20
+ input: Schema.declareConstructor<Schema.Json, Schema.Json, readonly [], Schema.Json>;
21
+ errors: {
22
+ decoder: Schema.declareConstructor<Schema.Json, Schema.Json, readonly [], Schema.Json>;
23
+ code: string;
24
+ status: number;
25
+ message: {
26
+ readonly source: "body";
27
+ } | {
28
+ readonly source: "schema";
29
+ readonly value: string;
30
+ };
31
+ schema: {
32
+ readonly [x: string]: Schema.Json;
33
+ };
34
+ }[];
35
+ output: () => {
36
+ readonly [x: string]: Schema.Json;
37
+ } | undefined;
38
+ }, never, never>;
39
+ export type PreparedOpenapiOperation = Effect.Success<ReturnType<typeof prepareOpenapiOperation>>;
4
40
  /** Decode retained metadata and expose only operations supported by the selected account. */
5
- export declare const openapiToolsEffect: (options: OpenapiToolsOptions) => Effect.Effect<OpenapiTools, OpenapiError>;
41
+ export declare const openapiToolsEffect: (options: OpenapiToolsOptions, prepared?: ReadonlyMap<string, PreparedOpenapiOperation>) => Effect.Effect<OpenapiTools, OpenapiError>;
@@ -7,16 +7,39 @@ import type { ToolAnnotations } from "../contracts/tools.js";
7
7
  import type { JsonObject } from "../contracts/schema.js";
8
8
  import { type Schema } from "./schema.js";
9
9
  declare const NativeOperation: unique symbol;
10
- declare const HandlerContext: unique symbol;
11
- /** A server-only declaration with its category preserved for catalog validation. */
10
+ declare const QueryHandlerContext: unique symbol;
11
+ declare const MutationHandlerContext: unique symbol;
12
+ /**
13
+ * A server-only declaration with its category preserved for catalog validation. Queries and
14
+ * mutations carry their handler context under different phantom keys, so a router can type a
15
+ * query's handler from its query context alone.
16
+ */
12
17
  export interface OperationDeclaration<Kind extends "query" | "mutation", Context = never> {
13
- readonly [HandlerContext]?: (context: Context) => void;
18
+ readonly [QueryHandlerContext]?: "query" extends Kind ? (context: Context) => void : never;
19
+ readonly [MutationHandlerContext]?: "mutation" extends Kind ? (context: Context) => void : never;
14
20
  readonly kind: Kind;
15
21
  readonly [NativeOperation]: Omit<AppOperation<never>, "kind" | "input"> & {
16
22
  readonly kind: Kind;
17
23
  readonly input: EffectSchema.Decoder<unknown>;
18
24
  };
19
25
  }
26
+ /**
27
+ * A router declaration. The phantom contexts let `defineApp` type inline handlers; protocol
28
+ * routers accept any context because their operations only use the framework's own capabilities.
29
+ * The native router is held under a private key in implementation/router.ts.
30
+ */
31
+ export interface RouterDeclaration<Query = unknown, Mutation = unknown> {
32
+ readonly [QueryHandlerContext]?: (context: Query) => void;
33
+ readonly [MutationHandlerContext]?: (context: Mutation) => void;
34
+ readonly [NativeRouterKey]: unknown;
35
+ }
36
+ /** An operation or nested router under one key. Each child is typed only by its own kind's context. */
37
+ export interface RouterChild<Query, Mutation> {
38
+ readonly [QueryHandlerContext]?: (context: Query) => void;
39
+ readonly [MutationHandlerContext]?: (context: Mutation) => void;
40
+ }
41
+ /** Private key for a router's native definition. */
42
+ export declare const NativeRouterKey: unique symbol;
20
43
  /** Typed operation handles drive browser reference inference without bundling handlers. */
21
44
  export interface Operation<Input, Output, Kind extends "query" | "mutation", Context = AppContext> extends OperationDeclaration<Kind, Context> {
22
45
  readonly [NativeOperation]: AppOperation<Input, Output> & {
@@ -17,8 +17,7 @@ interface ProtocolOperation {
17
17
  readonly run: (context: OperationContext, input: JsonValue) => Effect.Effect<unknown, unknown>;
18
18
  }
19
19
  /** Unknown behavior defaults to mutation. Classification never enforces an external service's behavior. */
20
- export declare const protocolOperations: (operations: Readonly<Record<string, ProtocolOperation>>, kinds?: OperationKinds) => {
21
- queries: Record<string, Operation<Schema.Json, unknown, "query", OperationContext>>;
22
- mutations: Record<string, Operation<Schema.Json, unknown, "mutation", OperationContext>>;
23
- };
20
+ export declare const protocolOperations: (operations: Readonly<Record<string, ProtocolOperation>>, kinds?: OperationKinds) => Record<string, Operation<Schema.Json, unknown, "query" | "mutation", OperationContext>>;
21
+ /** Operations already discovered, as a router keyed by upstream name. */
22
+ export declare const protocolRouter: (operations: Readonly<Record<string, ProtocolOperation>>, kinds?: OperationKinds) => import("./operations.js").RouterDeclaration<unknown, unknown>;
24
23
  export {};
@@ -0,0 +1,10 @@
1
+ import { Option } from "effect";
2
+ import { ProviderError } from "../contracts/provider-error.js";
3
+ /** Parse and rebuild the allowlisted fields, including when the input is already an Error instance. */
4
+ export declare function parseProviderError(error: unknown): Option.Option<ProviderError>;
5
+ /** Classify only explicit HTTP evidence. Raw provider content never enters the error. */
6
+ export declare function httpProviderError(status: number, headers?: Readonly<Record<string, string>>): ProviderError | undefined;
7
+ /** Attach the account used by the enclosing operation, without preserving arbitrary thrown fields. */
8
+ export declare function accountProviderError<E>(error: E, accountId: string): E | ProviderError;
9
+ /** GraphQL has no standard auth code; recognize these documented codes without guessing from prose. */
10
+ export declare function graphqlProviderError(errors: readonly unknown[], status: number): ProviderError | undefined;
@@ -1,6 +1,7 @@
1
1
  /** Pure constructors over the native provider contracts. */
2
2
  import { Effect, Schema } from "effect";
3
- import { type AuthMethods, OAuth2Config, OAuth2Method, Provider, SecretsMethod } from "../contracts/provider.js";
3
+ import { type PromiseMethod } from "./authoring.js";
4
+ import { type AccountCheck, type AuthMethods, OAuth2Config, OAuth2Method, Provider, SecretsMethod } from "../contracts/provider.js";
4
5
  import type { ValidationError } from "../contracts/schema.js";
5
6
  /** Declare a secrets method with an Effect decoder. */
6
7
  export declare const secrets: <Fields extends Schema.Decoder<unknown>>(options: {
@@ -9,8 +10,12 @@ export declare const secrets: <Fields extends Schema.Decoder<unknown>>(options:
9
10
  }) => SecretsMethod<Fields>;
10
11
  /** Validate OAuth endpoints while declaring their app-visible response projection. */
11
12
  export declare const oauth2: <Response extends Schema.Decoder<unknown>>(config: OAuth2Config, response: Response) => Effect.Effect<OAuth2Method<Response>, ValidationError>;
12
- /** Retain the provider and literal method names without registering or authenticating it. */
13
- export declare const defineProvider: <const Auth extends AuthMethods>(options: {
13
+ /** Author options: the account check is an ordinary async function. */
14
+ export interface ProviderOptions<Auth extends AuthMethods> {
14
15
  readonly name: string;
15
16
  readonly auth: Auth;
16
- }) => Provider<Auth>;
17
+ /** Verify a connected account with a safe read, optionally reporting its upstream identity. */
18
+ readonly health?: PromiseMethod<AccountCheck<Auth>["run"]>;
19
+ }
20
+ /** Retain the provider and literal method names without registering or authenticating it. */
21
+ export declare const defineProvider: <const Auth extends AuthMethods>({ health, ...options }: ProviderOptions<Auth>) => Provider<Auth>;
@@ -0,0 +1,225 @@
1
+ /**
2
+ * Read a live router tree into tools, routers and router skills. A nested dynamic router that fails
3
+ * is reported on its own entry; the root failing fails the read, as a single-source app would.
4
+ */
5
+ import { Effect, Schema } from "effect";
6
+ import { HostDeclarationInvalid, HostEvaluationFailed, type HostRouterError } from "../contracts/host.js";
7
+ import { McpError } from "../contracts/mcp.js";
8
+ import type { AppOperation } from "../contracts/operations.js";
9
+ import type { AppRouter, DynamicRouter, RouterMeta } from "../contracts/router.js";
10
+ import { SkillLoadFailed } from "../contracts/skills.js";
11
+ import type { OperationSchedule } from "../contracts/schedules.js";
12
+ /**
13
+ * Keep only a failure's safe fields. Anything unrecognized becomes an evaluation failure with the
14
+ * error's name and bounded message, with the given account secrets replaced.
15
+ */
16
+ export declare const safeFailure: (error: unknown, secrets: readonly string[]) => HostRouterError;
17
+ /**
18
+ * Router skills are named `tools` for the root and `tools-<path>` below it, so a router's
19
+ * instructions never take an authored skill's name by accident.
20
+ */
21
+ export declare const routerSkillPrefix = "tools";
22
+ /**
23
+ * The skill name for a router path. A path of lowercase letters and digits is spelled out:
24
+ * `issues.open` is `tools-issues-open`. Any other path, or one too long, is a readable slug
25
+ * followed by a hash of the exact path, such as `tools-issues-list-0123456789`. Plain segments
26
+ * start with a letter and a hash is all digits, so the two forms never meet, and paths that slug
27
+ * alike, such as `issues_list` and `issues.list`, get different names.
28
+ */
29
+ export declare const routerSkillName: (path: string) => string;
30
+ /** A declared operation's catalog entry without schemas. `router` is its owning router's path. */
31
+ export declare const operationSummary: (name: string, router: string, operation: AppOperation, schedules?: readonly OperationSchedule[]) => Effect.Effect<{
32
+ readonly name: string;
33
+ readonly description: string;
34
+ readonly title?: string;
35
+ readonly annotations?: {
36
+ readonly title?: string;
37
+ readonly readOnlyHint?: boolean;
38
+ readonly destructiveHint?: boolean;
39
+ readonly idempotentHint?: boolean;
40
+ readonly openWorldHint?: boolean;
41
+ };
42
+ readonly schedules?: readonly {
43
+ readonly name: string;
44
+ readonly timing: {
45
+ readonly kind: "interval";
46
+ readonly milliseconds: number;
47
+ } | {
48
+ readonly kind: "cron";
49
+ readonly calendar: {
50
+ readonly expression: string;
51
+ readonly timezone: string;
52
+ };
53
+ };
54
+ readonly input: Schema.Json;
55
+ }[];
56
+ readonly readOnly?: boolean;
57
+ readonly router?: string;
58
+ readonly tags?: readonly string[];
59
+ }, HostDeclarationInvalid, never>;
60
+ /** A declared operation's full description, including rendered schemas. */
61
+ export declare const operationDescription: (name: string, router: string, operation: AppOperation, schedules?: readonly OperationSchedule[]) => Effect.Effect<{
62
+ readonly name: string;
63
+ readonly description: string;
64
+ readonly inputSchema: {
65
+ readonly [x: string]: Schema.Json;
66
+ };
67
+ readonly _meta?: {
68
+ readonly [x: string]: Schema.Json;
69
+ };
70
+ readonly title?: string;
71
+ readonly annotations?: {
72
+ readonly title?: string;
73
+ readonly readOnlyHint?: boolean;
74
+ readonly destructiveHint?: boolean;
75
+ readonly idempotentHint?: boolean;
76
+ readonly openWorldHint?: boolean;
77
+ };
78
+ readonly outputSchema?: {
79
+ readonly [x: string]: Schema.Json;
80
+ };
81
+ readonly schedules?: readonly {
82
+ readonly name: string;
83
+ readonly timing: {
84
+ readonly kind: "interval";
85
+ readonly milliseconds: number;
86
+ } | {
87
+ readonly kind: "cron";
88
+ readonly calendar: {
89
+ readonly expression: string;
90
+ readonly timezone: string;
91
+ };
92
+ };
93
+ readonly input: Schema.Json;
94
+ }[];
95
+ readonly readOnly?: boolean;
96
+ readonly router?: string;
97
+ readonly tags?: readonly string[];
98
+ }, HostDeclarationInvalid, never>;
99
+ /**
100
+ * A dynamic router over operations already discovered, such as an eager OpenAPI document or a
101
+ * stdio server. Upstream names can contain dots, which static router keys cannot.
102
+ */
103
+ export declare const fixedRouter: (operations: Readonly<Record<string, AppOperation>>, meta?: RouterMeta) => DynamicRouter;
104
+ export interface CatalogOptions {
105
+ /** Omit schemas. */
106
+ readonly summary: boolean;
107
+ /** Account secrets that a failure's message must not reveal. */
108
+ readonly secrets: readonly string[];
109
+ /** Only these full tool names. Routers with none of them are not read. */
110
+ readonly wanted?: ReadonlySet<string>;
111
+ /** Schedules that target a declared operation, by full name. */
112
+ readonly schedules: (name: string) => readonly OperationSchedule[];
113
+ /**
114
+ * Only declared operations that have schedules. Schedules never target dynamic routers, and
115
+ * their catalogs can be expensive to discover, so none is read.
116
+ */
117
+ readonly scheduled?: true;
118
+ }
119
+ /**
120
+ * Read a router tree. Every nested router is listed, for grouping; the root only when it has
121
+ * metadata. A nested dynamic source that fails is reported on its router's entry.
122
+ */
123
+ export declare const readCatalog: (root: AppRouter | DynamicRouter | undefined, options: CatalogOptions) => Effect.Effect<{
124
+ tools: ({
125
+ readonly name: string;
126
+ readonly description: string;
127
+ readonly inputSchema: {
128
+ readonly [x: string]: Schema.Json;
129
+ };
130
+ readonly _meta?: {
131
+ readonly [x: string]: Schema.Json;
132
+ };
133
+ readonly title?: string;
134
+ readonly annotations?: {
135
+ readonly title?: string;
136
+ readonly readOnlyHint?: boolean;
137
+ readonly destructiveHint?: boolean;
138
+ readonly idempotentHint?: boolean;
139
+ readonly openWorldHint?: boolean;
140
+ };
141
+ readonly outputSchema?: {
142
+ readonly [x: string]: Schema.Json;
143
+ };
144
+ readonly schedules?: readonly {
145
+ readonly name: string;
146
+ readonly timing: {
147
+ readonly kind: "interval";
148
+ readonly milliseconds: number;
149
+ } | {
150
+ readonly kind: "cron";
151
+ readonly calendar: {
152
+ readonly expression: string;
153
+ readonly timezone: string;
154
+ };
155
+ };
156
+ readonly input: Schema.Json;
157
+ }[];
158
+ readonly readOnly?: boolean;
159
+ readonly router?: string;
160
+ readonly tags?: readonly string[];
161
+ } | {
162
+ readonly name: string;
163
+ readonly description: string;
164
+ readonly title?: string;
165
+ readonly annotations?: {
166
+ readonly title?: string;
167
+ readonly readOnlyHint?: boolean;
168
+ readonly destructiveHint?: boolean;
169
+ readonly idempotentHint?: boolean;
170
+ readonly openWorldHint?: boolean;
171
+ };
172
+ readonly schedules?: readonly {
173
+ readonly name: string;
174
+ readonly timing: {
175
+ readonly kind: "interval";
176
+ readonly milliseconds: number;
177
+ } | {
178
+ readonly kind: "cron";
179
+ readonly calendar: {
180
+ readonly expression: string;
181
+ readonly timezone: string;
182
+ };
183
+ };
184
+ readonly input: Schema.Json;
185
+ }[];
186
+ readonly readOnly?: boolean;
187
+ readonly router?: string;
188
+ readonly tags?: readonly string[];
189
+ })[];
190
+ routers: {
191
+ readonly path: string;
192
+ readonly error?: import("../index.js").ProviderError | SkillLoadFailed | McpError | HostDeclarationInvalid | HostEvaluationFailed;
193
+ readonly description?: string;
194
+ readonly title?: string;
195
+ readonly tags?: {
196
+ readonly [x: string]: string;
197
+ };
198
+ readonly icons?: readonly {
199
+ readonly src: string;
200
+ readonly mimeType?: string;
201
+ readonly sizes?: readonly string[];
202
+ readonly theme?: "light" | "dark";
203
+ }[];
204
+ readonly skill?: string;
205
+ }[];
206
+ }, import("../index.js").ProviderError | SkillLoadFailed | McpError | HostDeclarationInvalid | HostEvaluationFailed, never>;
207
+ /**
208
+ * One skill for each router with instructions. Skills and tools fail independently: a dynamic
209
+ * router whose metadata cannot be read, including the root, contributes no skill and does not
210
+ * fail the others. Metadata comes through each source's catalog cache, like a tool listing.
211
+ */
212
+ export declare const routerSkills: (root: AppRouter | DynamicRouter | undefined) => Effect.Effect<{
213
+ readonly name: string;
214
+ readonly description: string;
215
+ readonly files: readonly {
216
+ readonly path: string;
217
+ readonly content: string;
218
+ }[];
219
+ readonly license?: string;
220
+ readonly compatibility?: string;
221
+ readonly metadata?: {
222
+ readonly [x: string]: string;
223
+ };
224
+ readonly "allowed-tools"?: string;
225
+ }[], never, never>;
@@ -0,0 +1,59 @@
1
+ import { HostedTool } from "../contracts/host.js";
2
+ import type { AppOperation } from "../contracts/operations.js";
3
+ import { RouterMeta, type AppRouter, type DynamicRouter, type RouterIcon } from "../contracts/router.js";
4
+ import { type OperationDeclaration, type RouterChild, type RouterDeclaration } from "./operations.js";
5
+ export type { RouterChild, RouterDeclaration } from "./operations.js";
6
+ /** Author metadata for a router. Instructions become a skill named after the router's path. */
7
+ export interface RouterOptions {
8
+ readonly title?: string;
9
+ readonly description?: string;
10
+ readonly instructions?: string;
11
+ readonly icons?: readonly RouterIcon[];
12
+ readonly tags?: Readonly<Record<string, string>>;
13
+ }
14
+ /** Wrap a native router. Protocol helpers use this for the routers they build. */
15
+ export declare const routerDeclaration: (node: AppRouter | DynamicRouter) => RouterDeclaration;
16
+ /** Accept only framework-created routers. */
17
+ export declare const nativeRouter: (value: unknown) => AppRouter | DynamicRouter | undefined;
18
+ /** Author fields win; a field the author omits keeps the source's value. */
19
+ export declare const mergeMeta: (base: RouterMeta | undefined, override: RouterMeta | undefined) => RouterMeta | undefined;
20
+ /**
21
+ * Group operations and routers under path keys, like tRPC's nested routers, with metadata an
22
+ * agent can read. Passing an existing router instead of children overrides its metadata:
23
+ * `router(mcpRouter(options), { description: "..." })`.
24
+ */
25
+ export declare function router<Query = unknown, Mutation = unknown>(children: Readonly<Record<string, RouterChild<Query, Mutation>>>, options?: RouterOptions): RouterDeclaration<Query, Mutation>;
26
+ export declare function router<Query, Mutation>(source: RouterDeclaration<Query, Mutation>, options: RouterOptions): RouterDeclaration<Query, Mutation>;
27
+ /**
28
+ * Declare a router whose tools are discovered when read. `list` returns tools with names relative
29
+ * to this router; mark queries with `readOnly: true`. `resolve` receives one of those names.
30
+ */
31
+ export declare const dynamicRouter: (source: {
32
+ readonly meta?: () => RouterOptions | Promise<RouterOptions>;
33
+ readonly list: () => readonly HostedTool[] | Promise<readonly HostedTool[]>;
34
+ readonly resolve: (name: string) => OperationDeclaration<"query" | "mutation", unknown> | undefined | Promise<OperationDeclaration<"query" | "mutation", unknown> | undefined>;
35
+ }) => RouterDeclaration;
36
+ /** Join a router path and a relative name. The root router's path is "". */
37
+ export declare const joinPath: (path: string, name: string) => string;
38
+ /** Where a full tool name points: a declared operation, or a name inside a dynamic router. */
39
+ export type Location = {
40
+ readonly kind: "operation";
41
+ readonly operation: AppOperation;
42
+ readonly router: string;
43
+ } | {
44
+ readonly kind: "dynamic";
45
+ readonly source: DynamicRouter;
46
+ readonly router: string;
47
+ readonly name: string;
48
+ };
49
+ /**
50
+ * Walk static keys until the name ends at an operation or enters a dynamic router, which receives
51
+ * the rest of the name. Static keys contain no dots, so every name has at most one location.
52
+ */
53
+ export declare const locate: (root: AppRouter | DynamicRouter | undefined, name: string) => Location | undefined;
54
+ /** Every declared operation with its full name and owning router. Dynamic routers are not listed. */
55
+ export declare const declaredOperations: (root: AppRouter | undefined, path?: string) => Array<{
56
+ readonly name: string;
57
+ readonly router: string;
58
+ readonly operation: AppOperation;
59
+ }>;
@@ -1,6 +1,6 @@
1
1
  /** Author schema facade. Internals use the native decoder retained by each value. */
2
2
  import { Effect, Schema as EffectSchema } from "effect";
3
- import { ValidationError, type JsonObject } from "../contracts/schema.js";
3
+ import { JsonObject, ValidationError } from "../contracts/schema.js";
4
4
  import type { Field } from "../../../app-data/src/contracts/database.js";
5
5
  declare const StorageField: unique symbol;
6
6
  declare const Decoder: unique symbol;
@@ -64,6 +64,10 @@ declare const ImportedJsonSchema: unique symbol;
64
64
  export declare const importedJsonSchema: (decoder: EffectSchema.Decoder<unknown>) => unknown | undefined;
65
65
  /** Attach a composed discovery document without replacing its authoritative native decoder. */
66
66
  export declare const withJsonSchemaDocument: <S extends EffectSchema.Decoder<unknown>>(decoder: S, document: JsonObject) => S;
67
+ /** Compute a value on first use and reuse it. */
68
+ export declare const once: <A>(compute: () => A) => (() => A);
69
+ /** Attach a discovery document that is built only when it is first read. */
70
+ export declare const withLazyJsonSchemaDocument: <S extends EffectSchema.Decoder<unknown>>(decoder: S, document: () => JsonObject) => S;
67
71
  /**
68
72
  * Relocate a self-contained JSON Schema under a document pointer. Resolve references
69
73
  * before nesting so account schemas can reuse definition names, IDs and anchors.
@@ -76,12 +80,9 @@ export declare const compileJsonSchemaDecoder: (document: JsonObject) => Effect.
76
80
  readonly [x: string]: EffectSchema.Json;
77
81
  };
78
82
  }, ValidationError, never>;
83
+ export declare const lazyJsonSchemaDecoder: (document: () => JsonObject) => Effect.Effect<EffectSchema.declareConstructor<EffectSchema.Json, EffectSchema.Json, readonly [], EffectSchema.Json>, never, never>;
79
84
  /** Preserve the JSON document; compile its validator only when a value is first decoded. */
80
- export declare const jsonSchemaDecoder: (input: unknown) => Effect.Effect<EffectSchema.declareConstructor<EffectSchema.Json, EffectSchema.Json, readonly [], EffectSchema.Json> & {
81
- [ImportedJsonSchema]: {
82
- readonly [x: string]: EffectSchema.Json;
83
- };
84
- }, ValidationError, never>;
85
+ export declare const jsonSchemaDecoder: (input: unknown) => Effect.Effect<EffectSchema.declareConstructor<EffectSchema.Json, EffectSchema.Json, readonly [], EffectSchema.Json>, ValidationError, never>;
85
86
  /** Import JSON metadata now; unsupported schemas and invalid values fail when parsed. */
86
87
  export declare const jsonSchema: (input: unknown) => Schema<EffectSchema.Json>;
87
88
  /** Database declaration retained by primitive constructors; nested payload schemas are not database fields. */
@@ -90,4 +91,8 @@ export declare const storageFieldOf: (schema: Schema<unknown, boolean>) => Field
90
91
  export declare const id: (table: string) => Schema<string>;
91
92
  /** A host user identifier, stored as a string without imposing a product auth model. */
92
93
  export declare const userId: () => Schema<string>;
94
+ /** Render a decoder as a JSON Schema document, keeping an imported upstream document as-is. */
95
+ export declare const jsonSchemaDocument: (decoder: EffectSchema.Decoder<unknown>) => Effect.Effect<{
96
+ readonly [x: string]: EffectSchema.Json;
97
+ }, EffectSchema.SchemaError, never>;
93
98
  export {};
@@ -0,0 +1,10 @@
1
+ /** One parser for packaged, GitHub and well-known skill files. */
2
+ import { Effect } from "effect";
3
+ import { AppSkillSource, SkillDefinitionInvalid, SkillFile, type FolderSkillsOptions } from "../contracts/skills.js";
4
+ /** Parse one skill directory, retaining its full document and validating an optional source name. */
5
+ export declare const skillFromFiles: (input: readonly SkillFile[], source?: {
6
+ readonly directory?: string;
7
+ readonly name?: string;
8
+ }) => Effect.Effect<AppSkillSource, SkillDefinitionInvalid>;
9
+ /** Select immediate skill directories from packaged text files. Never accesses the host filesystem. */
10
+ export declare const folderSkillsEffect: (options: FolderSkillsOptions) => Effect.Effect<readonly AppSkillSource[], SkillDefinitionInvalid>;
@@ -0,0 +1,43 @@
1
+ /** Remote skill readers return complete portable bundles, never installed host files. */
2
+ import { Effect } from "effect";
3
+ import { SkillLoadFailed, type GitHubSkillsOptions, type WellKnownSkillsOptions, type SkillTransport } from "../contracts/skills.js";
4
+ /** Give every failure without a message one that names the service. */
5
+ export declare const withService: (service: string | undefined) => <A, R>(effect: Effect.Effect<A, SkillLoadFailed, R>) => Effect.Effect<A, SkillLoadFailed, R>;
6
+ /** One loader invocation owns its byte budget and all of its network requests. */
7
+ export declare const reader: (transport: SkillTransport) => Effect.Effect<{
8
+ fetchBytes: (url: string, post?: {
9
+ readonly body: Uint8Array;
10
+ readonly headers: Record<string, string>;
11
+ }) => Effect.Effect<Uint8Array<ArrayBuffer>, SkillLoadFailed, never>;
12
+ read: (url: string) => Effect.Effect<string, SkillLoadFailed, never>;
13
+ json: (url: string) => Effect.Effect<unknown, SkillLoadFailed, never>;
14
+ }, never, never>;
15
+ export declare const githubSkillsEffect: (options: GitHubSkillsOptions) => Effect.Effect<readonly {
16
+ readonly name: string;
17
+ readonly description: string;
18
+ readonly files: readonly {
19
+ readonly path: string;
20
+ readonly content: string;
21
+ }[];
22
+ readonly license?: string;
23
+ readonly compatibility?: string;
24
+ readonly metadata?: {
25
+ readonly [x: string]: string;
26
+ };
27
+ readonly "allowed-tools"?: string;
28
+ }[], SkillLoadFailed, never>;
29
+ /** Fetch all indexed files and reject a publication whose index changes during the read. */
30
+ export declare const wellKnownSkillsEffect: (options: WellKnownSkillsOptions) => Effect.Effect<readonly {
31
+ readonly name: string;
32
+ readonly description: string;
33
+ readonly files: readonly {
34
+ readonly path: string;
35
+ readonly content: string;
36
+ }[];
37
+ readonly license?: string;
38
+ readonly compatibility?: string;
39
+ readonly metadata?: {
40
+ readonly [x: string]: string;
41
+ };
42
+ readonly "allowed-tools"?: string;
43
+ }[], SkillLoadFailed, never>;
@@ -1,10 +1,12 @@
1
- import { type DatabaseSession } from "../../../app-data/src/index.js";
1
+ import { type DatabaseSession, type reservedFieldNames } from "../../../app-data/src/index.js";
2
+ type ReservedFieldName = (typeof reservedFieldNames)[number];
2
3
  import { type AppStorage } from "../contracts/storage.js";
3
4
  import type { DatabaseDefinition, Database, Table, Tables } from "../contracts/storage.js";
4
5
  import { type Fields } from "./schema.js";
5
6
  export type { DatabaseDefinition, Database, DatabaseReader, Table, Tables, RowOf, } from "../contracts/storage.js";
6
- /** Declare scalar columns using the same schemas as operation inputs. */
7
- export declare const table: <const F extends Fields>(fields: F) => Table<F>;
7
+ /** Declare scalar columns using the same schemas as operation inputs. The host adds `id`,
8
+ * `createdAt` and `updatedAt` to every row, so tables cannot declare those names. */
9
+ export declare const table: <const F extends Fields & { readonly [K in ReservedFieldName]?: never; }>(fields: F) => Table<F>;
8
10
  /** Build a fresh Promise database facade for one authorized invocation. */
9
11
  export declare const authorDatabase: <T extends Tables>(tables: T, session: DatabaseSession, signal: AbortSignal, writable: boolean) => Database<T>;
10
12
  /** Declare storage independently of handlers; the host binds each invocation's database. */
@@ -0,0 +1,28 @@
1
+ /** Swagger is most of the OpenAPI module's code. Discovery from a cached catalog never needs it,
2
+ * so a cold app Worker evaluates it only when it resolves a document or builds a request.
3
+ */
4
+ import "../contracts/swagger-client.ts";
5
+ export type SwaggerClient = typeof import("swagger-client").default;
6
+ export declare const loadSwaggerClient: () => Promise<{
7
+ buildRequest(options: {
8
+ spec: unknown;
9
+ operationId?: string;
10
+ pathName?: string;
11
+ method?: string;
12
+ parameters?: Readonly<Record<string, unknown>>;
13
+ requestBody?: unknown;
14
+ requestContentType?: string;
15
+ securities?: {
16
+ authorized: Readonly<Record<string, unknown>>;
17
+ };
18
+ }): unknown;
19
+ resolve(options: {
20
+ spec: unknown;
21
+ skipNormalization: boolean;
22
+ useCircularStructures: boolean;
23
+ requestInterceptor: () => never;
24
+ }): Promise<{
25
+ spec: unknown;
26
+ errors: readonly unknown[];
27
+ }>;
28
+ }>;