@feltdb/feltkit 0.3.22 → 0.3.24
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/deploy-appboundry.d.ts +26 -0
- package/dist/cli/deploy-appboundry.js +1 -1
- package/dist/cli/deploy-appboundry.js.map +1 -1
- package/dist/cli/main.js +17 -153
- package/dist/cli/main.js.map +1 -1
- package/dist/client/index.d.ts +83 -4
- package/dist/client/index.js +204 -10
- 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 +2 -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/managed.d.ts +43 -0
- package/dist/platform/managed.js +137 -0
- package/dist/platform/managed.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 +51 -0
- package/dist/platform/platform.js +105 -6
- package/dist/platform/platform.js.map +1 -1
- package/dist/platform/releases.d.ts +150 -0
- package/dist/platform/releases.js +467 -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 +605 -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/authboundry.d.ts +53 -0
- package/dist/runtime/authboundry.js +82 -0
- package/dist/runtime/authboundry.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 +208 -11
- package/dist/server/index.js.map +1 -1
- package/dist/server/tenancy.js +1 -1
- package/dist/server/tenancy.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 +3 -2
- package/docs/EXTENSION-HOSTS.md +52 -0
- package/docs/GENERATION.md +136 -0
- package/docs/README.md +4 -2
- package/package.json +6 -8
- 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 -1197
- package/dist/cli/create.js.map +0 -1
- package/dist/cli/domain.d.ts +0 -174
- package/dist/cli/domain.js +0 -1170
- package/dist/cli/domain.js.map +0 -1
- package/dist/cli/screens.d.ts +0 -25
- package/dist/cli/screens.js +0 -282
- package/dist/cli/screens.js.map +0 -1
- package/dist/cli/shell.d.ts +0 -7
- package/dist/cli/shell.js +0 -63
- 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,605 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace and command operations (docs/M2-AGENT-OPERATIONS.md G4–G7), in the same registry as
|
|
3
|
+
* every other platform operation: one definition each, served by the CLI, MCP and AppPort.
|
|
4
|
+
*
|
|
5
|
+
* A workspace and its executions belong to whoever created them; another caller is told they do
|
|
6
|
+
* not exist, unless they hold `feltkit.platform.all` (the owner profile). An agent's operation that
|
|
7
|
+
* requires approval (destroying a workspace, a command with network access, applying a change,
|
|
8
|
+
* deploying) runs only under a person's approval of exactly that input (approvals.ts).
|
|
9
|
+
*/
|
|
10
|
+
import { s, shapeToObjectSchema } from "../schema.js";
|
|
11
|
+
import { PLATFORM_PERMISSIONS, deployScope } from "./permissions.js";
|
|
12
|
+
const json = s.record(s.unknown());
|
|
13
|
+
const NONE = [{ code: "FORBIDDEN", retry: "unsafe", effect: "none" }, { code: "NOT_FOUND", retry: "unsafe", effect: "none" }];
|
|
14
|
+
const CONFLICT = { code: "CONFLICT", retry: "after-verification", effect: "none" };
|
|
15
|
+
const workspace = { workspace: s.string() };
|
|
16
|
+
/** A record as an operation returns it (without its store version). */
|
|
17
|
+
const strip = (r) => {
|
|
18
|
+
const { __version, ...rest } = r;
|
|
19
|
+
return rest;
|
|
20
|
+
};
|
|
21
|
+
const viewer = (c) => ({ id: c.caller.principal.id, all: c.seesAll });
|
|
22
|
+
/** A workspace record as an operation returns it. */
|
|
23
|
+
const view = (w) => {
|
|
24
|
+
const { __version, ...rest } = w;
|
|
25
|
+
return rest;
|
|
26
|
+
};
|
|
27
|
+
const limits = shapeToObjectSchema({
|
|
28
|
+
timeoutMs: s.optional(s.number()),
|
|
29
|
+
cpuSeconds: s.optional(s.number()),
|
|
30
|
+
memoryBytes: s.optional(s.number()),
|
|
31
|
+
fileBytes: s.optional(s.number()),
|
|
32
|
+
processes: s.optional(s.number()),
|
|
33
|
+
openFiles: s.optional(s.number()),
|
|
34
|
+
outputBytes: s.optional(s.number()),
|
|
35
|
+
});
|
|
36
|
+
/** A Git ref or revision name: no options, no paths outside, no shell. */
|
|
37
|
+
const checkRef = (ref) => {
|
|
38
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._/~^-]{0,199}$/.test(ref) || ref.includes(".."))
|
|
39
|
+
throw Object.assign(new Error(`${JSON.stringify(ref)} is not a branch or revision name.`), { code: "INVALID_INPUT" });
|
|
40
|
+
return ref;
|
|
41
|
+
};
|
|
42
|
+
const checkSourcePath = (path) => {
|
|
43
|
+
if (typeof path !== "string" || !path || path.startsWith("-") || path.startsWith("/") || path.split("/").includes(".."))
|
|
44
|
+
throw Object.assign(new Error(`${JSON.stringify(path)} is not a workspace path.`), { code: "INVALID_INPUT" });
|
|
45
|
+
return `:(literal)${path}`;
|
|
46
|
+
};
|
|
47
|
+
/** Commits are attributed to the caller (a platform principal), with no credentials. */
|
|
48
|
+
const identity = (c) => ["-c", `user.name=${c.caller.principal.id}`, "-c", `user.email=${c.caller.principal.id.replace(/[^A-Za-z0-9._-]/g, "_")}@feltkit.invalid`, "-c", "commit.gpgsign=false"];
|
|
49
|
+
/** git in the workspace, through the command runner: every Git action is a recorded execution. */
|
|
50
|
+
async function git(c, ws, args) {
|
|
51
|
+
return c.executions.run({ workspace: { id: ws.id, dir: ws.dir }, program: "git", args: ["-c", "core.hooksPath=/dev/null", "-c", "safe.directory=*", ...args], env: { GIT_CONFIG_NOSYSTEM: "1", GIT_TERMINAL_PROMPT: "0" }, limits: { timeoutMs: 120_000 } }, c.caller);
|
|
52
|
+
}
|
|
53
|
+
async function gitText(c, ws, args) {
|
|
54
|
+
const r = await git(c, ws, args);
|
|
55
|
+
if (r.state !== "succeeded")
|
|
56
|
+
throw Object.assign(new Error(`git ${args[0]} failed (execution ${r.id}): ${r.failure?.message}`), { code: "FAILED_PRECONDITION", details: { execution: r.id } });
|
|
57
|
+
return (await c.executions.output(r.id, "stdout", { id: c.caller.principal.id, all: true })).text;
|
|
58
|
+
}
|
|
59
|
+
export const WORKSPACE_OPERATIONS = [
|
|
60
|
+
{
|
|
61
|
+
name: "workspace.create",
|
|
62
|
+
version: 1,
|
|
63
|
+
description: "Create an isolated, durable workspace from a project's source (no state, builds, .env files or .git) and take its first snapshot, whose revision is the project's source revision.",
|
|
64
|
+
effect: "consequential",
|
|
65
|
+
permission: PLATFORM_PERMISSIONS.develop,
|
|
66
|
+
input: shapeToObjectSchema({ project: s.string(), label: s.optional(s.string()), idempotencyKey: s.optional(s.string()) }),
|
|
67
|
+
output: json,
|
|
68
|
+
integration: { purpose: "A place to change an application without touching it.", effects: [{ type: "write", description: "Copies the project's source into a new workspace directory and records it." }], approval: { required: false }, failures: [...NONE, { code: "feltkit.LIMIT_EXCEEDED", retry: "unsafe", effect: "none" }] },
|
|
69
|
+
run: async (c, input) => {
|
|
70
|
+
const { workspace: w, snapshot } = await c.workspaces.create({ project: c.project, projectDir: c.projectDir, ...(typeof input.label === "string" ? { label: input.label } : {}), ...(typeof input.idempotencyKey === "string" ? { idempotencyKey: input.idempotencyKey } : {}) }, c.caller);
|
|
71
|
+
return { workspace: view(w), snapshot: { id: snapshot.id, revision: snapshot.revision, files: snapshot.files.length } };
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "workspace.inspect",
|
|
76
|
+
version: 1,
|
|
77
|
+
description: "A workspace: owner, project, base revision, state, and its snapshots.",
|
|
78
|
+
effect: "observation",
|
|
79
|
+
permission: PLATFORM_PERMISSIONS.read,
|
|
80
|
+
input: shapeToObjectSchema(workspace),
|
|
81
|
+
output: json,
|
|
82
|
+
integration: { purpose: "Know what a workspace is and what has been captured in it.", effects: [], approval: { required: false }, failures: NONE },
|
|
83
|
+
run: async (c, input) => ({ workspace: view((await c.workspaces.get(String(input.workspace), viewer(c)))), snapshots: await c.workspaces.snapshots(String(input.workspace), viewer(c)) }),
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "workspace.list",
|
|
87
|
+
version: 1,
|
|
88
|
+
description: "Your workspaces (all of them for the owner), newest first.",
|
|
89
|
+
effect: "observation",
|
|
90
|
+
permission: PLATFORM_PERMISSIONS.read,
|
|
91
|
+
input: shapeToObjectSchema({ project: s.optional(s.string()), state: s.optional(s.enum(["active", "destroyed"])) }),
|
|
92
|
+
output: json,
|
|
93
|
+
integration: { purpose: "Find a workspace.", effects: [], approval: { required: false }, failures: NONE },
|
|
94
|
+
run: async (c, input) => ({ workspaces: (await c.workspaces.list(viewer(c), { ...(typeof input.project === "string" ? { project: input.project } : {}), ...(typeof input.state === "string" ? { state: input.state } : {}) })).map((w) => view(w)) }),
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: "workspace.files",
|
|
98
|
+
version: 1,
|
|
99
|
+
description: "The source files in a workspace (or under a directory of it), with sizes and digests.",
|
|
100
|
+
effect: "observation",
|
|
101
|
+
permission: PLATFORM_PERMISSIONS.read,
|
|
102
|
+
input: shapeToObjectSchema({ ...workspace, prefix: s.optional(s.string()) }),
|
|
103
|
+
output: json,
|
|
104
|
+
integration: { purpose: "See what a workspace contains.", effects: [], approval: { required: false }, failures: NONE },
|
|
105
|
+
run: async (c, input) => ({ files: await c.workspaces.files(String(input.workspace), viewer(c), typeof input.prefix === "string" ? input.prefix : "") }),
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: "workspace.read",
|
|
109
|
+
version: 1,
|
|
110
|
+
description: "Read a source file from a workspace (text as UTF-8, binary as base64), with its digest for a conditional write.",
|
|
111
|
+
effect: "observation",
|
|
112
|
+
permission: PLATFORM_PERMISSIONS.read,
|
|
113
|
+
input: shapeToObjectSchema({ ...workspace, path: s.string() }),
|
|
114
|
+
output: json,
|
|
115
|
+
integration: { purpose: "Inspect source before changing it.", effects: [], approval: { required: false }, failures: NONE },
|
|
116
|
+
run: (c, input) => c.workspaces.read(String(input.workspace), String(input.path), viewer(c)),
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "workspace.stat",
|
|
120
|
+
version: 1,
|
|
121
|
+
description: "Whether a path exists in a workspace, and its type, size, digest and modification time.",
|
|
122
|
+
effect: "observation",
|
|
123
|
+
permission: PLATFORM_PERMISSIONS.read,
|
|
124
|
+
input: shapeToObjectSchema({ ...workspace, path: s.string() }),
|
|
125
|
+
output: json,
|
|
126
|
+
integration: { purpose: "Inspect file metadata.", effects: [], approval: { required: false }, failures: NONE },
|
|
127
|
+
run: (c, input) => c.workspaces.stat(String(input.workspace), String(input.path), viewer(c)),
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: "workspace.write",
|
|
131
|
+
version: 1,
|
|
132
|
+
description: "Create or replace a source file in a workspace, atomically. ifDigest makes it conditional (the file's current digest, or null for a new file), so concurrent writers cannot silently overwrite each other.",
|
|
133
|
+
effect: "consequential",
|
|
134
|
+
permission: PLATFORM_PERMISSIONS.develop,
|
|
135
|
+
input: shapeToObjectSchema({ ...workspace, path: s.string(), content: s.string(), encoding: s.optional(s.enum(["utf8", "base64"])), ifDigest: s.optional(s.nullable(s.string())) }),
|
|
136
|
+
output: json,
|
|
137
|
+
integration: { purpose: "Change a file in the workspace only; the project is untouched.", effects: [{ type: "write", description: "Writes one file in the workspace." }], approval: { required: false }, failures: [...NONE, CONFLICT, { code: "feltkit.LIMIT_EXCEEDED", retry: "unsafe", effect: "none" }] },
|
|
138
|
+
run: (c, input) => c.workspaces.write(String(input.workspace), { path: String(input.path), content: String(input.content), ...(input.encoding ? { encoding: input.encoding } : {}), ...(input.ifDigest !== undefined ? { ifDigest: input.ifDigest } : {}) }, c.caller, c.seesAll),
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
name: "workspace.remove",
|
|
142
|
+
version: 1,
|
|
143
|
+
description: "Delete a source file from a workspace (conditional on its digest when ifDigest is given).",
|
|
144
|
+
effect: "consequential",
|
|
145
|
+
permission: PLATFORM_PERMISSIONS.develop,
|
|
146
|
+
input: shapeToObjectSchema({ ...workspace, path: s.string(), ifDigest: s.optional(s.string()) }),
|
|
147
|
+
output: json,
|
|
148
|
+
integration: { purpose: "Delete a file in the workspace only; its last snapshot still holds it.", effects: [{ type: "write", description: "Deletes one file in the workspace." }], approval: { required: false }, failures: [...NONE, CONFLICT] },
|
|
149
|
+
run: (c, input) => c.workspaces.remove(String(input.workspace), { path: String(input.path), ...(typeof input.ifDigest === "string" ? { ifDigest: input.ifDigest } : {}) }, c.caller, c.seesAll),
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: "workspace.move",
|
|
153
|
+
version: 1,
|
|
154
|
+
description: "Rename a source file in a workspace (refused if the target exists).",
|
|
155
|
+
effect: "consequential",
|
|
156
|
+
permission: PLATFORM_PERMISSIONS.develop,
|
|
157
|
+
input: shapeToObjectSchema({ ...workspace, from: s.string(), to: s.string() }),
|
|
158
|
+
output: json,
|
|
159
|
+
integration: { purpose: "Rename a file in the workspace only.", effects: [{ type: "write", description: "Renames one file in the workspace." }], approval: { required: false }, failures: [...NONE, CONFLICT] },
|
|
160
|
+
run: (c, input) => c.workspaces.move(String(input.workspace), { from: String(input.from), to: String(input.to) }, c.caller, c.seesAll),
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
name: "workspace.snapshot",
|
|
164
|
+
version: 1,
|
|
165
|
+
description: "Capture the workspace's source as it is now: a durable tree manifest with its revision; the bytes are stored by digest.",
|
|
166
|
+
effect: "consequential",
|
|
167
|
+
permission: PLATFORM_PERMISSIONS.develop,
|
|
168
|
+
input: shapeToObjectSchema({ ...workspace, label: s.optional(s.string()) }),
|
|
169
|
+
output: json,
|
|
170
|
+
integration: { purpose: "A revision you can compare, review, build and restore.", effects: [{ type: "write", description: "Records a snapshot and stores its files' bytes." }], approval: { required: false }, failures: [...NONE, CONFLICT] },
|
|
171
|
+
run: async (c, input) => {
|
|
172
|
+
const { snapshot } = await c.workspaces.snapshot(String(input.workspace), { ...(typeof input.label === "string" ? { label: input.label } : {}) }, c.caller, c.seesAll);
|
|
173
|
+
const { files, ...rest } = snapshot;
|
|
174
|
+
return { snapshot: { ...rest, fileCount: files.length } };
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: "workspace.diff",
|
|
179
|
+
version: 1,
|
|
180
|
+
description: "What changed between two snapshots, or from a snapshot (default: the first) to the files as they are now: per file, its status, digests and a unified diff. Computed by the platform from stored bytes; its digest identifies exactly this review.",
|
|
181
|
+
effect: "observation",
|
|
182
|
+
permission: PLATFORM_PERMISSIONS.read,
|
|
183
|
+
input: shapeToObjectSchema({ ...workspace, from: s.optional(s.string()), to: s.optional(s.string()), patches: s.optional(s.boolean()) }),
|
|
184
|
+
output: json,
|
|
185
|
+
integration: { purpose: "Review what actually changed; the diff, not a description of it, is the evidence.", effects: [], approval: { required: false }, failures: [...NONE, CONFLICT] },
|
|
186
|
+
run: (c, input) => c.workspaces.diff(String(input.workspace), { ...(typeof input.from === "string" ? { from: input.from } : {}), ...(typeof input.to === "string" ? { to: input.to } : {}), ...(typeof input.patches === "boolean" ? { patches: input.patches } : {}) }, viewer(c)),
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: "workspace.destroy",
|
|
190
|
+
version: 1,
|
|
191
|
+
description: "Delete a workspace's directory. Its record, snapshots and executions remain as evidence.",
|
|
192
|
+
effect: "consequential",
|
|
193
|
+
permission: PLATFORM_PERMISSIONS.develop,
|
|
194
|
+
input: shapeToObjectSchema({ ...workspace, approval: s.optional(s.string()), reason: s.optional(s.string()) }),
|
|
195
|
+
output: json,
|
|
196
|
+
integration: { purpose: "Discard a workspace; what it captured stays inspectable.", effects: [{ type: "delete", description: "Deletes the workspace directory (not its snapshots)." }], approval: { required: true }, failures: [...NONE, CONFLICT] },
|
|
197
|
+
precheck: async (c, input) => void (await c.workspaces.get(String(input.workspace), viewer(c))),
|
|
198
|
+
run: async (c, input) => ({ workspace: view((await c.workspaces.destroy(String(input.workspace), c.caller, c.seesAll))) }),
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
name: "command.run",
|
|
202
|
+
version: 1,
|
|
203
|
+
description: "Run an allowed program (node, npm, git, feltkit) with arguments in a workspace, under limits, without the platform's environment or secrets. Returns the execution record (with wait: false, once it is running). The record states the isolation actually enforced.",
|
|
204
|
+
effect: "consequential",
|
|
205
|
+
permission: PLATFORM_PERMISSIONS.develop,
|
|
206
|
+
requiresApproval: (input) => input.network === "allowed",
|
|
207
|
+
input: shapeToObjectSchema({
|
|
208
|
+
...workspace,
|
|
209
|
+
program: s.string(),
|
|
210
|
+
args: s.optional(s.array(s.string())),
|
|
211
|
+
env: s.optional(s.record(s.string())),
|
|
212
|
+
network: s.optional(s.enum(["none", "allowed"])),
|
|
213
|
+
isolation: s.optional(s.enum(["required", "best-available"])),
|
|
214
|
+
limits: s.optional(limits),
|
|
215
|
+
wait: s.optional(s.boolean()),
|
|
216
|
+
idempotencyKey: s.optional(s.string()),
|
|
217
|
+
approval: s.optional(s.string()), reason: s.optional(s.string()),
|
|
218
|
+
}),
|
|
219
|
+
output: json,
|
|
220
|
+
integration: {
|
|
221
|
+
purpose: "Build, test and inspect inside a workspace; the outcome is the program's, recorded.",
|
|
222
|
+
effects: [{ type: "execution", description: "Runs a program in the workspace (isolation per the record)." }, { type: "write", description: "Records the execution and stores its output." }],
|
|
223
|
+
approval: { required: false, when: "network: allowed (an agent's command with network access needs a person's approval)" },
|
|
224
|
+
failures: [...NONE, { code: "INVALID_INPUT", retry: "unsafe", effect: "none" }, { code: "feltkit.ISOLATION_UNAVAILABLE", retry: "unsafe", effect: "none" }, { code: "feltkit.APPROVAL_REQUIRED", retry: "after-verification", effect: "none" }],
|
|
225
|
+
},
|
|
226
|
+
precheck: async (c, input) => void (await c.workspaces.active(String(input.workspace), viewer(c))),
|
|
227
|
+
run: async (c, input) => {
|
|
228
|
+
const ws = await c.workspaces.active(String(input.workspace), viewer(c));
|
|
229
|
+
const request = {
|
|
230
|
+
workspace: { id: ws.id, dir: ws.dir },
|
|
231
|
+
program: String(input.program),
|
|
232
|
+
...(Array.isArray(input.args) ? { args: input.args } : {}),
|
|
233
|
+
...(input.env ? { env: input.env } : {}),
|
|
234
|
+
...(input.network ? { network: input.network } : {}),
|
|
235
|
+
...(input.isolation ? { isolation: input.isolation } : {}),
|
|
236
|
+
...(input.limits ? { limits: input.limits } : {}),
|
|
237
|
+
...(typeof input.idempotencyKey === "string" ? { idempotencyKey: input.idempotencyKey } : {}),
|
|
238
|
+
readable: c.workspaces.readable(ws),
|
|
239
|
+
};
|
|
240
|
+
const record = input.wait === false ? await c.executions.start(request, c.caller) : await c.executions.run(request, c.caller);
|
|
241
|
+
const { __version, ...rest } = record;
|
|
242
|
+
return { execution: rest };
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
name: "command.inspect",
|
|
247
|
+
version: 1,
|
|
248
|
+
description: "An execution: its command, limits, isolation, state, exit status, signal, CPU time, duration and output digests.",
|
|
249
|
+
effect: "observation",
|
|
250
|
+
permission: PLATFORM_PERMISSIONS.read,
|
|
251
|
+
input: shapeToObjectSchema({ execution: s.string() }),
|
|
252
|
+
output: json,
|
|
253
|
+
integration: { purpose: "Know exactly what ran and how it ended.", effects: [], approval: { required: false }, failures: NONE },
|
|
254
|
+
run: async (c, input) => {
|
|
255
|
+
const { __version, ...rest } = await c.executions.get(String(input.execution), viewer(c));
|
|
256
|
+
return { execution: rest };
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
name: "command.output",
|
|
261
|
+
version: 1,
|
|
262
|
+
description: "An execution's stored stdout or stderr (a byte range), verified against its digest.",
|
|
263
|
+
effect: "observation",
|
|
264
|
+
permission: PLATFORM_PERMISSIONS.read,
|
|
265
|
+
input: shapeToObjectSchema({ execution: s.string(), stream: s.enum(["stdout", "stderr"]), offset: s.optional(s.number()), limit: s.optional(s.number()) }),
|
|
266
|
+
output: json,
|
|
267
|
+
integration: { purpose: "Read what a command printed.", effects: [], approval: { required: false }, failures: NONE },
|
|
268
|
+
run: (c, input) => c.executions.output(String(input.execution), input.stream, viewer(c), { ...(typeof input.offset === "number" ? { offset: input.offset } : {}), ...(typeof input.limit === "number" ? { limit: input.limit } : {}) }),
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
name: "command.cancel",
|
|
272
|
+
version: 1,
|
|
273
|
+
description: "Cancel a running execution: all of its processes are stopped and it ends cancelled.",
|
|
274
|
+
effect: "consequential",
|
|
275
|
+
permission: PLATFORM_PERMISSIONS.develop,
|
|
276
|
+
input: shapeToObjectSchema({ execution: s.string() }),
|
|
277
|
+
output: json,
|
|
278
|
+
integration: { purpose: "Stop work that is no longer wanted.", effects: [{ type: "execution", description: "Stops the execution's processes." }], approval: { required: false }, failures: [...NONE, CONFLICT] },
|
|
279
|
+
run: async (c, input) => {
|
|
280
|
+
const { __version, ...rest } = await c.executions.cancel(String(input.execution), c.caller, c.seesAll);
|
|
281
|
+
return { execution: rest };
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
name: "command.list",
|
|
286
|
+
version: 1,
|
|
287
|
+
description: "Your executions (all of them for the owner), newest first, optionally for one workspace or state.",
|
|
288
|
+
effect: "observation",
|
|
289
|
+
permission: PLATFORM_PERMISSIONS.read,
|
|
290
|
+
input: shapeToObjectSchema({ workspace: s.optional(s.string()), state: s.optional(s.enum(["requested", "running", "succeeded", "failed", "cancelled", "timed_out", "interrupted"])), limit: s.optional(s.number()) }),
|
|
291
|
+
output: json,
|
|
292
|
+
integration: { purpose: "The history of what ran.", effects: [], approval: { required: false }, failures: NONE },
|
|
293
|
+
run: async (c, input) => ({ executions: (await c.executions.list(viewer(c), { ...(typeof input.workspace === "string" ? { workspace: input.workspace } : {}), ...(typeof input.state === "string" ? { state: input.state } : {}), ...(typeof input.limit === "number" ? { limit: input.limit } : {}) })).map(({ __version, ...r }) => r) }),
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
name: "approval.list",
|
|
297
|
+
version: 1,
|
|
298
|
+
description: "Approvals you proposed, and those you may decide (you hold what the operation requires), newest first.",
|
|
299
|
+
effect: "observation",
|
|
300
|
+
permission: PLATFORM_PERMISSIONS.read,
|
|
301
|
+
input: shapeToObjectSchema({ state: s.optional(s.enum(["pending", "approved", "rejected", "expired", "executing", "succeeded", "failed", "interrupted"])) }),
|
|
302
|
+
output: json,
|
|
303
|
+
integration: { purpose: "See what waits for a person's decision.", effects: [], approval: { required: false }, failures: NONE },
|
|
304
|
+
run: async (c, input) => ({ approvals: (await c.approvals.list({ id: c.caller.principal.id, mayPerform: c.mayPerform }, { ...(typeof input.state === "string" ? { state: input.state } : {}) })).map(({ __version, ...a }) => a) }),
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
name: "approval.inspect",
|
|
308
|
+
version: 1,
|
|
309
|
+
description: "One approval: the operation, its exact input and digest, its declared consequences, who proposed it, its expiry, the decision and the execution's outcome.",
|
|
310
|
+
effect: "observation",
|
|
311
|
+
permission: PLATFORM_PERMISSIONS.read,
|
|
312
|
+
input: shapeToObjectSchema({ approval: s.string() }),
|
|
313
|
+
output: json,
|
|
314
|
+
integration: { purpose: "Review exactly what would run before deciding.", effects: [], approval: { required: false }, failures: NONE },
|
|
315
|
+
run: async (c, input) => {
|
|
316
|
+
const { __version, ...a } = await c.approvals.get(String(input.approval), { id: c.caller.principal.id, mayPerform: c.mayPerform });
|
|
317
|
+
return { approval: a };
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
name: "approval.decide",
|
|
322
|
+
version: 1,
|
|
323
|
+
description: "Approve or reject a pending operation. Only a person who is not its proposer and may perform it themselves can decide, naming the input digest they reviewed. Approving does not run it: the proposer's next call with the approval does, once, after its own authority is checked again.",
|
|
324
|
+
effect: "consequential",
|
|
325
|
+
permission: PLATFORM_PERMISSIONS.read,
|
|
326
|
+
input: shapeToObjectSchema({ approval: s.string(), decision: s.enum(["approve", "reject"]), inputDigest: s.string(), note: s.optional(s.string()) }),
|
|
327
|
+
output: json,
|
|
328
|
+
integration: { purpose: "A person's decision, bound to exactly what they reviewed.", effects: [{ type: "write", description: "Records the decision." }], approval: { required: false }, failures: [...NONE, { code: "FAILED_PRECONDITION", retry: "unsafe", effect: "none" }] },
|
|
329
|
+
run: async (c, input) => {
|
|
330
|
+
const { __version, ...a } = await c.approvals.decide(String(input.approval), { approve: input.decision === "approve", inputDigest: String(input.inputDigest), ...(typeof input.note === "string" ? { note: input.note } : {}) }, c.caller, c.mayPerform);
|
|
331
|
+
return { approval: a };
|
|
332
|
+
},
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
name: "artifact.build",
|
|
336
|
+
version: 1,
|
|
337
|
+
description: "Build an immutable AppBoundry artifact (appboundry.app/1) from a workspace: snapshot, `feltkit build --target appboundry` in the workspace, the platform's checks and AppBoundry's verifier, then stored by its digest with its provenance. A failed build is recorded and produces no artifact.",
|
|
338
|
+
effect: "consequential",
|
|
339
|
+
permission: PLATFORM_PERMISSIONS.develop,
|
|
340
|
+
input: shapeToObjectSchema({ ...workspace }),
|
|
341
|
+
output: json,
|
|
342
|
+
integration: { purpose: "Produce the deployment unit: a validated, immutable artifact, never a repository.", effects: [{ type: "execution", description: "Runs the build and the verifier in the workspace." }, { type: "write", description: "Stores the artifact and its build record." }], approval: { required: false }, failures: [...NONE, { code: "feltkit.BUILD_FAILED", retry: "after-verification", effect: "none" }, { code: "feltkit.ARTIFACT_INVALID", retry: "unsafe", effect: "none" }, { code: "feltkit.BUILD_CHANGED_SOURCE", retry: "unsafe", effect: "none" }] },
|
|
343
|
+
run: async (c, input) => {
|
|
344
|
+
const { artifact, build, existing } = await c.artifacts.build({ workspace: String(input.workspace) }, c.caller, { workspaces: c.workspaces, executions: c.executions, all: c.seesAll });
|
|
345
|
+
return { artifact, build, existing };
|
|
346
|
+
},
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
name: "artifact.inspect",
|
|
350
|
+
version: 1,
|
|
351
|
+
description: "An artifact: its digest, application, module, files with digests, provenance (workspace, snapshot, source revision, build, tool versions, who built it) and validation.",
|
|
352
|
+
effect: "observation",
|
|
353
|
+
permission: PLATFORM_PERMISSIONS.read,
|
|
354
|
+
input: shapeToObjectSchema({ artifact: s.string() }),
|
|
355
|
+
output: json,
|
|
356
|
+
integration: { purpose: "Know exactly what an artifact is and where it came from.", effects: [], approval: { required: false }, failures: NONE },
|
|
357
|
+
run: async (c, input) => ({ artifact: await c.artifacts.get(String(input.artifact)) }),
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
name: "artifact.list",
|
|
361
|
+
version: 1,
|
|
362
|
+
description: "Artifacts, newest first, optionally of one application or workspace.",
|
|
363
|
+
effect: "observation",
|
|
364
|
+
permission: PLATFORM_PERMISSIONS.read,
|
|
365
|
+
input: shapeToObjectSchema({ application: s.optional(s.string()), workspace: s.optional(s.string()) }),
|
|
366
|
+
output: json,
|
|
367
|
+
integration: { purpose: "Find what can be deployed.", effects: [], approval: { required: false }, failures: NONE },
|
|
368
|
+
run: async (c, input) => ({ artifacts: (await c.artifacts.list({ ...(typeof input.application === "string" ? { application: input.application } : {}), ...(typeof input.workspace === "string" ? { workspace: input.workspace } : {}) })).map((a) => ({ id: a.id, digest: a.digest, application: a.application, sourceRevision: a.provenance.sourceRevision, workspace: a.provenance.workspace, createdAt: a.createdAt })) }),
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
name: "artifact.verify",
|
|
372
|
+
version: 1,
|
|
373
|
+
description: "Verify a stored artifact's bytes again: every file against its recorded digest, and the manifest against the artifact's identity.",
|
|
374
|
+
effect: "observation",
|
|
375
|
+
permission: PLATFORM_PERMISSIONS.read,
|
|
376
|
+
input: shapeToObjectSchema({ artifact: s.string() }),
|
|
377
|
+
output: json,
|
|
378
|
+
integration: { purpose: "Prove the artifact is still exactly what was built.", effects: [], approval: { required: false }, failures: NONE },
|
|
379
|
+
run: (c, input) => c.artifacts.verify(String(input.artifact)),
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
name: "release.deploy",
|
|
383
|
+
version: 1,
|
|
384
|
+
description: "Deploy a validated artifact, by id, to an application's environment: on a local AppBoundry runtime (target local, the default), where it is running only after the platform observed the process, the loaded artifact's digests, its health and its AppPort surface; or on managed AppBoundry hosting (target managed), where the portal deploys it and it is running only when the host agent's evidence names this artifact's module on the current attempt, its capability check passed and the observation is fresh. A failure leaves (or restores) the previous deployment. Returns the deployment with its receipt.",
|
|
385
|
+
effect: "consequential",
|
|
386
|
+
permission: PLATFORM_PERMISSIONS.deploy,
|
|
387
|
+
scope: (input) => deployScope(String(input.application ?? ""), String(input.environment ?? "")),
|
|
388
|
+
input: shapeToObjectSchema({ application: s.string(), artifact: s.string(), environment: s.string(), target: s.optional(s.enum(["local", "managed"])), accounts: s.optional(s.enum(["operator-sessions"])), approval: s.optional(s.string()), reason: s.optional(s.string()) }),
|
|
389
|
+
output: json,
|
|
390
|
+
integration: { purpose: "Run exactly one immutable artifact, with proof of what is running.", effects: [{ type: "deploy", description: "Stops the environment's running deployment and starts the artifact; restores the previous one if the new one fails its checks." }], approval: { required: true }, failures: [...NONE, { code: "CONFLICT", retry: "after-verification", effect: "none" }, { code: "feltkit.APPROVAL_REQUIRED", retry: "after-verification", effect: "none" }] },
|
|
391
|
+
precheck: async (c, input) => {
|
|
392
|
+
const artifact = await c.artifacts.get(String(input.artifact));
|
|
393
|
+
if (artifact.application.id !== input.application && artifact.application.name !== input.application)
|
|
394
|
+
throw Object.assign(new Error(`${artifact.id} is an artifact of ${artifact.application.id}, not ${String(input.application)}.`), { code: "INVALID_INPUT" });
|
|
395
|
+
const check = await c.artifacts.verify(artifact.id);
|
|
396
|
+
if (!check.ok)
|
|
397
|
+
throw Object.assign(new Error(`Artifact ${artifact.id} is corrupted (${check.problems.join("; ")}); it cannot be approved for deployment.`), { code: "feltkit.ARTIFACT_CORRUPTED" });
|
|
398
|
+
},
|
|
399
|
+
run: async (c, input) => {
|
|
400
|
+
const artifact = await c.artifacts.get(String(input.artifact));
|
|
401
|
+
if (artifact.application.id !== input.application && artifact.application.name !== input.application)
|
|
402
|
+
throw Object.assign(new Error(`${artifact.id} is an artifact of ${artifact.application.id}, not ${String(input.application)}.`), { code: "INVALID_INPUT" });
|
|
403
|
+
// accounts: AppBoundry serves an artifact that declares built-in accounts only when the operator accepts operator-issued sessions.
|
|
404
|
+
return { deployment: strip(await c.releases.deploy({ artifact: artifact.id, environment: String(input.environment), ...(input.target === "managed" ? { target: "managed" } : {}), ...(c.approval ? { approval: c.approval.id } : {}), ...(input.accounts === "operator-sessions" ? { runtime: { accounts: "operator-sessions" } } : {}) }, c.caller)) };
|
|
405
|
+
},
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
name: "release.rollback",
|
|
409
|
+
version: 1,
|
|
410
|
+
description: "Roll an environment back to an earlier deployment's immutable artifact (default: the one the current deployment replaced), as a new deployment linked to the one it rolls back, checked like any other.",
|
|
411
|
+
effect: "consequential",
|
|
412
|
+
permission: PLATFORM_PERMISSIONS.deploy,
|
|
413
|
+
scope: (input) => deployScope(String(input.application ?? ""), String(input.environment ?? "")),
|
|
414
|
+
input: shapeToObjectSchema({ application: s.string(), environment: s.string(), to: s.optional(s.string()), approval: s.optional(s.string()), reason: s.optional(s.string()) }),
|
|
415
|
+
output: json,
|
|
416
|
+
integration: { purpose: "Return to a revision that is known to have run.", effects: [{ type: "deploy", description: "Deploys an earlier artifact." }], approval: { required: true }, failures: [...NONE, { code: "FAILED_PRECONDITION", retry: "unsafe", effect: "none" }] },
|
|
417
|
+
precheck: async (c, input) => {
|
|
418
|
+
if (!(await c.releases.status(String(input.application), String(input.environment))).current)
|
|
419
|
+
throw Object.assign(new Error(`${String(input.application)}/${String(input.environment)} has nothing deployed.`), { code: "FAILED_PRECONDITION" });
|
|
420
|
+
},
|
|
421
|
+
run: async (c, input) => ({ deployment: strip(await c.releases.rollback({ application: String(input.application), environment: String(input.environment), ...(typeof input.to === "string" ? { to: input.to } : {}), ...(c.approval ? { approval: c.approval.id } : {}) }, c.caller)) }),
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
name: "release.status",
|
|
425
|
+
version: 1,
|
|
426
|
+
description: "What is running in an environment now, observed by the platform at this moment: the deployment, the artifact digest the runtime reports it loaded, health, AppPort surface, process.",
|
|
427
|
+
effect: "observation",
|
|
428
|
+
permission: PLATFORM_PERMISSIONS.read,
|
|
429
|
+
input: shapeToObjectSchema({ application: s.string(), environment: s.string() }),
|
|
430
|
+
output: json,
|
|
431
|
+
integration: { purpose: "See what is actually running, not what was last recorded.", effects: [], approval: { required: false }, failures: NONE },
|
|
432
|
+
run: async (c, input) => {
|
|
433
|
+
const st = await c.releases.status(String(input.application), String(input.environment));
|
|
434
|
+
return { ...st, current: st.current ? strip(st.current) : null };
|
|
435
|
+
},
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
name: "release.history",
|
|
439
|
+
version: 1,
|
|
440
|
+
description: "An environment's deployments, newest first: artifact, kind (deploy, rollback, restart), who, approval, outcome, checks and receipt.",
|
|
441
|
+
effect: "observation",
|
|
442
|
+
permission: PLATFORM_PERMISSIONS.read,
|
|
443
|
+
input: shapeToObjectSchema({ application: s.string(), environment: s.string() }),
|
|
444
|
+
output: json,
|
|
445
|
+
integration: { purpose: "Inspect every deployment and its evidence.", effects: [], approval: { required: false }, failures: NONE },
|
|
446
|
+
run: async (c, input) => ({ deployments: (await c.releases.history(String(input.application), String(input.environment))).map(strip) }),
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
name: "release.stop",
|
|
450
|
+
version: 1,
|
|
451
|
+
description: "Stop an environment's running deployment. Its state is kept.",
|
|
452
|
+
effect: "consequential",
|
|
453
|
+
permission: PLATFORM_PERMISSIONS.deploy,
|
|
454
|
+
scope: (input) => deployScope(String(input.application ?? ""), String(input.environment ?? "")),
|
|
455
|
+
input: shapeToObjectSchema({ application: s.string(), environment: s.string(), approval: s.optional(s.string()), reason: s.optional(s.string()) }),
|
|
456
|
+
output: json,
|
|
457
|
+
integration: { purpose: "Take an application out of service.", effects: [{ type: "deploy", description: "Stops the application's process." }], approval: { required: true }, failures: [...NONE, CONFLICT] },
|
|
458
|
+
precheck: async (c, input) => {
|
|
459
|
+
if (!(await c.releases.status(String(input.application), String(input.environment))).current)
|
|
460
|
+
throw Object.assign(new Error(`${String(input.application)}/${String(input.environment)} has nothing deployed.`), { code: "FAILED_PRECONDITION" });
|
|
461
|
+
},
|
|
462
|
+
run: async (c, input) => ({ deployment: strip(await c.releases.stop(String(input.application), String(input.environment), c.caller)) }),
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
name: "release.restart",
|
|
466
|
+
version: 1,
|
|
467
|
+
description: "Start the current deployment's artifact again (after a stop or a machine restart), checked like a deployment.",
|
|
468
|
+
effect: "consequential",
|
|
469
|
+
permission: PLATFORM_PERMISSIONS.deploy,
|
|
470
|
+
scope: (input) => deployScope(String(input.application ?? ""), String(input.environment ?? "")),
|
|
471
|
+
input: shapeToObjectSchema({ application: s.string(), environment: s.string(), approval: s.optional(s.string()), reason: s.optional(s.string()) }),
|
|
472
|
+
output: json,
|
|
473
|
+
integration: { purpose: "Bring the same immutable artifact back up.", effects: [{ type: "deploy", description: "Restarts the application on its current artifact." }], approval: { required: true }, failures: [...NONE, CONFLICT] },
|
|
474
|
+
precheck: async (c, input) => {
|
|
475
|
+
if (!(await c.releases.status(String(input.application), String(input.environment))).current)
|
|
476
|
+
throw Object.assign(new Error(`${String(input.application)}/${String(input.environment)} has nothing deployed.`), { code: "FAILED_PRECONDITION" });
|
|
477
|
+
},
|
|
478
|
+
run: async (c, input) => ({ deployment: strip(await c.releases.restart(String(input.application), String(input.environment), c.caller)) }),
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
name: "source.init",
|
|
482
|
+
version: 1,
|
|
483
|
+
description: "Make a workspace a Git repository whose first commit is its first snapshot (the project's source revision as it was copied). Git is one source-management integration; the workspace is the change boundary.",
|
|
484
|
+
effect: "consequential",
|
|
485
|
+
permission: PLATFORM_PERMISSIONS.develop,
|
|
486
|
+
input: shapeToObjectSchema({ ...workspace, branch: s.optional(s.string()) }),
|
|
487
|
+
output: json,
|
|
488
|
+
integration: { purpose: "Track changes in a workspace with Git.", effects: [{ type: "execution", description: "Runs git init, add and commit in the workspace (recorded executions)." }], approval: { required: false }, failures: NONE },
|
|
489
|
+
run: async (c, input) => {
|
|
490
|
+
const ws = await c.workspaces.active(String(input.workspace), viewer(c));
|
|
491
|
+
const branch = checkRef(typeof input.branch === "string" ? input.branch : "main");
|
|
492
|
+
const runs = [await git(c, ws, ["init", "-q", "-b", branch]), await git(c, ws, ["add", "-A", "--", ":/", ":!node_modules", ":!.feltkit-*"]), await git(c, ws, [...identity(c), "commit", "-q", "--allow-empty", "-m", `Workspace ${ws.id} at ${ws.baseRevision}`])];
|
|
493
|
+
return { branch, executions: runs.map((r) => r.id), head: (await gitText(c, ws, ["rev-parse", "HEAD"])).trim() };
|
|
494
|
+
},
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
name: "source.status",
|
|
498
|
+
version: 1,
|
|
499
|
+
description: "The workspace repository's branch, HEAD and changed paths (git status --porcelain=v2).",
|
|
500
|
+
effect: "observation",
|
|
501
|
+
permission: PLATFORM_PERMISSIONS.read,
|
|
502
|
+
input: shapeToObjectSchema(workspace),
|
|
503
|
+
output: json,
|
|
504
|
+
integration: { purpose: "What is uncommitted, from Git itself.", effects: [], approval: { required: false }, failures: NONE },
|
|
505
|
+
run: async (c, input) => {
|
|
506
|
+
const ws = await c.workspaces.active(String(input.workspace), viewer(c));
|
|
507
|
+
const text = await gitText(c, ws, ["status", "--porcelain=v2", "--branch", "--untracked-files=all"]);
|
|
508
|
+
const branch = /^# branch\.head (.+)$/m.exec(text)?.[1] ?? null;
|
|
509
|
+
const head = /^# branch\.oid (.+)$/m.exec(text)?.[1] ?? null;
|
|
510
|
+
const changes = text.split("\n").filter((l) => /^[12?u] /.test(l)).map((l) => (l.startsWith("?") ? { status: "untracked", path: l.slice(2) } : { status: l.split(" ")[1], path: l.split(" ").at(-1) }));
|
|
511
|
+
return { branch, head, changes };
|
|
512
|
+
},
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
name: "source.diff",
|
|
516
|
+
version: 1,
|
|
517
|
+
description: "Git's diff of the workspace (working tree against HEAD, or between two revisions), with untracked files included as additions.",
|
|
518
|
+
effect: "observation",
|
|
519
|
+
permission: PLATFORM_PERMISSIONS.read,
|
|
520
|
+
input: shapeToObjectSchema({ ...workspace, from: s.optional(s.string()), to: s.optional(s.string()) }),
|
|
521
|
+
output: json,
|
|
522
|
+
integration: { purpose: "Review changes as Git sees them.", effects: [], approval: { required: false }, failures: NONE },
|
|
523
|
+
run: async (c, input) => {
|
|
524
|
+
const ws = await c.workspaces.active(String(input.workspace), viewer(c));
|
|
525
|
+
const range = [typeof input.from === "string" ? checkRef(input.from) : "HEAD", ...(typeof input.to === "string" ? [checkRef(input.to)] : [])];
|
|
526
|
+
if (typeof input.to !== "string")
|
|
527
|
+
await git(c, ws, ["add", "-N", "-A", "--", ":/", ":!node_modules", ":!.feltkit-*"]);
|
|
528
|
+
return { patch: await gitText(c, ws, ["diff", "--no-color", "--no-ext-diff", ...range, "--", ":/", ":!node_modules", ":!.feltkit-*"]) };
|
|
529
|
+
},
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
name: "source.commit",
|
|
533
|
+
version: 1,
|
|
534
|
+
description: "Commit the workspace's changes (all, or the given paths) with a message, attributed to the caller. Never pushes. The commit's tree is checked against a fresh snapshot: they must hold the same source.",
|
|
535
|
+
effect: "consequential",
|
|
536
|
+
permission: PLATFORM_PERMISSIONS.develop,
|
|
537
|
+
input: shapeToObjectSchema({ ...workspace, message: s.string(), paths: s.optional(s.array(s.string())) }),
|
|
538
|
+
output: json,
|
|
539
|
+
integration: { purpose: "Record a reviewable revision in the workspace's history.", effects: [{ type: "write", description: "Creates a commit in the workspace repository." }], approval: { required: false, when: "a deployment policy may require it; commits never leave the workspace" }, failures: [...NONE, CONFLICT] },
|
|
540
|
+
run: async (c, input) => {
|
|
541
|
+
const ws = await c.workspaces.active(String(input.workspace), viewer(c));
|
|
542
|
+
const message = String(input.message).slice(0, 5000);
|
|
543
|
+
if (!message.trim())
|
|
544
|
+
throw Object.assign(new Error("A commit needs a message."), { code: "INVALID_INPUT" });
|
|
545
|
+
const paths = Array.isArray(input.paths) ? input.paths.map((p) => checkSourcePath(p)) : null;
|
|
546
|
+
const add = await git(c, ws, ["add", "-A", "--", ...(paths ?? [":/", ":!node_modules", ":!.feltkit-*"])]);
|
|
547
|
+
const commit = await git(c, ws, [...identity(c), "commit", "-q", "-m", message]);
|
|
548
|
+
if (commit.state !== "succeeded")
|
|
549
|
+
throw Object.assign(new Error(`git commit failed (execution ${commit.id}); nothing to commit?`), { code: "FAILED_PRECONDITION", details: { execution: commit.id } });
|
|
550
|
+
const head = (await gitText(c, ws, ["rev-parse", "HEAD"])).trim();
|
|
551
|
+
const { snapshot } = await c.workspaces.snapshot(ws.id, { label: `commit ${head.slice(0, 12)}` }, c.caller, c.seesAll);
|
|
552
|
+
return { commit: head, snapshot: { id: snapshot.id, revision: snapshot.revision }, executions: [add.id, commit.id] };
|
|
553
|
+
},
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
name: "source.log",
|
|
557
|
+
version: 1,
|
|
558
|
+
description: "The workspace repository's commits, newest first: hash, author, date, subject.",
|
|
559
|
+
effect: "observation",
|
|
560
|
+
permission: PLATFORM_PERMISSIONS.read,
|
|
561
|
+
input: shapeToObjectSchema({ ...workspace, limit: s.optional(s.number()) }),
|
|
562
|
+
output: json,
|
|
563
|
+
integration: { purpose: "The history of revisions.", effects: [], approval: { required: false }, failures: NONE },
|
|
564
|
+
run: async (c, input) => {
|
|
565
|
+
const ws = await c.workspaces.active(String(input.workspace), viewer(c));
|
|
566
|
+
const n = Math.min(Math.max(1, Number(input.limit ?? 50)), 500);
|
|
567
|
+
const text = await gitText(c, ws, ["log", `-n${n}`, "--format=%H%x1f%an%x1f%aI%x1f%s"]);
|
|
568
|
+
return { commits: text.split("\n").filter(Boolean).map((l) => { const [hash, author, date, subject] = l.split("\x1f"); return { hash, author, date, subject }; }) };
|
|
569
|
+
},
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
name: "source.branch",
|
|
573
|
+
version: 1,
|
|
574
|
+
description: "Create a branch at HEAD (or a revision) and switch to it, or switch to an existing one.",
|
|
575
|
+
effect: "consequential",
|
|
576
|
+
permission: PLATFORM_PERMISSIONS.develop,
|
|
577
|
+
input: shapeToObjectSchema({ ...workspace, name: s.string(), create: s.optional(s.boolean()), from: s.optional(s.string()) }),
|
|
578
|
+
output: json,
|
|
579
|
+
integration: { purpose: "Separate lines of work in one workspace.", effects: [{ type: "write", description: "Creates or switches a branch in the workspace repository." }], approval: { required: false }, failures: [...NONE, CONFLICT] },
|
|
580
|
+
run: async (c, input) => {
|
|
581
|
+
const ws = await c.workspaces.active(String(input.workspace), viewer(c));
|
|
582
|
+
const name = checkRef(String(input.name));
|
|
583
|
+
const r = await git(c, ws, input.create === false ? ["switch", name] : ["switch", "-c", name, ...(typeof input.from === "string" ? [checkRef(input.from)] : [])]);
|
|
584
|
+
if (r.state !== "succeeded")
|
|
585
|
+
throw Object.assign(new Error(`git switch failed (execution ${r.id}).`), { code: "CONFLICT", details: { execution: r.id } });
|
|
586
|
+
return { branch: name, execution: r.id };
|
|
587
|
+
},
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
name: "release.reconcile",
|
|
591
|
+
version: 1,
|
|
592
|
+
description: "Make what runs match what should: if the environment's current deployment is meant to run but is not observed running (after a machine restart or a crash), start the same immutable artifact again and check it like a deployment (recorded as a restart). Managed hosting is reconciled by its host agents; here it is only observed. Re-establishes the approved state; decides nothing new.",
|
|
593
|
+
effect: "consequential",
|
|
594
|
+
permission: PLATFORM_PERMISSIONS.deploy,
|
|
595
|
+
scope: (input) => deployScope(String(input.application ?? ""), String(input.environment ?? "")),
|
|
596
|
+
input: shapeToObjectSchema({ application: s.string(), environment: s.string() }),
|
|
597
|
+
output: json,
|
|
598
|
+
integration: { purpose: "Recover deterministically to the desired state.", effects: [{ type: "deploy", description: "Starts the current deployment's artifact again, if it is not running." }], approval: { required: false }, failures: [...NONE, CONFLICT] },
|
|
599
|
+
run: async (c, input) => {
|
|
600
|
+
const r = await c.releases.reconcile(String(input.application), String(input.environment), c.caller);
|
|
601
|
+
return { ...r, ...(r.deployment ? { deployment: strip(r.deployment) } : {}) };
|
|
602
|
+
},
|
|
603
|
+
},
|
|
604
|
+
];
|
|
605
|
+
//# sourceMappingURL=workspace-operations.js.map
|