@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.
Files changed (155) hide show
  1. package/dist/app.d.ts +17 -3
  2. package/dist/app.js +10 -0
  3. package/dist/app.js.map +1 -1
  4. package/dist/appboundry/build.js +4 -0
  5. package/dist/appboundry/build.js.map +1 -1
  6. package/dist/authorize.d.ts +1 -1
  7. package/dist/cli/deploy-appboundry.d.ts +26 -0
  8. package/dist/cli/deploy-appboundry.js +1 -1
  9. package/dist/cli/deploy-appboundry.js.map +1 -1
  10. package/dist/cli/main.js +17 -153
  11. package/dist/cli/main.js.map +1 -1
  12. package/dist/client/index.d.ts +83 -4
  13. package/dist/client/index.js +204 -10
  14. package/dist/client/index.js.map +1 -1
  15. package/dist/dashboard/assets/index-BEjtLLYq.js +15 -0
  16. package/dist/dashboard/index.html +1 -1
  17. package/dist/docs.d.ts +1 -1
  18. package/dist/docs.js +2 -0
  19. package/dist/docs.js.map +1 -1
  20. package/dist/index.d.ts +4 -2
  21. package/dist/index.js.map +1 -1
  22. package/dist/platform/approvals.d.ts +102 -0
  23. package/dist/platform/approvals.js +155 -0
  24. package/dist/platform/approvals.js.map +1 -0
  25. package/dist/platform/artifacts.d.ts +126 -0
  26. package/dist/platform/artifacts.js +251 -0
  27. package/dist/platform/artifacts.js.map +1 -0
  28. package/dist/platform/blobs.d.ts +25 -0
  29. package/dist/platform/blobs.js +78 -0
  30. package/dist/platform/blobs.js.map +1 -0
  31. package/dist/platform/diff.d.ts +23 -0
  32. package/dist/platform/diff.js +107 -0
  33. package/dist/platform/diff.js.map +1 -0
  34. package/dist/platform/exec.d.ts +182 -0
  35. package/dist/platform/exec.js +575 -0
  36. package/dist/platform/exec.js.map +1 -0
  37. package/dist/platform/managed.d.ts +43 -0
  38. package/dist/platform/managed.js +137 -0
  39. package/dist/platform/managed.js.map +1 -0
  40. package/dist/platform/operations.d.ts +30 -13
  41. package/dist/platform/operations.js +8 -17
  42. package/dist/platform/operations.js.map +1 -1
  43. package/dist/platform/permissions.d.ts +15 -0
  44. package/dist/platform/permissions.js +16 -0
  45. package/dist/platform/permissions.js.map +1 -0
  46. package/dist/platform/platform.d.ts +51 -0
  47. package/dist/platform/platform.js +105 -6
  48. package/dist/platform/platform.js.map +1 -1
  49. package/dist/platform/releases.d.ts +150 -0
  50. package/dist/platform/releases.js +467 -0
  51. package/dist/platform/releases.js.map +1 -0
  52. package/dist/platform/review.d.ts +10 -0
  53. package/dist/platform/review.js +109 -0
  54. package/dist/platform/review.js.map +1 -0
  55. package/dist/platform/server.js +7 -0
  56. package/dist/platform/server.js.map +1 -1
  57. package/dist/platform/source.d.ts +2 -0
  58. package/dist/platform/source.js +1 -1
  59. package/dist/platform/source.js.map +1 -1
  60. package/dist/platform/workspace-operations.d.ts +2 -0
  61. package/dist/platform/workspace-operations.js +605 -0
  62. package/dist/platform/workspace-operations.js.map +1 -0
  63. package/dist/platform/workspaces.d.ts +211 -0
  64. package/dist/platform/workspaces.js +435 -0
  65. package/dist/platform/workspaces.js.map +1 -0
  66. package/dist/react/index.d.ts +29 -1
  67. package/dist/react/index.js +50 -0
  68. package/dist/react/index.js.map +1 -1
  69. package/dist/runtime/activity.d.ts +1 -1
  70. package/dist/runtime/agent.d.ts +216 -2
  71. package/dist/runtime/agent.js +333 -7
  72. package/dist/runtime/agent.js.map +1 -1
  73. package/dist/runtime/approval-rules.d.ts +16 -0
  74. package/dist/runtime/approval-rules.js +37 -0
  75. package/dist/runtime/approval-rules.js.map +1 -0
  76. package/dist/runtime/authboundry.d.ts +53 -0
  77. package/dist/runtime/authboundry.js +82 -0
  78. package/dist/runtime/authboundry.js.map +1 -0
  79. package/dist/runtime/authority.d.ts +18 -1
  80. package/dist/runtime/authority.js +26 -1
  81. package/dist/runtime/authority.js.map +1 -1
  82. package/dist/runtime/browser-inference.d.ts +52 -0
  83. package/dist/runtime/browser-inference.js +53 -0
  84. package/dist/runtime/browser-inference.js.map +1 -0
  85. package/dist/runtime/context.d.ts +110 -0
  86. package/dist/runtime/decisions.d.ts +23 -0
  87. package/dist/runtime/decisions.js +54 -0
  88. package/dist/runtime/decisions.js.map +1 -1
  89. package/dist/runtime/generation.d.ts +94 -0
  90. package/dist/runtime/generation.js +295 -0
  91. package/dist/runtime/generation.js.map +1 -0
  92. package/dist/runtime/runtime.d.ts +10 -2
  93. package/dist/runtime/runtime.js +125 -1
  94. package/dist/runtime/runtime.js.map +1 -1
  95. package/dist/server/admin.d.ts +9 -1
  96. package/dist/server/admin.js +84 -2
  97. package/dist/server/admin.js.map +1 -1
  98. package/dist/server/index.d.ts +1 -1
  99. package/dist/server/index.js +208 -11
  100. package/dist/server/index.js.map +1 -1
  101. package/dist/server/tenancy.js +1 -1
  102. package/dist/server/tenancy.js.map +1 -1
  103. package/dist/testing/index.d.ts +11 -0
  104. package/dist/testing/index.js +7 -3
  105. package/dist/testing/index.js.map +1 -1
  106. package/docs/AUTH.md +3 -2
  107. package/docs/EXTENSION-HOSTS.md +52 -0
  108. package/docs/GENERATION.md +136 -0
  109. package/docs/README.md +4 -2
  110. package/package.json +6 -8
  111. package/skills/.claude-plugin/marketplace.json +1 -1
  112. package/skills/.claude-plugin/plugin.json +1 -1
  113. package/dist/cli/compose.d.ts +0 -31
  114. package/dist/cli/compose.js +0 -274
  115. package/dist/cli/compose.js.map +0 -1
  116. package/dist/cli/create.d.ts +0 -219
  117. package/dist/cli/create.js +0 -1197
  118. package/dist/cli/create.js.map +0 -1
  119. package/dist/cli/domain.d.ts +0 -174
  120. package/dist/cli/domain.js +0 -1170
  121. package/dist/cli/domain.js.map +0 -1
  122. package/dist/cli/screens.d.ts +0 -25
  123. package/dist/cli/screens.js +0 -282
  124. package/dist/cli/screens.js.map +0 -1
  125. package/dist/cli/shell.d.ts +0 -7
  126. package/dist/cli/shell.js +0 -63
  127. package/dist/cli/shell.js.map +0 -1
  128. package/dist/composition/catalog.d.ts +0 -3
  129. package/dist/composition/catalog.js +0 -217
  130. package/dist/composition/catalog.js.map +0 -1
  131. package/dist/composition/contract.d.ts +0 -165
  132. package/dist/composition/contract.js +0 -12
  133. package/dist/composition/contract.js.map +0 -1
  134. package/dist/composition/execute.d.ts +0 -110
  135. package/dist/composition/execute.js +0 -350
  136. package/dist/composition/execute.js.map +0 -1
  137. package/dist/composition/generate.d.ts +0 -105
  138. package/dist/composition/generate.js +0 -274
  139. package/dist/composition/generate.js.map +0 -1
  140. package/dist/composition/plan.d.ts +0 -131
  141. package/dist/composition/plan.js +0 -558
  142. package/dist/composition/plan.js.map +0 -1
  143. package/dist/composition/profiles.d.ts +0 -20
  144. package/dist/composition/profiles.js +0 -81
  145. package/dist/composition/profiles.js.map +0 -1
  146. package/dist/composition/reconcile.d.ts +0 -153
  147. package/dist/composition/reconcile.js +0 -282
  148. package/dist/composition/reconcile.js.map +0 -1
  149. package/dist/composition/recover.d.ts +0 -89
  150. package/dist/composition/recover.js +0 -407
  151. package/dist/composition/recover.js.map +0 -1
  152. package/dist/composition/resolve.d.ts +0 -2
  153. package/dist/composition/resolve.js +0 -208
  154. package/dist/composition/resolve.js.map +0 -1
  155. package/dist/dashboard/assets/index-BrC1AtZ1.js +0 -15
