Commit Graph

6439 Commits

Author SHA1 Message Date
Eric Allam 45047781ff WIP Assignments 2025-08-01 15:34:15 +01:00
Eric Allam 0ca3607a96 ignore .mcp.log 2025-07-31 15:56:54 +01:00
Eric Allam df907ff0aa more mcp stuff 2025-07-31 15:56:33 +01:00
Eric Allam 32af62e124 More MCP 2025-07-31 15:55:24 +01:00
Eric Allam 44ba239762 Upgrade zod to 3.25.76 2025-07-31 15:55:24 +01:00
Eric Allam ac8aaf566d Start MCP server 2025-07-31 15:55:24 +01:00
Eric Allam 580f95a464 we now convert schema to jsonSchema on the CLI side via the indexing 2025-07-31 15:53:52 +01:00
Eric Allam def3ee0f81 WIP 2025-07-31 15:53:52 +01:00
Eric Allam 0f5647c0af Fixed some stuff 2025-07-31 15:53:52 +01:00
Eric Allam 64fc703512 Refactor JSON Schema test files for clarity
Whitespace and formatting changes were applied across the `json-schema-test` reference project to enhance code readability and cohesion. This included removing unnecessary trailing spaces and ensuring consistent indentation patterns, which improves maintainability and readability by following the project's code style guidelines.

- Renamed JSONSchema type annotations to adhere to TypeScript conventions, ensuring that all schema definitions properly satisfy the JSONSchema interface.
- Restructured some object declarations for improved clarity, especially within complex schema definitions.
- These adjustments are crucial for better future maintainability, reducing potential developer errors when interacting with these test schemas.
2025-07-31 15:53:52 +01:00
Eric Allam af1e369fe4 Add JSON schema testing and revert package dependencies
This commit introduces a comprehensive set of JSON schema testing within the monorepo, specifically adding a new test project in `references/json-schema-test`. This includes a variety of schema definitions and tasks utilizing multiple validation libraries to ensure robust type-checking and runtime validation.

Additionally, the dependency versions for `@effect/schema` have been adjusted from `^0.76.5` to `^0.75.5` to maintain compatibility across the project components. This ensures consistent behavior and compatibility with existing code bases without introducing breaking changes or unexpected behavior due to version discrepancies.

Key updates include:
- Added new test project with extensive schema validation tests.
- Ensured type safety across various task implementations.
- Reverted dependency versions to ensure compatibility.
- Created multiple schema tasks using libraries like Zod, Yup, and others for thorough testing.
2025-07-31 15:53:52 +01:00
Eric Allam 7e4e77b24a Add JSONSchema type for payloadSchema in tasks
The change was necessary to improve type safety by using a proper JSONSchema type definition instead of a generic Record<string, unknown>. This enhances the developer experience and ensures that task payloads conform to the JSON Schema Draft 7 specification. The JSONSchema type is now re-exported from the SDK for user convenience, hiding internal complexity and maintaining a seamless developer experience.

- Added JSONSchema type based on Draft 7 specification
- Updated task metadata and options to use JSONSchema type
- Hid internal schema conversion logic from users by re-exporting types from SDK
- Improved bundle safety and dependency management
2025-07-31 15:53:52 +01:00
Eric Allam 200262818f Refactor SDK to encapsulate schema-to-json package
The previous implementation required users to directly import and initialize functions from the `@trigger.dev/schema-to-json` package, which was not the intended user experience. This change refactors the SDK so that all necessary functions and types from `@trigger.dev/schema-to-json` are encapsulated within the `@trigger.dev/*` packages.

- The examples in `usage.ts` have been updated to clearly mark `@trigger.dev/schema-to-json` as an internal-only package.
- Re-export JSON Schema types and conversions in the SDK to improve developer experience (DX).
- Removed unnecessary direct dependencies on `@trigger.dev/schema-to-json` from user-facing code, ensuring initialization and conversion logic is handled internally.
- Replaced instances where users were required to manually perform schema conversions with automatic handling within the SDK for simplification and better maintainability.
2025-07-31 15:53:52 +01:00
Eric Allam 088185b05b Add JSON Schema examples using various libraries
The change introduces extensive examples of using JSON Schemas in the 'references/hello-world' project within the 'trigger.dev' repository. These examples utilize libraries like Zod, Yup, and TypeBox for JSON Schema conversion and validation. The new examples demonstrate different use cases, including automatic conversion with schemaTask, manual schema provision, and schema conversion at build time. We also updated the dependencies in 'package.json' to include the necessary libraries for schema conversion and validation.

