apps 0.0.1-beta.4 → 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.
- package/README.md +65 -43
- package/framework-reference.json +1 -1
- package/js/{chunk-SATWJKN6.js → chunk-27F7W2LG.js} +1 -1
- package/js/{chunk-HDJH3RPR.js → chunk-57RKNWL2.js} +2 -2
- package/js/{chunk-WFSQXYUT.js → chunk-5T57N25Q.js} +15 -3
- package/js/{chunk-EQB7JMAL.js → chunk-6BSSI67S.js} +8 -8
- package/js/{chunk-3M2MEDNL.js → chunk-B3EOZTK3.js} +351 -33
- package/js/{chunk-FW5HBOIK.js → chunk-CDL5PM2Q.js} +307 -169
- package/js/{chunk-Z5NMEGJN.js → chunk-ECQFRCH4.js} +21 -9
- package/js/{chunk-G7ZIRKMK.js → chunk-IJX4CYZO.js} +3 -3
- package/js/{chunk-FDNTX5QJ.js → chunk-IPI4MFSN.js} +2 -2
- package/js/{chunk-2VPJHFOU.js → chunk-ITM77QPO.js} +28 -9
- package/js/{chunk-YEJOQEII.js → chunk-JU7VHODU.js} +1 -1
- package/js/{chunk-NQ3OMCA5.js → chunk-KUMBKVJD.js} +2 -2
- package/js/{chunk-EVJUVWN2.js → chunk-M3B3DE4K.js} +2 -2
- package/js/{chunk-ZJWDMTE3.js → chunk-MKWZPDR6.js} +3 -3
- package/js/chunk-MNMNLXBL.js +507 -0
- package/js/{chunk-BMOIAIVR.js → chunk-N7YDVXYJ.js} +49 -1
- package/js/{chunk-D47C7KG5.js → chunk-NKLWZJLE.js} +2 -2
- package/js/{chunk-DHUDODG5.js → chunk-OE3QQTSB.js} +41 -32
- package/js/{chunk-M6ZRRIBI.js → chunk-PJJ24GU7.js} +1 -1
- package/js/{chunk-FZJOYIZO.js → chunk-PZB6T6KU.js} +1 -1
- package/js/{chunk-LGIYBDWA.js → chunk-R3EV5FTO.js} +13 -1
- package/js/{chunk-5MQZEB6Y.js → chunk-RFVIONFX.js} +29 -12
- package/js/{chunk-ZCAMUXSG.js → chunk-RJDDBDSN.js} +3 -3
- package/js/{chunk-6VRYO2BG.js → chunk-SB4HEPNJ.js} +191 -170
- package/js/chunk-T7GKZBLP.js +209 -0
- package/js/{chunk-QKHR7BMF.js → chunk-UK573G7W.js} +1 -1
- package/js/{chunk-T2LAZCAD.js → chunk-VFZKSM3T.js} +1 -1
- package/js/{chunk-PLCMJREA.js → chunk-ZQINWV4W.js} +60 -20
- package/js/client.js +10 -10
- package/js/contracts.js +52 -16
- package/js/effect.js +19 -20
- package/js/graphql.js +34 -40
- package/js/host.js +19 -20
- package/js/index.js +189 -178
- package/js/mcp/effect.js +21 -22
- package/js/mcp/stdio.js +25 -26
- package/js/mcp.js +60 -45
- package/js/openapi.js +182 -224
- package/js/react.js +3 -3
- package/js/skills/effect.js +3 -3
- package/js/skills.js +12 -13
- package/js/storage/facet.js +4 -4
- package/js/ui/auth/contracts.js +2 -2
- package/js/ui/auth.js +5 -5
- package/js/ui/contracts.js +4 -4
- package/js/ui/serving.js +8 -8
- package/package.json +1 -1
- package/runtime.json +1 -1
- package/types/app-data/src/contracts/database.d.ts +33 -6
- package/types/app-data/src/implementation/schema.d.ts +2 -17
- package/types/apps/src/contracts/app.d.ts +2 -5
- package/types/apps/src/contracts/failure.d.ts +25 -0
- package/types/apps/src/contracts/host.d.ts +18 -9
- package/types/apps/src/contracts/mcp.d.ts +16 -0
- package/types/apps/src/contracts/openapi.d.ts +5 -1
- package/types/apps/src/contracts/operations.d.ts +0 -5
- package/types/apps/src/contracts/protocol-version.d.ts +2 -2
- package/types/apps/src/contracts/protocols/1.d.ts +15 -1
- package/types/apps/src/contracts/protocols/2.d.ts +2 -2
- package/types/apps/src/contracts/protocols/3.d.ts +676 -0
- package/types/apps/src/contracts/protocols/4.d.ts +1229 -0
- package/types/apps/src/contracts/router.d.ts +59 -0
- package/types/apps/src/contracts/storage.d.ts +3 -3
- package/types/apps/src/contracts/workflows.d.ts +34 -3
- package/types/apps/src/graphql.d.ts +1 -3
- package/types/apps/src/implementation/account-router.d.ts +12 -0
- package/types/apps/src/implementation/app.d.ts +5 -4
- package/types/apps/src/implementation/catalog-cache.d.ts +9 -2
- package/types/apps/src/implementation/elicitation.d.ts +1 -1
- package/types/apps/src/implementation/failure-detail.d.ts +25 -0
- package/types/apps/src/implementation/graphql-catalog.d.ts +1 -4
- package/types/apps/src/implementation/mcp-catalog.d.ts +1 -4
- package/types/apps/src/implementation/mcp-client.d.ts +35 -19
- package/types/apps/src/implementation/mcp.d.ts +35 -19
- package/types/apps/src/implementation/openapi-compile.d.ts +2 -1
- package/types/apps/src/implementation/openapi-source.d.ts +2 -6
- package/types/apps/src/implementation/operations.d.ts +26 -3
- package/types/apps/src/implementation/protocol-operations.d.ts +3 -4
- package/types/apps/src/implementation/router-catalog.d.ts +225 -0
- package/types/apps/src/implementation/router.d.ts +59 -0
- package/types/apps/src/implementation/schema.d.ts +5 -1
- package/types/apps/src/implementation/storage.d.ts +5 -3
- package/types/apps/src/implementation/webhooks.d.ts +1 -1
- package/types/apps/src/implementation/workflow-context.d.ts +11 -3
- package/types/apps/src/index.d.ts +3 -2
- package/types/apps/src/mcp-stdio.d.ts +2 -5
- package/types/apps/src/mcp.d.ts +5 -4
- package/types/apps/src/openapi.d.ts +6 -6
- package/js/chunk-PYUYJRSK.js +0 -93
- package/js/chunk-SWPD52J7.js +0 -35
- package/js/chunk-W7D7WVSY.js +0 -18
- package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
- package/types/apps/src/implementation/account-operations.d.ts +0 -151
- package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
|
@@ -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 {
|
|
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 {};
|
|
@@ -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
|
-
|
|
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. */
|
|
@@ -26,4 +26,4 @@ export declare const dispatchWebhook: <Context extends {
|
|
|
26
26
|
readonly [x: string]: string;
|
|
27
27
|
};
|
|
28
28
|
readonly body: string;
|
|
29
|
-
},
|
|
29
|
+
}, HostOperationNotFound | HostInputInvalid | HostOutputInvalid | HostDeclarationInvalid | HostOperationFailed, never>;
|
|
@@ -2,7 +2,15 @@
|
|
|
2
2
|
import { Effect } from "effect";
|
|
3
3
|
import type { AppDefinition } from "../contracts/app.js";
|
|
4
4
|
import { WorkflowFailure, type WorkflowContext, type WorkflowExecution, type WorkflowStepContext } from "../contracts/workflows.js";
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Preserve typed failures and cancellation. Other errors keep their name and bounded message,
|
|
7
|
+
* with the given account secrets replaced.
|
|
8
|
+
*/
|
|
9
|
+
export declare const workflowSafe: <A>(work: Effect.Effect<A, unknown>, secrets: readonly string[]) => Effect.Effect<A, WorkflowFailure>;
|
|
7
10
|
/** Construct one replay's Promise context. Step callbacks acquire fresh capabilities per actual attempt. */
|
|
8
|
-
export declare const makeWorkflowContext: (execution: WorkflowExecution, definition: Pick<AppDefinition<never>, "
|
|
11
|
+
export declare const makeWorkflowContext: (execution: WorkflowExecution, definition: Pick<AppDefinition<never>, "tools">,
|
|
12
|
+
/** A step attempt's context, and the raw account secrets its failures must not reveal. */
|
|
13
|
+
fresh: (stepId: string, signal: AbortSignal) => Effect.Effect<{
|
|
14
|
+
readonly context: WorkflowStepContext;
|
|
15
|
+
readonly secrets: readonly string[];
|
|
16
|
+
}, WorkflowFailure>, signal: AbortSignal) => Effect.Effect<WorkflowContext>;
|
|
@@ -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 {
|
|
20
|
-
export {
|
|
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
|
|
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>>;
|
package/types/apps/src/mcp.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 {
|
|
12
|
+
export { liveOpenapiRouter, type OpenapiSourceOptions } from "./implementation/openapi-source.js";
|
package/js/chunk-PYUYJRSK.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
decoderOf
|
|
3
|
-
} from "./chunk-WFSQXYUT.js";
|
|
4
|
-
import {
|
|
5
|
-
Effect_exports
|
|
6
|
-
} from "./chunk-FW5HBOIK.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
|
-
};
|
package/js/chunk-SWPD52J7.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Schema_exports
|
|
3
|
-
} from "./chunk-FW5HBOIK.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
|
-
};
|
package/js/chunk-W7D7WVSY.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AccountId
|
|
3
|
-
} from "./chunk-SATWJKN6.js";
|
|
4
|
-
import {
|
|
5
|
-
Schema_exports
|
|
6
|
-
} from "./chunk-FW5HBOIK.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,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
|
-
}
|