apps 0.0.1-beta.5 → 0.0.1-beta.6

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 (63) hide show
  1. package/README.md +65 -43
  2. package/framework-reference.json +1 -1
  3. package/js/{chunk-FWQC6I3C.js → chunk-5T57N25Q.js} +13 -1
  4. package/js/{chunk-67EVWIGJ.js → chunk-6BSSI67S.js} +4 -4
  5. package/js/{chunk-DQAZTA4I.js → chunk-B3EOZTK3.js} +212 -19
  6. package/js/{chunk-TDNYXSIX.js → chunk-ECQFRCH4.js} +21 -9
  7. package/js/{chunk-UDDE5KOR.js → chunk-ITM77QPO.js} +26 -7
  8. package/js/{chunk-G7T27IWB.js → chunk-MKWZPDR6.js} +1 -1
  9. package/js/chunk-MNMNLXBL.js +507 -0
  10. package/js/{chunk-CYYBFC2K.js → chunk-NKLWZJLE.js} +1 -1
  11. package/js/{chunk-C3VAOK5B.js → chunk-OE3QQTSB.js} +33 -26
  12. package/js/{chunk-YEPYT6SD.js → chunk-R3EV5FTO.js} +12 -0
  13. package/js/{chunk-XHO2ZX6W.js → chunk-RFVIONFX.js} +27 -10
  14. package/js/{chunk-LUVSFETN.js → chunk-SB4HEPNJ.js} +72 -228
  15. package/js/chunk-T7GKZBLP.js +209 -0
  16. package/js/client.js +1 -1
  17. package/js/contracts.js +24 -11
  18. package/js/effect.js +9 -11
  19. package/js/graphql.js +25 -32
  20. package/js/host.js +9 -11
  21. package/js/index.js +184 -173
  22. package/js/mcp/effect.js +11 -13
  23. package/js/mcp/stdio.js +15 -17
  24. package/js/mcp.js +50 -36
  25. package/js/openapi.js +166 -108
  26. package/js/skills.js +6 -7
  27. package/package.json +1 -1
  28. package/runtime.json +1 -1
  29. package/types/apps/src/contracts/app.d.ts +2 -5
  30. package/types/apps/src/contracts/host.d.ts +11 -7
  31. package/types/apps/src/contracts/mcp.d.ts +16 -0
  32. package/types/apps/src/contracts/openapi.d.ts +4 -0
  33. package/types/apps/src/contracts/operations.d.ts +0 -5
  34. package/types/apps/src/contracts/protocol-version.d.ts +2 -2
  35. package/types/apps/src/contracts/protocols/4.d.ts +1229 -0
  36. package/types/apps/src/contracts/router.d.ts +59 -0
  37. package/types/apps/src/graphql.d.ts +1 -3
  38. package/types/apps/src/implementation/account-router.d.ts +12 -0
  39. package/types/apps/src/implementation/app.d.ts +5 -4
  40. package/types/apps/src/implementation/catalog-cache.d.ts +9 -2
  41. package/types/apps/src/implementation/graphql-catalog.d.ts +1 -4
  42. package/types/apps/src/implementation/mcp-catalog.d.ts +1 -4
  43. package/types/apps/src/implementation/mcp-client.d.ts +35 -19
  44. package/types/apps/src/implementation/mcp.d.ts +35 -19
  45. package/types/apps/src/implementation/openapi-compile.d.ts +2 -1
  46. package/types/apps/src/implementation/openapi-source.d.ts +2 -6
  47. package/types/apps/src/implementation/operations.d.ts +26 -3
  48. package/types/apps/src/implementation/protocol-operations.d.ts +3 -4
  49. package/types/apps/src/implementation/router-catalog.d.ts +225 -0
  50. package/types/apps/src/implementation/router.d.ts +59 -0
  51. package/types/apps/src/implementation/schema.d.ts +5 -1
  52. package/types/apps/src/implementation/workflow-context.d.ts +1 -1
  53. package/types/apps/src/index.d.ts +3 -2
  54. package/types/apps/src/mcp-stdio.d.ts +2 -5
  55. package/types/apps/src/mcp.d.ts +5 -4
  56. package/types/apps/src/openapi.d.ts +6 -6
  57. package/js/chunk-3XKZDQLM.js +0 -93
  58. package/js/chunk-4M277YTM.js +0 -136
  59. package/js/chunk-SB3V4YVR.js +0 -18
  60. package/js/chunk-W4DMKWAB.js +0 -35
  61. package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
  62. package/types/apps/src/implementation/account-operations.d.ts +0 -151
  63. package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
