streamby-core 0.39.0 → 0.40.0

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 (52) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/LICENSE +661 -661
  3. package/README.md +680 -573
  4. package/dist/adapters/database/connectionManager.js +179 -124
  5. package/dist/adapters/database/sql.js +1 -1
  6. package/dist/mcp/tools.js +41 -0
  7. package/dist/middleware/createRouter.js +11 -1
  8. package/dist/middleware/routes/ai.js +3 -3
  9. package/dist/middleware/routes/deliverable.d.ts +4 -2
  10. package/dist/middleware/routes/deliverable.js +16 -7
  11. package/dist/middleware/routes/media.js +7 -6
  12. package/dist/middleware/routes/project.js +5 -1
  13. package/dist/middleware/routes/renderFarm.js +4 -77
  14. package/dist/middleware/routes/storage.js +13 -27
  15. package/dist/middleware/routes/worker.d.ts +7 -0
  16. package/dist/middleware/routes/worker.js +125 -0
  17. package/dist/middleware/routes/workerCallback.d.ts +5 -0
  18. package/dist/middleware/routes/workerCallback.js +31 -0
  19. package/dist/models/Model.js +9 -9
  20. package/dist/services/aiProcessor.js +11 -11
  21. package/dist/services/apiTokenPermissions.js +6 -5
  22. package/dist/services/executor.js +10 -10
  23. package/dist/services/jobQueue.d.ts +6 -4
  24. package/dist/services/jobQueue.js +28 -16
  25. package/dist/services/jobStore.d.ts +27 -0
  26. package/dist/services/jobStore.js +177 -0
  27. package/dist/services/mediaProcessor.js +16 -16
  28. package/dist/services/vfxProcessor.js +12 -12
  29. package/dist/services/workerJobs.d.ts +73 -0
  30. package/dist/services/workerJobs.js +459 -0
  31. package/dist/services/workers.d.ts +78 -0
  32. package/dist/services/workers.js +179 -0
  33. package/dist/types/index.d.ts +52 -2
  34. package/dist/utils/assetCategories.d.ts +4 -0
  35. package/dist/utils/assetCategories.js +21 -0
  36. package/dist/utils/builtinAccess.d.ts +1 -1
  37. package/dist/utils/builtinAccess.js +4 -3
  38. package/dist/utils/privateAddress.d.ts +10 -0
  39. package/dist/utils/privateAddress.js +85 -0
  40. package/package.json +1 -1
  41. package/dist/middleware/routes/apiConnection.d.ts +0 -3
  42. package/dist/middleware/routes/apiConnection.js +0 -100
  43. package/dist/middleware/routes/credential.d.ts +0 -3
  44. package/dist/middleware/routes/credential.js +0 -80
  45. package/dist/services/apiConnection.d.ts +0 -18
  46. package/dist/services/apiConnection.js +0 -65
  47. package/dist/services/credential.d.ts +0 -8
  48. package/dist/services/credential.js +0 -70
  49. package/dist/services/pipeline.d.ts +0 -2
  50. package/dist/services/pipeline.js +0 -292
  51. package/dist/utils/crypto.d.ts +0 -3
  52. package/dist/utils/crypto.js +0 -32
package/CHANGELOG.md CHANGED
@@ -1,5 +1,57 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.40.0
4
+
5
+ ### ⚠️ Breaking changes
6
+
7
+ - **A project's render farm connections are its workers.** `GET`, `POST` and
8
+ `DELETE /projects/:projectId/render-farm-connections` are now
9
+ `/projects/:projectId/workers`, which takes `{ name, provider?, endpoint, credential?, kinds,
10
+ categories, autoKind?, timeoutSeconds?, description? }`. They're still kept in the project's
11
+ `renderFarmConnections` list.
12
+ - **Jobs are kept in the main database** (a new `jobs` table, created at startup, or collection),
13
+ not in memory: they survive restarts and every instance sees them. `GET /jobs/:jobId` answers
14
+ from there.
15
+ - `canUseBuiltin` may be called with kind `'worker'`.
16
+
17
+ ### Added
18
+
19
+ - **Processing workers**: StreamBy sends jobs to external workers (the host's, in the router
20
+ config's `workers`; or a project's own) and keeps what they make, as a new asset derived from
21
+ the original or as the asset's new version, with the worker's report. The README documents the
22
+ contract a worker follows.
23
+ - `POST /projects/:projectId/jobs/process` asks for one; `GET /projects/:projectId/jobs` lists
24
+ a project's jobs; `POST /projects/:projectId/jobs/:jobId/retry` sends a failed one again.
25
+ - Workers call back to `/worker-jobs/:jobId/{progress,upload-url,complete,fail}` with a token
26
+ of that job's attempt alone.
27
+ - A job not taken, or not finished in time, is sent again (up to `workerOptions.maxAttempts`);
28
+ every instance looks for them (`workerOptions.sweepIntervalMs`), and only one sends each.
29
+ - A worker with an `autoKind` runs by itself on an asset of its categories marked as a
30
+ deliverable, unless it's marked with an API token without `jobs:run`.
31
+ - **Behind a proxy that ends TLS, set `workerOptions.callbackBaseUrl`** to the router's public
32
+ https URL: without it, the callback URL is made from the request (`req.protocol`), and comes
33
+ out as `http://`.
34
+ - A project's worker is reached only over https and never at a local, private, shared,
35
+ benchmarking, multicast or reserved address: neither as its endpoint is written nor as its
36
+ name resolves, checked when it's connected and again right before each job is sent. A job
37
+ for one that resolves to such an address fails for good. `workerOptions.allowLocalEndpoints`
38
+ lifts that, for development. Its credential is used only while whoever connected it is
39
+ still in the project.
40
+ - A worker's answer to a job it doesn't take is logged, not shown: the job says "The worker
41
+ refused the job".
42
+ - A job is sent as whoever asked for it, with the platform role they had then (a host's
43
+ `canUseBuiltin` decides on sending it as on asking for it).
44
+ - MCP tools `list_workers`, `process_asset`, `list_jobs` and `retry_job`.
45
+ - Deleting a project deletes its jobs.
46
+ - Job events (`jobEvent`) carry the job's `projectId` and `status`.
47
+
48
+ ### Fixed
49
+
50
+ - **Instances starting together don't deadlock on StreamBy's tables.** The statements that make
51
+ them (or bring them up to date) at startup run one instance at a time, in a transaction that
52
+ holds a transaction-level advisory lock (so it works behind a pooler in transaction mode, such
53
+ as Supabase's).
54
+
3
55
  ## 0.39.0
4
56
 
5
57
  ### Added