apps 0.0.1-beta.4 → 0.0.1-beta.6
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 +65 -43
- package/framework-reference.json +1 -1
- package/js/{chunk-SATWJKN6.js → chunk-27F7W2LG.js} +1 -1
- package/js/{chunk-HDJH3RPR.js → chunk-57RKNWL2.js} +2 -2
- package/js/{chunk-WFSQXYUT.js → chunk-5T57N25Q.js} +15 -3
- package/js/{chunk-EQB7JMAL.js → chunk-6BSSI67S.js} +8 -8
- package/js/{chunk-3M2MEDNL.js → chunk-B3EOZTK3.js} +351 -33
- package/js/{chunk-FW5HBOIK.js → chunk-CDL5PM2Q.js} +307 -169
- package/js/{chunk-Z5NMEGJN.js → chunk-ECQFRCH4.js} +21 -9
- package/js/{chunk-G7ZIRKMK.js → chunk-IJX4CYZO.js} +3 -3
- package/js/{chunk-FDNTX5QJ.js → chunk-IPI4MFSN.js} +2 -2
- package/js/{chunk-2VPJHFOU.js → chunk-ITM77QPO.js} +28 -9
- package/js/{chunk-YEJOQEII.js → chunk-JU7VHODU.js} +1 -1
- package/js/{chunk-NQ3OMCA5.js → chunk-KUMBKVJD.js} +2 -2
- package/js/{chunk-EVJUVWN2.js → chunk-M3B3DE4K.js} +2 -2
- package/js/{chunk-ZJWDMTE3.js → chunk-MKWZPDR6.js} +3 -3
- package/js/chunk-MNMNLXBL.js +507 -0
- package/js/{chunk-BMOIAIVR.js → chunk-N7YDVXYJ.js} +49 -1
- package/js/{chunk-D47C7KG5.js → chunk-NKLWZJLE.js} +2 -2
- package/js/{chunk-DHUDODG5.js → chunk-OE3QQTSB.js} +41 -32
- package/js/{chunk-M6ZRRIBI.js → chunk-PJJ24GU7.js} +1 -1
- package/js/{chunk-FZJOYIZO.js → chunk-PZB6T6KU.js} +1 -1
- package/js/{chunk-LGIYBDWA.js → chunk-R3EV5FTO.js} +13 -1
- package/js/{chunk-5MQZEB6Y.js → chunk-RFVIONFX.js} +29 -12
- package/js/{chunk-ZCAMUXSG.js → chunk-RJDDBDSN.js} +3 -3
- package/js/{chunk-6VRYO2BG.js → chunk-SB4HEPNJ.js} +191 -170
- package/js/chunk-T7GKZBLP.js +209 -0
- package/js/{chunk-QKHR7BMF.js → chunk-UK573G7W.js} +1 -1
- package/js/{chunk-T2LAZCAD.js → chunk-VFZKSM3T.js} +1 -1
- package/js/{chunk-PLCMJREA.js → chunk-ZQINWV4W.js} +60 -20
- package/js/client.js +10 -10
- package/js/contracts.js +52 -16
- package/js/effect.js +19 -20
- package/js/graphql.js +34 -40
- package/js/host.js +19 -20
- package/js/index.js +189 -178
- package/js/mcp/effect.js +21 -22
- package/js/mcp/stdio.js +25 -26
- package/js/mcp.js +60 -45
- package/js/openapi.js +182 -224
- package/js/react.js +3 -3
- package/js/skills/effect.js +3 -3
- package/js/skills.js +12 -13
- 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 +4 -4
- package/js/ui/serving.js +8 -8
- 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/app.d.ts +2 -5
- package/types/apps/src/contracts/failure.d.ts +25 -0
- package/types/apps/src/contracts/host.d.ts +18 -9
- package/types/apps/src/contracts/mcp.d.ts +16 -0
- package/types/apps/src/contracts/openapi.d.ts +5 -1
- package/types/apps/src/contracts/operations.d.ts +0 -5
- package/types/apps/src/contracts/protocol-version.d.ts +2 -2
- package/types/apps/src/contracts/protocols/1.d.ts +15 -1
- package/types/apps/src/contracts/protocols/2.d.ts +2 -2
- package/types/apps/src/contracts/protocols/3.d.ts +676 -0
- package/types/apps/src/contracts/protocols/4.d.ts +1229 -0
- package/types/apps/src/contracts/router.d.ts +59 -0
- package/types/apps/src/contracts/storage.d.ts +3 -3
- 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/catalog-cache.d.ts +9 -2
- package/types/apps/src/implementation/elicitation.d.ts +1 -1
- package/types/apps/src/implementation/failure-detail.d.ts +25 -0
- package/types/apps/src/implementation/graphql-catalog.d.ts +1 -4
- package/types/apps/src/implementation/mcp-catalog.d.ts +1 -4
- package/types/apps/src/implementation/mcp-client.d.ts +35 -19
- package/types/apps/src/implementation/mcp.d.ts +35 -19
- package/types/apps/src/implementation/openapi-compile.d.ts +2 -1
- package/types/apps/src/implementation/openapi-source.d.ts +2 -6
- package/types/apps/src/implementation/operations.d.ts +26 -3
- package/types/apps/src/implementation/protocol-operations.d.ts +3 -4
- package/types/apps/src/implementation/router-catalog.d.ts +225 -0
- package/types/apps/src/implementation/router.d.ts +59 -0
- package/types/apps/src/implementation/schema.d.ts +5 -1
- package/types/apps/src/implementation/storage.d.ts +5 -3
- 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 +3 -2
- package/types/apps/src/mcp-stdio.d.ts +2 -5
- package/types/apps/src/mcp.d.ts +5 -4
- package/types/apps/src/openapi.d.ts +6 -6
- package/js/chunk-PYUYJRSK.js +0 -93
- package/js/chunk-SWPD52J7.js +0 -35
- package/js/chunk-W7D7WVSY.js +0 -18
- 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
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
import {
|
|
2
|
-
parseDatabaseSchema,
|
|
3
2
|
promiseTable
|
|
4
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZQINWV4W.js";
|
|
5
4
|
import {
|
|
5
|
+
declaredOperations,
|
|
6
6
|
fromPromise,
|
|
7
|
-
nativeOperation
|
|
8
|
-
|
|
7
|
+
nativeOperation,
|
|
8
|
+
nativeRouter
|
|
9
|
+
} from "./chunk-T7GKZBLP.js";
|
|
9
10
|
import {
|
|
10
11
|
ScheduleTiming
|
|
11
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-B3EOZTK3.js";
|
|
13
|
+
import {
|
|
14
|
+
DatabaseSchema
|
|
15
|
+
} from "./chunk-N7YDVXYJ.js";
|
|
12
16
|
import {
|
|
13
17
|
decoderOf,
|
|
14
18
|
isSchema,
|
|
15
19
|
storageFieldOf
|
|
16
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-5T57N25Q.js";
|
|
17
21
|
import {
|
|
18
22
|
AppStorageUnavailable
|
|
19
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-PZB6T6KU.js";
|
|
20
24
|
import {
|
|
21
25
|
JsonValue
|
|
22
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-27F7W2LG.js";
|
|
23
27
|
import {
|
|
24
28
|
Effect_exports,
|
|
25
29
|
Schema_exports
|
|
26
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
27
31
|
|
|
28
32
|
// src/implementation/workflows.ts
|
|
29
33
|
var NativeWorkflow = /* @__PURE__ */ Symbol("apps.Workflow");
|
|
@@ -48,8 +52,12 @@ var nativeWorkflow = (value) => {
|
|
|
48
52
|
var InternalApp = /* @__PURE__ */ Symbol("apps.App");
|
|
49
53
|
var isApp = (value) => typeof value === "object" && value !== null && InternalApp in value;
|
|
50
54
|
var toEffectApp = (app) => app[InternalApp];
|
|
55
|
+
function rejectCatalogs(definition) {
|
|
56
|
+
if ("queries" in definition || "mutations" in definition)
|
|
57
|
+
throw new Error("Put queries and mutations in a router under tools");
|
|
58
|
+
}
|
|
51
59
|
function adaptDefinition(definition) {
|
|
52
|
-
|
|
60
|
+
rejectCatalogs(definition);
|
|
53
61
|
const webhooks = definition.webhooks === void 0 ? {} : {
|
|
54
62
|
webhooks: Object.fromEntries(
|
|
55
63
|
Object.entries(definition.webhooks).map(([name, webhook]) => [
|
|
@@ -65,42 +73,42 @@ function adaptDefinition(definition) {
|
|
|
65
73
|
])
|
|
66
74
|
)
|
|
67
75
|
};
|
|
68
|
-
const operations = (kind, catalog) => Object.fromEntries(
|
|
69
|
-
Object.entries(catalog).map(([name, value]) => {
|
|
70
|
-
const operation = nativeOperation(value);
|
|
71
|
-
if (operation === void 0 || operation.kind !== kind)
|
|
72
|
-
throw new Error("Invalid app data operation");
|
|
73
|
-
return [name, operation];
|
|
74
|
-
})
|
|
75
|
-
);
|
|
76
76
|
const workflows = definition.workflows === void 0 ? {} : {
|
|
77
77
|
workflows: Object.fromEntries(
|
|
78
78
|
Object.entries(definition.workflows).map(([name, value]) => {
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
81
|
-
return [name,
|
|
79
|
+
const declared2 = nativeWorkflow(value);
|
|
80
|
+
if (declared2 === void 0) throw new Error("Invalid workflow declaration");
|
|
81
|
+
return [name, declared2];
|
|
82
82
|
})
|
|
83
83
|
)
|
|
84
84
|
};
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
};
|
|
85
|
+
const root = definition.tools === void 0 ? void 0 : nativeRouter(definition.tools);
|
|
86
|
+
if (definition.tools !== void 0 && root === void 0)
|
|
87
|
+
throw new Error("tools must be a router");
|
|
88
|
+
const data = root === void 0 ? {} : { tools: root };
|
|
89
|
+
const declared = root?.kind === "router" ? declaredOperations(root) : [];
|
|
90
|
+
const mutations = /* @__PURE__ */ new Set();
|
|
91
|
+
for (const { operation } of declared) {
|
|
92
|
+
if (operation.kind !== "mutation") continue;
|
|
93
|
+
if (mutations.has(operation))
|
|
94
|
+
throw new Error("A mutation can be mounted at only one path in tools");
|
|
95
|
+
mutations.add(operation);
|
|
96
|
+
}
|
|
89
97
|
const schedules = definition.schedules === void 0 ? {} : {
|
|
90
98
|
schedules: Object.fromEntries(
|
|
91
99
|
Object.entries(definition.schedules).map(([name, schedule]) => {
|
|
92
|
-
const
|
|
93
|
-
|
|
100
|
+
const target = nativeOperation(schedule.operation);
|
|
101
|
+
const match = declared.find(
|
|
102
|
+
({ operation }) => operation === target && operation.kind === "mutation"
|
|
94
103
|
);
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
throw new Error("A schedule must reference exactly one named mutation in this app");
|
|
104
|
+
if (match === void 0)
|
|
105
|
+
throw new Error("A schedule must reference a mutation in this app's tools");
|
|
98
106
|
return [
|
|
99
107
|
name,
|
|
100
108
|
{
|
|
101
109
|
timing: Schema_exports.decodeUnknownSync(ScheduleTiming)(schedule.timing),
|
|
102
110
|
input: Schema_exports.decodeUnknownSync(JsonValue)(schedule.input),
|
|
103
|
-
tool:
|
|
111
|
+
tool: match.name
|
|
104
112
|
}
|
|
105
113
|
];
|
|
106
114
|
})
|
|
@@ -115,6 +123,7 @@ function adaptDefinition(definition) {
|
|
|
115
123
|
};
|
|
116
124
|
}
|
|
117
125
|
var defineApp = (requirements, definition) => {
|
|
126
|
+
if (typeof definition !== "function") rejectCatalogs(definition);
|
|
118
127
|
const evaluate = typeof definition === "function" ? definition : async () => definition;
|
|
119
128
|
const factory = fromPromise(evaluate);
|
|
120
129
|
const native = {
|
|
@@ -152,7 +161,7 @@ var serialize = (tables) => {
|
|
|
152
161
|
}
|
|
153
162
|
])
|
|
154
163
|
);
|
|
155
|
-
return
|
|
164
|
+
return Schema_exports.decodeUnknownSync(DatabaseSchema)(definitions);
|
|
156
165
|
};
|
|
157
166
|
var authorDatabase = (tables, session, signal, writable) => {
|
|
158
167
|
return Object.fromEntries(
|
|
@@ -58,7 +58,7 @@ import {
|
|
|
58
58
|
useSpan,
|
|
59
59
|
void_2 as void_,
|
|
60
60
|
withFiber
|
|
61
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
62
62
|
|
|
63
63
|
// ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect+effect@c7d1ffff31a3e2ae0b0b+a654a55b752bdb24/node_modules/effect/dist/unstable/reactivity/Reactivity.js
|
|
64
64
|
var TypeId = "~effect/reactivity/Reactivity";
|
|
@@ -1,6 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AccountId
|
|
3
|
+
} from "./chunk-27F7W2LG.js";
|
|
1
4
|
import {
|
|
2
5
|
Schema_exports
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
7
|
+
|
|
8
|
+
// src/contracts/provider-error.ts
|
|
9
|
+
var ProviderError = class extends Schema_exports.TaggedError()("ProviderError", {
|
|
10
|
+
reason: Schema_exports.Literals(["unauthorized", "forbidden", "rate_limited", "unavailable", "rejected"]),
|
|
11
|
+
status: Schema_exports.optional(Schema_exports.Int.check(Schema_exports.isBetween({ minimum: 100, maximum: 599 }))),
|
|
12
|
+
accountId: Schema_exports.optional(AccountId)
|
|
13
|
+
}) {
|
|
14
|
+
};
|
|
4
15
|
|
|
5
16
|
// ../app-cache/src/contracts/cache.ts
|
|
6
17
|
var CacheError = class extends Schema_exports.TaggedError()("CacheError", {
|
|
@@ -76,6 +87,7 @@ var CacheReply = Schema_exports.Union([
|
|
|
76
87
|
]);
|
|
77
88
|
|
|
78
89
|
export {
|
|
90
|
+
ProviderError,
|
|
79
91
|
CacheError,
|
|
80
92
|
cacheLimits,
|
|
81
93
|
CacheEntry,
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CacheError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-R3EV5FTO.js";
|
|
4
4
|
import {
|
|
5
5
|
wrap
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-5T57N25Q.js";
|
|
7
7
|
import {
|
|
8
8
|
JsonObject
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-27F7W2LG.js";
|
|
10
10
|
import {
|
|
11
11
|
Duration_exports,
|
|
12
12
|
Effect_exports,
|
|
13
13
|
Schema_exports
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
15
15
|
|
|
16
16
|
// src/implementation/catalog-cache.ts
|
|
17
17
|
var schema = (decoder) => wrap(decoder, false);
|
|
18
18
|
var Manifest = Schema_exports.Struct({
|
|
19
19
|
revision: Schema_exports.String,
|
|
20
20
|
pages: Schema_exports.Int,
|
|
21
|
-
summaries: Schema_exports.Int
|
|
21
|
+
summaries: Schema_exports.Int,
|
|
22
|
+
header: Schema_exports.optionalKey(JsonObject)
|
|
22
23
|
});
|
|
23
24
|
var invoke = (work) => Effect_exports.tryPromise({ try: work, catch: (error) => error });
|
|
24
25
|
var catalogCache = (options) => Effect_exports.gen(function* () {
|
|
@@ -35,9 +36,12 @@ var catalogCache = (options) => Effect_exports.gen(function* () {
|
|
|
35
36
|
const retention = Duration_exports.toMillis(Duration_exports.fromInputUnsafe(freshFor)) + Duration_exports.toMillis(Duration_exports.fromInputUnsafe(staleFor)) + 3e5;
|
|
36
37
|
const local = yield* Effect_exports.cached(options.load());
|
|
37
38
|
const refresh = (context) => Effect_exports.gen(function* () {
|
|
38
|
-
const tools = yield* options.load(context);
|
|
39
|
+
const { tools, header } = yield* options.load(context);
|
|
39
40
|
const digest = yield* invoke(
|
|
40
|
-
() => crypto.subtle.digest(
|
|
41
|
+
() => crypto.subtle.digest(
|
|
42
|
+
"SHA-256",
|
|
43
|
+
new TextEncoder().encode(JSON.stringify({ tools, header: header ?? null }))
|
|
44
|
+
)
|
|
41
45
|
);
|
|
42
46
|
const revision = Array.from(
|
|
43
47
|
new Uint8Array(digest),
|
|
@@ -104,7 +108,12 @@ var catalogCache = (options) => Effect_exports.gen(function* () {
|
|
|
104
108
|
yield* pageOut();
|
|
105
109
|
yield* summaryOut();
|
|
106
110
|
yield* flush();
|
|
107
|
-
return {
|
|
111
|
+
return {
|
|
112
|
+
revision,
|
|
113
|
+
pages: pages2,
|
|
114
|
+
summaries,
|
|
115
|
+
...header === void 0 ? {} : { header: yield* json(header) }
|
|
116
|
+
};
|
|
108
117
|
});
|
|
109
118
|
const getOptions = {
|
|
110
119
|
key,
|
|
@@ -113,7 +122,12 @@ var catalogCache = (options) => Effect_exports.gen(function* () {
|
|
|
113
122
|
staleFor,
|
|
114
123
|
load: (context) => Effect_exports.runPromise(refresh(context), { signal: context.signal })
|
|
115
124
|
};
|
|
116
|
-
|
|
125
|
+
let reading;
|
|
126
|
+
const current = () => cache === void 0 ? Effect_exports.fail(new CacheError({ reason: "unavailable" })) : invoke(
|
|
127
|
+
() => reading ??= cache.get(getOptions).finally(() => {
|
|
128
|
+
reading = void 0;
|
|
129
|
+
})
|
|
130
|
+
);
|
|
117
131
|
if (options.revalidate) {
|
|
118
132
|
if (cache === void 0) yield* local;
|
|
119
133
|
else yield* invoke(() => cache.revalidate(getOptions));
|
|
@@ -140,14 +154,17 @@ var catalogCache = (options) => Effect_exports.gen(function* () {
|
|
|
140
154
|
return values;
|
|
141
155
|
});
|
|
142
156
|
const metadata = () => Effect_exports.gen(function* () {
|
|
143
|
-
if (cache === void 0) return yield* local;
|
|
157
|
+
if (cache === void 0) return (yield* local).tools;
|
|
144
158
|
const manifest = yield* current();
|
|
145
159
|
return yield* pages(cache, manifest.revision, "page", manifest.pages, options.schema);
|
|
146
160
|
});
|
|
147
161
|
return {
|
|
148
162
|
list: metadata,
|
|
163
|
+
/** The record stored with the current revision, if the source supplied one. */
|
|
164
|
+
header: () => cache === void 0 ? local.pipe(Effect_exports.map(({ header }) => header)) : current().pipe(Effect_exports.map((manifest) => manifest.header)),
|
|
149
165
|
summaries: () => Effect_exports.gen(function* () {
|
|
150
|
-
if (cache === void 0)
|
|
166
|
+
if (cache === void 0)
|
|
167
|
+
return (yield* local).tools.map((tool) => options.summary.of(tool));
|
|
151
168
|
const manifest = yield* current();
|
|
152
169
|
return yield* pages(
|
|
153
170
|
cache,
|
|
@@ -157,7 +174,7 @@ var catalogCache = (options) => Effect_exports.gen(function* () {
|
|
|
157
174
|
options.summary.schema
|
|
158
175
|
);
|
|
159
176
|
}),
|
|
160
|
-
resolve: (name) => cache === void 0 ? local.pipe(Effect_exports.map((tools) => tools.find((tool) => tool.name === name))) : current().pipe(
|
|
177
|
+
resolve: (name) => cache === void 0 ? local.pipe(Effect_exports.map(({ tools }) => tools.find((tool) => tool.name === name))) : current().pipe(
|
|
161
178
|
Effect_exports.flatMap(
|
|
162
179
|
(manifest) => invoke(
|
|
163
180
|
() => cache.read(part(manifest.revision, "tool", name), schema(options.schema))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FetchHttpClient_exports
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-57RKNWL2.js";
|
|
4
4
|
import {
|
|
5
5
|
HttpBody_exports,
|
|
6
6
|
HttpClient,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
setBody,
|
|
19
19
|
transformResponse,
|
|
20
20
|
uint8Array
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-UK573G7W.js";
|
|
22
22
|
import {
|
|
23
23
|
Array as Array2,
|
|
24
24
|
Boolean2 as Boolean,
|
|
@@ -125,7 +125,7 @@ import {
|
|
|
125
125
|
withDefault2 as withDefault,
|
|
126
126
|
withTracerEnabled,
|
|
127
127
|
zero
|
|
128
|
-
} from "./chunk-
|
|
128
|
+
} from "./chunk-CDL5PM2Q.js";
|
|
129
129
|
import {
|
|
130
130
|
__export
|
|
131
131
|
} from "./chunk-CZ7CSFO4.js";
|