apps 0.0.1-beta.0 → 0.0.1-beta.1
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 +97 -4
- package/framework-reference.json +1 -1
- package/js/{chunk-BPEFS4YF.js → chunk-2HHMABB6.js} +70 -14
- package/js/{chunk-SBKHUC5L.js → chunk-4LPG6RCH.js} +2 -2
- package/js/{chunk-LOKGDT6B.js → chunk-6IIO4NPI.js} +5 -4
- package/js/chunk-6YBRWRK3.js +160 -0
- package/js/{chunk-7JXHF5IF.js → chunk-BMOIAIVR.js} +1 -1
- package/js/chunk-CZ7CSFO4.js +39 -0
- package/js/{chunk-YDR4CPJA.js → chunk-EVJUVWN2.js} +8 -8
- package/js/{chunk-2OTCEKL2.js → chunk-FW5HBOIK.js} +2352 -1493
- package/js/{chunk-EP6AEUZO.js → chunk-FZJOYIZO.js} +1 -1
- package/js/{chunk-WIDTG42X.js → chunk-G7IE6BKC.js} +79 -26
- package/js/{chunk-VFUZI3NY.js → chunk-HDJH3RPR.js} +4 -4
- package/js/{chunk-HP7E42X6.js → chunk-IHQ4ML7K.js} +693 -219
- package/js/{chunk-Q2FD5IBM.js → chunk-KOXMLKTM.js} +430 -41
- package/js/{chunk-D6BKYP2L.js → chunk-M6ZRRIBI.js} +4 -4
- package/js/chunk-NCYXZN2G.js +6274 -0
- package/js/{chunk-3ANFZFCV.js → chunk-OHRT55C4.js} +15 -15
- package/js/{chunk-R6JMJSVT.js → chunk-PLCMJREA.js} +2 -2
- package/js/{chunk-C24KEZXR.js → chunk-PZ36XMXW.js} +36 -2
- package/js/{chunk-W7Q5EOTS.js → chunk-QKHR7BMF.js} +32 -32
- package/js/{chunk-X3YBZCJW.js → chunk-RBAC33PQ.js} +59 -38
- package/js/{chunk-36DNRFZQ.js → chunk-SATWJKN6.js} +1 -1
- package/js/chunk-SWPD52J7.js +35 -0
- package/js/{chunk-BKVL7XAJ.js → chunk-TE4KO4HI.js} +1 -1
- package/js/chunk-W7D7WVSY.js +18 -0
- package/js/{chunk-KWTCHVLT.js → chunk-X7SFGU4Q.js} +47 -51
- package/js/chunk-YEJOQEII.js +104 -0
- package/js/{chunk-OWD2YICM.js → chunk-ZCAMUXSG.js} +116 -87
- package/js/chunk-ZJWDMTE3.js +63 -0
- package/js/chunk-ZTFQHGEB.js +80 -0
- package/js/client.js +11 -11
- package/js/contracts.js +81 -25
- package/js/effect.js +20 -15
- package/js/graphql.js +223 -121
- package/js/host.js +75 -19
- package/js/index.js +191 -51
- package/js/mcp/effect.js +24 -17
- package/js/mcp/stdio.js +22 -17
- package/js/mcp.js +109 -24
- package/js/openapi.js +43897 -143
- package/js/operations/approval.js +1 -1
- package/js/react.js +4 -4
- package/js/skills/effect.js +12 -0
- package/js/skills.js +857 -0
- package/js/storage/facet.js +7 -7
- package/js/ui/auth/contracts.js +6 -6
- package/js/ui/auth.js +8 -8
- package/js/ui/contracts.js +5 -5
- package/js/ui/serving.js +12 -12
- package/package.json +9 -1
- package/runtime.json +1 -1
- package/types/app-cache/src/contracts/cache.d.ts +79 -0
- package/types/app-cache/src/index.d.ts +35 -0
- package/types/apps/src/contracts/api-response-error.d.ts +43 -0
- package/types/apps/src/contracts/app.d.ts +11 -0
- package/types/apps/src/contracts/cache.d.ts +41 -0
- package/types/apps/src/contracts/dynamic-skills.d.ts +10 -0
- package/types/apps/src/contracts/dynamic-tools.d.ts +13 -0
- package/types/apps/src/contracts/graphql.d.ts +18 -1
- package/types/apps/src/contracts/host.d.ts +200 -7
- package/types/apps/src/contracts/mcp.d.ts +3 -1
- package/types/apps/src/contracts/openapi-compile.d.ts +11 -0
- package/types/apps/src/contracts/openapi-document.d.ts +53 -0
- package/types/apps/src/contracts/openapi.d.ts +150 -30
- package/types/apps/src/contracts/provider-error.d.ts +15 -0
- package/types/apps/src/contracts/provider.d.ts +18 -1
- package/types/apps/src/contracts/skills.d.ts +113 -0
- package/types/apps/src/contracts/swagger-client.d.ts +29 -0
- package/types/apps/src/graphql.d.ts +6 -6
- package/types/apps/src/host.d.ts +1 -0
- package/types/apps/src/implementation/account-operations.d.ts +122 -3
- package/types/apps/src/implementation/app.d.ts +1 -1
- package/types/apps/src/implementation/cache-session.d.ts +7 -0
- package/types/apps/src/implementation/cache.d.ts +6 -0
- package/types/apps/src/implementation/catalog-cache.d.ts +29 -0
- package/types/apps/src/implementation/dynamic-skills.d.ts +7 -0
- package/types/apps/src/implementation/dynamic-tools.d.ts +8 -0
- package/types/apps/src/implementation/elicitation.d.ts +12 -12
- package/types/apps/src/implementation/git.d.ts +25 -0
- package/types/apps/src/implementation/graphql-catalog.d.ts +10 -0
- package/types/apps/src/implementation/graphql.d.ts +81 -3
- package/types/apps/src/implementation/inflate.d.ts +16 -0
- package/types/apps/src/implementation/input-problems.d.ts +3 -0
- package/types/apps/src/implementation/mcp-call.d.ts +3 -2
- package/types/apps/src/implementation/mcp-catalog.d.ts +12 -0
- package/types/apps/src/implementation/mcp-client.d.ts +9 -8
- package/types/apps/src/implementation/mcp-stdio.d.ts +1 -1
- package/types/apps/src/implementation/mcp-tools.d.ts +6 -3
- package/types/apps/src/implementation/mcp.d.ts +39 -2
- package/types/apps/src/implementation/openapi-compile.d.ts +119 -0
- package/types/apps/src/implementation/openapi-document.d.ts +53 -0
- package/types/apps/src/implementation/openapi-request.d.ts +11 -4
- package/types/apps/src/implementation/openapi-source.d.ts +36 -0
- package/types/apps/src/implementation/openapi.d.ts +39 -3
- package/types/apps/src/implementation/provider-error.d.ts +10 -0
- package/types/apps/src/implementation/schema.d.ts +11 -5
- package/types/apps/src/implementation/skill-files.d.ts +10 -0
- package/types/apps/src/implementation/skills.d.ts +43 -0
- package/types/apps/src/index.d.ts +7 -0
- package/types/apps/src/mcp.d.ts +5 -5
- package/types/apps/src/openapi.d.ts +3 -1
- package/types/apps/src/skills.d.ts +72 -0
- package/types/telemetry/src/config.d.ts +2 -0
- package/js/chunk-22WRQZT7.js +0 -389
- package/js/chunk-MLKGABMK.js +0 -9
package/js/index.js
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CacheError,
|
|
2
3
|
defineApp,
|
|
3
4
|
defineDatabase,
|
|
4
5
|
table,
|
|
5
6
|
workflow
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-RBAC33PQ.js";
|
|
8
|
+
import "./chunk-PLCMJREA.js";
|
|
8
9
|
import {
|
|
10
|
+
fromPromise,
|
|
9
11
|
mutation,
|
|
10
12
|
nativeOperation,
|
|
11
13
|
operationDeclaration,
|
|
12
14
|
query,
|
|
13
15
|
withApproval
|
|
14
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-PZ36XMXW.js";
|
|
17
|
+
import {
|
|
18
|
+
accountProviderError
|
|
19
|
+
} from "./chunk-ZJWDMTE3.js";
|
|
15
20
|
import {
|
|
16
21
|
CalendarSchedule,
|
|
17
22
|
ElicitationFailed,
|
|
23
|
+
HostedTool,
|
|
24
|
+
HostedToolSummary,
|
|
18
25
|
Interval,
|
|
19
26
|
NonRetryableError,
|
|
20
27
|
OAuth2AccessToken,
|
|
@@ -24,8 +31,13 @@ import {
|
|
|
24
31
|
ScheduleTiming,
|
|
25
32
|
SecretsMethod,
|
|
26
33
|
WorkflowFailure
|
|
27
|
-
} from "./chunk-
|
|
28
|
-
import "./chunk-
|
|
34
|
+
} from "./chunk-IHQ4ML7K.js";
|
|
35
|
+
import "./chunk-BMOIAIVR.js";
|
|
36
|
+
import "./chunk-YEJOQEII.js";
|
|
37
|
+
import "./chunk-SWPD52J7.js";
|
|
38
|
+
import {
|
|
39
|
+
ProviderError
|
|
40
|
+
} from "./chunk-W7D7WVSY.js";
|
|
29
41
|
import {
|
|
30
42
|
array,
|
|
31
43
|
boolean,
|
|
@@ -38,24 +50,25 @@ import {
|
|
|
38
50
|
nestJsonSchema,
|
|
39
51
|
number,
|
|
40
52
|
object,
|
|
53
|
+
once,
|
|
41
54
|
parse,
|
|
42
55
|
record,
|
|
43
56
|
string,
|
|
44
57
|
userId,
|
|
45
|
-
|
|
58
|
+
withLazyJsonSchemaDocument,
|
|
46
59
|
wrap
|
|
47
|
-
} from "./chunk-
|
|
48
|
-
import "./chunk-
|
|
60
|
+
} from "./chunk-2HHMABB6.js";
|
|
61
|
+
import "./chunk-FZJOYIZO.js";
|
|
49
62
|
import {
|
|
50
63
|
JsonObject,
|
|
51
64
|
JsonValue,
|
|
52
65
|
ValidationError
|
|
53
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-SATWJKN6.js";
|
|
54
67
|
import {
|
|
55
68
|
Effect_exports,
|
|
56
69
|
Schema_exports
|
|
57
|
-
} from "./chunk-
|
|
58
|
-
import "./chunk-
|
|
70
|
+
} from "./chunk-FW5HBOIK.js";
|
|
71
|
+
import "./chunk-CZ7CSFO4.js";
|
|
59
72
|
|
|
60
73
|
// src/contracts/http.ts
|
|
61
74
|
var ResponseStatusError = class extends Schema_exports.TaggedError()(
|
|
@@ -96,6 +109,10 @@ var inputDocument = (operation) => {
|
|
|
96
109
|
const document = Schema_exports.toJsonSchemaDocument(operation.input);
|
|
97
110
|
return Schema_exports.decodeUnknownSync(JsonObject)({ ...document.schema, $defs: document.definitions });
|
|
98
111
|
};
|
|
112
|
+
var declaresOutput = (operation) => {
|
|
113
|
+
const property = Object.getOwnPropertyDescriptor(operation, "outputSchema");
|
|
114
|
+
return property !== void 0 && (property.get !== void 0 || property.value !== void 0);
|
|
115
|
+
};
|
|
99
116
|
var combine = (kind, groups) => Object.fromEntries(
|
|
100
117
|
[...groups].map(([name, accounts]) => {
|
|
101
118
|
const variants = [...accounts.values()];
|
|
@@ -108,15 +125,12 @@ var combine = (kind, groups) => Object.fromEntries(
|
|
|
108
125
|
throw new Error("Account selection must be decoded before execution");
|
|
109
126
|
return operation;
|
|
110
127
|
};
|
|
111
|
-
const outputs = variants.flatMap(
|
|
112
|
-
(operation) => operation.outputSchema === void 0 ? [] : [operation.outputSchema]
|
|
113
|
-
);
|
|
114
128
|
const input = Schema_exports.Union(
|
|
115
129
|
[...accounts].map(
|
|
116
130
|
([accountId, operation]) => Schema_exports.Struct({ accountId: Schema_exports.Literal(accountId), input: operation.input })
|
|
117
131
|
)
|
|
118
132
|
);
|
|
119
|
-
const inputSchema = {
|
|
133
|
+
const inputSchema = () => ({
|
|
120
134
|
type: "object",
|
|
121
135
|
anyOf: [...accounts].map(([accountId, operation], index) => ({
|
|
122
136
|
type: "object",
|
|
@@ -126,55 +140,100 @@ var combine = (kind, groups) => Object.fromEntries(
|
|
|
126
140
|
},
|
|
127
141
|
required: ["accountId", "input"]
|
|
128
142
|
}))
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
)
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
)
|
|
159
|
-
}
|
|
160
|
-
})
|
|
161
|
-
|
|
143
|
+
});
|
|
144
|
+
const declaration2 = operationDeclaration({
|
|
145
|
+
kind,
|
|
146
|
+
...first.description === void 0 ? {} : { description: first.description },
|
|
147
|
+
...first.title === void 0 ? {} : { title: first.title },
|
|
148
|
+
...first.annotations === void 0 || !variants.every(
|
|
149
|
+
(operation) => JSON.stringify(operation.annotations) === JSON.stringify(first.annotations)
|
|
150
|
+
) ? {} : { annotations: first.annotations },
|
|
151
|
+
...first._meta === void 0 || !variants.every(
|
|
152
|
+
(operation) => JSON.stringify(operation._meta) === JSON.stringify(first._meta)
|
|
153
|
+
) ? {} : { _meta: first._meta },
|
|
154
|
+
input: withLazyJsonSchemaDocument(input, inputSchema),
|
|
155
|
+
approval: (context) => {
|
|
156
|
+
const operation = select(context.toolInput);
|
|
157
|
+
return operation.approval === void 0 ? Effect_exports.succeed("approved") : operation.approval({ ...context, toolInput: context.toolInput.input });
|
|
158
|
+
},
|
|
159
|
+
run: (context, input2) => {
|
|
160
|
+
const operation = select(input2);
|
|
161
|
+
return operation.run(context, input2.input).pipe(
|
|
162
|
+
Effect_exports.mapError((error) => accountProviderError(error, input2.accountId)),
|
|
163
|
+
Effect_exports.flatMap(
|
|
164
|
+
(output) => operation.output === void 0 ? Effect_exports.succeed(output) : Schema_exports.decodeUnknownEffect(operation.output)(output)
|
|
165
|
+
)
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
if (variants.every(declaresOutput)) {
|
|
170
|
+
const outputSchema = once(() => ({
|
|
171
|
+
anyOf: variants.flatMap(
|
|
172
|
+
(operation) => operation.outputSchema === void 0 ? [] : [operation.outputSchema]
|
|
173
|
+
).map((output, index) => nestJsonSchema(output, `#/anyOf/${index}`))
|
|
174
|
+
}));
|
|
175
|
+
const native = nativeOperation(declaration2);
|
|
176
|
+
if (native !== void 0)
|
|
177
|
+
Object.defineProperty(native, "outputSchema", { enumerable: true, get: outputSchema });
|
|
178
|
+
}
|
|
179
|
+
return [name, declaration2];
|
|
162
180
|
})
|
|
163
181
|
);
|
|
182
|
+
var sameAcross = (key, variants) => {
|
|
183
|
+
const first = variants[0]?.[1][key];
|
|
184
|
+
return first !== void 0 && variants.every(([, tool]) => JSON.stringify(tool[key]) === JSON.stringify(first)) ? { [key]: first } : {};
|
|
185
|
+
};
|
|
186
|
+
var mergeSummary = (name, variants) => {
|
|
187
|
+
const first = variants[0]?.[1];
|
|
188
|
+
if (first === void 0) throw new Error("Expected a source operation");
|
|
189
|
+
return Schema_exports.decodeUnknownSync(HostedToolSummary)({
|
|
190
|
+
name,
|
|
191
|
+
description: first.description,
|
|
192
|
+
...first.title === void 0 ? {} : { title: first.title },
|
|
193
|
+
readOnly: name.startsWith("queries."),
|
|
194
|
+
...sameAcross("annotations", variants)
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
var merge = (name, variants) => Schema_exports.decodeUnknownSync(HostedTool)({
|
|
198
|
+
...mergeSummary(name, variants),
|
|
199
|
+
inputSchema: {
|
|
200
|
+
type: "object",
|
|
201
|
+
anyOf: variants.map(([accountId, tool], index) => ({
|
|
202
|
+
type: "object",
|
|
203
|
+
properties: {
|
|
204
|
+
accountId: { type: "string", const: accountId },
|
|
205
|
+
input: nestJsonSchema(tool.inputSchema, `#/anyOf/${index}/properties/input`)
|
|
206
|
+
},
|
|
207
|
+
required: ["accountId", "input"]
|
|
208
|
+
}))
|
|
209
|
+
},
|
|
210
|
+
...variants.every(([, tool]) => tool.outputSchema !== void 0) ? {
|
|
211
|
+
outputSchema: {
|
|
212
|
+
anyOf: variants.flatMap(
|
|
213
|
+
([, tool], index) => tool.outputSchema === void 0 ? [] : [nestJsonSchema(tool.outputSchema, `#/anyOf/${index}`)]
|
|
214
|
+
)
|
|
215
|
+
}
|
|
216
|
+
} : {},
|
|
217
|
+
...sameAcross("_meta", variants)
|
|
218
|
+
});
|
|
164
219
|
var accountOperations = (accounts, discover, options) => Effect_exports.runPromise(
|
|
165
220
|
Effect_exports.gen(function* () {
|
|
166
221
|
const queries = /* @__PURE__ */ new Map();
|
|
167
222
|
const mutations = /* @__PURE__ */ new Map();
|
|
223
|
+
const sources = /* @__PURE__ */ new Map();
|
|
168
224
|
for (const account of accounts) {
|
|
169
225
|
const operations = yield* Effect_exports.tryPromise({
|
|
170
226
|
try: () => discover(account),
|
|
171
|
-
catch: (error) => error
|
|
227
|
+
catch: (error) => accountProviderError(error, account.id)
|
|
172
228
|
});
|
|
229
|
+
if (sources.has(account.id))
|
|
230
|
+
return yield* Effect_exports.die(new Error("Account selections must be unique"));
|
|
231
|
+
if (operations.dynamicTools !== void 0) sources.set(account.id, operations.dynamicTools);
|
|
173
232
|
for (const [source, target] of [
|
|
174
233
|
[operations.queries, queries],
|
|
175
234
|
[operations.mutations, mutations]
|
|
176
235
|
]) {
|
|
177
|
-
for (const [name, declaration2] of Object.entries(source)) {
|
|
236
|
+
for (const [name, declaration2] of Object.entries(source ?? {})) {
|
|
178
237
|
const operation = nativeOperation(declaration2);
|
|
179
238
|
if (operation === void 0)
|
|
180
239
|
return yield* Effect_exports.die(new Error("Expected a protocol operation"));
|
|
@@ -186,11 +245,88 @@ var accountOperations = (accounts, discover, options) => Effect_exports.runPromi
|
|
|
186
245
|
}
|
|
187
246
|
}
|
|
188
247
|
}
|
|
189
|
-
|
|
248
|
+
const declared = {
|
|
249
|
+
queries: combine("query", queries),
|
|
250
|
+
mutations: combine("mutation", mutations)
|
|
251
|
+
};
|
|
252
|
+
if (sources.size === 0) return declared;
|
|
253
|
+
const grouped = (read) => Effect_exports.gen(function* () {
|
|
254
|
+
const groups = /* @__PURE__ */ new Map();
|
|
255
|
+
for (const [accountId, source] of sources) {
|
|
256
|
+
const tools = yield* read(source).pipe(
|
|
257
|
+
Effect_exports.mapError((error) => accountProviderError(error, accountId))
|
|
258
|
+
);
|
|
259
|
+
for (const tool of tools) {
|
|
260
|
+
const variants = groups.get(tool.name) ?? [];
|
|
261
|
+
if (variants.some(([id2]) => id2 === accountId))
|
|
262
|
+
return yield* Effect_exports.die(new Error("Duplicate source operation"));
|
|
263
|
+
variants.push([accountId, tool]);
|
|
264
|
+
groups.set(tool.name, variants);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return groups;
|
|
268
|
+
});
|
|
269
|
+
return {
|
|
270
|
+
...declared,
|
|
271
|
+
dynamicTools: {
|
|
272
|
+
list: () => grouped((source) => source.list()).pipe(
|
|
273
|
+
Effect_exports.map((groups) => [...groups].map(([name, variants]) => merge(name, variants)))
|
|
274
|
+
),
|
|
275
|
+
summaries: () => grouped(
|
|
276
|
+
(source) => source.summaries === void 0 ? source.list() : source.summaries()
|
|
277
|
+
).pipe(
|
|
278
|
+
Effect_exports.map(
|
|
279
|
+
(groups) => [...groups].map(([name, variants]) => mergeSummary(name, variants))
|
|
280
|
+
)
|
|
281
|
+
),
|
|
282
|
+
describe: (name) => Effect_exports.gen(function* () {
|
|
283
|
+
const variants = [];
|
|
284
|
+
for (const [accountId, source] of sources) {
|
|
285
|
+
const tool = yield* (source.describe === void 0 ? source.list().pipe(Effect_exports.map((tools) => tools.find((tool2) => tool2.name === name))) : source.describe(name)).pipe(Effect_exports.mapError((error) => accountProviderError(error, accountId)));
|
|
286
|
+
if (tool !== void 0) variants.push([accountId, tool]);
|
|
287
|
+
}
|
|
288
|
+
return variants.length === 0 ? void 0 : merge(name, variants);
|
|
289
|
+
}),
|
|
290
|
+
resolve: (name) => Effect_exports.gen(function* () {
|
|
291
|
+
const kind = name.startsWith("queries.") ? "query" : "mutation";
|
|
292
|
+
const operations = /* @__PURE__ */ new Map();
|
|
293
|
+
for (const [accountId, source] of sources) {
|
|
294
|
+
const operation = yield* source.resolve(name).pipe(Effect_exports.mapError((error) => accountProviderError(error, accountId)));
|
|
295
|
+
if (operation !== void 0) {
|
|
296
|
+
if (operation.kind !== kind)
|
|
297
|
+
return yield* Effect_exports.die(new Error("Operation kind changed"));
|
|
298
|
+
operations.set(accountId, operation);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
if (operations.size === 0) return void 0;
|
|
302
|
+
return nativeOperation(combine(kind, /* @__PURE__ */ new Map([[name, operations]]))[name]);
|
|
303
|
+
})
|
|
304
|
+
}
|
|
305
|
+
};
|
|
190
306
|
}),
|
|
191
307
|
options
|
|
192
308
|
);
|
|
193
309
|
|
|
310
|
+
// src/implementation/dynamic-tools.ts
|
|
311
|
+
var dynamicTools = (source) => ({
|
|
312
|
+
list: () => fromPromise(source.list)().pipe(
|
|
313
|
+
Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(Schema_exports.Array(HostedTool)))
|
|
314
|
+
),
|
|
315
|
+
resolve: (name) => fromPromise(source.resolve)(name).pipe(
|
|
316
|
+
Effect_exports.map((value) => {
|
|
317
|
+
if (value === void 0) return void 0;
|
|
318
|
+
const operation = nativeOperation(value);
|
|
319
|
+
if (operation === void 0) throw new Error("Expected an operation declaration");
|
|
320
|
+
return operation;
|
|
321
|
+
})
|
|
322
|
+
)
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
// src/implementation/dynamic-skills.ts
|
|
326
|
+
var dynamicSkills = (source) => ({
|
|
327
|
+
list: fromPromise(async () => source.list())
|
|
328
|
+
});
|
|
329
|
+
|
|
194
330
|
// src/contracts/app.ts
|
|
195
331
|
var NotImplemented = class extends Schema_exports.TaggedError()("NotImplemented", {
|
|
196
332
|
operation: Schema_exports.String
|
|
@@ -248,10 +384,12 @@ var decodeJson2 = (response, schema) => {
|
|
|
248
384
|
return Effect_exports.runPromise(decodeJson(native, decoderOf(schema)));
|
|
249
385
|
};
|
|
250
386
|
export {
|
|
387
|
+
CacheError,
|
|
251
388
|
ElicitationFailed,
|
|
252
389
|
NonRetryableError,
|
|
253
390
|
NotImplemented,
|
|
254
391
|
OAuth2AccessToken2 as OAuth2AccessToken,
|
|
392
|
+
ProviderError,
|
|
255
393
|
ResponseDecodeError,
|
|
256
394
|
ResponseStatusError,
|
|
257
395
|
ValidationError,
|
|
@@ -264,6 +402,8 @@ export {
|
|
|
264
402
|
defineApp,
|
|
265
403
|
defineDatabase,
|
|
266
404
|
defineProvider,
|
|
405
|
+
dynamicSkills,
|
|
406
|
+
dynamicTools,
|
|
267
407
|
id,
|
|
268
408
|
interval,
|
|
269
409
|
json,
|
package/js/mcp/effect.js
CHANGED
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
import {
|
|
2
|
+
mcpClientEffect,
|
|
2
3
|
mcpToolsEffect
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-G7IE6BKC.js";
|
|
5
|
+
import "../chunk-X7SFGU4Q.js";
|
|
5
6
|
import "../chunk-BCSNKUAC.js";
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
13
|
-
import "../chunk-
|
|
14
|
-
import "../chunk-
|
|
15
|
-
import "../chunk-
|
|
16
|
-
import "../chunk-
|
|
17
|
-
import "../chunk-
|
|
18
|
-
import "../chunk-
|
|
19
|
-
import "../chunk-
|
|
20
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-KOXMLKTM.js";
|
|
8
|
+
import "../chunk-ZTFQHGEB.js";
|
|
9
|
+
import "../chunk-NCYXZN2G.js";
|
|
10
|
+
import "../chunk-RBAC33PQ.js";
|
|
11
|
+
import "../chunk-PLCMJREA.js";
|
|
12
|
+
import "../chunk-PZ36XMXW.js";
|
|
13
|
+
import "../chunk-ZJWDMTE3.js";
|
|
14
|
+
import "../chunk-IHQ4ML7K.js";
|
|
15
|
+
import "../chunk-BMOIAIVR.js";
|
|
16
|
+
import "../chunk-YEJOQEII.js";
|
|
17
|
+
import "../chunk-SWPD52J7.js";
|
|
18
|
+
import "../chunk-W7D7WVSY.js";
|
|
19
|
+
import "../chunk-ZCAMUXSG.js";
|
|
20
|
+
import "../chunk-HDJH3RPR.js";
|
|
21
|
+
import "../chunk-QKHR7BMF.js";
|
|
22
|
+
import "../chunk-2HHMABB6.js";
|
|
23
|
+
import "../chunk-FZJOYIZO.js";
|
|
24
|
+
import "../chunk-SATWJKN6.js";
|
|
25
|
+
import "../chunk-FW5HBOIK.js";
|
|
26
|
+
import "../chunk-CZ7CSFO4.js";
|
|
21
27
|
export {
|
|
28
|
+
mcpClientEffect,
|
|
22
29
|
mcpToolsEffect
|
|
23
30
|
};
|
package/js/mcp/stdio.js
CHANGED
|
@@ -2,32 +2,37 @@ import {
|
|
|
2
2
|
adaptMcpTools,
|
|
3
3
|
mcpClient,
|
|
4
4
|
mcpJsonSchemaValidator
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-X7SFGU4Q.js";
|
|
6
6
|
import {
|
|
7
7
|
protocolOperations
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-6IIO4NPI.js";
|
|
9
9
|
import "../chunk-BCSNKUAC.js";
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
13
|
-
import "../chunk-
|
|
10
|
+
import "../chunk-KOXMLKTM.js";
|
|
11
|
+
import "../chunk-ZTFQHGEB.js";
|
|
12
|
+
import "../chunk-NCYXZN2G.js";
|
|
13
|
+
import "../chunk-RBAC33PQ.js";
|
|
14
|
+
import "../chunk-PLCMJREA.js";
|
|
15
|
+
import "../chunk-PZ36XMXW.js";
|
|
16
|
+
import "../chunk-ZJWDMTE3.js";
|
|
14
17
|
import {
|
|
15
18
|
McpError,
|
|
16
19
|
ProcessConfig
|
|
17
|
-
} from "../chunk-
|
|
18
|
-
import "../chunk-
|
|
19
|
-
import "../chunk-
|
|
20
|
-
import "../chunk-
|
|
21
|
-
import "../chunk-
|
|
22
|
-
import "../chunk-
|
|
23
|
-
import "../chunk-
|
|
24
|
-
import "../chunk-
|
|
25
|
-
import "../chunk-
|
|
20
|
+
} from "../chunk-IHQ4ML7K.js";
|
|
21
|
+
import "../chunk-BMOIAIVR.js";
|
|
22
|
+
import "../chunk-YEJOQEII.js";
|
|
23
|
+
import "../chunk-SWPD52J7.js";
|
|
24
|
+
import "../chunk-W7D7WVSY.js";
|
|
25
|
+
import "../chunk-ZCAMUXSG.js";
|
|
26
|
+
import "../chunk-HDJH3RPR.js";
|
|
27
|
+
import "../chunk-QKHR7BMF.js";
|
|
28
|
+
import "../chunk-2HHMABB6.js";
|
|
29
|
+
import "../chunk-FZJOYIZO.js";
|
|
30
|
+
import "../chunk-SATWJKN6.js";
|
|
26
31
|
import {
|
|
27
32
|
Effect_exports,
|
|
28
33
|
Schema_exports
|
|
29
|
-
} from "../chunk-
|
|
30
|
-
import "../chunk-
|
|
34
|
+
} from "../chunk-FW5HBOIK.js";
|
|
35
|
+
import "../chunk-CZ7CSFO4.js";
|
|
31
36
|
|
|
32
37
|
// src/implementation/mcp-stdio.ts
|
|
33
38
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
package/js/mcp.js
CHANGED
|
@@ -1,34 +1,119 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import
|
|
2
|
+
mcpClientEffect
|
|
3
|
+
} from "./chunk-G7IE6BKC.js";
|
|
4
|
+
import {
|
|
5
|
+
catalogCache
|
|
6
|
+
} from "./chunk-6YBRWRK3.js";
|
|
7
|
+
import {
|
|
8
|
+
adaptMcpTool
|
|
9
|
+
} from "./chunk-X7SFGU4Q.js";
|
|
5
10
|
import {
|
|
6
11
|
protocolOperations
|
|
7
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-6IIO4NPI.js";
|
|
8
13
|
import "./chunk-BCSNKUAC.js";
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
import "./chunk-
|
|
14
|
+
import {
|
|
15
|
+
cacheKey
|
|
16
|
+
} from "./chunk-KOXMLKTM.js";
|
|
17
|
+
import "./chunk-ZTFQHGEB.js";
|
|
18
|
+
import "./chunk-NCYXZN2G.js";
|
|
19
|
+
import "./chunk-RBAC33PQ.js";
|
|
20
|
+
import "./chunk-PLCMJREA.js";
|
|
21
|
+
import {
|
|
22
|
+
nativeOperation
|
|
23
|
+
} from "./chunk-PZ36XMXW.js";
|
|
24
|
+
import "./chunk-ZJWDMTE3.js";
|
|
25
|
+
import {
|
|
26
|
+
McpError,
|
|
27
|
+
McpToolMetadata,
|
|
28
|
+
McpToolsOptions
|
|
29
|
+
} from "./chunk-IHQ4ML7K.js";
|
|
30
|
+
import "./chunk-BMOIAIVR.js";
|
|
31
|
+
import "./chunk-YEJOQEII.js";
|
|
32
|
+
import "./chunk-SWPD52J7.js";
|
|
33
|
+
import "./chunk-W7D7WVSY.js";
|
|
34
|
+
import "./chunk-ZCAMUXSG.js";
|
|
35
|
+
import "./chunk-HDJH3RPR.js";
|
|
36
|
+
import "./chunk-QKHR7BMF.js";
|
|
37
|
+
import "./chunk-2HHMABB6.js";
|
|
38
|
+
import "./chunk-FZJOYIZO.js";
|
|
39
|
+
import "./chunk-SATWJKN6.js";
|
|
40
|
+
import {
|
|
41
|
+
Effect_exports,
|
|
42
|
+
Schema_exports
|
|
43
|
+
} from "./chunk-FW5HBOIK.js";
|
|
44
|
+
import "./chunk-CZ7CSFO4.js";
|
|
45
|
+
|
|
46
|
+
// src/implementation/mcp-catalog.ts
|
|
47
|
+
var McpToolSummary = McpToolMetadata.mapFields(
|
|
48
|
+
({ inputSchema: _input, outputSchema: _output, _meta, ...fields }) => fields
|
|
49
|
+
);
|
|
50
|
+
var invoke = (work) => Effect_exports.tryPromise({ try: work, catch: (error) => error });
|
|
51
|
+
var mcpCatalog = (options, kinds) => Effect_exports.gen(function* () {
|
|
52
|
+
const parsed = yield* Schema_exports.decodeUnknownEffect(McpToolsOptions)(options).pipe(
|
|
53
|
+
Effect_exports.mapError(() => new McpError({ phase: "connect", reason: "invalid_input" }))
|
|
54
|
+
);
|
|
55
|
+
const headers = {};
|
|
56
|
+
new Headers(parsed.headers).forEach((value, name) => {
|
|
57
|
+
headers[name] = value;
|
|
58
|
+
});
|
|
59
|
+
const id = yield* cacheKey({ url: parsed.url, headers, accountId: parsed.accountId ?? null });
|
|
60
|
+
const key = ["mcp-catalog-v2", id, "current"];
|
|
61
|
+
const cache = options.cache;
|
|
62
|
+
const changed = cache === void 0 ? void 0 : invoke(() => cache.invalidate(key));
|
|
63
|
+
const client = yield* mcpClientEffect(options, changed);
|
|
64
|
+
const catalog = yield* catalogCache({
|
|
65
|
+
...options,
|
|
66
|
+
prefix: ["mcp-catalog-v2", id],
|
|
67
|
+
schema: McpToolMetadata,
|
|
68
|
+
summary: {
|
|
69
|
+
schema: McpToolSummary,
|
|
70
|
+
of: ({ inputSchema: _input, outputSchema: _output, _meta, ...summary }) => summary
|
|
71
|
+
},
|
|
72
|
+
load: (context) => context === void 0 ? client.list : mcpClientEffect(
|
|
73
|
+
{ ...parsed, signal: context.signal },
|
|
74
|
+
invoke(() => context.cache.invalidate(key))
|
|
75
|
+
).pipe(Effect_exports.flatMap((source) => source.list))
|
|
76
|
+
});
|
|
77
|
+
const kindOf = (tool) => Object.hasOwn(kinds, tool.name) ? kinds[tool.name] ?? "mutation" : tool.annotations?.readOnlyHint === true ? "query" : "mutation";
|
|
78
|
+
const qualified = (tool) => `${kindOf(tool) === "query" ? "queries" : "mutations"}.${tool.name}`;
|
|
79
|
+
const summarize = (tool) => ({
|
|
80
|
+
name: qualified(tool),
|
|
81
|
+
description: tool.description ?? tool.title ?? tool.name,
|
|
82
|
+
readOnly: kindOf(tool) === "query",
|
|
83
|
+
...tool.title === void 0 ? {} : { title: tool.title },
|
|
84
|
+
annotations: { ...tool.annotations, readOnlyHint: kindOf(tool) === "query" }
|
|
85
|
+
});
|
|
86
|
+
const describe = (tool) => ({
|
|
87
|
+
...summarize(tool),
|
|
88
|
+
inputSchema: tool.inputSchema,
|
|
89
|
+
...tool.outputSchema === void 0 ? {} : { outputSchema: tool.outputSchema },
|
|
90
|
+
...tool._meta === void 0 ? {} : { _meta: tool._meta }
|
|
91
|
+
});
|
|
92
|
+
const selected = (name) => Effect_exports.gen(function* () {
|
|
93
|
+
if (!name.startsWith("queries.") && !name.startsWith("mutations.")) return void 0;
|
|
94
|
+
const tool = yield* catalog.resolve(name.slice(name.indexOf(".") + 1));
|
|
95
|
+
return tool === void 0 || qualified(tool) !== name ? void 0 : tool;
|
|
96
|
+
});
|
|
97
|
+
const dynamicTools = {
|
|
98
|
+
list: () => catalog.list().pipe(Effect_exports.map((tools) => tools.map(describe))),
|
|
99
|
+
summaries: () => catalog.summaries().pipe(Effect_exports.map((tools) => tools.map(summarize))),
|
|
100
|
+
describe: (name) => selected(name).pipe(
|
|
101
|
+
Effect_exports.map((tool) => tool === void 0 ? void 0 : describe(tool))
|
|
102
|
+
),
|
|
103
|
+
resolve: (name) => Effect_exports.gen(function* () {
|
|
104
|
+
const tool = yield* selected(name);
|
|
105
|
+
if (tool === void 0) return void 0;
|
|
106
|
+
const adapted = yield* adaptMcpTool(client, tool);
|
|
107
|
+
const operations = protocolOperations({ selected: adapted }, { selected: kindOf(tool) });
|
|
108
|
+
return nativeOperation(operations.queries.selected ?? operations.mutations.selected);
|
|
109
|
+
})
|
|
110
|
+
};
|
|
111
|
+
return { dynamicTools };
|
|
112
|
+
});
|
|
28
113
|
|
|
29
114
|
// src/mcp.ts
|
|
30
115
|
var mcpOperations = (options, kinds = {}) => Effect_exports.runPromise(
|
|
31
|
-
|
|
116
|
+
mcpCatalog(options, kinds),
|
|
32
117
|
options.signal === void 0 ? {} : { signal: options.signal }
|
|
33
118
|
);
|
|
34
119
|
export {
|