@@ -9,7 +9,7 @@
9
9
  <link rel="apple-touch-icon" href="/_feltkit/apple-touch-icon.png" />
10
10
  <title>FeltKit</title>
11
11
  <script>(function(){try{var v=window.localStorage.getItem("stack-ui.theme");if(v==="light"||v==="dark")document.documentElement.setAttribute("data-stack-theme",v);}catch(e){}})();</script>
12
- <script type="module" crossorigin src="/_feltkit/assets/index-BrC1AtZ1.js"></script>
12
+ <script type="module" crossorigin src="/_feltkit/assets/index-BEjtLLYq.js"></script>
13
13
  <link rel="stylesheet" crossorigin href="/_feltkit/assets/index-BXTNQAg1.css">
14
14
  </head>
15
15
  <body>
package/dist/docs.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export declare const PACKAGE_NAME = "@feltdb/feltkit";
2
2
  /** The documents shipped in the package, with what each one answers. Order = reading order. */
3
- export declare const SHIPPED_DOCS: readonly [readonly ["ARCHITECTURE.md", "How FeltKit is put together: one FeltDB instance, AppPort, AppPort Services"], readonly ["GUARANTEES.md", "What FeltKit guarantees, and its known limitations"], readonly ["TRANSACTIONS.md", "Mutations, ctx.db.sequence and ctx.afterCommit: the transaction contract"], readonly ["SECURITY.md", "Authorization, sessions, credentials, and production Studio"], readonly ["AUTH.md", "Accounts, sessions, workspaces (tenancy), invitations, and the React sign-in and workspace screens"], readonly ["AGENT-OPERATIONS.md", "Agents: MCP, tasks, proposals, approvals, and evidence"], readonly ["RESOLVER.md", "Model references: change the model a deployed app uses through Resolver, without a redeploy"], readonly ["PATH-TO-PRODUCTION.md", "From a local app to production: deploy targets and what you must provide"], readonly ["BACKUP.md", "Backing up and restoring an environment's state"], readonly ["COMPONENTS.md", "Runtime components: a gateway or worker that runs with the application, as a declared principal"], readonly ["APPBOUNDRY.md", "The AppBoundry artifact, deploying through AppBoundry, and the self-hosted runtime"], readonly ["APPBOUNDRY-DEPLOY-CONTRACT.md", "The deployment contract FeltKit expects from AppBoundry (proposed)"], readonly ["WHY-FELTKIT.md", "Design choices, compared with Convex"], readonly ["UPSTREAM-GAPS.md", "Known gaps in FeltDB, AppPort and AppPort Services, and their status"]];
3
+ export declare const SHIPPED_DOCS: readonly [readonly ["ARCHITECTURE.md", "How FeltKit is put together: one FeltDB instance, AppPort, AppPort Services"], readonly ["GUARANTEES.md", "What FeltKit guarantees, and its known limitations"], readonly ["TRANSACTIONS.md", "Mutations, ctx.db.sequence and ctx.afterCommit: the transaction contract"], readonly ["SECURITY.md", "Authorization, sessions, credentials, and production Studio"], readonly ["AUTH.md", "Accounts, sessions, workspaces (tenancy), invitations, and the React sign-in and workspace screens"], readonly ["EXTENSION-HOSTS.md", "Running the app in a browser extension: ownership, token storage, session end, lifecycle, gaps"], readonly ["AGENT-OPERATIONS.md", "Agents: MCP, tasks, proposals, approvals, and evidence"], readonly ["GENERATION.md", "Model generation in an application: actions, streaming, tools as proposals, in-app approvals, caller context"], readonly ["RESOLVER.md", "Model references: change the model a deployed app uses through Resolver, without a redeploy"], readonly ["PATH-TO-PRODUCTION.md", "From a local app to production: deploy targets and what you must provide"], readonly ["BACKUP.md", "Backing up and restoring an environment's state"], readonly ["COMPONENTS.md", "Runtime components: a gateway or worker that runs with the application, as a declared principal"], readonly ["APPBOUNDRY.md", "The AppBoundry artifact, deploying through AppBoundry, and the self-hosted runtime"], readonly ["APPBOUNDRY-DEPLOY-CONTRACT.md", "The deployment contract FeltKit expects from AppBoundry (proposed)"], readonly ["WHY-FELTKIT.md", "Design choices, compared with Convex"], readonly ["UPSTREAM-GAPS.md", "Known gaps in FeltDB, AppPort and AppPort Services, and their status"]];
4
4
  export type DocName = (typeof SHIPPED_DOCS)[number][0];
