@feltdb/feltkit 0.3.11 → 0.3.12

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 (98) hide show
  1. package/dist/app.d.ts +80 -3
  2. package/dist/app.js +41 -0
  3. package/dist/app.js.map +1 -1
  4. package/dist/appboundry/build.d.ts +39 -1
  5. package/dist/appboundry/build.js +47 -4
  6. package/dist/appboundry/build.js.map +1 -1
  7. package/dist/appboundry/guest.js +46 -5
  8. package/dist/appboundry/guest.js.map +1 -1
  9. package/dist/appboundry/host.d.ts +24 -5
  10. package/dist/appboundry/host.js +234 -141
  11. package/dist/appboundry/host.js.map +1 -1
  12. package/dist/appboundry/runtime.d.ts +44 -0
  13. package/dist/appboundry/runtime.js +99 -0
  14. package/dist/appboundry/runtime.js.map +1 -0
  15. package/dist/cli/entry.d.ts +1 -0
  16. package/dist/cli/entry.js +4 -0
  17. package/dist/cli/entry.js.map +1 -0
  18. package/dist/cli/main.js +445 -7
  19. package/dist/cli/main.js.map +1 -1
  20. package/dist/cli/test-reporter.d.ts +9 -0
  21. package/dist/cli/test-reporter.js +26 -0
  22. package/dist/cli/test-reporter.js.map +1 -0
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/platform/changes.d.ts +340 -0
  26. package/dist/platform/changes.js +353 -0
  27. package/dist/platform/changes.js.map +1 -0
  28. package/dist/platform/deployments.d.ts +653 -0
  29. package/dist/platform/deployments.js +530 -0
  30. package/dist/platform/deployments.js.map +1 -0
  31. package/dist/platform/operations.d.ts +74 -0
  32. package/dist/platform/operations.js +198 -0
  33. package/dist/platform/operations.js.map +1 -0
  34. package/dist/platform/platform.d.ts +78 -0
  35. package/dist/platform/platform.js +264 -0
  36. package/dist/platform/platform.js.map +1 -0
  37. package/dist/platform/server.d.ts +25 -0
  38. package/dist/platform/server.js +165 -0
  39. package/dist/platform/server.js.map +1 -0
  40. package/dist/platform/source.d.ts +27 -0
  41. package/dist/platform/source.js +142 -0
  42. package/dist/platform/source.js.map +1 -0
  43. package/dist/runtime/backup-environment.d.ts +25 -0
  44. package/dist/runtime/backup-environment.js +60 -0
  45. package/dist/runtime/backup-environment.js.map +1 -0
  46. package/dist/runtime/backup.d.ts +87 -0
  47. package/dist/runtime/backup.js +175 -0
  48. package/dist/runtime/backup.js.map +1 -0
  49. package/dist/runtime/contract.js +4 -3
  50. package/dist/runtime/contract.js.map +1 -1
  51. package/dist/runtime/data.d.ts +6 -2
  52. package/dist/runtime/data.js +29 -23
  53. package/dist/runtime/data.js.map +1 -1
  54. package/dist/runtime/instance.js +17 -0
  55. package/dist/runtime/instance.js.map +1 -1
  56. package/dist/runtime/loader.js +6 -2
  57. package/dist/runtime/loader.js.map +1 -1
  58. package/dist/runtime/migration-context.d.ts +25 -0
  59. package/dist/runtime/migration-context.js +69 -0
  60. package/dist/runtime/migration-context.js.map +1 -0
  61. package/dist/runtime/outbox.d.ts +6 -82
  62. package/dist/runtime/outbox.js +14 -59
  63. package/dist/runtime/outbox.js.map +1 -1
  64. package/dist/runtime/readiness.js +12 -0
  65. package/dist/runtime/readiness.js.map +1 -1
  66. package/dist/runtime/runtime.d.ts +60 -2
  67. package/dist/runtime/runtime.js +301 -116
  68. package/dist/runtime/runtime.js.map +1 -1
  69. package/dist/runtime/services.d.ts +22 -0
  70. package/dist/runtime/services.js +35 -0
  71. package/dist/runtime/services.js.map +1 -1
  72. package/dist/runtime/state-contract.d.ts +167 -0
  73. package/dist/runtime/state-contract.js +438 -0
  74. package/dist/runtime/state-contract.js.map +1 -0
  75. package/dist/runtime/transactions.d.ts +199 -0
  76. package/dist/runtime/transactions.js +246 -0
  77. package/dist/runtime/transactions.js.map +1 -0
  78. package/dist/schema.d.ts +13 -1
  79. package/dist/schema.js +21 -2
  80. package/dist/schema.js.map +1 -1
  81. package/dist/server/admin.d.ts +1 -0
  82. package/dist/server/admin.js +27 -0
  83. package/dist/server/admin.js.map +1 -1
  84. package/dist/server/index.d.ts +4 -0
  85. package/dist/server/index.js +45 -1
  86. package/dist/server/index.js.map +1 -1
  87. package/dist/server/project.d.ts +5 -0
  88. package/dist/server/project.js +13 -2
  89. package/dist/server/project.js.map +1 -1
  90. package/dist/testing/index.d.ts +4 -1
  91. package/dist/testing/index.js +5 -3
  92. package/dist/testing/index.js.map +1 -1
  93. package/package.json +3 -3
  94. package/skills/.claude-plugin/marketplace.json +1 -1
  95. package/skills/.claude-plugin/plugin.json +1 -1
  96. package/skills/feltkit-build/SKILL.md +6 -3
  97. package/skills/feltkit-data/SKILL.md +11 -0
  98. package/skills/feltkit-services/SKILL.md +6 -4
