apps 0.0.1-beta.1 → 0.0.1-beta.100
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 +112 -72
- package/framework-reference.json +1 -1
- package/js/browser-XIPJGLH2.js +65 -0
- package/js/chunk-2CURR5Y7.js +264 -0
- package/js/chunk-2LSGC7XY.js +42 -0
- package/js/{chunk-YEJOQEII.js → chunk-4PIQKACY.js} +65 -10
- package/js/chunk-4UPC36ZL.js +5185 -0
- package/js/{chunk-4LPG6RCH.js → chunk-4X2UI4R2.js} +7 -27
- package/js/chunk-5C6RAGAS.js +335 -0
- package/js/chunk-62NVUKED.js +39 -0
- package/js/chunk-74H25C4X.js +95 -0
- package/js/chunk-7HG422GB.js +90 -0
- package/js/chunk-7STIP5CS.js +171 -0
- package/js/{chunk-QKHR7BMF.js → chunk-ACQXVKVQ.js} +87 -51
- package/js/{chunk-OHRT55C4.js → chunk-DILSCQPJ.js} +226 -265
- package/js/chunk-ILYCJ3HV.js +449 -0
- package/js/chunk-K6TSCYAO.js +712 -0
- package/js/{chunk-EVJUVWN2.js → chunk-KLSEU35Y.js} +463 -218
- package/js/chunk-OD3KFKZD.js +1617 -0
- package/js/chunk-OWN3DP2W.js +88 -0
- package/js/{chunk-ZTFQHGEB.js → chunk-PBGPES67.js} +3 -5
- package/js/chunk-QI66R4FP.js +786 -0
- package/js/chunk-RN4YB4JT.js +1922 -0
- package/js/{chunk-ZCAMUXSG.js → chunk-URKOTNDA.js} +795 -177
- package/js/{chunk-NCYXZN2G.js → chunk-UVL56Z6E.js} +390 -23
- package/js/{chunk-2HHMABB6.js → chunk-VAI3EVCS.js} +700 -78
- package/js/chunk-VCYWAA4N.js +49 -0
- package/js/{chunk-HDJH3RPR.js → chunk-YDW7DX3A.js} +4 -4
- package/js/chunk-YWVISRZD.js +268 -0
- package/js/{chunk-FW5HBOIK.js → chunk-ZKDXML77.js} +19272 -18299
- package/js/client.js +148 -100
- package/js/contracts.js +208 -24
- package/js/effect.js +18 -19
- package/js/es-DIULA3ZF.js +39371 -0
- package/js/graphql.js +62 -58
- package/js/host.js +83 -60
- package/js/index.js +381 -263
- package/js/mcp/effect.js +21 -21
- package/js/mcp.js +117 -74
- package/js/openapi.js +4613 -42691
- package/js/react.js +2 -3
- package/js/skills/effect.js +6 -4
- package/js/skills.js +233 -70
- package/js/storage/facet.js +1 -540
- package/js/ui/auth/contracts.js +8 -9
- package/js/ui/auth.js +16 -14
- package/js/ui/contracts.js +9 -8
- package/js/ui/serving.js +8609 -227
- package/package.json +3 -8
- package/runtime.json +1 -1
- package/types/app-cache/src/contracts/cache.d.ts +60 -2
- package/types/app-cache/src/index.d.ts +92 -2
- package/types/app-data/src/contracts/database.d.ts +33 -6
- package/types/apps/src/contracts/api-response-error.d.ts +4 -0
- package/types/apps/src/contracts/app.d.ts +63 -17
- package/types/apps/src/contracts/cache.d.ts +24 -1
- package/types/apps/src/contracts/context.d.ts +60 -17
- package/types/apps/src/contracts/elicitation.d.ts +23 -7
- package/types/apps/src/contracts/events.d.ts +94 -0
- package/types/apps/src/contracts/failure.d.ts +54 -0
- package/types/apps/src/contracts/graphql.d.ts +2 -1
- package/types/apps/src/contracts/host.d.ts +1325 -534
- package/types/apps/src/contracts/icons.d.ts +28 -0
- package/types/apps/src/contracts/live.d.ts +2 -0
- package/types/apps/src/contracts/mcp.d.ts +97 -20
- package/types/apps/src/contracts/network.d.ts +120 -0
- package/types/apps/src/contracts/openapi-compile.d.ts +82 -3
- package/types/apps/src/contracts/openapi-document.d.ts +1 -1
- package/types/apps/src/contracts/openapi.d.ts +51 -9
- package/types/apps/src/contracts/operations.d.ts +14 -12
- package/types/apps/src/contracts/placement.d.ts +102 -0
- package/types/apps/src/contracts/protocol-version.d.ts +6 -0
- package/types/apps/src/contracts/protocols/1.d.ts +2241 -0
- package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
- package/types/apps/src/contracts/protocols/11.d.ts +1149 -0
- package/types/apps/src/contracts/protocols/12.d.ts +3310 -0
- package/types/apps/src/contracts/protocols/2.d.ts +711 -0
- package/types/apps/src/contracts/protocols/3.d.ts +776 -0
- package/types/apps/src/contracts/protocols/4.d.ts +1306 -0
- package/types/apps/src/contracts/protocols/5.d.ts +1200 -0
- package/types/apps/src/contracts/protocols/6.d.ts +1629 -0
- package/types/apps/src/contracts/protocols/7.d.ts +1785 -0
- package/types/apps/src/contracts/protocols/8.d.ts +1182 -0
- package/types/apps/src/contracts/protocols/9.d.ts +1104 -0
- package/types/apps/src/contracts/protocols/current.d.ts +6857 -0
- package/types/apps/src/contracts/protocols/oauth-6.d.ts +74 -0
- package/types/apps/src/contracts/protocols/oauth.d.ts +134 -0
- package/types/apps/src/contracts/provider-error.d.ts +9 -0
- package/types/apps/src/contracts/provider.d.ts +140 -10
- package/types/apps/src/contracts/router.d.ts +59 -0
- package/types/apps/src/contracts/schedules.d.ts +7 -1
- package/types/apps/src/contracts/schema.d.ts +21 -0
- package/types/apps/src/contracts/shared-catalog.d.ts +11 -0
- package/types/apps/src/contracts/skills.d.ts +60 -14
- package/types/apps/src/contracts/sql.d.ts +63 -0
- package/types/apps/src/contracts/ui-auth.d.ts +6 -14
- package/types/apps/src/contracts/ui.d.ts +70 -30
- package/types/apps/src/contracts/webhooks.d.ts +24 -7
- package/types/apps/src/contracts/workflows.d.ts +89 -36
- package/types/apps/src/facet.d.ts +4 -5
- package/types/apps/src/graphql.d.ts +1 -3
- package/types/apps/src/host.d.ts +5 -0
- package/types/apps/src/implementation/account-router.d.ts +13 -0
- package/types/apps/src/implementation/app.d.ts +44 -16
- package/types/apps/src/implementation/authoring.d.ts +25 -5
- package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
- package/types/apps/src/implementation/cache.d.ts +32 -3
- package/types/apps/src/implementation/catalog-cache.d.ts +43 -5
- package/types/apps/src/implementation/elicitation.d.ts +18 -15
- package/types/apps/src/implementation/events.d.ts +64 -0
- package/types/apps/src/implementation/failure-detail.d.ts +48 -0
- package/types/apps/src/implementation/graphql-catalog.d.ts +4 -7
- package/types/apps/src/implementation/graphql.d.ts +4 -3
- package/types/apps/src/implementation/input-problems.d.ts +6 -2
- package/types/apps/src/implementation/invocation-timing.d.ts +18 -0
- package/types/apps/src/implementation/live.d.ts +2 -2
- package/types/apps/src/implementation/mcp-call.d.ts +6 -5
- package/types/apps/src/implementation/mcp-catalog.d.ts +7 -8
- package/types/apps/src/implementation/mcp-client.d.ts +49 -25
- package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
- package/types/apps/src/implementation/mcp.d.ts +52 -25
- package/types/apps/src/implementation/network.d.ts +16 -0
- package/types/apps/src/implementation/openapi-compile.d.ts +30 -8
- package/types/apps/src/implementation/openapi-document.d.ts +46 -21
- package/types/apps/src/implementation/openapi-names.d.ts +23 -0
- package/types/apps/src/implementation/openapi-request.d.ts +10 -3
- package/types/apps/src/implementation/openapi-source.d.ts +30 -8
- package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
- package/types/apps/src/implementation/operations.d.ts +84 -10
- package/types/apps/src/implementation/optimistic.d.ts +1 -1
- package/types/apps/src/implementation/placement.d.ts +60 -0
- package/types/apps/src/implementation/protocol-operations.d.ts +6 -4
- package/types/apps/src/implementation/provider-error.d.ts +28 -1
- package/types/apps/src/implementation/provider.d.ts +26 -6
- package/types/apps/src/implementation/query-commit.d.ts +1 -1
- package/types/apps/src/implementation/router-catalog.d.ts +227 -0
- package/types/apps/src/implementation/router.d.ts +78 -0
- package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
- package/types/apps/src/implementation/schedules.d.ts +39 -8
- package/types/apps/src/implementation/schema.d.ts +111 -15
- package/types/apps/src/implementation/skills.d.ts +18 -24
- package/types/apps/src/implementation/sql.d.ts +71 -0
- package/types/apps/src/implementation/swagger-client.d.ts +28 -0
- package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
- package/types/apps/src/implementation/ui-auth.d.ts +12 -6
- package/types/apps/src/implementation/ui-client.d.ts +3 -3
- package/types/apps/src/implementation/ui-document.d.ts +5 -0
- package/types/apps/src/implementation/ui-errors.d.ts +1 -1
- package/types/apps/src/implementation/ui-serving.d.ts +31 -12
- package/types/apps/src/implementation/ui-watch.d.ts +1 -1
- package/types/apps/src/implementation/upstream-error.d.ts +7 -0
- package/types/apps/src/implementation/webhooks.d.ts +15 -6
- package/types/apps/src/implementation/workflow-context.d.ts +17 -5
- package/types/apps/src/implementation/workflows.d.ts +11 -4
- package/types/apps/src/index.d.ts +71 -21
- package/types/apps/src/mcp.d.ts +25 -5
- package/types/apps/src/openapi.d.ts +11 -6
- package/types/apps/src/react.d.ts +1 -1
- package/types/apps/src/skills.d.ts +13 -8
- package/types/apps/src/ui-auth.d.ts +2 -2
- package/types/apps/src/ui-serving.d.ts +1 -1
- package/types/telemetry/src/app-records.d.ts +42 -0
- package/types/telemetry/src/browser-operations.d.ts +7 -4
- package/types/telemetry/src/browser.d.ts +8 -3
- package/types/telemetry/src/config.d.ts +2 -2
- package/types/telemetry/src/index.d.ts +2 -1
- package/types/telemetry/src/layer.d.ts +10 -4
- package/types/telemetry/src/measurements.d.ts +1 -1
- package/types/telemetry/src/ownership.d.ts +60 -0
- package/types/telemetry/src/recorded-failure.d.ts +29 -0
- package/types/telemetry/src/relay.d.ts +16 -6
- package/types/telemetry/src/span-attributes.d.ts +17 -1
- package/types/telemetry/src/transport.d.ts +8 -1
- package/types/utils/src/api-error.d.ts +55 -0
- package/types/utils/src/connection-failure.d.ts +33 -0
- package/types/utils/src/legacy-keys.d.ts +20 -0
- package/types/utils/src/recorded-message.d.ts +18 -0
- package/types/utils/src/schema-definitions.d.ts +13 -0
- package/types/utils/src/user-facing-error.d.ts +83 -0
- package/js/chunk-6IIO4NPI.js +0 -29
- package/js/chunk-6YBRWRK3.js +0 -160
- package/js/chunk-BMOIAIVR.js +0 -138
- package/js/chunk-FZJOYIZO.js +0 -19
- package/js/chunk-G7IE6BKC.js +0 -224
- package/js/chunk-IHQ4ML7K.js +0 -2193
- package/js/chunk-KOXMLKTM.js +0 -1288
- package/js/chunk-M6ZRRIBI.js +0 -877
- package/js/chunk-PLCMJREA.js +0 -590
- package/js/chunk-PZ36XMXW.js +0 -93
- package/js/chunk-RBAC33PQ.js +0 -267
- package/js/chunk-SATWJKN6.js +0 -34
- package/js/chunk-SWPD52J7.js +0 -35
- package/js/chunk-TE4KO4HI.js +0 -47
- package/js/chunk-W7D7WVSY.js +0 -18
- package/js/chunk-X7SFGU4Q.js +0 -280
- package/js/chunk-ZJWDMTE3.js +0 -63
- package/js/mcp/stdio.js +0 -128
- package/types/app-data/src/implementation/cursor.d.ts +0 -10
- package/types/app-data/src/implementation/index-key.d.ts +0 -7
- package/types/app-data/src/implementation/promise.d.ts +0 -68
- package/types/app-data/src/implementation/range.d.ts +0 -8
- package/types/app-data/src/implementation/schema.d.ts +0 -33
- package/types/app-data/src/implementation/sqlite.d.ts +0 -11
- package/types/app-data/src/index.d.ts +0 -4
- package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
- package/types/apps/src/contracts/storage.d.ts +0 -68
- package/types/apps/src/implementation/account-operations.d.ts +0 -151
- package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
- package/types/apps/src/implementation/mcp-stdio.d.ts +0 -4
- package/types/apps/src/implementation/storage.d.ts +0 -13
- package/types/apps/src/mcp-stdio.d.ts +0 -8
package/js/chunk-RBAC33PQ.js
DELETED
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
parseDatabaseSchema,
|
|
3
|
-
promiseTable
|
|
4
|
-
} from "./chunk-PLCMJREA.js";
|
|
5
|
-
import {
|
|
6
|
-
fromPromise,
|
|
7
|
-
nativeOperation
|
|
8
|
-
} from "./chunk-PZ36XMXW.js";
|
|
9
|
-
import {
|
|
10
|
-
ScheduleTiming
|
|
11
|
-
} from "./chunk-IHQ4ML7K.js";
|
|
12
|
-
import {
|
|
13
|
-
decoderOf,
|
|
14
|
-
isSchema,
|
|
15
|
-
storageFieldOf
|
|
16
|
-
} from "./chunk-2HHMABB6.js";
|
|
17
|
-
import {
|
|
18
|
-
AppStorageUnavailable
|
|
19
|
-
} from "./chunk-FZJOYIZO.js";
|
|
20
|
-
import {
|
|
21
|
-
JsonValue
|
|
22
|
-
} from "./chunk-SATWJKN6.js";
|
|
23
|
-
import {
|
|
24
|
-
Effect_exports,
|
|
25
|
-
Schema_exports
|
|
26
|
-
} from "./chunk-FW5HBOIK.js";
|
|
27
|
-
|
|
28
|
-
// ../app-cache/src/contracts/cache.ts
|
|
29
|
-
var CacheError = class extends Schema_exports.TaggedError()("CacheError", {
|
|
30
|
-
reason: Schema_exports.Literals(["unavailable", "storage", "invalid", "capacity", "timeout"])
|
|
31
|
-
}) {
|
|
32
|
-
};
|
|
33
|
-
var cacheLimits = {
|
|
34
|
-
keyBytes: 8192,
|
|
35
|
-
entryBytes: 2e6,
|
|
36
|
-
batchBytes: 8e6,
|
|
37
|
-
batchEntries: 128,
|
|
38
|
-
totalBytes: 128e6,
|
|
39
|
-
totalEntries: 1e5,
|
|
40
|
-
retentionMs: 7 * 24 * 60 * 60 * 1e3,
|
|
41
|
-
loadTimeoutMs: 9e4,
|
|
42
|
-
leaseMs: 12e4
|
|
43
|
-
};
|
|
44
|
-
var Key = Schema_exports.String.check(Schema_exports.isPattern(/^[a-f0-9]{64}$/));
|
|
45
|
-
var Time = Schema_exports.Finite.check(Schema_exports.isGreaterThanOrEqualTo(0));
|
|
46
|
-
var CacheEntry = Schema_exports.Struct({
|
|
47
|
-
value: Schema_exports.Json,
|
|
48
|
-
version: Schema_exports.String,
|
|
49
|
-
freshUntil: Time,
|
|
50
|
-
staleUntil: Time
|
|
51
|
-
});
|
|
52
|
-
var CacheCommand = Schema_exports.Union([
|
|
53
|
-
Schema_exports.Struct({ operation: Schema_exports.Literal("read"), keys: Schema_exports.Array(Key) }),
|
|
54
|
-
Schema_exports.Struct({
|
|
55
|
-
operation: Schema_exports.Literal("claim"),
|
|
56
|
-
key: Key,
|
|
57
|
-
version: Schema_exports.NullOr(Schema_exports.String)
|
|
58
|
-
}),
|
|
59
|
-
Schema_exports.Struct({
|
|
60
|
-
operation: Schema_exports.Literal("publish"),
|
|
61
|
-
key: Key,
|
|
62
|
-
lease: Schema_exports.String,
|
|
63
|
-
entry: CacheEntry
|
|
64
|
-
}),
|
|
65
|
-
Schema_exports.Struct({ operation: Schema_exports.Literal("release"), key: Key, lease: Schema_exports.String }),
|
|
66
|
-
Schema_exports.Struct({
|
|
67
|
-
operation: Schema_exports.Literal("write"),
|
|
68
|
-
entries: Schema_exports.Array(Schema_exports.Struct({ key: Key, entry: CacheEntry }))
|
|
69
|
-
}),
|
|
70
|
-
Schema_exports.Struct({ operation: Schema_exports.Literal("invalidate"), key: Key })
|
|
71
|
-
]);
|
|
72
|
-
var CacheReply = Schema_exports.Union([
|
|
73
|
-
Schema_exports.Struct({ ok: Schema_exports.Literal(true), value: Schema_exports.Json }),
|
|
74
|
-
Schema_exports.Struct({ ok: Schema_exports.Literal(false), error: CacheError })
|
|
75
|
-
]);
|
|
76
|
-
|
|
77
|
-
// src/implementation/workflows.ts
|
|
78
|
-
var NativeWorkflow = /* @__PURE__ */ Symbol("apps.Workflow");
|
|
79
|
-
var workflow = (options, run) => ({
|
|
80
|
-
[NativeWorkflow]: {
|
|
81
|
-
input: decoderOf(options.input),
|
|
82
|
-
...options.output === void 0 ? {} : { output: decoderOf(options.output) },
|
|
83
|
-
...options.description === void 0 ? {} : { description: options.description },
|
|
84
|
-
run: (context, input) => Effect_exports.tryPromise({
|
|
85
|
-
// SAFETY: defineApp checks required context; the host supplies the pinned run's capabilities.
|
|
86
|
-
try: () => run(context, input),
|
|
87
|
-
catch: (error) => error
|
|
88
|
-
})
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
var nativeWorkflow = (value) => {
|
|
92
|
-
if (typeof value !== "object" || value === null || !(NativeWorkflow in value)) return void 0;
|
|
93
|
-
return value[NativeWorkflow];
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
// src/implementation/app.ts
|
|
97
|
-
var InternalApp = /* @__PURE__ */ Symbol("apps.App");
|
|
98
|
-
var isApp = (value) => typeof value === "object" && value !== null && InternalApp in value;
|
|
99
|
-
var toEffectApp = (app) => app[InternalApp];
|
|
100
|
-
function adaptDefinition(definition) {
|
|
101
|
-
if ("tools" in definition) throw new Error("Use queries and mutations instead of tools");
|
|
102
|
-
const webhooks = definition.webhooks === void 0 ? {} : {
|
|
103
|
-
webhooks: Object.fromEntries(
|
|
104
|
-
Object.entries(definition.webhooks).map(([name, webhook]) => [
|
|
105
|
-
name,
|
|
106
|
-
{
|
|
107
|
-
...webhook,
|
|
108
|
-
...webhook.register === void 0 ? {} : { register: fromPromise(webhook.register) },
|
|
109
|
-
handle: fromPromise(webhook.handle),
|
|
110
|
-
...webhook.unregister === void 0 ? {} : { unregister: fromPromise(webhook.unregister) },
|
|
111
|
-
..."config" in webhook && isSchema(webhook.config) ? { config: decoderOf(webhook.config) } : {},
|
|
112
|
-
..."state" in webhook && isSchema(webhook.state) ? { state: decoderOf(webhook.state) } : {}
|
|
113
|
-
}
|
|
114
|
-
])
|
|
115
|
-
)
|
|
116
|
-
};
|
|
117
|
-
const operations = (kind, catalog) => Object.fromEntries(
|
|
118
|
-
Object.entries(catalog).map(([name, value]) => {
|
|
119
|
-
const operation = nativeOperation(value);
|
|
120
|
-
if (operation === void 0 || operation.kind !== kind)
|
|
121
|
-
throw new Error("Invalid app data operation");
|
|
122
|
-
return [name, operation];
|
|
123
|
-
})
|
|
124
|
-
);
|
|
125
|
-
const workflows = definition.workflows === void 0 ? {} : {
|
|
126
|
-
workflows: Object.fromEntries(
|
|
127
|
-
Object.entries(definition.workflows).map(([name, value]) => {
|
|
128
|
-
const declared = nativeWorkflow(value);
|
|
129
|
-
if (declared === void 0) throw new Error("Invalid workflow declaration");
|
|
130
|
-
return [name, declared];
|
|
131
|
-
})
|
|
132
|
-
)
|
|
133
|
-
};
|
|
134
|
-
const data = {
|
|
135
|
-
...definition.queries === void 0 ? {} : { queries: operations("query", definition.queries) },
|
|
136
|
-
...definition.mutations === void 0 ? {} : { mutations: operations("mutation", definition.mutations) }
|
|
137
|
-
};
|
|
138
|
-
const schedules = definition.schedules === void 0 ? {} : {
|
|
139
|
-
schedules: Object.fromEntries(
|
|
140
|
-
Object.entries(definition.schedules).map(([name, schedule]) => {
|
|
141
|
-
const matches = Object.entries(definition.mutations ?? {}).filter(
|
|
142
|
-
([, operation]) => operation === schedule.operation
|
|
143
|
-
);
|
|
144
|
-
const match = matches[0];
|
|
145
|
-
if (match === void 0 || matches.length !== 1)
|
|
146
|
-
throw new Error("A schedule must reference exactly one named mutation in this app");
|
|
147
|
-
return [
|
|
148
|
-
name,
|
|
149
|
-
{
|
|
150
|
-
timing: Schema_exports.decodeUnknownSync(ScheduleTiming)(schedule.timing),
|
|
151
|
-
input: Schema_exports.decodeUnknownSync(JsonValue)(schedule.input),
|
|
152
|
-
tool: `mutations.${match[0]}`
|
|
153
|
-
}
|
|
154
|
-
];
|
|
155
|
-
})
|
|
156
|
-
)
|
|
157
|
-
};
|
|
158
|
-
return {
|
|
159
|
-
...definition,
|
|
160
|
-
...webhooks,
|
|
161
|
-
...workflows,
|
|
162
|
-
...data,
|
|
163
|
-
...schedules
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
var defineApp = (requirements, definition) => {
|
|
167
|
-
const evaluate = typeof definition === "function" ? definition : async () => definition;
|
|
168
|
-
const factory = fromPromise(evaluate);
|
|
169
|
-
const native = {
|
|
170
|
-
accounts: requirements.accounts,
|
|
171
|
-
...requirements.database === void 0 ? {} : { database: requirements.database },
|
|
172
|
-
evaluate: (context) => factory(context).pipe(Effect_exports.map((value) => adaptDefinition(value)))
|
|
173
|
-
};
|
|
174
|
-
return {
|
|
175
|
-
[InternalApp]: native,
|
|
176
|
-
accounts: native.accounts,
|
|
177
|
-
evaluate: (context) => Effect_exports.runPromise(factory(context))
|
|
178
|
-
};
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
// src/implementation/storage.ts
|
|
182
|
-
var table = (fields) => tableWithIndexes(fields, []);
|
|
183
|
-
var tableWithIndexes = (fields, indexes) => ({
|
|
184
|
-
fields,
|
|
185
|
-
indexes,
|
|
186
|
-
index: (name, fieldsInIndex) => tableWithIndexes(fields, [...indexes, { name, fields: fieldsInIndex }])
|
|
187
|
-
});
|
|
188
|
-
var serialize = (tables) => {
|
|
189
|
-
const definitions = Object.fromEntries(
|
|
190
|
-
Object.entries(tables).map(([name, table2]) => [
|
|
191
|
-
name,
|
|
192
|
-
{
|
|
193
|
-
fields: Object.fromEntries(
|
|
194
|
-
Object.entries(table2.fields).map(([fieldName, schema]) => {
|
|
195
|
-
const field = storageFieldOf(schema);
|
|
196
|
-
if (field === void 0) throw new Error("Database columns must use a scalar schema");
|
|
197
|
-
return [fieldName, field];
|
|
198
|
-
})
|
|
199
|
-
),
|
|
200
|
-
indexes: table2.indexes
|
|
201
|
-
}
|
|
202
|
-
])
|
|
203
|
-
);
|
|
204
|
-
return Effect_exports.runSync(parseDatabaseSchema(definitions));
|
|
205
|
-
};
|
|
206
|
-
var authorDatabase = (tables, session, signal, writable) => {
|
|
207
|
-
return Object.fromEntries(
|
|
208
|
-
Object.entries(tables).map(([name, table2]) => {
|
|
209
|
-
const api = promiseTable(session, name, signal);
|
|
210
|
-
const parseFields = (input, partial) => {
|
|
211
|
-
const values = Schema_exports.decodeUnknownSync(
|
|
212
|
-
Schema_exports.Record(Schema_exports.String, Schema_exports.Unknown)
|
|
213
|
-
)(input);
|
|
214
|
-
const fields = {};
|
|
215
|
-
for (const [key, value] of Object.entries(values)) {
|
|
216
|
-
if (value === void 0) continue;
|
|
217
|
-
const field = Object.hasOwn(table2.fields, key) ? table2.fields[key] : void 0;
|
|
218
|
-
if (field === void 0) throw new Error("Unknown database column");
|
|
219
|
-
const definition = storageFieldOf(field);
|
|
220
|
-
fields[key] = value === null && definition?.optional ? null : field.parse(value);
|
|
221
|
-
}
|
|
222
|
-
if (!partial) {
|
|
223
|
-
for (const [key, field] of Object.entries(table2.fields))
|
|
224
|
-
if (!Object.hasOwn(fields, key)) {
|
|
225
|
-
const value = field.parse(void 0);
|
|
226
|
-
if (value !== void 0) fields[key] = value;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
return fields;
|
|
230
|
-
};
|
|
231
|
-
const read = { get: api.get, withIndex: api.withIndex };
|
|
232
|
-
return [
|
|
233
|
-
name,
|
|
234
|
-
writable ? {
|
|
235
|
-
...read,
|
|
236
|
-
insert: (value) => api.insert(parseFields(value, false)),
|
|
237
|
-
update: (id, value) => api.update(id, parseFields(value, true)),
|
|
238
|
-
delete: api.delete
|
|
239
|
-
} : read
|
|
240
|
-
];
|
|
241
|
-
})
|
|
242
|
-
);
|
|
243
|
-
};
|
|
244
|
-
var defineDatabase = (tables) => ({
|
|
245
|
-
schema: serialize(tables),
|
|
246
|
-
tables
|
|
247
|
-
});
|
|
248
|
-
var unavailableStorage = {
|
|
249
|
-
read: () => Effect_exports.fail(new AppStorageUnavailable()),
|
|
250
|
-
mutate: () => Effect_exports.fail(new AppStorageUnavailable())
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
export {
|
|
254
|
-
CacheError,
|
|
255
|
-
cacheLimits,
|
|
256
|
-
CacheEntry,
|
|
257
|
-
CacheCommand,
|
|
258
|
-
CacheReply,
|
|
259
|
-
workflow,
|
|
260
|
-
isApp,
|
|
261
|
-
toEffectApp,
|
|
262
|
-
defineApp,
|
|
263
|
-
table,
|
|
264
|
-
authorDatabase,
|
|
265
|
-
defineDatabase,
|
|
266
|
-
unavailableStorage
|
|
267
|
-
};
|
package/js/chunk-SATWJKN6.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Schema_exports
|
|
3
|
-
} from "./chunk-FW5HBOIK.js";
|
|
4
|
-
|
|
5
|
-
// src/contracts/schema.ts
|
|
6
|
-
var JsonValue = Schema_exports.Json;
|
|
7
|
-
var JsonObject = Schema_exports.Record(Schema_exports.String, JsonValue);
|
|
8
|
-
var AccountId = Schema_exports.String.pipe(
|
|
9
|
-
Schema_exports.check(Schema_exports.isStartsWith("acc_"), Schema_exports.isMinLength(5)),
|
|
10
|
-
Schema_exports.brand("acc")
|
|
11
|
-
);
|
|
12
|
-
var HttpUrl = Schema_exports.String.check(
|
|
13
|
-
Schema_exports.makeFilter((value) => {
|
|
14
|
-
try {
|
|
15
|
-
const url = new URL(value);
|
|
16
|
-
return url.protocol === "https:" || url.protocol === "http:";
|
|
17
|
-
} catch {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
})
|
|
21
|
-
);
|
|
22
|
-
var ValidationError = class extends Schema_exports.TaggedError()("ValidationError", {}) {
|
|
23
|
-
get message() {
|
|
24
|
-
return "Value did not match the schema";
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export {
|
|
29
|
-
JsonValue,
|
|
30
|
-
JsonObject,
|
|
31
|
-
AccountId,
|
|
32
|
-
HttpUrl,
|
|
33
|
-
ValidationError
|
|
34
|
-
};
|
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-TE4KO4HI.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
HttpServerResponse_exports
|
|
3
|
-
} from "./chunk-QKHR7BMF.js";
|
|
4
|
-
|
|
5
|
-
// src/implementation/ui-auth.ts
|
|
6
|
-
var appPrivateHeaders = {
|
|
7
|
-
"cache-control": "no-store",
|
|
8
|
-
"referrer-policy": "no-referrer",
|
|
9
|
-
"x-content-type-options": "nosniff",
|
|
10
|
-
"content-security-policy": "frame-ancestors 'none'"
|
|
11
|
-
};
|
|
12
|
-
var appSignInPage = () => HttpServerResponse_exports.text(
|
|
13
|
-
`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Opening app</title></head><body><p>Opening app\u2026</p><a href="/" hidden>Try again</a><script src="/_executor/auth/browser.js"></script></body></html>`,
|
|
14
|
-
{
|
|
15
|
-
contentType: "text/html",
|
|
16
|
-
headers: {
|
|
17
|
-
...appPrivateHeaders,
|
|
18
|
-
"content-security-policy": "default-src 'none'; script-src 'self'; connect-src 'self'; frame-ancestors 'none'; base-uri 'none'"
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
);
|
|
22
|
-
var appSignInScript = () => HttpServerResponse_exports.text(
|
|
23
|
-
`
|
|
24
|
-
const callback = location.pathname === "/_executor/auth/callback";
|
|
25
|
-
const parameters = new URLSearchParams(location.hash.slice(1));
|
|
26
|
-
const body = callback
|
|
27
|
-
? {request: parameters.get("request"), code: parameters.get("code")}
|
|
28
|
-
: {returnTo: location.pathname + location.search + location.hash};
|
|
29
|
-
if (callback) history.replaceState(null, "", location.pathname);
|
|
30
|
-
fetch(callback ? "/_executor/auth/complete" : "/_executor/auth/start", {
|
|
31
|
-
method: "POST", headers: {"content-type":"application/json"}, body: JSON.stringify(body)
|
|
32
|
-
}).then(async response => {
|
|
33
|
-
if (!response.ok) throw new Error();
|
|
34
|
-
const result = await response.json();
|
|
35
|
-
location.replace(callback ? result.returnTo : result.url);
|
|
36
|
-
}).catch(() => {
|
|
37
|
-
document.querySelector("p").textContent = "Could not sign in to this app. Try opening it again.";
|
|
38
|
-
document.querySelector("a").hidden = false;
|
|
39
|
-
});`,
|
|
40
|
-
{ contentType: "text/javascript", headers: appPrivateHeaders }
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
export {
|
|
44
|
-
appPrivateHeaders,
|
|
45
|
-
appSignInPage,
|
|
46
|
-
appSignInScript
|
|
47
|
-
};
|
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
|
-
};
|
package/js/chunk-X7SFGU4Q.js
DELETED
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
prepareElicitation
|
|
3
|
-
} from "./chunk-KOXMLKTM.js";
|
|
4
|
-
import {
|
|
5
|
-
fromPromise
|
|
6
|
-
} from "./chunk-PZ36XMXW.js";
|
|
7
|
-
import {
|
|
8
|
-
ElicitationFailed,
|
|
9
|
-
McpError,
|
|
10
|
-
McpToolMetadata,
|
|
11
|
-
McpToolResult,
|
|
12
|
-
ToolResultObservation,
|
|
13
|
-
defaultElicitationLimits,
|
|
14
|
-
defaultMcpClientLimits,
|
|
15
|
-
mcpSdkTimerCeilingMs
|
|
16
|
-
} from "./chunk-IHQ4ML7K.js";
|
|
17
|
-
import {
|
|
18
|
-
compileJsonSchemaDecoder,
|
|
19
|
-
jsonSchemaDecoder
|
|
20
|
-
} from "./chunk-2HHMABB6.js";
|
|
21
|
-
import {
|
|
22
|
-
JsonObject
|
|
23
|
-
} from "./chunk-SATWJKN6.js";
|
|
24
|
-
import {
|
|
25
|
-
Clock_exports,
|
|
26
|
-
Deferred_exports,
|
|
27
|
-
Effect_exports,
|
|
28
|
-
Exit_exports,
|
|
29
|
-
Option_exports,
|
|
30
|
-
Queue_exports,
|
|
31
|
-
Schema_exports
|
|
32
|
-
} from "./chunk-FW5HBOIK.js";
|
|
33
|
-
|
|
34
|
-
// src/implementation/mcp-tools.ts
|
|
35
|
-
var adaptMcpTool = (client, tool) => Effect_exports.gen(function* () {
|
|
36
|
-
const decoder = yield* jsonSchemaDecoder(tool.inputSchema).pipe(
|
|
37
|
-
Effect_exports.mapError(() => new McpError({ phase: "schema", reason: "invalid_response" }))
|
|
38
|
-
);
|
|
39
|
-
const output = tool.outputSchema === void 0 ? void 0 : yield* Effect_exports.cached(
|
|
40
|
-
compileJsonSchemaDecoder(tool.outputSchema).pipe(
|
|
41
|
-
Effect_exports.mapError(() => new McpError({ phase: "schema", reason: "invalid_response" }))
|
|
42
|
-
)
|
|
43
|
-
);
|
|
44
|
-
const adapted = {
|
|
45
|
-
...tool,
|
|
46
|
-
description: tool.description ?? tool.title ?? tool.name,
|
|
47
|
-
input: decoder,
|
|
48
|
-
...tool.annotations?.readOnlyHint === void 0 ? {} : { readOnly: tool.annotations.readOnlyHint },
|
|
49
|
-
run: (context, input) => Effect_exports.gen(function* () {
|
|
50
|
-
const arguments_ = yield* Schema_exports.decodeUnknownEffect(decoder)(input).pipe(
|
|
51
|
-
Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(JsonObject)),
|
|
52
|
-
Effect_exports.mapError(() => new McpError({ phase: "call", reason: "invalid_input" }))
|
|
53
|
-
);
|
|
54
|
-
const outputDecoder = output === void 0 ? void 0 : yield* output;
|
|
55
|
-
const result = yield* client.call(tool.name, arguments_, context);
|
|
56
|
-
if (result.isError === true) {
|
|
57
|
-
(yield* ToolResultObservation).failed();
|
|
58
|
-
yield* Effect_exports.annotateCurrentSpan({
|
|
59
|
-
"executor.outcome": "failed",
|
|
60
|
-
"error.type": "McpToolError"
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
if (outputDecoder !== void 0 && !result.isError)
|
|
64
|
-
yield* Schema_exports.decodeUnknownEffect(outputDecoder)(result.structuredContent).pipe(
|
|
65
|
-
Effect_exports.mapError(() => new McpError({ phase: "call", reason: "invalid_response" }))
|
|
66
|
-
);
|
|
67
|
-
return result;
|
|
68
|
-
})
|
|
69
|
-
};
|
|
70
|
-
return adapted;
|
|
71
|
-
});
|
|
72
|
-
var adaptMcpTools = (client) => Effect_exports.gen(function* () {
|
|
73
|
-
const metadata = yield* client.list;
|
|
74
|
-
const entries = yield* Effect_exports.forEach(
|
|
75
|
-
metadata,
|
|
76
|
-
(tool) => adaptMcpTool(client, tool).pipe(Effect_exports.map((adapted) => [tool.name, adapted]))
|
|
77
|
-
);
|
|
78
|
-
return Object.fromEntries(entries);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
// src/implementation/mcp-client.ts
|
|
82
|
-
import { ListToolsResultSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
83
|
-
|
|
84
|
-
// src/implementation/mcp-call.ts
|
|
85
|
-
import {
|
|
86
|
-
ElicitRequestSchema,
|
|
87
|
-
ElicitResultSchema,
|
|
88
|
-
ErrorCode,
|
|
89
|
-
McpError as ProtocolError
|
|
90
|
-
} from "@modelcontextprotocol/sdk/types.js";
|
|
91
|
-
function callBudget(timeoutMs) {
|
|
92
|
-
return Effect_exports.gen(function* () {
|
|
93
|
-
const clock = yield* Clock_exports.Clock;
|
|
94
|
-
const changes = yield* Queue_exports.unbounded();
|
|
95
|
-
let remaining = timeoutMs, updated = clock.currentTimeMillisUnsafe(), waiting = 0;
|
|
96
|
-
const account = () => {
|
|
97
|
-
const now = clock.currentTimeMillisUnsafe();
|
|
98
|
-
if (waiting === 0) remaining -= Math.max(0, now - updated);
|
|
99
|
-
updated = now;
|
|
100
|
-
return remaining;
|
|
101
|
-
};
|
|
102
|
-
return {
|
|
103
|
-
waitForInput: (input) => Effect_exports.acquireUseRelease(
|
|
104
|
-
Effect_exports.sync(() => {
|
|
105
|
-
account();
|
|
106
|
-
waiting++;
|
|
107
|
-
}).pipe(Effect_exports.andThen(Queue_exports.offer(changes, void 0))),
|
|
108
|
-
() => input,
|
|
109
|
-
() => Effect_exports.sync(() => {
|
|
110
|
-
account();
|
|
111
|
-
waiting--;
|
|
112
|
-
}).pipe(Effect_exports.andThen(Queue_exports.offer(changes, void 0)))
|
|
113
|
-
),
|
|
114
|
-
expired: Effect_exports.gen(function* () {
|
|
115
|
-
while (true) {
|
|
116
|
-
const left = account();
|
|
117
|
-
if (waiting === 0 && left <= 0)
|
|
118
|
-
return yield* new McpError({ phase: "call", reason: "timeout" });
|
|
119
|
-
if (waiting > 0) yield* Queue_exports.take(changes);
|
|
120
|
-
else yield* Queue_exports.take(changes).pipe(Effect_exports.raceFirst(Effect_exports.sleep(Math.max(1, left))));
|
|
121
|
-
}
|
|
122
|
-
})
|
|
123
|
-
};
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
var mcpCall = (client, name, input, context, timeoutMs, failure) => Effect_exports.scoped(
|
|
127
|
-
Effect_exports.gen(function* () {
|
|
128
|
-
const budget = yield* callBudget(timeoutMs);
|
|
129
|
-
const failed = yield* Deferred_exports.make();
|
|
130
|
-
const runtime = yield* Effect_exports.context();
|
|
131
|
-
const callbacks = /* @__PURE__ */ new Set();
|
|
132
|
-
const lifetime = yield* Effect_exports.acquireRelease(
|
|
133
|
-
Effect_exports.sync(() => new AbortController()),
|
|
134
|
-
(controller) => Effect_exports.promise(async () => {
|
|
135
|
-
controller.abort();
|
|
136
|
-
client.removeRequestHandler("elicitation/create");
|
|
137
|
-
await Promise.allSettled(callbacks);
|
|
138
|
-
})
|
|
139
|
-
);
|
|
140
|
-
client.setRequestHandler(ElicitRequestSchema, (request, extra) => {
|
|
141
|
-
const signal = AbortSignal.any([lifetime.signal, extra.signal]);
|
|
142
|
-
const interaction = Effect_exports.gen(function* () {
|
|
143
|
-
const form = yield* prepareElicitation({
|
|
144
|
-
...request.params,
|
|
145
|
-
mode: request.params.mode ?? "form"
|
|
146
|
-
});
|
|
147
|
-
const deliver = context.elicit;
|
|
148
|
-
if (deliver === void 0) return yield* new ElicitationFailed({ reason: "unavailable" });
|
|
149
|
-
const answer = yield* budget.waitForInput(
|
|
150
|
-
fromPromise(deliver)(form.request).pipe(
|
|
151
|
-
Effect_exports.mapError(
|
|
152
|
-
(error) => Option_exports.getOrElse(
|
|
153
|
-
Schema_exports.decodeUnknownOption(ElicitationFailed)(error),
|
|
154
|
-
() => new ElicitationFailed({ reason: "transport" })
|
|
155
|
-
)
|
|
156
|
-
),
|
|
157
|
-
Effect_exports.timeoutOrElse({
|
|
158
|
-
duration: defaultElicitationLimits.timeoutMs,
|
|
159
|
-
orElse: () => Effect_exports.fail(new ElicitationFailed({ reason: "expired" }))
|
|
160
|
-
})
|
|
161
|
-
)
|
|
162
|
-
).pipe(Effect_exports.withSpan("provider.mcp.elicitation"));
|
|
163
|
-
return yield* form.respond(answer).pipe(
|
|
164
|
-
Effect_exports.flatMap(
|
|
165
|
-
(response) => Effect_exports.try({
|
|
166
|
-
try: () => ElicitResultSchema.parse(response),
|
|
167
|
-
catch: () => new ElicitationFailed({ reason: "invalid-response" })
|
|
168
|
-
})
|
|
169
|
-
)
|
|
170
|
-
);
|
|
171
|
-
}).pipe(Effect_exports.tapError((error) => Deferred_exports.fail(failed, error)));
|
|
172
|
-
const callback = Effect_exports.runPromiseWith(runtime)(interaction, { signal }).catch(() => {
|
|
173
|
-
if (!lifetime.signal.aborted)
|
|
174
|
-
Effect_exports.runSync(Deferred_exports.fail(failed, new ElicitationFailed({ reason: "transport" })));
|
|
175
|
-
throw new ProtocolError(ErrorCode.InternalError, "User input could not be delivered");
|
|
176
|
-
});
|
|
177
|
-
callbacks.add(callback);
|
|
178
|
-
return callback.finally(() => callbacks.delete(callback));
|
|
179
|
-
});
|
|
180
|
-
return yield* Effect_exports.tryPromise({
|
|
181
|
-
try: (signal) => client.callTool({ name, arguments: input }, void 0, {
|
|
182
|
-
signal: AbortSignal.any([signal, lifetime.signal]),
|
|
183
|
-
timeout: mcpSdkTimerCeilingMs
|
|
184
|
-
}),
|
|
185
|
-
catch: (error) => failure("call", error)
|
|
186
|
-
}).pipe(
|
|
187
|
-
Effect_exports.raceFirst(Deferred_exports.await(failed)),
|
|
188
|
-
Effect_exports.raceFirst(budget.expired),
|
|
189
|
-
Effect_exports.flatMap(
|
|
190
|
-
(result) => Schema_exports.decodeUnknownEffect(McpToolResult)(result).pipe(
|
|
191
|
-
Effect_exports.mapError(() => new McpError({ phase: "call", reason: "invalid_response" }))
|
|
192
|
-
)
|
|
193
|
-
),
|
|
194
|
-
Effect_exports.tap(
|
|
195
|
-
(result) => Effect_exports.annotateCurrentSpan("mcp.tool.is_error", result.isError === true)
|
|
196
|
-
)
|
|
197
|
-
);
|
|
198
|
-
})
|
|
199
|
-
).pipe(
|
|
200
|
-
Effect_exports.withSpan("provider.mcp.request", {
|
|
201
|
-
kind: "client",
|
|
202
|
-
attributes: {
|
|
203
|
-
"rpc.system.name": "jsonrpc",
|
|
204
|
-
"rpc.method": "tools/call",
|
|
205
|
-
"mcp.tool.name": name
|
|
206
|
-
}
|
|
207
|
-
})
|
|
208
|
-
);
|
|
209
|
-
|
|
210
|
-
// src/implementation/mcp-client.ts
|
|
211
|
-
var mcpJsonSchemaValidator = {
|
|
212
|
-
getValidator(document) {
|
|
213
|
-
const decoder = Effect_exports.runSync(jsonSchemaDecoder(document));
|
|
214
|
-
return (input) => {
|
|
215
|
-
const result = Effect_exports.runSyncExit(Schema_exports.decodeUnknownEffect(decoder)(input));
|
|
216
|
-
if (Exit_exports.isFailure(result))
|
|
217
|
-
return {
|
|
218
|
-
valid: false,
|
|
219
|
-
data: void 0,
|
|
220
|
-
errorMessage: "Value does not match the supported JSON Schema"
|
|
221
|
-
};
|
|
222
|
-
return { valid: true, data: result.value, errorMessage: void 0 };
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
function mcpClient(withClient, timeoutMs, failure) {
|
|
227
|
-
const list = withClient(
|
|
228
|
-
"discover",
|
|
229
|
-
(client) => Effect_exports.gen(function* () {
|
|
230
|
-
const tools = /* @__PURE__ */ new Map();
|
|
231
|
-
const cursors = /* @__PURE__ */ new Set();
|
|
232
|
-
let cursor;
|
|
233
|
-
do {
|
|
234
|
-
const page = yield* Effect_exports.tryPromise({
|
|
235
|
-
// This session only reads metadata. listTools() also eagerly compiles
|
|
236
|
-
// every output validator; mcpOperations validates the selected tool on call.
|
|
237
|
-
try: (signal) => client.request(
|
|
238
|
-
{ method: "tools/list", params: cursor === void 0 ? {} : { cursor } },
|
|
239
|
-
ListToolsResultSchema,
|
|
240
|
-
{ signal, timeout: timeoutMs }
|
|
241
|
-
),
|
|
242
|
-
catch: (error) => failure("discover", error)
|
|
243
|
-
}).pipe(
|
|
244
|
-
Effect_exports.withSpan("provider.mcp.request", {
|
|
245
|
-
kind: "client",
|
|
246
|
-
attributes: { "rpc.system.name": "jsonrpc", "rpc.method": "tools/list" }
|
|
247
|
-
})
|
|
248
|
-
);
|
|
249
|
-
const metadata = yield* Schema_exports.decodeUnknownEffect(Schema_exports.Array(McpToolMetadata))(
|
|
250
|
-
page.tools
|
|
251
|
-
).pipe(
|
|
252
|
-
Effect_exports.mapError(() => new McpError({ phase: "discover", reason: "invalid_response" }))
|
|
253
|
-
);
|
|
254
|
-
for (const tool of metadata) {
|
|
255
|
-
if (!tool.name || tools.has(tool.name) || tools.size >= defaultMcpClientLimits.maxTools)
|
|
256
|
-
return yield* new McpError({ phase: "discover", reason: "invalid_response" });
|
|
257
|
-
tools.set(tool.name, tool);
|
|
258
|
-
}
|
|
259
|
-
cursor = page.nextCursor;
|
|
260
|
-
if (cursor !== void 0) {
|
|
261
|
-
if (cursors.has(cursor) || cursors.size >= defaultMcpClientLimits.maxPaginationCursors)
|
|
262
|
-
return yield* new McpError({ phase: "discover", reason: "invalid_response" });
|
|
263
|
-
cursors.add(cursor);
|
|
264
|
-
}
|
|
265
|
-
} while (cursor !== void 0);
|
|
266
|
-
return [...tools.values()];
|
|
267
|
-
})
|
|
268
|
-
).pipe(Effect_exports.withSpan("provider.mcp.discover"));
|
|
269
|
-
const call = (name, input, context) => withClient("call", (client) => mcpCall(client, name, input, context, timeoutMs, failure)).pipe(
|
|
270
|
-
Effect_exports.withSpan("provider.mcp.call", { attributes: { "mcp.tool.name": name } })
|
|
271
|
-
);
|
|
272
|
-
return { list, call };
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
export {
|
|
276
|
-
adaptMcpTool,
|
|
277
|
-
adaptMcpTools,
|
|
278
|
-
mcpJsonSchemaValidator,
|
|
279
|
-
mcpClient
|
|
280
|
-
};
|