apps 0.0.1-beta.5 → 0.0.1-beta.55
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-47F7VXST.js +221 -0
- package/js/chunk-5FHWNLCI.js +88 -0
- package/js/{chunk-M3B3DE4K.js → chunk-74YVXBKY.js} +463 -218
- package/js/chunk-7UUHJR2Q.js +49 -0
- package/js/{chunk-CYYBFC2K.js → chunk-AQU56EPI.js} +9 -5
- package/js/chunk-BTSIG4NQ.js +1885 -0
- package/js/chunk-CDXQDN7W.js +92 -0
- package/js/{chunk-UK573G7W.js → chunk-EOPQ727L.js} +87 -51
- package/js/{chunk-27F7W2LG.js → chunk-H2CJWXA3.js} +2 -2
- package/js/{chunk-JU7VHODU.js → chunk-H72MEDMN.js} +65 -10
- package/js/{chunk-CDL5PM2Q.js → chunk-IFJU5SYQ.js} +19082 -18402
- package/js/{chunk-UDDE5KOR.js → chunk-JK5S2N2S.js} +148 -34
- package/js/{chunk-RJDDBDSN.js → chunk-JM7LOD2W.js} +628 -85
- package/js/{chunk-VFZKSM3T.js → chunk-JPEUKEV4.js} +3 -3
- package/js/{chunk-FWQC6I3C.js → chunk-KGCTYL2S.js} +523 -63
- package/js/{chunk-KUMBKVJD.js → chunk-KLYSEHUD.js} +2 -2
- package/js/chunk-L4K2K22P.js +42 -0
- package/js/chunk-LTDHQJ2Z.js +171 -0
- package/js/chunk-MWKHKOTL.js +240 -0
- package/js/chunk-OD3KFKZD.js +1617 -0
- package/js/{chunk-57RKNWL2.js → chunk-PD6I2SDG.js} +4 -4
- package/js/chunk-PXXZ6ABC.js +266 -0
- package/js/chunk-QEBRH5AP.js +729 -0
- package/js/chunk-TLWLJ7PD.js +4342 -0
- package/js/{chunk-IJX4CYZO.js → chunk-TUMGL2OC.js} +228 -264
- package/js/{chunk-XHO2ZX6W.js → chunk-UM62MBJQ.js} +96 -41
- package/js/{chunk-IPI4MFSN.js → chunk-XBG7HHXC.js} +2 -2
- package/js/chunk-XCSG7FT7.js +340 -0
- package/js/client.js +142 -94
- package/js/contracts.js +123 -33
- package/js/effect.js +19 -21
- package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
- package/js/graphql.js +63 -60
- package/js/host.js +83 -60
- package/js/index.js +262 -222
- package/js/mcp/effect.js +23 -23
- package/js/mcp/stdio.js +48 -40
- package/js/mcp.js +109 -72
- package/js/openapi.js +4129 -1419
- package/js/react.js +2 -3
- package/js/skills/effect.js +6 -3
- package/js/skills.js +208 -82
- 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-cache/src/index.d.ts +10 -1
- package/types/apps/src/contracts/api-response-error.d.ts +4 -0
- package/types/apps/src/contracts/app.d.ts +9 -8
- package/types/apps/src/contracts/cache.d.ts +20 -0
- package/types/apps/src/contracts/context.d.ts +19 -11
- package/types/apps/src/contracts/elicitation.d.ts +6 -6
- package/types/apps/src/contracts/events.d.ts +93 -0
- package/types/apps/src/contracts/failure.d.ts +30 -1
- package/types/apps/src/contracts/graphql.d.ts +2 -1
- package/types/apps/src/contracts/host.d.ts +57 -18
- 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 +733 -81
- package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
- package/types/apps/src/contracts/protocols/2.d.ts +69 -26
- package/types/apps/src/contracts/protocols/3.d.ts +133 -33
- package/types/apps/src/contracts/protocols/4.d.ts +1306 -0
- package/types/apps/src/contracts/protocols/5.d.ts +1200 -0
- package/types/apps/src/contracts/protocols/6.d.ts +1629 -0
- package/types/apps/src/contracts/protocols/7.d.ts +1785 -0
- package/types/apps/src/contracts/protocols/8.d.ts +1182 -0
- package/types/apps/src/contracts/protocols/9.d.ts +1104 -0
- package/types/apps/src/contracts/protocols/current.d.ts +2476 -0
- package/types/apps/src/contracts/protocols/oauth-6.d.ts +74 -0
- package/types/apps/src/contracts/protocols/oauth.d.ts +134 -0
- package/types/apps/src/contracts/provider-error.d.ts +9 -0
- package/types/apps/src/contracts/provider.d.ts +115 -10
- package/types/apps/src/contracts/router.d.ts +59 -0
- package/types/apps/src/contracts/skills.d.ts +50 -13
- 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 +6 -0
- package/types/apps/src/facet.d.ts +4 -5
- package/types/apps/src/graphql.d.ts +1 -3
- package/types/apps/src/host.d.ts +5 -0
- package/types/apps/src/implementation/account-router.d.ts +13 -0
- package/types/apps/src/implementation/app.d.ts +5 -4
- package/types/apps/src/implementation/authoring.d.ts +25 -5
- package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
- package/types/apps/src/implementation/cache.d.ts +4 -0
- package/types/apps/src/implementation/catalog-cache.d.ts +43 -5
- package/types/apps/src/implementation/elicitation.d.ts +18 -15
- package/types/apps/src/implementation/events.d.ts +59 -0
- package/types/apps/src/implementation/failure-detail.d.ts +25 -3
- package/types/apps/src/implementation/graphql-catalog.d.ts +4 -7
- package/types/apps/src/implementation/graphql.d.ts +4 -3
- package/types/apps/src/implementation/input-problems.d.ts +6 -2
- package/types/apps/src/implementation/invocation-timing.d.ts +16 -0
- package/types/apps/src/implementation/live.d.ts +2 -2
- package/types/apps/src/implementation/mcp-call.d.ts +6 -5
- package/types/apps/src/implementation/mcp-catalog.d.ts +7 -8
- package/types/apps/src/implementation/mcp-client.d.ts +49 -25
- package/types/apps/src/implementation/mcp-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 +43 -5
- 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 +70 -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 +71 -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 +1 -1
- package/types/apps/src/implementation/workflows.d.ts +1 -1
- package/types/apps/src/index.d.ts +32 -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 +7 -4
- package/types/telemetry/src/browser.d.ts +8 -3
- package/types/telemetry/src/config.d.ts +2 -2
- package/types/telemetry/src/index.d.ts +1 -0
- package/types/telemetry/src/layer.d.ts +2 -2
- package/types/telemetry/src/ownership.d.ts +56 -0
- package/types/telemetry/src/recorded-failure.d.ts +29 -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 +55 -0
- package/types/utils/src/connection-failure.d.ts +33 -0
- package/types/utils/src/recorded-message.d.ts +18 -0
- package/types/utils/src/user-facing-error.d.ts +83 -0
- package/js/chunk-3XKZDQLM.js +0 -93
- package/js/chunk-4M277YTM.js +0 -136
- package/js/chunk-67EVWIGJ.js +0 -224
- package/js/chunk-C3VAOK5B.js +0 -215
- package/js/chunk-DQAZTA4I.js +0 -2375
- package/js/chunk-G7T27IWB.js +0 -63
- package/js/chunk-LUVSFETN.js +0 -1347
- package/js/chunk-N7YDVXYJ.js +0 -186
- package/js/chunk-PJJ24GU7.js +0 -877
- package/js/chunk-PZB6T6KU.js +0 -19
- package/js/chunk-SB3V4YVR.js +0 -18
- package/js/chunk-TDNYXSIX.js +0 -29
- package/js/chunk-W4DMKWAB.js +0 -35
- package/js/chunk-YEPYT6SD.js +0 -85
- package/js/chunk-ZQINWV4W.js +0 -630
- 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 -18
- 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 -15
package/js/index.js
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ResponseDecodeError,
|
|
3
|
+
ResponseStatusError,
|
|
2
4
|
defineApp,
|
|
3
|
-
|
|
4
|
-
table,
|
|
5
|
+
event,
|
|
5
6
|
workflow
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-ZQINWV4W.js";
|
|
7
|
+
} from "./chunk-PXXZ6ABC.js";
|
|
8
8
|
import {
|
|
9
|
-
|
|
9
|
+
dynamicRouter,
|
|
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-47F7VXST.js";
|
|
16
21
|
import {
|
|
17
|
-
accountProviderError
|
|
18
|
-
|
|
22
|
+
accountProviderError,
|
|
23
|
+
fromPromise
|
|
24
|
+
} from "./chunk-LTDHQJ2Z.js";
|
|
19
25
|
import {
|
|
20
26
|
CalendarSchedule,
|
|
21
27
|
ElicitationFailed,
|
|
@@ -30,22 +36,21 @@ import {
|
|
|
30
36
|
ScheduleTiming,
|
|
31
37
|
SecretsMethod,
|
|
32
38
|
WorkflowFailure
|
|
33
|
-
} from "./chunk-
|
|
34
|
-
import "./chunk-N7YDVXYJ.js";
|
|
35
|
-
import {
|
|
36
|
-
CacheError
|
|
37
|
-
} from "./chunk-YEPYT6SD.js";
|
|
38
|
-
import "./chunk-JU7VHODU.js";
|
|
39
|
-
import "./chunk-W4DMKWAB.js";
|
|
39
|
+
} from "./chunk-TLWLJ7PD.js";
|
|
40
40
|
import {
|
|
41
|
+
CacheError,
|
|
42
|
+
FetchOptionUnsupported,
|
|
43
|
+
NetworkRefused,
|
|
41
44
|
ProviderError
|
|
42
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-MWKHKOTL.js";
|
|
46
|
+
import "./chunk-H72MEDMN.js";
|
|
43
47
|
import {
|
|
44
48
|
array,
|
|
45
49
|
boolean,
|
|
46
50
|
decoderOf,
|
|
47
|
-
|
|
51
|
+
fieldExposure,
|
|
48
52
|
importedJsonSchema,
|
|
53
|
+
isSchema,
|
|
49
54
|
json,
|
|
50
55
|
jsonSchema,
|
|
51
56
|
literal,
|
|
@@ -54,42 +59,29 @@ import {
|
|
|
54
59
|
object,
|
|
55
60
|
once,
|
|
56
61
|
parse,
|
|
62
|
+
plain,
|
|
63
|
+
raw,
|
|
57
64
|
record,
|
|
58
65
|
string,
|
|
59
|
-
userId,
|
|
60
66
|
withLazyJsonSchemaDocument,
|
|
61
67
|
wrap
|
|
62
|
-
} from "./chunk-
|
|
63
|
-
import "./chunk-
|
|
68
|
+
} from "./chunk-KGCTYL2S.js";
|
|
69
|
+
import "./chunk-JM7LOD2W.js";
|
|
70
|
+
import "./chunk-PD6I2SDG.js";
|
|
71
|
+
import "./chunk-5FHWNLCI.js";
|
|
64
72
|
import {
|
|
65
73
|
JsonObject,
|
|
66
74
|
JsonValue,
|
|
67
75
|
ValidationError
|
|
68
|
-
} from "./chunk-
|
|
76
|
+
} from "./chunk-H2CJWXA3.js";
|
|
77
|
+
import "./chunk-TUMGL2OC.js";
|
|
78
|
+
import "./chunk-EOPQ727L.js";
|
|
69
79
|
import {
|
|
70
80
|
Effect_exports,
|
|
71
81
|
Schema_exports
|
|
72
|
-
} from "./chunk-
|
|
82
|
+
} from "./chunk-IFJU5SYQ.js";
|
|
73
83
|
import "./chunk-CZ7CSFO4.js";
|
|
74
84
|
|
|
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
85
|
// src/implementation/http.ts
|
|
94
86
|
var decodeJson = (response, schema) => Effect_exports.gen(function* () {
|
|
95
87
|
if (response.status < 200 || response.status >= 300) {
|
|
@@ -101,86 +93,101 @@ var decodeJson = (response, schema) => Effect_exports.gen(function* () {
|
|
|
101
93
|
|
|
102
94
|
// src/implementation/provider.ts
|
|
103
95
|
var secrets = (options) => new SecretsMethod(options);
|
|
104
|
-
var oauth2 = (config, response) => parse(OAuth2Config, config).pipe(
|
|
105
|
-
|
|
96
|
+
var oauth2 = (config, response, exposure) => parse(OAuth2Config, config).pipe(
|
|
97
|
+
Effect_exports.map(
|
|
98
|
+
(config2) => new OAuth2Method({ config: config2, response, ...exposure === void 0 ? {} : { exposure } })
|
|
99
|
+
)
|
|
100
|
+
);
|
|
101
|
+
var defineProvider = ({
|
|
102
|
+
health,
|
|
103
|
+
...options
|
|
104
|
+
}) => {
|
|
105
|
+
if (health === void 0) return new Provider(options);
|
|
106
|
+
const run = fromPromise(health, "check");
|
|
107
|
+
return new Provider({ ...options, health: { run } });
|
|
108
|
+
};
|
|
106
109
|
|
|
107
|
-
// src/implementation/account-
|
|
108
|
-
var
|
|
109
|
-
const imported = importedJsonSchema(
|
|
110
|
+
// src/implementation/account-router.ts
|
|
111
|
+
var decoderDocument = (decoder) => {
|
|
112
|
+
const imported = importedJsonSchema(decoder);
|
|
110
113
|
if (imported !== void 0) return Schema_exports.decodeUnknownSync(JsonObject)(imported);
|
|
111
|
-
const document = Schema_exports.toJsonSchemaDocument(
|
|
114
|
+
const document = Schema_exports.toJsonSchemaDocument(decoder);
|
|
112
115
|
return Schema_exports.decodeUnknownSync(JsonObject)({ ...document.schema, $defs: document.definitions });
|
|
113
116
|
};
|
|
114
117
|
var declaresOutput = (operation) => {
|
|
118
|
+
if (operation.output !== void 0) return true;
|
|
115
119
|
const property = Object.getOwnPropertyDescriptor(operation, "outputSchema");
|
|
116
120
|
return property !== void 0 && (property.get !== void 0 || property.value !== void 0);
|
|
117
121
|
};
|
|
118
|
-
var
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
122
|
+
var outputDocument = (operation) => operation.output === void 0 ? operation.outputSchema : decoderDocument(operation.output);
|
|
123
|
+
var combineOperation = (accounts) => {
|
|
124
|
+
const variants = [...accounts.values()];
|
|
125
|
+
const first = variants[0];
|
|
126
|
+
if (first === void 0) throw new Error("An account operation must have at least one account");
|
|
127
|
+
const kind = variants.every((operation) => operation.kind === "query") ? "query" : "mutation";
|
|
128
|
+
const select = (input2) => {
|
|
129
|
+
const operation = accounts.get(input2.accountId);
|
|
130
|
+
if (operation === void 0)
|
|
131
|
+
throw new Error("Account selection must be decoded before execution");
|
|
132
|
+
return operation;
|
|
133
|
+
};
|
|
134
|
+
const input = Schema_exports.Union(
|
|
135
|
+
[...accounts].map(
|
|
136
|
+
([accountId, operation]) => Schema_exports.Struct({ accountId: Schema_exports.Literal(accountId), input: operation.input })
|
|
137
|
+
)
|
|
138
|
+
);
|
|
139
|
+
const inputSchema = () => ({
|
|
140
|
+
type: "object",
|
|
141
|
+
anyOf: [...accounts].map(([accountId, operation], index) => ({
|
|
136
142
|
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 });
|
|
143
|
+
properties: {
|
|
144
|
+
accountId: { type: "string", const: accountId },
|
|
145
|
+
input: nestJsonSchema(
|
|
146
|
+
decoderDocument(operation.input),
|
|
147
|
+
`#/anyOf/${index}/properties/input`
|
|
148
|
+
)
|
|
160
149
|
},
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
150
|
+
required: ["accountId", "input"]
|
|
151
|
+
}))
|
|
152
|
+
});
|
|
153
|
+
const declaration2 = operationDeclaration({
|
|
154
|
+
kind,
|
|
155
|
+
...first.description === void 0 ? {} : { description: first.description },
|
|
156
|
+
...first.title === void 0 ? {} : { title: first.title },
|
|
157
|
+
...first.annotations === void 0 || !variants.every(
|
|
158
|
+
(operation) => JSON.stringify(operation.annotations) === JSON.stringify(first.annotations)
|
|
159
|
+
) ? {} : { annotations: first.annotations },
|
|
160
|
+
...first._meta === void 0 || !variants.every((operation) => JSON.stringify(operation._meta) === JSON.stringify(first._meta)) ? {} : { _meta: first._meta },
|
|
161
|
+
input: withLazyJsonSchemaDocument(input, inputSchema),
|
|
162
|
+
approval: (context) => {
|
|
163
|
+
const operation = select(context.toolInput);
|
|
164
|
+
return operation.approval === void 0 ? Effect_exports.succeed("approved") : operation.approval({ ...context, toolInput: context.toolInput.input });
|
|
165
|
+
},
|
|
166
|
+
run: (context, input2) => {
|
|
167
|
+
const operation = select(input2);
|
|
168
|
+
return operation.run(context, input2.input).pipe(
|
|
169
|
+
Effect_exports.mapError((error) => accountProviderError(error, input2.accountId)),
|
|
170
|
+
Effect_exports.flatMap(
|
|
171
|
+
(output) => operation.output === void 0 ? Effect_exports.succeed(output) : Schema_exports.decodeUnknownEffect(operation.output)(output)
|
|
172
|
+
)
|
|
173
|
+
);
|
|
180
174
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
)
|
|
175
|
+
});
|
|
176
|
+
if (variants.every(declaresOutput)) {
|
|
177
|
+
const outputSchema = once(() => ({
|
|
178
|
+
anyOf: variants.flatMap((operation) => {
|
|
179
|
+
const output = outputDocument(operation);
|
|
180
|
+
return output === void 0 ? [] : [output];
|
|
181
|
+
}).map((output, index) => nestJsonSchema(output, `#/anyOf/${index}`))
|
|
182
|
+
}));
|
|
183
|
+
const native2 = nativeOperation(declaration2);
|
|
184
|
+
if (native2 !== void 0)
|
|
185
|
+
Object.defineProperty(native2, "outputSchema", { enumerable: true, get: outputSchema });
|
|
186
|
+
}
|
|
187
|
+
const native = nativeOperation(declaration2);
|
|
188
|
+
if (native === void 0) throw new Error("Expected a combined operation");
|
|
189
|
+
return native;
|
|
190
|
+
};
|
|
184
191
|
var sameAcross = (key, variants) => {
|
|
185
192
|
const first = variants[0]?.[1][key];
|
|
186
193
|
return first !== void 0 && variants.every(([, tool]) => JSON.stringify(tool[key]) === JSON.stringify(first)) ? { [key]: first } : {};
|
|
@@ -192,7 +199,7 @@ var mergeSummary = (name, variants) => {
|
|
|
192
199
|
name,
|
|
193
200
|
description: first.description,
|
|
194
201
|
...first.title === void 0 ? {} : { title: first.title },
|
|
195
|
-
readOnly:
|
|
202
|
+
readOnly: variants.every(([, tool]) => tool.readOnly === true),
|
|
196
203
|
...sameAcross("annotations", variants)
|
|
197
204
|
});
|
|
198
205
|
};
|
|
@@ -218,115 +225,126 @@ var merge = (name, variants) => Schema_exports.decodeUnknownSync(HostedTool)({
|
|
|
218
225
|
} : {},
|
|
219
226
|
...sameAcross("_meta", variants)
|
|
220
227
|
});
|
|
221
|
-
var
|
|
228
|
+
var combineDynamic = (sources) => {
|
|
229
|
+
const first = [...sources.values()][0];
|
|
230
|
+
const grouped = (read) => Effect_exports.gen(function* () {
|
|
231
|
+
const groups = /* @__PURE__ */ new Map();
|
|
232
|
+
for (const [accountId, source] of sources) {
|
|
233
|
+
const tools = yield* read(source).pipe(
|
|
234
|
+
Effect_exports.mapError((error) => accountProviderError(error, accountId))
|
|
235
|
+
);
|
|
236
|
+
for (const tool of tools) {
|
|
237
|
+
const variants = groups.get(tool.name) ?? [];
|
|
238
|
+
if (variants.some(([id]) => id === accountId))
|
|
239
|
+
return yield* Effect_exports.die(new Error("Duplicate source operation"));
|
|
240
|
+
variants.push([accountId, tool]);
|
|
241
|
+
groups.set(tool.name, variants);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return groups;
|
|
245
|
+
});
|
|
246
|
+
return {
|
|
247
|
+
kind: "dynamic",
|
|
248
|
+
// Accounts share one source, so the first account describes the router.
|
|
249
|
+
...first?.meta === void 0 ? {} : { meta: first.meta },
|
|
250
|
+
...first?.overrides === void 0 ? {} : { overrides: first.overrides },
|
|
251
|
+
list: () => grouped((source) => source.list()).pipe(
|
|
252
|
+
Effect_exports.map((groups) => [...groups].map(([name, variants]) => merge(name, variants)))
|
|
253
|
+
),
|
|
254
|
+
summaries: () => grouped(
|
|
255
|
+
(source) => source.summaries === void 0 ? source.list() : source.summaries()
|
|
256
|
+
).pipe(
|
|
257
|
+
Effect_exports.map((groups) => [...groups].map(([name, variants]) => mergeSummary(name, variants)))
|
|
258
|
+
),
|
|
259
|
+
describe: (name) => Effect_exports.gen(function* () {
|
|
260
|
+
const variants = [];
|
|
261
|
+
for (const [accountId, source] of sources) {
|
|
262
|
+
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)));
|
|
263
|
+
if (tool !== void 0) variants.push([accountId, tool]);
|
|
264
|
+
}
|
|
265
|
+
return variants.length === 0 ? void 0 : merge(name, variants);
|
|
266
|
+
}),
|
|
267
|
+
resolve: (name) => Effect_exports.gen(function* () {
|
|
268
|
+
const operations = /* @__PURE__ */ new Map();
|
|
269
|
+
for (const [accountId, source] of sources) {
|
|
270
|
+
const operation = yield* source.resolve(name).pipe(Effect_exports.mapError((error) => accountProviderError(error, accountId)));
|
|
271
|
+
if (operation !== void 0) operations.set(accountId, operation);
|
|
272
|
+
}
|
|
273
|
+
return operations.size === 0 ? void 0 : combineOperation(operations);
|
|
274
|
+
})
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
var combineNode = (variants) => {
|
|
278
|
+
const nodes = [...variants.values()];
|
|
279
|
+
const first = nodes[0];
|
|
280
|
+
if (first === void 0) throw new Error("An account operation must have at least one account");
|
|
281
|
+
switch (first.kind) {
|
|
282
|
+
case "query":
|
|
283
|
+
case "mutation":
|
|
284
|
+
return combineOperation(
|
|
285
|
+
narrow(
|
|
286
|
+
variants,
|
|
287
|
+
(node) => node.kind === "query" || node.kind === "mutation"
|
|
288
|
+
)
|
|
289
|
+
);
|
|
290
|
+
case "dynamic":
|
|
291
|
+
return combineDynamic(
|
|
292
|
+
narrow(variants, (node) => node.kind === "dynamic")
|
|
293
|
+
);
|
|
294
|
+
case "router": {
|
|
295
|
+
const routers = narrow(variants, (node) => node.kind === "router");
|
|
296
|
+
const keys = new Set([...routers.values()].flatMap((router2) => Object.keys(router2.children)));
|
|
297
|
+
return {
|
|
298
|
+
kind: "router",
|
|
299
|
+
...first.meta === void 0 ? {} : { meta: first.meta },
|
|
300
|
+
children: Object.fromEntries(
|
|
301
|
+
[...keys].map((key) => {
|
|
302
|
+
const children = /* @__PURE__ */ new Map();
|
|
303
|
+
for (const [accountId, router2] of routers) {
|
|
304
|
+
const child = Object.hasOwn(router2.children, key) ? router2.children[key] : void 0;
|
|
305
|
+
if (child !== void 0) children.set(accountId, child);
|
|
306
|
+
}
|
|
307
|
+
return [key, combineNode(children)];
|
|
308
|
+
})
|
|
309
|
+
)
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
var narrow = (variants, is) => {
|
|
315
|
+
const narrowed = /* @__PURE__ */ new Map();
|
|
316
|
+
for (const [accountId, node] of variants) {
|
|
317
|
+
if (!is(node)) throw new Error("Each account's router must have the same shape");
|
|
318
|
+
narrowed.set(accountId, node);
|
|
319
|
+
}
|
|
320
|
+
return narrowed;
|
|
321
|
+
};
|
|
322
|
+
var accountRouter = (accounts, discover, options) => Effect_exports.runPromise(
|
|
222
323
|
Effect_exports.gen(function* () {
|
|
223
|
-
const
|
|
224
|
-
const mutations = /* @__PURE__ */ new Map();
|
|
225
|
-
const sources = /* @__PURE__ */ new Map();
|
|
324
|
+
const routers = /* @__PURE__ */ new Map();
|
|
226
325
|
for (const account of accounts) {
|
|
227
|
-
const
|
|
228
|
-
try: () => discover(account),
|
|
326
|
+
const declaration2 = yield* Effect_exports.tryPromise({
|
|
327
|
+
try: async () => discover(account),
|
|
229
328
|
catch: (error) => accountProviderError(error, account.id)
|
|
230
329
|
});
|
|
231
|
-
if (
|
|
330
|
+
if (routers.has(account.id))
|
|
232
331
|
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
|
-
}
|
|
332
|
+
const router2 = nativeRouter(declaration2);
|
|
333
|
+
if (router2 === void 0) return yield* Effect_exports.die(new Error("Expected a protocol router"));
|
|
334
|
+
routers.set(account.id, router2);
|
|
249
335
|
}
|
|
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
|
-
};
|
|
336
|
+
if (routers.size === 0) return routerDeclaration({ kind: "router", children: {} });
|
|
337
|
+
const combined = combineNode(routers);
|
|
338
|
+
if (combined.kind !== "router" && combined.kind !== "dynamic")
|
|
339
|
+
return yield* Effect_exports.die(new Error("Expected a protocol router"));
|
|
340
|
+
return routerDeclaration(combined);
|
|
308
341
|
}),
|
|
309
342
|
options
|
|
310
343
|
);
|
|
311
344
|
|
|
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
345
|
// src/implementation/dynamic-skills.ts
|
|
328
346
|
var dynamicSkills = (source) => ({
|
|
329
|
-
list: fromPromise(async () => source.list())
|
|
347
|
+
list: fromPromise(async () => source.list(), "skills")
|
|
330
348
|
});
|
|
331
349
|
|
|
332
350
|
// src/contracts/app.ts
|
|
@@ -365,21 +383,39 @@ var cron = (calendar, operation, input) => declaration(
|
|
|
365
383
|
);
|
|
366
384
|
|
|
367
385
|
// src/index.ts
|
|
386
|
+
var isFields = (value) => typeof value === "object" && value !== null && Object.values(value).every(isSchema);
|
|
387
|
+
var accountDecoder = (schema) => (
|
|
388
|
+
// SAFETY: the brand exists only in types; secret values are strings at runtime.
|
|
389
|
+
decoderOf(schema)
|
|
390
|
+
);
|
|
391
|
+
var exposureOf = (schema) => {
|
|
392
|
+
const marked = "fields" in schema && isFields(schema.fields) ? fieldExposure(schema.fields) : {};
|
|
393
|
+
return Object.keys(marked).length === 0 ? {} : { exposure: marked };
|
|
394
|
+
};
|
|
368
395
|
var OAuth2AccessToken2 = wrap(OAuth2AccessToken, false);
|
|
369
|
-
var secrets2 = (options) => secrets({
|
|
396
|
+
var secrets2 = (options) => secrets({
|
|
397
|
+
label: options.label,
|
|
398
|
+
fields: accountDecoder(options.fields),
|
|
399
|
+
...exposureOf(options.fields)
|
|
400
|
+
});
|
|
370
401
|
function oauth22(options) {
|
|
371
402
|
const { response = OAuth2AccessToken2, ...config } = options;
|
|
372
|
-
return Effect_exports.runSync(
|
|
403
|
+
return Effect_exports.runSync(
|
|
404
|
+
oauth2(config, accountDecoder(response), exposureOf(response).exposure)
|
|
405
|
+
);
|
|
373
406
|
}
|
|
374
407
|
var decodeJson2 = (response, schema) => {
|
|
375
408
|
const native = {
|
|
376
409
|
status: response.status,
|
|
377
|
-
json: () =>
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
410
|
+
json: () => (
|
|
411
|
+
// oxlint-disable-next-line executor/authored-code-through-adapter -- a Response the app passes from its own code
|
|
412
|
+
Effect_exports.tryPromise({
|
|
413
|
+
try: () => response.json(),
|
|
414
|
+
catch: (error) => error
|
|
415
|
+
}).pipe(
|
|
416
|
+
Effect_exports.catch(
|
|
417
|
+
(error) => error instanceof SyntaxError ? Effect_exports.fail(new ResponseDecodeError()) : Effect_exports.die(error)
|
|
418
|
+
)
|
|
383
419
|
)
|
|
384
420
|
)
|
|
385
421
|
};
|
|
@@ -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,17 +434,16 @@ export {
|
|
|
396
434
|
ResponseStatusError,
|
|
397
435
|
ValidationError,
|
|
398
436
|
WorkflowFailure,
|
|
399
|
-
|
|
437
|
+
accountRouter,
|
|
400
438
|
array,
|
|
401
439
|
boolean,
|
|
402
440
|
cron,
|
|
403
441
|
decodeJson2 as decodeJson,
|
|
404
442
|
defineApp,
|
|
405
|
-
defineDatabase,
|
|
406
443
|
defineProvider,
|
|
444
|
+
dynamicRouter,
|
|
407
445
|
dynamicSkills,
|
|
408
|
-
|
|
409
|
-
id,
|
|
446
|
+
event,
|
|
410
447
|
interval,
|
|
411
448
|
json,
|
|
412
449
|
jsonSchema,
|
|
@@ -415,12 +452,15 @@ export {
|
|
|
415
452
|
number,
|
|
416
453
|
oauth22 as oauth2,
|
|
417
454
|
object,
|
|
455
|
+
plain,
|
|
418
456
|
query,
|
|
457
|
+
raw,
|
|
419
458
|
record,
|
|
459
|
+
router,
|
|
420
460
|
secrets2 as secrets,
|
|
421
461
|
string,
|
|
422
|
-
|
|
423
|
-
userId,
|
|
462
|
+
toolAnnotations,
|
|
424
463
|
withApproval,
|
|
464
|
+
withApprovals,
|
|
425
465
|
workflow
|
|
426
466
|
};
|
package/js/mcp/effect.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mcpClientEffect,
|
|
3
|
+
mcpHealthEffect,
|
|
3
4
|
mcpToolsEffect
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-XCSG7FT7.js";
|
|
6
|
+
import "../chunk-JK5S2N2S.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-27F7W2LG.js";
|
|
27
|
-
import "../chunk-CDL5PM2Q.js";
|
|
8
|
+
import "../chunk-BTSIG4NQ.js";
|
|
9
|
+
import "../chunk-AQU56EPI.js";
|
|
10
|
+
import "../chunk-QEBRH5AP.js";
|
|
11
|
+
import "../chunk-7UUHJR2Q.js";
|
|
12
|
+
import "../chunk-XBG7HHXC.js";
|
|
13
|
+
import "../chunk-PXXZ6ABC.js";
|
|
14
|
+
import "../chunk-47F7VXST.js";
|
|
15
|
+
import "../chunk-LTDHQJ2Z.js";
|
|
16
|
+
import "../chunk-TLWLJ7PD.js";
|
|
17
|
+
import "../chunk-MWKHKOTL.js";
|
|
18
|
+
import "../chunk-H72MEDMN.js";
|
|
19
|
+
import "../chunk-KGCTYL2S.js";
|
|
20
|
+
import "../chunk-JM7LOD2W.js";
|
|
21
|
+
import "../chunk-PD6I2SDG.js";
|
|
22
|
+
import "../chunk-5FHWNLCI.js";
|
|
23
|
+
import "../chunk-H2CJWXA3.js";
|
|
24
|
+
import "../chunk-TUMGL2OC.js";
|
|
25
|
+
import "../chunk-EOPQ727L.js";
|
|
26
|
+
import "../chunk-IFJU5SYQ.js";
|
|
28
27
|
import "../chunk-CZ7CSFO4.js";
|
|
29
28
|
export {
|
|
30
29
|
mcpClientEffect,
|
|
30
|
+
mcpHealthEffect,
|
|
31
31
|
mcpToolsEffect
|
|
32
32
|
};
|