@feltdb/feltkit 0.3.5 → 0.3.7
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/appboundry/engine.wasm +0 -0
- package/dist/appboundry/build.d.ts +106 -0
- package/dist/appboundry/build.js +306 -0
- package/dist/appboundry/build.js.map +1 -0
- package/dist/appboundry/codec.d.ts +6 -0
- package/dist/appboundry/codec.js +98 -0
- package/dist/appboundry/codec.js.map +1 -0
- package/dist/appboundry/guest-index.d.ts +9 -0
- package/dist/appboundry/guest-index.js +10 -0
- package/dist/appboundry/guest-index.js.map +1 -0
- package/dist/appboundry/guest.d.ts +3 -0
- package/dist/appboundry/guest.js +300 -0
- package/dist/appboundry/guest.js.map +1 -0
- package/dist/appboundry/wasm.d.ts +12 -0
- package/dist/appboundry/wasm.js +68 -0
- package/dist/appboundry/wasm.js.map +1 -0
- package/dist/cli/deploy.d.ts +1 -1
- package/dist/cli/deploy.js +19 -11
- package/dist/cli/deploy.js.map +1 -1
- package/dist/cli/main.d.ts +6 -1
- package/dist/cli/main.js +145 -46
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/vercel.d.ts +20 -4
- package/dist/cli/vercel.js +38 -22
- package/dist/cli/vercel.js.map +1 -1
- package/dist/dashboard/assets/index-OfCJSyfP.js +15 -0
- package/dist/dashboard/assets/index-dGaQg6ak.css +1 -0
- package/dist/dashboard/index.html +3 -3
- package/dist/dashboard/theme.js +9 -4
- package/dist/runtime/assemble.d.ts +2 -0
- package/dist/runtime/assemble.js +45 -0
- package/dist/runtime/assemble.js.map +1 -0
- package/dist/runtime/capabilities.d.ts +2 -0
- package/dist/runtime/capabilities.js +24 -0
- package/dist/runtime/capabilities.js.map +1 -0
- package/dist/runtime/collections.d.ts +7 -0
- package/dist/runtime/collections.js +18 -0
- package/dist/runtime/collections.js.map +1 -0
- package/dist/runtime/data.d.ts +2 -6
- package/dist/runtime/data.js +2 -16
- package/dist/runtime/data.js.map +1 -1
- package/dist/runtime/deployment.d.ts +48 -0
- package/dist/runtime/deployment.js +141 -0
- package/dist/runtime/deployment.js.map +1 -0
- package/dist/runtime/loader.d.ts +2 -1
- package/dist/runtime/loader.js +2 -38
- package/dist/runtime/loader.js.map +1 -1
- package/dist/runtime/projects.d.ts +16 -0
- package/dist/runtime/projects.js +8 -1
- package/dist/runtime/projects.js.map +1 -1
- package/dist/runtime/runtime.js +16 -28
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/server/admin.js +10 -0
- package/dist/server/admin.js.map +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/production.d.ts +61 -0
- package/dist/server/production.js +113 -0
- package/dist/server/production.js.map +1 -0
- package/dist/server/project.d.ts +1 -1
- package/dist/server/project.js +2 -1
- package/dist/server/project.js.map +1 -1
- package/package.json +6 -2
- package/skills/.claude-plugin/marketplace.json +1 -1
- package/skills/.claude-plugin/plugin.json +1 -1
- package/skills/feltkit-operations/SKILL.md +6 -0
- package/dist/dashboard/assets/index-B-ra0AY9.css +0 -1
- package/dist/dashboard/assets/index-DnJaSnzt.js +0 -15
|
Binary file
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { FeltKitApp } from "../app.js";
|
|
2
|
+
import { GUEST_ABI } from "./guest.js";
|
|
3
|
+
export declare const ARTIFACT_FORMAT = "appboundry.app/1";
|
|
4
|
+
/** Host interfaces the program uses, with the version of each. */
|
|
5
|
+
export declare const HOST_INTERFACES: {
|
|
6
|
+
readonly collections: 1;
|
|
7
|
+
readonly services: 1;
|
|
8
|
+
readonly identity: 1;
|
|
9
|
+
readonly web: 1;
|
|
10
|
+
};
|
|
11
|
+
export interface AppBoundryBuildResult {
|
|
12
|
+
path: string;
|
|
13
|
+
manifest: ArtifactManifest;
|
|
14
|
+
/** Things the application configures that the artifact does not carry. */
|
|
15
|
+
omitted: string[];
|
|
16
|
+
}
|
|
17
|
+
export interface ArtifactManifest {
|
|
18
|
+
format: typeof ARTIFACT_FORMAT;
|
|
19
|
+
runtime: {
|
|
20
|
+
abi: typeof GUEST_ABI;
|
|
21
|
+
interfaces: typeof HOST_INTERFACES;
|
|
22
|
+
};
|
|
23
|
+
producer: {
|
|
24
|
+
name: "feltkit";
|
|
25
|
+
version: string;
|
|
26
|
+
};
|
|
27
|
+
application: {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
version: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
};
|
|
33
|
+
module: {
|
|
34
|
+
path: "module.wasm";
|
|
35
|
+
sha256: string;
|
|
36
|
+
size: number;
|
|
37
|
+
imports: [];
|
|
38
|
+
program: {
|
|
39
|
+
section: string;
|
|
40
|
+
sha256: string;
|
|
41
|
+
size: number;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
functions: Array<{
|
|
45
|
+
name: string;
|
|
46
|
+
kind: "query" | "mutation";
|
|
47
|
+
access: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
args: unknown;
|
|
50
|
+
returns?: unknown;
|
|
51
|
+
capability?: {
|
|
52
|
+
name: string;
|
|
53
|
+
version: number;
|
|
54
|
+
};
|
|
55
|
+
}>;
|
|
56
|
+
collections: Array<{
|
|
57
|
+
name: string;
|
|
58
|
+
schema: unknown;
|
|
59
|
+
description?: string;
|
|
60
|
+
}>;
|
|
61
|
+
identity: {
|
|
62
|
+
roles: Record<string, string[]>;
|
|
63
|
+
devUsers: Array<{
|
|
64
|
+
id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
roles: string[];
|
|
67
|
+
type: string;
|
|
68
|
+
}>;
|
|
69
|
+
sessionTtlMs: number;
|
|
70
|
+
};
|
|
71
|
+
services: Record<string, Record<string, unknown>>;
|
|
72
|
+
permissions: {
|
|
73
|
+
collections: {
|
|
74
|
+
read: string[];
|
|
75
|
+
write: string[];
|
|
76
|
+
};
|
|
77
|
+
services: string[];
|
|
78
|
+
network: "none";
|
|
79
|
+
filesystem: "none";
|
|
80
|
+
};
|
|
81
|
+
appport: unknown;
|
|
82
|
+
frontend: null | {
|
|
83
|
+
root: "assets";
|
|
84
|
+
entry: string;
|
|
85
|
+
files: Array<{
|
|
86
|
+
path: string;
|
|
87
|
+
sha256: string;
|
|
88
|
+
size: number;
|
|
89
|
+
contentType: string;
|
|
90
|
+
}>;
|
|
91
|
+
};
|
|
92
|
+
omitted: string[];
|
|
93
|
+
}
|
|
94
|
+
export declare function enginePath(): string;
|
|
95
|
+
/** Uses of FeltKit features an artifact cannot provide, with their source location. */
|
|
96
|
+
export declare function unsupportedUses(projectDir: string, app: FeltKitApp): string[];
|
|
97
|
+
/**
|
|
98
|
+
* Compile a built project (after `build()`: .feltkit/build/functions.mjs and dist/client)
|
|
99
|
+
* into `<outDir>/<name>.app`.
|
|
100
|
+
*/
|
|
101
|
+
export declare function buildAppBoundry(projectDirInput: string, options: {
|
|
102
|
+
bundle: string;
|
|
103
|
+
client: string | null;
|
|
104
|
+
producerVersion: string;
|
|
105
|
+
outDir?: string;
|
|
106
|
+
}): Promise<AppBoundryBuildResult>;
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `feltkit build --target appboundry`: compile an application into an AppBoundry
|
|
3
|
+
* artifact, a directory AppBoundry runs with nothing else:
|
|
4
|
+
*
|
|
5
|
+
* <name>.app/
|
|
6
|
+
* manifest.json what the application is and what the host may do for it
|
|
7
|
+
* module.wasm the guest engine with the application program in its
|
|
8
|
+
* `appboundry.program` section (imports nothing)
|
|
9
|
+
* assets/ the built frontend, each file hashed in the manifest
|
|
10
|
+
*
|
|
11
|
+
* Everything in the manifest comes from the loaded application itself: functions,
|
|
12
|
+
* collections and roles from its definitions, and the AppPort contract from the same
|
|
13
|
+
* capability definitions the FeltKit runtime serves (runtime/capabilities.ts). There is
|
|
14
|
+
* no second, hand-maintained description.
|
|
15
|
+
*
|
|
16
|
+
* What an artifact cannot do is refused here, with where and why, rather than built
|
|
17
|
+
* into something that behaves differently at run time.
|
|
18
|
+
*/
|
|
19
|
+
import { createApplication } from "@appport/sdk";
|
|
20
|
+
import { createHash } from "node:crypto";
|
|
21
|
+
import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
22
|
+
import { dirname, extname, join, relative, resolve } from "node:path";
|
|
23
|
+
import { fileURLToPath } from "node:url";
|
|
24
|
+
import { FeltKitError } from "../errors.js";
|
|
25
|
+
import { capabilityDefinition } from "../runtime/capabilities.js";
|
|
26
|
+
import { backendModules, loadBundle } from "../runtime/loader.js";
|
|
27
|
+
import { GUEST_ABI } from "./guest.js";
|
|
28
|
+
import { appendCustomSection, customSections, PROGRAM_SECTION } from "./wasm.js";
|
|
29
|
+
export const ARTIFACT_FORMAT = "appboundry.app/1";
|
|
30
|
+
/** Host interfaces the program uses, with the version of each. */
|
|
31
|
+
export const HOST_INTERFACES = { collections: 1, services: 1, identity: 1, web: 1 };
|
|
32
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
33
|
+
/** src/appboundry or dist/appboundry → the package root. */
|
|
34
|
+
const PACKAGE_ROOT = resolve(HERE, "..", "..");
|
|
35
|
+
const SERVICES_IN_CODE = ["files", "notifications", "configuration", "jobs", "webhooks"];
|
|
36
|
+
const DEFAULT_SESSION_TTL_MS = 7 * 24 * 60 * 60 * 1000;
|
|
37
|
+
const sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
38
|
+
export function enginePath() {
|
|
39
|
+
return join(PACKAGE_ROOT, "appboundry", "engine.wasm");
|
|
40
|
+
}
|
|
41
|
+
/** Comments and string literals removed, newlines kept, so a match still has its line. */
|
|
42
|
+
function codeOnly(source) {
|
|
43
|
+
return source.replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*|`(?:\\[\s\S]|[^\\`])*`|"(?:\\.|[^\\"\n])*"|'(?:\\.|[^\\'\n])*'/g, (match) => match.replace(/[^\n]/g, " "));
|
|
44
|
+
}
|
|
45
|
+
/** Uses of FeltKit features an artifact cannot provide, with their source location. */
|
|
46
|
+
export function unsupportedUses(projectDir, app) {
|
|
47
|
+
const problems = [];
|
|
48
|
+
const checks = [
|
|
49
|
+
[/\.\s*unsafe\b/g, "ctx.unsafe.feltdb writes FeltDB directly, around the host's validation and transactions. An artifact's state is reached only through ctx.db; use ctx.db instead."],
|
|
50
|
+
[/\.\s*agent\b/g, "ctx.agent starts work for FeltKit's agent, which runs in the FeltKit server, not in an artifact. Keep agent work in a FeltKit deployment, or remove it before building for AppBoundry."],
|
|
51
|
+
];
|
|
52
|
+
for (const module of backendModules(projectDir)) {
|
|
53
|
+
const code = codeOnly(readFileSync(module.path, "utf8"));
|
|
54
|
+
for (const [pattern, why] of checks) {
|
|
55
|
+
for (const match of code.matchAll(pattern)) {
|
|
56
|
+
const line = code.slice(0, match.index).split("\n").length;
|
|
57
|
+
problems.push(`${relative(projectDir, module.path)}:${line}: ${why}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (app.integrations.size) {
|
|
62
|
+
problems.push(`app.integration(${[...app.integrations.keys()].map((n) => JSON.stringify(n)).join(", ")}): integrations call external HTTP APIs, and an artifact has no network access. Run this application with FeltKit, or remove the integration.`);
|
|
63
|
+
}
|
|
64
|
+
if (app.options.auth?.authenticate) {
|
|
65
|
+
problems.push("feltkit({ auth: { authenticate } }): the identity hook is not yet supported by the AppBoundry target. Identity in an artifact comes from AppBoundry sessions.");
|
|
66
|
+
}
|
|
67
|
+
return problems;
|
|
68
|
+
}
|
|
69
|
+
function contentType(path) {
|
|
70
|
+
const types = {
|
|
71
|
+
".html": "text/html; charset=utf-8",
|
|
72
|
+
".js": "text/javascript; charset=utf-8",
|
|
73
|
+
".mjs": "text/javascript; charset=utf-8",
|
|
74
|
+
".css": "text/css; charset=utf-8",
|
|
75
|
+
".json": "application/json",
|
|
76
|
+
".svg": "image/svg+xml",
|
|
77
|
+
".png": "image/png",
|
|
78
|
+
".jpg": "image/jpeg",
|
|
79
|
+
".jpeg": "image/jpeg",
|
|
80
|
+
".gif": "image/gif",
|
|
81
|
+
".webp": "image/webp",
|
|
82
|
+
".ico": "image/x-icon",
|
|
83
|
+
".woff": "font/woff",
|
|
84
|
+
".woff2": "font/woff2",
|
|
85
|
+
".txt": "text/plain; charset=utf-8",
|
|
86
|
+
".map": "application/json",
|
|
87
|
+
".webmanifest": "application/manifest+json",
|
|
88
|
+
};
|
|
89
|
+
return types[extname(path).toLowerCase()] ?? "application/octet-stream";
|
|
90
|
+
}
|
|
91
|
+
function files(dir, base = dir) {
|
|
92
|
+
return readdirSync(dir, { withFileTypes: true })
|
|
93
|
+
.flatMap((entry) => (entry.isDirectory() ? files(join(dir, entry.name), base) : [relative(base, join(dir, entry.name)).split("\\").join("/")]))
|
|
94
|
+
.sort();
|
|
95
|
+
}
|
|
96
|
+
/** The application program: the guest runtime and the application's modules, for an engine with only ECMAScript. */
|
|
97
|
+
async function bundleProgram(projectDir, producer) {
|
|
98
|
+
const modules = backendModules(projectDir);
|
|
99
|
+
const guest = existsSync(join(HERE, "guest.js")) ? join(HERE, "guest.js") : join(HERE, "guest.ts");
|
|
100
|
+
const guestIndex = existsSync(join(HERE, "guest-index.js")) ? join(HERE, "guest-index.js") : join(HERE, "guest-index.ts");
|
|
101
|
+
const source = [
|
|
102
|
+
...modules.map((m, i) => `import * as m${i} from ${JSON.stringify(m.path)};`),
|
|
103
|
+
`import { installGuest } from ${JSON.stringify(guest)};`,
|
|
104
|
+
`installGuest({ ${modules.map((m, i) => `${JSON.stringify(m.name)}: m${i}`).join(", ")} }, ${JSON.stringify(producer)});`,
|
|
105
|
+
].join("\n");
|
|
106
|
+
const esbuild = await import("esbuild");
|
|
107
|
+
try {
|
|
108
|
+
const result = await esbuild.build({
|
|
109
|
+
stdin: { contents: source, resolveDir: projectDir, sourcefile: "appboundry-entry.ts", loader: "ts" },
|
|
110
|
+
bundle: true,
|
|
111
|
+
write: false,
|
|
112
|
+
platform: "neutral",
|
|
113
|
+
format: "iife",
|
|
114
|
+
target: "es2022",
|
|
115
|
+
mainFields: ["module", "main"],
|
|
116
|
+
conditions: ["import", "default"],
|
|
117
|
+
logLevel: "silent",
|
|
118
|
+
plugins: [
|
|
119
|
+
{
|
|
120
|
+
name: "feltkit-guest",
|
|
121
|
+
setup(build) {
|
|
122
|
+
build.onResolve({ filter: /^@feltdb\/feltkit(\/.*)?$/ }, (args) => {
|
|
123
|
+
if (args.path === "@feltdb/feltkit")
|
|
124
|
+
return { path: guestIndex };
|
|
125
|
+
return { errors: [{ text: `${args.path} is not available inside an AppBoundry artifact; backend code may import only "@feltdb/feltkit".` }] };
|
|
126
|
+
});
|
|
127
|
+
// FeltKit's own entry, however it is reached (a workspace or a relative path), is the guest's.
|
|
128
|
+
const entries = new Set([join(PACKAGE_ROOT, "src", "index.ts"), join(PACKAGE_ROOT, "src", "index.js"), join(PACKAGE_ROOT, "dist", "index.js")]);
|
|
129
|
+
build.onResolve({ filter: /(^|\/)index(\.js|\.ts)?$/ }, (args) => {
|
|
130
|
+
if (!args.path.startsWith("."))
|
|
131
|
+
return undefined;
|
|
132
|
+
const target = resolve(args.resolveDir, args.path);
|
|
133
|
+
const candidates = [target, target.replace(/\.js$/, ".ts"), `${target}.ts`, `${target}.js`];
|
|
134
|
+
return candidates.some((c) => entries.has(c)) ? { path: guestIndex } : undefined;
|
|
135
|
+
});
|
|
136
|
+
build.onResolve({ filter: /^node:|^(fs|path|os|crypto|http|https|net|child_process|worker_threads|url|stream|zlib|process)$/ }, (args) => ({
|
|
137
|
+
errors: [{ text: `${args.path} is a Node API. An artifact runs without Node, a filesystem, or a network: backend code reaches state and services only through ctx.` }],
|
|
138
|
+
}));
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
});
|
|
143
|
+
return result.outputFiles[0].text;
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
const errors = error.errors ?? [];
|
|
147
|
+
const lines = errors.map((e) => `${e.location ? `${relative(projectDir, e.location.file)}:${e.location.line}: ` : ""}${e.text}`);
|
|
148
|
+
throw new FeltKitError("CONFIGURATION", `The application cannot be compiled for AppBoundry:\n ${lines.join("\n ") || error.message}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/** Run the module the way AppBoundry will load it, and check it describes exactly the built application. */
|
|
152
|
+
async function verifyModule(module, project) {
|
|
153
|
+
const compiled = new WebAssembly.Module(module);
|
|
154
|
+
const imports = WebAssembly.Module.imports(compiled);
|
|
155
|
+
if (imports.length)
|
|
156
|
+
throw new FeltKitError("INTERNAL", `module.wasm imports ${imports.map((i) => `${i.module}.${i.name}`).join(", ")}; an artifact module must import nothing.`);
|
|
157
|
+
const instance = new WebAssembly.Instance(compiled, {});
|
|
158
|
+
const x = instance.exports;
|
|
159
|
+
const program = customSections(module).find((s) => s.name === PROGRAM_SECTION).payload;
|
|
160
|
+
x.abg_clock(Date.now());
|
|
161
|
+
const pointer = x.abg_alloc(program.length);
|
|
162
|
+
new Uint8Array(x.memory.buffer, pointer, program.length).set(program);
|
|
163
|
+
const packed = BigInt(x.abg_init(pointer, program.length));
|
|
164
|
+
const text = new TextDecoder().decode(new Uint8Array(x.memory.buffer, Number(packed >> 32n), Number(packed & 0xffffffffn)).slice());
|
|
165
|
+
const described = JSON.parse(text);
|
|
166
|
+
if (!described.ok)
|
|
167
|
+
throw new FeltKitError("CONFIGURATION", `The compiled program did not load in the guest engine: ${described.error?.message ?? text}`);
|
|
168
|
+
const inGuest = (described.functions ?? []).map((f) => `${f.name}/${f.kind}`).join(",");
|
|
169
|
+
const built = [...project.functions.entries()].map(([name, fn]) => `${name}/${fn.kind}`).sort().join(",");
|
|
170
|
+
if (inGuest !== built)
|
|
171
|
+
throw new FeltKitError("INTERNAL", `The compiled program defines different functions than the build:\n guest: ${inGuest}\n build: ${built}`);
|
|
172
|
+
}
|
|
173
|
+
function servicesManifest(app) {
|
|
174
|
+
const config = app.options.services ?? {};
|
|
175
|
+
const services = {};
|
|
176
|
+
const omitted = [];
|
|
177
|
+
const options = (value) => (typeof value === "object" && value ? { ...value } : {});
|
|
178
|
+
if (config.files)
|
|
179
|
+
services.files = { maxBytes: options(config.files).maxBytes ?? 1024 * 1024 };
|
|
180
|
+
if (config.notifications)
|
|
181
|
+
services.notifications = { types: options(config.notifications).types ?? [] };
|
|
182
|
+
if (config.configuration)
|
|
183
|
+
services.configuration = {};
|
|
184
|
+
if (config.jobs)
|
|
185
|
+
services.jobs = { handlers: options(config.jobs).handlers ?? {} };
|
|
186
|
+
if (config.webhooks)
|
|
187
|
+
services.webhooks = { events: options(config.webhooks).events ?? [] };
|
|
188
|
+
if (config.apiKeys)
|
|
189
|
+
omitted.push("services.apiKeys: API keys are issued and verified by a FeltKit server; artifact identity comes from AppBoundry sessions.");
|
|
190
|
+
if (config.schedules)
|
|
191
|
+
omitted.push("services.schedules: recurring jobs are created in FeltKit Studio, which is not part of an artifact.");
|
|
192
|
+
if (config.intelligence)
|
|
193
|
+
omitted.push("services.intelligence: model selection serves FeltKit's agent, which does not run in an artifact.");
|
|
194
|
+
if (config.webhooks)
|
|
195
|
+
omitted.push("webhook delivery: emit() records events, but an artifact has no network access, so AppBoundry does not deliver them to endpoints.");
|
|
196
|
+
for (const [type, fn] of Object.entries((services.jobs?.handlers ?? {}))) {
|
|
197
|
+
if (!/^[\w/-]+:[\w]+$/.test(fn))
|
|
198
|
+
throw new FeltKitError("CONFIGURATION", `services.jobs.handlers["${type}"] must name a function as "<module>:<export>" (got ${JSON.stringify(fn)}).`);
|
|
199
|
+
}
|
|
200
|
+
return { services, omitted };
|
|
201
|
+
}
|
|
202
|
+
function functionsManifest(project) {
|
|
203
|
+
return [...project.functions.entries()]
|
|
204
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
205
|
+
.map(([name, fn]) => ({
|
|
206
|
+
name,
|
|
207
|
+
kind: fn.kind,
|
|
208
|
+
access: fn.access,
|
|
209
|
+
...(fn.description ? { description: fn.description } : {}),
|
|
210
|
+
args: fn.argsSchema.toJSONSchema(),
|
|
211
|
+
...(fn.returns ? { returns: fn.returns.toJSONSchema() } : {}),
|
|
212
|
+
...(fn.capability ? { capability: { name: fn.capability.name, version: fn.capability.version } } : {}),
|
|
213
|
+
}));
|
|
214
|
+
}
|
|
215
|
+
async function appportContract(project) {
|
|
216
|
+
const { app } = project;
|
|
217
|
+
const capabilities = [...project.functions.entries()]
|
|
218
|
+
.filter(([, fn]) => fn.capability)
|
|
219
|
+
.map(([name, fn]) => capabilityDefinition(name, fn, async () => {
|
|
220
|
+
throw new Error("contract only");
|
|
221
|
+
}));
|
|
222
|
+
const application = createApplication({
|
|
223
|
+
application: { id: app.name, name: app.name, version: app.options.version ?? "0.0.0", ...(app.options.description ? { description: app.options.description } : {}) },
|
|
224
|
+
capabilities,
|
|
225
|
+
});
|
|
226
|
+
return JSON.parse(JSON.stringify(await application.manifest()));
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Compile a built project (after `build()`: .feltkit/build/functions.mjs and dist/client)
|
|
230
|
+
* into `<outDir>/<name>.app`.
|
|
231
|
+
*/
|
|
232
|
+
export async function buildAppBoundry(projectDirInput, options) {
|
|
233
|
+
const projectDir = resolve(projectDirInput);
|
|
234
|
+
const project = await loadBundle(options.bundle);
|
|
235
|
+
const { app } = project;
|
|
236
|
+
const problems = unsupportedUses(projectDir, app);
|
|
237
|
+
if (problems.length) {
|
|
238
|
+
throw new FeltKitError("CONFIGURATION", `This application uses FeltKit features an AppBoundry artifact cannot provide:\n ${problems.join("\n ")}`, {
|
|
239
|
+
hint: "Each one names where it is used. The artifact would behave differently from your application, so nothing was built.",
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
for (const [type, fn] of Object.entries((typeof app.options.services?.jobs === "object" ? app.options.services.jobs.handlers : undefined) ?? {})) {
|
|
243
|
+
const target = project.functions.get(fn);
|
|
244
|
+
if (!target || target.kind !== "mutation")
|
|
245
|
+
throw new FeltKitError("CONFIGURATION", `services.jobs.handlers["${type}"] names ${fn}, which is not a mutation of this application.`);
|
|
246
|
+
}
|
|
247
|
+
const producer = `feltkit/${options.producerVersion}`;
|
|
248
|
+
const program = new TextEncoder().encode(await bundleProgram(projectDir, producer));
|
|
249
|
+
const engine = new Uint8Array(readFileSync(enginePath()));
|
|
250
|
+
const module = appendCustomSection(engine, PROGRAM_SECTION, program);
|
|
251
|
+
await verifyModule(module, project);
|
|
252
|
+
const { services, omitted } = servicesManifest(app);
|
|
253
|
+
omitted.unshift("FeltKit Studio (the development dashboard) and the MCP endpoint are served by FeltKit, not by an artifact.");
|
|
254
|
+
if (app.options.agent?.decisions)
|
|
255
|
+
omitted.push("agent.decisions: FeltKit's agent does not run in an artifact.");
|
|
256
|
+
const outDir = resolve(options.outDir ?? projectDir);
|
|
257
|
+
const path = join(outDir, `${app.name}.app`);
|
|
258
|
+
if (existsSync(path)) {
|
|
259
|
+
if (!existsSync(join(path, "manifest.json")))
|
|
260
|
+
throw new FeltKitError("CONFLICT", `${path} exists and is not an AppBoundry artifact; refusing to replace it.`);
|
|
261
|
+
rmSync(path, { recursive: true, force: true });
|
|
262
|
+
}
|
|
263
|
+
mkdirSync(path, { recursive: true });
|
|
264
|
+
writeFileSync(join(path, "module.wasm"), module);
|
|
265
|
+
let frontend = null;
|
|
266
|
+
if (options.client && existsSync(options.client) && statSync(options.client).isDirectory()) {
|
|
267
|
+
cpSync(options.client, join(path, "assets"), { recursive: true });
|
|
268
|
+
const assetFiles = files(join(path, "assets")).map((file) => {
|
|
269
|
+
const bytes = readFileSync(join(path, "assets", file));
|
|
270
|
+
return { path: file, sha256: sha256(bytes), size: bytes.byteLength, contentType: contentType(file) };
|
|
271
|
+
});
|
|
272
|
+
if (!assetFiles.some((f) => f.path === "index.html"))
|
|
273
|
+
throw new FeltKitError("CONFIGURATION", `The frontend build at ${options.client} has no index.html.`);
|
|
274
|
+
frontend = { root: "assets", entry: "index.html", files: assetFiles };
|
|
275
|
+
}
|
|
276
|
+
const collections = [...app.collections.values()].map((c) => ({ name: c.name, schema: c.schema.toJSONSchema(), ...(c.description ? { description: c.description } : {}) }));
|
|
277
|
+
const names = collections.map((c) => c.name);
|
|
278
|
+
const writable = [...project.functions.values()].some((fn) => fn.kind === "mutation");
|
|
279
|
+
const manifest = {
|
|
280
|
+
format: ARTIFACT_FORMAT,
|
|
281
|
+
runtime: { abi: GUEST_ABI, interfaces: HOST_INTERFACES },
|
|
282
|
+
producer: { name: "feltkit", version: options.producerVersion },
|
|
283
|
+
application: { id: app.name, name: app.name, version: app.options.version ?? "0.0.0", ...(app.options.description ? { description: app.options.description } : {}) },
|
|
284
|
+
module: { path: "module.wasm", sha256: sha256(module), size: module.byteLength, imports: [], program: { section: PROGRAM_SECTION, sha256: sha256(program), size: program.byteLength } },
|
|
285
|
+
functions: functionsManifest(project),
|
|
286
|
+
collections,
|
|
287
|
+
identity: {
|
|
288
|
+
roles: Object.fromEntries(Object.entries(app.options.roles ?? {}).map(([role, permissions]) => [role, [...permissions]])),
|
|
289
|
+
devUsers: (app.options.dev?.users ?? []).map((u) => ({ id: u.id, name: u.name ?? u.id, roles: [...u.roles], type: u.type ?? "user" })),
|
|
290
|
+
sessionTtlMs: app.options.auth?.sessionTtlMs ?? DEFAULT_SESSION_TTL_MS,
|
|
291
|
+
},
|
|
292
|
+
services,
|
|
293
|
+
permissions: {
|
|
294
|
+
collections: { read: names, write: writable ? names : [] },
|
|
295
|
+
services: SERVICES_IN_CODE.filter((s) => s in services),
|
|
296
|
+
network: "none",
|
|
297
|
+
filesystem: "none",
|
|
298
|
+
},
|
|
299
|
+
appport: await appportContract(project),
|
|
300
|
+
frontend,
|
|
301
|
+
omitted,
|
|
302
|
+
};
|
|
303
|
+
writeFileSync(join(path, "manifest.json"), `${JSON.stringify(manifest, null, 2)}\n`);
|
|
304
|
+
return { path, manifest, omitted };
|
|
305
|
+
}
|
|
306
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","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KACR,CAAC;IACF,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IACrF,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function utf8Encode(text: string): Uint8Array;
|
|
2
|
+
export declare function utf8Decode(bytes: Uint8Array): string;
|
|
3
|
+
export declare function toBase64(bytes: Uint8Array): string;
|
|
4
|
+
export declare function fromBase64(text: string): Uint8Array;
|
|
5
|
+
/** TextEncoder/TextDecoder for application code, when the engine has none. */
|
|
6
|
+
export declare function installTextCodecs(): void;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UTF-8 and base64 without Node or the Web platform: the guest engine provides only
|
|
3
|
+
* ECMAScript. File bytes cross the host boundary as base64.
|
|
4
|
+
*/
|
|
5
|
+
const ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
6
|
+
export function utf8Encode(text) {
|
|
7
|
+
const out = [];
|
|
8
|
+
for (const char of text) {
|
|
9
|
+
let code = char.codePointAt(0);
|
|
10
|
+
if (code >= 0xd800 && code <= 0xdfff)
|
|
11
|
+
code = 0xfffd;
|
|
12
|
+
if (code < 0x80)
|
|
13
|
+
out.push(code);
|
|
14
|
+
else if (code < 0x800)
|
|
15
|
+
out.push(0xc0 | (code >> 6), 0x80 | (code & 63));
|
|
16
|
+
else if (code < 0x10000)
|
|
17
|
+
out.push(0xe0 | (code >> 12), 0x80 | ((code >> 6) & 63), 0x80 | (code & 63));
|
|
18
|
+
else
|
|
19
|
+
out.push(0xf0 | (code >> 18), 0x80 | ((code >> 12) & 63), 0x80 | ((code >> 6) & 63), 0x80 | (code & 63));
|
|
20
|
+
}
|
|
21
|
+
return new Uint8Array(out);
|
|
22
|
+
}
|
|
23
|
+
export function utf8Decode(bytes) {
|
|
24
|
+
let out = "";
|
|
25
|
+
let i = 0;
|
|
26
|
+
while (i < bytes.length) {
|
|
27
|
+
const b = bytes[i];
|
|
28
|
+
const need = b < 0x80 ? 0 : b >= 0xc2 && b < 0xe0 ? 1 : b >= 0xe0 && b < 0xf0 ? 2 : b >= 0xf0 && b < 0xf5 ? 3 : -1;
|
|
29
|
+
if (need === 0) {
|
|
30
|
+
out += String.fromCharCode(b);
|
|
31
|
+
i += 1;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
let code = need > 0 ? b & (0x3f >> need) : 0;
|
|
35
|
+
let valid = need > 0 && i + need < bytes.length + 0 && i + need <= bytes.length - 1;
|
|
36
|
+
for (let k = 1; valid && k <= need; k++) {
|
|
37
|
+
const c = bytes[i + k];
|
|
38
|
+
if ((c & 0xc0) !== 0x80)
|
|
39
|
+
valid = false;
|
|
40
|
+
else
|
|
41
|
+
code = (code << 6) | (c & 63);
|
|
42
|
+
}
|
|
43
|
+
if (!valid) {
|
|
44
|
+
out += "\ufffd";
|
|
45
|
+
i += 1;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
out += String.fromCodePoint(code);
|
|
49
|
+
i += need + 1;
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
export function toBase64(bytes) {
|
|
54
|
+
let out = "";
|
|
55
|
+
for (let i = 0; i < bytes.length; i += 3) {
|
|
56
|
+
const n = (bytes[i] << 16) | ((bytes[i + 1] ?? 0) << 8) | (bytes[i + 2] ?? 0);
|
|
57
|
+
out += ALPHABET[(n >> 18) & 63] + ALPHABET[(n >> 12) & 63] + (i + 1 < bytes.length ? ALPHABET[(n >> 6) & 63] : "=") + (i + 2 < bytes.length ? ALPHABET[n & 63] : "=");
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
export function fromBase64(text) {
|
|
62
|
+
const clean = text.replace(/[^A-Za-z0-9+/]/g, "");
|
|
63
|
+
const out = new Uint8Array(Math.floor((clean.length * 3) / 4));
|
|
64
|
+
let length = 0;
|
|
65
|
+
for (let i = 0; i < clean.length; i += 4) {
|
|
66
|
+
const n = (ALPHABET.indexOf(clean[i]) << 18) | (ALPHABET.indexOf(clean[i + 1] ?? "A") << 12) | (Math.max(0, ALPHABET.indexOf(clean[i + 2] ?? "A")) << 6) | Math.max(0, ALPHABET.indexOf(clean[i + 3] ?? "A"));
|
|
67
|
+
out[length++] = (n >> 16) & 255;
|
|
68
|
+
if (i + 2 < clean.length)
|
|
69
|
+
out[length++] = (n >> 8) & 255;
|
|
70
|
+
if (i + 3 < clean.length)
|
|
71
|
+
out[length++] = n & 255;
|
|
72
|
+
}
|
|
73
|
+
return out.slice(0, length);
|
|
74
|
+
}
|
|
75
|
+
/** TextEncoder/TextDecoder for application code, when the engine has none. */
|
|
76
|
+
export function installTextCodecs() {
|
|
77
|
+
const g = globalThis;
|
|
78
|
+
if (typeof g.TextEncoder !== "function") {
|
|
79
|
+
g.TextEncoder = class TextEncoder {
|
|
80
|
+
encoding = "utf-8";
|
|
81
|
+
encode(text = "") {
|
|
82
|
+
return utf8Encode(String(text));
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (typeof g.TextDecoder !== "function") {
|
|
87
|
+
g.TextDecoder = class TextDecoder {
|
|
88
|
+
encoding = "utf-8";
|
|
89
|
+
decode(bytes) {
|
|
90
|
+
if (!bytes)
|
|
91
|
+
return "";
|
|
92
|
+
const view = bytes instanceof ArrayBuffer ? new Uint8Array(bytes) : new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
93
|
+
return utf8Decode(view);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=codec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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,CAAC,GAAG,KAAK,CAAC,MAAM;YAAE,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;IACpD,CAAC;IACD,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,iBAAiB;IAC/B,MAAM,CAAC,GAAG,UAAqC,CAAC;IAChD,IAAI,OAAO,CAAC,CAAC,WAAW,KAAK,UAAU,EAAE,CAAC;QACxC,CAAC,CAAC,WAAW,GAAG,MAAM,WAAW;YACtB,QAAQ,GAAG,OAAO,CAAC;YAC5B,MAAM,CAAC,IAAI,GAAG,EAAE;gBACd,OAAO,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;YAClC,CAAC;SACF,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,CAAC,CAAC,WAAW,KAAK,UAAU,EAAE,CAAC;QACxC,CAAC,CAAC,WAAW,GAAG,MAAM,WAAW;YACtB,QAAQ,GAAG,OAAO,CAAC;YAC5B,MAAM,CAAC,KAAqC;gBAC1C,IAAI,CAAC,KAAK;oBAAE,OAAO,EAAE,CAAC;gBACtB,MAAM,IAAI,GAAG,KAAK,YAAY,WAAW,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;gBACrI,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@feltdb/feltkit` as application code sees it inside an AppBoundry artifact: the
|
|
3
|
+
* definition API, schemas and errors. Nothing here reaches Node, a database, or the
|
|
4
|
+
* network; `feltkit build --target appboundry` fails if application code imports
|
|
5
|
+
* anything else from FeltKit.
|
|
6
|
+
*/
|
|
7
|
+
export { feltkit, FeltKitApp, RESERVED_COLLECTIONS } from "../app.js";
|
|
8
|
+
export { s } from "../schema.js";
|
|
9
|
+
export { FeltKitError, fail, isFeltKitError } from "../errors.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@feltdb/feltkit` as application code sees it inside an AppBoundry artifact: the
|
|
3
|
+
* definition API, schemas and errors. Nothing here reaches Node, a database, or the
|
|
4
|
+
* network; `feltkit build --target appboundry` fails if application code imports
|
|
5
|
+
* anything else from FeltKit.
|
|
6
|
+
*/
|
|
7
|
+
export { feltkit, FeltKitApp, RESERVED_COLLECTIONS } from "../app.js";
|
|
8
|
+
export { s } from "../schema.js";
|
|
9
|
+
export { FeltKitError, fail, isFeltKitError } from "../errors.js";
|
|
10
|
+
//# sourceMappingURL=guest-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guest-index.js","sourceRoot":"","sources":["../../src/appboundry/guest-index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
|