apps 0.0.1-beta.115 → 0.0.1-beta.117
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/framework-reference.json +1 -1
- package/js/{chunk-FCVF3PEM.js → chunk-4EOLLVQ6.js} +1 -1
- package/js/{chunk-7XZKCNGB.js → chunk-6A6P5TYV.js} +26 -10
- package/js/{chunk-3BI34I5S.js → chunk-ES6QUAAC.js} +1 -1
- package/js/{chunk-FDZGNN3U.js → chunk-GFRK2I3S.js} +2 -2
- package/js/chunk-OIMMQRYE.js +572 -0
- package/js/{chunk-27DVBAB5.js → chunk-OSVCX4MV.js} +3 -3
- package/js/effect.js +4 -4
- package/js/graphql.js +5 -5
- package/js/host.js +4 -4
- package/js/index.js +3 -268
- package/js/mcp/effect.js +5 -5
- package/js/mcp.js +6 -6
- package/js/openapi.js +7 -4
- package/package.json +1 -1
- package/runtime.json +1 -1
- package/types/apps/src/implementation/account-router.d.ts +16 -0
- package/js/chunk-ZXG7RMCB.js +0 -264
|
@@ -1,8 +1,23 @@
|
|
|
1
|
+
/** Combine account-bound protocol operations without changing their upstream inputs. */
|
|
2
|
+
import { Schema } from "effect";
|
|
1
3
|
import { type RouterDeclaration } from "./router.js";
|
|
4
|
+
declare const PartialListing_base: Schema.Class<PartialListing, Schema.TaggedStruct<"PartialListing", {
|
|
5
|
+
readonly tools: Schema.$Array<Schema.Unknown>;
|
|
6
|
+
readonly error: Schema.Unknown;
|
|
7
|
+
}>, import("effect/Cause").YieldableError>;
|
|
8
|
+
/**
|
|
9
|
+
* Some accounts listed their tools and at least one could not: the tools the others listed, and
|
|
10
|
+
* the first failing account's error. A catalog read keeps the tools and reports the error on the
|
|
11
|
+
* router, so one broken account does not hide every other account's tools.
|
|
12
|
+
*/
|
|
13
|
+
export declare class PartialListing extends PartialListing_base {
|
|
14
|
+
}
|
|
2
15
|
/**
|
|
3
16
|
* Discover each selected account's router and combine matching names.
|
|
4
17
|
* Calls take { accountId, input }; each branch retains its account's input schema,
|
|
5
18
|
* credentials, approval and output validation. Empty selections expose no operations.
|
|
19
|
+
* An account whose source fails does not hide the others' tools; its error is reported on the
|
|
20
|
+
* router, and a call that selects it fails with that error.
|
|
6
21
|
* Discovery is sequential and cancellation follows the caller's signal. `discover` may return the
|
|
7
22
|
* router or a Promise of it, and the combined router keeps its operations' handler contexts.
|
|
8
23
|
*/
|
|
@@ -11,3 +26,4 @@ export declare const accountRouter: <Account extends {
|
|
|
11
26
|
}, Query = unknown, Mutation = unknown>(accounts: readonly Account[], discover: (account: Account) => RouterDeclaration<Query, Mutation> | Promise<RouterDeclaration<Query, Mutation>>, options: {
|
|
12
27
|
readonly signal: AbortSignal;
|
|
13
28
|
}) => Promise<RouterDeclaration<Query, Mutation>>;
|
|
29
|
+
export {};
|
package/js/chunk-ZXG7RMCB.js
DELETED
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
fromPromise
|
|
3
|
-
} from "./chunk-OIH73VFM.js";
|
|
4
|
-
import {
|
|
5
|
-
HostedTool,
|
|
6
|
-
RouterKey,
|
|
7
|
-
RouterMeta,
|
|
8
|
-
reservedRouterKeys
|
|
9
|
-
} from "./chunk-2RGJMA7N.js";
|
|
10
|
-
import {
|
|
11
|
-
decoderOf,
|
|
12
|
-
schemaArgument
|
|
13
|
-
} from "./chunk-VAI3EVCS.js";
|
|
14
|
-
import {
|
|
15
|
-
Effect_exports,
|
|
16
|
-
Schema_exports
|
|
17
|
-
} from "./chunk-ZKDXML77.js";
|
|
18
|
-
|
|
19
|
-
// src/implementation/operations.ts
|
|
20
|
-
var NativeOperation = /* @__PURE__ */ Symbol("apps.Operation");
|
|
21
|
-
var NativeRouterKey = /* @__PURE__ */ Symbol("apps.Router");
|
|
22
|
-
var operationDeclaration = (operation) => ({
|
|
23
|
-
kind: operation.kind,
|
|
24
|
-
[NativeOperation]: operation
|
|
25
|
-
});
|
|
26
|
-
var nativeOperation = (value) => {
|
|
27
|
-
if (typeof value !== "object" || value === null || !(NativeOperation in value)) return void 0;
|
|
28
|
-
return value[NativeOperation];
|
|
29
|
-
};
|
|
30
|
-
var operationOptions = (options) => {
|
|
31
|
-
const approval = options.approval;
|
|
32
|
-
return {
|
|
33
|
-
...options.description === void 0 ? {} : { description: options.description },
|
|
34
|
-
...options.title === void 0 ? {} : { title: options.title },
|
|
35
|
-
...options.annotations === void 0 ? {} : { annotations: options.annotations },
|
|
36
|
-
...options._meta === void 0 ? {} : { _meta: options._meta },
|
|
37
|
-
input: decoderOf(options.input),
|
|
38
|
-
...approval === void 0 ? {} : {
|
|
39
|
-
approval: (context) => fromPromise(async () => approval(context), "approval")()
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
var approvedOperation = (operation, approval) => {
|
|
44
|
-
const copy = Object.defineProperties({}, Object.getOwnPropertyDescriptors(operation));
|
|
45
|
-
return Object.defineProperty(copy, "approval", {
|
|
46
|
-
enumerable: true,
|
|
47
|
-
value: (context) => fromPromise(async () => approval(context), "approval")()
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
var withApproval = (operation, approval) => (
|
|
51
|
-
// SAFETY: `Approved` is a type-only mark; the native operation now carries the approval.
|
|
52
|
-
{
|
|
53
|
-
...operation,
|
|
54
|
-
[NativeOperation]: approvedOperation(operation[NativeOperation], approval)
|
|
55
|
-
}
|
|
56
|
-
);
|
|
57
|
-
var toolAnnotations = (operation) => nativeOperation(operation)?.annotations;
|
|
58
|
-
var make = (kind, options, run) => operationDeclaration({
|
|
59
|
-
...operationOptions({ ...options, input: schemaArgument(options.input, `The ${kind} input`) }),
|
|
60
|
-
kind,
|
|
61
|
-
// The host always validates JSON serialization, even without a stronger output declaration.
|
|
62
|
-
...options.output === void 0 ? {} : { output: decoderOf(schemaArgument(options.output, `The ${kind} output`)) },
|
|
63
|
-
// SAFETY: defineApp checks the handler context against its requirements.
|
|
64
|
-
// The host validates account bindings and creates the matching storage facade.
|
|
65
|
-
run: (context, input) => fromPromise(run, "handler")(context, input)
|
|
66
|
-
});
|
|
67
|
-
var query = (options, run) => make("query", options, run);
|
|
68
|
-
function mutation(options, run) {
|
|
69
|
-
return make("mutation", options, run);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// src/implementation/router.ts
|
|
73
|
-
var routerDeclaration = (node) => ({
|
|
74
|
-
[NativeRouterKey]: node
|
|
75
|
-
});
|
|
76
|
-
var nativeRouter = (value) => {
|
|
77
|
-
if (typeof value !== "object" || value === null || !(NativeRouterKey in value)) return void 0;
|
|
78
|
-
return value[NativeRouterKey];
|
|
79
|
-
};
|
|
80
|
-
var nativeNode = (value) => nativeOperation(value) ?? nativeRouter(value);
|
|
81
|
-
var metaOf = (options) => {
|
|
82
|
-
if (options === void 0) return void 0;
|
|
83
|
-
const defined = Object.fromEntries(
|
|
84
|
-
Object.entries(options).filter(([, value]) => value !== void 0)
|
|
85
|
-
);
|
|
86
|
-
return Object.keys(defined).length === 0 ? void 0 : Schema_exports.decodeUnknownSync(RouterMeta)(defined);
|
|
87
|
-
};
|
|
88
|
-
var mergeMeta = (base, override) => base === void 0 ? override : override === void 0 ? base : { ...base, ...override };
|
|
89
|
-
function router(children, options) {
|
|
90
|
-
const meta = metaOf(options);
|
|
91
|
-
const existing = nativeRouter(children);
|
|
92
|
-
if (existing !== void 0)
|
|
93
|
-
return routerDeclaration(
|
|
94
|
-
existing.kind === "router" ? { ...existing, ...withMeta(mergeMeta(existing.meta, meta)) } : { ...existing, ...withOverrides(mergeMeta(existing.overrides, meta)) }
|
|
95
|
-
);
|
|
96
|
-
const nodes = {};
|
|
97
|
-
for (const [key, value] of Object.entries(children)) {
|
|
98
|
-
if (reservedRouterKeys.has(key)) throw new Error(`Router key "${key}" is reserved`);
|
|
99
|
-
if (!Schema_exports.is(RouterKey)(key))
|
|
100
|
-
throw new Error(`Router key "${key}" must start with a letter or _ and contain no dots`);
|
|
101
|
-
const node = nativeNode(value);
|
|
102
|
-
if (node === void 0)
|
|
103
|
-
throw new Error(`Router key "${key}" must be a query, mutation or router`);
|
|
104
|
-
nodes[key] = node;
|
|
105
|
-
}
|
|
106
|
-
return routerDeclaration({ kind: "router", ...withMeta(meta), children: nodes });
|
|
107
|
-
}
|
|
108
|
-
var withMeta = (meta) => meta === void 0 ? {} : { meta };
|
|
109
|
-
var withOverrides = (overrides) => overrides === void 0 ? {} : { overrides };
|
|
110
|
-
var dynamicRouter = (source) => {
|
|
111
|
-
const meta = source.meta;
|
|
112
|
-
return routerDeclaration({
|
|
113
|
-
kind: "dynamic",
|
|
114
|
-
...meta === void 0 ? {} : {
|
|
115
|
-
meta: () => fromPromise(async () => meta(), "router")().pipe(
|
|
116
|
-
Effect_exports.flatMap((options) => Schema_exports.decodeUnknownEffect(RouterMeta)(options))
|
|
117
|
-
)
|
|
118
|
-
},
|
|
119
|
-
list: () => fromPromise(async () => source.list(), "router")().pipe(
|
|
120
|
-
Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(Schema_exports.Array(HostedTool)))
|
|
121
|
-
),
|
|
122
|
-
resolve: (name) => fromPromise(async () => source.resolve(name), "router")().pipe(
|
|
123
|
-
Effect_exports.map((value) => {
|
|
124
|
-
if (value === void 0) return void 0;
|
|
125
|
-
const operation = nativeOperation(value);
|
|
126
|
-
if (operation === void 0) throw new Error("Expected an operation declaration");
|
|
127
|
-
return operation;
|
|
128
|
-
})
|
|
129
|
-
)
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
var joinPath = (path, name) => path === "" ? name : `${path}.${name}`;
|
|
133
|
-
var locate = (root, name) => {
|
|
134
|
-
if (root?.kind === "dynamic") return { kind: "dynamic", source: root, router: "", name };
|
|
135
|
-
let current = root;
|
|
136
|
-
let path = "";
|
|
137
|
-
let rest = name;
|
|
138
|
-
while (current !== void 0) {
|
|
139
|
-
const dot = rest.indexOf(".");
|
|
140
|
-
const key = dot < 0 ? rest : rest.slice(0, dot);
|
|
141
|
-
const child = Object.hasOwn(current.children, key) ? current.children[key] : void 0;
|
|
142
|
-
if (child === void 0) return void 0;
|
|
143
|
-
const remaining = dot < 0 ? void 0 : rest.slice(dot + 1);
|
|
144
|
-
switch (child.kind) {
|
|
145
|
-
case "query":
|
|
146
|
-
case "mutation":
|
|
147
|
-
return remaining === void 0 ? { kind: "operation", operation: child, router: path } : void 0;
|
|
148
|
-
case "dynamic":
|
|
149
|
-
return remaining === void 0 || remaining === "" ? void 0 : { kind: "dynamic", source: child, router: joinPath(path, key), name: remaining };
|
|
150
|
-
case "router":
|
|
151
|
-
if (remaining === void 0) return void 0;
|
|
152
|
-
current = child;
|
|
153
|
-
path = joinPath(path, key);
|
|
154
|
-
rest = remaining;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return void 0;
|
|
158
|
-
};
|
|
159
|
-
var declaredOperations = (root, path = "") => Object.entries(root?.children ?? {}).flatMap(([key, child]) => {
|
|
160
|
-
const name = joinPath(path, key);
|
|
161
|
-
switch (child.kind) {
|
|
162
|
-
case "query":
|
|
163
|
-
case "mutation":
|
|
164
|
-
return [{ name, router: path, operation: child }];
|
|
165
|
-
case "router":
|
|
166
|
-
return declaredOperations(child, name);
|
|
167
|
-
case "dynamic":
|
|
168
|
-
return [];
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
var withApprovals = (source, policy) => {
|
|
172
|
-
const native = nativeRouter(source);
|
|
173
|
-
if (native === void 0) throw new Error("withApprovals expects a router");
|
|
174
|
-
const operation = (node, name) => {
|
|
175
|
-
const approval = policy(operationDeclaration(node), name);
|
|
176
|
-
return approval === void 0 ? node : approvedOperation(node, approval);
|
|
177
|
-
};
|
|
178
|
-
const child = (node, name) => {
|
|
179
|
-
switch (node.kind) {
|
|
180
|
-
case "query":
|
|
181
|
-
case "mutation":
|
|
182
|
-
return operation(node, name);
|
|
183
|
-
case "router":
|
|
184
|
-
case "dynamic":
|
|
185
|
-
return walk(node, name);
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
const walk = (node, path) => node.kind === "dynamic" ? {
|
|
189
|
-
...node,
|
|
190
|
-
resolve: (name) => node.resolve(name).pipe(
|
|
191
|
-
Effect_exports.flatMap(
|
|
192
|
-
(resolved) => resolved === void 0 ? Effect_exports.succeed(void 0) : Effect_exports.try({
|
|
193
|
-
try: () => operation(resolved, joinPath(path, name)),
|
|
194
|
-
catch: (error) => error
|
|
195
|
-
})
|
|
196
|
-
)
|
|
197
|
-
)
|
|
198
|
-
} : {
|
|
199
|
-
...node,
|
|
200
|
-
children: Object.fromEntries(
|
|
201
|
-
Object.entries(node.children).map(([key, value]) => [
|
|
202
|
-
key,
|
|
203
|
-
child(value, joinPath(path, key))
|
|
204
|
-
])
|
|
205
|
-
)
|
|
206
|
-
};
|
|
207
|
-
return routerDeclaration(walk(native, ""));
|
|
208
|
-
};
|
|
209
|
-
var renameTools = (source, rename) => {
|
|
210
|
-
const native = nativeRouter(source);
|
|
211
|
-
if (native?.kind !== "dynamic") throw new Error("renameTools expects a protocol router");
|
|
212
|
-
const exposed = (tools) => {
|
|
213
|
-
const seen = /* @__PURE__ */ new Set();
|
|
214
|
-
return tools.flatMap((tool) => {
|
|
215
|
-
const name = rename(tool.name);
|
|
216
|
-
if (name === void 0 || seen.has(name)) return [];
|
|
217
|
-
seen.add(name);
|
|
218
|
-
return [{ ...tool, name, source: tool.name }];
|
|
219
|
-
});
|
|
220
|
-
};
|
|
221
|
-
const listed = native.summaries ?? native.list;
|
|
222
|
-
const original = (name) => listed().pipe(Effect_exports.map((tools) => exposed(tools).find((tool) => tool.name === name)?.source));
|
|
223
|
-
const strip = ({
|
|
224
|
-
source: _source,
|
|
225
|
-
...tool
|
|
226
|
-
}) => tool;
|
|
227
|
-
return routerDeclaration({
|
|
228
|
-
...native,
|
|
229
|
-
list: () => native.list().pipe(Effect_exports.map((tools) => exposed(tools).map(strip))),
|
|
230
|
-
...native.summaries === void 0 ? {} : {
|
|
231
|
-
summaries: () => listed().pipe(Effect_exports.map((tools) => exposed(tools).map(strip)))
|
|
232
|
-
},
|
|
233
|
-
describe: (name) => original(name).pipe(
|
|
234
|
-
Effect_exports.flatMap(
|
|
235
|
-
(found) => found === void 0 ? Effect_exports.succeed(void 0) : native.describe?.(found) ?? native.list().pipe(Effect_exports.map((tools) => tools.find((tool) => tool.name === found)))
|
|
236
|
-
),
|
|
237
|
-
Effect_exports.map((tool) => tool === void 0 ? void 0 : { ...tool, name })
|
|
238
|
-
),
|
|
239
|
-
resolve: (name) => original(name).pipe(
|
|
240
|
-
Effect_exports.flatMap(
|
|
241
|
-
(found) => found === void 0 ? Effect_exports.succeed(void 0) : native.resolve(found)
|
|
242
|
-
)
|
|
243
|
-
)
|
|
244
|
-
});
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
export {
|
|
248
|
-
operationDeclaration,
|
|
249
|
-
nativeOperation,
|
|
250
|
-
withApproval,
|
|
251
|
-
toolAnnotations,
|
|
252
|
-
query,
|
|
253
|
-
mutation,
|
|
254
|
-
routerDeclaration,
|
|
255
|
-
nativeRouter,
|
|
256
|
-
mergeMeta,
|
|
257
|
-
router,
|
|
258
|
-
dynamicRouter,
|
|
259
|
-
joinPath,
|
|
260
|
-
locate,
|
|
261
|
-
declaredOperations,
|
|
262
|
-
withApprovals,
|
|
263
|
-
renameTools
|
|
264
|
-
};
|