apps 0.0.1-beta.4 → 0.0.1-beta.41
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-QKHR7BMF.js → chunk-3MMG2H6M.js} +89 -53
- package/js/{chunk-EQB7JMAL.js → chunk-6XGB4BAL.js} +146 -31
- package/js/chunk-ADD6H64X.js +729 -0
- package/js/{chunk-6VRYO2BG.js → chunk-AHGGO2VY.js} +837 -254
- package/js/{chunk-FDNTX5QJ.js → chunk-CQD3WSYH.js} +2 -2
- package/js/{chunk-EVJUVWN2.js → chunk-DKUEYTYD.js} +463 -218
- package/js/chunk-EM4UL26F.js +118 -0
- package/js/{chunk-2VPJHFOU.js → chunk-FXWRE655.js} +128 -24
- package/js/{chunk-5MQZEB6Y.js → chunk-JI3EP2GL.js} +40 -12
- package/js/chunk-JJSLEJ6T.js +156 -0
- package/js/chunk-KAQD3DTI.js +16 -0
- package/js/chunk-KIM5HXNK.js +49 -0
- package/js/chunk-MJZYV7IO.js +255 -0
- package/js/{chunk-FW5HBOIK.js → chunk-MXDKXAY4.js} +19117 -18309
- package/js/{chunk-T2LAZCAD.js → chunk-NKWWPJYX.js} +3 -3
- package/js/chunk-OD3KFKZD.js +1617 -0
- package/js/{chunk-3M2MEDNL.js → chunk-OTCLXFLL.js} +1337 -188
- package/js/chunk-P7MGDPFD.js +240 -0
- package/js/{chunk-ZCAMUXSG.js → chunk-PNVCCB4L.js} +432 -79
- package/js/{chunk-D47C7KG5.js → chunk-RIXVGVA6.js} +2 -2
- package/js/{chunk-NQ3OMCA5.js → chunk-TT6OU4UG.js} +2 -2
- package/js/{chunk-YEJOQEII.js → chunk-UOZMSUJ2.js} +61 -9
- package/js/chunk-UTJIGUSS.js +42 -0
- package/js/{chunk-G7ZIRKMK.js → chunk-VIU2XXA7.js} +228 -264
- package/js/{chunk-HDJH3RPR.js → chunk-VJQXXOQ3.js} +4 -4
- package/js/{chunk-WFSQXYUT.js → chunk-WPBR4AWB.js} +523 -63
- package/js/{chunk-SATWJKN6.js → chunk-YQ35E7KS.js} +2 -2
- package/js/chunk-ZUKBIHMK.js +92 -0
- package/js/client.js +122 -88
- package/js/contracts.js +116 -25
- package/js/effect.js +19 -20
- package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
- package/js/graphql.js +57 -55
- package/js/host.js +19 -20
- package/js/index.js +245 -212
- package/js/mcp/effect.js +23 -22
- package/js/mcp/stdio.js +34 -30
- package/js/mcp.js +104 -68
- package/js/openapi.js +4087 -1503
- package/js/react.js +2 -3
- package/js/skills/effect.js +6 -3
- package/js/skills.js +147 -65
- package/js/storage/facet.js +1 -540
- package/js/ui/auth/contracts.js +2 -2
- package/js/ui/auth.js +5 -5
- package/js/ui/contracts.js +5 -4
- package/js/ui/serving.js +8517 -214
- package/package.json +2 -3
- package/runtime.json +1 -1
- 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 +7 -8
- package/types/apps/src/contracts/cache.d.ts +14 -0
- package/types/apps/src/contracts/context.d.ts +12 -11
- package/types/apps/src/contracts/elicitation.d.ts +6 -6
- 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 +44 -17
- package/types/apps/src/contracts/live.d.ts +2 -0
- package/types/apps/src/contracts/mcp.d.ts +96 -10
- package/types/apps/src/contracts/network.d.ts +84 -0
- package/types/apps/src/contracts/openapi-compile.d.ts +32 -3
- package/types/apps/src/contracts/openapi.d.ts +45 -9
- package/types/apps/src/contracts/operations.d.ts +8 -9
- package/types/apps/src/contracts/protocol-version.d.ts +2 -2
- package/types/apps/src/contracts/protocols/1.d.ts +263 -74
- package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
- package/types/apps/src/contracts/protocols/2.d.ts +66 -24
- package/types/apps/src/contracts/protocols/3.d.ts +715 -0
- package/types/apps/src/contracts/protocols/4.d.ts +1297 -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/8.d.ts +1130 -0
- package/types/apps/src/contracts/protocols/9.d.ts +1106 -0
- package/types/apps/src/contracts/protocols/oauth.d.ts +89 -0
- package/types/apps/src/contracts/provider-error.d.ts +9 -0
- package/types/apps/src/contracts/provider.d.ts +115 -10
- package/types/apps/src/contracts/router.d.ts +59 -0
- package/types/apps/src/contracts/skills.d.ts +39 -9
- package/types/apps/src/contracts/sql.d.ts +58 -0
- package/types/apps/src/contracts/ui.d.ts +19 -1
- package/types/apps/src/contracts/workflows.d.ts +40 -3
- package/types/apps/src/facet.d.ts +4 -5
- 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 +32 -5
- package/types/apps/src/implementation/elicitation.d.ts +12 -12
- package/types/apps/src/implementation/failure-detail.d.ts +47 -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/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-stdio.d.ts +1 -1
- 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 +27 -6
- package/types/apps/src/implementation/openapi-document.d.ts +46 -19
- package/types/apps/src/implementation/openapi-names.d.ts +9 -4
- package/types/apps/src/implementation/openapi-request.d.ts +10 -2
- package/types/apps/src/implementation/openapi-source.d.ts +8 -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/optimistic.d.ts +1 -1
- 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 +19 -5
- package/types/apps/src/implementation/query-commit.d.ts +1 -1
- package/types/apps/src/implementation/router-catalog.d.ts +223 -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 +95 -11
- package/types/apps/src/implementation/skills.d.ts +18 -24
- package/types/apps/src/implementation/sql.d.ts +66 -0
- package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
- package/types/apps/src/implementation/ui-auth.d.ts +1 -1
- package/types/apps/src/implementation/ui-client.d.ts +2 -2
- 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 +11 -5
- 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 +1 -1
- package/types/apps/src/implementation/workflow-context.d.ts +11 -3
- package/types/apps/src/index.d.ts +30 -13
- package/types/apps/src/mcp-stdio.d.ts +2 -5
- package/types/apps/src/mcp.d.ts +25 -5
- package/types/apps/src/openapi.d.ts +6 -6
- package/types/apps/src/react.d.ts +1 -1
- package/types/apps/src/skills.d.ts +10 -8
- package/types/telemetry/src/app-records.d.ts +42 -0
- package/types/telemetry/src/browser-operations.d.ts +6 -3
- package/types/telemetry/src/browser.d.ts +2 -2
- package/types/telemetry/src/config.d.ts +2 -2
- package/types/telemetry/src/layer.d.ts +2 -2
- package/types/telemetry/src/recorded-failure.d.ts +20 -0
- package/types/telemetry/src/relay.d.ts +2 -2
- package/types/telemetry/src/transport.d.ts +8 -1
- package/types/utils/src/api-error.d.ts +53 -0
- package/types/utils/src/recorded-message.d.ts +15 -0
- package/js/chunk-BMOIAIVR.js +0 -138
- package/js/chunk-DHUDODG5.js +0 -213
- package/js/chunk-FZJOYIZO.js +0 -19
- package/js/chunk-LGIYBDWA.js +0 -85
- package/js/chunk-M6ZRRIBI.js +0 -877
- package/js/chunk-PLCMJREA.js +0 -590
- package/js/chunk-PYUYJRSK.js +0 -93
- package/js/chunk-SWPD52J7.js +0 -35
- package/js/chunk-W7D7WVSY.js +0 -18
- package/js/chunk-Z5NMEGJN.js +0 -29
- package/js/chunk-ZJWDMTE3.js +0 -63
- 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/storage.d.ts +0 -13
package/js/index.js
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ResponseDecodeError,
|
|
3
|
+
ResponseStatusError,
|
|
2
4
|
defineApp,
|
|
3
|
-
defineDatabase,
|
|
4
|
-
table,
|
|
5
5
|
workflow
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-PLCMJREA.js";
|
|
6
|
+
} from "./chunk-JJSLEJ6T.js";
|
|
8
7
|
import {
|
|
8
|
+
dynamicRouter,
|
|
9
9
|
fromPromise,
|
|
10
10
|
mutation,
|
|
11
11
|
nativeOperation,
|
|
12
|
+
nativeRouter,
|
|
12
13
|
operationDeclaration,
|
|
13
14
|
query,
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
router,
|
|
16
|
+
routerDeclaration,
|
|
17
|
+
toolAnnotations,
|
|
18
|
+
withApproval,
|
|
19
|
+
withApprovals
|
|
20
|
+
} from "./chunk-MJZYV7IO.js";
|
|
16
21
|
import {
|
|
17
22
|
accountProviderError
|
|
18
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-EM4UL26F.js";
|
|
19
24
|
import {
|
|
20
25
|
CalendarSchedule,
|
|
21
26
|
ElicitationFailed,
|
|
@@ -30,22 +35,21 @@ import {
|
|
|
30
35
|
ScheduleTiming,
|
|
31
36
|
SecretsMethod,
|
|
32
37
|
WorkflowFailure
|
|
33
|
-
} from "./chunk-
|
|
34
|
-
import "./chunk-BMOIAIVR.js";
|
|
35
|
-
import {
|
|
36
|
-
CacheError
|
|
37
|
-
} from "./chunk-LGIYBDWA.js";
|
|
38
|
-
import "./chunk-YEJOQEII.js";
|
|
39
|
-
import "./chunk-SWPD52J7.js";
|
|
38
|
+
} from "./chunk-OTCLXFLL.js";
|
|
40
39
|
import {
|
|
40
|
+
CacheError,
|
|
41
|
+
FetchOptionUnsupported,
|
|
42
|
+
NetworkRefused,
|
|
41
43
|
ProviderError
|
|
42
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-P7MGDPFD.js";
|
|
45
|
+
import "./chunk-UOZMSUJ2.js";
|
|
43
46
|
import {
|
|
44
47
|
array,
|
|
45
48
|
boolean,
|
|
46
49
|
decoderOf,
|
|
47
|
-
|
|
50
|
+
fieldExposure,
|
|
48
51
|
importedJsonSchema,
|
|
52
|
+
isSchema,
|
|
49
53
|
json,
|
|
50
54
|
jsonSchema,
|
|
51
55
|
literal,
|
|
@@ -54,42 +58,27 @@ import {
|
|
|
54
58
|
object,
|
|
55
59
|
once,
|
|
56
60
|
parse,
|
|
61
|
+
plain,
|
|
62
|
+
raw,
|
|
57
63
|
record,
|
|
58
64
|
string,
|
|
59
|
-
userId,
|
|
60
65
|
withLazyJsonSchemaDocument,
|
|
61
66
|
wrap
|
|
62
|
-
} from "./chunk-
|
|
63
|
-
import "./chunk-
|
|
67
|
+
} from "./chunk-WPBR4AWB.js";
|
|
68
|
+
import "./chunk-KAQD3DTI.js";
|
|
64
69
|
import {
|
|
65
70
|
JsonObject,
|
|
66
71
|
JsonValue,
|
|
67
72
|
ValidationError
|
|
68
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-YQ35E7KS.js";
|
|
74
|
+
import "./chunk-VIU2XXA7.js";
|
|
75
|
+
import "./chunk-3MMG2H6M.js";
|
|
69
76
|
import {
|
|
70
77
|
Effect_exports,
|
|
71
78
|
Schema_exports
|
|
72
|
-
} from "./chunk-
|
|
79
|
+
} from "./chunk-MXDKXAY4.js";
|
|
73
80
|
import "./chunk-CZ7CSFO4.js";
|
|
74
81
|
|
|
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
82
|
// src/implementation/http.ts
|
|
94
83
|
var decodeJson = (response, schema) => Effect_exports.gen(function* () {
|
|
95
84
|
if (response.status < 200 || response.status >= 300) {
|
|
@@ -101,86 +90,101 @@ var decodeJson = (response, schema) => Effect_exports.gen(function* () {
|
|
|
101
90
|
|
|
102
91
|
// src/implementation/provider.ts
|
|
103
92
|
var secrets = (options) => new SecretsMethod(options);
|
|
104
|
-
var oauth2 = (config, response) => parse(OAuth2Config, config).pipe(
|
|
105
|
-
|
|
93
|
+
var oauth2 = (config, response, exposure) => parse(OAuth2Config, config).pipe(
|
|
94
|
+
Effect_exports.map(
|
|
95
|
+
(config2) => new OAuth2Method({ config: config2, response, ...exposure === void 0 ? {} : { exposure } })
|
|
96
|
+
)
|
|
97
|
+
);
|
|
98
|
+
var defineProvider = ({
|
|
99
|
+
health,
|
|
100
|
+
...options
|
|
101
|
+
}) => {
|
|
102
|
+
if (health === void 0) return new Provider(options);
|
|
103
|
+
const run = fromPromise(health);
|
|
104
|
+
return new Provider({ ...options, health: { run } });
|
|
105
|
+
};
|
|
106
106
|
|
|
107
|
-
// src/implementation/account-
|
|
108
|
-
var
|
|
109
|
-
const imported = importedJsonSchema(
|
|
107
|
+
// src/implementation/account-router.ts
|
|
108
|
+
var decoderDocument = (decoder) => {
|
|
109
|
+
const imported = importedJsonSchema(decoder);
|
|
110
110
|
if (imported !== void 0) return Schema_exports.decodeUnknownSync(JsonObject)(imported);
|
|
111
|
-
const document = Schema_exports.toJsonSchemaDocument(
|
|
111
|
+
const document = Schema_exports.toJsonSchemaDocument(decoder);
|
|
112
112
|
return Schema_exports.decodeUnknownSync(JsonObject)({ ...document.schema, $defs: document.definitions });
|
|
113
113
|
};
|
|
114
114
|
var declaresOutput = (operation) => {
|
|
115
|
+
if (operation.output !== void 0) return true;
|
|
115
116
|
const property = Object.getOwnPropertyDescriptor(operation, "outputSchema");
|
|
116
117
|
return property !== void 0 && (property.get !== void 0 || property.value !== void 0);
|
|
117
118
|
};
|
|
118
|
-
var
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
119
|
+
var outputDocument = (operation) => operation.output === void 0 ? operation.outputSchema : decoderDocument(operation.output);
|
|
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
|
-
|
|
141
|
-
|
|
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(
|
|
143
|
+
decoderDocument(operation.input),
|
|
144
|
+
`#/anyOf/${index}/properties/input`
|
|
145
|
+
)
|
|
160
146
|
},
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
147
|
+
required: ["accountId", "input"]
|
|
148
|
+
}))
|
|
149
|
+
});
|
|
150
|
+
const declaration2 = operationDeclaration({
|
|
151
|
+
kind,
|
|
152
|
+
...first.description === void 0 ? {} : { description: first.description },
|
|
153
|
+
...first.title === void 0 ? {} : { title: first.title },
|
|
154
|
+
...first.annotations === void 0 || !variants.every(
|
|
155
|
+
(operation) => JSON.stringify(operation.annotations) === JSON.stringify(first.annotations)
|
|
156
|
+
) ? {} : { annotations: first.annotations },
|
|
157
|
+
...first._meta === void 0 || !variants.every((operation) => JSON.stringify(operation._meta) === JSON.stringify(first._meta)) ? {} : { _meta: first._meta },
|
|
158
|
+
input: withLazyJsonSchemaDocument(input, inputSchema),
|
|
159
|
+
approval: (context) => {
|
|
160
|
+
const operation = select(context.toolInput);
|
|
161
|
+
return operation.approval === void 0 ? Effect_exports.succeed("approved") : operation.approval({ ...context, toolInput: context.toolInput.input });
|
|
162
|
+
},
|
|
163
|
+
run: (context, input2) => {
|
|
164
|
+
const operation = select(input2);
|
|
165
|
+
return operation.run(context, input2.input).pipe(
|
|
166
|
+
Effect_exports.mapError((error) => accountProviderError(error, input2.accountId)),
|
|
167
|
+
Effect_exports.flatMap(
|
|
168
|
+
(output) => operation.output === void 0 ? Effect_exports.succeed(output) : Schema_exports.decodeUnknownEffect(operation.output)(output)
|
|
169
|
+
)
|
|
170
|
+
);
|
|
180
171
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
)
|
|
172
|
+
});
|
|
173
|
+
if (variants.every(declaresOutput)) {
|
|
174
|
+
const outputSchema = once(() => ({
|
|
175
|
+
anyOf: variants.flatMap((operation) => {
|
|
176
|
+
const output = outputDocument(operation);
|
|
177
|
+
return output === void 0 ? [] : [output];
|
|
178
|
+
}).map((output, index) => nestJsonSchema(output, `#/anyOf/${index}`))
|
|
179
|
+
}));
|
|
180
|
+
const native2 = nativeOperation(declaration2);
|
|
181
|
+
if (native2 !== void 0)
|
|
182
|
+
Object.defineProperty(native2, "outputSchema", { enumerable: true, get: outputSchema });
|
|
183
|
+
}
|
|
184
|
+
const native = nativeOperation(declaration2);
|
|
185
|
+
if (native === void 0) throw new Error("Expected a combined operation");
|
|
186
|
+
return native;
|
|
187
|
+
};
|
|
184
188
|
var sameAcross = (key, variants) => {
|
|
185
189
|
const first = variants[0]?.[1][key];
|
|
186
190
|
return first !== void 0 && variants.every(([, tool]) => JSON.stringify(tool[key]) === JSON.stringify(first)) ? { [key]: first } : {};
|
|
@@ -192,7 +196,7 @@ var mergeSummary = (name, variants) => {
|
|
|
192
196
|
name,
|
|
193
197
|
description: first.description,
|
|
194
198
|
...first.title === void 0 ? {} : { title: first.title },
|
|
195
|
-
readOnly:
|
|
199
|
+
readOnly: variants.every(([, tool]) => tool.readOnly === true),
|
|
196
200
|
...sameAcross("annotations", variants)
|
|
197
201
|
});
|
|
198
202
|
};
|
|
@@ -218,112 +222,123 @@ var merge = (name, variants) => Schema_exports.decodeUnknownSync(HostedTool)({
|
|
|
218
222
|
} : {},
|
|
219
223
|
...sameAcross("_meta", variants)
|
|
220
224
|
});
|
|
221
|
-
var
|
|
225
|
+
var combineDynamic = (sources) => {
|
|
226
|
+
const first = [...sources.values()][0];
|
|
227
|
+
const grouped = (read) => Effect_exports.gen(function* () {
|
|
228
|
+
const groups = /* @__PURE__ */ new Map();
|
|
229
|
+
for (const [accountId, source] of sources) {
|
|
230
|
+
const tools = yield* read(source).pipe(
|
|
231
|
+
Effect_exports.mapError((error) => accountProviderError(error, accountId))
|
|
232
|
+
);
|
|
233
|
+
for (const tool of tools) {
|
|
234
|
+
const variants = groups.get(tool.name) ?? [];
|
|
235
|
+
if (variants.some(([id]) => id === accountId))
|
|
236
|
+
return yield* Effect_exports.die(new Error("Duplicate source operation"));
|
|
237
|
+
variants.push([accountId, tool]);
|
|
238
|
+
groups.set(tool.name, variants);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return groups;
|
|
242
|
+
});
|
|
243
|
+
return {
|
|
244
|
+
kind: "dynamic",
|
|
245
|
+
// Accounts share one source, so the first account describes the router.
|
|
246
|
+
...first?.meta === void 0 ? {} : { meta: first.meta },
|
|
247
|
+
...first?.overrides === void 0 ? {} : { overrides: first.overrides },
|
|
248
|
+
list: () => grouped((source) => source.list()).pipe(
|
|
249
|
+
Effect_exports.map((groups) => [...groups].map(([name, variants]) => merge(name, variants)))
|
|
250
|
+
),
|
|
251
|
+
summaries: () => grouped(
|
|
252
|
+
(source) => source.summaries === void 0 ? source.list() : source.summaries()
|
|
253
|
+
).pipe(
|
|
254
|
+
Effect_exports.map((groups) => [...groups].map(([name, variants]) => mergeSummary(name, variants)))
|
|
255
|
+
),
|
|
256
|
+
describe: (name) => Effect_exports.gen(function* () {
|
|
257
|
+
const variants = [];
|
|
258
|
+
for (const [accountId, source] of sources) {
|
|
259
|
+
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)));
|
|
260
|
+
if (tool !== void 0) variants.push([accountId, tool]);
|
|
261
|
+
}
|
|
262
|
+
return variants.length === 0 ? void 0 : merge(name, variants);
|
|
263
|
+
}),
|
|
264
|
+
resolve: (name) => Effect_exports.gen(function* () {
|
|
265
|
+
const operations = /* @__PURE__ */ new Map();
|
|
266
|
+
for (const [accountId, source] of sources) {
|
|
267
|
+
const operation = yield* source.resolve(name).pipe(Effect_exports.mapError((error) => accountProviderError(error, accountId)));
|
|
268
|
+
if (operation !== void 0) operations.set(accountId, operation);
|
|
269
|
+
}
|
|
270
|
+
return operations.size === 0 ? void 0 : combineOperation(operations);
|
|
271
|
+
})
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
var combineNode = (variants) => {
|
|
275
|
+
const nodes = [...variants.values()];
|
|
276
|
+
const first = nodes[0];
|
|
277
|
+
if (first === void 0) throw new Error("An account operation must have at least one account");
|
|
278
|
+
switch (first.kind) {
|
|
279
|
+
case "query":
|
|
280
|
+
case "mutation":
|
|
281
|
+
return combineOperation(
|
|
282
|
+
narrow(
|
|
283
|
+
variants,
|
|
284
|
+
(node) => node.kind === "query" || node.kind === "mutation"
|
|
285
|
+
)
|
|
286
|
+
);
|
|
287
|
+
case "dynamic":
|
|
288
|
+
return combineDynamic(
|
|
289
|
+
narrow(variants, (node) => node.kind === "dynamic")
|
|
290
|
+
);
|
|
291
|
+
case "router": {
|
|
292
|
+
const routers = narrow(variants, (node) => node.kind === "router");
|
|
293
|
+
const keys = new Set([...routers.values()].flatMap((router2) => Object.keys(router2.children)));
|
|
294
|
+
return {
|
|
295
|
+
kind: "router",
|
|
296
|
+
...first.meta === void 0 ? {} : { meta: first.meta },
|
|
297
|
+
children: Object.fromEntries(
|
|
298
|
+
[...keys].map((key) => {
|
|
299
|
+
const children = /* @__PURE__ */ new Map();
|
|
300
|
+
for (const [accountId, router2] of routers) {
|
|
301
|
+
const child = Object.hasOwn(router2.children, key) ? router2.children[key] : void 0;
|
|
302
|
+
if (child !== void 0) children.set(accountId, child);
|
|
303
|
+
}
|
|
304
|
+
return [key, combineNode(children)];
|
|
305
|
+
})
|
|
306
|
+
)
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
var narrow = (variants, is) => {
|
|
312
|
+
const narrowed = /* @__PURE__ */ new Map();
|
|
313
|
+
for (const [accountId, node] of variants) {
|
|
314
|
+
if (!is(node)) throw new Error("Each account's router must have the same shape");
|
|
315
|
+
narrowed.set(accountId, node);
|
|
316
|
+
}
|
|
317
|
+
return narrowed;
|
|
318
|
+
};
|
|
319
|
+
var accountRouter = (accounts, discover, options) => Effect_exports.runPromise(
|
|
222
320
|
Effect_exports.gen(function* () {
|
|
223
|
-
const
|
|
224
|
-
const mutations = /* @__PURE__ */ new Map();
|
|
225
|
-
const sources = /* @__PURE__ */ new Map();
|
|
321
|
+
const routers = /* @__PURE__ */ new Map();
|
|
226
322
|
for (const account of accounts) {
|
|
227
|
-
const
|
|
323
|
+
const declaration2 = yield* Effect_exports.tryPromise({
|
|
228
324
|
try: () => discover(account),
|
|
229
325
|
catch: (error) => accountProviderError(error, account.id)
|
|
230
326
|
});
|
|
231
|
-
if (
|
|
327
|
+
if (routers.has(account.id))
|
|
232
328
|
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
|
-
}
|
|
329
|
+
const router2 = nativeRouter(declaration2);
|
|
330
|
+
if (router2 === void 0) return yield* Effect_exports.die(new Error("Expected a protocol router"));
|
|
331
|
+
routers.set(account.id, router2);
|
|
249
332
|
}
|
|
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
|
-
};
|
|
333
|
+
if (routers.size === 0) return routerDeclaration({ kind: "router", children: {} });
|
|
334
|
+
const combined = combineNode(routers);
|
|
335
|
+
if (combined.kind !== "router" && combined.kind !== "dynamic")
|
|
336
|
+
return yield* Effect_exports.die(new Error("Expected a protocol router"));
|
|
337
|
+
return routerDeclaration(combined);
|
|
308
338
|
}),
|
|
309
339
|
options
|
|
310
340
|
);
|
|
311
341
|
|
|
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
342
|
// src/implementation/dynamic-skills.ts
|
|
328
343
|
var dynamicSkills = (source) => ({
|
|
329
344
|
list: fromPromise(async () => source.list())
|
|
@@ -365,11 +380,26 @@ var cron = (calendar, operation, input) => declaration(
|
|
|
365
380
|
);
|
|
366
381
|
|
|
367
382
|
// src/index.ts
|
|
383
|
+
var isFields = (value) => typeof value === "object" && value !== null && Object.values(value).every(isSchema);
|
|
384
|
+
var accountDecoder = (schema) => (
|
|
385
|
+
// SAFETY: the brand exists only in types; secret values are strings at runtime.
|
|
386
|
+
decoderOf(schema)
|
|
387
|
+
);
|
|
388
|
+
var exposureOf = (schema) => {
|
|
389
|
+
const marked = "fields" in schema && isFields(schema.fields) ? fieldExposure(schema.fields) : {};
|
|
390
|
+
return Object.keys(marked).length === 0 ? {} : { exposure: marked };
|
|
391
|
+
};
|
|
368
392
|
var OAuth2AccessToken2 = wrap(OAuth2AccessToken, false);
|
|
369
|
-
var secrets2 = (options) => secrets({
|
|
393
|
+
var secrets2 = (options) => secrets({
|
|
394
|
+
label: options.label,
|
|
395
|
+
fields: accountDecoder(options.fields),
|
|
396
|
+
...exposureOf(options.fields)
|
|
397
|
+
});
|
|
370
398
|
function oauth22(options) {
|
|
371
399
|
const { response = OAuth2AccessToken2, ...config } = options;
|
|
372
|
-
return Effect_exports.runSync(
|
|
400
|
+
return Effect_exports.runSync(
|
|
401
|
+
oauth2(config, accountDecoder(response), exposureOf(response).exposure)
|
|
402
|
+
);
|
|
373
403
|
}
|
|
374
404
|
var decodeJson2 = (response, schema) => {
|
|
375
405
|
const native = {
|
|
@@ -388,6 +418,8 @@ var decodeJson2 = (response, schema) => {
|
|
|
388
418
|
export {
|
|
389
419
|
CacheError,
|
|
390
420
|
ElicitationFailed,
|
|
421
|
+
FetchOptionUnsupported,
|
|
422
|
+
NetworkRefused,
|
|
391
423
|
NonRetryableError,
|
|
392
424
|
NotImplemented,
|
|
393
425
|
OAuth2AccessToken2 as OAuth2AccessToken,
|
|
@@ -396,17 +428,15 @@ export {
|
|
|
396
428
|
ResponseStatusError,
|
|
397
429
|
ValidationError,
|
|
398
430
|
WorkflowFailure,
|
|
399
|
-
|
|
431
|
+
accountRouter,
|
|
400
432
|
array,
|
|
401
433
|
boolean,
|
|
402
434
|
cron,
|
|
403
435
|
decodeJson2 as decodeJson,
|
|
404
436
|
defineApp,
|
|
405
|
-
defineDatabase,
|
|
406
437
|
defineProvider,
|
|
438
|
+
dynamicRouter,
|
|
407
439
|
dynamicSkills,
|
|
408
|
-
dynamicTools,
|
|
409
|
-
id,
|
|
410
440
|
interval,
|
|
411
441
|
json,
|
|
412
442
|
jsonSchema,
|
|
@@ -415,12 +445,15 @@ export {
|
|
|
415
445
|
number,
|
|
416
446
|
oauth22 as oauth2,
|
|
417
447
|
object,
|
|
448
|
+
plain,
|
|
418
449
|
query,
|
|
450
|
+
raw,
|
|
419
451
|
record,
|
|
452
|
+
router,
|
|
420
453
|
secrets2 as secrets,
|
|
421
454
|
string,
|
|
422
|
-
|
|
423
|
-
userId,
|
|
455
|
+
toolAnnotations,
|
|
424
456
|
withApproval,
|
|
457
|
+
withApprovals,
|
|
425
458
|
workflow
|
|
426
459
|
};
|
package/js/mcp/effect.js
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mcpClientEffect,
|
|
3
|
+
mcpHealthEffect,
|
|
3
4
|
mcpToolsEffect
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-6XGB4BAL.js";
|
|
6
|
+
import "../chunk-FXWRE655.js";
|
|
6
7
|
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";
|
|
8
|
+
import "../chunk-AHGGO2VY.js";
|
|
9
|
+
import "../chunk-RIXVGVA6.js";
|
|
10
|
+
import "../chunk-ADD6H64X.js";
|
|
11
|
+
import "../chunk-KIM5HXNK.js";
|
|
12
|
+
import "../chunk-CQD3WSYH.js";
|
|
13
|
+
import "../chunk-JJSLEJ6T.js";
|
|
14
|
+
import "../chunk-MJZYV7IO.js";
|
|
15
|
+
import "../chunk-EM4UL26F.js";
|
|
16
|
+
import "../chunk-OTCLXFLL.js";
|
|
17
|
+
import "../chunk-P7MGDPFD.js";
|
|
18
|
+
import "../chunk-UOZMSUJ2.js";
|
|
19
|
+
import "../chunk-PNVCCB4L.js";
|
|
20
|
+
import "../chunk-VJQXXOQ3.js";
|
|
21
|
+
import "../chunk-WPBR4AWB.js";
|
|
22
|
+
import "../chunk-KAQD3DTI.js";
|
|
23
|
+
import "../chunk-YQ35E7KS.js";
|
|
24
|
+
import "../chunk-VIU2XXA7.js";
|
|
25
|
+
import "../chunk-3MMG2H6M.js";
|
|
26
|
+
import "../chunk-MXDKXAY4.js";
|
|
27
27
|
import "../chunk-CZ7CSFO4.js";
|
|
28
28
|
export {
|
|
29
29
|
mcpClientEffect,
|
|
30
|
+
mcpHealthEffect,
|
|
30
31
|
mcpToolsEffect
|
|
31
32
|
};
|