@feltdb/feltkit 0.3.29 → 0.3.31

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 (185) hide show
  1. package/dist/app.d.ts +101 -11
  2. package/dist/app.js +131 -3
  3. package/dist/app.js.map +1 -1
  4. package/dist/appboundry/build.js +2 -0
  5. package/dist/appboundry/build.js.map +1 -1
  6. package/dist/appboundry/guest-tenancy.d.ts +2 -2
  7. package/dist/appboundry/guest-tenancy.js.map +1 -1
  8. package/dist/appboundry/guest.js +27 -2
  9. package/dist/appboundry/guest.js.map +1 -1
  10. package/dist/appboundry/host.js +3 -0
  11. package/dist/appboundry/host.js.map +1 -1
  12. package/dist/authorize.d.ts +47 -4
  13. package/dist/authorize.js +37 -0
  14. package/dist/authorize.js.map +1 -1
  15. package/dist/cli/deploy-appboundry.d.ts +1 -1
  16. package/dist/cli/deploy-appboundry.js.map +1 -1
  17. package/dist/cli/deploy.js.map +1 -1
  18. package/dist/cli/main.js +27 -1
  19. package/dist/cli/main.js.map +1 -1
  20. package/dist/cli/skills.js.map +1 -1
  21. package/dist/client/index.js.map +1 -1
  22. package/dist/dashboard/assets/index-9rMS3yBm.js +15 -0
  23. package/dist/dashboard/assets/index-DkiYTUMR.css +1 -0
  24. package/dist/dashboard/index.html +2 -2
  25. package/dist/docs.d.ts +1 -1
  26. package/dist/docs.js +4 -0
  27. package/dist/docs.js.map +1 -1
  28. package/dist/errors.js.map +1 -1
  29. package/dist/event-stage.js.map +1 -1
  30. package/dist/execution.d.ts +186 -0
  31. package/dist/execution.js +105 -0
  32. package/dist/execution.js.map +1 -0
  33. package/dist/index.d.ts +10 -2
  34. package/dist/index.js +5 -0
  35. package/dist/index.js.map +1 -1
  36. package/dist/measure/index.js.map +1 -1
  37. package/dist/platform/approvals.js.map +1 -1
  38. package/dist/platform/artifacts.js.map +1 -1
  39. package/dist/platform/changes.d.ts +54 -54
  40. package/dist/platform/changes.js.map +1 -1
  41. package/dist/platform/deployments.d.ts +32 -32
  42. package/dist/platform/exec.js.map +1 -1
  43. package/dist/platform/platform.js.map +1 -1
  44. package/dist/platform/releases.js.map +1 -1
  45. package/dist/platform/server.js.map +1 -1
  46. package/dist/platform/workspaces.js.map +1 -1
  47. package/dist/policy.d.ts +172 -0
  48. package/dist/policy.js +311 -0
  49. package/dist/policy.js.map +1 -0
  50. package/dist/react/auth.d.ts +10 -10
  51. package/dist/react/auth.js +1 -1
  52. package/dist/react/auth.js.map +1 -1
  53. package/dist/react/context.d.ts +1 -1
  54. package/dist/react/index.js.map +1 -1
  55. package/dist/runtime/accounts.js.map +1 -1
  56. package/dist/runtime/activity.d.ts +17 -1
  57. package/dist/runtime/activity.js.map +1 -1
  58. package/dist/runtime/agent.d.ts +3 -3
  59. package/dist/runtime/agent.js +9 -3
  60. package/dist/runtime/agent.js.map +1 -1
  61. package/dist/runtime/application-authority.d.ts +33 -3
  62. package/dist/runtime/application-authority.js +74 -14
  63. package/dist/runtime/application-authority.js.map +1 -1
  64. package/dist/runtime/assemble.d.ts +13 -0
  65. package/dist/runtime/assemble.js +29 -1
  66. package/dist/runtime/assemble.js.map +1 -1
  67. package/dist/runtime/audit.js.map +1 -1
  68. package/dist/runtime/authboundry.d.ts +17 -0
  69. package/dist/runtime/authboundry.js +8 -1
  70. package/dist/runtime/authboundry.js.map +1 -1
  71. package/dist/runtime/authority.d.ts +10 -0
  72. package/dist/runtime/authority.js +17 -0
  73. package/dist/runtime/authority.js.map +1 -1
  74. package/dist/runtime/backup-environment.js.map +1 -1
  75. package/dist/runtime/backup.js.map +1 -1
  76. package/dist/runtime/changes.js.map +1 -1
  77. package/dist/runtime/claims.js.map +1 -1
  78. package/dist/runtime/collections.js.map +1 -1
  79. package/dist/runtime/content.d.ts +77 -2
  80. package/dist/runtime/content.js +153 -6
  81. package/dist/runtime/content.js.map +1 -1
  82. package/dist/runtime/context.d.ts +207 -3
  83. package/dist/runtime/contract.js +16 -3
  84. package/dist/runtime/contract.js.map +1 -1
  85. package/dist/runtime/credentials.d.ts +31 -2
  86. package/dist/runtime/credentials.js +55 -3
  87. package/dist/runtime/credentials.js.map +1 -1
  88. package/dist/runtime/crypto-token.js.map +1 -1
  89. package/dist/runtime/data.d.ts +25 -0
  90. package/dist/runtime/data.js +92 -8
  91. package/dist/runtime/data.js.map +1 -1
  92. package/dist/runtime/decisions.js.map +1 -1
  93. package/dist/runtime/deployment.js.map +1 -1
  94. package/dist/runtime/execution-host.d.ts +54 -0
  95. package/dist/runtime/execution-host.js +54 -0
  96. package/dist/runtime/execution-host.js.map +1 -0
  97. package/dist/runtime/generation.js.map +1 -1
  98. package/dist/runtime/image-variants.d.ts +48 -0
  99. package/dist/runtime/image-variants.js +295 -0
  100. package/dist/runtime/image-variants.js.map +1 -0
  101. package/dist/runtime/instance.js.map +1 -1
  102. package/dist/runtime/integrations.d.ts +8 -6
  103. package/dist/runtime/integrations.js +46 -5
  104. package/dist/runtime/integrations.js.map +1 -1
  105. package/dist/runtime/invocations.d.ts +313 -0
  106. package/dist/runtime/invocations.js +493 -0
  107. package/dist/runtime/invocations.js.map +1 -0
  108. package/dist/runtime/live.d.ts +10 -7
  109. package/dist/runtime/live.js +24 -12
  110. package/dist/runtime/live.js.map +1 -1
  111. package/dist/runtime/loader.js.map +1 -1
  112. package/dist/runtime/local-authority.d.ts +92 -0
  113. package/dist/runtime/local-authority.js +396 -0
  114. package/dist/runtime/local-authority.js.map +1 -0
  115. package/dist/runtime/oauth-credentials.d.ts +40 -3
  116. package/dist/runtime/oauth-credentials.js +133 -25
  117. package/dist/runtime/oauth-credentials.js.map +1 -1
  118. package/dist/runtime/outbox.js +3 -0
  119. package/dist/runtime/outbox.js.map +1 -1
  120. package/dist/runtime/policies.d.ts +89 -0
  121. package/dist/runtime/policies.js +152 -0
  122. package/dist/runtime/policies.js.map +1 -0
  123. package/dist/runtime/projects.d.ts +1 -1
  124. package/dist/runtime/readiness.js +11 -0
  125. package/dist/runtime/readiness.js.map +1 -1
  126. package/dist/runtime/runtime.d.ts +66 -5
  127. package/dist/runtime/runtime.js +328 -18
  128. package/dist/runtime/runtime.js.map +1 -1
  129. package/dist/runtime/services-rules.d.ts +9 -0
  130. package/dist/runtime/services-rules.js +47 -1
  131. package/dist/runtime/services-rules.js.map +1 -1
  132. package/dist/runtime/services.d.ts +154 -9
  133. package/dist/runtime/services.js +343 -14
  134. package/dist/runtime/services.js.map +1 -1
  135. package/dist/runtime/sessions.js.map +1 -1
  136. package/dist/runtime/state-contract.js.map +1 -1
  137. package/dist/runtime/storage-check.js.map +1 -1
  138. package/dist/runtime/targets.d.ts +1 -1
  139. package/dist/runtime/tenancy.js.map +1 -1
  140. package/dist/runtime/transactions.d.ts +15 -0
  141. package/dist/runtime/transactions.js +5 -0
  142. package/dist/runtime/transactions.js.map +1 -1
  143. package/dist/schema.js.map +1 -1
  144. package/dist/server/admin.d.ts +72 -51
  145. package/dist/server/admin.js +125 -0
  146. package/dist/server/admin.js.map +1 -1
  147. package/dist/server/components.js.map +1 -1
  148. package/dist/server/index.js +72 -6
  149. package/dist/server/index.js.map +1 -1
  150. package/dist/server/management.js.map +1 -1
  151. package/dist/server/mcp.d.ts +59 -37
  152. package/dist/server/mcp.js +24 -1
  153. package/dist/server/mcp.js.map +1 -1
  154. package/dist/server/operators.d.ts +1 -0
  155. package/dist/server/operators.js +1 -1
  156. package/dist/server/operators.js.map +1 -1
  157. package/dist/server/ports.d.ts +7 -0
  158. package/dist/server/ports.js +17 -0
  159. package/dist/server/ports.js.map +1 -1
  160. package/dist/server/production.js.map +1 -1
  161. package/dist/server/project.js.map +1 -1
  162. package/dist/server/session-http.js.map +1 -1
  163. package/dist/server/tenancy.js.map +1 -1
  164. package/dist/surfaces.d.ts +153 -0
  165. package/dist/surfaces.js +228 -0
  166. package/dist/surfaces.js.map +1 -0
  167. package/dist/testing/index.d.ts +11 -0
  168. package/dist/testing/index.js +7 -0
  169. package/dist/testing/index.js.map +1 -1
  170. package/docs/AGENT-OPERATIONS.md +1 -1
  171. package/docs/ARCHITECTURE.md +2 -1
  172. package/docs/CONNECTIONS.md +151 -0
  173. package/docs/EXECUTION.md +271 -0
  174. package/docs/GUARANTEES.md +134 -8
  175. package/docs/INVOCATIONS.md +170 -0
  176. package/docs/POLICIES.md +121 -0
  177. package/docs/README.md +6 -2
  178. package/docs/SECURITY.md +30 -0
  179. package/docs/TRANSACTIONS.md +4 -0
  180. package/package.json +27 -19
  181. package/skills/.claude-plugin/marketplace.json +1 -1
  182. package/skills/.claude-plugin/plugin.json +1 -1
  183. package/skills/feltkit-services/SKILL.md +1 -1
  184. package/dist/dashboard/assets/index-BehzsQOa.css +0 -1
  185. package/dist/dashboard/assets/index-UuZ63NA6.js +0 -15