- Included examples of processing tasks with JSON Schema using libraries such as Zod, Yup, TypeBox, and ArkType.
- Showcased schema conversion techniques and type-safe JSON Schema creation.
- Updated 'package.json' to ensure all necessary dependencies for schema operations are available.
- Created illustrative scripts that cover task management from user processing to complex schema implementations.
2025-07-31 15:53:52 +01:00
Eric Allam 74ec4063b0 Refine JSON Schema typing across packages
The changes introduce stricter typing for JSON Schema-related definitions, specifically replacing vague types with more precise ones, such as using `z.record(z.unknown())` instead of `z.any()` and `Record<string, unknown>` in place of `any`. This is part of an effort to better align with common practices and improve type safety in the packages.

- Updated the `payloadSchema` in several files to use `z.record(z.unknown())`, enhancing the type strictness and consistency with JSON Schema Draft 7 recommendations.
- Added `@types/json-schema` as a dependency, utilizing its definitions for improved type clarity and adherence to best practices in TypeScript.
- Modified various comments to explicitly mention JSON Schema Draft 7, ensuring developers are aware of the JSON Schema version being implemented.
- These adjustments are informed by research into how popular libraries and tools handle JSON Schema typing, aiming to integrate best practices for improved maintainability and interoperability.
2025-07-31 15:53:52 +01:00
Eric Allam eb81722cd5 Revise schema-to-json for bundle safety and tests
The package @trigger.dev/schema-to-json has been revised to ensure bundle safety by removing direct dependencies on schema libraries such as Zod, Yup, and Effect. This change minimizes bundle size and enhances tree-shaking by allowing external conversion libraries to be utilized only at runtime if necessary. As a result, the README was updated to reflect this usage pattern.

- Introduced `initializeSchemaConverters` function to load necessary conversion libraries at runtime, keeping the base package slim.
- Adjusted test suite to initialize converters before tests, ensuring accurate testing of schema conversion capabilities.
- Updated `schemaToJsonSchema` function to dynamically check for availability of conversion libraries, improving flexibility without increasing the package size.
- Added configuration files for Vitest to support the new testing framework, reflecting the transition from previous test setups.

These enhancements ensure that only the schema libraries actively used in an application are bundled, optimizing performance and resource usage.
2025-07-31 15:53:52 +01:00
Eric Allam 87ed9c4a67 Add support for Zod 4 in schema-to-json
This change enhances the schema-to-json package by adding support for Zod version 4, which introduces the native `toJsonSchema` method. This method facilitates a direct conversion of Zod schemas to JSON Schema format, improving performance and reducing reliance on the `zod-to-json-schema` library.

- Updated README to reflect Zod 4 support with native method and retained support for Zod 3 via existing library.
- Modified package.json to allow installation of both Zod 3 and 4 versions.
- Implemented handling for Zod 4 schemas in `src/index.ts` using their native method.
- Added a test case to verify the proper conversion of Zod 4 schemas to JSON Schema.
- Included a script for updating the package version based on the root package.json.
- Introduced a specific TypeScript config for source files.
2025-07-31 15:53:52 +01:00
Eric Allam 9b395d6a4a Refactor: Remove getSchemaToJsonSchema in favor of schemaToJsonSchema
The `getSchemaToJsonSchema` function was removed and replaced with `schemaToJsonSchema` across the codebase. This update introduces a new `@trigger.dev/schema-to-json` package to handle conversions of schema validation libraries to JSON Schema format, centralizing the functionality and improving maintainability.

- Removed `getSchemaToJsonSchema` exports and references.
- Added new schema conversion utility `@trigger.dev/schema-to-json`.
- Updated `trigger-sdk` package to utilize `schemaToJsonSchema` for payloads.
- Extensive testing coverage included to ensure conversion accuracy across various schema libraries including Zod, Yup, ArkType, Effect, and TypeBox.
- The update ensures consistent and reliable schema conversions, facilitating future enhancements and supporting additional schema libraries.
2025-07-31 15:53:52 +01:00
Eric Allam e86000b221 Add payload schema handling for task indexing
This change introduces support for handling payload schemas during task indexing. By incorporating the `payloadSchema` attribute into various components, we ensure that each task's payload structure is clearly defined and can be validated before processing.

