apps 0.0.1-beta.0 → 0.0.1-beta.10
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 +145 -30
- package/framework-reference.json +1 -1
- package/js/browser-XIPJGLH2.js +65 -0
- package/js/{chunk-36DNRFZQ.js → chunk-27F7W2LG.js} +1 -1
- package/js/{chunk-VFUZI3NY.js → chunk-57RKNWL2.js} +4 -4
- package/js/{chunk-BPEFS4YF.js → chunk-5T57N25Q.js} +122 -18
- package/js/chunk-72JNVHPK.js +41 -0
- package/js/{chunk-2OTCEKL2.js → chunk-CDL5PM2Q.js} +2643 -1646
- package/js/{chunk-KWTCHVLT.js → chunk-CRDWFA74.js} +69 -54
- package/js/chunk-CZ7CSFO4.js +39 -0
- package/js/{chunk-WIDTG42X.js → chunk-EPT3ZP52.js} +79 -26
- package/js/chunk-FL2QR3XW.js +507 -0
- package/js/{chunk-3ANFZFCV.js → chunk-IJX4CYZO.js} +15 -18
- package/js/chunk-IPI4MFSN.js +78 -0
- package/js/chunk-JU7VHODU.js +104 -0
- package/js/chunk-KUMBKVJD.js +39 -0
- package/js/{chunk-YDR4CPJA.js → chunk-M3B3DE4K.js} +8 -8
- package/js/chunk-MKWZPDR6.js +63 -0
- package/js/{chunk-7JXHF5IF.js → chunk-N7YDVXYJ.js} +49 -1
- package/js/chunk-NKLWZJLE.js +172 -0
- package/js/{chunk-OWD2YICM.js → chunk-ODEIDRGW.js} +116 -88
- package/js/{chunk-D6BKYP2L.js → chunk-PJJ24GU7.js} +4 -4
- package/js/{chunk-EP6AEUZO.js → chunk-PZB6T6KU.js} +1 -1
- package/js/chunk-R3EV5FTO.js +97 -0
- package/js/chunk-RFVIONFX.js +189 -0
- package/js/{chunk-W7Q5EOTS.js → chunk-UK573G7W.js} +32 -32
- package/js/chunk-UVL56Z6E.js +6641 -0
- package/js/{chunk-Q2FD5IBM.js → chunk-V5KNQVCT.js} +505 -124
- package/js/{chunk-SBKHUC5L.js → chunk-VFZKSM3T.js} +5 -25
- package/js/{chunk-HP7E42X6.js → chunk-WLE7WX2U.js} +1158 -232
- package/js/{chunk-X3YBZCJW.js → chunk-YXQHV65J.js} +58 -62
- package/js/chunk-Z5M2LQOZ.js +209 -0
- package/js/{chunk-R6JMJSVT.js → chunk-ZQINWV4W.js} +60 -20
- package/js/client.js +11 -27
- package/js/contracts.js +138 -27
- package/js/effect.js +20 -15
- package/js/es-APDZKREY.js +40968 -0
- package/js/graphql.js +220 -123
- package/js/host.js +75 -19
- package/js/index.js +261 -117
- package/js/mcp/effect.js +24 -17
- package/js/mcp/stdio.js +26 -21
- package/js/mcp.js +127 -26
- package/js/openapi.js +3048 -150
- package/js/operations/approval.js +1 -1
- package/js/react.js +4 -4
- package/js/skills/effect.js +11 -0
- package/js/skills.js +893 -0
- package/js/storage/facet.js +7 -7
- package/js/ui/auth/contracts.js +9 -10
- package/js/ui/auth.js +17 -15
- package/js/ui/contracts.js +5 -5
- package/js/ui/serving.js +14 -13
- package/package.json +9 -1
- package/runtime.json +1 -1
- package/types/app-cache/src/contracts/cache.d.ts +119 -0
- package/types/app-cache/src/index.d.ts +93 -0
- package/types/app-data/src/contracts/database.d.ts +33 -6
- package/types/app-data/src/implementation/schema.d.ts +2 -17
- package/types/apps/src/contracts/api-response-error.d.ts +43 -0
- package/types/apps/src/contracts/app.d.ts +16 -4
- package/types/apps/src/contracts/cache.d.ts +44 -0
- package/types/apps/src/contracts/dynamic-skills.d.ts +10 -0
- package/types/apps/src/contracts/failure.d.ts +25 -0
- package/types/apps/src/contracts/graphql.d.ts +18 -1
- package/types/apps/src/contracts/host.d.ts +76 -528
- package/types/apps/src/contracts/mcp.d.ts +19 -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 +160 -30
- package/types/apps/src/contracts/operations.d.ts +0 -5
- package/types/apps/src/contracts/protocol-version.d.ts +6 -0
- package/types/apps/src/contracts/protocols/1.d.ts +1589 -0
- package/types/apps/src/contracts/protocols/2.d.ts +668 -0
- package/types/apps/src/contracts/protocols/3.d.ts +676 -0
- package/types/apps/src/contracts/protocols/4.d.ts +1229 -0
- package/types/apps/src/contracts/protocols/5.d.ts +1090 -0
- package/types/apps/src/contracts/provider-error.d.ts +15 -0
- package/types/apps/src/contracts/provider.d.ts +69 -6
- package/types/apps/src/contracts/router.d.ts +59 -0
- package/types/apps/src/contracts/skills.d.ts +122 -0
- package/types/apps/src/contracts/storage.d.ts +3 -3
- package/types/apps/src/contracts/swagger-client.d.ts +29 -0
- package/types/apps/src/contracts/ui-auth.d.ts +6 -14
- package/types/apps/src/contracts/workflows.d.ts +34 -3
- package/types/apps/src/graphql.d.ts +5 -7
- package/types/apps/src/host.d.ts +1 -0
- package/types/apps/src/implementation/account-router.d.ts +12 -0
- package/types/apps/src/implementation/app.d.ts +5 -4
- package/types/apps/src/implementation/cache-session.d.ts +7 -0
- package/types/apps/src/implementation/cache.d.ts +8 -0
- package/types/apps/src/implementation/catalog-cache.d.ts +36 -0
- package/types/apps/src/implementation/dynamic-skills.d.ts +7 -0
- package/types/apps/src/implementation/elicitation.d.ts +13 -13
- package/types/apps/src/implementation/failure-detail.d.ts +25 -0
- package/types/apps/src/implementation/git.d.ts +25 -0
- package/types/apps/src/implementation/graphql-catalog.d.ts +7 -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 +9 -0
- package/types/apps/src/implementation/mcp-client.d.ts +39 -22
- 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 +55 -2
- package/types/apps/src/implementation/openapi-compile.d.ts +120 -0
- package/types/apps/src/implementation/openapi-document.d.ts +51 -0
- package/types/apps/src/implementation/openapi-names.d.ts +18 -0
- package/types/apps/src/implementation/openapi-request.d.ts +10 -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/operations.d.ts +26 -3
- package/types/apps/src/implementation/protocol-operations.d.ts +3 -4
- package/types/apps/src/implementation/provider-error.d.ts +10 -0
- package/types/apps/src/implementation/provider.d.ts +9 -4
- package/types/apps/src/implementation/router-catalog.d.ts +225 -0
- package/types/apps/src/implementation/router.d.ts +59 -0
- package/types/apps/src/implementation/schema.d.ts +11 -6
- 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/implementation/storage.d.ts +5 -3
- package/types/apps/src/implementation/swagger-client.d.ts +28 -0
- package/types/apps/src/implementation/ui-auth.d.ts +11 -5
- package/types/apps/src/implementation/ui-serving.d.ts +4 -2
- package/types/apps/src/implementation/webhooks.d.ts +1 -1
- package/types/apps/src/implementation/workflow-context.d.ts +11 -3
- package/types/apps/src/index.d.ts +11 -3
- package/types/apps/src/mcp-stdio.d.ts +2 -5
- package/types/apps/src/mcp.d.ts +8 -7
- package/types/apps/src/openapi.d.ts +8 -6
- package/types/apps/src/skills.d.ts +75 -0
- package/types/apps/src/ui-auth.d.ts +2 -2
- package/types/telemetry/src/browser-operations.d.ts +5 -2
- package/types/telemetry/src/config.d.ts +2 -0
- package/js/chunk-22WRQZT7.js +0 -389
- package/js/chunk-BKVL7XAJ.js +0 -47
- package/js/chunk-C24KEZXR.js +0 -59
- package/js/chunk-LOKGDT6B.js +0 -28
- package/js/chunk-MLKGABMK.js +0 -9
- package/types/apps/src/implementation/account-operations.d.ts +0 -32
package/js/index.js
CHANGED
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ResponseDecodeError,
|
|
3
|
+
ResponseStatusError,
|
|
2
4
|
defineApp,
|
|
3
5
|
defineDatabase,
|
|
4
6
|
table,
|
|
5
7
|
workflow
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-YXQHV65J.js";
|
|
9
|
+
import "./chunk-ZQINWV4W.js";
|
|
8
10
|
import {
|
|
11
|
+
dynamicRouter,
|
|
12
|
+
fromPromise,
|
|
9
13
|
mutation,
|
|
10
14
|
nativeOperation,
|
|
15
|
+
nativeRouter,
|
|
11
16
|
operationDeclaration,
|
|
12
17
|
query,
|
|
18
|
+
router,
|
|
19
|
+
routerDeclaration,
|
|
13
20
|
withApproval
|
|
14
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-Z5M2LQOZ.js";
|
|
22
|
+
import {
|
|
23
|
+
accountProviderError
|
|
24
|
+
} from "./chunk-MKWZPDR6.js";
|
|
15
25
|
import {
|
|
16
26
|
CalendarSchedule,
|
|
17
27
|
ElicitationFailed,
|
|
28
|
+
HostedTool,
|
|
29
|
+
HostedToolSummary,
|
|
18
30
|
Interval,
|
|
19
31
|
NonRetryableError,
|
|
20
32
|
OAuth2AccessToken,
|
|
@@ -24,8 +36,13 @@ import {
|
|
|
24
36
|
ScheduleTiming,
|
|
25
37
|
SecretsMethod,
|
|
26
38
|
WorkflowFailure
|
|
27
|
-
} from "./chunk-
|
|
28
|
-
import "./chunk-
|
|
39
|
+
} from "./chunk-WLE7WX2U.js";
|
|
40
|
+
import "./chunk-N7YDVXYJ.js";
|
|
41
|
+
import {
|
|
42
|
+
CacheError,
|
|
43
|
+
ProviderError
|
|
44
|
+
} from "./chunk-R3EV5FTO.js";
|
|
45
|
+
import "./chunk-JU7VHODU.js";
|
|
29
46
|
import {
|
|
30
47
|
array,
|
|
31
48
|
boolean,
|
|
@@ -38,42 +55,25 @@ import {
|
|
|
38
55
|
nestJsonSchema,
|
|
39
56
|
number,
|
|
40
57
|
object,
|
|
58
|
+
once,
|
|
41
59
|
parse,
|
|
42
60
|
record,
|
|
43
61
|
string,
|
|
44
62
|
userId,
|
|
45
|
-
|
|
63
|
+
withLazyJsonSchemaDocument,
|
|
46
64
|
wrap
|
|
47
|
-
} from "./chunk-
|
|
48
|
-
import "./chunk-
|
|
65
|
+
} from "./chunk-5T57N25Q.js";
|
|
66
|
+
import "./chunk-PZB6T6KU.js";
|
|
49
67
|
import {
|
|
50
68
|
JsonObject,
|
|
51
69
|
JsonValue,
|
|
52
70
|
ValidationError
|
|
53
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-27F7W2LG.js";
|
|
54
72
|
import {
|
|
55
73
|
Effect_exports,
|
|
56
74
|
Schema_exports
|
|
57
|
-
} from "./chunk-
|
|
58
|
-
import "./chunk-
|
|
59
|
-
|
|
60
|
-
// src/contracts/http.ts
|
|
61
|
-
var ResponseStatusError = class extends Schema_exports.TaggedError()(
|
|
62
|
-
"ResponseStatusError",
|
|
63
|
-
{ status: Schema_exports.Number }
|
|
64
|
-
) {
|
|
65
|
-
get message() {
|
|
66
|
-
return `Request failed with status ${this.status}`;
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
var ResponseDecodeError = class extends Schema_exports.TaggedError()(
|
|
70
|
-
"ResponseDecodeError",
|
|
71
|
-
{}
|
|
72
|
-
) {
|
|
73
|
-
get message() {
|
|
74
|
-
return "Response body did not match the expected schema";
|
|
75
|
-
}
|
|
76
|
-
};
|
|
75
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
76
|
+
import "./chunk-CZ7CSFO4.js";
|
|
77
77
|
|
|
78
78
|
// src/implementation/http.ts
|
|
79
79
|
var decodeJson = (response, schema) => Effect_exports.gen(function* () {
|
|
@@ -87,110 +87,249 @@ var decodeJson = (response, schema) => Effect_exports.gen(function* () {
|
|
|
87
87
|
// src/implementation/provider.ts
|
|
88
88
|
var secrets = (options) => new SecretsMethod(options);
|
|
89
89
|
var oauth2 = (config, response) => parse(OAuth2Config, config).pipe(Effect_exports.map((config2) => new OAuth2Method({ config: config2, response })));
|
|
90
|
-
var defineProvider = (
|
|
90
|
+
var defineProvider = ({
|
|
91
|
+
health,
|
|
92
|
+
...options
|
|
93
|
+
}) => {
|
|
94
|
+
if (health === void 0) return new Provider(options);
|
|
95
|
+
const run = fromPromise(health);
|
|
96
|
+
return new Provider({ ...options, health: { run } });
|
|
97
|
+
};
|
|
91
98
|
|
|
92
|
-
// src/implementation/account-
|
|
99
|
+
// src/implementation/account-router.ts
|
|
93
100
|
var inputDocument = (operation) => {
|
|
94
101
|
const imported = importedJsonSchema(operation.input);
|
|
95
102
|
if (imported !== void 0) return Schema_exports.decodeUnknownSync(JsonObject)(imported);
|
|
96
103
|
const document = Schema_exports.toJsonSchemaDocument(operation.input);
|
|
97
104
|
return Schema_exports.decodeUnknownSync(JsonObject)({ ...document.schema, $defs: document.definitions });
|
|
98
105
|
};
|
|
99
|
-
var
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
106
|
+
var declaresOutput = (operation) => {
|
|
107
|
+
const property = Object.getOwnPropertyDescriptor(operation, "outputSchema");
|
|
108
|
+
return property !== void 0 && (property.get !== void 0 || property.value !== void 0);
|
|
109
|
+
};
|
|
110
|
+
var combineOperation = (accounts) => {
|
|
111
|
+
const variants = [...accounts.values()];
|
|
112
|
+
const first = variants[0];
|
|
113
|
+
if (first === void 0) throw new Error("An account operation must have at least one account");
|
|
114
|
+
const kind = variants.every((operation) => operation.kind === "query") ? "query" : "mutation";
|
|
115
|
+
const select = (input2) => {
|
|
116
|
+
const operation = accounts.get(input2.accountId);
|
|
117
|
+
if (operation === void 0)
|
|
118
|
+
throw new Error("Account selection must be decoded before execution");
|
|
119
|
+
return operation;
|
|
120
|
+
};
|
|
121
|
+
const input = Schema_exports.Union(
|
|
122
|
+
[...accounts].map(
|
|
123
|
+
([accountId, operation]) => Schema_exports.Struct({ accountId: Schema_exports.Literal(accountId), input: operation.input })
|
|
124
|
+
)
|
|
125
|
+
);
|
|
126
|
+
const inputSchema = () => ({
|
|
127
|
+
type: "object",
|
|
128
|
+
anyOf: [...accounts].map(([accountId, operation], index) => ({
|
|
120
129
|
type: "object",
|
|
121
|
-
|
|
122
|
-
type: "
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
130
|
+
properties: {
|
|
131
|
+
accountId: { type: "string", const: accountId },
|
|
132
|
+
input: nestJsonSchema(inputDocument(operation), `#/anyOf/${index}/properties/input`)
|
|
133
|
+
},
|
|
134
|
+
required: ["accountId", "input"]
|
|
135
|
+
}))
|
|
136
|
+
});
|
|
137
|
+
const declaration2 = operationDeclaration({
|
|
138
|
+
kind,
|
|
139
|
+
...first.description === void 0 ? {} : { description: first.description },
|
|
140
|
+
...first.title === void 0 ? {} : { title: first.title },
|
|
141
|
+
...first.annotations === void 0 || !variants.every(
|
|
142
|
+
(operation) => JSON.stringify(operation.annotations) === JSON.stringify(first.annotations)
|
|
143
|
+
) ? {} : { annotations: first.annotations },
|
|
144
|
+
...first._meta === void 0 || !variants.every((operation) => JSON.stringify(operation._meta) === JSON.stringify(first._meta)) ? {} : { _meta: first._meta },
|
|
145
|
+
input: withLazyJsonSchemaDocument(input, inputSchema),
|
|
146
|
+
approval: (context) => {
|
|
147
|
+
const operation = select(context.toolInput);
|
|
148
|
+
return operation.approval === void 0 ? Effect_exports.succeed("approved") : operation.approval({ ...context, toolInput: context.toolInput.input });
|
|
149
|
+
},
|
|
150
|
+
run: (context, input2) => {
|
|
151
|
+
const operation = select(input2);
|
|
152
|
+
return operation.run(context, input2.input).pipe(
|
|
153
|
+
Effect_exports.mapError((error) => accountProviderError(error, input2.accountId)),
|
|
154
|
+
Effect_exports.flatMap(
|
|
155
|
+
(output) => operation.output === void 0 ? Effect_exports.succeed(output) : Schema_exports.decodeUnknownEffect(operation.output)(output)
|
|
156
|
+
)
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
if (variants.every(declaresOutput)) {
|
|
161
|
+
const outputSchema = once(() => ({
|
|
162
|
+
anyOf: variants.flatMap(
|
|
163
|
+
(operation) => operation.outputSchema === void 0 ? [] : [operation.outputSchema]
|
|
164
|
+
).map((output, index) => nestJsonSchema(output, `#/anyOf/${index}`))
|
|
165
|
+
}));
|
|
166
|
+
const native2 = nativeOperation(declaration2);
|
|
167
|
+
if (native2 !== void 0)
|
|
168
|
+
Object.defineProperty(native2, "outputSchema", { enumerable: true, get: outputSchema });
|
|
169
|
+
}
|
|
170
|
+
const native = nativeOperation(declaration2);
|
|
171
|
+
if (native === void 0) throw new Error("Expected a combined operation");
|
|
172
|
+
return native;
|
|
173
|
+
};
|
|
174
|
+
var sameAcross = (key, variants) => {
|
|
175
|
+
const first = variants[0]?.[1][key];
|
|
176
|
+
return first !== void 0 && variants.every(([, tool]) => JSON.stringify(tool[key]) === JSON.stringify(first)) ? { [key]: first } : {};
|
|
177
|
+
};
|
|
178
|
+
var mergeSummary = (name, variants) => {
|
|
179
|
+
const first = variants[0]?.[1];
|
|
180
|
+
if (first === void 0) throw new Error("Expected a source operation");
|
|
181
|
+
return Schema_exports.decodeUnknownSync(HostedToolSummary)({
|
|
182
|
+
name,
|
|
183
|
+
description: first.description,
|
|
184
|
+
...first.title === void 0 ? {} : { title: first.title },
|
|
185
|
+
readOnly: variants.every(([, tool]) => tool.readOnly === true),
|
|
186
|
+
...sameAcross("annotations", variants)
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
var merge = (name, variants) => Schema_exports.decodeUnknownSync(HostedTool)({
|
|
190
|
+
...mergeSummary(name, variants),
|
|
191
|
+
inputSchema: {
|
|
192
|
+
type: "object",
|
|
193
|
+
anyOf: variants.map(([accountId, tool], index) => ({
|
|
194
|
+
type: "object",
|
|
195
|
+
properties: {
|
|
196
|
+
accountId: { type: "string", const: accountId },
|
|
197
|
+
input: nestJsonSchema(tool.inputSchema, `#/anyOf/${index}/properties/input`)
|
|
198
|
+
},
|
|
199
|
+
required: ["accountId", "input"]
|
|
200
|
+
}))
|
|
201
|
+
},
|
|
202
|
+
...variants.every(([, tool]) => tool.outputSchema !== void 0) ? {
|
|
203
|
+
outputSchema: {
|
|
204
|
+
anyOf: variants.flatMap(
|
|
205
|
+
([, tool], index) => tool.outputSchema === void 0 ? [] : [nestJsonSchema(tool.outputSchema, `#/anyOf/${index}`)]
|
|
206
|
+
)
|
|
207
|
+
}
|
|
208
|
+
} : {},
|
|
209
|
+
...sameAcross("_meta", variants)
|
|
210
|
+
});
|
|
211
|
+
var combineDynamic = (sources) => {
|
|
212
|
+
const first = [...sources.values()][0];
|
|
213
|
+
const grouped = (read) => Effect_exports.gen(function* () {
|
|
214
|
+
const groups = /* @__PURE__ */ new Map();
|
|
215
|
+
for (const [accountId, source] of sources) {
|
|
216
|
+
const tools = yield* read(source).pipe(
|
|
217
|
+
Effect_exports.mapError((error) => accountProviderError(error, accountId))
|
|
218
|
+
);
|
|
219
|
+
for (const tool of tools) {
|
|
220
|
+
const variants = groups.get(tool.name) ?? [];
|
|
221
|
+
if (variants.some(([id2]) => id2 === accountId))
|
|
222
|
+
return yield* Effect_exports.die(new Error("Duplicate source operation"));
|
|
223
|
+
variants.push([accountId, tool]);
|
|
224
|
+
groups.set(tool.name, variants);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return groups;
|
|
228
|
+
});
|
|
229
|
+
return {
|
|
230
|
+
kind: "dynamic",
|
|
231
|
+
// Accounts share one source, so the first account describes the router.
|
|
232
|
+
...first?.meta === void 0 ? {} : { meta: first.meta },
|
|
233
|
+
...first?.overrides === void 0 ? {} : { overrides: first.overrides },
|
|
234
|
+
list: () => grouped((source) => source.list()).pipe(
|
|
235
|
+
Effect_exports.map((groups) => [...groups].map(([name, variants]) => merge(name, variants)))
|
|
236
|
+
),
|
|
237
|
+
summaries: () => grouped(
|
|
238
|
+
(source) => source.summaries === void 0 ? source.list() : source.summaries()
|
|
239
|
+
).pipe(
|
|
240
|
+
Effect_exports.map((groups) => [...groups].map(([name, variants]) => mergeSummary(name, variants)))
|
|
241
|
+
),
|
|
242
|
+
describe: (name) => Effect_exports.gen(function* () {
|
|
243
|
+
const variants = [];
|
|
244
|
+
for (const [accountId, source] of sources) {
|
|
245
|
+
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)));
|
|
246
|
+
if (tool !== void 0) variants.push([accountId, tool]);
|
|
247
|
+
}
|
|
248
|
+
return variants.length === 0 ? void 0 : merge(name, variants);
|
|
249
|
+
}),
|
|
250
|
+
resolve: (name) => Effect_exports.gen(function* () {
|
|
251
|
+
const operations = /* @__PURE__ */ new Map();
|
|
252
|
+
for (const [accountId, source] of sources) {
|
|
253
|
+
const operation = yield* source.resolve(name).pipe(Effect_exports.mapError((error) => accountProviderError(error, accountId)));
|
|
254
|
+
if (operation !== void 0) operations.set(accountId, operation);
|
|
255
|
+
}
|
|
256
|
+
return operations.size === 0 ? void 0 : combineOperation(operations);
|
|
257
|
+
})
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
var combineNode = (variants) => {
|
|
261
|
+
const nodes = [...variants.values()];
|
|
262
|
+
const first = nodes[0];
|
|
263
|
+
if (first === void 0) throw new Error("An account operation must have at least one account");
|
|
264
|
+
switch (first.kind) {
|
|
265
|
+
case "query":
|
|
266
|
+
case "mutation":
|
|
267
|
+
return combineOperation(
|
|
268
|
+
narrow(
|
|
269
|
+
variants,
|
|
270
|
+
(node) => node.kind === "query" || node.kind === "mutation"
|
|
271
|
+
)
|
|
272
|
+
);
|
|
273
|
+
case "dynamic":
|
|
274
|
+
return combineDynamic(
|
|
275
|
+
narrow(variants, (node) => node.kind === "dynamic")
|
|
276
|
+
);
|
|
277
|
+
case "router": {
|
|
278
|
+
const routers = narrow(variants, (node) => node.kind === "router");
|
|
279
|
+
const keys = new Set([...routers.values()].flatMap((router2) => Object.keys(router2.children)));
|
|
280
|
+
return {
|
|
281
|
+
kind: "router",
|
|
282
|
+
...first.meta === void 0 ? {} : { meta: first.meta },
|
|
283
|
+
children: Object.fromEntries(
|
|
284
|
+
[...keys].map((key) => {
|
|
285
|
+
const children = /* @__PURE__ */ new Map();
|
|
286
|
+
for (const [accountId, router2] of routers) {
|
|
287
|
+
const child = Object.hasOwn(router2.children, key) ? router2.children[key] : void 0;
|
|
288
|
+
if (child !== void 0) children.set(accountId, child);
|
|
289
|
+
}
|
|
290
|
+
return [key, combineNode(children)];
|
|
291
|
+
})
|
|
292
|
+
)
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
var narrow = (variants, is) => {
|
|
298
|
+
const narrowed = /* @__PURE__ */ new Map();
|
|
299
|
+
for (const [accountId, node] of variants) {
|
|
300
|
+
if (!is(node)) throw new Error("Each account's router must have the same shape");
|
|
301
|
+
narrowed.set(accountId, node);
|
|
302
|
+
}
|
|
303
|
+
return narrowed;
|
|
304
|
+
};
|
|
305
|
+
var accountRouter = (accounts, discover, options) => Effect_exports.runPromise(
|
|
165
306
|
Effect_exports.gen(function* () {
|
|
166
|
-
const
|
|
167
|
-
const mutations = /* @__PURE__ */ new Map();
|
|
307
|
+
const routers = /* @__PURE__ */ new Map();
|
|
168
308
|
for (const account of accounts) {
|
|
169
|
-
const
|
|
309
|
+
const declaration2 = yield* Effect_exports.tryPromise({
|
|
170
310
|
try: () => discover(account),
|
|
171
|
-
catch: (error) => error
|
|
311
|
+
catch: (error) => accountProviderError(error, account.id)
|
|
172
312
|
});
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const operation = nativeOperation(declaration2);
|
|
179
|
-
if (operation === void 0)
|
|
180
|
-
return yield* Effect_exports.die(new Error("Expected a protocol operation"));
|
|
181
|
-
const group = target.get(name) ?? /* @__PURE__ */ new Map();
|
|
182
|
-
if (group.has(account.id))
|
|
183
|
-
return yield* Effect_exports.die(new Error("Account selections must be unique"));
|
|
184
|
-
group.set(account.id, operation);
|
|
185
|
-
target.set(name, group);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
313
|
+
if (routers.has(account.id))
|
|
314
|
+
return yield* Effect_exports.die(new Error("Account selections must be unique"));
|
|
315
|
+
const router2 = nativeRouter(declaration2);
|
|
316
|
+
if (router2 === void 0) return yield* Effect_exports.die(new Error("Expected a protocol router"));
|
|
317
|
+
routers.set(account.id, router2);
|
|
188
318
|
}
|
|
189
|
-
return {
|
|
319
|
+
if (routers.size === 0) return routerDeclaration({ kind: "router", children: {} });
|
|
320
|
+
const combined = combineNode(routers);
|
|
321
|
+
if (combined.kind !== "router" && combined.kind !== "dynamic")
|
|
322
|
+
return yield* Effect_exports.die(new Error("Expected a protocol router"));
|
|
323
|
+
return routerDeclaration(combined);
|
|
190
324
|
}),
|
|
191
325
|
options
|
|
192
326
|
);
|
|
193
327
|
|
|
328
|
+
// src/implementation/dynamic-skills.ts
|
|
329
|
+
var dynamicSkills = (source) => ({
|
|
330
|
+
list: fromPromise(async () => source.list())
|
|
331
|
+
});
|
|
332
|
+
|
|
194
333
|
// src/contracts/app.ts
|
|
195
334
|
var NotImplemented = class extends Schema_exports.TaggedError()("NotImplemented", {
|
|
196
335
|
operation: Schema_exports.String
|
|
@@ -248,15 +387,17 @@ var decodeJson2 = (response, schema) => {
|
|
|
248
387
|
return Effect_exports.runPromise(decodeJson(native, decoderOf(schema)));
|
|
249
388
|
};
|
|
250
389
|
export {
|
|
390
|
+
CacheError,
|
|
251
391
|
ElicitationFailed,
|
|
252
392
|
NonRetryableError,
|
|
253
393
|
NotImplemented,
|
|
254
394
|
OAuth2AccessToken2 as OAuth2AccessToken,
|
|
395
|
+
ProviderError,
|
|
255
396
|
ResponseDecodeError,
|
|
256
397
|
ResponseStatusError,
|
|
257
398
|
ValidationError,
|
|
258
399
|
WorkflowFailure,
|
|
259
|
-
|
|
400
|
+
accountRouter,
|
|
260
401
|
array,
|
|
261
402
|
boolean,
|
|
262
403
|
cron,
|
|
@@ -264,6 +405,8 @@ export {
|
|
|
264
405
|
defineApp,
|
|
265
406
|
defineDatabase,
|
|
266
407
|
defineProvider,
|
|
408
|
+
dynamicRouter,
|
|
409
|
+
dynamicSkills,
|
|
267
410
|
id,
|
|
268
411
|
interval,
|
|
269
412
|
json,
|
|
@@ -275,6 +418,7 @@ export {
|
|
|
275
418
|
object,
|
|
276
419
|
query,
|
|
277
420
|
record,
|
|
421
|
+
router,
|
|
278
422
|
secrets2 as secrets,
|
|
279
423
|
string,
|
|
280
424
|
table,
|
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-EPT3ZP52.js";
|
|
5
|
+
import "../chunk-CRDWFA74.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-V5KNQVCT.js";
|
|
8
|
+
import "../chunk-NKLWZJLE.js";
|
|
9
|
+
import "../chunk-FL2QR3XW.js";
|
|
10
|
+
import "../chunk-IPI4MFSN.js";
|
|
11
|
+
import "../chunk-YXQHV65J.js";
|
|
12
|
+
import "../chunk-ZQINWV4W.js";
|
|
13
|
+
import "../chunk-Z5M2LQOZ.js";
|
|
14
|
+
import "../chunk-MKWZPDR6.js";
|
|
15
|
+
import "../chunk-WLE7WX2U.js";
|
|
16
|
+
import "../chunk-N7YDVXYJ.js";
|
|
17
|
+
import "../chunk-R3EV5FTO.js";
|
|
18
|
+
import "../chunk-JU7VHODU.js";
|
|
19
|
+
import "../chunk-ODEIDRGW.js";
|
|
20
|
+
import "../chunk-57RKNWL2.js";
|
|
21
|
+
import "../chunk-UK573G7W.js";
|
|
22
|
+
import "../chunk-5T57N25Q.js";
|
|
23
|
+
import "../chunk-PZB6T6KU.js";
|
|
24
|
+
import "../chunk-27F7W2LG.js";
|
|
25
|
+
import "../chunk-CDL5PM2Q.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-CRDWFA74.js";
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
} from "../chunk-
|
|
7
|
+
protocolRouter
|
|
8
|
+
} from "../chunk-72JNVHPK.js";
|
|
9
9
|
import "../chunk-BCSNKUAC.js";
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
13
|
-
import "../chunk-
|
|
10
|
+
import "../chunk-V5KNQVCT.js";
|
|
11
|
+
import "../chunk-NKLWZJLE.js";
|
|
12
|
+
import "../chunk-FL2QR3XW.js";
|
|
13
|
+
import "../chunk-IPI4MFSN.js";
|
|
14
|
+
import "../chunk-YXQHV65J.js";
|
|
15
|
+
import "../chunk-ZQINWV4W.js";
|
|
16
|
+
import "../chunk-Z5M2LQOZ.js";
|
|
17
|
+
import "../chunk-MKWZPDR6.js";
|
|
14
18
|
import {
|
|
15
19
|
McpError,
|
|
16
20
|
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-
|
|
21
|
+
} from "../chunk-WLE7WX2U.js";
|
|
22
|
+
import "../chunk-N7YDVXYJ.js";
|
|
23
|
+
import "../chunk-R3EV5FTO.js";
|
|
24
|
+
import "../chunk-JU7VHODU.js";
|
|
25
|
+
import "../chunk-ODEIDRGW.js";
|
|
26
|
+
import "../chunk-57RKNWL2.js";
|
|
27
|
+
import "../chunk-UK573G7W.js";
|
|
28
|
+
import "../chunk-5T57N25Q.js";
|
|
29
|
+
import "../chunk-PZB6T6KU.js";
|
|
30
|
+
import "../chunk-27F7W2LG.js";
|
|
26
31
|
import {
|
|
27
32
|
Effect_exports,
|
|
28
33
|
Schema_exports
|
|
29
|
-
} from "../chunk-
|
|
30
|
-
import "../chunk-
|
|
34
|
+
} from "../chunk-CDL5PM2Q.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";
|
|
@@ -113,11 +118,11 @@ var stdioToolsEffect = (input) => Effect_exports.gen(function* () {
|
|
|
113
118
|
});
|
|
114
119
|
|
|
115
120
|
// src/mcp-stdio.ts
|
|
116
|
-
var
|
|
117
|
-
stdioToolsEffect(config).pipe(Effect_exports.map((tools) =>
|
|
121
|
+
var stdioRouter = (config, signal, kinds = {}) => Effect_exports.runPromise(
|
|
122
|
+
stdioToolsEffect(config).pipe(Effect_exports.map((tools) => protocolRouter(tools, kinds))),
|
|
118
123
|
signal === void 0 ? {} : { signal }
|
|
119
124
|
);
|
|
120
125
|
export {
|
|
121
126
|
McpError,
|
|
122
|
-
|
|
127
|
+
stdioRouter
|
|
123
128
|
};
|