@@ -39,15 +39,61 @@ export interface FilesReader {
39
39
  * your function first: holding the link is enough to download until it expires. Default
40
40
  * 5 minutes, at most 1 hour. Node server only.
41
41
  */
42
- link(id: string, options?: {
43
- expiresInSeconds?: number;
44
- disposition?: "attachment" | "inline";
45
- }): Promise<FileLink>;
42
+ link(id: string, options?: FileLinkOptions): Promise<FileLink>;
43
+ }
44
+ export interface FileLinkOptions {
45
+ /** Default 300 (3600 with `cache`); at most 3600. With `cache`, at least 2. */
46
+ expiresInSeconds?: number;
47
+ disposition?: "attachment" | "inline";
48
+ /**
49
+ * A cacheable link. The same caller asking for the same file (same content, variant and
50
+ * disposition) gets the same URL for half of `expiresInSeconds` (`stableUntil`), and the
51
+ * response is `Cache-Control: private, max-age=<seconds until expiresAt>, immutable` with an
52
+ * ETag, so a browser downloads it once. The tradeoff: a copy a browser already holds stays
53
+ * usable until `expiresAt` (at most `expiresInSeconds`, ≤ 1 h) even if the file is removed or
54
+ * the caller loses access; new downloads through the link stop at once. Default false
55
+ * (`private, no-store`, a new URL every call).
56
+ */
57
+ cache?: boolean;
58
+ /** A declared image variant (`services.files.variants`), served instead of the original. */
59
+ variant?: string;
46
60
  }
