streamby-core 0.39.0 → 0.41.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 (63) hide show
  1. package/CHANGELOG.md +84 -0
  2. package/LICENSE +661 -661
  3. package/README.md +785 -573
  4. package/dist/adapters/database/connectionManager.js +182 -124
  5. package/dist/adapters/database/sql.js +1 -1
  6. package/dist/index.d.ts +3 -1
  7. package/dist/index.js +9 -1
  8. package/dist/mcp/audit.d.ts +5 -2
  9. package/dist/mcp/audit.js +8 -0
  10. package/dist/mcp/server.js +3 -3
  11. package/dist/mcp/tools.js +41 -0
  12. package/dist/middleware/createRouter.js +14 -1
  13. package/dist/middleware/routes/ai.js +3 -3
  14. package/dist/middleware/routes/deliverable.d.ts +4 -2
  15. package/dist/middleware/routes/deliverable.js +16 -7
  16. package/dist/middleware/routes/mcp.js +11 -4
  17. package/dist/middleware/routes/media.js +7 -6
  18. package/dist/middleware/routes/{apiConnection.d.ts → oauthResource.d.ts} +1 -1
  19. package/dist/middleware/routes/oauthResource.js +18 -0
  20. package/dist/middleware/routes/project.js +5 -1
  21. package/dist/middleware/routes/renderFarm.js +4 -77
  22. package/dist/middleware/routes/storage.js +13 -27
  23. package/dist/middleware/routes/worker.d.ts +7 -0
  24. package/dist/middleware/routes/worker.js +125 -0
  25. package/dist/middleware/routes/workerCallback.d.ts +5 -0
  26. package/dist/middleware/routes/workerCallback.js +31 -0
  27. package/dist/models/Model.js +9 -9
  28. package/dist/services/aiProcessor.js +11 -11
  29. package/dist/services/apiTokenPermissions.js +6 -5
  30. package/dist/services/auth.d.ts +2 -0
  31. package/dist/services/auth.js +36 -10
  32. package/dist/services/executor.js +10 -10
  33. package/dist/services/jobQueue.d.ts +6 -4
  34. package/dist/services/jobQueue.js +28 -16
  35. package/dist/services/jobStore.d.ts +27 -0
  36. package/dist/services/jobStore.js +177 -0
  37. package/dist/services/mediaProcessor.js +16 -16
  38. package/dist/services/oauthTokens.d.ts +60 -0
  39. package/dist/services/oauthTokens.js +164 -0
  40. package/dist/services/vfxProcessor.js +12 -12
  41. package/dist/services/workerJobs.d.ts +73 -0
  42. package/dist/services/workerJobs.js +459 -0
  43. package/dist/services/workers.d.ts +78 -0
  44. package/dist/services/workers.js +179 -0
  45. package/dist/types/index.d.ts +64 -2
  46. package/dist/utils/assetCategories.d.ts +4 -0
  47. package/dist/utils/assetCategories.js +21 -0
  48. package/dist/utils/builtinAccess.d.ts +1 -1
  49. package/dist/utils/builtinAccess.js +4 -3
  50. package/dist/utils/privateAddress.d.ts +10 -0
  51. package/dist/utils/privateAddress.js +85 -0
  52. package/package.json +1 -1
  53. package/dist/middleware/routes/apiConnection.js +0 -100
  54. package/dist/middleware/routes/credential.d.ts +0 -3
  55. package/dist/middleware/routes/credential.js +0 -80
  56. package/dist/services/apiConnection.d.ts +0 -18
  57. package/dist/services/apiConnection.js +0 -65
  58. package/dist/services/credential.d.ts +0 -8
  59. package/dist/services/credential.js +0 -70
  60. package/dist/services/pipeline.d.ts +0 -2
  61. package/dist/services/pipeline.js +0 -292
  62. package/dist/utils/crypto.d.ts +0 -3
  63. package/dist/utils/crypto.js +0 -32
