An entry for the streamplace vod showcase
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: use bundle's valibot instance for input validation

The sandbox was importing valibot from npm which created a different
instance than the one bundled with the endpoint. Now uses module.v.parse
from the bundle itself. Bundles must export { v } for validation to work.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

+35 -10
+21 -4
apps/vod/src/index.ts
··· 5 5 */ 6 6 7 7 import { endpoint, manifest, v } from "@at-run/runtime" 8 + 9 + // Re-export v for sandbox validation 10 + export { v } 8 11 import { AtpAgent } from "@atproto/api" 9 12 import { IdResolver } from "@atproto/identity" 10 13 import { AtUri } from "@atproto/syntax" ··· 349 352 }, 350 353 }) 351 354 352 - export const pollTranscoding = endpoint<v.InferOutput<typeof UriOnlySchema>, { status: "pending" | "complete"; playlistUri: string }>({ 353 - input: UriOnlySchema, 354 - permissions: {}, 355 - async handler({ uri }) { 355 + export const pollTranscoding = endpoint<v.InferOutput<typeof GetPlaylistSchema>, { status: "pending" | "complete"; playlistUri: string }>({ 356 + input: GetPlaylistSchema, 357 + permissions: { 358 + run: ["ffmpeg", "ffprobe"], 359 + write: ["/tmp/vod-cache/"], 360 + read: ["/tmp/vod-cache/"] 361 + }, 362 + async handler({ uri, quality }) { 363 + const atUri = new AtUri(uri) 364 + const agent = await getAgentForDid(atUri.host) 365 + 366 + const response = await agent.com.atproto.repo.getRecord({ 367 + repo: atUri.host, 368 + collection: atUri.collection, 369 + rkey: atUri.rkey, 370 + }) 371 + 372 + console.log(response.data) 356 373 return { 357 374 status: "pending", 358 375 playlistUri: "",
+9 -3
packages/at-run/README.md
··· 27 27 28 28 ```typescript 29 29 // my-api/index.ts 30 - import { manifest, endpoint } from "@at-run/runtime" 30 + import { manifest, endpoint, v } from "@at-run/runtime" 31 + 32 + // IMPORTANT: Re-export v for sandbox input validation 33 + export { v } 31 34 32 35 // Declare bundle metadata and permissions 33 36 export const bundle = manifest({ ··· 38 41 }, 39 42 }) 40 43 41 - // Define endpoints 44 + // Define endpoints with input validation 42 45 export const hello = endpoint({ 43 - handler: async (args: { name?: string }) => { 46 + input: v.object({ 47 + name: v.optional(v.string()), 48 + }), 49 + handler: async (args) => { 44 50 return { message: `Hello, ${args.name || "world"}!` } 45 51 }, 46 52 })
+5 -3
packages/at-run/runner/src/sandbox.ts
··· 187 187 188 188 // Validate input if schema is defined 189 189 if (endpoint.input) { 190 - // Import valibot dynamically (it's bundled with the endpoint) 191 - const { parse } = await import("npm:valibot@1"); 190 + // Use the bundle's own valibot instance (exported as 'v' from @at-run/runtime) 191 + if (!module.v || !module.v.parse) { 192 + throw new Error("Bundle must export 'v' from @at-run/runtime for input validation"); 193 + } 192 194 try { 193 - args = parse(endpoint.input, args); 195 + args = module.v.parse(endpoint.input, args); 194 196 } catch (validationErr) { 195 197 result = { 196 198 success: false,