@feltdb/feltkit 0.3.29 → 0.3.30

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 +74 -2
  2. package/dist/app.js +95 -1
  3. package/dist/app.js.map +1 -1
  4. package/dist/appboundry/build.js.map +1 -1
  5. package/dist/appboundry/guest-tenancy.d.ts +2 -2
  6. package/dist/appboundry/guest-tenancy.js.map +1 -1
  7. package/dist/appboundry/guest.js +4 -1
  8. package/dist/appboundry/guest.js.map +1 -1
  9. package/dist/appboundry/host.js +3 -0
  10. package/dist/appboundry/host.js.map +1 -1
  11. package/dist/authorize.d.ts +23 -1
  12. package/dist/authorize.js +37 -0
  13. package/dist/authorize.js.map +1 -1
  14. package/dist/cli/deploy-appboundry.d.ts +1 -1
  15. package/dist/cli/deploy-appboundry.js.map +1 -1
  16. package/dist/cli/deploy.js.map +1 -1
  17. package/dist/cli/main.js +27 -1
  18. package/dist/cli/main.js.map +1 -1
  19. package/dist/cli/skills.js.map +1 -1
  20. package/dist/client/index.js.map +1 -1
  21. package/dist/dashboard/assets/index-9rMS3yBm.js +15 -0
  22. package/dist/dashboard/assets/index-DkiYTUMR.css +1 -0
  23. package/dist/dashboard/index.html +2 -2
  24. package/dist/docs.d.ts +1 -1
  25. package/dist/docs.js +3 -0
  26. package/dist/docs.js.map +1 -1
  27. package/dist/errors.js.map +1 -1
  28. package/dist/event-stage.js.map +1 -1
  29. package/dist/execution.d.ts +186 -0
  30. package/dist/execution.js +105 -0
  31. package/dist/execution.js.map +1 -0
  32. package/dist/index.d.ts +5 -0
  33. package/dist/index.js +4 -0
  34. package/dist/index.js.map +1 -1
  35. package/dist/measure/index.js.map +1 -1
  36. package/dist/platform/approvals.js.map +1 -1
  37. package/dist/platform/artifacts.js.map +1 -1
  38. package/dist/platform/changes.d.ts +54 -54
  39. package/dist/platform/changes.js.map +1 -1
  40. package/dist/platform/deployments.d.ts +32 -32
  41. package/dist/platform/exec.js.map +1 -1
  42. package/dist/platform/platform.js.map +1 -1
  43. package/dist/platform/releases.js.map +1 -1
  44. package/dist/platform/server.js.map +1 -1
  45. package/dist/platform/workspaces.js.map +1 -1
  46. package/dist/react/auth.d.ts +10 -10
  47. package/dist/react/auth.js +1 -1
  48. package/dist/react/auth.js.map +1 -1
  49. package/dist/react/context.d.ts +1 -1
  50. package/dist/react/index.js.map +1 -1
  51. package/dist/runtime/accounts.js.map +1 -1
  52. package/dist/runtime/activity.d.ts +1 -1
  53. package/dist/runtime/activity.js.map +1 -1
  54. package/dist/runtime/agent.d.ts +3 -3
  55. package/dist/runtime/agent.js +9 -3
  56. package/dist/runtime/agent.js.map +1 -1
  57. package/dist/runtime/application-authority.d.ts +13 -2
  58. package/dist/runtime/application-authority.js +18 -6
  59. package/dist/runtime/application-authority.js.map +1 -1
  60. package/dist/runtime/audit.js.map +1 -1
  61. package/dist/runtime/authboundry.d.ts +17 -0
  62. package/dist/runtime/authboundry.js +8 -1
  63. package/dist/runtime/authboundry.js.map +1 -1
  64. package/dist/runtime/authority.d.ts +10 -0
  65. package/dist/runtime/authority.js +17 -0
  66. package/dist/runtime/authority.js.map +1 -1
  67. package/dist/runtime/backup-environment.js.map +1 -1
  68. package/dist/runtime/backup.js.map +1 -1
  69. package/dist/runtime/changes.js.map +1 -1
  70. package/dist/runtime/claims.js.map +1 -1
  71. package/dist/runtime/collections.js.map +1 -1
  72. package/dist/runtime/content.d.ts +27 -2
  73. package/dist/runtime/content.js +55 -5
  74. package/dist/runtime/content.js.map +1 -1
  75. package/dist/runtime/context.d.ts +153 -0
  76. package/dist/runtime/contract.js +5 -1
  77. package/dist/runtime/contract.js.map +1 -1
  78. package/dist/runtime/credentials.d.ts +31 -2
  79. package/dist/runtime/credentials.js +55 -3
  80. package/dist/runtime/credentials.js.map +1 -1
  81. package/dist/runtime/crypto-token.js.map +1 -1
  82. package/dist/runtime/data.js.map +1 -1
  83. package/dist/runtime/decisions.js.map +1 -1
  84. package/dist/runtime/deployment.js.map +1 -1
  85. package/dist/runtime/execution-host.d.ts +54 -0
  86. package/dist/runtime/execution-host.js +54 -0
  87. package/dist/runtime/execution-host.js.map +1 -0
  88. package/dist/runtime/generation.js.map +1 -1
  89. package/dist/runtime/instance.js.map +1 -1
  90. package/dist/runtime/integrations.d.ts +8 -6
  91. package/dist/runtime/integrations.js +48 -5
  92. package/dist/runtime/integrations.js.map +1 -1
  93. package/dist/runtime/invocations.d.ts +313 -0
  94. package/dist/runtime/invocations.js +493 -0
  95. package/dist/runtime/invocations.js.map +1 -0
  96. package/dist/runtime/loader.js.map +1 -1
  97. package/dist/runtime/local-authority.d.ts +50 -0
  98. package/dist/runtime/local-authority.js +214 -0
  99. package/dist/runtime/local-authority.js.map +1 -0
  100. package/dist/runtime/oauth-credentials.d.ts +40 -3
  101. package/dist/runtime/oauth-credentials.js +133 -25
  102. package/dist/runtime/oauth-credentials.js.map +1 -1
  103. package/dist/runtime/outbox.js +3 -0
  104. package/dist/runtime/outbox.js.map +1 -1
  105. package/dist/runtime/projects.d.ts +1 -1
  106. package/dist/runtime/readiness.js +11 -0
  107. package/dist/runtime/readiness.js.map +1 -1
  108. package/dist/runtime/runtime.d.ts +48 -5
  109. package/dist/runtime/runtime.js +139 -17
  110. package/dist/runtime/runtime.js.map +1 -1
  111. package/dist/runtime/services.d.ts +37 -0
  112. package/dist/runtime/services.js +191 -3
  113. package/dist/runtime/services.js.map +1 -1
  114. package/dist/runtime/sessions.js.map +1 -1
  115. package/dist/runtime/state-contract.js.map +1 -1
  116. package/dist/runtime/storage-check.js.map +1 -1
  117. package/dist/runtime/targets.d.ts +1 -1
  118. package/dist/runtime/tenancy.js.map +1 -1
  119. package/dist/runtime/transactions.d.ts +15 -0
  120. package/dist/runtime/transactions.js +5 -0
  121. package/dist/runtime/transactions.js.map +1 -1
  122. package/dist/schema.js.map +1 -1
  123. package/dist/server/admin.d.ts +51 -51
  124. package/dist/server/admin.js +11 -0
  125. package/dist/server/admin.js.map +1 -1
  126. package/dist/server/components.js.map +1 -1
  127. package/dist/server/index.js +39 -0
  128. package/dist/server/index.js.map +1 -1
  129. package/dist/server/management.js.map +1 -1
  130. package/dist/server/mcp.d.ts +59 -37
  131. package/dist/server/mcp.js +24 -1
  132. package/dist/server/mcp.js.map +1 -1
  133. package/dist/server/operators.js.map +1 -1
  134. package/dist/server/ports.d.ts +7 -0
  135. package/dist/server/ports.js +17 -0
  136. package/dist/server/ports.js.map +1 -1
  137. package/dist/server/production.js.map +1 -1
  138. package/dist/server/project.js.map +1 -1
  139. package/dist/server/session-http.js.map +1 -1
  140. package/dist/server/tenancy.js.map +1 -1
  141. package/dist/surfaces.d.ts +153 -0
  142. package/dist/surfaces.js +228 -0
  143. package/dist/surfaces.js.map +1 -0
  144. package/dist/testing/index.js.map +1 -1
  145. package/docs/CONNECTIONS.md +151 -0
  146. package/docs/EXECUTION.md +271 -0
  147. package/docs/GUARANTEES.md +54 -2
  148. package/docs/INVOCATIONS.md +170 -0
  149. package/docs/README.md +5 -2
  150. package/package.json +19 -15
  151. package/skills/.claude-plugin/marketplace.json +1 -1
  152. package/skills/.claude-plugin/plugin.json +1 -1
  153. package/skills/feltkit-services/SKILL.md +1 -1
  154. package/dist/dashboard/assets/index-BehzsQOa.css +0 -1
  155. package/dist/dashboard/assets/index-UuZ63NA6.js +0 -15
