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/graphql.js
CHANGED
|
@@ -1,46 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
catalogCache
|
|
3
|
+
} from "./chunk-6YBRWRK3.js";
|
|
1
4
|
import {
|
|
2
5
|
protocolOperations
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-6IIO4NPI.js";
|
|
4
7
|
import "./chunk-BCSNKUAC.js";
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import
|
|
8
|
+
import {
|
|
9
|
+
cacheKey
|
|
10
|
+
} from "./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 {
|
|
16
|
+
nativeOperation
|
|
17
|
+
} from "./chunk-PZ36XMXW.js";
|
|
18
|
+
import {
|
|
19
|
+
accountProviderError,
|
|
20
|
+
graphqlProviderError,
|
|
21
|
+
httpProviderError
|
|
22
|
+
} from "./chunk-ZJWDMTE3.js";
|
|
23
|
+
import "./chunk-IHQ4ML7K.js";
|
|
24
|
+
import "./chunk-BMOIAIVR.js";
|
|
25
|
+
import "./chunk-YEJOQEII.js";
|
|
26
|
+
import "./chunk-SWPD52J7.js";
|
|
27
|
+
import {
|
|
28
|
+
ProviderError
|
|
29
|
+
} from "./chunk-W7D7WVSY.js";
|
|
30
|
+
import "./chunk-ZCAMUXSG.js";
|
|
13
31
|
import {
|
|
14
32
|
FetchHttpClient_exports
|
|
15
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-HDJH3RPR.js";
|
|
16
34
|
import {
|
|
17
35
|
HttpClientRequest_exports,
|
|
18
36
|
HttpClient_exports
|
|
19
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-QKHR7BMF.js";
|
|
20
38
|
import {
|
|
21
39
|
jsonSchemaDecoder
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
40
|
+
} from "./chunk-2HHMABB6.js";
|
|
41
|
+
import "./chunk-FZJOYIZO.js";
|
|
24
42
|
import {
|
|
43
|
+
AccountId,
|
|
25
44
|
HttpUrl,
|
|
26
45
|
JsonObject
|
|
27
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-SATWJKN6.js";
|
|
28
47
|
import {
|
|
29
48
|
Effect_exports,
|
|
30
49
|
Redacted_exports,
|
|
31
50
|
Schema_exports
|
|
32
|
-
} from "./chunk-
|
|
33
|
-
import "./chunk-
|
|
34
|
-
|
|
35
|
-
// src/implementation/graphql.ts
|
|
36
|
-
import {
|
|
37
|
-
getIntrospectionQuery,
|
|
38
|
-
Kind as Kind2,
|
|
39
|
-
OperationTypeNode,
|
|
40
|
-
parse,
|
|
41
|
-
parseType,
|
|
42
|
-
print
|
|
43
|
-
} from "graphql";
|
|
51
|
+
} from "./chunk-FW5HBOIK.js";
|
|
52
|
+
import "./chunk-CZ7CSFO4.js";
|
|
44
53
|
|
|
45
54
|
// src/contracts/graphql.ts
|
|
46
55
|
var GraphqlClientLimits = Schema_exports.Struct({
|
|
@@ -53,6 +62,7 @@ var defaultGraphqlClientLimits = GraphqlClientLimits.make({
|
|
|
53
62
|
});
|
|
54
63
|
var GraphqlToolsOptions = Schema_exports.Struct({
|
|
55
64
|
url: HttpUrl,
|
|
65
|
+
accountId: Schema_exports.optional(AccountId),
|
|
56
66
|
headers: Schema_exports.optional(Schema_exports.Record(Schema_exports.String, Schema_exports.String)),
|
|
57
67
|
signal: Schema_exports.optional(Schema_exports.instanceOf(AbortSignal)),
|
|
58
68
|
timeoutMs: Schema_exports.optional(
|
|
@@ -121,8 +131,26 @@ var GraphqlResponse = Schema_exports.Struct({
|
|
|
121
131
|
data: Schema_exports.optional(Schema_exports.NullOr(JsonObject)),
|
|
122
132
|
errors: Schema_exports.optional(Schema_exports.Array(JsonObject))
|
|
123
133
|
});
|
|
134
|
+
var GraphqlToolDefinition = Schema_exports.Struct({
|
|
135
|
+
name: Name,
|
|
136
|
+
kind: Schema_exports.Literals(["query", "mutation"]),
|
|
137
|
+
field: Name,
|
|
138
|
+
description: Schema_exports.String,
|
|
139
|
+
arguments: Schema_exports.Array(Schema_exports.Struct({ name: Name, type: Schema_exports.String })),
|
|
140
|
+
inputSchema: JsonObject,
|
|
141
|
+
composite: Schema_exports.Boolean,
|
|
142
|
+
selection: Schema_exports.String
|
|
143
|
+
});
|
|
124
144
|
|
|
125
145
|
// src/implementation/graphql.ts
|
|
146
|
+
import {
|
|
147
|
+
getIntrospectionQuery,
|
|
148
|
+
Kind as Kind2,
|
|
149
|
+
OperationTypeNode,
|
|
150
|
+
parse,
|
|
151
|
+
parseType,
|
|
152
|
+
print
|
|
153
|
+
} from "graphql";
|
|
126
154
|
function wrapped(type) {
|
|
127
155
|
if (!type.ofType) throw new GraphqlError({ phase: "discover", reason: "invalid_response" });
|
|
128
156
|
return type.ofType;
|
|
@@ -136,8 +164,7 @@ function typeName(type) {
|
|
|
136
164
|
if (!type.name) throw new GraphqlError({ phase: "discover", reason: "invalid_response" });
|
|
137
165
|
return type.name;
|
|
138
166
|
}
|
|
139
|
-
function fieldInput(field,
|
|
140
|
-
const types = new Map(catalog.__schema.types.map((type) => [type.name, type]));
|
|
167
|
+
function fieldInput(field, types) {
|
|
141
168
|
const definitions = /* @__PURE__ */ new Map();
|
|
142
169
|
const convert = (ref) => ref.kind === "NON_NULL" ? nonNull(wrapped(ref)) : { anyOf: [nonNull(ref), { type: "null" }] };
|
|
143
170
|
const nonNull = (ref) => {
|
|
@@ -221,7 +248,7 @@ function selection(text) {
|
|
|
221
248
|
throw new GraphqlError({ phase: "call", reason: "invalid_input" });
|
|
222
249
|
return field.selectionSet;
|
|
223
250
|
}
|
|
224
|
-
var
|
|
251
|
+
var graphqlClientEffect = (input) => Effect_exports.gen(function* () {
|
|
225
252
|
const options = yield* Schema_exports.decodeUnknownEffect(GraphqlToolsOptions)(input).pipe(
|
|
226
253
|
Effect_exports.mapError(() => new GraphqlError({ phase: "discover", reason: "invalid_input" }))
|
|
227
254
|
);
|
|
@@ -234,23 +261,21 @@ var graphqlToolsEffect = (input) => Effect_exports.gen(function* () {
|
|
|
234
261
|
const client = yield* HttpClient_exports.HttpClient;
|
|
235
262
|
const response = yield* HttpClient_exports.withScope(client).execute(
|
|
236
263
|
HttpClientRequest_exports.post(url.href).pipe(
|
|
264
|
+
// GitHub requires this header; Workers do not supply one by default.
|
|
265
|
+
HttpClientRequest_exports.setHeader("user-agent", "Executor"),
|
|
237
266
|
HttpClientRequest_exports.setHeaders(Redacted_exports.value(headers)),
|
|
238
267
|
HttpClientRequest_exports.bodyJsonUnsafe({ query, variables })
|
|
239
268
|
)
|
|
240
269
|
);
|
|
241
270
|
if (response.status < 200 || response.status >= 300)
|
|
242
|
-
return yield* new GraphqlError({
|
|
243
|
-
phase,
|
|
244
|
-
reason: [401, 403].includes(response.status) ? "unauthorized" : "request",
|
|
245
|
-
status: response.status
|
|
246
|
-
});
|
|
271
|
+
return yield* httpProviderError(response.status, response.headers) ?? new GraphqlError({ phase, reason: "request", status: response.status });
|
|
247
272
|
const result = yield* response.json.pipe(
|
|
248
273
|
Effect_exports.withSpan("provider.http.response.read"),
|
|
249
274
|
Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(GraphqlResponse)),
|
|
250
275
|
Effect_exports.mapError(() => new GraphqlError({ phase, reason: "invalid_response" }))
|
|
251
276
|
);
|
|
252
277
|
if (result.errors?.length)
|
|
253
|
-
return yield* new GraphqlError({ phase, reason: "execution", status: response.status });
|
|
278
|
+
return yield* graphqlProviderError(result.errors, response.status) ?? new GraphqlError({ phase, reason: "execution", status: response.status });
|
|
254
279
|
if (result.data == null)
|
|
255
280
|
return yield* new GraphqlError({ phase, reason: "invalid_response" });
|
|
256
281
|
return result.data;
|
|
@@ -270,15 +295,19 @@ var graphqlToolsEffect = (input) => Effect_exports.gen(function* () {
|
|
|
270
295
|
orElse: () => Effect_exports.fail(new GraphqlError({ phase, reason: "timeout" }))
|
|
271
296
|
}),
|
|
272
297
|
Effect_exports.mapError(
|
|
273
|
-
(error) => error instanceof GraphqlError ? error : new GraphqlError({ phase, reason: "request" })
|
|
298
|
+
(error) => error instanceof ProviderError && options.accountId !== void 0 ? accountProviderError(error, options.accountId) : error instanceof GraphqlError || error instanceof ProviderError ? error : new GraphqlError({ phase, reason: "request" })
|
|
274
299
|
)
|
|
275
300
|
);
|
|
276
|
-
const
|
|
301
|
+
const discover = request("discover", getIntrospectionQuery()).pipe(
|
|
277
302
|
Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(GraphqlIntrospection)),
|
|
278
303
|
Effect_exports.mapError(
|
|
279
|
-
(error) => error instanceof GraphqlError ? error : new GraphqlError({ phase: "discover", reason: "invalid_response" })
|
|
304
|
+
(error) => error instanceof GraphqlError || error instanceof ProviderError ? error : new GraphqlError({ phase: "discover", reason: "invalid_response" })
|
|
280
305
|
)
|
|
281
306
|
);
|
|
307
|
+
return { request, discover };
|
|
308
|
+
});
|
|
309
|
+
var graphqlDefinitions = (catalog) => Effect_exports.gen(function* () {
|
|
310
|
+
const types = new Map(catalog.__schema.types.map((type) => [type.name, type]));
|
|
282
311
|
const roots = [
|
|
283
312
|
{ kind: OperationTypeNode.QUERY, type: catalog.__schema.queryType },
|
|
284
313
|
{ kind: OperationTypeNode.MUTATION, type: catalog.__schema.mutationType }
|
|
@@ -287,103 +316,176 @@ var graphqlToolsEffect = (input) => Effect_exports.gen(function* () {
|
|
|
287
316
|
(field) => ({ kind, field })
|
|
288
317
|
)
|
|
289
318
|
);
|
|
290
|
-
|
|
319
|
+
return yield* Effect_exports.forEach(
|
|
291
320
|
roots,
|
|
292
321
|
({ kind, field }) => Effect_exports.gen(function* () {
|
|
293
322
|
const definition = yield* Effect_exports.try({
|
|
294
|
-
try: () => fieldInput(field,
|
|
323
|
+
try: () => fieldInput(field, types),
|
|
295
324
|
catch: () => new GraphqlError({ phase: "discover", reason: "invalid_response" })
|
|
296
325
|
});
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
326
|
+
return yield* Effect_exports.try({
|
|
327
|
+
try: () => ({
|
|
328
|
+
name: kind + "_" + field.name,
|
|
329
|
+
kind,
|
|
330
|
+
field: field.name,
|
|
331
|
+
description: field.description ?? field.name,
|
|
332
|
+
arguments: field.args.map((arg) => ({ name: arg.name, type: typeName(arg.type) })),
|
|
333
|
+
inputSchema: definition.schema,
|
|
334
|
+
composite: definition.composite,
|
|
335
|
+
selection: definition.selection
|
|
336
|
+
}),
|
|
337
|
+
catch: () => new GraphqlError({ phase: "discover", reason: "invalid_response" })
|
|
338
|
+
});
|
|
339
|
+
})
|
|
340
|
+
);
|
|
341
|
+
});
|
|
342
|
+
var adaptGraphqlTool = (client, definition) => Effect_exports.gen(function* () {
|
|
343
|
+
const decoder = yield* jsonSchemaDecoder(definition.inputSchema).pipe(
|
|
344
|
+
Effect_exports.mapError(() => new GraphqlError({ phase: "discover", reason: "invalid_response" }))
|
|
345
|
+
);
|
|
346
|
+
const kind = definition.kind === "query" ? OperationTypeNode.QUERY : OperationTypeNode.MUTATION;
|
|
347
|
+
const name = definition.name;
|
|
348
|
+
const tool = {
|
|
349
|
+
description: definition.description,
|
|
350
|
+
readOnly: kind === OperationTypeNode.QUERY,
|
|
351
|
+
input: decoder,
|
|
352
|
+
run: (_context, input) => Effect_exports.gen(function* () {
|
|
353
|
+
const args = yield* Schema_exports.decodeUnknownEffect(decoder)(input).pipe(
|
|
354
|
+
Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(JsonObject)),
|
|
355
|
+
Effect_exports.mapError(() => new GraphqlError({ phase: "call", reason: "invalid_input" }))
|
|
356
|
+
);
|
|
357
|
+
const variables = yield* Schema_exports.decodeUnknownEffect(JsonObject)(
|
|
358
|
+
args.arguments ?? {}
|
|
359
|
+
).pipe(
|
|
360
|
+
Effect_exports.mapError(() => new GraphqlError({ phase: "call", reason: "invalid_input" }))
|
|
301
361
|
);
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
},
|
|
332
|
-
type: parseType(typeName(arg.type))
|
|
333
|
-
})),
|
|
334
|
-
selectionSet: {
|
|
335
|
-
kind: Kind2.SELECTION_SET,
|
|
336
|
-
selections: [
|
|
337
|
-
{
|
|
338
|
-
kind: Kind2.FIELD,
|
|
339
|
-
name: { kind: Kind2.NAME, value: field.name },
|
|
340
|
-
arguments: used.map((arg) => ({
|
|
341
|
-
kind: Kind2.ARGUMENT,
|
|
342
|
-
name: { kind: Kind2.NAME, value: arg.name },
|
|
343
|
-
value: {
|
|
344
|
-
kind: Kind2.VARIABLE,
|
|
345
|
-
name: { kind: Kind2.NAME, value: arg.name }
|
|
346
|
-
}
|
|
347
|
-
})),
|
|
348
|
-
...definition.composite ? {
|
|
349
|
-
selectionSet: selection(
|
|
350
|
-
typeof args.select === "string" ? args.select : definition.selection
|
|
351
|
-
)
|
|
352
|
-
} : {}
|
|
362
|
+
const query = yield* Effect_exports.try({
|
|
363
|
+
try: () => {
|
|
364
|
+
const used = definition.arguments.filter((arg) => Object.hasOwn(variables, arg.name));
|
|
365
|
+
return print({
|
|
366
|
+
kind: Kind2.DOCUMENT,
|
|
367
|
+
definitions: [
|
|
368
|
+
{
|
|
369
|
+
kind: Kind2.OPERATION_DEFINITION,
|
|
370
|
+
operation: kind,
|
|
371
|
+
variableDefinitions: used.map((arg) => ({
|
|
372
|
+
kind: Kind2.VARIABLE_DEFINITION,
|
|
373
|
+
variable: {
|
|
374
|
+
kind: Kind2.VARIABLE,
|
|
375
|
+
name: { kind: Kind2.NAME, value: arg.name }
|
|
376
|
+
},
|
|
377
|
+
type: parseType(arg.type)
|
|
378
|
+
})),
|
|
379
|
+
selectionSet: {
|
|
380
|
+
kind: Kind2.SELECTION_SET,
|
|
381
|
+
selections: [
|
|
382
|
+
{
|
|
383
|
+
kind: Kind2.FIELD,
|
|
384
|
+
name: { kind: Kind2.NAME, value: definition.field },
|
|
385
|
+
arguments: used.map((arg) => ({
|
|
386
|
+
kind: Kind2.ARGUMENT,
|
|
387
|
+
name: { kind: Kind2.NAME, value: arg.name },
|
|
388
|
+
value: {
|
|
389
|
+
kind: Kind2.VARIABLE,
|
|
390
|
+
name: { kind: Kind2.NAME, value: arg.name }
|
|
353
391
|
}
|
|
354
|
-
|
|
392
|
+
})),
|
|
393
|
+
...definition.composite ? {
|
|
394
|
+
selectionSet: selection(
|
|
395
|
+
typeof args.select === "string" ? args.select : definition.selection
|
|
396
|
+
)
|
|
397
|
+
} : {}
|
|
355
398
|
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
catch: () => new GraphqlError({ phase: "call", reason: "invalid_input" })
|
|
399
|
+
]
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
]
|
|
361
403
|
});
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
404
|
+
},
|
|
405
|
+
catch: () => new GraphqlError({ phase: "call", reason: "invalid_input" })
|
|
406
|
+
});
|
|
407
|
+
const data = yield* client.request("call", query, variables);
|
|
408
|
+
const value = Object.hasOwn(data, definition.field) ? data[definition.field] : void 0;
|
|
409
|
+
if (value === void 0)
|
|
410
|
+
return yield* new GraphqlError({ phase: "call", reason: "invalid_response" });
|
|
411
|
+
return value;
|
|
412
|
+
}).pipe(
|
|
413
|
+
Effect_exports.withSpan("provider.graphql.call", {
|
|
414
|
+
attributes: {
|
|
415
|
+
"graphql.operation.type": kind,
|
|
416
|
+
"executor.tool.name": name
|
|
417
|
+
}
|
|
418
|
+
})
|
|
419
|
+
)
|
|
420
|
+
};
|
|
421
|
+
return tool;
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
// src/implementation/graphql-catalog.ts
|
|
425
|
+
var GraphqlToolSummary = GraphqlToolDefinition.mapFields(({ name, kind, description }) => ({
|
|
426
|
+
name,
|
|
427
|
+
kind,
|
|
428
|
+
description
|
|
429
|
+
}));
|
|
430
|
+
var graphqlCatalog = (options, kinds) => Effect_exports.gen(function* () {
|
|
431
|
+
const parsed = yield* Schema_exports.decodeUnknownEffect(GraphqlToolsOptions)(options).pipe(
|
|
432
|
+
Effect_exports.mapError(() => new GraphqlError({ phase: "discover", reason: "invalid_input" }))
|
|
378
433
|
);
|
|
379
|
-
|
|
434
|
+
const headers = {};
|
|
435
|
+
new Headers(parsed.headers).forEach((value, name) => {
|
|
436
|
+
headers[name] = value;
|
|
437
|
+
});
|
|
438
|
+
const id = yield* cacheKey({ url: parsed.url, headers, accountId: parsed.accountId ?? null });
|
|
439
|
+
const client = yield* graphqlClientEffect(parsed);
|
|
440
|
+
const catalog = yield* catalogCache({
|
|
441
|
+
...options,
|
|
442
|
+
prefix: ["graphql-catalog-v2", id],
|
|
443
|
+
schema: GraphqlToolDefinition,
|
|
444
|
+
summary: {
|
|
445
|
+
schema: GraphqlToolSummary,
|
|
446
|
+
of: ({ name, kind, description }) => ({ name, kind, description })
|
|
447
|
+
},
|
|
448
|
+
load: (context) => (context === void 0 ? Effect_exports.succeed(client) : graphqlClientEffect({ ...parsed, signal: context.signal })).pipe(
|
|
449
|
+
Effect_exports.flatMap((source) => source.discover),
|
|
450
|
+
Effect_exports.flatMap(graphqlDefinitions)
|
|
451
|
+
)
|
|
452
|
+
});
|
|
453
|
+
const kindOf = (tool) => Object.hasOwn(kinds, tool.name) ? kinds[tool.name] ?? "mutation" : tool.kind;
|
|
454
|
+
const qualified = (tool) => `${kindOf(tool) === "query" ? "queries" : "mutations"}.${tool.name}`;
|
|
455
|
+
const summarize = (tool) => ({
|
|
456
|
+
name: qualified(tool),
|
|
457
|
+
description: tool.description,
|
|
458
|
+
readOnly: kindOf(tool) === "query"
|
|
459
|
+
});
|
|
460
|
+
const describe = (tool) => ({
|
|
461
|
+
...summarize(tool),
|
|
462
|
+
inputSchema: tool.inputSchema
|
|
463
|
+
});
|
|
464
|
+
const selected = (name) => Effect_exports.gen(function* () {
|
|
465
|
+
if (!name.startsWith("queries.") && !name.startsWith("mutations.")) return void 0;
|
|
466
|
+
const tool = yield* catalog.resolve(name.slice(name.indexOf(".") + 1));
|
|
467
|
+
return tool === void 0 || qualified(tool) !== name ? void 0 : tool;
|
|
468
|
+
});
|
|
469
|
+
const dynamicTools = {
|
|
470
|
+
list: () => catalog.list().pipe(Effect_exports.map((tools) => tools.map(describe))),
|
|
471
|
+
summaries: () => catalog.summaries().pipe(Effect_exports.map((tools) => tools.map(summarize))),
|
|
472
|
+
describe: (name) => selected(name).pipe(
|
|
473
|
+
Effect_exports.map((tool) => tool === void 0 ? void 0 : describe(tool))
|
|
474
|
+
),
|
|
475
|
+
resolve: (name) => Effect_exports.gen(function* () {
|
|
476
|
+
const tool = yield* selected(name);
|
|
477
|
+
if (tool === void 0) return void 0;
|
|
478
|
+
const adapted = yield* adaptGraphqlTool(client, tool);
|
|
479
|
+
const operations = protocolOperations({ selected: adapted }, { selected: kindOf(tool) });
|
|
480
|
+
return nativeOperation(operations.queries.selected ?? operations.mutations.selected);
|
|
481
|
+
})
|
|
482
|
+
};
|
|
483
|
+
return { dynamicTools };
|
|
380
484
|
});
|
|
381
485
|
|
|
382
486
|
// src/graphql.ts
|
|
383
487
|
var graphqlOperations = (options, kinds = {}) => Effect_exports.runPromise(
|
|
384
|
-
|
|
385
|
-
Effect_exports.map((operations) => protocolOperations(operations, kinds))
|
|
386
|
-
),
|
|
488
|
+
graphqlCatalog(options, kinds),
|
|
387
489
|
options.signal === void 0 ? {} : { signal: options.signal }
|
|
388
490
|
);
|
|
389
491
|
export {
|
package/js/host.js
CHANGED
|
@@ -1,43 +1,98 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAppHandler
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-C24KEZXR.js";
|
|
3
|
+
} from "./chunk-KOXMLKTM.js";
|
|
4
|
+
import "./chunk-ZTFQHGEB.js";
|
|
5
|
+
import "./chunk-NCYXZN2G.js";
|
|
7
6
|
import {
|
|
7
|
+
CacheCommand,
|
|
8
|
+
CacheError,
|
|
9
|
+
CacheReply
|
|
10
|
+
} from "./chunk-RBAC33PQ.js";
|
|
11
|
+
import "./chunk-PLCMJREA.js";
|
|
12
|
+
import "./chunk-PZ36XMXW.js";
|
|
13
|
+
import "./chunk-ZJWDMTE3.js";
|
|
14
|
+
import {
|
|
15
|
+
ElicitationFailed,
|
|
16
|
+
ElicitationReply,
|
|
8
17
|
HostAccountsInvalid,
|
|
9
18
|
HostInputInvalid,
|
|
10
19
|
HostResponse,
|
|
11
20
|
ResolvedAccounts,
|
|
12
|
-
TrustedToolApproval
|
|
13
|
-
} from "./chunk-22WRQZT7.js";
|
|
14
|
-
import {
|
|
15
|
-
ElicitationFailed,
|
|
16
|
-
ElicitationReply,
|
|
21
|
+
TrustedToolApproval,
|
|
17
22
|
WorkflowFailure,
|
|
18
23
|
WorkflowRpcResult,
|
|
19
24
|
WorkflowRun,
|
|
20
25
|
WorkflowRunId,
|
|
21
26
|
WorkflowRunPage
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
27
|
+
} from "./chunk-IHQ4ML7K.js";
|
|
28
|
+
import "./chunk-BMOIAIVR.js";
|
|
29
|
+
import "./chunk-YEJOQEII.js";
|
|
30
|
+
import "./chunk-SWPD52J7.js";
|
|
31
|
+
import "./chunk-W7D7WVSY.js";
|
|
24
32
|
import {
|
|
25
33
|
collectTelemetry,
|
|
26
34
|
withRemoteSpan
|
|
27
|
-
} from "./chunk-
|
|
28
|
-
import "./chunk-
|
|
29
|
-
import "./chunk-
|
|
30
|
-
import "./chunk-
|
|
31
|
-
import "./chunk-
|
|
32
|
-
import "./chunk-
|
|
35
|
+
} from "./chunk-ZCAMUXSG.js";
|
|
36
|
+
import "./chunk-HDJH3RPR.js";
|
|
37
|
+
import "./chunk-QKHR7BMF.js";
|
|
38
|
+
import "./chunk-2HHMABB6.js";
|
|
39
|
+
import "./chunk-FZJOYIZO.js";
|
|
40
|
+
import "./chunk-SATWJKN6.js";
|
|
33
41
|
import {
|
|
34
42
|
Cause_exports,
|
|
35
43
|
Effect_exports,
|
|
36
44
|
Redacted_exports,
|
|
37
45
|
Scheduler_exports,
|
|
38
46
|
Schema_exports
|
|
39
|
-
} from "./chunk-
|
|
40
|
-
import "./chunk-
|
|
47
|
+
} from "./chunk-FW5HBOIK.js";
|
|
48
|
+
import "./chunk-CZ7CSFO4.js";
|
|
49
|
+
|
|
50
|
+
// src/implementation/cache-session.ts
|
|
51
|
+
var isolatedCacheSession = (callback) => {
|
|
52
|
+
const controller = new AbortController();
|
|
53
|
+
const pending = /* @__PURE__ */ new Set();
|
|
54
|
+
const cache = {
|
|
55
|
+
transport: (command) => Effect_exports.tryPromise({
|
|
56
|
+
try: () => callback(Schema_exports.encodeSync(CacheCommand)(command)),
|
|
57
|
+
catch: () => new CacheError({ reason: "storage" })
|
|
58
|
+
}).pipe(
|
|
59
|
+
Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(CacheReply)),
|
|
60
|
+
Effect_exports.mapError(() => new CacheError({ reason: "storage" })),
|
|
61
|
+
Effect_exports.flatMap(
|
|
62
|
+
(reply) => reply.ok ? Effect_exports.succeed(reply.value) : Effect_exports.fail(reply.error)
|
|
63
|
+
)
|
|
64
|
+
),
|
|
65
|
+
background: (task) => Effect_exports.gen(function* () {
|
|
66
|
+
const services = yield* Effect_exports.context();
|
|
67
|
+
const promise = Effect_exports.runPromiseWith(services)(
|
|
68
|
+
task.pipe(
|
|
69
|
+
Effect_exports.timeout("30 seconds"),
|
|
70
|
+
Effect_exports.catchCause(() => Effect_exports.logWarning("App cache refresh failed"))
|
|
71
|
+
),
|
|
72
|
+
{ signal: controller.signal }
|
|
73
|
+
).then(
|
|
74
|
+
() => {
|
|
75
|
+
pending.delete(promise);
|
|
76
|
+
},
|
|
77
|
+
() => {
|
|
78
|
+
pending.delete(promise);
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
pending.add(promise);
|
|
82
|
+
})
|
|
83
|
+
};
|
|
84
|
+
const drain = async () => {
|
|
85
|
+
while (pending.size > 0) await Promise.all(pending);
|
|
86
|
+
};
|
|
87
|
+
return {
|
|
88
|
+
cache,
|
|
89
|
+
drain,
|
|
90
|
+
cancel: async () => {
|
|
91
|
+
controller.abort();
|
|
92
|
+
await drain();
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
};
|
|
41
96
|
|
|
42
97
|
// src/implementation/workflow-rpc.ts
|
|
43
98
|
var isolatedWorkflowExecution = (run, deliver, signal) => {
|
|
@@ -187,6 +242,7 @@ export {
|
|
|
187
242
|
createAppHandler2 as createAppHandler,
|
|
188
243
|
createIsolatedAppHandler,
|
|
189
244
|
hostContext,
|
|
245
|
+
isolatedCacheSession,
|
|
190
246
|
isolatedElicitation,
|
|
191
247
|
isolatedWorkflowControls,
|
|
192
248
|
isolatedWorkflowExecution
|