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