47
61
  /** A capability URL for one file transfer. `url` is relative to the application's origin. */
48
62
  export interface FileLink {
49
63
  url: string;
50
64
  expiresAt: string;
65
+ /** `cache: true`: until when the same request returns this same URL (then a new one, valid until its own `expiresAt`). */
66
+ stableUntil?: string;
67
+ /** `variant`: what the link serves. */
68
+ variant?: FileVariantInfo;
69
+ }
70
+ /**
71
+ * A variant as a link sees it.
72
+ * ready derived and stored: the link serves it (width, height, contentType)
73
+ * pending not derived yet: the first download derives it (or serves the original, saying why)
74
+ * original it cannot be derived from this file (reason): the link serves the original
75
+ * The download says what it served in `X-FeltKit-Variant` (the name, or `original`) and, for the
76
+ * original, `X-FeltKit-Variant-Reason`.
77
+ */
78
+ export interface FileVariantInfo {
79
+ name: string;
80
+ status: "ready" | "pending" | "original";
81
+ reason?: string;
82
+ width?: number;
83
+ height?: number;
84
+ contentType?: string;
85
+ }
86
+ /** One image variant: the largest box it fits in (`inside`, default) or fills and crops to (`cover`). Never larger than the original. */
87
+ export interface FileVariantSpec {
88
+ /** Pixels, 1-4096. */
89
+ width: number;
90
+ /** Pixels, 1-4096. Required with `fit: "cover"`. */
91
+ height?: number;
92
+ fit?: "inside" | "cover";
93
+ /** auto (default): PNG when the result has transparency, else JPEG. */
94
+ format?: "auto" | "jpeg" | "png";
95
+ /** JPEG quality, 1-100. Default 80. */
96
+ quality?: number;
51
97
  }