@@ -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;
@@ -91,4 +91,8 @@ export declare const storageFieldOf: (schema: Schema<unknown, boolean>) => Field
91
91
  export declare const id: (table: string) => Schema<string>;
92
92
  /** A host user identifier, stored as a string without imposing a product auth model. */
93
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>;
94
98
  export {};
@@ -8,7 +8,7 @@ import { WorkflowFailure, type WorkflowContext, type WorkflowExecution, type Wor
8
8
  */
9
9
  export declare const workflowSafe: <A>(work: Effect.Effect<A, unknown>, secrets: readonly string[]) => Effect.Effect<A, WorkflowFailure>;
10
10
  /** Construct one replay's Promise context. Step callbacks acquire fresh capabilities per actual attempt. */
11
- export declare const makeWorkflowContext: (execution: WorkflowExecution, definition: Pick<AppDefinition<never>, "queries" | "mutations">,
11
+ export declare const makeWorkflowContext: (execution: WorkflowExecution, definition: Pick<AppDefinition<never>, "tools">,
12
12
  /** A step attempt's context, and the raw account secrets its failures must not reveal. */
13
13
  fresh: (stepId: string, signal: AbortSignal) => Effect.Effect<{
14
14
  readonly context: WorkflowStepContext;
@@ -16,8 +16,9 @@ export { type JsonObject, type JsonValue, ValidationError } from "./contracts/sc
16
16
  export { type Fields, type Infer, type ObjectSchema, type ObjectValue, type Schema, array, boolean, json, jsonSchema, literal, number, object, record, string, } from "./implementation/schema.js";
17
17
  export { type AccountOf, type AuthMethod, type AuthMethodData, type AuthMethods, type ManyAccounts, type OAuth2Config, type Provider, } from "./contracts/provider.js";
18
18
  export { defineProvider } from "./implementation/provider.js";
19
- export { accountOperations } from "./implementation/account-operations.js";
20
- export { dynamicTools } from "./implementation/dynamic-tools.js";
19
+ export { accountRouter } from "./implementation/account-router.js";
20
+ export { router, dynamicRouter, type RouterDeclaration, type RouterChild, type RouterOptions, } from "./implementation/router.js";
21
+ export type { RouterIcon } from "./contracts/router.js";
21
22
  export { dynamicSkills } from "./implementation/dynamic-skills.js";
22
23
  export type { HostedTool as OperationDescription } from "./contracts/host.js";
23
24
  /** A secrets declaration inferred from an author schema. */
@@ -1,8 +1,5 @@
1
1
  import type { ProcessConfig } from "./contracts/mcp.js";
2
2
  import { type OperationKinds } from "./implementation/protocol-operations.js";
3
3
  export { McpError, type McpToolContext, type ProcessConfig } from "./contracts/mcp.js";
4
- /** Discover an account's tools; each discovery and call owns and closes its subprocess. */
5
- export declare const stdioOperations: (config: ProcessConfig, signal?: AbortSignal, kinds?: OperationKinds) => Promise<{
6
- queries: Record<string, import("./index.js").Operation<import("effect/Schema").Json, unknown, "query", import("./index.js").OperationContext>>;
7
- mutations: Record<string, import("./index.js").Operation<import("effect/Schema").Json, unknown, "mutation", import("./index.js").OperationContext>>;
8
- }>;
4
+ /** Discover an account's tools as a router; each discovery and call owns and closes its subprocess. */
5
+ export declare const stdioRouter: (config: ProcessConfig, signal?: AbortSignal, kinds?: OperationKinds) => Promise<import("./index.js").RouterDeclaration<unknown, unknown>>;
@@ -3,8 +3,9 @@ import type { OperationKinds } from "./implementation/protocol-operations.js";
3
3
  import { type McpCatalogOptions } from "./implementation/mcp-catalog.js";
4
4
  export type { McpCatalogOptions } from "./implementation/mcp-catalog.js";
5
5
  export { McpError, type McpToolContext, type McpToolsOptions, type McpToolResult, } from "./contracts/mcp.js";
6
- /** Discover operations for the selected account. Kinds override uncertain upstream read-only hints. */
7
- export declare const mcpOperations: (options: McpCatalogOptions, kinds?: OperationKinds) => Promise<{
8
- dynamicTools: import("./contracts/dynamic-tools.js").DynamicTools;
9
- }>;
6
+ /**
7
+ * A router over a server's tools for the selected account. Its title, description and
8
+ * instructions come from the server. Kinds override uncertain upstream read-only hints.
9
+ */
10
+ export declare const mcpRouter: (options: McpCatalogOptions, kinds?: OperationKinds) => Promise<import("./index.js").RouterDeclaration<unknown, unknown>>;
10
11
  export type { OperationKinds } from "./implementation/protocol-operations.js";
@@ -2,11 +2,11 @@
2
2
  import { type OperationKinds } from "./implementation/protocol-operations.js";
3
3
  import type { OpenapiToolsOptions } from "./contracts/openapi.js";
4
4
  export { OpenapiError, isOpenapiTextMedia, openapiBinaryResultSchema, OpenapiErrorResponse, type OpenapiToolsOptions, type OpenapiOperation, type CredentialBinding, OpenapiParameter, OpenapiRequestBody, openapiMediaKind, } from "./contracts/openapi.js";
5
- /** Discover operations for the selected account. Kinds override uncertain upstream read-only hints. */
6
- export declare const openapiOperations: (options: OpenapiToolsOptions, kinds?: OperationKinds) => Promise<{
7
- queries: Record<string, import("./index.js").Operation<import("effect/Schema").Json, unknown, "query", import("./index.js").OperationContext>>;
8
- mutations: Record<string, import("./index.js").Operation<import("effect/Schema").Json, unknown, "mutation", import("./index.js").OperationContext>>;
9
- }>;
5
+ /**
6
+ * Discover a document's operations as a router for the selected account. Kinds override uncertain
7
+ * upstream read-only hints. Mount it under a key, or override its metadata with `router(...)`.
8
+ */
9
+ export declare const openapiRouter: (options: OpenapiToolsOptions, kinds?: OperationKinds) => Promise<import("./index.js").RouterDeclaration<unknown, unknown>>;
10
10
  export type { OperationKinds } from "./implementation/protocol-operations.js";
11
11
  export * from "./contracts/openapi-compile.js";
12
- export { liveOpenapiOperations, type OpenapiSourceOptions, } from "./implementation/openapi-source.js";
12
+ export { liveOpenapiRouter, type OpenapiSourceOptions } from "./implementation/openapi-source.js";
@@ -1,93 +0,0 @@
1
- import {
2
- decoderOf
3
- } from "./chunk-FWQC6I3C.js";
4
- import {
5
- Effect_exports
6
- } from "./chunk-CDL5PM2Q.js";
7
-
8
- // src/implementation/authoring.ts
9
- var NativeCallback = /* @__PURE__ */ Symbol("apps.NativeCallback");
10
- var fromPromise = (callback) => (...args) => {
11
- if (NativeCallback in callback) {
12
- const native = callback[NativeCallback];
13
- return native(...args);
14
- }
15
- return Effect_exports.tryPromise({ try: () => callback(...args), catch: (error) => error });
16
- };
17
- var toPromise = (operation, signal) => {
18
- const native = (...args) => Effect_exports.suspend(() => {
19
- if (signal === void 0) return operation(...args);
20
- if (signal.aborted) return Effect_exports.interrupt;
21
- const cancelled = Effect_exports.callback((resume) => {
22
- if (signal.aborted) {
23
- resume(Effect_exports.interrupt);
24
- return;
25
- }
26
- const abort = () => resume(Effect_exports.interrupt);
27
- signal.addEventListener("abort", abort, { once: true });
28
- return Effect_exports.sync(() => signal.removeEventListener("abort", abort));
29
- });
30
- return Effect_exports.raceFirst(
31
- cancelled,
32
- Effect_exports.suspend(() => operation(...args))
33
- );
34
- });
35
- return Object.assign((...args) => Effect_exports.runPromise(native(...args)), {
36
- [NativeCallback]: native
37
- });
38
- };
39
-
40
- // src/implementation/operations.ts
41
- var NativeOperation = /* @__PURE__ */ Symbol("apps.Operation");
42
- var operationDeclaration = (operation) => ({
43
- kind: operation.kind,
44
- [NativeOperation]: operation
45
- });
46
- var nativeOperation = (value) => {
47
- if (typeof value !== "object" || value === null || !(NativeOperation in value)) return void 0;
48
- return value[NativeOperation];
49
- };
50
- var operationOptions = (options) => {
51
- const approval = options.approval;
52
- return {
53
- ...options.description === void 0 ? {} : { description: options.description },
54
- ...options.title === void 0 ? {} : { title: options.title },
55
- ...options.annotations === void 0 ? {} : { annotations: options.annotations },
56
- ...options._meta === void 0 ? {} : { _meta: options._meta },
57
- input: decoderOf(options.input),
58
- ...approval === void 0 ? {} : {
59
- approval: (context) => Effect_exports.tryPromise({ try: async () => approval(context), catch: (error) => error })
60
- }
61
- };
62
- };
63
- var withApproval = (operation, approval) => ({
64
- ...operation,
65
- [NativeOperation]: {
66
- ...operation[NativeOperation],
67
- approval: (context) => Effect_exports.tryPromise({ try: async () => approval(context), catch: (error) => error })
68
- }
69
- });
70
- var make = (kind, options, run) => operationDeclaration({
71
- ...operationOptions(options),
72
- kind,
73
- // The host always validates JSON serialization, even without a stronger output declaration.
74
- ...options.output === void 0 ? {} : { output: decoderOf(options.output) },
75
- run: (context, input) => Effect_exports.tryPromise({
76
- // SAFETY: defineApp checks the handler context against its requirements.
77
- // The host validates account bindings and creates the matching storage facade.
78
- try: () => run(context, input),
79
- catch: (error) => error
80
- })
81
- });
82
- var query = (options, run) => make("query", options, run);
83
- var mutation = (options, run) => make("mutation", options, run);
84
-
85
- export {
86
- fromPromise,
87
- toPromise,
88
- operationDeclaration,
89
- nativeOperation,
90
- withApproval,
91
- query,
92
- mutation
93
- };
@@ -1,136 +0,0 @@
1
- import {
2
- ApiErrorResponse
3
- } from "./chunk-W4DMKWAB.js";
4
- import {
5
- AccountId,
6
- HttpUrl,
7
- JsonObject
8
- } from "./chunk-27F7W2LG.js";
9
- import {
10
- Schema_exports
11
- } from "./chunk-CDL5PM2Q.js";
12
-
13
- // src/contracts/openapi.ts
14
- var OpenapiErrorResponse = Schema_exports.Struct({
15
- code: ApiErrorResponse.fields.code,
16
- status: ApiErrorResponse.fields.status,
17
- message: Schema_exports.Union([
18
- Schema_exports.Struct({ source: Schema_exports.Literal("body") }),
19
- Schema_exports.Struct({ source: Schema_exports.Literal("schema"), value: ApiErrorResponse.fields.message })
20
- ]),
21
- schema: JsonObject
22
- });
23
- var OpenapiParameter = Schema_exports.Struct({
24
- name: Schema_exports.String,
25
- in: Schema_exports.Literals(["path", "query", "header", "cookie"]),
26
- required: Schema_exports.optionalKey(Schema_exports.Boolean),
27
- schema: Schema_exports.optionalKey(JsonObject),
28
- style: Schema_exports.optionalKey(Schema_exports.String),
29
- explode: Schema_exports.optionalKey(Schema_exports.Boolean),
30
- allowReserved: Schema_exports.optionalKey(Schema_exports.Boolean),
31
- allowEmptyValue: Schema_exports.optionalKey(Schema_exports.Boolean),
32
- content: Schema_exports.optionalKey(JsonObject)
33
- });
34
- var OpenapiRequestBody = Schema_exports.Struct({
35
- required: Schema_exports.optionalKey(Schema_exports.Boolean),
36
- content: Schema_exports.Record(
37
- Schema_exports.String,
38
- Schema_exports.Struct({
39
- schema: Schema_exports.optionalKey(JsonObject),
40
- encoding: Schema_exports.optionalKey(JsonObject)
41
- })
42
- )
43
- });
44
- var OpenapiOperation = Schema_exports.Struct({
45
- /** The tool name after `queries.` or `mutations.`, grouped as `<group>.<leaf>`. */
46
- name: Schema_exports.NonEmptyString,
47
- /** The document's operationId, when it declares one. `kinds` overrides are keyed by it. */
48
- operationId: Schema_exports.optionalKey(Schema_exports.String),
49
- description: Schema_exports.String,
50
- method: Schema_exports.Literals(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]),
51
- path: Schema_exports.String,
52
- baseUrl: HttpUrl,
53
- openapi: Schema_exports.String,
54
- securitySchemes: Schema_exports.Record(Schema_exports.String, JsonObject),
55
- /** The resolved OpenAPI Operation Object; Executor schemas remain separate. */
56
- request: Schema_exports.Struct({
57
- parameters: Schema_exports.Array(OpenapiParameter),
58
- requestBody: Schema_exports.optionalKey(OpenapiRequestBody),
59
- security: Schema_exports.Array(Schema_exports.Record(Schema_exports.String, Schema_exports.Array(Schema_exports.String))),
60
- responses: Schema_exports.Record(Schema_exports.String, JsonObject)
61
- }),
62
- /** Streams remain in the metadata but cannot run through a single-result tool call. */
63
- streaming: Schema_exports.optionalKey(Schema_exports.Literal(true)),
64
- input: JsonObject,
65
- outputSchema: Schema_exports.optionalKey(JsonObject),
66
- errorResponses: Schema_exports.optionalKey(Schema_exports.Array(OpenapiErrorResponse))
67
- });
68
- var CredentialBinding = Schema_exports.Struct({
69
- scheme: Schema_exports.String,
70
- field: Schema_exports.String,
71
- part: Schema_exports.Literals(["value", "username", "password"]),
72
- prefix: Schema_exports.String
73
- });
74
- var OpenapiAccount = Schema_exports.Struct({
75
- id: Schema_exports.optional(AccountId),
76
- method: Schema_exports.String,
77
- fields: Schema_exports.Record(Schema_exports.String, Schema_exports.Unknown)
78
- });
79
- var OpenapiParameterDefaults = Schema_exports.Struct({
80
- path: Schema_exports.optionalKey(Schema_exports.Record(Schema_exports.String, Schema_exports.String)),
81
- query: Schema_exports.optionalKey(Schema_exports.Record(Schema_exports.String, Schema_exports.String)),
82
- headers: Schema_exports.optionalKey(Schema_exports.Record(Schema_exports.String, Schema_exports.String))
83
- });
84
- var OpenapiToolsOptions = Schema_exports.Struct({
85
- operations: Schema_exports.Array(OpenapiOperation),
86
- /**
87
- * Component schemas stored once per app and referenced as `#/$defs/<name>`. Operations
88
- * generated before shared definitions carry their own `$defs` and omit this.
89
- */
90
- definitions: Schema_exports.optional(Schema_exports.Record(Schema_exports.String, JsonObject)),
91
- methods: Schema_exports.Record(Schema_exports.String, Schema_exports.Array(CredentialBinding)),
92
- oauth: Schema_exports.Array(Schema_exports.String),
93
- account: Schema_exports.optional(OpenapiAccount),
94
- parameterDefaults: Schema_exports.optional(OpenapiParameterDefaults),
95
- signal: Schema_exports.optional(Schema_exports.instanceOf(AbortSignal)),
96
- fetch: Schema_exports.optional(
97
- Schema_exports.declare((value) => typeof value === "function")
98
- )
99
- });
100
- var OpenapiError = class extends Schema_exports.TaggedError()("OpenapiError", {
101
- reason: Schema_exports.Literals(["invalid_definition", "invalid_input", "request"]),
102
- status: Schema_exports.optional(Schema_exports.Number)
103
- }) {
104
- };
105
- var defaultOpenapiResponseLimits = {
106
- maxBodyBytes: 16777216,
107
- readTimeoutMs: 3e4
108
- };
109
- var isOpenapiTextMedia = (type) => /^(?:text\/|application\/(?:[\w.-]+\+)?(?:json|xml)|application\/(?:javascript|x-ndjson|x-www-form-urlencoded))/i.test(
110
- type
111
- );
112
- var isOpenapiFileSchema = (shape) => shape.contentMediaType !== void 0 && shape.contentEncoding === void 0 || shape.type === "string" && shape.format === "binary";
113
- var openapiBinaryResultSchema = {
114
- type: "object",
115
- properties: {
116
- base64: { type: "string", contentEncoding: "base64" },
117
- contentType: { type: "string" }
118
- },
119
- required: ["base64", "contentType"],
120
- additionalProperties: false
121
- };
122
- var openapiMediaKind = (type) => type.includes("json") && !type.includes("ndjson") ? "json" : type === "application/x-www-form-urlencoded" ? "form" : type === "multipart/form-data" ? "multipart" : isOpenapiTextMedia(type) ? "text" : "binary";
123
-
124
- export {
125
- OpenapiErrorResponse,
126
- OpenapiParameter,
127
- OpenapiRequestBody,
128
- OpenapiOperation,
129
- OpenapiToolsOptions,
130
- OpenapiError,
131
- defaultOpenapiResponseLimits,
132
- isOpenapiTextMedia,
133
- isOpenapiFileSchema,
134
- openapiBinaryResultSchema,
135
- openapiMediaKind
136
- };
@@ -1,18 +0,0 @@
1
- import {
2
- AccountId
3
- } from "./chunk-27F7W2LG.js";
4
- import {
5
- Schema_exports
6
- } from "./chunk-CDL5PM2Q.js";
7
-
8
- // src/contracts/provider-error.ts
9
- var ProviderError = class extends Schema_exports.TaggedError()("ProviderError", {
10
- reason: Schema_exports.Literals(["unauthorized", "forbidden", "rate_limited", "unavailable", "rejected"]),
11
- status: Schema_exports.optional(Schema_exports.Int.check(Schema_exports.isBetween({ minimum: 100, maximum: 599 }))),
12
- accountId: Schema_exports.optional(AccountId)
13
- }) {
14
- };
15
-
16
- export {
17
- ProviderError
18
- };
@@ -1,35 +0,0 @@
1
- import {
2
- Schema_exports
3
- } from "./chunk-CDL5PM2Q.js";
4
-
5
- // src/contracts/api-response-error.ts
6
- var ApiErrorRecovery = Schema_exports.Struct({
7
- action: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(1024)),
8
- instructions: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(4096))
9
- });
10
- var ApiErrorResponse = Schema_exports.Struct({
11
- code: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(128)),
12
- status: Schema_exports.Int.check(Schema_exports.isBetween({ minimum: 400, maximum: 599 })),
13
- message: Schema_exports.NonEmptyString.check(Schema_exports.isMaxLength(4096)),
14
- recovery: Schema_exports.optionalKey(ApiErrorRecovery)
15
- });
16
- var OpenapiResponseError = class extends Schema_exports.TaggedError()(
17
- "OpenapiResponseError",
18
- ApiErrorResponse.fields
19
- ) {
20
- };
21
- var OpenapiErrorLimits = Schema_exports.Struct({
22
- maxBodyBytes: Schema_exports.Int.check(Schema_exports.isGreaterThan(0)),
23
- readTimeoutMs: Schema_exports.Int.check(Schema_exports.isGreaterThan(0))
24
- });
25
- var defaultOpenapiErrorLimits = OpenapiErrorLimits.make({
26
- maxBodyBytes: 65536,
27
- readTimeoutMs: 2e3
28
- });
29
-
30
- export {
31
- ApiErrorRecovery,
32
- ApiErrorResponse,
33
- OpenapiResponseError,
34
- defaultOpenapiErrorLimits
35
- };
@@ -1,13 +0,0 @@
1
- /** Lazy operation discovery and resolution. Executables remain invocation-owned. */
2
- import type { Effect } from "effect";
3
- import type { HostedTool, HostedToolSummary } from "./host.js";
4
- import type { AppOperation } from "./operations.js";
5
- /** Tool names include their queries./mutations. prefix. Resolution never requires listing. */
6
- export interface DynamicTools {
7
- readonly list: () => Effect.Effect<readonly HostedTool[], unknown>;
8
- readonly resolve: (name: string) => Effect.Effect<AppOperation | undefined, unknown>;
9
- /** Names and descriptions without schemas. Omitted sources reduce list(). */
10
- readonly summaries?: () => Effect.Effect<readonly HostedToolSummary[], unknown>;
11
- /** One tool's full metadata without listing. Omitted sources search list(). */
12
- readonly describe?: (name: string) => Effect.Effect<HostedTool | undefined, unknown>;
13
- }
@@ -1,151 +0,0 @@
1
- /** Combine account-bound protocol operations without changing their upstream inputs. */
2
- import { Effect, Schema } from "effect";
3
- import type { DynamicTools } from "../contracts/dynamic-tools.js";
4
- import type { AppOperation, OperationContext } from "../contracts/operations.js";
5
- import { type JsonValue } from "../contracts/schema.js";
6
- import { type Operation } from "./operations.js";
7
- type Operations = {
8
- readonly queries?: Readonly<Record<string, Operation<JsonValue, unknown, "query", OperationContext>>>;
9
- readonly dynamicTools?: DynamicTools;
10
- readonly mutations?: Readonly<Record<string, Operation<JsonValue, unknown, "mutation", OperationContext>>>;
11
- };
12
- /**
13
- * Discover each selected account's protocol operations and combine matching names.
14
- * Calls take { accountId, input }; each branch retains its account's input schema,
15
- * credentials, approval and output validation. Empty selections expose no operations.
16
- * Discovery is sequential and cancellation follows the caller's signal.
17
- */
18
- export declare const accountOperations: <Account extends {
19
- readonly id: string;
20
- }>(accounts: readonly Account[], discover: (account: Account) => Promise<Operations>, options: {
21
- readonly signal: AbortSignal;
22
- }) => Promise<{
23
- queries: {
24
- [k: string]: Operation<{
25
- readonly accountId: string;
26
- readonly input: unknown;
27
- }, unknown, "query", import("../index.js").AppContext>;
28
- };
29
- mutations: {
30
- [k: string]: Operation<{
31
- readonly accountId: string;
32
- readonly input: unknown;
33
- }, unknown, "mutation", import("../index.js").AppContext>;
34
- };
35
- } | {
36
- dynamicTools: {
37
- list: () => Effect.Effect<{
38
- readonly name: string;
39
- readonly description: string;
40
- readonly inputSchema: {
41
- readonly [x: string]: Schema.Json;
42
- };
43
- readonly _meta?: {
44
- readonly [x: string]: Schema.Json;
45
- };
46
- readonly title?: string;
47
- readonly outputSchema?: {
48
- readonly [x: string]: Schema.Json;
49
- };
50
- readonly annotations?: {
51
- readonly title?: string;
52
- readonly readOnlyHint?: boolean;
53
- readonly destructiveHint?: boolean;
54
- readonly idempotentHint?: boolean;
55
- readonly openWorldHint?: boolean;
56
- };
57
- readonly schedules?: readonly {
58
- readonly name: string;
59
- readonly timing: {
60
- readonly kind: "interval";
61
- readonly milliseconds: number;
62
- } | {
63
- readonly kind: "cron";
64
- readonly calendar: {
65
- readonly expression: string;
66
- readonly timezone: string;
67
- };
68
- };
69
- readonly input: Schema.Json;
70
- }[];
71
- readonly readOnly?: boolean;
72
- }[], unknown, never>;
73
- summaries: () => Effect.Effect<{
74
- readonly name: string;
75
- readonly description: string;
76
- readonly title?: string;
77
- readonly annotations?: {
78
- readonly title?: string;
79
- readonly readOnlyHint?: boolean;
80
- readonly destructiveHint?: boolean;
81
- readonly idempotentHint?: boolean;
82
- readonly openWorldHint?: boolean;
83
- };
84
- readonly schedules?: readonly {
85
- readonly name: string;
86
- readonly timing: {
87
- readonly kind: "interval";
88
- readonly milliseconds: number;
89
- } | {
90
- readonly kind: "cron";
91
- readonly calendar: {
92
- readonly expression: string;
93
- readonly timezone: string;
94
- };
95
- };
96
- readonly input: Schema.Json;
97
- }[];
98
- readonly readOnly?: boolean;
99
- }[], unknown, never>;
100
- describe: (name: string) => Effect.Effect<{
101
- readonly name: string;
102
- readonly description: string;
103
- readonly inputSchema: {
104
- readonly [x: string]: Schema.Json;
105
- };
106
- readonly _meta?: {
107
- readonly [x: string]: Schema.Json;
108
- };
109
- readonly title?: string;
110
- readonly outputSchema?: {
111
- readonly [x: string]: Schema.Json;
112
- };
113
- readonly annotations?: {
114
- readonly title?: string;
115
- readonly readOnlyHint?: boolean;
116
- readonly destructiveHint?: boolean;
117
- readonly idempotentHint?: boolean;
118
- readonly openWorldHint?: boolean;
119
- };
120
- readonly schedules?: readonly {
121
- readonly name: string;
122
- readonly timing: {
123
- readonly kind: "interval";
124
- readonly milliseconds: number;
125
- } | {
126
- readonly kind: "cron";
127
- readonly calendar: {
128
- readonly expression: string;
129
- readonly timezone: string;
130
- };
131
- };
132
- readonly input: Schema.Json;
133
- }[];
134
- readonly readOnly?: boolean;
135
- } | undefined, unknown, never>;
136
- resolve: (name: string) => Effect.Effect<AppOperation<unknown, unknown> | undefined, unknown, never>;
137
- };
138
- queries: {
139
- [k: string]: Operation<{
140
- readonly accountId: string;
141
- readonly input: unknown;
142
- }, unknown, "query", import("../index.js").AppContext>;
143
- };
144
- mutations: {
145
- [k: string]: Operation<{
146
- readonly accountId: string;
147
- readonly input: unknown;
148
- }, unknown, "mutation", import("../index.js").AppContext>;
149
- };
150
- }>;
151
- export {};
@@ -1,8 +0,0 @@
1
- import { HostedTool } from "../contracts/host.js";
2
- import type { DynamicTools } from "../contracts/dynamic-tools.js";
3
- import { type OperationDeclaration } from "./operations.js";
4
- /** Declare metadata discovery separately from executable resolution. Names are fully qualified. */
5
- export declare const dynamicTools: (source: {
6
- readonly list: () => Promise<readonly HostedTool[]>;
7
- readonly resolve: (name: string) => Promise<OperationDeclaration<"query" | "mutation"> | undefined>;
8
- }) => DynamicTools;