apps 0.0.1-beta.9 → 0.0.1-beta.91
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 +56 -38
- package/framework-reference.json +1 -1
- package/js/chunk-3LEVTFD4.js +712 -0
- package/js/chunk-5FHWNLCI.js +88 -0
- package/js/{chunk-FL2QR3XW.js → chunk-5MDA7MKL.js} +338 -73
- package/js/chunk-6XQLA5NC.js +5047 -0
- package/js/{chunk-M3B3DE4K.js → chunk-74YVXBKY.js} +463 -218
- package/js/chunk-7PHHWYV4.js +335 -0
- package/js/chunk-DADXWWRZ.js +449 -0
- package/js/{chunk-27F7W2LG.js → chunk-DDHBUKXX.js} +18 -2
- package/js/{chunk-UK573G7W.js → chunk-EOPQ727L.js} +87 -51
- package/js/{chunk-5T57N25Q.js → chunk-GQ33QSNB.js} +583 -69
- package/js/{chunk-JU7VHODU.js → chunk-H72MEDMN.js} +65 -10
- package/js/chunk-I5C7FD5Z.js +171 -0
- package/js/{chunk-CDL5PM2Q.js → chunk-IFJU5SYQ.js} +19082 -18402
- package/js/{chunk-VFZKSM3T.js → chunk-JPEUKEV4.js} +3 -3
- package/js/{chunk-KUMBKVJD.js → chunk-KLYSEHUD.js} +2 -2
- package/js/{chunk-RFVIONFX.js → chunk-KUCCHNVY.js} +123 -44
- package/js/chunk-OD3KFKZD.js +1617 -0
- package/js/{chunk-57RKNWL2.js → chunk-PD6I2SDG.js} +4 -4
- package/js/{chunk-72JNVHPK.js → chunk-PYQLOLOC.js} +4 -3
- package/js/{chunk-ODEIDRGW.js → chunk-QWQM3CLH.js} +795 -176
- package/js/{chunk-IJX4CYZO.js → chunk-TUMGL2OC.js} +228 -264
- package/js/{chunk-IPI4MFSN.js → chunk-XBG7HHXC.js} +2 -2
- package/js/chunk-XPRZTLHD.js +1915 -0
- package/js/chunk-YNJ5CZMJ.js +93 -0
- package/js/chunk-YRGL4QEF.js +49 -0
- package/js/{chunk-Z5M2LQOZ.js → chunk-YWFUWTUJ.js} +113 -58
- package/js/client.js +142 -78
- package/js/contracts.js +142 -21
- package/js/effect.js +18 -19
- package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
- package/js/graphql.js +49 -40
- package/js/host.js +85 -62
- package/js/index.js +165 -70
- package/js/mcp/effect.js +21 -21
- package/js/mcp.js +76 -56
- package/js/openapi.js +4189 -1411
- package/js/react.js +2 -3
- package/js/skills/effect.js +6 -3
- package/js/skills.js +208 -81
- 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 +8605 -225
- package/package.json +3 -8
- package/runtime.json +1 -1
- package/types/app-cache/src/contracts/cache.d.ts +18 -0
- package/types/app-cache/src/index.d.ts +34 -2
- package/types/apps/src/contracts/api-response-error.d.ts +4 -0
- package/types/apps/src/contracts/app.d.ts +60 -11
- package/types/apps/src/contracts/cache.d.ts +20 -0
- package/types/apps/src/contracts/context.d.ts +60 -17
- package/types/apps/src/contracts/elicitation.d.ts +23 -7
- package/types/apps/src/contracts/events.d.ts +94 -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 +1446 -17
- package/types/apps/src/contracts/icons.d.ts +28 -0
- package/types/apps/src/contracts/live.d.ts +2 -0
- package/types/apps/src/contracts/mcp.d.ts +81 -20
- package/types/apps/src/contracts/network.d.ts +120 -0
- package/types/apps/src/contracts/openapi-compile.d.ts +82 -3
- package/types/apps/src/contracts/openapi.d.ts +41 -9
- package/types/apps/src/contracts/operations.d.ts +14 -7
- package/types/apps/src/contracts/placement.d.ts +102 -0
- 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/11.d.ts +1149 -0
- package/types/apps/src/contracts/protocols/12.d.ts +3310 -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 +122 -45
- package/types/apps/src/contracts/protocols/5.d.ts +157 -47
- 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 +6669 -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 +90 -6
- package/types/apps/src/contracts/schedules.d.ts +7 -1
- package/types/apps/src/contracts/schema.d.ts +21 -0
- package/types/apps/src/contracts/skills.d.ts +50 -13
- package/types/apps/src/contracts/sql.d.ts +63 -0
- package/types/apps/src/contracts/ui.d.ts +44 -14
- package/types/apps/src/contracts/webhooks.d.ts +24 -7
- package/types/apps/src/contracts/workflows.d.ts +19 -17
- package/types/apps/src/facet.d.ts +4 -5
- package/types/apps/src/host.d.ts +5 -0
- package/types/apps/src/implementation/account-router.d.ts +4 -3
- package/types/apps/src/implementation/app.d.ts +41 -14
- 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 +29 -2
- package/types/apps/src/implementation/catalog-cache.d.ts +35 -4
- package/types/apps/src/implementation/elicitation.d.ts +18 -15
- package/types/apps/src/implementation/events.d.ts +64 -0
- package/types/apps/src/implementation/failure-detail.d.ts +28 -5
- package/types/apps/src/implementation/graphql-catalog.d.ts +3 -3
- 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 +18 -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 +6 -4
- package/types/apps/src/implementation/mcp-client.d.ts +17 -9
- package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
- package/types/apps/src/implementation/mcp.d.ts +20 -9
- package/types/apps/src/implementation/network.d.ts +16 -0
- package/types/apps/src/implementation/openapi-compile.d.ts +28 -7
- 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 +23 -1
- package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
- package/types/apps/src/implementation/operations.d.ts +57 -7
- package/types/apps/src/implementation/optimistic.d.ts +1 -1
- package/types/apps/src/implementation/placement.d.ts +60 -0
- package/types/apps/src/implementation/protocol-operations.d.ts +3 -0
- package/types/apps/src/implementation/provider-error.d.ts +28 -1
- package/types/apps/src/implementation/provider.d.ts +19 -4
- package/types/apps/src/implementation/query-commit.d.ts +1 -1
- package/types/apps/src/implementation/router-catalog.d.ts +20 -18
- package/types/apps/src/implementation/router.d.ts +24 -5
- package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
- package/types/apps/src/implementation/schedules.d.ts +39 -8
- package/types/apps/src/implementation/schema.d.ts +98 -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 +26 -9
- 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 +15 -6
- package/types/apps/src/implementation/workflow-context.d.ts +6 -2
- package/types/apps/src/implementation/workflows.d.ts +11 -4
- package/types/apps/src/index.d.ts +68 -19
- package/types/apps/src/mcp.d.ts +20 -1
- package/types/apps/src/openapi.d.ts +6 -1
- package/types/apps/src/react.d.ts +1 -1
- package/types/apps/src/skills.d.ts +10 -8
- package/types/apps/src/ui-serving.d.ts +1 -1
- package/types/telemetry/src/app-records.d.ts +42 -0
- package/types/telemetry/src/browser-operations.d.ts +2 -2
- 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 +2 -1
- package/types/telemetry/src/layer.d.ts +10 -4
- package/types/telemetry/src/measurements.d.ts +1 -1
- package/types/telemetry/src/ownership.d.ts +60 -0
- package/types/telemetry/src/recorded-failure.d.ts +29 -0
- package/types/telemetry/src/relay.d.ts +16 -6
- package/types/telemetry/src/span-attributes.d.ts +17 -1
- 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-7EK2JDX4.js +0 -299
- package/js/chunk-IKS2C5MQ.js +0 -224
- package/js/chunk-MKWZPDR6.js +0 -63
- package/js/chunk-N7YDVXYJ.js +0 -186
- package/js/chunk-NKLWZJLE.js +0 -172
- package/js/chunk-PJJ24GU7.js +0 -877
- package/js/chunk-PZB6T6KU.js +0 -19
- package/js/chunk-R3EV5FTO.js +0 -97
- package/js/chunk-SJFZCGXG.js +0 -1243
- package/js/chunk-WLE7WX2U.js +0 -2645
- package/js/chunk-YXQHV65J.js +0 -242
- package/js/chunk-ZQINWV4W.js +0 -630
- package/js/mcp/stdio.js +0 -128
- 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/storage.d.ts +0 -68
- package/types/apps/src/implementation/mcp-stdio.d.ts +0 -4
- package/types/apps/src/implementation/storage.d.ts +0 -15
- package/types/apps/src/mcp-stdio.d.ts +0 -5
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import {
|
|
2
|
+
JsonValue
|
|
3
|
+
} from "./chunk-DDHBUKXX.js";
|
|
4
|
+
import {
|
|
5
|
+
HttpApiEndpoint_exports,
|
|
6
|
+
HttpApiGroup_exports,
|
|
7
|
+
HttpApiSchema_exports,
|
|
8
|
+
HttpApi_exports
|
|
9
|
+
} from "./chunk-TUMGL2OC.js";
|
|
10
|
+
import {
|
|
11
|
+
Schema_exports
|
|
12
|
+
} from "./chunk-IFJU5SYQ.js";
|
|
13
|
+
|
|
14
|
+
// src/contracts/ui.ts
|
|
15
|
+
var UiContext = Schema_exports.Struct({
|
|
16
|
+
deployment: Schema_exports.NonEmptyString,
|
|
17
|
+
accounts: Schema_exports.optional(
|
|
18
|
+
Schema_exports.Record(Schema_exports.NonEmptyString, Schema_exports.Array(Schema_exports.NonEmptyString))
|
|
19
|
+
)
|
|
20
|
+
});
|
|
21
|
+
var UiOperation = Schema_exports.Struct({
|
|
22
|
+
...UiContext.fields,
|
|
23
|
+
name: Schema_exports.NonEmptyString,
|
|
24
|
+
input: JsonValue
|
|
25
|
+
});
|
|
26
|
+
var UiUnauthorized = class extends Schema_exports.TaggedError()(
|
|
27
|
+
"UiUnauthorized",
|
|
28
|
+
{},
|
|
29
|
+
{ httpApiStatus: 401 }
|
|
30
|
+
) {
|
|
31
|
+
};
|
|
32
|
+
var UiForbidden = class extends Schema_exports.TaggedError()(
|
|
33
|
+
"UiForbidden",
|
|
34
|
+
{},
|
|
35
|
+
{ httpApiStatus: 403 }
|
|
36
|
+
) {
|
|
37
|
+
};
|
|
38
|
+
var UiDeploymentChanged = class extends Schema_exports.TaggedError()(
|
|
39
|
+
"UiDeploymentChanged",
|
|
40
|
+
{},
|
|
41
|
+
{ httpApiStatus: 409 }
|
|
42
|
+
) {
|
|
43
|
+
};
|
|
44
|
+
var UiFailed = class extends Schema_exports.TaggedError()(
|
|
45
|
+
"UiFailed",
|
|
46
|
+
{
|
|
47
|
+
reason: Schema_exports.Literals(["unavailable", "operation_failed", "account_required"])
|
|
48
|
+
},
|
|
49
|
+
{ httpApiStatus: 422 }
|
|
50
|
+
) {
|
|
51
|
+
};
|
|
52
|
+
var UiSnapshot = Schema_exports.Union([
|
|
53
|
+
Schema_exports.Struct({
|
|
54
|
+
type: Schema_exports.Literal("snapshot"),
|
|
55
|
+
value: JsonValue,
|
|
56
|
+
trace: Schema_exports.optional(Schema_exports.Unknown)
|
|
57
|
+
}),
|
|
58
|
+
Schema_exports.Struct({ type: Schema_exports.Literal("failure"), error: UiFailed }),
|
|
59
|
+
Schema_exports.Struct({ type: Schema_exports.Literal("heartbeat") })
|
|
60
|
+
]);
|
|
61
|
+
var errors = [UiUnauthorized, UiForbidden, UiDeploymentChanged, UiFailed];
|
|
62
|
+
var AppUiApi = HttpApi_exports.make("app-ui").add(
|
|
63
|
+
HttpApiGroup_exports.make("ui").add(
|
|
64
|
+
HttpApiEndpoint_exports.post("query", "/_executor/api/query", {
|
|
65
|
+
payload: UiOperation,
|
|
66
|
+
success: JsonValue,
|
|
67
|
+
error: errors
|
|
68
|
+
})
|
|
69
|
+
).add(
|
|
70
|
+
HttpApiEndpoint_exports.post("mutate", "/_executor/api/mutate", {
|
|
71
|
+
payload: UiOperation,
|
|
72
|
+
success: JsonValue,
|
|
73
|
+
error: errors
|
|
74
|
+
})
|
|
75
|
+
).add(
|
|
76
|
+
HttpApiEndpoint_exports.post("subscribe", "/_executor/api/subscribe", {
|
|
77
|
+
payload: UiOperation,
|
|
78
|
+
success: HttpApiSchema_exports.StreamSse({ data: UiSnapshot, error: Schema_exports.Union(errors) }),
|
|
79
|
+
error: errors
|
|
80
|
+
})
|
|
81
|
+
)
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
export {
|
|
85
|
+
UiContext,
|
|
86
|
+
UiOperation,
|
|
87
|
+
UiUnauthorized,
|
|
88
|
+
UiForbidden,
|
|
89
|
+
UiDeploymentChanged,
|
|
90
|
+
UiFailed,
|
|
91
|
+
UiSnapshot,
|
|
92
|
+
AppUiApi
|
|
93
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FetchOptionUnsupported,
|
|
3
|
+
NetworkRefusedHeader,
|
|
4
|
+
RestrictedFetchOption,
|
|
5
|
+
networkRefusalHeader,
|
|
6
|
+
networkRefusalStatus,
|
|
7
|
+
supportedFetchOptions
|
|
8
|
+
} from "./chunk-6XQLA5NC.js";
|
|
9
|
+
import {
|
|
10
|
+
invocationFetch
|
|
11
|
+
} from "./chunk-QWQM3CLH.js";
|
|
12
|
+
import {
|
|
13
|
+
Effect_exports,
|
|
14
|
+
Schema_exports
|
|
15
|
+
} from "./chunk-IFJU5SYQ.js";
|
|
16
|
+
|
|
17
|
+
// src/implementation/network.ts
|
|
18
|
+
var refusalHeader = (status, header) => status === networkRefusalStatus && header !== null && header !== void 0 ? header : void 0;
|
|
19
|
+
var failOnNetworkRefusal = (response) => {
|
|
20
|
+
const header = refusalHeader(response.status, response.headers[networkRefusalHeader]);
|
|
21
|
+
return header === void 0 ? Effect_exports.void : Schema_exports.decodeUnknownEffect(NetworkRefusedHeader)(header).pipe(
|
|
22
|
+
Effect_exports.orDie,
|
|
23
|
+
Effect_exports.flatMap(Effect_exports.fail)
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
var unsupportedOption = (init) => {
|
|
27
|
+
for (const option of RestrictedFetchOption.literals) {
|
|
28
|
+
const value = init?.[option];
|
|
29
|
+
const supported = supportedFetchOptions[option];
|
|
30
|
+
if (value !== void 0 && !supported.includes(value))
|
|
31
|
+
return new FetchOptionUnsupported({ option, value: String(value), supported });
|
|
32
|
+
}
|
|
33
|
+
return void 0;
|
|
34
|
+
};
|
|
35
|
+
var appFetch = (fetch) => async (input, init) => {
|
|
36
|
+
const unsupported = unsupportedOption(init);
|
|
37
|
+
if (unsupported !== void 0) throw unsupported;
|
|
38
|
+
const response = await fetch(input, init);
|
|
39
|
+
const header = refusalHeader(response.status, response.headers.get(networkRefusalHeader));
|
|
40
|
+
if (header === void 0) return response;
|
|
41
|
+
await response.body?.cancel();
|
|
42
|
+
throw Schema_exports.decodeUnknownSync(NetworkRefusedHeader)(header);
|
|
43
|
+
};
|
|
44
|
+
var appInvocationFetch = (signal) => invocationFetch(signal).pipe(Effect_exports.map(appFetch));
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
failOnNetworkRefusal,
|
|
48
|
+
appInvocationFetch
|
|
49
|
+
};
|
|
@@ -1,48 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fromPromise
|
|
3
|
+
} from "./chunk-I5C7FD5Z.js";
|
|
1
4
|
import {
|
|
2
5
|
HostedTool,
|
|
3
6
|
RouterKey,
|
|
4
7
|
RouterMeta,
|
|
5
8
|
reservedRouterKeys
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-6XQLA5NC.js";
|
|
7
10
|
import {
|
|
8
|
-
decoderOf
|
|
9
|
-
|
|
11
|
+
decoderOf,
|
|
12
|
+
schemaArgument
|
|
13
|
+
} from "./chunk-GQ33QSNB.js";
|
|
10
14
|
import {
|
|
11
15
|
Effect_exports,
|
|
12
16
|
Schema_exports
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
|
|
15
|
-
// src/implementation/authoring.ts
|
|
16
|
-
var NativeCallback = /* @__PURE__ */ Symbol("apps.NativeCallback");
|
|
17
|
-
var fromPromise = (callback) => (...args) => {
|
|
18
|
-
if (NativeCallback in callback) {
|
|
19
|
-
const native = callback[NativeCallback];
|
|
20
|
-
return native(...args);
|
|
21
|
-
}
|
|
22
|
-
return Effect_exports.tryPromise({ try: () => callback(...args), catch: (error) => error });
|
|
23
|
-
};
|
|
24
|
-
var toPromise = (operation, signal) => {
|
|
25
|
-
const native = (...args) => Effect_exports.suspend(() => {
|
|
26
|
-
if (signal === void 0) return operation(...args);
|
|
27
|
-
if (signal.aborted) return Effect_exports.interrupt;
|
|
28
|
-
const cancelled = Effect_exports.callback((resume) => {
|
|
29
|
-
if (signal.aborted) {
|
|
30
|
-
resume(Effect_exports.interrupt);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const abort = () => resume(Effect_exports.interrupt);
|
|
34
|
-
signal.addEventListener("abort", abort, { once: true });
|
|
35
|
-
return Effect_exports.sync(() => signal.removeEventListener("abort", abort));
|
|
36
|
-
});
|
|
37
|
-
return Effect_exports.raceFirst(
|
|
38
|
-
cancelled,
|
|
39
|
-
Effect_exports.suspend(() => operation(...args))
|
|
40
|
-
);
|
|
41
|
-
});
|
|
42
|
-
return Object.assign((...args) => Effect_exports.runPromise(native(...args)), {
|
|
43
|
-
[NativeCallback]: native
|
|
44
|
-
});
|
|
45
|
-
};
|
|
17
|
+
} from "./chunk-IFJU5SYQ.js";
|
|
46
18
|
|
|
47
19
|
// src/implementation/operations.ts
|
|
48
20
|
var NativeOperation = /* @__PURE__ */ Symbol("apps.Operation");
|
|
@@ -64,31 +36,38 @@ var operationOptions = (options) => {
|
|
|
64
36
|
...options._meta === void 0 ? {} : { _meta: options._meta },
|
|
65
37
|
input: decoderOf(options.input),
|
|
66
38
|
...approval === void 0 ? {} : {
|
|
67
|
-
approval: (context) =>
|
|
39
|
+
approval: (context) => fromPromise(async () => approval(context), "approval")()
|
|
68
40
|
}
|
|
69
41
|
};
|
|
70
42
|
};
|
|
71
|
-
var
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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)
|
|
76
55
|
}
|
|
77
|
-
|
|
56
|
+
);
|
|
57
|
+
var toolAnnotations = (operation) => nativeOperation(operation)?.annotations;
|
|
78
58
|
var make = (kind, options, run) => operationDeclaration({
|
|
79
|
-
...operationOptions(options),
|
|
59
|
+
...operationOptions({ ...options, input: schemaArgument(options.input, `The ${kind} input`) }),
|
|
80
60
|
kind,
|
|
81
61
|
// The host always validates JSON serialization, even without a stronger output declaration.
|
|
82
|
-
...options.output === void 0 ? {} : { output: decoderOf(options.output) },
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
try: () => run(context, input),
|
|
87
|
-
catch: (error) => error
|
|
88
|
-
})
|
|
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)
|
|
89
66
|
});
|
|
90
67
|
var query = (options, run) => make("query", options, run);
|
|
91
|
-
|
|
68
|
+
function mutation(options, run) {
|
|
69
|
+
return make("mutation", options, run);
|
|
70
|
+
}
|
|
92
71
|
|
|
93
72
|
// src/implementation/router.ts
|
|
94
73
|
var routerDeclaration = (node) => ({
|
|
@@ -133,14 +112,14 @@ var dynamicRouter = (source) => {
|
|
|
133
112
|
return routerDeclaration({
|
|
134
113
|
kind: "dynamic",
|
|
135
114
|
...meta === void 0 ? {} : {
|
|
136
|
-
meta: () => fromPromise(async () => meta())().pipe(
|
|
115
|
+
meta: () => fromPromise(async () => meta(), "router")().pipe(
|
|
137
116
|
Effect_exports.flatMap((options) => Schema_exports.decodeUnknownEffect(RouterMeta)(options))
|
|
138
117
|
)
|
|
139
118
|
},
|
|
140
|
-
list: () => fromPromise(async () => source.list())().pipe(
|
|
119
|
+
list: () => fromPromise(async () => source.list(), "router")().pipe(
|
|
141
120
|
Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(Schema_exports.Array(HostedTool)))
|
|
142
121
|
),
|
|
143
|
-
resolve: (name) => fromPromise(async () => source.resolve(name))().pipe(
|
|
122
|
+
resolve: (name) => fromPromise(async () => source.resolve(name), "router")().pipe(
|
|
144
123
|
Effect_exports.map((value) => {
|
|
145
124
|
if (value === void 0) return void 0;
|
|
146
125
|
const operation = nativeOperation(value);
|
|
@@ -189,13 +168,87 @@ var declaredOperations = (root, path = "") => Object.entries(root?.children ?? {
|
|
|
189
168
|
return [];
|
|
190
169
|
}
|
|
191
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
|
+
};
|
|
192
246
|
|
|
193
247
|
export {
|
|
194
|
-
fromPromise,
|
|
195
|
-
toPromise,
|
|
196
248
|
operationDeclaration,
|
|
197
249
|
nativeOperation,
|
|
198
250
|
withApproval,
|
|
251
|
+
toolAnnotations,
|
|
199
252
|
query,
|
|
200
253
|
mutation,
|
|
201
254
|
routerDeclaration,
|
|
@@ -205,5 +258,7 @@ export {
|
|
|
205
258
|
dynamicRouter,
|
|
206
259
|
joinPath,
|
|
207
260
|
locate,
|
|
208
|
-
declaredOperations
|
|
261
|
+
declaredOperations,
|
|
262
|
+
withApprovals,
|
|
263
|
+
renameTools
|
|
209
264
|
};
|