52
98
  export interface FilesWriter extends FilesReader {
53
99
  upload(input: UploadInput): Promise<FileInfo>;
@@ -96,11 +142,49 @@ export interface NotificationsReader {
96
142
  type?: string;
97
143
  }): Promise<NotificationInfo[]>;
98
144
  get(id: string): Promise<NotificationInfo>;
145
+ /**
146
+ * The caller's inbox, one bounded page at a time (FRAME-GAP-08): newest first (`createdAt`
147
+ * descending, then `id` ascending), read from the recipient's timeline index, never the whole
148
+ * history. `limit` 1-100 (default 50). Pass `nextCursor` back, with the same `unread`, `type`
149
+ * and `limit`, for the next page; a cursor from another recipient, filter or limit is refused
150
+ * (INVALID_ARGUMENT). With `unread`, a page may hold fewer than `limit` items, even none, and
151
+ * still have a `nextCursor`: only a page without one is the end.
152
+ */
153
+ page(options?: NotificationPageOptions): Promise<NotificationPage>;
154
+ /** How many of the caller's notifications are unread, up to `max` (1-500, default 100). `complete: false`: at least `count` ("99+"). */
155
+ unreadCount(options?: {
156
+ type?: string;
157
+ max?: number;
158
+ }): Promise<{
159
+ count: number;
160
+ complete: boolean;
161
+ }>;
162
+ }
163
+ export interface NotificationPageOptions {
164
+ unread?: boolean;
165
+ type?: string;
166
+ limit?: number;
167
+ cursor?: string;
168
+ }
169
+ export interface NotificationPage {
170
+ items: NotificationInfo[];
171
+ nextCursor?: string;
99
172
  }
100
173
  export interface NotificationsWriter extends NotificationsReader {
101
174
  send(input: SendNotificationInput): Promise<NotificationInfo>;
102
175
  markRead(id: string): Promise<NotificationInfo>;
103
176
  dismiss(id: string): Promise<NotificationInfo>;
177
+ /**
178
+ * Mark the caller's unread notifications read (of `type`, if given), at most 1,000 per call, each
179
+ * as `markRead` does (version-checked, audited). `complete: false`: more remain, call again. Not
180
+ * atomic across notifications.
181
+ */
182
+ markAllRead(options?: {
183
+ type?: string;
184
+ }): Promise<{
185
+ marked: number;
186
+ complete: boolean;
187
+ }>;
104
188
  }
105
189
  /** Variables for the current environment. Secrets (credential references) are not offered. */