@@ -0,0 +1,313 @@
1
+ import type { Principal } from "./authority.js";
2
+ import { type AfterCommit } from "./outbox.js";
3
+ import type { FeltKitRuntime } from "./runtime.js";
4
+ import { type InvocationState, type NormalizedInvocation, type SurfaceDefinition } from "../surfaces.js";
5
+ import { EXECUTION_CONTRACT, type ExecutionAuthority, type ExecutionRequest, type ExecutionRequirements, type PlacementConstraints, type PlacementDecision } from "../execution.js";
6
+ import type { ExecutorProof } from "./authboundry.js";
7
+ export declare const INVOCATIONS_COLLECTION = "_feltkit_invocations";
8
+ export declare const DEFAULT_LEASE_MS: number;
9
+ export declare const MAX_REDISPATCH = 3;
10
+ type Json = null | boolean | number | string | Json[] | {
11
+ [k: string]: Json;
12
+ };
13
+ export interface InvocationRecord {
14
+ id: string;
15
+ person: string;
16
+ tenantId?: string;
17
+ surface: string;
18
+ deliveredBy: {
19
+ id: string;
20
+ type: string;
21
+ };
22
+ invocation: Omit<NormalizedInvocation, "digest">;
23
+ digest: string;
24
+ state: InvocationState;
25
+ history: Array<{
26
+ state: InvocationState;
27
+ at: number;
28
+ by: string;
29
+ note?: string;
30
+ }>;
31
+ /** How the current execution was handed to its environment: always one after-commit outbox effect (and its re-dispatches). */
32
+ dispatch: {
33
+ environment: string;
34
+ job: string;
35
+ outboxIds: string[];
36
+ redispatches: number;
37
+ state: "pending" | "dispatched" | "failed";
38
+ jobId?: string;
39
+ };
40
+ /** The live claim (fencing): which attempt holds it, until when. */
41
+ execution: {
42
+ claim: string | null;
43
+ claimedAt: number | null;
44
+ leaseMs: number;
45
+ attempts: number;
46
+ attempt: string | null;
47
+ };
48
+ /** Each placed execution of this invocation, with its placement decision and attempts (src/execution.ts). One today. */
49
+ executions: ExecutionEntry[];
50
+ outcome: {
51
+ result?: Json;
52
+ error?: {
53
+ code: string;
54
+ message: string;
55
+ };
56
+ } | null;
57
+ createdAt: number;
58
+ updatedAt: number;
59
+ }
60
+ /** One try at an execution: which environment and worker claimed it, what it reported, how it ended. */
61
+ export interface AttemptRecord {
62
+ id: string;
63
+ number: number;
64
+ environment: string;
65
+ /** Who actually ran it: the worker's identity, how it reached the control plane, its run. */
66
+ worker: {
67
+ id: string;
68
+ via: string;
69
+ run: string | null;
70
+ };
71
+ principal: string;
72
+ claimedAt: number;
73
+ endedAt: number | null;
74
+ /**
75
+ * running; succeeded / failed / awaiting_approval / cancelled as reported; `unknown` when the attempt
76
+ * lost its claim without reporting (its effects may or may not have happened) or reported an
77
+ * ambiguous external outcome. Never reported as success.
78
+ */
79
+ outcome: "running" | "succeeded" | "failed" | "awaiting_approval" | "cancelled" | "unknown";
80
+ error?: {
81
+ code: string;
82
+ message: string;
83
+ };
84
+ result?: Json;
85
+ /**
86
+ * Who executed, as AuthBoundry established it across this attempt's decisions: proven only when
87
+ * every decision proved the same agent by its credential; otherwise asserted. Null before any decision.
88
+ */
89
+ executor?: ExecutorProof | null;
90
+ /**
91
+ * The AuthBoundry decisions made while this attempt ran, as they were answered (decision and
92
+ * delegation ids, outcome, the executor's proof). Recorded when made, never reconstructed from
93
+ * current permissions or delegations. Bounded (the last 100). No secret.
94
+ */
95
+ decisions?: Array<{
96
+ at: number;
97
+ capability: string;
98
+ onBehalfOf: string | null;
99
+ outcome: string;
100
+ decisionId: string | null;
101
+ delegationId: string | null;
102
+ executor: ExecutorProof;
103
+ }>;
104
+ /** What only the claimant says: its environment and worker, until remote workers authenticate (M4). */
105
+ attribution?: {
106
+ environment: "asserted";
107
+ worker: "asserted";
108
+ };
109
+ /** Bounded (the last 50). */
110
+ evidence: Array<{
111
+ at: number;
112
+ type: "claimed" | "progress" | "succeeded" | "failed" | "awaiting_approval" | "cancelled" | "abandoned";
113
+ note?: string;
114
+ data?: Json;
115
+ }>;
116
+ }
117
+ /** One placed execution: the request the environment received, why it was placed there, and its attempts. */
118
+ export interface ExecutionEntry {
119
+ id: string;
120
+ contract: typeof EXECUTION_CONTRACT;
121
+ request: Pick<ExecutionRequest, "work" | "input" | "authority" | "requirements" | "placement">;
122
+ placement: PlacementDecision;
123
+ environment: string;
124
+ adapter: {
125
+ id: string;
126
+ version: string;
127
+ };
128
+ dispatchedAt: number;
129
+ /** This execution's own dispatch evidence (its outbox effects, re-dispatches included): never rewritten by a later execution. */
130
+ dispatch: {
131
+ job: string;
132
+ outboxIds: string[];
133
+ };
134
+ attempts: AttemptRecord[];
135
+ }
136
+ /** What callers see: everything but the claim token (holding it is what lets a worker move the invocation). */
137
+ export type InvocationView = Omit<InvocationRecord, "execution"> & {
138
+ execution: {
139
+ claimed: boolean;
140
+ claimedAt: number | null;
141
+ leaseMs: number;
142
+ attempts: number;
143
+ attempt: string | null;
144
+ };
145
+ };
146
+ export interface Receipt {
147
+ id: string;
148
+ invocationId: string;
149
+ surface: string;
150
+ state: InvocationState;
151
+ replayed: boolean;
152
+ receivedAt: number;
153
+ }
154
+ export interface RecoveryReport {
155
+ dispatchPending: string[];
156
+ dispatched: string[];
157
+ redispatched: string[];
158
+ failed: string[];
159
+ stalled: string[];
160
+ }
161
+ /** The record id: one per (person, surface, invocationId), so a duplicate submission is the same record. */
162
+ export declare function invocationRecordId(person: string, surface: string, invocationId: string): string;
163
+ export declare function view(record: InvocationRecord): InvocationView;
164
+ /** The execution id: the invocation's n-th execution (stable: a retry of an attempt is not a new execution). */
165
+ export declare function executionId(invocation: string, n: number): string;
166
+ /** The default execution of work `job` on the managed environment, as `accept` places it without constraints (tests recreating durable state use it). */
167
+ export declare function defaultExecution(input: {
168
+ invocation: string;
169
+ job: string;
170
+ outboxId?: string;
171
+ payload?: Record<string, unknown>;
172
+ authority: ExecutionAuthority;
173
+ at: number;
174
+ }): ExecutionEntry;
175
+ /** The record `accept` stages (exported for tests that recreate a crashed process's durable state). */
176
+ export declare function newInvocationRecord(input: {
177
+ id: string;
178
+ person: string;
179
+ tenantId?: string;
180
+ surface: SurfaceDefinition;
181
+ deliveredBy: Principal;
182
+ normalized: NormalizedInvocation;
183
+ job: string;
184
+ outboxId: string;
185
+ now: number;
186
+ execution?: ExecutionEntry;
187
+ }): InvocationRecord;
188
+ export declare class InvocationStore {
189
+ #private;
190
+ constructor(runtime: FeltKitRuntime);
191
+ /**
192
+ * Accept an invocation from a registered surface, inside the caller's mutation: the record and its
193
+ * dispatch job commit together (see the module comment). `person`: for a bridge surface, the person
194
+ * the application resolved; for a session surface, the caller (and nobody else).
195
+ */
196
+ accept(c: {
197
+ principal: Principal | null;
198
+ stage: (record: InvocationRecord) => void;
199
+ staged: () => ReadonlyArray<string>;
200
+ effects: AfterCommit | null;
201
+ }, input: {
202
+ surface: string;
203
+ envelope: unknown;
204
+ person?: string;
205
+ dispatch: {
206
+ job: string;
207
+ payload?: Record<string, unknown>;
208
+ requirements?: Partial<ExecutionRequirements>;
209
+ placement?: PlacementConstraints;
210
+ };
211
+ }): Promise<Receipt>;
212
+ get(principal: Principal | null, id: string): Promise<InvocationView>;
213
+ /** The caller's invocations (as the person they are for, or as the principal that delivered them), newest first. */
214
+ list(principal: Principal | null, filter?: {
215
+ state?: InvocationState;
216
+ surface?: string;
217
+ limit?: number;
218
+ }): Promise<InvocationView[]>;
219
+ /**
220
+ * Claim execution (the dispatched work's first step) as a new attempt, recording the environment and
221
+ * worker that run it. `proceed: false` when there is nothing to run: it was cancelled or finished, it
222
+ * waits for approval, or another attempt holds a live claim. A claimant from another environment than
223
+ * the one the execution was placed in is refused. Reclaiming after an expired lease marks the
224
+ * abandoned attempt `unknown` (it may have partly happened): `previous` tells the new attempt.
225
+ */
226
+ start(principal: Principal | null, id: string, options?: {
227
+ leaseMs?: number;
228
+ environment?: string;
229
+ worker?: string;
230
+ }, origin?: {
231
+ via: string;
232
+ requestId: string | null;
233
+ }): Promise<{
234
+ proceed: boolean;
235
+ claim?: string;
236
+ attempt?: number;
237
+ attemptId?: string;
238
+ execution?: string;
239
+ environment?: string;
240
+ previous?: Array<{
241
+ attempt: string;
242
+ outcome: AttemptRecord["outcome"];
243
+ }>;
244
+ state: InvocationState;
245
+ reason?: string;
246
+ }>;
247
+ /**
248
+ * Record an AuthBoundry decision made in request `requestId` on the attempt that request claimed (if
249
+ * any, and while that attempt is still the running one). Called by the runtime for every decision.
250
+ */
251
+ noteDecision(requestId: string, d: {
252
+ capability: string;
253
+ onBehalfOf: string | null;
254
+ outcome: string;
255
+ decisionId: string | null;
256
+ delegationId: string | null;
257
+ executor: ExecutorProof;
258
+ }): Promise<void>;
259
+ /**
260
+ * Report progress on the attempt that holds the claim: evidence on the attempt, and the lease renewed
261
+ * (a heartbeat). A worker that lost its claim reports nothing (CLAIM_LOST).
262
+ */
263
+ progress(principal: Principal | null, id: string, options: {
264
+ claim: string;
265
+ note?: string;
266
+ data?: Json;
267
+ }): Promise<{
268
+ leaseUntil: number;
269
+ }>;
270
+ /** After approval: awaiting_approval → running, with a new claim. */
271
+ resume(principal: Principal | null, id: string, options?: {
272
+ leaseMs?: number;
273
+ environment?: string;
274
+ worker?: string;
275
+ }, origin?: {
276
+ via: string;
277
+ requestId: string | null;
278
+ }): Promise<{
279
+ proceed: boolean;
280
+ claim?: string;
281
+ attemptId?: string;
282
+ state: InvocationState;
283
+ reason?: string;
284
+ }>;
285
+ /**
286
+ * Move a running invocation on: to awaiting_approval, completed or failed. From running it needs the
287
+ * current claim; from awaiting_approval (no claim is held) the person or the deliverer may settle it.
288
+ */
289
+ transition(principal: Principal | null, id: string, to: "awaiting_approval" | "completed" | "failed", options?: {
290
+ claim?: string;
291
+ note?: string;
292
+ result?: Json;
293
+ error?: {
294
+ code: string;
295
+ message: string;
296
+ };
297
+ }): Promise<InvocationView>;
298
+ /** The person cancels their own invocation. A terminal invocation is final: cancelling one that already ended is refused (or a no-op if it was cancelled). */
299
+ cancel(principal: Principal | null, id: string, options?: {
300
+ reason?: string;
301
+ }): Promise<InvocationView>;
302
+ /**
303
+ * The recovery sweep (the services worker): see the module comment. Returns what it found; records
304
+ * an `invocation.recovery` activity event whenever it found anything.
305
+ */
306
+ recover(now?: number): Promise<RecoveryReport>;
307
+ /** The registry's view: each surface as declared, and when a delivery last arrived through it (its availability, separate from any invocation's health). */
308
+ surfaces(): Promise<Array<SurfaceDefinition & {
309
+ lastDeliveryAt: number | null;
310
+ adapterVersions: string[];
311
+ }>>;
312
+ }
313
+ export {};