Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .cursor/rules/coding-style.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ Coding style:
- Alphabetize imports, group by source type (built-in/external/internal)
- Favor US English over UK English, so `summarizeError` over `summarise Error`
- Favor `.replaceAll('a', 'b)` over `.replace(/a/g, 'b')` or `.replace(new RegExp('a', 'g'), 'b')` when the only need for regeses was replacing all strings. That's usually both easier to read and more performant.
- Use typographic characters: ellipsis (`…`) instead of `...`, curly quotes (`'` `"`) instead of straight quotes in user-facing text
- Put API keys and secrets in `.env` files, not hardcoded in components
- Check for existing hooks before creating new ones (e.g., `useUppy()` for Uppy functionality)
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@
"badge-maker": "^5.0.2",
"execa": "9.6.0",
"image-size": "^2.0.2",
"minimatch": "^10.1.1",
"nock": "^14.0.10",
"npm-run-all": "^4.1.5",
"p-retry": "^7.0.0",
"rimraf": "^6.1.2",
"temp": "^0.9.4",
"tsx": "4.20.5",
"typescript": "5.9.2",
"tsx": "4.21.0",
"typescript": "5.9.3",
"vitest": "^3.2.4"
},
"repository": {
Expand Down
8 changes: 4 additions & 4 deletions src/alphalib/mcache.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { SevLogger } from '@transloadit/sev-logger'
import type { Schema } from 'zod'

export interface McacheOpts<T> {
export interface McacheOpts {
ttlMs?: number
zodSchema?: Schema
logger?: SevLogger
Expand Down Expand Up @@ -37,10 +37,10 @@ interface CacheEntry<T> {
*/
export class Mcache<T> {
#cache: Map<string, CacheEntry<T>>
#opts: Required<Omit<McacheOpts<T>, 'logger' | 'zodSchema' | 'keyFn'>> &
Pick<McacheOpts<T>, 'logger' | 'zodSchema' | 'keyFn'>
#opts: Required<Omit<McacheOpts, 'logger' | 'zodSchema' | 'keyFn'>> &
Pick<McacheOpts, 'logger' | 'zodSchema' | 'keyFn'>

constructor(opts: McacheOpts<T> = {}) {
constructor(opts: McacheOpts = {}) {
this.#cache = new Map()
this.#opts = {
ttlMs: opts.ttlMs ?? Number.POSITIVE_INFINITY,
Expand Down
15 changes: 14 additions & 1 deletion src/alphalib/types/robots/_index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { z } from 'zod'

import {
meta as aiChatMeta,
interpolatableRobotAiChatInstructionsSchema,
interpolatableRobotAiChatInstructionsWithHiddenFieldsSchema,
} from './ai-chat.ts'
import {
meta as audioArtworkMeta,
interpolatableRobotAudioArtworkInstructionsSchema,
Expand Down Expand Up @@ -474,6 +478,7 @@ const robotStepsInstructions = [
interpolatableRobotSwiftStoreInstructionsSchema,
interpolatableRobotTextSpeakInstructionsSchema,
interpolatableRobotTextTranslateInstructionsSchema,
interpolatableRobotAiChatInstructionsSchema,
interpolatableRobotTigrisImportInstructionsSchema,
interpolatableRobotTigrisStoreInstructionsSchema,
interpolatableRobotTlcdnDeliverInstructionsSchema,
Expand Down Expand Up @@ -558,6 +563,7 @@ const robotStepsInstructionsWithHiddenFields = [
interpolatableRobotSwiftStoreInstructionsWithHiddenFieldsSchema,
interpolatableRobotTextSpeakInstructionsWithHiddenFieldsSchema,
interpolatableRobotTextTranslateInstructionsWithHiddenFieldsSchema,
interpolatableRobotAiChatInstructionsWithHiddenFieldsSchema,
interpolatableRobotTigrisImportInstructionsWithHiddenFieldsSchema,
interpolatableRobotTigrisStoreInstructionsWithHiddenFieldsSchema,
interpolatableRobotTlcdnDeliverInstructionsWithHiddenFieldsSchema,
Expand Down Expand Up @@ -605,6 +611,7 @@ export type RobotsWithHiddenBots = z.infer<typeof robotsWithHiddenBotsSchema>
export type RobotsWithHiddenBotsAndFields = z.infer<typeof robotsWithHiddenBotsAndFieldsSchema>

export const robotsMeta = {
aiChatMeta,
audioArtworkMeta,
audioConcatMeta,
audioEncodeMeta,
Expand Down Expand Up @@ -687,6 +694,12 @@ export const robotsMeta = {
youtubeStoreMeta,
}

export type {
InterpolatableRobotAiChatInstructions,
InterpolatableRobotAiChatInstructionsInput,
InterpolatableRobotAiChatInstructionsWithHiddenFields,
InterpolatableRobotAiChatInstructionsWithHiddenFieldsInput,
} from './ai-chat.ts'
export type {
InterpolatableRobotAssemblySavejsonInstructions,
InterpolatableRobotAssemblySavejsonInstructionsInput,
Expand Down
36 changes: 21 additions & 15 deletions src/alphalib/types/robots/_instructions-primitives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { z } from 'zod'
import { stackVersions } from '../stackVersions.ts'

export const robotNames = z.enum([
'AiChatRobot',
'UploadHandleRobot',
'FileServeRobot',
'FileWatermarkRobot',
Expand Down Expand Up @@ -395,21 +396,18 @@ export function interpolateRecursive<Schema extends z.ZodFirstPartySchemaTypes>(
*/
const uninterpolatableKeys = ['robot', 'use'] as const

type InterpolatableRobot<Schema extends z.ZodObject<z.ZodRawShape>> = Schema extends z.ZodObject<
infer T,
infer UnknownKeys,
infer Catchall
>
? z.ZodObject<
{
[Key in keyof T]: Key extends (typeof uninterpolatableKeys)[number]
? T[Key]
: InterpolatableSchema<T[Key]>
},
UnknownKeys,
Catchall
>
: never
type InterpolatableRobot<Schema extends z.ZodObject<z.ZodRawShape>> =
Schema extends z.ZodObject<infer T, infer UnknownKeys, infer Catchall>
? z.ZodObject<
{
[Key in keyof T]: Key extends (typeof uninterpolatableKeys)[number]
? T[Key]
: InterpolatableSchema<T[Key]>
},
UnknownKeys,
Catchall
>
: never

export function interpolateRobot<Schema extends z.ZodObject<z.ZodRawShape>>(
schema: Schema,
Expand Down Expand Up @@ -1762,3 +1760,11 @@ Delta to apply to segment duration. This is optional and allows fine-tuning of s
`),
})
.strict()

/**
* Type for the normalized use parameter from AssemblyNormalizer
* The steps array can contain either strings or objects with name property
*/
export interface NormalizedUse {
steps: Array<{ name: string; as?: string; fields?: string }>
}
Loading