5
5
  /** The shipped file on disk (inside node_modules/@feltdb/feltkit in a project). */
6
6
  export declare function docFile(name: DocName): string;
package/dist/docs.js CHANGED
@@ -19,7 +19,9 @@ export const SHIPPED_DOCS = [
19
19
  ["TRANSACTIONS.md", "Mutations, ctx.db.sequence and ctx.afterCommit: the transaction contract"],
20
20
  ["SECURITY.md", "Authorization, sessions, credentials, and production Studio"],
21
21
  ["AUTH.md", "Accounts, sessions, workspaces (tenancy), invitations, and the React sign-in and workspace screens"],
22
+ ["EXTENSION-HOSTS.md", "Running the app in a browser extension: ownership, token storage, session end, lifecycle, gaps"],
22
23
  ["AGENT-OPERATIONS.md", "Agents: MCP, tasks, proposals, approvals, and evidence"],
24
+ ["GENERATION.md", "Model generation in an application: actions, streaming, tools as proposals, in-app approvals, caller context"],
23
25
  ["RESOLVER.md", "Model references: change the model a deployed app uses through Resolver, without a redeploy"],
24
26
  ["PATH-TO-PRODUCTION.md", "From a local app to production: deploy targets and what you must provide"],
25
27
  ["BACKUP.md", "Backing up and restoring an environment's state"],
package/dist/docs.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"docs.js","sourceRoot":"","sources":["../src/docs.ts"],"names":[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C,eAAe,EAAE,iGAAiG,CAAC;IACpH,CAAC,eAAe,EAAE,oFAAoF,CAAC;IACvG,CAAC,+BAA+B,EAAE,oEAAoE,CAAC;IACvG,CAAC,gBAAgB,EAAE,sCAAsC,CAAC;IAC1D,CAAC,kBAAkB,EAAE,sEAAsE,CAAC;CACpF,CAAC;AAIX,mFAAmF;AACnF,MAAM,UAAU,OAAO,CAAC,IAAa;IACnC,OAAO,aAAa,CAAC,IAAI,GAAG,CAAC,WAAW,IAAI,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,MAAM,CAAC,IAAc;IACnC,OAAO,gCAAgC,YAAY,IAAI,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;AAC1G,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,MAAM,CAAC,IAAa;IAClC,OAAO,gBAAgB,YAAY,SAAS,IAAI,KAAK,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AACvE,CAAC;AAED,gFAAgF;AAChF,MAAM,CAAC,MAAM,YAAY,GAAG,iCAAiC,YAAY,EAAE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -7,12 +7,14 @@
7
7
  * export const list = app.query({ access: "tasks.read", handler: (ctx) => ctx.db.find(tasks) });
8
8
  */
9
9
  export { feltkit, FeltKitApp, RESERVED_COLLECTIONS } from "./app.js";
10
- export type { Access, AgentConfig, AgentDefinition, AuthenticateRequest, CapabilityExposure, CollectionDefinition, CollectionOptions, MigrationContext, MigrationDefinition, StoredRecord, UniqueDeclaration, FeltKitOptions, DevUser, AccountsOptions, AccountEmailOptions, ProviderClient, OidcProvider, SignInProviders, FunctionConfig, FunctionDefinition, FunctionKind, MutationDefinition, PrincipalInput, QueryDefinition, } from "./app.js";
10
+ export type { Access, AgentConfig, AgentDefinition, AuthenticateRequest, CapabilityExposure, CollectionDefinition, CollectionOptions, MigrationContext, MigrationDefinition, StoredRecord, UniqueDeclaration, FeltKitOptions, DevUser, AccountsOptions, AccountEmailOptions, ProviderClient, OidcProvider, SignInProviders, FunctionConfig, FunctionDefinition, FunctionKind, MutationDefinition, ActionDefinition, PrincipalInput, QueryDefinition, } from "./app.js";
11
11
  export { s } from "./schema.js";
12
12
  export type { Doc, InferShape, Schema, ShapeInput, ShapeSchema } from "./schema.js";
13
13
  export { FeltKitError, fail, isFeltKitError } from "./errors.js";
14
14
  export type { FeltKitErrorCode, FeltKitErrorJSON } from "./errors.js";
15
- export type { QueryCtx, MutationCtx, AgentCtx, AgentTrigger, Logger, EnvironmentInfo } from "./runtime/context.js";
15
+ export type { QueryCtx, MutationCtx, ActionCtx, ActionModel, ActionAgent, ActionProposal, AgentCtx, AgentTrigger, Logger, EnvironmentInfo } from "./runtime/context.js";
16
+ export type { GenerationMessage, GenerationResult, GenerationReceipt, ToolCall, ToolDefinition, FinishReason } from "./runtime/generation.js";
17
+ export type { CallerContext } from "./runtime/authority.js";
16
18
  export type { CryptoContext } from "./runtime/crypto-token.js";
17
19
  export type { ClaimDeclaration, ClaimSpec, ClaimStatus, ClaimProvenance } from "./runtime/claims.js";
18
20
  export { CLAIM_TYPES, claimSpecProblem, claimSchema, isClaimSpec } from "./runtime/claims.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AA2BrE,OAAO,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAEhC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAKjE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAQ9F,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AA4BrE,OAAO,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAEhC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAOjE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAQ9F,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,102 @@
1
+ import type { StateFirstDB } from "@feltdb/core";
2
+ import type { Caller } from "./exec.js";
3
+ export declare const APPROVALS = "feltkit.platform.approvals";
4
+ export type ApprovalState = "pending" | "approved" | "rejected" | "expired" | "executing" | "succeeded" | "failed" | "interrupted";
5
+ export interface ApprovalRecord {
6
+ id: string;
7
+ operation: string;
8
+ version: number;
9
+ /** The exact input that will run (without the `approval` field). */
10
+ input: Record<string, unknown>;
11
+ inputDigest: string;
12
+ /** What the operation declares it does (its integration effects): the expected consequences. */
13
+ consequences: Array<{
14
+ type: string;
15
+ description: string;
16
+ }>;
17
+ /** The permissions it requires (the operation's and, when scoped, the scope). */
18
+ requires: string[];
19
+ proposedBy: {
20
+ id: string;
21
+ type: string;
22
+ };
23
+ proposedAt: string;
24
+ reason?: string;
25
+ requestId: string;
26
+ decisionId: string;
27
+ expiresAt: string;
28
+ state: ApprovalState;
29
+ decidedBy?: string;
30
+ decidedAt?: string;
31
+ note?: string;
32
+ executedAt?: string;
33
+ finishedAt?: string;
34
+ executionRequestId?: string;
35
+ result?: {
36
+ ok: boolean;
37
+ error?: {
38
+ code: string;
39
+ message: string;
40
+ };
41
+ };
42
+ __version?: number;
43
+ }
44
+ export declare class Approvals {
45
+ #private;
46
+ readonly ready: Promise<{
47
+ interrupted: string[];
48
+ }>;
49
+ constructor(db: StateFirstDB, options?: {
50
+ ttlMs?: number;
51
+ });
52
+ /** Record a pending approval for an operation an agent asked to run. */
53
+ request(operation: {
54
+ name: string;
55
+ version: number;
56
+ effects: Array<{
57
+ type: string;
58
+ description: string;
59
+ }>;
60
+ requires: string[];
61
+ }, input: Record<string, unknown>, caller: Caller, reason?: string): Promise<ApprovalRecord>;
62
+ /**
63
+ * An approval its viewer may see: the proposer, or someone who may decide it (holds what it
64
+ * requires). Others are told it does not exist. An expired one is reported as expired.
65
+ */
66
+ get(id: string, viewer: {
67
+ id: string;
68
+ mayPerform: (requires: string[]) => boolean;
69
+ }): Promise<ApprovalRecord>;
70
+ list(viewer: {
71
+ id: string;
72
+ mayPerform: (requires: string[]) => boolean;
73
+ }, filter?: {
74
+ state?: ApprovalState;
75
+ }): Promise<ApprovalRecord[]>;
76
+ /**
77
+ * A person decides. They must not be the proposer, must be able to perform the operation
78
+ * themselves (`mayPerform`), and must name the digest they reviewed.
79
+ */
80
+ decide(id: string, decision: {
81
+ approve: boolean;
82
+ inputDigest: string;
83
+ note?: string;
84
+ }, approver: Caller, mayPerform: (requires: string[]) => boolean): Promise<ApprovalRecord>;
85
+ /**
86
+ * Consume an approval to run `operation` with `input` as `caller`: it must be approved, unexpired,
87
+ * proposed by this caller, for this operation and exactly this input. The transition to
88
+ * `executing` is fenced, so it is consumed once even under concurrent calls.
89
+ */
90
+ consume(id: string, operation: {
91
+ name: string;
92
+ version: number;
93
+ }, input: Record<string, unknown>, caller: Caller): Promise<ApprovalRecord>;
94
+ /** The outcome of a consumed approval. */
95
+ finish(record: ApprovalRecord, result: {
96
+ ok: boolean;
97
+ error?: {
98
+ code: string;
99
+ message: string;
100
+ };
101
+ }): Promise<ApprovalRecord>;
102
+ }
@@ -0,0 +1,155 @@
1
+ /**
2
+ * Approvals for consequential platform operations (docs/M2-AGENT-OPERATIONS.md G3), with the same
3
+ * rules as an application's agent actions (runtime/approval-rules.ts).
4
+ *
5
+ * pending ──decide(approve)──▶ approved ──execute──▶ executing ──▶ succeeded | failed
6
+ * │ │ └──(platform stopped)──▶ interrupted
7
+ * ├──decide(reject)──▶ rejected
8
+ * └──(expiresAt)─────▶ expired (an approved one expires too, if never executed)
9
+ *
10
+ * An agent that invokes an operation requiring approval does not run it: a pending approval is
11
+ * recorded with the exact input and its digest, and the call answers `feltkit.APPROVAL_REQUIRED`.
12
+ * A person other than the proposer, who may perform the operation themselves, reviews it and
13
+ * approves the digest they saw. The proposer then invokes the same operation, with the same
14
+ * input and `approval: <id>`: its own session is authorized again, the input must still have the
15
+ * approved digest, and the approval is consumed exactly once (a fenced transition). A person
16
+ * holding the permission runs the operation directly; that call is their decision.
17
+ */
18
+ import { randomUUID } from "node:crypto";
19
+ import { readAll } from "../runtime/data.js";
20
+ import { credentialPaths } from "../runtime/agent.js";
21
+ import { DEFAULT_APPROVAL_TTL_MS, actionDigest, approverRefusal, isExpired } from "../runtime/approval-rules.js";
22
+ export const APPROVALS = "feltkit.platform.approvals";
23
+ const fail = (code, message, details) => Object.assign(new Error(message), { code, ...(details ? { details } : {}) });
24
+ const now = () => new Date().toISOString();
25
+ export class Approvals {
26
+ #db;
27
+ #ttlMs;
28
+ ready;
29
+ constructor(db, options = {}) {
30
+ this.#db = db;
31
+ this.#ttlMs = options.ttlMs ?? DEFAULT_APPROVAL_TTL_MS;
32
+ this.ready = this.#recover();
33
+ }
34
+ /** Record a pending approval for an operation an agent asked to run. */
35
+ async request(operation, input, caller, reason) {
36
+ await this.ready;
37
+ const secrets = credentialPaths(input);
38
+ if (secrets.length)
39
+ throw fail("INVALID_INPUT", `The input to ${operation.name} carries credential material (${secrets.join(", ")}); an approval records its input exactly, so pass a reference instead.`);
40
+ const at = now();
41
+ const record = {
42
+ id: `apr_${randomUUID().replace(/-/g, "").slice(0, 24)}`,
43
+ operation: operation.name,
44
+ version: operation.version,
45
+ input,
46
+ inputDigest: actionDigest(operation.name, input, operation.version),
47
+ consequences: operation.effects,
48
+ requires: operation.requires,
49
+ proposedBy: { id: caller.principal.id, type: caller.principal.type },
50
+ proposedAt: at,
51
+ ...(reason ? { reason: reason.slice(0, 2000) } : {}),
52
+ requestId: caller.requestId,
53
+ decisionId: caller.decisionId,
54
+ expiresAt: new Date(Date.parse(at) + this.#ttlMs).toISOString(),
55
+ state: "pending",
56
+ };
57
+ await this.#db.transaction({ operations: [{ collection: APPROVALS, id: record.id, requireAbsent: true, value: record }] });
58
+ return { ...record, __version: 1 };
59
+ }
60
+ async #get(id) {
61
+ if (typeof id !== "string" || !/^apr_[0-9a-f]{24}$/.test(id))
62
+ throw fail("INVALID_INPUT", "approval is an approval id (apr_…).");
63
+ const record = (await this.#db.collection(APPROVALS).get(id));
64
+ if (!record)
65
+ throw fail("NOT_FOUND", `No approval ${id}.`);
66
+ return record;
67
+ }
68
+ /**
69
+ * An approval its viewer may see: the proposer, or someone who may decide it (holds what it
70
+ * requires). Others are told it does not exist. An expired one is reported as expired.
71
+ */
72
+ async get(id, viewer) {
73
+ let record = await this.#get(id);
74
+ if (record.proposedBy.id !== viewer.id && !viewer.mayPerform(record.requires))
75
+ throw fail("NOT_FOUND", `No approval ${id}.`);
76
+ if ((record.state === "pending" || record.state === "approved") && isExpired(record.expiresAt))
77
+ record = await this.#move(record, { state: "expired" }).catch(() => record);
78
+ return record;
79
+ }
80
+ async list(viewer, filter = {}) {
81
+ const all = (await readAll(this.#db, { collection: APPROVALS, ...(filter.state ? { where: [{ field: "state", eq: filter.state }] } : {}) }));
82
+ return all.filter((a) => a.proposedBy.id === viewer.id || viewer.mayPerform(a.requires)).sort((a, b) => b.proposedAt.localeCompare(a.proposedAt));
83
+ }
84
+ /**
85
+ * A person decides. They must not be the proposer, must be able to perform the operation
86
+ * themselves (`mayPerform`), and must name the digest they reviewed.
87
+ */
88
+ async decide(id, decision, approver, mayPerform) {
89
+ const record = await this.get(id, { id: approver.principal.id, mayPerform });
90
+ if (record.state !== "pending")
91
+ throw fail("FAILED_PRECONDITION", `Approval ${id} is ${record.state}; only a pending one can be decided.`, { details: { state: record.state } });
92
+ const rule = approverRefusal(approver.principal, record.proposedBy, { separate: true });
93
+ if (rule)
94
+ throw fail("FORBIDDEN", `Approval refused: ${rule}.`);
95
+ if (!mayPerform(record.requires))
96
+ throw fail("FORBIDDEN", `Approval refused: ${approver.principal.id} may not perform ${record.operation} (requires ${record.requires.join(", ")}).`);
97
+ if (decision.inputDigest !== record.inputDigest)
98
+ throw fail("FAILED_PRECONDITION", `The operation you reviewed (${decision.inputDigest}) is not this approval's (${record.inputDigest}); nothing was decided. Review it again.`);
99
+ return this.#move(record, { state: decision.approve ? "approved" : "rejected", decidedBy: approver.principal.id, decidedAt: now(), ...(decision.note ? { note: decision.note.slice(0, 2000) } : {}) });
100
+ }
101
+ /**
102
+ * Consume an approval to run `operation` with `input` as `caller`: it must be approved, unexpired,
103
+ * proposed by this caller, for this operation and exactly this input. The transition to
104
+ * `executing` is fenced, so it is consumed once even under concurrent calls.
105
+ */
106
+ async consume(id, operation, input, caller) {
107
+ const record = await this.#get(id);
108
+ if (record.proposedBy.id !== caller.principal.id)
109
+ throw fail("NOT_FOUND", `No approval ${id}.`);
110
+ if (record.operation !== operation.name || record.version !== operation.version)
111
+ throw fail("FAILED_PRECONDITION", `Approval ${id} is for ${record.operation}, not ${operation.name}.`);
112
+ if (record.state === "approved" && isExpired(record.expiresAt)) {
113
+ await this.#move(record, { state: "expired" }).catch(() => undefined);
114
+ throw fail("FAILED_PRECONDITION", `Approval ${id} expired at ${record.expiresAt} before it was used; nothing ran.`);
115
+ }
116
+ if (record.state !== "approved")
117
+ throw fail(record.state === "pending" ? "feltkit.APPROVAL_PENDING" : "FAILED_PRECONDITION", record.state === "pending" ? `Approval ${id} has not been decided yet.` : `Approval ${id} is ${record.state}; it authorizes nothing now.`, { details: { state: record.state } });
118
+ const digest = actionDigest(operation.name, input, operation.version);
119
+ if (digest !== record.inputDigest)
120
+ throw fail("FAILED_PRECONDITION", `This input is not the one approved (${digest} ≠ ${record.inputDigest}): a changed operation needs its own approval. Nothing ran.`);
121
+ try {
122
+ return await this.#move(record, { state: "executing", executedAt: now(), executionRequestId: caller.requestId });
123
+ }
124
+ catch (error) {
125
+ if (error.code === "CONFLICT")
126
+ throw fail("CONFLICT", `Approval ${id} is already being used; it runs once.`);
127
+ throw error;
128
+ }
129
+ }
130
+ /** The outcome of a consumed approval. */
131
+ async finish(record, result) {
132
+ return this.#move(record, { state: result.ok ? "succeeded" : "failed", finishedAt: now(), result });
133
+ }
134
+ async #move(current, patch) {
135
+ const { __version, ...rest } = current;
136
+ const next = { ...rest, ...patch };
137
+ try {
138
+ await this.#db.transaction({ operations: [{ collection: APPROVALS, id: current.id, ifVersion: __version, value: next }] });
139
+ }
140
+ catch (error) {
141
+ if (error.code === "PRECONDITION_FAILED")
142
+ throw fail("CONFLICT", `Approval ${current.id} changed concurrently.`);
143
+ throw error;
144
+ }
145
+ return { ...next, __version: (__version ?? 0) + 1 };
146
+ }
147
+ /** An approval that was executing when the platform stopped: its outcome is unknown, and it is not run again. */
148
+ async #recover() {
149
+ const open = (await readAll(this.#db, { collection: APPROVALS, where: [{ field: "state", eq: "executing" }] }));
150
+ for (const record of open)
151
+ await this.#move(record, { state: "interrupted", finishedAt: now(), result: { ok: false, error: { code: "feltkit.INTERRUPTED", message: "The platform stopped while this approved operation ran; inspect its target. It is not run again." } } }).catch(() => undefined);
152
+ return { interrupted: open.map((r) => r.id) };
153
+ }
154
+ }
155
+ //# sourceMappingURL=approvals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approvals.js","sourceRoot":"","sources":["../../src/platform/approvals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,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I,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,CAAgC,CAAC;QAC/I,KAAK,MAAM,MAAM,IAAI,IAAI;YAAE,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,OAAO,EAAE,kGAAkG,EAAE,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACpS,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IAChD,CAAC;CACF"}
@@ -0,0 +1,126 @@
1
+ import type { StateFirstDB } from "@feltdb/core";
2
+ import type { BlobStore, Digest } from "./blobs.js";
3
+ import type { Caller, Executions } from "./exec.js";
4
+ import type { Workspaces } from "./workspaces.js";
5
+ export declare const ARTIFACTS = "feltkit.platform.artifacts";
6
+ export declare const BUILDS = "feltkit.platform.builds";
7
+ export declare const ARTIFACT_FORMAT = "appboundry.app/1";
8
+ export interface ArtifactRecord {
9
+ /** `art_` and the first 24 hex digits of the digest. */
10
+ id: string;
11
+ /** sha256 of manifest.json's bytes: AppBoundry's artifact id. */
12
+ digest: Digest;
13
+ format: string;
14
+ application: {
15
+ id: string;
16
+ name: string;
17
+ version?: string;
18
+ };
19
+ module: {
20
+ sha256: string;
21
+ size: number;
22
+ };
23
+ files: Array<[path: string, digest: Digest, size: number]>;
24
+ provenance: {
25
+ workspace: string;
26
+ project: string;
27
+ snapshot: string;
28
+ sourceRevision: string;
29
+ build: {
30
+ id: string;
31
+ execution: string;
32
+ tool: string;
33
+ producer: {
34
+ name?: string;
35
+ version?: string;
36
+ };
37
+ node: string;
38
+ command: string[];
39
+ };
40
+ builtBy: {
41
+ id: string;
42
+ type: string;
43
+ };
44
+ decisionId: string;
45
+ builtAt: string;
46
+ };
47
+ validation: {
48
+ platform: Array<{
49
+ check: string;
50
+ ok: boolean;
51
+ detail?: string;
52
+ }>;
53
+ verifier: {
54
+ execution: string;
55
+ program: string;
56
+ ok: boolean;
57
+ };
58
+ };
59
+ createdAt: string;
60
+ }
61
+ export interface BuildRecord {
62
+ id: string;
63
+ workspace: string;
64
+ snapshot: string;
65
+ sourceRevision: string;
66
+ state: "succeeded" | "failed";
67
+ executions: string[];
68
+ artifact?: string;
69
+ failure?: {
70
+ code: string;
71
+ message: string;
72
+ };
73
+ by: {
74
+ id: string;
75
+ type: string;
76
+ };
77
+ decisionId: string;
78
+ at: string;
79
+ }
80
+ /**
81
+ * The platform's own checks of an `appboundry.app/1` directory: its format, that the module and
82
+ * every file the manifest declares have the digests it declares, and that nothing else is there.
83
+ */
84
+ export declare function checkArtifact(dir: string): {
85
+ checks: Array<{
86
+ check: string;
87
+ ok: boolean;
88
+ detail?: string;
89
+ }>;
90
+ manifest: any;
91
+ manifestBytes: Buffer | null;
92
+ };
93
+ export declare class Artifacts {
94
+ #private;
95
+ constructor(db: StateFirstDB, options: {
96
+ blobs: BlobStore;
97
+ });
98
+ /** Build, validate and store an artifact from a workspace, as `caller`. */
99
+ build(input: {
100
+ workspace: string;
101
+ }, caller: Caller, deps: {
102
+ workspaces: Workspaces;
103
+ executions: Executions;
104
+ all: boolean;
105
+ }): Promise<{
106
+ artifact: ArtifactRecord;
107
+ build: BuildRecord;
108
+ existing: boolean;
109
+ }>;
110
+ get(id: string): Promise<ArtifactRecord>;
111
+ list(filter?: {
112
+ application?: string;
113
+ workspace?: string;
114
+ }): Promise<ArtifactRecord[]>;
115
+ builds(workspace: string): Promise<BuildRecord[]>;
116
+ /** Verify a stored artifact's bytes: every file against its recorded digest, and the manifest against the id. */
117
+ verify(id: string): Promise<{
118
+ ok: boolean;
119
+ problems: string[];
120
+ }>;
121
+ /**
122
+ * Write an artifact's files into `dir` (a release directory), each verified against its digest,
123
+ * then check the result again. A corrupted artifact is refused, never written.
124
+ */
125
+ materialize(id: string, dir: string): Promise<ArtifactRecord>;
126
+ }