@feltdb/feltkit 0.3.14 → 0.3.16

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.
Files changed (46) hide show
  1. package/dist/app.d.ts +11 -0
  2. package/dist/app.js.map +1 -1
  3. package/dist/appboundry/build.d.ts +8 -1
  4. package/dist/appboundry/build.js +8 -1
  5. package/dist/appboundry/build.js.map +1 -1
  6. package/dist/appboundry/guest.js +16 -0
  7. package/dist/appboundry/guest.js.map +1 -1
  8. package/dist/appboundry/host.js +8 -1
  9. package/dist/appboundry/host.js.map +1 -1
  10. package/dist/appboundry/runtime.d.ts +5 -0
  11. package/dist/appboundry/runtime.js +5 -0
  12. package/dist/appboundry/runtime.js.map +1 -1
  13. package/dist/authorize.d.ts +63 -0
  14. package/dist/authorize.js +45 -0
  15. package/dist/authorize.js.map +1 -0
  16. package/dist/cli/deploy-appboundry-self-hosted.d.ts +16 -0
  17. package/dist/cli/deploy-appboundry-self-hosted.js +200 -0
  18. package/dist/cli/deploy-appboundry-self-hosted.js.map +1 -0
  19. package/dist/cli/deploy-appboundry.d.ts +142 -0
  20. package/dist/cli/deploy-appboundry.js +263 -0
  21. package/dist/cli/deploy-appboundry.js.map +1 -0
  22. package/dist/cli/main.js +106 -5
  23. package/dist/cli/main.js.map +1 -1
  24. package/dist/docs.d.ts +1 -1
  25. package/dist/docs.js +2 -1
  26. package/dist/docs.js.map +1 -1
  27. package/dist/index.d.ts +2 -0
  28. package/dist/runtime/activity.d.ts +5 -0
  29. package/dist/runtime/activity.js.map +1 -1
  30. package/dist/runtime/context.d.ts +5 -0
  31. package/dist/runtime/crypto-token.d.ts +8 -0
  32. package/dist/runtime/crypto-token.js +17 -0
  33. package/dist/runtime/crypto-token.js.map +1 -0
  34. package/dist/runtime/runtime.d.ts +0 -9
  35. package/dist/runtime/runtime.js +35 -1
  36. package/dist/runtime/runtime.js.map +1 -1
  37. package/dist/server/admin.d.ts +1 -1
  38. package/docs/APPBOUNDRY-DEPLOY-CONTRACT.md +49 -0
  39. package/docs/APPBOUNDRY.md +43 -0
  40. package/docs/GUARANTEES.md +22 -0
  41. package/docs/README.md +4 -3
  42. package/docs/UPSTREAM-GAPS.md +2 -0
  43. package/package.json +2 -2
  44. package/skills/.claude-plugin/marketplace.json +1 -1
  45. package/skills/.claude-plugin/plugin.json +1 -1
  46. package/skills/feltkit-build/SKILL.md +3 -2
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Application-supplied, input-aware authorization: `feltkit({ authorize })`.
3
+ *
4
+ * FeltKit's roles answer "may this principal call this function at all" (AppPort's
5
+ * permissionAuthorizer, evaluated before the arguments are looked at). Many applications also
6
+ * need "may this principal act on *this* workspace / document / channel", which depends on the
7
+ * validated arguments and on stored records. AppPort's Authorizer contract already carries the
8
+ * validated input for exactly this ("so policies can make resource-aware decisions") and its
9
+ * decision type is reused here; FeltKit composes the two the way AppPort's `combineAuthorizers`
10
+ * does — every authorizer must allow, the first denial wins — with the role policy first.
11
+ *
12
+ * Where it runs: at the one execution boundary every interface goes through (HTTP functions,
13
+ * AppPort capabilities, MCP tools, agent actions, jobs) — in FeltKit's runtime and in the
14
+ * AppBoundry guest alike — after the role check and argument validation, before the handler.
15
+ *
16
+ * What it reads with: the call's own `ctx.db`, read-only. So its reads are part of the call:
17
+ * - a mutation's commit is checked against them (a membership removed after the decision makes
18
+ * the mutation fail with CONFLICT instead of committing under a stale decision);
19
+ * - a query's live subscription includes them (revoking access re-runs the query, which is
20
+ * then denied).
21
+ *
22
+ * This module is runtime-neutral (no Node APIs): the AppBoundry guest imports it.
23
+ */
24
+ import type { AuthorizationDecision } from "@appport/authorization";
25
+ import type { Access } from "./app.js";
26
+ import type { Principal } from "./runtime/authority.js";
27
+ import type { DatabaseReader } from "./runtime/data.js";
28
+ export interface AuthorizeRequest {
29
+ /** The function being called, "<module>:<export>". */
30
+ function: string;
31
+ kind: "query" | "mutation";
32
+ /** The function's declared `access` (already granted by the role policy). */
33
+ access: Access;
34
+ /** The AppPort capability, when the call came through AppPort or MCP. */
35
+ capability?: {
36
+ name: string;
37
+ version: number;
38
+ };
39
+ /** The verified caller; null only for a `public` function called anonymously. */
40
+ principal: Principal | null;
41
+ /** The validated arguments (AppPort's `input`). */
42
+ args: Record<string, unknown>;
43
+ /** "http", "appport", "mcp", "agent", "job", "test", … — for auditing, never for trust. */
44
+ transport: string;
45
+ requestId: string;
46
+ /** The call's own database reader (read-only). Reads are fenced at commit / tracked live. */
47
+ db: DatabaseReader;
48
+ }
49
+ /** AppPort's decision, or a boolean (`true` allows; `false` denies with FORBIDDEN). */
50
+ export type AuthorizeResult = boolean | AuthorizationDecision;
51
+ export type AuthorizeHook = (request: AuthorizeRequest) => AuthorizeResult | Promise<AuthorizeResult>;
52
+ export interface ResourceDecision {
53
+ allowed: boolean;
54
+ reason?: string;
55
+ }
56
+ /** A read-only view of a reader or writer: the hook cannot write, whatever it is handed. */
57
+ export declare function readOnly(db: DatabaseReader): DatabaseReader;
58
+ /**
59
+ * Run the application's hook. Returns the decision for the activity record; throws the
60
+ * FeltKitError the caller receives when it denies. A hook that throws or returns anything other
61
+ * than a boolean or an AppPort decision denies (fail closed).
62
+ */
63
+ export declare function evaluateAuthorize(hook: AuthorizeHook | undefined, request: AuthorizeRequest): Promise<ResourceDecision | null>;
@@ -0,0 +1,45 @@
1
+ import { FeltKitError, isFeltKitError } from "./errors.js";
2
+ /** A read-only view of a reader or writer: the hook cannot write, whatever it is handed. */
3
+ export function readOnly(db) {
4
+ return Object.freeze({
5
+ get: db.get.bind(db),
6
+ find: db.find.bind(db),
7
+ query: db.query.bind(db),
8
+ count: db.count.bind(db),
9
+ });
10
+ }
11
+ /**
12
+ * Run the application's hook. Returns the decision for the activity record; throws the
13
+ * FeltKitError the caller receives when it denies. A hook that throws or returns anything other
14
+ * than a boolean or an AppPort decision denies (fail closed).
15
+ */
16
+ export async function evaluateAuthorize(hook, request) {
17
+ if (!hook)
18
+ return null;
19
+ let result;
20
+ try {
21
+ result = await hook({ ...request, db: readOnly(request.db) });
22
+ }
23
+ catch (error) {
24
+ // The application's own structured refusal passes through as is: fail("FORBIDDEN", …), or
25
+ // fail("NOT_FOUND", …) to refuse unknown and unauthorized ids alike. AppPort's decision type has
26
+ // no "not found", so hiding existence is done by throwing (recorded as a denial all the same).
27
+ if (isFeltKitError(error))
28
+ throw error;
29
+ throw new FeltKitError("INTERNAL", `feltkit({ authorize }) threw while deciding ${request.function}: ${error?.message ?? String(error)}. The call was refused.`);
30
+ }
31
+ if (result === true || (isDecision(result) && result.allowed))
32
+ return { allowed: true };
33
+ if (result === false) {
34
+ throw new FeltKitError("FORBIDDEN", `Not allowed: ${request.function}`, { details: { authorize: "denied" } });
35
+ }
36
+ if (isDecision(result) && !result.allowed) {
37
+ const code = result.code === "UNAUTHORIZED" ? "UNAUTHORIZED" : "FORBIDDEN";
38
+ throw new FeltKitError(code, result.reason ?? `Not allowed: ${request.function}`, { details: { authorize: "denied" } });
39
+ }
40
+ throw new FeltKitError("INTERNAL", `feltkit({ authorize }) must return a boolean or an AppPort decision ({ allowed, code?, reason? }); for ${request.function} it returned ${JSON.stringify(result)}. The call was refused.`);
41
+ }
42
+ function isDecision(value) {
43
+ return typeof value === "object" && value !== null && typeof value.allowed === "boolean";
44
+ }
45
+ //# sourceMappingURL=authorize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorize.js","sourceRoot":"","sources":["../src/authorize.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAkC3D,4FAA4F;AAC5F,MAAM,UAAU,QAAQ,CAAC,EAAkB;IACzC,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACpB,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAA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CAAC,WAAW,CAAC;QAC3E,MAAM,IAAI,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,IAAI,gBAAgB,OAAO,CAAC,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC1H,CAAC;IACD,MAAM,IAAI,YAAY,CAAC,UAAU,EAAE,0GAA0G,OAAO,CAAC,QAAQ,gBAAgB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC;AAChO,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,OAAQ,KAA+B,CAAC,OAAO,KAAK,SAAS,CAAC;AACtH,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { type ArtifactManifest } from "../appboundry/build.js";
2
+ export declare const APPBOUNDRY_SELF_HOSTED_TITLE = "Self-hosted AppBoundry runtime: the artifact in one Docker container you operate; data on a volume";
3
+ export interface AppBoundrySelfHostedResult {
4
+ dir: string;
5
+ artifact: string;
6
+ application: string;
7
+ manifest: ArtifactManifest;
8
+ omitted: string[];
9
+ runtime: string;
10
+ }
11
+ export declare function deployAppBoundrySelfHosted(options: {
12
+ projectDir: string;
13
+ out?: string;
14
+ }): Promise<AppBoundrySelfHostedResult>;
15
+ /** The commands that give a person access, as the CLI prints them and DEPLOY.md lists them. */
16
+ export declare function accessCommands(composeFile: string, user?: string, role?: string): string[];
@@ -0,0 +1,200 @@
1
+ /**
2
+ * `feltkit deploy --target appboundry-self-hosted`: the AppBoundry artifact with the published AppBoundry
3
+ * runtime in one Docker container, for people who operate their own execution environment.
4
+ *
5
+ * This is NOT how AppBoundry deploys. `feltkit deploy --target appboundry` (deploy-appboundry.ts) sends
6
+ * the artifact to the AppBoundry control plane, which owns execution; the developer never sees a
7
+ * container. This target exists for self-hosting, and its Docker files are its contract, nobody else's.
8
+ *
9
+ * The other targets ship this project's production build, run by FeltKit. This one ships the
10
+ * artifact `feltkit build --target appboundry` compiles (manifest.json, module.wasm that imports
11
+ * nothing, the frontend), run by the published AppBoundry runtime (@appport/appboundry). Nothing of
12
+ * FeltKit runs in the deployment, and nothing here is new runtime code: the Dockerfile installs the
13
+ * pinned runtime, and the entrypoint is the one AppBoundry's own artifact runner uses
14
+ * (rkendel1/appboundry deploy/artifact-runner): it refuses any module but the one this deployment
15
+ * was built with, verifies the whole artifact, bootstraps the operator on first start, then runs it.
16
+ *
17
+ * Written to .feltkit/deploy (replaced on every deploy; state lives in the Docker volume, never here):
18
+ * <name>.app/ the artifact, unchanged
19
+ * Dockerfile node:22 + @appport/appboundry@APPBOUNDRY_DEPLOY_VERSION + the artifact
20
+ * entrypoint.sh identity check, verify, first-start bootstrap, run
21
+ * docker-compose.yml port 3000, state on the `data` volume
22
+ * deploy.json what was deployed: application, module SHA-256, runtime version
23
+ * DEPLOY.md the target's contract: identity, access, state, upgrades, limits
24
+ */
25
+ import { cpSync, existsSync, mkdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
26
+ import { basename, join, resolve } from "node:path";
27
+ import { FeltKitError } from "../errors.js";
28
+ import { SDK_VERSION, build } from "../server/project.js";
29
+ import { buildAppBoundry } from "../appboundry/build.js";
30
+ import { APPBOUNDRY_DEPLOY_VERSION, APPBOUNDRY_PACKAGE } from "../appboundry/runtime.js";
31
+ import { DEPLOY_DIR } from "../runtime/deployment.js";
32
+ export const APPBOUNDRY_SELF_HOSTED_TITLE = "Self-hosted AppBoundry runtime: the artifact in one Docker container you operate; data on a volume";
33
+ const PORT = 3000;
34
+ export async function deployAppBoundrySelfHosted(options) {
35
+ const projectDir = resolve(options.projectDir);
36
+ const target = resolve(options.out ?? join(projectDir, DEPLOY_DIR));
37
+ if (options.out && existsSync(target))
38
+ throw new FeltKitError("CONFIGURATION", `${target} already exists; choose another --out.`);
39
+ const dir = options.out ? target : `${target}.next`;
40
+ rmSync(dir, { recursive: true, force: true });
41
+ mkdirSync(dir, { recursive: true });
42
+ // The same build and artifact as `feltkit build --target appboundry`: the module is loaded in the
43
+ // guest engine and must define exactly the functions the build does, or nothing is written.
44
+ const built = await build(projectDir);
45
+ const artifact = await buildAppBoundry(projectDir, { bundle: built.bundle, client: built.client, producerVersion: SDK_VERSION, outDir: dir });
46
+ const m = artifact.manifest;
47
+ const name = basename(artifact.path);
48
+ const application = m.application.name;
49
+ const moduleSha = m.module.sha256;
50
+ writeFileSync(join(dir, "Dockerfile"), dockerfile(name));
51
+ writeFileSync(join(dir, "entrypoint.sh"), ENTRYPOINT, { mode: 0o755 });
52
+ writeFileSync(join(dir, ".dockerignore"), "data\nnode_modules\n");
53
+ writeFileSync(join(dir, "docker-compose.yml"), compose(application, moduleSha));
54
+ writeFileSync(join(dir, "deploy.json"), JSON.stringify({ target: "appboundry-self-hosted", application, artifact: name, format: m.format, module: { sha256: moduleSha, size: m.module.size }, runtime: { package: APPBOUNDRY_PACKAGE, version: APPBOUNDRY_DEPLOY_VERSION }, producer: `feltkit ${SDK_VERSION}` }, null, 2) + "\n");
55
+ writeFileSync(join(dir, "DEPLOY.md"), deployMd({ application, name, manifest: m, omitted: artifact.omitted }));
56
+ if (!options.out) {
57
+ rmSync(target, { recursive: true, force: true });
58
+ renameSync(dir, target);
59
+ }
60
+ return { dir: target, artifact: join(target, name), application, manifest: m, omitted: artifact.omitted, runtime: APPBOUNDRY_DEPLOY_VERSION };
61
+ }
62
+ /** The commands that give a person access, as the CLI prints them and DEPLOY.md lists them. */
63
+ export function accessCommands(composeFile, user = "ada", role = "member") {
64
+ const exec = `docker compose -f ${composeFile} exec -u node app appboundry admin`;
65
+ return [`${exec} users add ${user} --role ${role} --state /data/state`, `${exec} sessions issue --user ${user} --state /data/state`];
66
+ }
67
+ function dockerfile(name) {
68
+ return `# Written by \`feltkit deploy --target appboundry-self-hosted\` (FeltKit ${SDK_VERSION}); replaced on every deploy.
69
+ # The published AppBoundry runtime running one artifact. No FeltKit code is in this image.
70
+ FROM node:22-bookworm-slim
71
+ ENV NODE_ENV=production
72
+ WORKDIR /app
73
+ ARG APPBOUNDRY_VERSION=${APPBOUNDRY_DEPLOY_VERSION}
74
+ RUN npm install --omit=dev --no-audit --no-fund ${APPBOUNDRY_PACKAGE}@\${APPBOUNDRY_VERSION} \\
75
+ && ln -s /app/node_modules/.bin/appboundry /usr/local/bin/appboundry \\
76
+ && npm cache clean --force
77
+ COPY entrypoint.sh /app/entrypoint.sh
78
+ COPY ${name} /app/artifact.app
79
+ RUN chmod 0755 /app/entrypoint.sh && mkdir -p /data && chown node:node /data
80
+ ENV ARTIFACT=/app/artifact.app STATE=/data/state OPERATOR_TOKEN_FILE=/data/operator-token.txt PORT=${PORT}
81
+ EXPOSE ${PORT}
82
+ ENTRYPOINT ["/app/entrypoint.sh"]
83
+ `;
84
+ }
85
+ // The entrypoint of AppBoundry's artifact runner (rkendel1/appboundry deploy/artifact-runner), unchanged
86
+ // in behaviour: identity check (exit 78), full verification, first-start bootstrap, run in production.
87
+ const ENTRYPOINT = `#!/bin/sh
88
+ # Starts one artifact, and refuses to if it is not the artifact this deployment asked for.
89
+ # EXPECTED_MODULE_SHA256 the module SHA-256 this deployment was built with (docker-compose.yml)
90
+ set -eu
91
+ ARTIFACT=\${ARTIFACT:-/app/artifact.app}
92
+ STATE=\${STATE:-/data/state}
93
+
94
+ # Volumes are mounted root-owned; drop to the unprivileged user before touching anything else.
95
+ if [ "$(id -u)" = 0 ]; then
96
+ chown node:node /data
97
+ exec runuser -u node -- "$0" "$@"
98
+ fi
99
+
100
+ : "\${EXPECTED_MODULE_SHA256:?set the module SHA-256 this deployment must run}"
101
+ actual=$(node -e 'process.stdout.write(JSON.parse(require("fs").readFileSync(process.argv[1] + "/manifest.json", "utf8")).module.sha256)' "$ARTIFACT")
102
+ if [ "$actual" != "$EXPECTED_MODULE_SHA256" ]; then
103
+ echo "refusing to start: the artifact's module is sha256:$actual, the deployment asked for sha256:$EXPECTED_MODULE_SHA256" >&2
104
+ exit 78
105
+ fi
106
+ # Full verification (manifest, module, program section, every asset, program matches the manifest).
107
+ appboundry artifact verify "$ARTIFACT"
108
+
109
+ if [ ! -e "$STATE" ]; then
110
+ # First start: bind the new state to production and create the operator. The operator token is
111
+ # shown once; it is left in a 0600 file for the person doing the deployment to collect and delete.
112
+ umask 077
113
+ TOKEN_FILE=\${OPERATOR_TOKEN_FILE:-/data/operator-token.txt}
114
+ appboundry admin bootstrap --artifact "$ARTIFACT" --state "$STATE" --operator ops > "$TOKEN_FILE" 2>&1
115
+ echo "first start: operator created; collect and delete $TOKEN_FILE"
116
+ fi
117
+
118
+ exec appboundry run "$ARTIFACT" --state "$STATE" --bind 0.0.0.0 --port "\${PORT:-${PORT}}" --environment production
119
+ `;
120
+ function compose(application, moduleSha) {
121
+ return `# Written by \`feltkit deploy --target appboundry-self-hosted\`; replaced on every deploy. State is on the \`data\` volume.
122
+ services:
123
+ app:
124
+ build: .
125
+ image: ${application}-appboundry
126
+ environment:
127
+ # The deployment request: the container refuses to start any other module (exit 78).
128
+ EXPECTED_MODULE_SHA256: "${moduleSha}"
129
+ ports:
130
+ - "${PORT}:${PORT}"
131
+ volumes:
132
+ - data:/data
133
+ restart: unless-stopped
134
+ healthcheck:
135
+ test: ["CMD", "node", "-e", "fetch('http://127.0.0.1:${PORT}/_appboundry/health').then(r=>process.exit(r.ok?0:1),()=>process.exit(1))"]
136
+ interval: 10s
137
+ timeout: 3s
138
+ retries: 3
139
+ volumes:
140
+ data:
141
+ `;
142
+ }
143
+ function deployMd(o) {
144
+ const m = o.manifest;
145
+ const [add, issue] = accessCommands(".feltkit/deploy/docker-compose.yml", "<id>", "<role>");
146
+ const roles = Object.keys(m.identity.roles ?? {});
147
+ return `# ${o.application} on a self-hosted AppBoundry runtime
148
+
149
+ Written by \`feltkit deploy --target appboundry-self-hosted\` (FeltKit ${SDK_VERSION}). This directory is replaced on every deploy.
150
+
151
+ ## What runs
152
+
153
+ | | |
154
+ |---|---|
155
+ | Artifact | \`${o.name}\` (${m.format}), built from this project by \`feltkit build --target appboundry\` |
156
+ | Module | \`sha256:${m.module.sha256}\` (${(m.module.size / 1024 / 1024).toFixed(1)} MB, imports nothing) |
157
+ | Runtime | ${APPBOUNDRY_PACKAGE} ${APPBOUNDRY_DEPLOY_VERSION}, installed in the image. No FeltKit code runs in the deployment. |
158
+ | Host access | collections ${m.permissions.collections.read.join(", ") || "none"}; services ${m.permissions.services.join(", ") || "none"}; network none; filesystem none |
159
+ | State | FeltDB on the \`data\` volume (\`/data/state\`) |
160
+
161
+ ## Run it
162
+
163
+ \`\`\`bash
164
+ docker compose -f .feltkit/deploy/docker-compose.yml up --build
165
+ \`\`\`
166
+
167
+ The container refuses to start a module other than \`sha256:${m.module.sha256.slice(0, 16)}…\` (exit 78), verifies
168
+ the manifest, module, program and every frontend file, and on first start creates the state and an operator
169
+ (\`ops\`, token in \`/data/operator-token.txt\`, 0600: collect it and delete it). Then open http://localhost:${PORT}.
170
+ \`GET /_appboundry/health\` reports the module it is running.
171
+
172
+ ## Give someone access
173
+
174
+ Production has no development sign-in. An operator adds a user with one of the app's roles (${roles.join(", ") || "none declared"}) and issues
175
+ their session; they paste it into the app's sign-in screen.
176
+
177
+ \`\`\`bash
178
+ ${add}
179
+ ${issue}
180
+ \`\`\`
181
+
182
+ ## Upgrades
183
+
184
+ Deploy again and rebuild the image. AppBoundry installs the new version's state contract only if every stored
185
+ record satisfies it, after running the artifact's pending migrations once; otherwise it refuses to start
186
+ (\`SCHEMA_INCOMPATIBLE\`) and the previous image keeps working on the same data.
187
+
188
+ ## Not in the artifact
189
+
190
+ ${o.omitted.map((note) => `- ${note}`).join("\n") || "- Nothing."}
191
+
192
+ ## Limits
193
+
194
+ - One container per application. Containers share the host's kernel: this is not isolation for untrusted tenants.
195
+ - Backups: \`appboundry admin export\` and \`appboundry admin restore\` (1.7.3 fixed restoring apps with indexed
196
+ collections). Test a restore before relying on it.
197
+ - To have AppBoundry deploy and operate the artifact instead, with no container to manage: \`feltkit deploy --target appboundry\`.
198
+ `;
199
+ }
200
+ //# sourceMappingURL=deploy-appboundry-self-hosted.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy-appboundry-self-hosted.js","sourceRoot":"","sources":["../../src/cli/deploy-appboundry-self-hosted.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3F,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAyB,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,MAAM,CAAC,MAAM,4BAA4B,GAAG,oGAAoG,CAAC;AACjJ,MAAM,IAAI,GAAG,IAAI,CAAC;AAWlB,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,OAA6C;IAC5F,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;IACpE,IAAI,OAAO,CAAC,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC;QAAE,MAAM,IAAI,YAAY,CAAC,eAAe,EAAE,GAAG,MAAM,wCAAwC,CAAC,CAAC;IAClI,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,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CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;;+GAEqB,IAAI;;;;;8FAKrB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,eAAe;;;;EAI/H,GAAG;EACH,KAAK;;;;;;;;;;;EAWL,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,YAAY;;;;;;;;CAQhE,CAAC;AACF,CAAC"}
@@ -0,0 +1,142 @@
1
+ import { type ArtifactManifest } from "../appboundry/build.js";
2
+ export declare const APPBOUNDRY_TARGET_TITLE = "AppBoundry: send the verified artifact to AppBoundry, which deploys and operates it";
3
+ /** Where the deployment request's result is recorded, for `feltkit status`. */
4
+ export declare const APPBOUNDRY_RECORD: string;
5
+ export interface AppBoundryConnection {
6
+ /** The AppBoundry portal origin, e.g. https://appboundry.com (APPBOUNDRY_URL). */
7
+ portal: string;
8
+ /** A credential the portal accepts as `Authorization: Bearer` (APPBOUNDRY_TOKEN). Never printed or written. */
9
+ token: string;
10
+ /** The execution host (APPBOUNDRY_HOST). M1a needs one; once AppBoundry places deployments it is optional (docs/APPBOUNDRY-DEPLOY-CONTRACT.md). */
11
+ hostId?: string;
12
+ }
13
+ export type DeploymentState = "Requested" | "Starting" | "Running" | "Failed" | "Stopped" | "Superseded";
14
+ export interface PortalDeployment {
15
+ deploymentId: string;
16
+ applicationId: string;
17
+ hostId: string;
18
+ artifactId: string;
19
+ moduleSha256: string;
20
+ state: DeploymentState;
21
+ desired?: string;
22
+ attempt?: number;
23
+ runtime?: {
24
+ package: string;
25
+ version: string;
26
+ };
27
+ evidence?: {
28
+ hostId: string;
29
+ observedModuleSha256: string;
30
+ health: "ready";
31
+ startedAt: string;
32
+ observedAt: string;
33
+ /** The attempt the observed instance was started for, the instance, and the runtime verified on it (AppBoundry requires all three for Running). */
34
+ attempt?: number;
35
+ instanceId?: string;
36
+ runtime?: {
37
+ package: string;
38
+ version: string;
39
+ };
40
+ source?: {
41
+ kind: string;
42
+ hostId: string;
43
+ agentVersion?: string;
44
+ };
45
+ } | null;
46
+ failure?: {
47
+ code: string;
48
+ message: string;
49
+ at: string;
50
+ } | null;
51
+ requestedAt?: string;
52
+ updatedAt?: string;
53
+ /** Where it is served, once AppBoundry routes it. Separate from `state`: Running does not mean publicly reachable. */
54
+ address?: string | null;
55
+ routing?: {
56
+ status: string;
57
+ address: string | null;
58
+ reason?: string;
59
+ };
60
+ }
61
+ export interface AppBoundryDeployResult {
62
+ portal: string;
63
+ applicationId: string;
64
+ artifact: {
65
+ path: string;
66
+ artifactId: string;
67
+ moduleSha256: string;
68
+ archiveSha256: string;
69
+ created: boolean;
70
+ };
71
+ deployment: PortalDeployment;
72
+ /** Running with evidence naming this build's module; or pending (still starting when we stopped waiting); or failed. */
73
+ outcome: "running" | "pending" | "failed";
74
+ manifest: ArtifactManifest;
75
+ }
76
+ type Fetch = typeof fetch;
77
+ /** Read the connection from options, then the environment. Refuses http except to loopback. */
78
+ export declare function appboundryConnection(options?: {
79
+ portal?: string;
80
+ hostId?: string;
81
+ env?: NodeJS.ProcessEnv;
82
+ }): AppBoundryConnection;
83
+ /**
84
+ * The artifact folder as a deterministic ustar .tar.gz: files at the root, sorted, fixed modes and times,
85
+ * so the same artifact always has the same archive digest. This is the format the portal ingests.
86
+ */
87
+ export declare function artifactArchive(dir: string): Buffer;
88
+ /**
89
+ * Running counts only with evidence that names the module this build produced, observed on the deployment's current attempt
90
+ * (AppBoundry enforces both; FeltKit checks again rather than trusting the state word alone).
91
+ */
92
+ export declare function verifiedRunning(deployment: PortalDeployment, moduleSha256: string): boolean;
93
+ /** The outcome FeltKit reports for what AppBoundry says now. */
94
+ export declare function outcomeOf(deployment: PortalDeployment, moduleSha256: string): "running" | "pending" | "failed";
95
+ export declare function deployToAppBoundry(options: {
96
+ projectDir: string;
97
+ connection: AppBoundryConnection;
98
+ fetch?: Fetch;
99
+ /** How long to wait for the runtime's evidence before reporting "pending" (default 5 minutes). */
100
+ waitMs?: number;
101
+ pollMs?: number;
102
+ onProgress?: (event: {
103
+ step: "built" | "uploaded" | "requested" | "state";
104
+ detail: string;
105
+ }) => void;
106
+ }): Promise<AppBoundryDeployResult>;
107
+ /**
108
+ * `.feltkit/appboundry/deployment.json`: references only, never a credential. `lastStatus`/`lastObservedAt` are what AppBoundry said
109
+ * when FeltKit last asked; they are a note, not the truth: `feltkit status` always asks AppBoundry again.
110
+ */
111
+ interface DeploymentNote {
112
+ portal: string;
113
+ hostId?: string;
114
+ applicationId: string;
115
+ artifactId: string;
116
+ archiveSha256: string;
117
+ moduleSha256: string;
118
+ deploymentId: string;
119
+ requestedAt: string;
120
+ feltkit: string;
121
+ lastStatus?: {
122
+ state: string;
123
+ outcome: "running" | "pending" | "failed";
124
+ hostId?: string;
125
+ address?: string | null;
126
+ };
127
+ lastObservedAt?: string;
128
+ }
129
+ export declare function readAppBoundryRecord(projectDir: string): DeploymentNote | null;
130
+ /** `feltkit status`: what AppBoundry says about the last deployment requested from this project. */
131
+ export declare function appboundryStatus(options: {
132
+ projectDir: string;
133
+ connection?: Partial<AppBoundryConnection>;
134
+ fetch?: Fetch;
135
+ env?: NodeJS.ProcessEnv;
136
+ }): Promise<{
137
+ note: DeploymentNote;
138
+ deployment: PortalDeployment;
139
+ verified: boolean;
140
+ outcome: "pending" | "failed" | "running";
141
+ } | null>;
142
+ export {};