106
190
  export interface ConfigurationReader {
@@ -137,8 +221,16 @@ export interface BoundServices {
137
221
  webhooks?: WebhooksWriter;
138
222
  }
139
223
  export interface ServicesConfig {
224
+ /**
225
+ * `variants`: image renditions a link may ask for (`files.link(id, { variant })`), by name, e.g.
226
+ * `{ w640: { width: 640 }, avatar64: { width: 64, height: 64, fit: "cover" } }`. Derived once per
227
+ * file and variant from JPEG and PNG originals, kept with the original's bytes and removed with
228
+ * them. `maxVariantPixels` (default 24,000,000): larger images are served as the original.
229
+ */
140
230
  files?: boolean | {
141
231
  maxBytes?: number;
232
+ variants?: Record<string, FileVariantSpec>;
233
+ maxVariantPixels?: number;
142
234
  };
143
235
  /** `types`: the notification types this application sends, offered in Studio. */
144
236
  notifications?: boolean | {
@@ -210,6 +302,26 @@ export interface ServiceStatus {
210
302
  page?: string;
211
303
  }
212
304
  export declare const CONFIGURATION_ENVIRONMENT: Record<string, "development" | "staging" | "production">;
305
+ /** What `GET /api/files/<token>` serves. */
306
+ export interface DownloadedFile {
307
+ file: FileInfo;
308
+ bytes: Uint8Array;
309
+ disposition: "attachment" | "inline";
310
+ /** Of the bytes served (a variant's own type). */
311
+ contentType?: string;
312
+ /** For Content-Disposition (a variant's name says which). */
313
+ filename: string;
314
+ /** A strong ETag: the SHA-256 of the bytes served. */
315
+ etag: string;
316
+ /** A cacheable link: seconds until it expires (the response's max-age). null: not cacheable (no-store). */
317
+ maxAgeSeconds: number | null;
318
+ /** A variant link: whether the variant was served, or the original and why. */
319
+ variant?: {
320
+ name: string;
321
+ served: "variant" | "original";
322
+ reason?: string;
323
+ };
324
+ }
213
325
  /** One pass of the services worker (FeltKitRuntime.runServices). */
214
326
  export interface ServiceTick {
215
327
  /** Job attempts made. */
@@ -248,6 +360,8 @@ export declare class ServicesHost {
248
360
  constructor(options: {
249
361
  servicesDb: StateFirstDB;
250
362
  contentDb: StateFirstDB;
363
+ /** The handle that holds the after-commit outbox; `files.remove` needs it (a removal records its byte release there). */
364
+ outboxDb?: StateFirstDB;
251
365
  applicationId: string;
252
366
  authority: Authority;
253
367
  config: ServicesConfig;
@@ -430,11 +544,7 @@ export declare class ServicesHost {
430
544
  * `GET /api/files/<token>`: the file a download link names. The link is the authority (the
431
545
  * function that issued it authorized the reader); the file must still exist and verify.
432
546
  */
433
- redeemDownload(token: string): Promise<{
434
- file: FileInfo;
435
- bytes: Uint8Array;
436
- disposition: "attachment" | "inline";
437
- }>;
547
+ redeemDownload(token: string): Promise<DownloadedFile>;
438
548
  /**
439
549
  * `PUT /api/files/<token>`: create the file an upload link allows, as the principal who created
440
550
  * the link, with the link's metadata. The link is consumed first, so it works once.
@@ -443,6 +553,39 @@ export declare class ServicesHost {
443
553
  name?: string;
444
554
  contentType?: string;
445
555
  }): Promise<FileInfo>;
556
+ /**
557
+ * Perform a recorded byte release (outbox effect `files.release`): claimed under the outbox's
558
+ * version check, so two performers never both hold it, and settled done or failed with evidence.
559
+ * Called by `files.remove`, by the outbox's recovery after a stop, and by an operator's retry.
560
+ *
561
+ * the file's record is still live failed: "not deleted"; the bytes are kept
562
+ * another live record uses the bytes done: { released: false, retained: true, referencedBy }
563
+ * otherwise the bytes are removed: done { released: true }, or
564
+ * { released: false } when they were already gone
565
+ * anything fails failed, with the error (an operator retries it)
566
+ *
567
+ * It reads as FeltKit's `file-release` principal (files.read only), never as the caller: the
568
+ * caller's files.delete was decided when the metadata was deleted, and nothing here can widen it.
569
+ */
570
+ releaseFile(id: string, now?: () => number): Promise<"done" | "failed" | "retrying" | "skipped">;
571
+ /**
572
+ * Stored bytes no live file record references: left by a removal before byte releases were
573
+ * recorded, by a delete through Services' management API (which removes metadata only), or by an
574
+ * upload that stopped between storing its bytes and recording its file. Bytes stored less than
575
+ * `graceMs` ago are excluded (an upload in flight has no record yet); rows from before `storedAt`
576
+ * was kept are treated as old.
577
+ */
578
+ orphanedContent(graceMs?: number, now?: number): Promise<Array<{
579
+ storageKey: string;
580
+ storedAt?: number;
581
+ size: number;
582
+ }>>;
583
+ /**
584
+ * An operator's reclaim of orphaned bytes: each is a recorded byte release (outbox effect
585
+ * `files.release`, no file), performed through the same checks as a removal's (nothing a live
586
+ * record references is released), and kept as evidence. Returns the outbox ids.
587
+ */
588
+ reclaimOrphanedContent(by: string, graceMs?: number): Promise<string[]>;
446
589
  /** Allow `principal` to cause service effects while request `requestId` runs. */
447
590
  enter(requestId: string, principal: Principal | null): () => void;
448
591
  /** The `ctx.services` object for one invocation. `reads` collects collections read, for reactivity. */
@@ -463,6 +606,8 @@ export declare class ServicesHost {
463
606
  */
464
607
  status(connected: boolean): Promise<ServiceStatus[]>;
465
608
  }
609
+ /** Bytes younger than this are not orphans: an upload stores its bytes before it records its file. */
610
+ export declare const ORPHAN_GRACE_MS: number;
466
611
  /**
467
612
  * `ctx.services` for one function call, with service denials explained in the caller's
468
613
  * terms. Service calls inside a function run as the function's caller, so a role that may