@@ -0,0 +1,264 @@
1
+ /**
2
+ * The FeltKit platform: the development and operations capabilities (operations.ts) as one
3
+ * AppPort application, `dev.feltkit.platform`, over a root directory of projects.
4
+ *
5
+ * identity platform sessions (`fks_…` tokens, FeltKit's session store) for agents and people;
6
+ * the local CLI acts as the workspace owner
7
+ * authority FeltKit's Authority with the profiles below as roles, evaluated by AppPort on every
8
+ * invocation: a revoked session is refused at its next call, connected or not
9
+ * evidence every invocation, allowed or refused, in the platform's activity log: principal,
10
+ * capability, decision id, policy version, outcome
11
+ * state one FeltDB store under <root>/.feltkit-platform, the platform's own (sessions,
12
+ * activity); application state stays in each project's environments
13
+ *
14
+ * The CLI (`feltkit op`), AppPort over HTTP (`/appport`) and MCP (`/mcp`) all dispatch through
15
+ * this one application.
16
+ */
17
+ import { AsyncLocalStorage } from "node:async_hooks";
18
+ import { spawn } from "node:child_process";
19
+ import { randomUUID } from "node:crypto";
20
+ import { existsSync } from "node:fs";
21
+ import { userInfo } from "node:os";
22
+ import { extname, isAbsolute, join, relative, resolve } from "node:path";
23
+ import { fileURLToPath } from "node:url";
24
+ import { AppPortError, createApplication, createMcpBridge, defineCapability } from "@appport/sdk";
25
+ import { ActivityLog } from "../runtime/activity.js";
26
+ import { Authority, fromAppPortPrincipal, toAppPortPrincipal } from "../runtime/authority.js";
27
+ import { resolveEnvironment } from "../runtime/environment.js";
28
+ import { InstanceFactory } from "../runtime/instance.js";
29
+ import { FeltDbSessionStore } from "../runtime/sessions.js";
30
+ import { ChangeSets } from "./changes.js";
31
+ import { Deployments } from "./deployments.js";
32
+ import { OPERATIONS, PLATFORM_PERMISSIONS, deployScope } from "./operations.js";
33
+ export const PLATFORM_APPLICATION = "dev.feltkit.platform";
34
+ const VERSION = (await import("../server/project.js")).SDK_VERSION;
35
+ /**
36
+ * Authority profiles: permission sets on FeltKit's authority (docs/AGENT-OPERATIONS.md §2), not
37
+ * another permission system. `deploy:<project>/<environment>` is one profile per target: it holds
38
+ * develop's permissions and may apply change sets to that project and environment only.
39
+ */
40
+ export const PROFILES = {
41
+ inspect: [PLATFORM_PERMISSIONS.read],
42
+ develop: [PLATFORM_PERMISSIONS.read, PLATFORM_PERMISSIONS.develop, PLATFORM_PERMISSIONS.logs],
43
+ "deploy:{project}/{environment}": [PLATFORM_PERMISSIONS.read, PLATFORM_PERMISSIONS.develop, PLATFORM_PERMISSIONS.logs, PLATFORM_PERMISSIONS.deploy, deployScope("{project}", "{environment}")],
44
+ owner: ["feltkit.platform.*"],
45
+ };
46
+ const DEPLOY_ROLE = /^deploy:([A-Za-z0-9_-][A-Za-z0-9._-]*(?:\/[A-Za-z0-9_-][A-Za-z0-9._-]*)*)\/([a-z][a-z0-9-]*)$/;
47
+ /** A profile name: one of PROFILES, or a deploy profile for a project and environment. */
48
+ export const isProfile = (role) => (role in PROFILES && !role.includes("{")) || DEPLOY_ROLE.test(role);
49
+ /** FeltKit's Authority, with the deploy profile resolved for the project and environment its role names. */
50
+ class PlatformAuthority extends Authority {
51
+ permissionsFor(principal) {
52
+ const granted = new Set(super.permissionsFor(principal));
53
+ for (const role of principal?.roles ?? []) {
54
+ const match = DEPLOY_ROLE.exec(role);
55
+ if (!match)
56
+ continue;
57
+ for (const permission of PROFILES["deploy:{project}/{environment}"])
58
+ granted.add(permission.replace("{project}", match[1]).replace("{environment}", match[2]));
59
+ }
60
+ return [...granted];
61
+ }
62
+ }
63
+ /** The MCP tool name of an operation (AppPort's projection: dots become underscores). */
64
+ export const toolName = (operation) => operation.replace(/\./g, "_");
65
+ export class Platform {
66
+ root;
67
+ instance;
68
+ sessions;
69
+ authority;
70
+ activity;
71
+ appport;
72
+ changes;
73
+ deployments;
74
+ /** The invocation in progress: its caller, and the decision that allowed it (for the evidence). */
75
+ #caller = new AsyncLocalStorage();
76
+ /** `fault` is a test seam (changes.ts): it simulates the process stopping at a named point. */
77
+ static open(root, options = {}) {
78
+ return new Platform(resolve(root), options);
79
+ }
80
+ constructor(root, options) {
81
+ this.root = root;
82
+ const environment = resolveEnvironment({ projectDir: root, appName: "feltkit-platform", name: "development", env: {}, storage: { kind: "local", path: join(root, ".feltkit-platform", "state") } });
83
+ this.instance = new InstanceFactory().open(environment);
84
+ this.sessions = new FeltDbSessionStore(this.instance.handle("feltkit.platform.sessions"));
85
+ this.authority = new PlatformAuthority(PLATFORM_APPLICATION, PROFILES);
86
+ this.deployments = new Deployments(this.instance.handle("feltkit.platform.deployments"), { cli: runCli, command: cliCommand, projectDir: (project) => this.projectDir(project), ...(options.readinessTimeoutMs ? { readinessTimeoutMs: options.readinessTimeoutMs } : {}), ...(options.deployFault ? { fault: options.deployFault } : {}) });
87
+ this.changes = new ChangeSets(this.instance.handle("feltkit.platform.changes"), { workspaces: join(root, ".feltkit-platform", "workspaces"), cli: runCli, deploy: (input, caller) => this.deployments.deploy(input, caller), projectDir: (project) => this.projectDir(project), ...(options.fault ? { fault: options.fault } : {}) });
88
+ this.activity = new ActivityLog(this.instance.handle("feltkit.platform.activity"), { mode: "all", evidence: async () => ({ items: [], truncated: false }) });
89
+ this.appport = createApplication({
90
+ application: { id: PLATFORM_APPLICATION, name: "FeltKit", version: VERSION, description: "FeltKit's application lifecycle: inspect, build, test (and, next, change, deploy and operate) FeltKit applications." },
91
+ capabilities: OPERATIONS.map((operation) => this.#capability(operation)),
92
+ authorizer: this.authority.authorizer,
93
+ sessions: this.sessions,
94
+ mode: "production",
95
+ });
96
+ // Every transport (HTTP, MCP, the CLI) dispatches through handleRequest: evidence for each
97
+ // invocation, allowed or refused, with the caller and the authority's decision.
98
+ const original = this.appport.handleRequest.bind(this.appport);
99
+ this.appport.handleRequest = async (request, options = {}) => {
100
+ const principal = fromAppPortPrincipal(options?.principal ?? options?.session?.principal) ?? null;
101
+ const started = Date.now();
102
+ const call = { principal };
103
+ const response = await this.#caller.run(call, () => original(request, options));
104
+ // A handler's own refusal (a stale base, say) answers without AppPort's decision reference;
105
+ // the decision that let it run is still the evidence.
106
+ const decisionId = response.authorizationDecision?.decisionId ?? response.error?.details?.decisionId ?? call.decisionId;
107
+ const decision = decisionId ? { decisionId: String(decisionId) } : undefined;
108
+ this.activity.record({
109
+ kind: "capability",
110
+ name: String(request?.capability?.name ?? "?"),
111
+ capability: { name: String(request?.capability?.name ?? "?"), version: Number(request?.capability?.version ?? 1) },
112
+ via: String(options?.transport ?? "appport"),
113
+ requestId: String(request?.requestId ?? ""),
114
+ principal: principal ? { id: principal.id, type: principal.type, roles: principal.roles } : null,
115
+ authority: { required: OPERATIONS.find((o) => o.name === request?.capability?.name)?.permission ?? "", allowed: response.ok || !["FORBIDDEN", "UNAUTHORIZED"].includes(String(response.error?.code)), decisionId: decision?.decisionId ?? "", policyVersion: this.authority.policyVersion },
116
+ outcome: response.ok ? "success" : ["FORBIDDEN", "UNAUTHORIZED"].includes(String(response.error?.code)) ? "denied" : "error",
117
+ ...(response.ok ? {} : { error: { code: String(response.error?.code), message: String(response.error?.message ?? "") } }),
118
+ durationMs: Date.now() - started,
119
+ argKeys: Object.keys((request?.input ?? {})),
120
+ });
121
+ return response;
122
+ };
123
+ }
124
+ /** An operation as an AppPort capability: authority before input (an unauthorized caller learns nothing of the input contract). */
125
+ #capability(operation) {
126
+ const gate = (value) => {
127
+ const call = this.#caller.getStore();
128
+ const principal = call?.principal ?? null;
129
+ if (!principal)
130
+ throw new AppPortError("UNAUTHORIZED", "A platform session is required.");
131
+ const required = [operation.permission, ...(operation.scope && value && typeof value === "object" ? [operation.scope(value)] : [])];
132
+ const missing = required.find((permission) => !this.holds(principal, permission));
133
+ if (missing) {
134
+ // A refusal is a decision too: it carries an id, recorded with the evidence.
135
+ throw new AppPortError("FORBIDDEN", `${operation.name} requires ${missing}; ${principal.id} (${principal.roles.join(", ") || "no profile"}) does not hold it.`, { details: { decisionId: `dec_${randomUUID()}`, required: missing, policyVersion: this.authority.policyVersion } });
136
+ }
137
+ // FeltKit's own allow decision (the scoped check); AppPort's, when it reaches the handler, replaces it.
138
+ if (call && !call.decisionId)
139
+ call.decisionId = `dec_${randomUUID()}`;
140
+ };
141
+ const input = Object.freeze({ ...operation.input, appport: "schema", validate: (value, path) => (gate(value), operation.input.validate(value, path)), toJSONSchema: () => operation.input.toJSONSchema() });
142
+ return defineCapability({
143
+ name: operation.name,
144
+ version: operation.version,
145
+ description: operation.description,
146
+ input: input,
147
+ output: operation.output,
148
+ authorization: [operation.permission],
149
+ effect: operation.effect,
150
+ integration: { name: operation.name, version: operation.version, purpose: operation.integration.purpose, authority: operation.permission, effects: operation.integration.effects, approval: operation.integration.approval, failures: operation.integration.failures },
151
+ handler: async (value, context) => {
152
+ const args = value;
153
+ const project = String(args.project ?? "");
154
+ const projectDir = this.projectDir(project);
155
+ const call = this.#caller.getStore();
156
+ const principal = fromAppPortPrincipal(context?.principal ?? context?.session?.principal) ?? call?.principal;
157
+ if (!principal)
158
+ throw new AppPortError("UNAUTHORIZED", "A platform session is required.");
159
+ if (call && context?.authorizationDecision?.decisionId)
160
+ call.decisionId = String(context.authorizationDecision.decisionId);
161
+ const caller = { principal, decisionId: String(call?.decisionId ?? context?.authorizationDecision?.decisionId ?? ""), requestId: String(context?.requestId ?? "") };
162
+ try {
163
+ return await operation.run({ project, projectDir, caller, changes: this.changes, deployments: this.deployments, cli: (cliArgs) => runCli(projectDir, cliArgs) }, args);
164
+ }
165
+ catch (error) {
166
+ if (error instanceof AppPortError)
167
+ throw error;
168
+ const code = String(error.code ?? "INTERNAL_ERROR");
169
+ const kept = ["INVALID_INPUT", "NOT_FOUND", "CONFLICT", "FORBIDDEN"].includes(code) || code.startsWith("feltkit.");
170
+ const details = error.details;
171
+ throw new AppPortError(kept ? code : "INTERNAL_ERROR", error.message, details ? { details } : undefined);
172
+ }
173
+ },
174
+ });
175
+ }
176
+ /** A project directory inside the root: never outside it, and it must be a FeltKit project. */
177
+ projectDir(project) {
178
+ if (!project || isAbsolute(project))
179
+ throw new AppPortError("INVALID_INPUT", "project is a path relative to the platform's root.");
180
+ const dir = resolve(this.root, project);
181
+ const rel = relative(this.root, dir);
182
+ if (rel.startsWith("..") || isAbsolute(rel) || rel.split(/[\\/]/).includes(".feltkit-platform"))
183
+ throw new AppPortError("FORBIDDEN", `${project} is outside the platform's root.`);
184
+ if (!existsSync(join(dir, "feltkit")))
185
+ throw new AppPortError("NOT_FOUND", `${project} is not a FeltKit project (no feltkit/ directory).`);
186
+ return dir;
187
+ }
188
+ /** Invoke an operation as `principal` (the CLI adapter), through the same AppPort pipeline. */
189
+ async invoke(name, input, options = {}) {
190
+ const requestId = `req_${randomUUID()}`;
191
+ const response = (await this.appport.handleRequest({ protocol: "appport/1", type: "request", requestId, capability: { name, version: 1 }, input }, { ...(options.session ? { session: options.session } : {}), ...(options.principal ? { principal: toAppPortPrincipal(options.principal) } : {}), transport: options.transport ?? "cli" }));
192
+ const decisionId = response.authorizationDecision?.decisionId ?? response.error?.details?.decisionId;
193
+ return { ok: response.ok, ...(response.ok ? { output: response.output } : { error: response.error }), ...(decisionId ? { decisionId } : {}), requestId };
194
+ }
195
+ /** MCP tools a session may call: the operations its profile grants, nothing else. */
196
+ toolsFor(principal) {
197
+ const granted = new Set(OPERATIONS.filter((op) => this.holds(principal, op.permission)).map((op) => toolName(op.name)));
198
+ return (session) => {
199
+ const bridge = createMcpBridge(this.appport, { session });
200
+ return { tools: bridge.listTools().filter((tool) => granted.has(tool.name)), call: (name, args) => bridge.callTool(name, args) };
201
+ };
202
+ }
203
+ /** Whether `principal` holds `permission` under the profiles (wildcards included). */
204
+ holds(principal, permission) {
205
+ return !!principal && this.authority.permissionsFor(principal).some((p) => p === permission || p === "*" || (p.endsWith(".*") && permission.startsWith(p.slice(0, -1))));
206
+ }
207
+ /** Issue a platform session for an agent or person holding `profile`. Returns the token once. */
208
+ issue(input) {
209
+ if (!isProfile(input.profile))
210
+ throw new AppPortError("INVALID_INPUT", `Unknown profile ${input.profile}; profiles: inspect, develop, deploy:<project>/<environment>, owner.`);
211
+ return this.sessions.issue(PLATFORM_APPLICATION, { id: input.id, type: input.type, roles: [input.profile] }, { kind: "platform", ...(input.label ? { label: input.label } : {}), ...(input.ttlMs ? { ttlMs: input.ttlMs } : {}) });
212
+ }
213
+ async close() {
214
+ await this.changes.ready.catch(() => undefined);
215
+ await this.deployments.ready.catch(() => undefined);
216
+ await this.activity.flush();
217
+ await this.instance.close();
218
+ }
219
+ }
220
+ /** The local CLI acts as the workspace's owner (its filesystem access is its authority). */
221
+ export function localOwner() {
222
+ let name = "owner";
223
+ try {
224
+ name = userInfo().username;
225
+ }
226
+ catch { }
227
+ return { id: `local:${name}`, type: "user", roles: ["owner"] };
228
+ }
229
+ /** How this FeltKit's CLI is run in a child process: [executable, ...leading arguments]. */
230
+ export function cliCommand() {
231
+ const ext = extname(fileURLToPath(import.meta.url));
232
+ const entry = fileURLToPath(new URL(`../cli/entry${ext}`, import.meta.url));
233
+ const loader = ext === ".ts" ? ["--import", import.meta.resolve("tsx")] : [];
234
+ return [process.execPath, ...loader, entry];
235
+ }
236
+ /** FeltKit's CLI in `cwd`, in a child process; its JSON output and exit code. */
237
+ async function runCli(cwd, args, env = {}) {
238
+ const [executable, ...lead] = cliCommand();
239
+ return new Promise((done) => {
240
+ const child = spawn(executable, [...lead, ...args, "--cwd", cwd], {
241
+ cwd,
242
+ stdio: ["ignore", "pipe", "pipe"],
243
+ env: { ...Object.fromEntries(Object.entries(process.env).filter(([k]) => !["NODE_TEST_CONTEXT", "FELTKIT_ENV", "FELTKIT_STATE_DIR", "FELTDB_URL", "FELTKIT_STORAGE"].includes(k) && !k.startsWith("FELTKIT_DEPLOYMENT_"))), NO_COLOR: "1", ...env },
244
+ });
245
+ let stdout = "";
246
+ let stderr = "";
247
+ const timer = setTimeout(() => child.kill("SIGKILL"), 10 * 60_000);
248
+ child.stdout.on("data", (d) => (stdout += d));
249
+ child.stderr.on("data", (d) => (stderr += d));
250
+ child.on("exit", (status) => {
251
+ clearTimeout(timer);
252
+ const start = stdout.indexOf("{");
253
+ let json = null;
254
+ try {
255
+ json = start >= 0 ? JSON.parse(stdout.slice(start)) : null;
256
+ }
257
+ catch {
258
+ json = null;
259
+ }
260
+ done({ code: status ?? 1, json, stderr, stdout });
261
+ });
262
+ });
263
+ }
264
+ //# sourceMappingURL=platform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.js","sourceRoot":"","sources":["../../src/platform/platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAA2B,MAAM,cAAc,CAAC;AAC3H,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,kBAAkB,EAAkB,MAAM,yBAA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GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,CAAC;QACnE,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;QAC9C,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;QAC9C,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE;YAC1B,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAClC,IAAI,IAAI,GAAY,IAAI,CAAC;YACzB,IAAI,CAAC;gBACH,IAAI,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YAC7D,CAAC;YAAC,MAAM,CAAC;gBACP,IAAI,GAAG,IAAI,CAAC;YACd,CAAC;YACD,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { type Server } from "node:http";
2
+ import { type Platform } from "./platform.js";
3
+ /**
4
+ * Where a running platform server tells the local CLI how to reach it: its URL and an owner
5
+ * session (the platform's store has one process as its owner, so while it serves, the CLI goes
6
+ * through it). Readable by the operating-system user only: filesystem access to the root is the
7
+ * owner's authority, as it is for the local CLI. The session is revoked when the server stops.
8
+ */
9
+ export declare const serverFile: (root: string) => string;
10
+ export interface PlatformConnection {
11
+ url: string;
12
+ token: string;
13
+ pid: number;
14
+ }
15
+ /** The running platform server for `root`, if its process is alive. */
16
+ export declare function runningPlatform(root: string): PlatformConnection | undefined;
17
+ export interface PlatformServer {
18
+ url: string;
19
+ server: Server;
20
+ close(): Promise<void>;
21
+ }
22
+ export declare function servePlatform(platform: Platform, options?: {
23
+ port?: number;
24
+ host?: string;
25
+ }): Promise<PlatformServer>;
@@ -0,0 +1,165 @@
1
+ /**
2
+ * The platform over HTTP: AppPort (`/.well-known/appport`, `/appport/manifest`, `POST /appport`)
3
+ * and MCP (`POST /mcp`, Streamable HTTP with JSON responses). Every request is identified by its
4
+ * own bearer token (a platform session), so a revoked session is refused at its next request,
5
+ * whatever it was doing before. Both dispatch through the platform's one AppPort application.
6
+ */
7
+ import { chmodSync, existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
8
+ import { createServer } from "node:http";
9
+ import { join } from "node:path";
10
+ import { bearerToken, readBody, sendJSON } from "../server/http.js";
11
+ import { fromAppPortPrincipal } from "../runtime/authority.js";
12
+ import { PLATFORM_PERMISSIONS } from "./operations.js";
13
+ import { localOwner, PLATFORM_APPLICATION } from "./platform.js";
14
+ /**
15
+ * Where a running platform server tells the local CLI how to reach it: its URL and an owner
16
+ * session (the platform's store has one process as its owner, so while it serves, the CLI goes
17
+ * through it). Readable by the operating-system user only: filesystem access to the root is the
18
+ * owner's authority, as it is for the local CLI. The session is revoked when the server stops.
19
+ */
20
+ export const serverFile = (root) => join(root, ".feltkit-platform", "server.json");
21
+ /** The running platform server for `root`, if its process is alive. */
22
+ export function runningPlatform(root) {
23
+ const file = serverFile(root);
24
+ if (!existsSync(file))
25
+ return undefined;
26
+ try {
27
+ const connection = JSON.parse(readFileSync(file, "utf8"));
28
+ process.kill(connection.pid, 0);
29
+ return connection;
30
+ }
31
+ catch {
32
+ return undefined;
33
+ }
34
+ }
35
+ const STATUS = { INVALID_REQUEST: 400, INVALID_INPUT: 400, UNAUTHORIZED: 401, FORBIDDEN: 403, NOT_FOUND: 404, UNKNOWN_CAPABILITY: 404, CONFLICT: 409, RATE_LIMITED: 429, TIMEOUT: 504 };
36
+ /** FeltKit's own refusals are about the change set's state (409); a failed execution is the platform's (502). */
37
+ const statusOf = (code) => STATUS[code] ?? (code === "feltkit.EXECUTION_FAILED" || code === "feltkit.DEPLOY_FAILED" ? 502 : code.startsWith("feltkit.") ? 409 : 500);
38
+ const PROTOCOL_VERSIONS = ["2025-06-18", "2025-03-26", "2024-11-05"];
39
+ export async function servePlatform(platform, options = {}) {
40
+ const server = createServer((request, response) => {
41
+ handle(platform, request, response).catch((error) => {
42
+ if (!response.headersSent)
43
+ sendJSON(response, 500, { ok: false, error: { code: "INTERNAL_ERROR", message: error.message } });
44
+ });
45
+ });
46
+ await new Promise((done) => server.listen(options.port ?? 0, options.host ?? "127.0.0.1", done));
47
+ const address = server.address();
48
+ const url = `http://${options.host ?? "127.0.0.1"}:${address.port}`;
49
+ const owner = await platform.issue({ id: localOwner().id, type: "user", profile: "owner", label: "platform serve (local CLI)" });
50
+ const file = serverFile(platform.root);
51
+ writeFileSync(file, JSON.stringify({ url, token: owner.id, pid: process.pid }), { mode: 0o600 });
52
+ chmodSync(file, 0o600);
53
+ return {
54
+ url,
55
+ server,
56
+ close: async () => {
57
+ server.closeAllConnections?.();
58
+ await new Promise((done) => server.close(() => done()));
59
+ await platform.sessions.delete(owner.id).catch(() => undefined);
60
+ rmSync(file, { force: true });
61
+ },
62
+ };
63
+ }
64
+ async function session(platform, request) {
65
+ const token = bearerToken(request);
66
+ return token ? platform.sessions.get(token) : undefined;
67
+ }
68
+ async function handle(platform, request, response) {
69
+ const path = new URL(request.url ?? "/", "http://platform").pathname;
70
+ if (request.method === "GET" && path === "/.well-known/appport")
71
+ return sendJSON(response, 200, { protocol: "appport/1", manifest: "/appport/manifest", endpoint: "/appport" });
72
+ if (request.method === "GET" && path === "/appport/manifest")
73
+ return sendJSON(response, 200, platform.appport.manifest());
74
+ if (request.method === "POST" && path === "/appport") {
75
+ const found = await session(platform, request);
76
+ if (!found)
77
+ return sendJSON(response, 401, { protocol: "appport/1", type: "response", ok: false, error: { code: "UNAUTHORIZED", message: "A platform session token is required (Authorization: Bearer fks_…). Create one with `feltkit platform session create`." } });
78
+ let body;
79
+ try {
80
+ body = JSON.parse(await readBody(request));
81
+ }
82
+ catch {
83
+ return sendJSON(response, 400, { protocol: "appport/1", type: "response", ok: false, error: { code: "INVALID_REQUEST", message: "The body is not JSON." } });
84
+ }
85
+ const result = (await platform.appport.handleRequest(body, { session: found, transport: "http" }));
86
+ return sendJSON(response, result.ok ? 200 : statusOf(String(result.error?.code)), result);
87
+ }
88
+ if (path === "/mcp")
89
+ return mcp(platform, request, response);
90
+ if (path === "/platform/sessions" || path.startsWith("/platform/sessions/"))
91
+ return sessions(platform, request, response, path);
92
+ sendJSON(response, 404, { ok: false, error: { code: "NOT_FOUND", message: `No route ${request.method} ${path}.` } });
93
+ }
94
+ async function mcp(platform, request, response) {
95
+ if (request.method !== "POST") {
96
+ response.writeHead(405, { Allow: "POST" }).end();
97
+ return;
98
+ }
99
+ const found = await session(platform, request);
100
+ if (!found) {
101
+ response.setHeader("WWW-Authenticate", 'Bearer realm="feltkit-platform"');
102
+ return sendJSON(response, 401, { jsonrpc: "2.0", id: null, error: { code: -32001, message: "A platform session token is required (Authorization: Bearer fks_…)." } });
103
+ }
104
+ let rpc;
105
+ try {
106
+ rpc = JSON.parse(await readBody(request));
107
+ }
108
+ catch {
109
+ return sendJSON(response, 400, { jsonrpc: "2.0", id: null, error: { code: -32700, message: "Parse error" } });
110
+ }
111
+ if (rpc.id === undefined) {
112
+ response.writeHead(202).end();
113
+ return;
114
+ }
115
+ // The tools this session's profile grants, nothing more; each call is authorized again by AppPort.
116
+ const tools = platform.toolsFor(fromAppPortPrincipal(found.principal))(found);
117
+ let result;
118
+ switch (rpc.method) {
119
+ case "initialize": {
120
+ const requested = String(rpc.params?.protocolVersion ?? "");
121
+ result = { protocolVersion: PROTOCOL_VERSIONS.includes(requested) ? requested : PROTOCOL_VERSIONS[0], capabilities: { tools: { listChanged: false } }, serverInfo: { name: "feltkit-platform", version: String(platform.appport.manifest().application.version) }, instructions: "FeltKit's application lifecycle as tools. Each call runs with this session's profile and is recorded; a tool's answer is evidence of what the platform did, not of anything a model said." };
122
+ break;
123
+ }
124
+ case "ping":
125
+ result = {};
126
+ break;
127
+ case "tools/list":
128
+ result = { tools: tools.tools.map((tool) => ({ name: tool.name, description: tool.description, inputSchema: tool.inputSchema })) };
129
+ break;
130
+ case "tools/call":
131
+ result = await tools.call(String(rpc.params?.name ?? ""), rpc.params?.arguments ?? {});
132
+ break;
133
+ default:
134
+ return sendJSON(response, 200, { jsonrpc: "2.0", id: rpc.id, error: { code: -32601, message: `Method not found: ${rpc.method}` } });
135
+ }
136
+ sendJSON(response, 200, { jsonrpc: "2.0", id: rpc.id, result });
137
+ }
138
+ /** Platform sessions, for the workspace owner (`feltkit platform session …` while the server runs). */
139
+ async function sessions(platform, request, response, path) {
140
+ const found = await session(platform, request);
141
+ const principal = fromAppPortPrincipal(found?.principal);
142
+ if (!found)
143
+ return sendJSON(response, 401, { ok: false, error: { code: "UNAUTHORIZED", message: "A platform session token is required." } });
144
+ if (!platform.holds(principal, PLATFORM_PERMISSIONS.admin))
145
+ return sendJSON(response, 403, { ok: false, error: { code: "FORBIDDEN", message: `Managing sessions requires ${PLATFORM_PERMISSIONS.admin}.` } });
146
+ if (request.method === "GET" && path === "/platform/sessions")
147
+ return sendJSON(response, 200, { ok: true, sessions: await platform.sessions.list() });
148
+ if (request.method === "POST" && path === "/platform/sessions") {
149
+ try {
150
+ const input = JSON.parse(await readBody(request));
151
+ const issued = await platform.issue(input);
152
+ return sendJSON(response, 200, { ok: true, token: issued.id, applicationId: PLATFORM_APPLICATION, principal: fromAppPortPrincipal(issued.principal), ...(issued.expiresAt ? { expiresAt: issued.expiresAt } : {}) });
153
+ }
154
+ catch (error) {
155
+ return sendJSON(response, 400, { ok: false, error: { code: String(error.code ?? "INVALID_INPUT"), message: error.message } });
156
+ }
157
+ }
158
+ if (request.method === "DELETE") {
159
+ const ref = decodeURIComponent(path.slice("/platform/sessions/".length));
160
+ const revoked = ref.startsWith("principal:") ? await platform.sessions.revokePrincipal(ref.slice("principal:".length)) : await platform.sessions.revoke(ref);
161
+ return sendJSON(response, 200, { ok: true, revoked });
162
+ }
163
+ sendJSON(response, 405, { ok: false, error: { code: "INVALID_REQUEST", message: `${request.method} ${path} is not supported.` } });
164
+ }
165
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/platform/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrF,OAAO,EAAE,YAAY,EAA0D,MAAM,WAAW,CAAC;AACjG,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAiB,MAAM,eAAe,CAAC;AAEhF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,mBAAmB,EAAE,aAAa,CAAC,CAAC;AAQ3F,uEAAuE;AACvE,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,CAAC;IACxC,IAAI,CAA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AC,KAAK,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC;QACzE,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC7J,OAAO,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IACxD,CAAC;IACD,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,MAAM,IAAI,IAAI,oBAAoB,EAAE,EAAE,CAAC,CAAC;AACrI,CAAC"}
@@ -0,0 +1,27 @@
1
+ export interface SourceFile {
2
+ path: string;
3
+ /** New content (UTF-8), or null to delete the file. */
4
+ content: string | null;
5
+ }
6
+ export declare const LIMITS: {
7
+ readonly files: 200;
8
+ readonly fileBytes: number;
9
+ readonly totalBytes: number;
10
+ };
11
+ /** Every source file's SHA-256, by project-relative path. */
12
+ export declare function sourceFiles(dir: string): Map<string, string>;
13
+ /** The project's revision: `rev_` and the SHA-256 of its sorted (path, content digest) list. */
14
+ export declare function sourceRevision(dir: string): string;
15
+ /** A change set's content digest: computed from its files, in path order. */
16
+ export declare function contentDigest(files: readonly SourceFile[]): string;
17
+ /** Validate and normalize a change set's files; throws INVALID_INPUT naming the problem. */
18
+ export declare function checkFiles(files: unknown): SourceFile[];
19
+ /** The current content of each path (null when absent), for restoring after a failed apply. */
20
+ export declare function snapshot(dir: string, paths: readonly string[]): SourceFile[];
21
+ /** Write (or delete) each file, each one atomically (a temporary file, then a rename). */
22
+ export declare function writeFiles(dir: string, files: readonly SourceFile[]): void;
23
+ /**
24
+ * A fresh workspace: a copy of the project's source and configuration (no state, builds, .env
25
+ * files or .git), its node_modules linked rather than copied, then the change set's files.
26
+ */
27
+ export declare function createWorkspace(projectDir: string, workspace: string, files: readonly SourceFile[]): void;