apps 0.0.1-beta.2 → 0.0.1-beta.21
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 +68 -44
- package/framework-reference.json +1 -1
- package/js/{chunk-SATWJKN6.js → chunk-27F7W2LG.js} +1 -1
- package/js/{chunk-WFSQXYUT.js → chunk-4QQ62BVS.js} +37 -3
- package/js/{chunk-HDJH3RPR.js → chunk-57RKNWL2.js} +2 -2
- package/js/chunk-625MBYU4.js +524 -0
- package/js/{chunk-RN2MXB4R.js → chunk-BLI53LPN.js} +28 -9
- package/js/{chunk-FW5HBOIK.js → chunk-CDL5PM2Q.js} +307 -169
- package/js/{chunk-J7O55ZV7.js → chunk-CHAK4P5C.js} +317 -176
- package/js/{chunk-HDTGZWP2.js → chunk-CMRKLZZY.js} +8 -8
- package/js/{chunk-OHRT55C4.js → chunk-IJX4CYZO.js} +3 -6
- package/js/{chunk-FDNTX5QJ.js → chunk-IPI4MFSN.js} +2 -2
- package/js/{chunk-YEJOQEII.js → chunk-JU7VHODU.js} +1 -1
- package/js/chunk-KUMBKVJD.js +39 -0
- package/js/{chunk-EVJUVWN2.js → chunk-M3B3DE4K.js} +2 -2
- package/js/{chunk-ZJWDMTE3.js → chunk-MKWZPDR6.js} +3 -3
- package/js/{chunk-BMOIAIVR.js → chunk-N7YDVXYJ.js} +49 -1
- package/js/{chunk-D47C7KG5.js → chunk-NKLWZJLE.js} +2 -2
- package/js/chunk-NMKHTJOQ.js +254 -0
- package/js/chunk-OD3KFKZD.js +1617 -0
- package/js/{chunk-ZCAMUXSG.js → chunk-ODEIDRGW.js} +3 -4
- package/js/{chunk-5MQZEB6Y.js → chunk-OZ4UK3CD.js} +37 -12
- package/js/{chunk-M6ZRRIBI.js → chunk-PJJ24GU7.js} +1 -1
- package/js/{chunk-FZJOYIZO.js → chunk-PZB6T6KU.js} +1 -1
- package/js/{chunk-LGIYBDWA.js → chunk-R3EV5FTO.js} +13 -1
- package/js/{chunk-Z5NMEGJN.js → chunk-RAAPJMVZ.js} +21 -9
- package/js/{chunk-QKHR7BMF.js → chunk-UK573G7W.js} +1 -1
- package/js/{chunk-4LPG6RCH.js → chunk-VFZKSM3T.js} +5 -25
- package/js/{chunk-MYYEW3RA.js → chunk-VXWY44LE.js} +780 -55
- package/js/{chunk-JN55AYQH.js → chunk-XNCYIB4D.js} +61 -32
- package/js/{chunk-PLCMJREA.js → chunk-ZQINWV4W.js} +60 -20
- package/js/client.js +10 -26
- package/js/contracts.js +74 -16
- package/js/effect.js +19 -20
- package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
- package/js/graphql.js +47 -49
- package/js/host.js +19 -20
- package/js/index.js +232 -201
- package/js/mcp/effect.js +21 -22
- package/js/mcp/stdio.js +25 -26
- package/js/mcp.js +74 -56
- package/js/openapi.js +3428 -1276
- package/js/react.js +3 -3
- package/js/skills/effect.js +3 -3
- package/js/skills.js +12 -13
- package/js/storage/facet.js +4 -4
- package/js/ui/auth/contracts.js +8 -9
- package/js/ui/auth.js +16 -14
- package/js/ui/contracts.js +4 -4
- package/js/ui/serving.js +71 -218
- package/package.json +1 -1
- package/runtime.json +1 -1
- package/types/app-data/src/contracts/database.d.ts +33 -6
- package/types/app-data/src/implementation/schema.d.ts +2 -17
- package/types/apps/src/contracts/app.d.ts +7 -6
- package/types/apps/src/contracts/failure.d.ts +25 -0
- package/types/apps/src/contracts/host.d.ts +31 -10
- package/types/apps/src/contracts/mcp.d.ts +16 -0
- package/types/apps/src/contracts/openapi.d.ts +5 -1
- package/types/apps/src/contracts/operations.d.ts +0 -5
- package/types/apps/src/contracts/protocol-version.d.ts +2 -2
- package/types/apps/src/contracts/protocols/1.d.ts +235 -67
- package/types/apps/src/contracts/protocols/2.d.ts +710 -0
- package/types/apps/src/contracts/protocols/3.d.ts +718 -0
- package/types/apps/src/contracts/protocols/4.d.ts +1299 -0
- package/types/apps/src/contracts/protocols/5.d.ts +1174 -0
- package/types/apps/src/contracts/protocols/6.d.ts +1620 -0
- package/types/apps/src/contracts/protocols/7.d.ts +1784 -0
- package/types/apps/src/contracts/protocols/oauth.d.ts +89 -0
- package/types/apps/src/contracts/provider.d.ts +109 -10
- package/types/apps/src/contracts/router.d.ts +59 -0
- package/types/apps/src/contracts/storage.d.ts +3 -3
- package/types/apps/src/contracts/ui-auth.d.ts +6 -14
- package/types/apps/src/contracts/ui.d.ts +18 -0
- package/types/apps/src/contracts/workflows.d.ts +34 -3
- package/types/apps/src/graphql.d.ts +1 -3
- package/types/apps/src/implementation/account-router.d.ts +12 -0
- package/types/apps/src/implementation/app.d.ts +5 -4
- package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
- package/types/apps/src/implementation/catalog-cache.d.ts +34 -4
- package/types/apps/src/implementation/elicitation.d.ts +2 -2
- package/types/apps/src/implementation/failure-detail.d.ts +26 -0
- package/types/apps/src/implementation/graphql-catalog.d.ts +4 -7
- package/types/apps/src/implementation/mcp-catalog.d.ts +7 -8
- package/types/apps/src/implementation/mcp-client.d.ts +35 -19
- package/types/apps/src/implementation/mcp.d.ts +35 -19
- package/types/apps/src/implementation/openapi-compile.d.ts +9 -5
- package/types/apps/src/implementation/openapi-document.d.ts +15 -2
- package/types/apps/src/implementation/openapi-request.d.ts +8 -1
- package/types/apps/src/implementation/openapi-source.d.ts +2 -6
- package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
- package/types/apps/src/implementation/operations.d.ts +36 -3
- package/types/apps/src/implementation/protocol-operations.d.ts +3 -4
- package/types/apps/src/implementation/provider.d.ts +19 -5
- package/types/apps/src/implementation/router-catalog.d.ts +225 -0
- package/types/apps/src/implementation/router.d.ts +68 -0
- package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
- package/types/apps/src/implementation/schema.d.ts +44 -1
- package/types/apps/src/implementation/storage.d.ts +5 -3
- package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
- package/types/apps/src/implementation/ui-auth.d.ts +11 -5
- package/types/apps/src/implementation/ui-errors.d.ts +1 -1
- package/types/apps/src/implementation/ui-serving.d.ts +10 -4
- package/types/apps/src/implementation/ui-watch.d.ts +1 -1
- 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 +28 -11
- package/types/apps/src/mcp-stdio.d.ts +2 -5
- package/types/apps/src/mcp.d.ts +5 -4
- package/types/apps/src/openapi.d.ts +6 -6
- package/types/apps/src/ui-auth.d.ts +2 -2
- package/types/telemetry/src/browser-operations.d.ts +5 -2
- package/js/chunk-PYUYJRSK.js +0 -93
- package/js/chunk-SWPD52J7.js +0 -35
- package/js/chunk-TE4KO4HI.js +0 -47
- package/js/chunk-W7D7WVSY.js +0 -18
- package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
- package/types/apps/src/implementation/account-operations.d.ts +0 -151
- package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
package/js/index.js
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
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-XNCYIB4D.js";
|
|
9
|
+
import "./chunk-ZQINWV4W.js";
|
|
8
10
|
import {
|
|
11
|
+
dynamicRouter,
|
|
9
12
|
fromPromise,
|
|
10
13
|
mutation,
|
|
11
14
|
nativeOperation,
|
|
15
|
+
nativeRouter,
|
|
12
16
|
operationDeclaration,
|
|
13
17
|
query,
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
router,
|
|
19
|
+
routerDeclaration,
|
|
20
|
+
toolAnnotations,
|
|
21
|
+
withApproval,
|
|
22
|
+
withApprovals
|
|
23
|
+
} from "./chunk-NMKHTJOQ.js";
|
|
16
24
|
import {
|
|
17
25
|
accountProviderError
|
|
18
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-MKWZPDR6.js";
|
|
19
27
|
import {
|
|
20
28
|
CalendarSchedule,
|
|
21
29
|
ElicitationFailed,
|
|
@@ -30,22 +38,21 @@ import {
|
|
|
30
38
|
ScheduleTiming,
|
|
31
39
|
SecretsMethod,
|
|
32
40
|
WorkflowFailure
|
|
33
|
-
} from "./chunk-
|
|
34
|
-
import "./chunk-
|
|
35
|
-
import {
|
|
36
|
-
CacheError
|
|
37
|
-
} from "./chunk-LGIYBDWA.js";
|
|
38
|
-
import "./chunk-YEJOQEII.js";
|
|
39
|
-
import "./chunk-SWPD52J7.js";
|
|
41
|
+
} from "./chunk-VXWY44LE.js";
|
|
42
|
+
import "./chunk-N7YDVXYJ.js";
|
|
40
43
|
import {
|
|
44
|
+
CacheError,
|
|
41
45
|
ProviderError
|
|
42
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-R3EV5FTO.js";
|
|
47
|
+
import "./chunk-JU7VHODU.js";
|
|
43
48
|
import {
|
|
44
49
|
array,
|
|
45
50
|
boolean,
|
|
46
51
|
decoderOf,
|
|
52
|
+
fieldExposure,
|
|
47
53
|
id,
|
|
48
54
|
importedJsonSchema,
|
|
55
|
+
isSchema,
|
|
49
56
|
json,
|
|
50
57
|
jsonSchema,
|
|
51
58
|
literal,
|
|
@@ -54,42 +61,26 @@ import {
|
|
|
54
61
|
object,
|
|
55
62
|
once,
|
|
56
63
|
parse,
|
|
64
|
+
plain,
|
|
65
|
+
raw,
|
|
57
66
|
record,
|
|
58
67
|
string,
|
|
59
68
|
userId,
|
|
60
69
|
withLazyJsonSchemaDocument,
|
|
61
70
|
wrap
|
|
62
|
-
} from "./chunk-
|
|
63
|
-
import "./chunk-
|
|
71
|
+
} from "./chunk-4QQ62BVS.js";
|
|
72
|
+
import "./chunk-PZB6T6KU.js";
|
|
64
73
|
import {
|
|
65
74
|
JsonObject,
|
|
66
75
|
JsonValue,
|
|
67
76
|
ValidationError
|
|
68
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-27F7W2LG.js";
|
|
69
78
|
import {
|
|
70
79
|
Effect_exports,
|
|
71
80
|
Schema_exports
|
|
72
|
-
} from "./chunk-
|
|
81
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
73
82
|
import "./chunk-CZ7CSFO4.js";
|
|
74
83
|
|
|
75
|
-
// src/contracts/http.ts
|
|
76
|
-
var ResponseStatusError = class extends Schema_exports.TaggedError()(
|
|
77
|
-
"ResponseStatusError",
|
|
78
|
-
{ status: Schema_exports.Number }
|
|
79
|
-
) {
|
|
80
|
-
get message() {
|
|
81
|
-
return `Request failed with status ${this.status}`;
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
var ResponseDecodeError = class extends Schema_exports.TaggedError()(
|
|
85
|
-
"ResponseDecodeError",
|
|
86
|
-
{}
|
|
87
|
-
) {
|
|
88
|
-
get message() {
|
|
89
|
-
return "Response body did not match the expected schema";
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
84
|
// src/implementation/http.ts
|
|
94
85
|
var decodeJson = (response, schema) => Effect_exports.gen(function* () {
|
|
95
86
|
if (response.status < 200 || response.status >= 300) {
|
|
@@ -101,10 +92,21 @@ var decodeJson = (response, schema) => Effect_exports.gen(function* () {
|
|
|
101
92
|
|
|
102
93
|
// src/implementation/provider.ts
|
|
103
94
|
var secrets = (options) => new SecretsMethod(options);
|
|
104
|
-
var oauth2 = (config, response) => parse(OAuth2Config, config).pipe(
|
|
105
|
-
|
|
95
|
+
var oauth2 = (config, response, exposure) => parse(OAuth2Config, config).pipe(
|
|
96
|
+
Effect_exports.map(
|
|
97
|
+
(config2) => new OAuth2Method({ config: config2, response, ...exposure === void 0 ? {} : { exposure } })
|
|
98
|
+
)
|
|
99
|
+
);
|
|
100
|
+
var defineProvider = ({
|
|
101
|
+
health,
|
|
102
|
+
...options
|
|
103
|
+
}) => {
|
|
104
|
+
if (health === void 0) return new Provider(options);
|
|
105
|
+
const run = fromPromise(health);
|
|
106
|
+
return new Provider({ ...options, health: { run } });
|
|
107
|
+
};
|
|
106
108
|
|
|
107
|
-
// src/implementation/account-
|
|
109
|
+
// src/implementation/account-router.ts
|
|
108
110
|
var inputDocument = (operation) => {
|
|
109
111
|
const imported = importedJsonSchema(operation.input);
|
|
110
112
|
if (imported !== void 0) return Schema_exports.decodeUnknownSync(JsonObject)(imported);
|
|
@@ -115,72 +117,70 @@ var declaresOutput = (operation) => {
|
|
|
115
117
|
const property = Object.getOwnPropertyDescriptor(operation, "outputSchema");
|
|
116
118
|
return property !== void 0 && (property.get !== void 0 || property.value !== void 0);
|
|
117
119
|
};
|
|
118
|
-
var
|
|
119
|
-
[...
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
[
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
120
|
+
var combineOperation = (accounts) => {
|
|
121
|
+
const variants = [...accounts.values()];
|
|
122
|
+
const first = variants[0];
|
|
123
|
+
if (first === void 0) throw new Error("An account operation must have at least one account");
|
|
124
|
+
const kind = variants.every((operation) => operation.kind === "query") ? "query" : "mutation";
|
|
125
|
+
const select = (input2) => {
|
|
126
|
+
const operation = accounts.get(input2.accountId);
|
|
127
|
+
if (operation === void 0)
|
|
128
|
+
throw new Error("Account selection must be decoded before execution");
|
|
129
|
+
return operation;
|
|
130
|
+
};
|
|
131
|
+
const input = Schema_exports.Union(
|
|
132
|
+
[...accounts].map(
|
|
133
|
+
([accountId, operation]) => Schema_exports.Struct({ accountId: Schema_exports.Literal(accountId), input: operation.input })
|
|
134
|
+
)
|
|
135
|
+
);
|
|
136
|
+
const inputSchema = () => ({
|
|
137
|
+
type: "object",
|
|
138
|
+
anyOf: [...accounts].map(([accountId, operation], index) => ({
|
|
136
139
|
type: "object",
|
|
137
|
-
|
|
138
|
-
type: "
|
|
139
|
-
|
|
140
|
-
accountId: { type: "string", const: accountId },
|
|
141
|
-
input: nestJsonSchema(inputDocument(operation), `#/anyOf/${index}/properties/input`)
|
|
142
|
-
},
|
|
143
|
-
required: ["accountId", "input"]
|
|
144
|
-
}))
|
|
145
|
-
});
|
|
146
|
-
const declaration2 = operationDeclaration({
|
|
147
|
-
kind,
|
|
148
|
-
...first.description === void 0 ? {} : { description: first.description },
|
|
149
|
-
...first.title === void 0 ? {} : { title: first.title },
|
|
150
|
-
...first.annotations === void 0 || !variants.every(
|
|
151
|
-
(operation) => JSON.stringify(operation.annotations) === JSON.stringify(first.annotations)
|
|
152
|
-
) ? {} : { annotations: first.annotations },
|
|
153
|
-
...first._meta === void 0 || !variants.every(
|
|
154
|
-
(operation) => JSON.stringify(operation._meta) === JSON.stringify(first._meta)
|
|
155
|
-
) ? {} : { _meta: first._meta },
|
|
156
|
-
input: withLazyJsonSchemaDocument(input, inputSchema),
|
|
157
|
-
approval: (context) => {
|
|
158
|
-
const operation = select(context.toolInput);
|
|
159
|
-
return operation.approval === void 0 ? Effect_exports.succeed("approved") : operation.approval({ ...context, toolInput: context.toolInput.input });
|
|
140
|
+
properties: {
|
|
141
|
+
accountId: { type: "string", const: accountId },
|
|
142
|
+
input: nestJsonSchema(inputDocument(operation), `#/anyOf/${index}/properties/input`)
|
|
160
143
|
},
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
144
|
+
required: ["accountId", "input"]
|
|
145
|
+
}))
|
|
146
|
+
});
|
|
147
|
+
const declaration2 = operationDeclaration({
|
|
148
|
+
kind,
|
|
149
|
+
...first.description === void 0 ? {} : { description: first.description },
|
|
150
|
+
...first.title === void 0 ? {} : { title: first.title },
|
|
151
|
+
...first.annotations === void 0 || !variants.every(
|
|
152
|
+
(operation) => JSON.stringify(operation.annotations) === JSON.stringify(first.annotations)
|
|
153
|
+
) ? {} : { annotations: first.annotations },
|
|
154
|
+
...first._meta === void 0 || !variants.every((operation) => JSON.stringify(operation._meta) === JSON.stringify(first._meta)) ? {} : { _meta: first._meta },
|
|
155
|
+
input: withLazyJsonSchemaDocument(input, inputSchema),
|
|
156
|
+
approval: (context) => {
|
|
157
|
+
const operation = select(context.toolInput);
|
|
158
|
+
return operation.approval === void 0 ? Effect_exports.succeed("approved") : operation.approval({ ...context, toolInput: context.toolInput.input });
|
|
159
|
+
},
|
|
160
|
+
run: (context, input2) => {
|
|
161
|
+
const operation = select(input2);
|
|
162
|
+
return operation.run(context, input2.input).pipe(
|
|
163
|
+
Effect_exports.mapError((error) => accountProviderError(error, input2.accountId)),
|
|
164
|
+
Effect_exports.flatMap(
|
|
165
|
+
(output) => operation.output === void 0 ? Effect_exports.succeed(output) : Schema_exports.decodeUnknownEffect(operation.output)(output)
|
|
166
|
+
)
|
|
167
|
+
);
|
|
180
168
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
)
|
|
169
|
+
});
|
|
170
|
+
if (variants.every(declaresOutput)) {
|
|
171
|
+
const outputSchema = once(() => ({
|
|
172
|
+
anyOf: variants.flatMap(
|
|
173
|
+
(operation) => operation.outputSchema === void 0 ? [] : [operation.outputSchema]
|
|
174
|
+
).map((output, index) => nestJsonSchema(output, `#/anyOf/${index}`))
|
|
175
|
+
}));
|
|
176
|
+
const native2 = nativeOperation(declaration2);
|
|
177
|
+
if (native2 !== void 0)
|
|
178
|
+
Object.defineProperty(native2, "outputSchema", { enumerable: true, get: outputSchema });
|
|
179
|
+
}
|
|
180
|
+
const native = nativeOperation(declaration2);
|
|
181
|
+
if (native === void 0) throw new Error("Expected a combined operation");
|
|
182
|
+
return native;
|
|
183
|
+
};
|
|
184
184
|
var sameAcross = (key, variants) => {
|
|
185
185
|
const first = variants[0]?.[1][key];
|
|
186
186
|
return first !== void 0 && variants.every(([, tool]) => JSON.stringify(tool[key]) === JSON.stringify(first)) ? { [key]: first } : {};
|
|
@@ -192,7 +192,7 @@ var mergeSummary = (name, variants) => {
|
|
|
192
192
|
name,
|
|
193
193
|
description: first.description,
|
|
194
194
|
...first.title === void 0 ? {} : { title: first.title },
|
|
195
|
-
readOnly:
|
|
195
|
+
readOnly: variants.every(([, tool]) => tool.readOnly === true),
|
|
196
196
|
...sameAcross("annotations", variants)
|
|
197
197
|
});
|
|
198
198
|
};
|
|
@@ -218,112 +218,123 @@ var merge = (name, variants) => Schema_exports.decodeUnknownSync(HostedTool)({
|
|
|
218
218
|
} : {},
|
|
219
219
|
...sameAcross("_meta", variants)
|
|
220
220
|
});
|
|
221
|
-
var
|
|
221
|
+
var combineDynamic = (sources) => {
|
|
222
|
+
const first = [...sources.values()][0];
|
|
223
|
+
const grouped = (read) => Effect_exports.gen(function* () {
|
|
224
|
+
const groups = /* @__PURE__ */ new Map();
|
|
225
|
+
for (const [accountId, source] of sources) {
|
|
226
|
+
const tools = yield* read(source).pipe(
|
|
227
|
+
Effect_exports.mapError((error) => accountProviderError(error, accountId))
|
|
228
|
+
);
|
|
229
|
+
for (const tool of tools) {
|
|
230
|
+
const variants = groups.get(tool.name) ?? [];
|
|
231
|
+
if (variants.some(([id2]) => id2 === accountId))
|
|
232
|
+
return yield* Effect_exports.die(new Error("Duplicate source operation"));
|
|
233
|
+
variants.push([accountId, tool]);
|
|
234
|
+
groups.set(tool.name, variants);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return groups;
|
|
238
|
+
});
|
|
239
|
+
return {
|
|
240
|
+
kind: "dynamic",
|
|
241
|
+
// Accounts share one source, so the first account describes the router.
|
|
242
|
+
...first?.meta === void 0 ? {} : { meta: first.meta },
|
|
243
|
+
...first?.overrides === void 0 ? {} : { overrides: first.overrides },
|
|
244
|
+
list: () => grouped((source) => source.list()).pipe(
|
|
245
|
+
Effect_exports.map((groups) => [...groups].map(([name, variants]) => merge(name, variants)))
|
|
246
|
+
),
|
|
247
|
+
summaries: () => grouped(
|
|
248
|
+
(source) => source.summaries === void 0 ? source.list() : source.summaries()
|
|
249
|
+
).pipe(
|
|
250
|
+
Effect_exports.map((groups) => [...groups].map(([name, variants]) => mergeSummary(name, variants)))
|
|
251
|
+
),
|
|
252
|
+
describe: (name) => Effect_exports.gen(function* () {
|
|
253
|
+
const variants = [];
|
|
254
|
+
for (const [accountId, source] of sources) {
|
|
255
|
+
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)));
|
|
256
|
+
if (tool !== void 0) variants.push([accountId, tool]);
|
|
257
|
+
}
|
|
258
|
+
return variants.length === 0 ? void 0 : merge(name, variants);
|
|
259
|
+
}),
|
|
260
|
+
resolve: (name) => Effect_exports.gen(function* () {
|
|
261
|
+
const operations = /* @__PURE__ */ new Map();
|
|
262
|
+
for (const [accountId, source] of sources) {
|
|
263
|
+
const operation = yield* source.resolve(name).pipe(Effect_exports.mapError((error) => accountProviderError(error, accountId)));
|
|
264
|
+
if (operation !== void 0) operations.set(accountId, operation);
|
|
265
|
+
}
|
|
266
|
+
return operations.size === 0 ? void 0 : combineOperation(operations);
|
|
267
|
+
})
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
var combineNode = (variants) => {
|
|
271
|
+
const nodes = [...variants.values()];
|
|
272
|
+
const first = nodes[0];
|
|
273
|
+
if (first === void 0) throw new Error("An account operation must have at least one account");
|
|
274
|
+
switch (first.kind) {
|
|
275
|
+
case "query":
|
|
276
|
+
case "mutation":
|
|
277
|
+
return combineOperation(
|
|
278
|
+
narrow(
|
|
279
|
+
variants,
|
|
280
|
+
(node) => node.kind === "query" || node.kind === "mutation"
|
|
281
|
+
)
|
|
282
|
+
);
|
|
283
|
+
case "dynamic":
|
|
284
|
+
return combineDynamic(
|
|
285
|
+
narrow(variants, (node) => node.kind === "dynamic")
|
|
286
|
+
);
|
|
287
|
+
case "router": {
|
|
288
|
+
const routers = narrow(variants, (node) => node.kind === "router");
|
|
289
|
+
const keys = new Set([...routers.values()].flatMap((router2) => Object.keys(router2.children)));
|
|
290
|
+
return {
|
|
291
|
+
kind: "router",
|
|
292
|
+
...first.meta === void 0 ? {} : { meta: first.meta },
|
|
293
|
+
children: Object.fromEntries(
|
|
294
|
+
[...keys].map((key) => {
|
|
295
|
+
const children = /* @__PURE__ */ new Map();
|
|
296
|
+
for (const [accountId, router2] of routers) {
|
|
297
|
+
const child = Object.hasOwn(router2.children, key) ? router2.children[key] : void 0;
|
|
298
|
+
if (child !== void 0) children.set(accountId, child);
|
|
299
|
+
}
|
|
300
|
+
return [key, combineNode(children)];
|
|
301
|
+
})
|
|
302
|
+
)
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
var narrow = (variants, is) => {
|
|
308
|
+
const narrowed = /* @__PURE__ */ new Map();
|
|
309
|
+
for (const [accountId, node] of variants) {
|
|
310
|
+
if (!is(node)) throw new Error("Each account's router must have the same shape");
|
|
311
|
+
narrowed.set(accountId, node);
|
|
312
|
+
}
|
|
313
|
+
return narrowed;
|
|
314
|
+
};
|
|
315
|
+
var accountRouter = (accounts, discover, options) => Effect_exports.runPromise(
|
|
222
316
|
Effect_exports.gen(function* () {
|
|
223
|
-
const
|
|
224
|
-
const mutations = /* @__PURE__ */ new Map();
|
|
225
|
-
const sources = /* @__PURE__ */ new Map();
|
|
317
|
+
const routers = /* @__PURE__ */ new Map();
|
|
226
318
|
for (const account of accounts) {
|
|
227
|
-
const
|
|
319
|
+
const declaration2 = yield* Effect_exports.tryPromise({
|
|
228
320
|
try: () => discover(account),
|
|
229
321
|
catch: (error) => accountProviderError(error, account.id)
|
|
230
322
|
});
|
|
231
|
-
if (
|
|
323
|
+
if (routers.has(account.id))
|
|
232
324
|
return yield* Effect_exports.die(new Error("Account selections must be unique"));
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
[operations.mutations, mutations]
|
|
237
|
-
]) {
|
|
238
|
-
for (const [name, declaration2] of Object.entries(source ?? {})) {
|
|
239
|
-
const operation = nativeOperation(declaration2);
|
|
240
|
-
if (operation === void 0)
|
|
241
|
-
return yield* Effect_exports.die(new Error("Expected a protocol operation"));
|
|
242
|
-
const group = target.get(name) ?? /* @__PURE__ */ new Map();
|
|
243
|
-
if (group.has(account.id))
|
|
244
|
-
return yield* Effect_exports.die(new Error("Account selections must be unique"));
|
|
245
|
-
group.set(account.id, operation);
|
|
246
|
-
target.set(name, group);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
325
|
+
const router2 = nativeRouter(declaration2);
|
|
326
|
+
if (router2 === void 0) return yield* Effect_exports.die(new Error("Expected a protocol router"));
|
|
327
|
+
routers.set(account.id, router2);
|
|
249
328
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
const grouped = (read) => Effect_exports.gen(function* () {
|
|
256
|
-
const groups = /* @__PURE__ */ new Map();
|
|
257
|
-
for (const [accountId, source] of sources) {
|
|
258
|
-
const tools = yield* read(source).pipe(
|
|
259
|
-
Effect_exports.mapError((error) => accountProviderError(error, accountId))
|
|
260
|
-
);
|
|
261
|
-
for (const tool of tools) {
|
|
262
|
-
const variants = groups.get(tool.name) ?? [];
|
|
263
|
-
if (variants.some(([id2]) => id2 === accountId))
|
|
264
|
-
return yield* Effect_exports.die(new Error("Duplicate source operation"));
|
|
265
|
-
variants.push([accountId, tool]);
|
|
266
|
-
groups.set(tool.name, variants);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
return groups;
|
|
270
|
-
});
|
|
271
|
-
return {
|
|
272
|
-
...declared,
|
|
273
|
-
dynamicTools: {
|
|
274
|
-
list: () => grouped((source) => source.list()).pipe(
|
|
275
|
-
Effect_exports.map((groups) => [...groups].map(([name, variants]) => merge(name, variants)))
|
|
276
|
-
),
|
|
277
|
-
summaries: () => grouped(
|
|
278
|
-
(source) => source.summaries === void 0 ? source.list() : source.summaries()
|
|
279
|
-
).pipe(
|
|
280
|
-
Effect_exports.map(
|
|
281
|
-
(groups) => [...groups].map(([name, variants]) => mergeSummary(name, variants))
|
|
282
|
-
)
|
|
283
|
-
),
|
|
284
|
-
describe: (name) => Effect_exports.gen(function* () {
|
|
285
|
-
const variants = [];
|
|
286
|
-
for (const [accountId, source] of sources) {
|
|
287
|
-
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)));
|
|
288
|
-
if (tool !== void 0) variants.push([accountId, tool]);
|
|
289
|
-
}
|
|
290
|
-
return variants.length === 0 ? void 0 : merge(name, variants);
|
|
291
|
-
}),
|
|
292
|
-
resolve: (name) => Effect_exports.gen(function* () {
|
|
293
|
-
const kind = name.startsWith("queries.") ? "query" : "mutation";
|
|
294
|
-
const operations = /* @__PURE__ */ new Map();
|
|
295
|
-
for (const [accountId, source] of sources) {
|
|
296
|
-
const operation = yield* source.resolve(name).pipe(Effect_exports.mapError((error) => accountProviderError(error, accountId)));
|
|
297
|
-
if (operation !== void 0) {
|
|
298
|
-
if (operation.kind !== kind)
|
|
299
|
-
return yield* Effect_exports.die(new Error("Operation kind changed"));
|
|
300
|
-
operations.set(accountId, operation);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
if (operations.size === 0) return void 0;
|
|
304
|
-
return nativeOperation(combine(kind, /* @__PURE__ */ new Map([[name, operations]]))[name]);
|
|
305
|
-
})
|
|
306
|
-
}
|
|
307
|
-
};
|
|
329
|
+
if (routers.size === 0) return routerDeclaration({ kind: "router", children: {} });
|
|
330
|
+
const combined = combineNode(routers);
|
|
331
|
+
if (combined.kind !== "router" && combined.kind !== "dynamic")
|
|
332
|
+
return yield* Effect_exports.die(new Error("Expected a protocol router"));
|
|
333
|
+
return routerDeclaration(combined);
|
|
308
334
|
}),
|
|
309
335
|
options
|
|
310
336
|
);
|
|
311
337
|
|
|
312
|
-
// src/implementation/dynamic-tools.ts
|
|
313
|
-
var dynamicTools = (source) => ({
|
|
314
|
-
list: () => fromPromise(source.list)().pipe(
|
|
315
|
-
Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(Schema_exports.Array(HostedTool)))
|
|
316
|
-
),
|
|
317
|
-
resolve: (name) => fromPromise(source.resolve)(name).pipe(
|
|
318
|
-
Effect_exports.map((value) => {
|
|
319
|
-
if (value === void 0) return void 0;
|
|
320
|
-
const operation = nativeOperation(value);
|
|
321
|
-
if (operation === void 0) throw new Error("Expected an operation declaration");
|
|
322
|
-
return operation;
|
|
323
|
-
})
|
|
324
|
-
)
|
|
325
|
-
});
|
|
326
|
-
|
|
327
338
|
// src/implementation/dynamic-skills.ts
|
|
328
339
|
var dynamicSkills = (source) => ({
|
|
329
340
|
list: fromPromise(async () => source.list())
|
|
@@ -365,11 +376,26 @@ var cron = (calendar, operation, input) => declaration(
|
|
|
365
376
|
);
|
|
366
377
|
|
|
367
378
|
// src/index.ts
|
|
379
|
+
var isFields = (value) => typeof value === "object" && value !== null && Object.values(value).every(isSchema);
|
|
380
|
+
var accountDecoder = (schema) => (
|
|
381
|
+
// SAFETY: the brand exists only in types; secret values are strings at runtime.
|
|
382
|
+
decoderOf(schema)
|
|
383
|
+
);
|
|
384
|
+
var exposureOf = (schema) => {
|
|
385
|
+
const marked = "fields" in schema && isFields(schema.fields) ? fieldExposure(schema.fields) : {};
|
|
386
|
+
return Object.keys(marked).length === 0 ? {} : { exposure: marked };
|
|
387
|
+
};
|
|
368
388
|
var OAuth2AccessToken2 = wrap(OAuth2AccessToken, false);
|
|
369
|
-
var secrets2 = (options) => secrets({
|
|
389
|
+
var secrets2 = (options) => secrets({
|
|
390
|
+
label: options.label,
|
|
391
|
+
fields: accountDecoder(options.fields),
|
|
392
|
+
...exposureOf(options.fields)
|
|
393
|
+
});
|
|
370
394
|
function oauth22(options) {
|
|
371
395
|
const { response = OAuth2AccessToken2, ...config } = options;
|
|
372
|
-
return Effect_exports.runSync(
|
|
396
|
+
return Effect_exports.runSync(
|
|
397
|
+
oauth2(config, accountDecoder(response), exposureOf(response).exposure)
|
|
398
|
+
);
|
|
373
399
|
}
|
|
374
400
|
var decodeJson2 = (response, schema) => {
|
|
375
401
|
const native = {
|
|
@@ -396,7 +422,7 @@ export {
|
|
|
396
422
|
ResponseStatusError,
|
|
397
423
|
ValidationError,
|
|
398
424
|
WorkflowFailure,
|
|
399
|
-
|
|
425
|
+
accountRouter,
|
|
400
426
|
array,
|
|
401
427
|
boolean,
|
|
402
428
|
cron,
|
|
@@ -404,8 +430,8 @@ export {
|
|
|
404
430
|
defineApp,
|
|
405
431
|
defineDatabase,
|
|
406
432
|
defineProvider,
|
|
433
|
+
dynamicRouter,
|
|
407
434
|
dynamicSkills,
|
|
408
|
-
dynamicTools,
|
|
409
435
|
id,
|
|
410
436
|
interval,
|
|
411
437
|
json,
|
|
@@ -415,12 +441,17 @@ export {
|
|
|
415
441
|
number,
|
|
416
442
|
oauth22 as oauth2,
|
|
417
443
|
object,
|
|
444
|
+
plain,
|
|
418
445
|
query,
|
|
446
|
+
raw,
|
|
419
447
|
record,
|
|
448
|
+
router,
|
|
420
449
|
secrets2 as secrets,
|
|
421
450
|
string,
|
|
422
451
|
table,
|
|
452
|
+
toolAnnotations,
|
|
423
453
|
userId,
|
|
424
454
|
withApproval,
|
|
455
|
+
withApprovals,
|
|
425
456
|
workflow
|
|
426
457
|
};
|
package/js/mcp/effect.js
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mcpClientEffect,
|
|
3
3
|
mcpToolsEffect
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-CMRKLZZY.js";
|
|
5
|
+
import "../chunk-BLI53LPN.js";
|
|
6
6
|
import "../chunk-BCSNKUAC.js";
|
|
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-
|
|
21
|
-
import "../chunk-
|
|
22
|
-
import "../chunk-
|
|
23
|
-
import "../chunk-
|
|
24
|
-
import "../chunk-
|
|
25
|
-
import "../chunk-
|
|
26
|
-
import "../chunk-FW5HBOIK.js";
|
|
7
|
+
import "../chunk-CHAK4P5C.js";
|
|
8
|
+
import "../chunk-NKLWZJLE.js";
|
|
9
|
+
import "../chunk-625MBYU4.js";
|
|
10
|
+
import "../chunk-IPI4MFSN.js";
|
|
11
|
+
import "../chunk-XNCYIB4D.js";
|
|
12
|
+
import "../chunk-ZQINWV4W.js";
|
|
13
|
+
import "../chunk-NMKHTJOQ.js";
|
|
14
|
+
import "../chunk-MKWZPDR6.js";
|
|
15
|
+
import "../chunk-VXWY44LE.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-4QQ62BVS.js";
|
|
23
|
+
import "../chunk-PZB6T6KU.js";
|
|
24
|
+
import "../chunk-27F7W2LG.js";
|
|
25
|
+
import "../chunk-CDL5PM2Q.js";
|
|
27
26
|
import "../chunk-CZ7CSFO4.js";
|
|
28
27
|
export {
|
|
29
28
|
mcpClientEffect,
|