- Updated the TaskManifest and task metadata structures to include an optional `payloadSchema` attribute. This addition allows for more robust validation and handling of task payloads.
- Enhanced several core modules to export and utilize the new `getSchemaToJsonSchema` function, providing easier conversion of schema types to JSON schemas.
- Modified the database schema to store the `payloadSchema` attribute, ensuring that the payload schema information is persisted.
- The change helps in maintaining consistency in data handling and improves the integrity of task data across the application.
2025-07-31 15:53:52 +01:00
Eric Allam 134942b2dd The schedule HTTP API now accepts deduplicationKeys as well as schedule IDs in the URL (#2329) 2025-07-31 14:12:31 +01:00
Eric Allam b153324cd9 fix: importing from runEngine/index.js breaks non-node runtimes (#2328) 2025-07-31 13:22:02 +01:00
James Ritchie 59bfce86db Docs: Fixes incorrect concurrency pricing on the limits page (#2324) 2025-07-31 12:07:42 +01:00
Eric Allam 748565c9db Fix backwards compatible execution by allowing additional properties to passthrough (#2327) 2025-07-31 11:14:46 +01:00
Matt Aitken 8b31871998 Usage billing alerts (#2323)
* First draft billing alerts page

* Budget alert form working

* Don't let free plan users change the billing alert amount

* Fix missing key in map in the form

* Disable queues/org from admin API endpoint

* Don't allow resuming if runsEnabled is false

* Refer to "Billing alerts" not "Plans"

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Form missing dependencies fix

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Deal with thrown errors, fix for duplicating email fields

* Added a RuntimeEnvironment organizationId index

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-07-30 13:48:02 +01:00
Eric Allam 14dcc76f93 feat: run.ctx tidying and additions (#2322)
* Cleanup context and execution creation, cache stuff, add parent and root task run ids

* more efficient by using friendly IDs instead of doing joins

* metadata.root/parent now reference current run when run has no root/parent

* Adding changeset

* try to make test less flaky

* Clean imports

* Another attempt to fix the flaky test

* Fix usage by still passing durationMs and costInCents to the execution, just not the run.ctx
2025-07-30 13:47:12 +01:00
Nicolas Rigaudière 5ea6605ec6 feat(extensions): add lightpanda (#2192)
* feat: add lightpanda structure

* chore: add lightpanda doc links

* fix: lightpanda extension instructions

* feat: add Lightpanda guide and examples

* feat: lightpanda - add 3rd example

* feat: add lightpandaTask

* fix: lightpanda 3rd example

* fix: lightpanda 1st example

* chore: add changeset

* add v4 tag to guide

* fix: merge lightpanda docker instructions

* fix: add failsafes

* add scrape warning

* lint

* successful login also switches to that profile

* update docs and links as this is v4 only

* extension tweaks

* simplify extension

* update examples

* update docs

* remove from extensions list as v4 only

* remove from catalog

* update changeset

---------

Co-authored-by: nicktrn <55853254+nicktrn@users.noreply.github.com>
2025-07-28 18:38:13 +01:00
nicktrn 3e1cc69db9 feat(ecr): make assume role optional (#2321) 2025-07-28 14:47:30 +01:00
nicktrn 2ea52da628 fix(runner): disable warm starts after SIGTERM (#2316)
* security: bump form-data to latest patch versions (CVE-2025-7783)

* disable warm starts on sigterm

* add changeset
2025-07-28 11:29:49 +01:00
Saadi Myftija 3493b9464f Cancel readonly ClickHouse queries on client close (#2319) 2025-07-28 11:00:35 +01:00
Eric Allam a7ff6de388 fix: otel logs better DynamicFlushScheduler (#2318)
* Improve dynamic flush scheduler for otel data

The changes introduce a more flexible and adaptive dynamic flush scheduler to address production issues where the system wasn't flushing data fast enough, causing memory growth and crashes. This issue arises from the existing scheduler handling only a single flush at a time, limiting concurrency and failing to cope with the influx of logs.

- Added configuration options for setting minimum and maximum concurrency levels, maximum batch size, and memory pressure threshold. These parameters ensure that flush operations adjust dynamically based on workload and pressure.
- Implemented `pLimit` to facilitate concurrent flush operations, with adjustments made according to batch queue length and memory pressure.
- Metrics reporting improvements were added to monitor the dynamic behavior of the flush scheduler, aiding in identifying performance issues and optimizing the operation accordingly.

* Implement load shedding for TaskEvent records

This change introduces load shedding mechanisms to manage TaskEvent
records, particularly those of kind LOG, when the system experiences
high volumes and is unable to flush to the database in a timely
manner. The addition aims to prevent overwhelming the system and
ensure critical tasks are prioritized.

- Added configuration options for `loadSheddingThreshold` and
  `loadSheddingEnabled` in multiple modules to activate load shedding.
- Introduced `isDroppableEvent` function to allow specific events to
  be dropped when load shedding is enabled.
- Ensured metrics are updated to reflect dropped events and load
  shedding status, providing visibility into system performance
during high load conditions.
- Updated loggers to inform about load shedding state changes,
  ensuring timely awareness of load management activities.

* Fix undefined 'queuePressure' variable in DynamicFlushScheduler

The 'queuePressure' variable was being used without being defined
in the DynamicFlushScheduler class, causing potential runtime
errors. This commit adds the missing definition and ensures that
the variable is correctly calculated based on the 'totalQueuedItems'
and 'memoryPressureThreshold'.

- Addressed code inconsistencies and improved formatting.
- Defined 'queuePressure' in the 'adjustConcurrency' method
  to prevent potential undefined errors.
- Enhanced readability by maintaining consistent spacing and
  format across the file, contributing to the stability and
  maintainability of the code.
- Adjusted batch size logic based on the newly defined 'queuePressure'
  variable.

* Refactor concurrency adjustment logic in scheduler

The concurrency adjustment logic in the dynamic flush scheduler has been refactored to improve clarity and maintainability. This change moves the calculation of pressure metrics outside of the conditional blocks to ensure they are always determined prior to decision-making.

- The queue pressure and time since last flush calculations were moved up in the code to be independent of the 'backOff' condition.
- This refactor sets up the groundwork for more reliable concurrency scaling and better performance monitoring capabilities. The overall logic of adjusting concurrency based on system pressure metrics remains unchanged.

This adjustment addresses ongoing issues with the scheduler that were not resolved by previous changes.

* Some tweaks
2025-07-26 11:06:56 +01:00
Eric Allam 0d136a3e0c fix runs.retrieve when the payload or output has unstringifiable JSON (#2315) 2025-07-25 12:00:05 +01:00
nicktrn c8165ccd44 security: bump form-data to latest patch versions (CVE-2025-7783) (#2314) 2025-07-24 17:44:19 +01:00
Eric Allam 00cc07dad3 Ignore queryRoute() call aborted errors (#2313) 2025-07-24 16:22:21 +01:00
Eric Allam 71693eb9b3 stop double reporting errors to sentry (#2312) 2025-07-24 16:02:26 +01:00
Eric Allam fb59bfd8f8 sentry: remove node native integration because it breaks (#2311) 2025-07-24 15:37:06 +01:00
Matt Aitken 038ee75c28 Queue "View runs" buttons turn off root only (#2310) 2025-07-24 15:26:56 +01:00
Eric Allam 09d0e80804 Add sentry error reporting (#2309)
* Sentry WIP

* Configure sentry for uploading and releasing during the publish webapp step

* Delete source maps after uploading

* Forward logger.error calls to sentry through Logger.onError

* Couple tweaks to the dockerfile
2025-07-24 15:09:50 +01:00
Saadi Myftija 74808d7400 Pre-merge and pre-sort run batches before sending to clickhouse (#2308)
* Premerge run batch before sending it to clickhouse

* Pre-order batch items before sending to clickhouse in favor of performance

* existing

* Emit event on batch flushes

* When merging batches, keep the last occurrence items with the same version

* Add a couple of tests
2025-07-24 14:17:26 +01:00
Matt Aitken 6791328a94 Queues dashboard update (burst concurrency) (#2293)
* Initial burst changes to queue page

* Added tooltip and changed wording around

* View runs from Queues page

* Fix for ugly Version filter "Current" badge
2025-07-24 10:17:54 +01:00
Eric Allam 3dce1f66f7 docs: beta.25 changelog entry (#2306) 2025-07-24 09:38:24 +01:00
github-actions[bot] 17bb0c0cef Release v4.0.0-v4-beta.25
🚀 Publish Trigger.dev Docker / typecheck (push) Failing after 3s
🚀 Publish Trigger.dev Docker / publish-webapp (push) Has been skipped
🚀 Publish Trigger.dev Docker / publish-worker (push) Has been skipped
🚀 Publish Trigger.dev Docker / publish-worker-v4 (push) Has been skipped
🚀 Publish Trigger.dev Docker / units (push) Failing after 4s
* chore: Update version for release (v4-beta)

* Release v4.0.0-v4-beta.25

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Eric Allam <eallam@icloud.com>
@trigger.dev/python@4.0.0-v4-beta.25 @trigger.dev/build@4.0.0-v4-beta.25 @trigger.dev/core@4.0.0-v4-beta.25 @trigger.dev/react-hooks@4.0.0-v4-beta.25 @trigger.dev/redis-worker@4.0.0-v4-beta.25 @trigger.dev/rsc@4.0.0-v4-beta.25 trigger.dev@4.0.0-v4-beta.25 v.docker.4.0.0-v4-beta.25 @trigger.dev/sdk@4.0.0-v4-beta.25
2025-07-23 20:22:33 +01:00
Eric Allam ef59a62368 Ability to perform bulk run backfills (#2304)
* Ability to perform bulk run backfills

* Fix tests

* Allow controlling the delay interval when creating the batch
2025-07-23 20:12:35 +01:00
Eric Allam b447a8040f Use sync insert strategy since we are already batching client-side (#2303) 2025-07-23 17:17:13 +01:00
Matt Aitken ed86b4f5db Run repository test fix (#2302)
The normal database needs to be mocked because an import somewhere is 
using it which causes issues with the test container dbs and hanging at 
the end. 

Strategy copied from the trigger test file.
2025-07-23 17:10:20 +01:00
Matt Aitken 9b0eb64035 Fallback from ClickHouse to Postgres (#2300)
* Set the default replication concurrency to 2 for self-hosters

100 was a bit crazy

* Made the run repository an interface, deferring just to CH for now

* Added run repository feature flag, allowing passing a default when getting a flag

* Switch run repository using a feature flag

* Added spans

* Pass the default repository in, so we can try Postgres in the tests

* Fallback to Postgres if ClickHouse errors

* Update feature flags API endpoint
2025-07-23 16:30:30 +01:00
Eric Allam c927fbc8e4 Gracefully shutdown task run processes (#2299)
* Gracefully shutdown task run processes

* better log, thanks coderabbit
2025-07-23 16:11:26 +01:00
Matt Aitken bf4fff9cca The tasks page shows an error rather than breaking the entire page (#2297) 2025-07-23 12:28:06 +01:00
Saadi Myftija ad1672d95f Fail gracefully when runs cannot be loaded (#2296) 2025-07-23 11:21:54 +01:00
Eric Allam 6df7eb2bb5 docs: new release concurrency system and run statuses (#2287)
* WIP new docs for the new release concurrency and run statuses

* Fixed status description

* Add the beta.24 changelog entry
2025-07-22 11:30:28 +01:00
github-actions[bot] 36ced50c04 Release 4.0.0-v4-beta.24
🚀 Publish Trigger.dev Docker / typecheck (push) Failing after 0s
🚀 Publish Trigger.dev Docker / publish-webapp (push) Has been skipped
🚀 Publish Trigger.dev Docker / publish-worker (push) Has been skipped
🚀 Publish Trigger.dev Docker / publish-worker-v4 (push) Has been skipped
🚀 Publish Trigger.dev Docker / units (push) Failing after 4s
* chore: Update version for release (v4-beta)

* Release 4.0.0-v4-beta.24

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Eric Allam <eallam@icloud.com>
@trigger.dev/python@4.0.0-v4-beta.24 @trigger.dev/build@4.0.0-v4-beta.24 @trigger.dev/core@4.0.0-v4-beta.24 @trigger.dev/react-hooks@4.0.0-v4-beta.24 @trigger.dev/rsc@4.0.0-v4-beta.24 @trigger.dev/sdk@4.0.0-v4-beta.24 trigger.dev@4.0.0-v4-beta.24 v.docker.4.0.0-v4-beta.24 @trigger.dev/redis-worker@4.0.0-v4-beta.24
2025-07-22 10:42:59 +01:00