@feltdb/feltkit 0.3.21 → 0.3.23
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/dist/app.d.ts +17 -3
- package/dist/app.js +10 -0
- package/dist/app.js.map +1 -1
- package/dist/appboundry/build.js +4 -0
- package/dist/appboundry/build.js.map +1 -1
- package/dist/authorize.d.ts +1 -1
- package/dist/cli/main.js +8 -152
- package/dist/cli/main.js.map +1 -1
- package/dist/client/index.d.ts +83 -4
- package/dist/client/index.js +154 -2
- package/dist/client/index.js.map +1 -1
- package/dist/dashboard/assets/index-BEjtLLYq.js +15 -0
- package/dist/dashboard/index.html +1 -1
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +1 -0
- package/dist/docs.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js.map +1 -1
- package/dist/platform/approvals.d.ts +102 -0
- package/dist/platform/approvals.js +155 -0
- package/dist/platform/approvals.js.map +1 -0
- package/dist/platform/artifacts.d.ts +126 -0
- package/dist/platform/artifacts.js +251 -0
- package/dist/platform/artifacts.js.map +1 -0
- package/dist/platform/blobs.d.ts +25 -0
- package/dist/platform/blobs.js +78 -0
- package/dist/platform/blobs.js.map +1 -0
- package/dist/platform/diff.d.ts +23 -0
- package/dist/platform/diff.js +107 -0
- package/dist/platform/diff.js.map +1 -0
- package/dist/platform/exec.d.ts +182 -0
- package/dist/platform/exec.js +575 -0
- package/dist/platform/exec.js.map +1 -0
- package/dist/platform/operations.d.ts +30 -13
- package/dist/platform/operations.js +8 -17
- package/dist/platform/operations.js.map +1 -1
- package/dist/platform/permissions.d.ts +15 -0
- package/dist/platform/permissions.js +16 -0
- package/dist/platform/permissions.js.map +1 -0
- package/dist/platform/platform.d.ts +28 -0
- package/dist/platform/platform.js +84 -5
- package/dist/platform/platform.js.map +1 -1
- package/dist/platform/releases.d.ts +110 -0
- package/dist/platform/releases.js +344 -0
- package/dist/platform/releases.js.map +1 -0
- package/dist/platform/review.d.ts +10 -0
- package/dist/platform/review.js +109 -0
- package/dist/platform/review.js.map +1 -0
- package/dist/platform/server.js +7 -0
- package/dist/platform/server.js.map +1 -1
- package/dist/platform/source.d.ts +2 -0
- package/dist/platform/source.js +1 -1
- package/dist/platform/source.js.map +1 -1
- package/dist/platform/workspace-operations.d.ts +2 -0
- package/dist/platform/workspace-operations.js +590 -0
- package/dist/platform/workspace-operations.js.map +1 -0
- package/dist/platform/workspaces.d.ts +211 -0
- package/dist/platform/workspaces.js +435 -0
- package/dist/platform/workspaces.js.map +1 -0
- package/dist/react/index.d.ts +29 -1
- package/dist/react/index.js +50 -0
- package/dist/react/index.js.map +1 -1
- package/dist/runtime/activity.d.ts +1 -1
- package/dist/runtime/agent.d.ts +216 -2
- package/dist/runtime/agent.js +333 -7
- package/dist/runtime/agent.js.map +1 -1
- package/dist/runtime/approval-rules.d.ts +16 -0
- package/dist/runtime/approval-rules.js +37 -0
- package/dist/runtime/approval-rules.js.map +1 -0
- package/dist/runtime/authority.d.ts +18 -1
- package/dist/runtime/authority.js +26 -1
- package/dist/runtime/authority.js.map +1 -1
- package/dist/runtime/browser-inference.d.ts +52 -0
- package/dist/runtime/browser-inference.js +53 -0
- package/dist/runtime/browser-inference.js.map +1 -0
- package/dist/runtime/context.d.ts +110 -0
- package/dist/runtime/decisions.d.ts +23 -0
- package/dist/runtime/decisions.js +54 -0
- package/dist/runtime/decisions.js.map +1 -1
- package/dist/runtime/generation.d.ts +94 -0
- package/dist/runtime/generation.js +295 -0
- package/dist/runtime/generation.js.map +1 -0
- package/dist/runtime/runtime.d.ts +10 -2
- package/dist/runtime/runtime.js +125 -1
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/server/admin.d.ts +9 -1
- package/dist/server/admin.js +84 -2
- package/dist/server/admin.js.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +159 -8
- package/dist/server/index.js.map +1 -1
- package/dist/testing/index.d.ts +11 -0
- package/dist/testing/index.js +7 -3
- package/dist/testing/index.js.map +1 -1
- package/docs/AUTH.md +2 -2
- package/docs/GENERATION.md +136 -0
- package/docs/README.md +3 -2
- package/package.json +2 -4
- package/skills/.claude-plugin/marketplace.json +1 -1
- package/skills/.claude-plugin/plugin.json +1 -1
- package/dist/cli/compose.d.ts +0 -31
- package/dist/cli/compose.js +0 -274
- package/dist/cli/compose.js.map +0 -1
- package/dist/cli/create.d.ts +0 -219
- package/dist/cli/create.js +0 -1193
- package/dist/cli/create.js.map +0 -1
- package/dist/cli/domain.d.ts +0 -174
- package/dist/cli/domain.js +0 -1119
- package/dist/cli/domain.js.map +0 -1
- package/dist/cli/shell.d.ts +0 -7
- package/dist/cli/shell.js +0 -59
- package/dist/cli/shell.js.map +0 -1
- package/dist/composition/catalog.d.ts +0 -3
- package/dist/composition/catalog.js +0 -217
- package/dist/composition/catalog.js.map +0 -1
- package/dist/composition/contract.d.ts +0 -165
- package/dist/composition/contract.js +0 -12
- package/dist/composition/contract.js.map +0 -1
- package/dist/composition/execute.d.ts +0 -110
- package/dist/composition/execute.js +0 -350
- package/dist/composition/execute.js.map +0 -1
- package/dist/composition/generate.d.ts +0 -105
- package/dist/composition/generate.js +0 -274
- package/dist/composition/generate.js.map +0 -1
- package/dist/composition/plan.d.ts +0 -131
- package/dist/composition/plan.js +0 -558
- package/dist/composition/plan.js.map +0 -1
- package/dist/composition/profiles.d.ts +0 -20
- package/dist/composition/profiles.js +0 -81
- package/dist/composition/profiles.js.map +0 -1
- package/dist/composition/reconcile.d.ts +0 -153
- package/dist/composition/reconcile.js +0 -282
- package/dist/composition/reconcile.js.map +0 -1
- package/dist/composition/recover.d.ts +0 -89
- package/dist/composition/recover.js +0 -407
- package/dist/composition/recover.js.map +0 -1
- package/dist/composition/resolve.d.ts +0 -2
- package/dist/composition/resolve.js +0 -208
- package/dist/composition/resolve.js.map +0 -1
- package/dist/dashboard/assets/index-BrC1AtZ1.js +0 -15
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { StateFirstDB } from "@feltdb/core";
|
|
2
|
+
import type { ArtifactRecord, Artifacts } from "./artifacts.js";
|
|
3
|
+
import type { Caller } from "./exec.js";
|
|
4
|
+
export declare const RELEASES = "feltkit.platform.releases";
|
|
5
|
+
export declare const RELEASE_ENVIRONMENTS = "feltkit.platform.release-environments";
|
|
6
|
+
export type ReleaseState = "deploying" | "running" | "failed" | "superseded" | "stopped";
|
|
7
|
+
export interface Check {
|
|
8
|
+
check: string;
|
|
9
|
+
ok: boolean;
|
|
10
|
+
expected?: unknown;
|
|
11
|
+
actual?: unknown;
|
|
12
|
+
detail?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ReleaseRecord {
|
|
15
|
+
id: string;
|
|
16
|
+
application: string;
|
|
17
|
+
environment: string;
|
|
18
|
+
kind: "deploy" | "rollback" | "restart";
|
|
19
|
+
artifact: {
|
|
20
|
+
id: string;
|
|
21
|
+
digest: string;
|
|
22
|
+
module: string;
|
|
23
|
+
};
|
|
24
|
+
previous: {
|
|
25
|
+
deployment: string;
|
|
26
|
+
artifact: string;
|
|
27
|
+
} | null;
|
|
28
|
+
rollbackOf?: string;
|
|
29
|
+
state: ReleaseState;
|
|
30
|
+
requestedBy: {
|
|
31
|
+
id: string;
|
|
32
|
+
type: string;
|
|
33
|
+
};
|
|
34
|
+
decisionId: string;
|
|
35
|
+
requestId: string;
|
|
36
|
+
approval?: string;
|
|
37
|
+
release: string;
|
|
38
|
+
/** Runtime options the operator chose (part of what was approved), reused by restart and rollback. */
|
|
39
|
+
runtime?: {
|
|
40
|
+
accounts?: "operator-sessions";
|
|
41
|
+
};
|
|
42
|
+
pid?: number | null;
|
|
43
|
+
url?: string | null;
|
|
44
|
+
checks?: Check[];
|
|
45
|
+
failure?: {
|
|
46
|
+
code: string;
|
|
47
|
+
message: string;
|
|
48
|
+
};
|
|
49
|
+
restored?: {
|
|
50
|
+
deployment: string;
|
|
51
|
+
ok: boolean;
|
|
52
|
+
checks: Check[];
|
|
53
|
+
} | null;
|
|
54
|
+
receipt?: Record<string, unknown>;
|
|
55
|
+
startedAt: string;
|
|
56
|
+
finishedAt?: string;
|
|
57
|
+
supersededBy?: string;
|
|
58
|
+
__version?: number;
|
|
59
|
+
}
|
|
60
|
+
/** What the platform observes of a running release: process, artifact, health, AppPort surface. */
|
|
61
|
+
export declare function observe(url: string | null, pid: number | null | undefined, artifact: ArtifactRecord, declared: string[]): Promise<Check[]>;
|
|
62
|
+
export interface ReleasesOptions {
|
|
63
|
+
dir: string;
|
|
64
|
+
artifacts: Artifacts;
|
|
65
|
+
/** [executable, ...args] that runs AppBoundry's CLI (`appboundry`). */
|
|
66
|
+
appboundry: () => string[] | null;
|
|
67
|
+
readinessTimeoutMs?: number;
|
|
68
|
+
/** Test seam: what the candidate is started with (a failing runtime, say). */
|
|
69
|
+
runArgs?: (args: string[]) => string[];
|
|
70
|
+
}
|
|
71
|
+
export declare class Releases {
|
|
72
|
+
#private;
|
|
73
|
+
readonly ready: Promise<{
|
|
74
|
+
interrupted: string[];
|
|
75
|
+
}>;
|
|
76
|
+
constructor(db: StateFirstDB, options: ReleasesOptions);
|
|
77
|
+
/** Deploy an artifact to an environment (the caller's authority and approval were checked by the platform). */
|
|
78
|
+
deploy(input: {
|
|
79
|
+
artifact: string;
|
|
80
|
+
environment: string;
|
|
81
|
+
kind?: ReleaseRecord["kind"];
|
|
82
|
+
rollbackOf?: string;
|
|
83
|
+
approval?: string;
|
|
84
|
+
runtime?: ReleaseRecord["runtime"];
|
|
85
|
+
}, caller: Caller): Promise<ReleaseRecord>;
|
|
86
|
+
/** Roll back to an earlier deployment's artifact (default: the one the current deployment replaced). */
|
|
87
|
+
rollback(input: {
|
|
88
|
+
application: string;
|
|
89
|
+
environment: string;
|
|
90
|
+
to?: string;
|
|
91
|
+
approval?: string;
|
|
92
|
+
}, caller: Caller): Promise<ReleaseRecord>;
|
|
93
|
+
/** What is running now, observed (not what was last recorded). */
|
|
94
|
+
status(application: string, environment: string): Promise<{
|
|
95
|
+
application: string;
|
|
96
|
+
environment: string;
|
|
97
|
+
current: ReleaseRecord | null;
|
|
98
|
+
running: boolean;
|
|
99
|
+
checks: Check[];
|
|
100
|
+
}>;
|
|
101
|
+
history(application: string, environment: string): Promise<ReleaseRecord[]>;
|
|
102
|
+
get(id: string): Promise<ReleaseRecord>;
|
|
103
|
+
/** Stop the running deployment (the state stays). */
|
|
104
|
+
stop(application: string, environment: string, caller: Caller): Promise<ReleaseRecord>;
|
|
105
|
+
/** Start the current deployment's release again (after a stop or a machine restart), checked like a deployment. */
|
|
106
|
+
restart(application: string, environment: string, caller: Caller): Promise<ReleaseRecord>;
|
|
107
|
+
/** Stop every running application this store knows of (tests, or a deliberate shutdown). */
|
|
108
|
+
stopAll(): Promise<void>;
|
|
109
|
+
}
|
|
110
|
+
export declare const releaseLog: (dir: string, application: string, environment: string, id: string) => string;
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deployments of immutable artifacts to a local AppBoundry runtime (docs/M2-AGENT-OPERATIONS.md
|
|
3
|
+
* G10–G12). The deployment unit is a validated artifact (artifacts.ts), never a repository or a
|
|
4
|
+
* workspace: the platform writes the artifact's verified bytes into a release directory and runs
|
|
5
|
+
* `appboundry run` on it, with the environment's state directory.
|
|
6
|
+
*
|
|
7
|
+
* deploying ──▶ running (receipt) ──▶ superseded (a later deployment is running)
|
|
8
|
+
* │ └──▶ stopped
|
|
9
|
+
* └──▶ failed (no receipt; the previous deployment is restored and checked, when there was one)
|
|
10
|
+
*
|
|
11
|
+
* What runs is observed, not assumed: a deployment is `running` only after the platform itself
|
|
12
|
+
* has checked the process it started (alive), the artifact the runtime loaded (its manifest digest
|
|
13
|
+
* and module digest, from /_appboundry/artifact), its health, and that its AppPort surface serves
|
|
14
|
+
* exactly the capabilities the artifact declares (GET /appport/manifest). A successful start
|
|
15
|
+
* command is not success. Status probes the same way, every time it is asked.
|
|
16
|
+
*
|
|
17
|
+
* One deployment at a time per environment (a fenced lock record). AppBoundry's state for an
|
|
18
|
+
* environment is one directory owned by one process, so the previous process stops before the
|
|
19
|
+
* candidate starts (seconds of downtime, as in deployments.ts); a candidate that fails its checks
|
|
20
|
+
* is stopped and the previous release is started again on the same state and checked.
|
|
21
|
+
* A rollback is a new deployment of an earlier artifact, linked to what it rolled back.
|
|
22
|
+
*/
|
|
23
|
+
import { spawn } from "node:child_process";
|
|
24
|
+
import { createWriteStream, existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
25
|
+
import { join } from "node:path";
|
|
26
|
+
import { randomUUID } from "node:crypto";
|
|
27
|
+
import { readAll } from "../runtime/data.js";
|
|
28
|
+
export const RELEASES = "feltkit.platform.releases";
|
|
29
|
+
export const RELEASE_ENVIRONMENTS = "feltkit.platform.release-environments";
|
|
30
|
+
const fail = (code, message, details) => Object.assign(new Error(message), { code, ...(details ? { details } : {}) });
|
|
31
|
+
const now = () => new Date().toISOString();
|
|
32
|
+
const hex = (digest) => digest.replace(/^sha256:/, "");
|
|
33
|
+
const alive = (pid) => {
|
|
34
|
+
if (!pid)
|
|
35
|
+
return false;
|
|
36
|
+
try {
|
|
37
|
+
process.kill(pid, 0);
|
|
38
|
+
const stat = readFileSync(`/proc/${pid}/stat`, "utf8");
|
|
39
|
+
return stat.slice(stat.lastIndexOf(")") + 2, stat.lastIndexOf(")") + 3) !== "Z";
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
async function getJSON(url, timeoutMs = 3000) {
|
|
46
|
+
const response = await fetch(url, { signal: AbortSignal.timeout(timeoutMs) });
|
|
47
|
+
return { status: response.status, body: await response.json().catch(() => null) };
|
|
48
|
+
}
|
|
49
|
+
/** What the platform observes of a running release: process, artifact, health, AppPort surface. */
|
|
50
|
+
export async function observe(url, pid, artifact, declared) {
|
|
51
|
+
const checks = [{ check: "process", ok: alive(pid), expected: "alive", actual: alive(pid) ? `pid ${pid}` : "not running" }];
|
|
52
|
+
if (!url)
|
|
53
|
+
return [...checks, { check: "reachable", ok: false, detail: "no address" }];
|
|
54
|
+
try {
|
|
55
|
+
const a = await getJSON(`${url}/_appboundry/artifact`);
|
|
56
|
+
checks.push({ check: "artifact", ok: a.status === 200 && a.body?.manifestSha256 === hex(artifact.digest), expected: hex(artifact.digest), actual: a.body?.manifestSha256 ?? `HTTP ${a.status}` });
|
|
57
|
+
checks.push({ check: "module", ok: a.body?.module?.sha256 === artifact.module.sha256, expected: artifact.module.sha256, actual: a.body?.module?.sha256 ?? null });
|
|
58
|
+
const h = await getJSON(`${url}/_appboundry/health`);
|
|
59
|
+
checks.push({ check: "health", ok: h.status === 200 && h.body?.status === "ready", expected: "ready", actual: h.body?.status ?? `HTTP ${h.status}`, detail: "the runtime's own report; not trusted alone" });
|
|
60
|
+
const m = await getJSON(`${url}/appport/manifest`);
|
|
61
|
+
const served = Array.isArray(m.body?.capabilities) ? m.body.capabilities.map((c) => c.name).filter((n) => !n.startsWith("appport.")).sort() : null;
|
|
62
|
+
checks.push({ check: "capabilities", ok: !!served && JSON.stringify(served) === JSON.stringify([...declared].sort()), expected: [...declared].sort(), actual: served ?? `HTTP ${m.status}` });
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
checks.push({ check: "reachable", ok: false, detail: error.message });
|
|
66
|
+
}
|
|
67
|
+
return checks;
|
|
68
|
+
}
|
|
69
|
+
export class Releases {
|
|
70
|
+
#db;
|
|
71
|
+
#options;
|
|
72
|
+
ready;
|
|
73
|
+
constructor(db, options) {
|
|
74
|
+
this.#db = db;
|
|
75
|
+
this.#options = options;
|
|
76
|
+
mkdirSync(options.dir, { recursive: true });
|
|
77
|
+
this.ready = this.#recover();
|
|
78
|
+
}
|
|
79
|
+
#envId(application, environment) {
|
|
80
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/.test(application) || !/^[a-z][a-z0-9-]{0,31}$/.test(environment))
|
|
81
|
+
throw fail("INVALID_INPUT", "application and environment are names (letters, digits, . _ -).");
|
|
82
|
+
return `${application}__${environment}`;
|
|
83
|
+
}
|
|
84
|
+
async #env(application, environment) {
|
|
85
|
+
const id = this.#envId(application, environment);
|
|
86
|
+
return (await this.#db.collection(RELEASE_ENVIRONMENTS).get(id)) ?? { id, application, environment, current: null, deploying: null, pid: null, url: null };
|
|
87
|
+
}
|
|
88
|
+
async #putEnv(env, patch) {
|
|
89
|
+
const { __version, ...rest } = env;
|
|
90
|
+
const next = { ...rest, ...patch };
|
|
91
|
+
try {
|
|
92
|
+
await this.#db.transaction({ operations: [{ collection: RELEASE_ENVIRONMENTS, id: env.id, ...(__version ? { ifVersion: __version } : { requireAbsent: true }), value: next }] });
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
if (error.code === "PRECONDITION_FAILED")
|
|
96
|
+
throw fail("CONFLICT", `${env.application}/${env.environment} changed concurrently (another deployment?); inspect it and retry.`);
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
return { ...next, __version: (__version ?? 0) + 1 };
|
|
100
|
+
}
|
|
101
|
+
async #get(id) {
|
|
102
|
+
if (typeof id !== "string" || !/^rel_[0-9a-f]{24}$/.test(id))
|
|
103
|
+
throw fail("INVALID_INPUT", "deployment is a deployment id (rel_…).");
|
|
104
|
+
const record = (await this.#db.collection(RELEASES).get(id));
|
|
105
|
+
if (!record)
|
|
106
|
+
throw fail("NOT_FOUND", `No deployment ${id}.`);
|
|
107
|
+
return record;
|
|
108
|
+
}
|
|
109
|
+
async #put(record, patch) {
|
|
110
|
+
const { __version, ...rest } = record;
|
|
111
|
+
const next = { ...rest, ...patch };
|
|
112
|
+
await this.#db.transaction({ operations: [{ collection: RELEASES, id: record.id, ...(__version ? { ifVersion: __version } : { requireAbsent: true }), value: next }] });
|
|
113
|
+
return { ...next, __version: (__version ?? 0) + 1 };
|
|
114
|
+
}
|
|
115
|
+
/** Start `appboundry run` on a release directory with the environment's state; its address once it listens. */
|
|
116
|
+
async #start(release, state, log, runtime = {}) {
|
|
117
|
+
const cli = this.#options.appboundry();
|
|
118
|
+
if (!cli)
|
|
119
|
+
throw fail("feltkit.RUNTIME_UNAVAILABLE", "No AppBoundry runtime is configured (FELTKIT_APPBOUNDRY_BIN, or the platform's appboundry option); nothing was deployed.");
|
|
120
|
+
const args = (this.#options.runArgs ?? ((a) => a))([...cli.slice(1), "run", release, "--state", state, "--port", "0", "--environment", "production", ...(runtime?.accounts ? ["--accounts", runtime.accounts] : [])]);
|
|
121
|
+
const out = createWriteStream(log, { flags: "a" });
|
|
122
|
+
const child = spawn(cli[0], args, { cwd: release, detached: true, stdio: ["ignore", "pipe", "pipe"], env: { PATH: process.env.PATH ?? "/usr/bin:/bin", HOME: state, NO_COLOR: "1" } });
|
|
123
|
+
child.unref();
|
|
124
|
+
let text = "";
|
|
125
|
+
const onData = (d) => {
|
|
126
|
+
text += d.toString();
|
|
127
|
+
out.write(d);
|
|
128
|
+
};
|
|
129
|
+
child.stdout.on("data", onData);
|
|
130
|
+
child.stderr.on("data", onData);
|
|
131
|
+
const timeoutMs = this.#options.readinessTimeoutMs ?? 60_000;
|
|
132
|
+
const url = await new Promise((resolveUrl) => {
|
|
133
|
+
const timer = setTimeout(() => resolveUrl(null), timeoutMs);
|
|
134
|
+
const check = () => {
|
|
135
|
+
const match = /App\s+(http:\/\/\S+)/.exec(text);
|
|
136
|
+
if (match) {
|
|
137
|
+
clearTimeout(timer);
|
|
138
|
+
resolveUrl(match[1].replace(/\/$/, ""));
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
child.stdout.on("data", check);
|
|
142
|
+
child.once("exit", () => {
|
|
143
|
+
clearTimeout(timer);
|
|
144
|
+
resolveUrl(null);
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
// Keep the log, but let the process outlive this platform process.
|
|
148
|
+
child.stdout.removeAllListeners("data");
|
|
149
|
+
child.stderr.removeAllListeners("data");
|
|
150
|
+
child.stdout.on("data", (d) => out.write(d));
|
|
151
|
+
child.stderr.on("data", (d) => out.write(d));
|
|
152
|
+
child.stdout.unref?.();
|
|
153
|
+
child.stderr.unref?.();
|
|
154
|
+
return url ? { pid: child.pid ?? null, url } : { pid: child.pid ?? null, url: null, error: `the runtime did not report an address within ${timeoutMs} ms: ${text.trim().split("\n").slice(-3).join(" ")}` };
|
|
155
|
+
}
|
|
156
|
+
#stop(pid) {
|
|
157
|
+
if (!pid || !alive(pid))
|
|
158
|
+
return Promise.resolve();
|
|
159
|
+
try {
|
|
160
|
+
process.kill(-pid, "SIGTERM");
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
try {
|
|
164
|
+
process.kill(pid, "SIGTERM");
|
|
165
|
+
}
|
|
166
|
+
catch { }
|
|
167
|
+
}
|
|
168
|
+
return new Promise((done) => {
|
|
169
|
+
const started = Date.now();
|
|
170
|
+
const poll = setInterval(() => {
|
|
171
|
+
if (!alive(pid) || Date.now() - started > 10_000) {
|
|
172
|
+
if (alive(pid)) {
|
|
173
|
+
try {
|
|
174
|
+
process.kill(-pid, "SIGKILL");
|
|
175
|
+
}
|
|
176
|
+
catch { }
|
|
177
|
+
}
|
|
178
|
+
clearInterval(poll);
|
|
179
|
+
done();
|
|
180
|
+
}
|
|
181
|
+
}, 100);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
#declared(artifact, release) {
|
|
185
|
+
const manifest = JSON.parse(readFileSync(join(release, "manifest.json"), "utf8"));
|
|
186
|
+
return (manifest.functions ?? []).filter((f) => f.capability).map((f) => f.capability.name);
|
|
187
|
+
}
|
|
188
|
+
/** Deploy an artifact to an environment (the caller's authority and approval were checked by the platform). */
|
|
189
|
+
async deploy(input, caller) {
|
|
190
|
+
await this.ready;
|
|
191
|
+
const artifact = await this.#options.artifacts.get(input.artifact);
|
|
192
|
+
const application = artifact.application.id || artifact.application.name;
|
|
193
|
+
let env = await this.#env(application, input.environment);
|
|
194
|
+
if (env.deploying)
|
|
195
|
+
throw fail("CONFLICT", `${application}/${input.environment} is being deployed by ${env.deploying}; one deployment at a time.`);
|
|
196
|
+
const id = `rel_${randomUUID().replace(/-/g, "").slice(0, 24)}`;
|
|
197
|
+
env = await this.#putEnv(env, { deploying: id });
|
|
198
|
+
const base = join(this.#options.dir, application, input.environment);
|
|
199
|
+
const release = join(base, "releases", id);
|
|
200
|
+
const state = join(base, "state");
|
|
201
|
+
mkdirSync(state, { recursive: true });
|
|
202
|
+
const previous = env.current ? await this.#get(env.current) : null;
|
|
203
|
+
let record = await this.#put({
|
|
204
|
+
id,
|
|
205
|
+
application,
|
|
206
|
+
environment: input.environment,
|
|
207
|
+
kind: input.kind ?? "deploy",
|
|
208
|
+
artifact: { id: artifact.id, digest: artifact.digest, module: artifact.module.sha256 },
|
|
209
|
+
previous: previous ? { deployment: previous.id, artifact: previous.artifact.id } : null,
|
|
210
|
+
...(input.rollbackOf ? { rollbackOf: input.rollbackOf } : {}),
|
|
211
|
+
state: "deploying",
|
|
212
|
+
requestedBy: { id: caller.principal.id, type: caller.principal.type },
|
|
213
|
+
decisionId: caller.decisionId,
|
|
214
|
+
requestId: caller.requestId,
|
|
215
|
+
...(input.approval ? { approval: input.approval } : {}),
|
|
216
|
+
release,
|
|
217
|
+
...(input.runtime?.accounts ? { runtime: { accounts: input.runtime.accounts } } : {}),
|
|
218
|
+
startedAt: now(),
|
|
219
|
+
}, {});
|
|
220
|
+
const finish = async (patch, envPatch) => {
|
|
221
|
+
record = await this.#put(record, { ...patch, finishedAt: now() });
|
|
222
|
+
env = await this.#putEnv(await this.#env(application, input.environment), { ...envPatch, deploying: null });
|
|
223
|
+
return record;
|
|
224
|
+
};
|
|
225
|
+
// 1. The artifact's bytes, verified, into the release directory. A corrupted artifact stops
|
|
226
|
+
// here, before anything that is running is touched.
|
|
227
|
+
try {
|
|
228
|
+
await this.#options.artifacts.materialize(artifact.id, release);
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
return finish({ state: "failed", failure: { code: error.code ?? "feltkit.ARTIFACT_CORRUPTED", message: error.message }, restored: null }, {});
|
|
232
|
+
}
|
|
233
|
+
const declared = this.#declared(artifact, release);
|
|
234
|
+
// 2. Cut over: the state directory has one owner.
|
|
235
|
+
await this.#stop(env.pid);
|
|
236
|
+
const log = join(base, `${id}.log`);
|
|
237
|
+
const started = await this.#start(release, state, log, input.runtime);
|
|
238
|
+
const checks = started.url ? await this.#settle(started.url, started.pid, artifact, declared) : [{ check: "start", ok: false, detail: started.error }];
|
|
239
|
+
if (checks.every((c) => c.ok)) {
|
|
240
|
+
if (previous)
|
|
241
|
+
await this.#put(previous, { state: "superseded", supersededBy: id }).catch(() => undefined);
|
|
242
|
+
const receipt = { id: `rcp_${id.slice(4)}`, deployment: id, kind: record.kind, application, environment: input.environment, artifact: artifact.digest, artifactId: artifact.id, module: artifact.module.sha256, sourceRevision: artifact.provenance.sourceRevision, previous: record.previous, requestedBy: record.requestedBy, decisionId: caller.decisionId, ...(input.approval ? { approval: input.approval } : {}), ...(input.rollbackOf ? { rollbackOf: input.rollbackOf } : {}), checks, url: started.url, at: now() };
|
|
243
|
+
return finish({ state: "running", pid: started.pid, url: started.url, checks, receipt }, { current: id, pid: started.pid, url: started.url });
|
|
244
|
+
}
|
|
245
|
+
// 3. The candidate failed its checks: stop it, and restore what ran before.
|
|
246
|
+
await this.#stop(started.pid);
|
|
247
|
+
const failure = { code: started.url ? "feltkit.HEALTH_FAILED" : "feltkit.STARTUP_FAILED", message: `The deployment did not pass the platform's checks: ${checks.filter((c) => !c.ok).map((c) => `${c.check} (${c.detail ?? `expected ${JSON.stringify(c.expected)}, got ${JSON.stringify(c.actual)}`})`).join("; ")}.` };
|
|
248
|
+
let restored = null;
|
|
249
|
+
let envPatch = { current: previous?.id ?? null, pid: null, url: null };
|
|
250
|
+
if (previous) {
|
|
251
|
+
const prev = await this.#options.artifacts.get(previous.artifact.id);
|
|
252
|
+
const again = await this.#start(previous.release, state, join(base, `${previous.id}.restore.log`), previous.runtime);
|
|
253
|
+
const prevChecks = again.url ? await this.#settle(again.url, again.pid, prev, this.#declared(prev, previous.release)) : [{ check: "start", ok: false, detail: again.error }];
|
|
254
|
+
restored = { deployment: previous.id, ok: prevChecks.every((c) => c.ok), checks: prevChecks };
|
|
255
|
+
envPatch = { current: previous.id, pid: again.pid, url: again.url };
|
|
256
|
+
await this.#put(previous, { pid: again.pid, url: again.url, ...(restored.ok ? {} : { state: "failed", failure: { code: "feltkit.RESTORE_FAILED", message: "Restored after a failed deployment, but it did not pass the checks." } }) }).catch(() => undefined);
|
|
257
|
+
}
|
|
258
|
+
return finish({ state: "failed", pid: null, url: null, checks, failure, restored }, envPatch);
|
|
259
|
+
}
|
|
260
|
+
/** Observe until every check passes or the readiness timeout ends; the last observation. */
|
|
261
|
+
async #settle(url, pid, artifact, declared) {
|
|
262
|
+
const deadline = Date.now() + (this.#options.readinessTimeoutMs ?? 60_000);
|
|
263
|
+
let checks = await observe(url, pid, artifact, declared);
|
|
264
|
+
while (!checks.every((c) => c.ok) && Date.now() < deadline && alive(pid)) {
|
|
265
|
+
await new Promise((r) => setTimeout(r, 250));
|
|
266
|
+
checks = await observe(url, pid, artifact, declared);
|
|
267
|
+
}
|
|
268
|
+
return checks;
|
|
269
|
+
}
|
|
270
|
+
/** Roll back to an earlier deployment's artifact (default: the one the current deployment replaced). */
|
|
271
|
+
async rollback(input, caller) {
|
|
272
|
+
const env = await this.#env(input.application, input.environment);
|
|
273
|
+
if (!env.current)
|
|
274
|
+
throw fail("FAILED_PRECONDITION", `${input.application}/${input.environment} has no current deployment to roll back.`);
|
|
275
|
+
const current = await this.#get(env.current);
|
|
276
|
+
const targetId = input.to ?? current.previous?.deployment;
|
|
277
|
+
if (!targetId)
|
|
278
|
+
throw fail("FAILED_PRECONDITION", `${current.id} replaced nothing; name the deployment to roll back to.`);
|
|
279
|
+
const target = await this.#get(targetId);
|
|
280
|
+
if (target.application !== input.application || target.environment !== input.environment)
|
|
281
|
+
throw fail("INVALID_INPUT", `${targetId} is not a deployment of ${input.application}/${input.environment}.`);
|
|
282
|
+
if (!target.receipt)
|
|
283
|
+
throw fail("FAILED_PRECONDITION", `${targetId} never ran successfully; only a deployment that passed its checks can be rolled back to.`);
|
|
284
|
+
return this.deploy({ artifact: target.artifact.id, environment: input.environment, kind: "rollback", rollbackOf: current.id, ...(target.runtime ? { runtime: target.runtime } : {}), ...(input.approval ? { approval: input.approval } : {}) }, caller);
|
|
285
|
+
}
|
|
286
|
+
/** What is running now, observed (not what was last recorded). */
|
|
287
|
+
async status(application, environment) {
|
|
288
|
+
const env = await this.#env(application, environment);
|
|
289
|
+
if (!env.current)
|
|
290
|
+
return { application, environment, current: null, running: false, checks: [] };
|
|
291
|
+
const current = await this.#get(env.current);
|
|
292
|
+
const artifact = await this.#options.artifacts.get(current.artifact.id);
|
|
293
|
+
const checks = await observe(env.url, env.pid, artifact, this.#declared(artifact, current.release));
|
|
294
|
+
return { application, environment, current, running: checks.every((c) => c.ok), checks };
|
|
295
|
+
}
|
|
296
|
+
async history(application, environment) {
|
|
297
|
+
const all = (await readAll(this.#db, { collection: RELEASES, where: [{ field: "application", eq: application }] }));
|
|
298
|
+
return all.filter((r) => r.application === application && r.environment === environment).sort((a, b) => b.startedAt.localeCompare(a.startedAt));
|
|
299
|
+
}
|
|
300
|
+
async get(id) {
|
|
301
|
+
return this.#get(id);
|
|
302
|
+
}
|
|
303
|
+
/** Stop the running deployment (the state stays). */
|
|
304
|
+
async stop(application, environment, caller) {
|
|
305
|
+
const env = await this.#env(application, environment);
|
|
306
|
+
if (!env.current)
|
|
307
|
+
throw fail("FAILED_PRECONDITION", `${application}/${environment} has nothing deployed.`);
|
|
308
|
+
if (env.deploying)
|
|
309
|
+
throw fail("CONFLICT", `${application}/${environment} is being deployed.`);
|
|
310
|
+
await this.#stop(env.pid);
|
|
311
|
+
await this.#putEnv(env, { pid: null, url: null });
|
|
312
|
+
const current = await this.#get(env.current);
|
|
313
|
+
return this.#put(current, { state: "stopped", pid: null, url: null, failure: { code: "feltkit.STOPPED", message: `Stopped by ${caller.principal.id}.` } });
|
|
314
|
+
}
|
|
315
|
+
/** Start the current deployment's release again (after a stop or a machine restart), checked like a deployment. */
|
|
316
|
+
async restart(application, environment, caller) {
|
|
317
|
+
const env = await this.#env(application, environment);
|
|
318
|
+
if (!env.current)
|
|
319
|
+
throw fail("FAILED_PRECONDITION", `${application}/${environment} has nothing deployed.`);
|
|
320
|
+
const current = await this.#get(env.current);
|
|
321
|
+
return this.deploy({ artifact: current.artifact.id, environment, kind: "restart", ...(current.runtime ? { runtime: current.runtime } : {}) }, caller);
|
|
322
|
+
}
|
|
323
|
+
/** Deployments left `deploying` by a stopped platform fail; the environment lock is released. Running applications keep running. */
|
|
324
|
+
async #recover() {
|
|
325
|
+
const open = (await readAll(this.#db, { collection: RELEASES, where: [{ field: "state", eq: "deploying" }] }));
|
|
326
|
+
for (const r of open) {
|
|
327
|
+
await this.#put(r, { state: "failed", finishedAt: now(), failure: { code: "feltkit.INTERRUPTED", message: "The platform stopped during this deployment; check the environment's status." } }).catch(() => undefined);
|
|
328
|
+
const env = await this.#env(r.application, r.environment);
|
|
329
|
+
if (env.deploying === r.id)
|
|
330
|
+
await this.#putEnv(env, { deploying: null }).catch(() => undefined);
|
|
331
|
+
}
|
|
332
|
+
return { interrupted: open.map((r) => r.id) };
|
|
333
|
+
}
|
|
334
|
+
/** Stop every running application this store knows of (tests, or a deliberate shutdown). */
|
|
335
|
+
async stopAll() {
|
|
336
|
+
const envs = (await readAll(this.#db, { collection: RELEASE_ENVIRONMENTS }));
|
|
337
|
+
await Promise.all(envs.map((e) => this.#stop(e.pid)));
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
export const releaseLog = (dir, application, environment, id) => {
|
|
341
|
+
const path = join(dir, application, environment, `${id}.log`);
|
|
342
|
+
return existsSync(path) ? readFileSync(path, "utf8").slice(-20_000) : "";
|
|
343
|
+
};
|
|
344
|
+
//# sourceMappingURL=releases.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+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CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IAChD,CAAC;IAED,4FAA4F;IAC5F,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,GAAG,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC,CAAmC,CAAC;QAC/G,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;CACF;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,WAAmB,EAAE,WAAmB,EAAE,EAAU,EAAE,EAAE;IAC9F,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IAC9D,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC3E,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The person's review page (docs/M2-AGENT-OPERATIONS.md G13), served by `feltkit platform serve`
|
|
3
|
+
* at /review. It is a client of the same AppPort operations every other client uses (no second
|
|
4
|
+
* API): approval.list / approval.inspect / approval.decide, with the evidence behind each pending
|
|
5
|
+
* operation — the platform-computed diff of its workspace, the recorded test executions and their
|
|
6
|
+
* outcome, the artifact's digest and provenance, and what is running now. Approving sends back the
|
|
7
|
+
* digest of exactly what was shown. The page authenticates with a platform session token given in
|
|
8
|
+
* the URL fragment (never sent to the server in a URL), kept in this tab's sessionStorage.
|
|
9
|
+
*/
|
|
10
|
+
export declare const REVIEW_HTML: string;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The person's review page (docs/M2-AGENT-OPERATIONS.md G13), served by `feltkit platform serve`
|
|
3
|
+
* at /review. It is a client of the same AppPort operations every other client uses (no second
|
|
4
|
+
* API): approval.list / approval.inspect / approval.decide, with the evidence behind each pending
|
|
5
|
+
* operation — the platform-computed diff of its workspace, the recorded test executions and their
|
|
6
|
+
* outcome, the artifact's digest and provenance, and what is running now. Approving sends back the
|
|
7
|
+
* digest of exactly what was shown. The page authenticates with a platform session token given in
|
|
8
|
+
* the URL fragment (never sent to the server in a URL), kept in this tab's sessionStorage.
|
|
9
|
+
*/
|
|
10
|
+
export const REVIEW_HTML = String.raw `<!doctype html>
|
|
11
|
+
<html lang="en">
|
|
12
|
+
<head>
|
|
13
|
+
<meta charset="utf-8">
|
|
14
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
15
|
+
<title>Review · FeltKit</title>
|
|
16
|
+
<style>
|
|
17
|
+
:root { --bg: #fafaf9; --fg: #1c1917; --muted: #78716c; --card: #fff; --line: #e7e5e4; --ok: #15803d; --bad: #b91c1c; --add: #ecfdf5; --del: #fef2f2; --accent: #1d4ed8; }
|
|
18
|
+
@media (prefers-color-scheme: dark) { :root { --bg: #0c0a09; --fg: #f5f5f4; --muted: #a8a29e; --card: #1c1917; --line: #292524; --ok: #4ade80; --bad: #f87171; --add: #052e16; --del: #450a0a; --accent: #93c5fd; } }
|
|
19
|
+
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 system-ui, sans-serif; }
|
|
20
|
+
main { max-width: 960px; margin: 0 auto; padding: 24px 16px; }
|
|
21
|
+
h1 { font-size: 22px; margin: 0 0 4px; } .muted { color: var(--muted); }
|
|
22
|
+
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin: 16px 0; }
|
|
23
|
+
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
|
|
24
|
+
code, pre { font: 13px/1.45 ui-monospace, monospace; } pre { overflow-x: auto; margin: 8px 0; padding: 8px; border: 1px solid var(--line); border-radius: 6px; }
|
|
25
|
+
.add { background: var(--add); } .del { background: var(--del); } .ok { color: var(--ok); } .bad { color: var(--bad); }
|
|
26
|
+
button { font: inherit; padding: 6px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); color: var(--fg); cursor: pointer; }
|
|
27
|
+
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
|
|
28
|
+
h2 { font-size: 17px; margin: 0; } h3 { font-size: 14px; margin: 14px 0 4px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
|
|
29
|
+
</style>
|
|
30
|
+
</head>
|
|
31
|
+
<body>
|
|
32
|
+
<main>
|
|
33
|
+
<h1>Review</h1>
|
|
34
|
+
<p class="muted">Operations agents asked to run, waiting for a person. Approving authorizes exactly what is shown here (its digest), once; the agent's own authority is checked again when it runs.</p>
|
|
35
|
+
<div id="who" class="muted"></div>
|
|
36
|
+
<div id="list"></div>
|
|
37
|
+
</main>
|
|
38
|
+
<script>
|
|
39
|
+
const fromHash = new URLSearchParams(location.hash.slice(1)).get("token");
|
|
40
|
+
if (fromHash) { sessionStorage.setItem("feltkit.platform.token", fromHash); history.replaceState(null, "", location.pathname); }
|
|
41
|
+
const token = sessionStorage.getItem("feltkit.platform.token");
|
|
42
|
+
const esc = (v) => String(v ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
43
|
+
async function op(name, input) {
|
|
44
|
+
const r = await fetch("/appport", { method: "POST", headers: { "content-type": "application/json", authorization: "Bearer " + token }, body: JSON.stringify({ protocol: "appport/1", type: "request", requestId: "review_" + Math.random().toString(36).slice(2), capability: { name, version: 1 }, input }) });
|
|
45
|
+
const body = await r.json();
|
|
46
|
+
if (!body.ok) throw Object.assign(new Error(body.error?.message ?? "failed"), { code: body.error?.code });
|
|
47
|
+
return body.output;
|
|
48
|
+
}
|
|
49
|
+
const patch = (text) => esc(text).split("\n").map((l) => l.startsWith("+") && !l.startsWith("+++") ? '<span class="add">' + l + "</span>" : l.startsWith("-") && !l.startsWith("---") ? '<span class="del">' + l + "</span>" : l).join("\n");
|
|
50
|
+
async function evidence(a) {
|
|
51
|
+
const parts = [];
|
|
52
|
+
let workspace = a.input.workspace, artifact = null;
|
|
53
|
+
if (a.input.artifact) {
|
|
54
|
+
try { artifact = (await op("artifact.inspect", { artifact: a.input.artifact })).artifact; workspace = artifact.provenance.workspace; } catch (e) { parts.push('<p class="bad">Artifact: ' + esc(e.message) + "</p>"); }
|
|
55
|
+
}
|
|
56
|
+
if (artifact) {
|
|
57
|
+
const valid = artifact.validation.platform.every((c) => c.ok) && artifact.validation.verifier.ok;
|
|
58
|
+
parts.push("<h3>Artifact</h3><p data-artifact><code>" + esc(artifact.digest) + "</code> " + esc(artifact.application.id) + ' · <span class="' + (valid ? "ok" : "bad") + '">' + (valid ? "validated" : "NOT validated") + "</span> · built from snapshot <code>" + esc(artifact.provenance.snapshot) + "</code> (" + esc(artifact.provenance.sourceRevision.slice(0, 16)) + "…) by " + esc(artifact.provenance.builtBy.id) + "</p>");
|
|
59
|
+
}
|
|
60
|
+
if (a.input.application && a.input.environment) {
|
|
61
|
+
try {
|
|
62
|
+
const st = await op("release.status", { application: a.input.application, environment: a.input.environment });
|
|
63
|
+
parts.push("<h3>Running now</h3><p>" + (st.current ? "<code>" + esc(st.current.artifact.digest) + "</code> · " + (st.running ? '<span class="ok">observed running</span>' : '<span class="bad">not running</span>') : "nothing deployed") + "</p>");
|
|
64
|
+
} catch {}
|
|
65
|
+
}
|
|
66
|
+
if (workspace) {
|
|
67
|
+
try {
|
|
68
|
+
const d = await op("workspace.diff", { workspace, ...(artifact ? { to: artifact.provenance.snapshot } : {}) });
|
|
69
|
+
parts.push("<h3>Changes (" + d.stats.added + " added, " + d.stats.modified + " modified, " + d.stats.removed + " removed; +" + d.stats.insertions + " −" + d.stats.deletions + ")</h3>" + d.files.map((f) => '<div data-file="' + esc(f.path) + '"><b>' + esc(f.status) + "</b> <code>" + esc(f.path) + "</code>" + (f.patch ? "<pre>" + patch(f.patch) + "</pre>" : "") + "</div>").join(""));
|
|
70
|
+
} catch (e) { parts.push('<p class="bad">Diff: ' + esc(e.message) + "</p>"); }
|
|
71
|
+
try {
|
|
72
|
+
const runs = (await op("command.list", { workspace, limit: 20 })).executions.filter((e) => e.program !== "git");
|
|
73
|
+
parts.push("<h3>Executions</h3>" + (runs.length ? "<ul>" + runs.map((e) => '<li data-execution="' + esc(e.state) + '"><code>' + esc(e.program + " " + e.args.join(" ")) + '</code> · <span class="' + (e.state === "succeeded" ? "ok" : "bad") + '">' + esc(e.state) + "</span>" + (e.exitCode != null ? " (exit " + esc(e.exitCode) + ")" : "") + " · isolation " + esc(e.isolation.filesystem) + "</li>").join("") + "</ul>" : '<p class="muted">none recorded</p>'));
|
|
74
|
+
} catch {}
|
|
75
|
+
}
|
|
76
|
+
return parts.join("");
|
|
77
|
+
}
|
|
78
|
+
async function render() {
|
|
79
|
+
const list = document.getElementById("list");
|
|
80
|
+
if (!token) { list.innerHTML = '<div class="card bad">Open this page with a platform session token: /review#token=fks_…</div>'; return; }
|
|
81
|
+
const { approvals } = await op("approval.list", { state: "pending" });
|
|
82
|
+
document.getElementById("who").textContent = approvals.length + " pending";
|
|
83
|
+
list.innerHTML = approvals.length ? "" : '<div class="card muted">Nothing is waiting for you.</div>';
|
|
84
|
+
for (const a of approvals) {
|
|
85
|
+
const card = document.createElement("div");
|
|
86
|
+
card.className = "card";
|
|
87
|
+
card.dataset.approval = a.id;
|
|
88
|
+
card.innerHTML = '<div class="row"><h2>' + esc(a.operation) + '</h2><span class="muted">proposed by ' + esc(a.proposedBy.id) + " · expires " + esc(new Date(a.expiresAt).toLocaleString()) + "</span></div>" + (a.reason ? "<p>" + esc(a.reason) + "</p>" : "") + "<h3>Exactly this</h3><pre>" + esc(JSON.stringify(a.input, null, 2)) + '</pre><p class="muted">digest <code data-digest>' + esc(a.inputDigest) + "</code></p><h3>Consequences</h3><ul>" + a.consequences.map((c) => "<li>" + esc(c.type) + ": " + esc(c.description) + "</li>").join("") + '</ul><div class="evidence muted">Loading evidence…</div><div class="row" style="margin-top:12px"><button class="primary" data-act="approve">Approve</button><button data-act="reject">Reject</button><span class="result"></span></div>';
|
|
89
|
+
list.appendChild(card);
|
|
90
|
+
evidence(a).then((html) => (card.querySelector(".evidence").outerHTML = '<div class="evidence">' + html + "</div>"));
|
|
91
|
+
for (const button of card.querySelectorAll("button")) button.onclick = async () => {
|
|
92
|
+
const result = card.querySelector(".result");
|
|
93
|
+
try {
|
|
94
|
+
const out = await op("approval.decide", { approval: a.id, decision: button.dataset.act, inputDigest: a.inputDigest });
|
|
95
|
+
result.className = "result ok";
|
|
96
|
+
result.textContent = out.approval.state + " by " + out.approval.decidedBy + ". The agent can now run it, once.";
|
|
97
|
+
for (const b of card.querySelectorAll("button")) b.disabled = true;
|
|
98
|
+
} catch (e) {
|
|
99
|
+
result.className = "result bad";
|
|
100
|
+
result.textContent = (e.code ?? "") + " " + e.message;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
render().catch((e) => (document.getElementById("list").innerHTML = '<div class="card bad">' + esc(e.message) + "</div>"));
|
|
106
|
+
</script>
|
|
107
|
+
</body>
|
|
108
|
+
</html>`;
|
|
109
|
+
//# sourceMappingURL=review.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review.js","sourceRoot":"","sources":["../../src/platform/review.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAkG7B,CAAC"}
|