package/CHANGELOG.md CHANGED
@@ -1,5 +1,89 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.41.0
4
+
5
+ ### Added
6
+
7
+ - **OAuth access tokens**: apps the user signs in to with their account (claude.ai's
8
+ connector) work with StreamBy and its MCP server, as a protected resource (RFC 9728). The
9
+ README documents the setup, and how to add the connector in claude.ai.
10
+ - `createOAuthTokenVerifier({ issuer, audiences, jwks })` checks a token with the
11
+ authorization server's keys (RS256, from its JWKS URL or a function), its issuer, its
12
+ audience (one of StreamBy's resources, RFC 8707) and its expiry. The host's `authProvider`
13
+ returns its user with `apiToken: verified.scope` and `oauth: { clientId, clientName? }`.
14
+ - Scopes map to permissions: `streamby:read` to every `:read` one, `streamby:write` to those
15
+ and making and changing; none to deleting nor managing members (`OAUTH_SCOPE_PERMISSIONS`,
16
+ `permissionsForOAuthScopes`). The user's role in each project still applies.
17
+ - An app deletes nothing: its `DELETE` requests answer 403 whatever their route's permission
18
+ (`project:update`, `workflow:write` and `exports:write` reach some that delete), but taking
19
+ a deliverable's mark off. API tokens are unchanged.
20
+ - The router's `oauth` config (`{ issuer, resource, resourceMetadataUrl?, resourceName? }`)
21
+ makes a request without a valid token answer 401 with
22
+ `WWW-Authenticate: Bearer resource_metadata="..."`, and serves the metadata at
23
+ `GET /.well-known/oauth-protected-resource`; `protectedResourceMetadata` builds it for the
24
+ host to serve at its root too.
25
+ - `looksLikeOAuthAccessToken` tells an access token from a host's session tokens.
26
+ - `Auth.oauth`: the app a request comes from. A request with it and without `apiToken` is
27
+ refused (an app never gets all of its user's access).
28
+
29
+ ### Changed
30
+
31
+ - The MCP server takes an OAuth access token too. An app's requests are limited per user it acts
32
+ for, and its tool calls are recorded in `mcp_audit` by its client (`oauthClientId`, a new
33
+ column added at startup) with no `tokenId` (now nullable).
34
+
35
+ ## 0.40.0
36
+
37
+ ### ⚠️ Breaking changes
38
+
39
+ - **A project's render farm connections are its workers.** `GET`, `POST` and
40
+ `DELETE /projects/:projectId/render-farm-connections` are now
41
+ `/projects/:projectId/workers`, which takes `{ name, provider?, endpoint, credential?, kinds,
42
+ categories, autoKind?, timeoutSeconds?, description? }`. They're still kept in the project's
43
+ `renderFarmConnections` list.
44
+ - **Jobs are kept in the main database** (a new `jobs` table, created at startup, or collection),
45
+ not in memory: they survive restarts and every instance sees them. `GET /jobs/:jobId` answers
46
+ from there.
47
+ - `canUseBuiltin` may be called with kind `'worker'`.
48
+
49
+ ### Added
50
+
51
+ - **Processing workers**: StreamBy sends jobs to external workers (the host's, in the router
52
+ config's `workers`; or a project's own) and keeps what they make, as a new asset derived from
53
+ the original or as the asset's new version, with the worker's report. The README documents the
54
+ contract a worker follows.
55
+ - `POST /projects/:projectId/jobs/process` asks for one; `GET /projects/:projectId/jobs` lists
56
+ a project's jobs; `POST /projects/:projectId/jobs/:jobId/retry` sends a failed one again.
57
+ - Workers call back to `/worker-jobs/:jobId/{progress,upload-url,complete,fail}` with a token
58
+ of that job's attempt alone.
59
+ - A job not taken, or not finished in time, is sent again (up to `workerOptions.maxAttempts`);
60
+ every instance looks for them (`workerOptions.sweepIntervalMs`), and only one sends each.
61
+ - A worker with an `autoKind` runs by itself on an asset of its categories marked as a
62
+ deliverable, unless it's marked with an API token without `jobs:run`.
63
+ - **Behind a proxy that ends TLS, set `workerOptions.callbackBaseUrl`** to the router's public
64
+ https URL: without it, the callback URL is made from the request (`req.protocol`), and comes
65
+ out as `http://`.
66
+ - A project's worker is reached only over https and never at a local, private, shared,
67
+ benchmarking, multicast or reserved address: neither as its endpoint is written nor as its
68
+ name resolves, checked when it's connected and again right before each job is sent. A job
69
+ for one that resolves to such an address fails for good. `workerOptions.allowLocalEndpoints`
70
+ lifts that, for development. Its credential is used only while whoever connected it is
71
+ still in the project.
72
+ - A worker's answer to a job it doesn't take is logged, not shown: the job says "The worker
73
+ refused the job".
74
+ - A job is sent as whoever asked for it, with the platform role they had then (a host's
75
+ `canUseBuiltin` decides on sending it as on asking for it).
76
+ - MCP tools `list_workers`, `process_asset`, `list_jobs` and `retry_job`.
77
+ - Deleting a project deletes its jobs.
78
+ - Job events (`jobEvent`) carry the job's `projectId` and `status`.
79
+
80
+ ### Fixed
81
+
82
+ - **Instances starting together don't deadlock on StreamBy's tables.** The statements that make
83
+ them (or bring them up to date) at startup run one instance at a time, in a transaction that
84
+ holds a transaction-level advisory lock (so it works behind a pooler in transaction mode, such
85
+ as Supabase's).
86
+
3
87
  ## 0.39.0
4
88
 
5
89
  ### Added