chore: kanban template
This commit is contained in:
41
packages/functions/bin/db-migrate.ts
Normal file
41
packages/functions/bin/db-migrate.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import postgres from 'postgres'
|
||||
import { readdir, readFile } from 'node:fs/promises'
|
||||
import { join, dirname } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url))
|
||||
const sqlDir = join(__dirname, '../../../sql')
|
||||
|
||||
const databaseUrl = process.env.DATABASE_URL
|
||||
if (!databaseUrl) {
|
||||
console.error('[db-migrate] DATABASE_URL is not set')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const sql = postgres(databaseUrl)
|
||||
|
||||
await sql`
|
||||
CREATE TABLE IF NOT EXISTS schema_migrations (
|
||||
filename TEXT PRIMARY KEY,
|
||||
applied_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
)
|
||||
`
|
||||
|
||||
const applied = new Set((await sql`SELECT filename FROM schema_migrations`).map((r) => r.filename))
|
||||
|
||||
const files = (await readdir(sqlDir)).filter((f) => f.endsWith('.sql')).sort()
|
||||
|
||||
for (const file of files) {
|
||||
if (applied.has(file)) {
|
||||
console.log(`[db-migrate] skip ${file} (already applied)`)
|
||||
continue
|
||||
}
|
||||
const content = await readFile(join(sqlDir, file), 'utf8')
|
||||
console.log(`[db-migrate] applying ${file}...`)
|
||||
await sql.unsafe(content)
|
||||
await sql`INSERT INTO schema_migrations (filename) VALUES (${file})`
|
||||
console.log(`[db-migrate] applied ${file}`)
|
||||
}
|
||||
|
||||
await sql.end()
|
||||
console.log('[db-migrate] done')
|
||||
5680
packages/functions/coverage/coverage-final.json
Normal file
5680
packages/functions/coverage/coverage-final.json
Normal file
File diff suppressed because it is too large
Load Diff
16669
packages/functions/coverage/tmp/coverage-57615-1780003237390-1.json
Normal file
16669
packages/functions/coverage/tmp/coverage-57615-1780003237390-1.json
Normal file
File diff suppressed because it is too large
Load Diff
133639
packages/functions/coverage/tmp/coverage-57615-1780003237413-0.json
Normal file
133639
packages/functions/coverage/tmp/coverage-57615-1780003237413-0.json
Normal file
File diff suppressed because one or more lines are too long
4106
packages/functions/coverage/tmp/coverage-57616-1780003236411-0.json
Normal file
4106
packages/functions/coverage/tmp/coverage-57616-1780003236411-0.json
Normal file
File diff suppressed because it is too large
Load Diff
33
packages/functions/package.json
Normal file
33
packages/functions/package.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "@project/functions",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"imports": {
|
||||
"#pikku": "./.pikku/pikku-types.gen.ts",
|
||||
"#pikku/*": "./.pikku/*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ai-sdk/openai-compatible": "^2.0.48",
|
||||
"@cloudflare/workers-types": "^4.20241218.0",
|
||||
"@pikku/ai-vercel": "^0.12.6",
|
||||
"@pikku/better-auth": "^0.12.9",
|
||||
"@pikku/kysely": "^0.12.16",
|
||||
"@pikku/schema-cfworker": "^0.12.2",
|
||||
"ai": "^6.0.0",
|
||||
"better-auth": "^1.6.18",
|
||||
"kysely": "^0.28.12",
|
||||
"zod": "^4.3.6"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@pikku/ai-vercel": "^0.12.6",
|
||||
"@pikku/better-auth": "^0.12.9",
|
||||
"@pikku/cloudflare": "^0.12.10",
|
||||
"@pikku/core": "^0.12.35",
|
||||
"@pikku/kysely": "^0.12.16",
|
||||
"@pikku/kysely-node-sqlite": "^0.12.2",
|
||||
"@pikku/kysely-sqlite": "^0.12.6",
|
||||
"@pikku/schedule": "^0.12.2",
|
||||
"@pikku/schema-cfworker": "^0.12.2"
|
||||
}
|
||||
}
|
||||
4
packages/functions/packages/functions/.pikku/agent/pikku-agent-map.gen.d.ts
vendored
Normal file
4
packages/functions/packages/functions/.pikku/agent/pikku-agent-map.gen.d.ts
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
export type AgentMap = {}
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
import {
|
||||
CoreAIAgent,
|
||||
PikkuAIMiddlewareHooks,
|
||||
} from '@pikku/core/ai-agent'
|
||||
import {
|
||||
agent as coreAgent,
|
||||
agentStream as coreAgentStream,
|
||||
agentResume as coreAgentResume,
|
||||
agentApprove as coreAgentApprove,
|
||||
} from '@pikku/core/ai-agent'
|
||||
import type { PikkuPermission, PikkuMiddleware, Services, PikkuFunctionConfig } from '../function/pikku-function-types.gen.js'
|
||||
import type { StandardSchemaV1 } from '@standard-schema/spec'
|
||||
import type { AIAgentMemoryConfig, AIAgentInput } from '@pikku/core/ai-agent'
|
||||
import type { AgentMap } from './pikku-agent-map.gen.d.js'
|
||||
|
||||
type AIAgentConfig<
|
||||
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
||||
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
||||
> = Omit<CoreAIAgent<PikkuPermission, PikkuMiddleware>, 'tools' | 'agents' | 'memory' | 'input' | 'output'> & {
|
||||
input?: InputSchema
|
||||
output?: OutputSchema
|
||||
memory?: Omit<AIAgentMemoryConfig, 'workingMemory'> & { workingMemory?: StandardSchemaV1 }
|
||||
tools?: object[]
|
||||
agents?: AIAgentConfig<StandardSchemaV1 | undefined, StandardSchemaV1 | undefined>[]
|
||||
}
|
||||
|
||||
export const pikkuAIAgent = <
|
||||
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
||||
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
||||
>(
|
||||
agent: AIAgentConfig<InputSchema, OutputSchema>
|
||||
) => {
|
||||
return agent
|
||||
}
|
||||
|
||||
export const pikkuAIMiddleware = <
|
||||
State extends Record<string, unknown> = Record<string, unknown>,
|
||||
RequiredServices extends Services = Services,
|
||||
>(
|
||||
hooks: PikkuAIMiddlewareHooks<State, RequiredServices>
|
||||
): PikkuAIMiddlewareHooks<State, RequiredServices> => hooks
|
||||
|
||||
export const agent = <Name extends keyof AgentMap>(
|
||||
agentName: Name
|
||||
) => {
|
||||
return coreAgent<AgentMap>(agentName as string & keyof AgentMap) as PikkuFunctionConfig<
|
||||
AIAgentInput,
|
||||
{ runId: string; result: AgentMap[Name]['output']; usage: { inputTokens: number; outputTokens: number } },
|
||||
'session' | 'rpc'
|
||||
>
|
||||
}
|
||||
|
||||
export const agentStream = <Name extends keyof AgentMap>(
|
||||
agentName?: Name
|
||||
) => {
|
||||
return coreAgentStream<AgentMap>(agentName as string & keyof AgentMap) as PikkuFunctionConfig<
|
||||
{ agentName?: string; message: string; threadId: string; resourceId: string },
|
||||
void,
|
||||
'session' | 'rpc'
|
||||
>
|
||||
}
|
||||
|
||||
export const agentResume = () => {
|
||||
return coreAgentResume() as PikkuFunctionConfig<
|
||||
{ runId: string; toolCallId: string; approved: boolean },
|
||||
void,
|
||||
'session' | 'rpc'
|
||||
>
|
||||
}
|
||||
|
||||
export const agentApprove = <Name extends keyof AgentMap>(
|
||||
agentName: Name
|
||||
) => {
|
||||
return coreAgentApprove<AgentMap>(agentName as string & keyof AgentMap) as PikkuFunctionConfig<
|
||||
{ runId: string; approvals: { toolCallId: string; approved: boolean }[] },
|
||||
unknown,
|
||||
'session' | 'rpc'
|
||||
>
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
/**
|
||||
* Channel-specific type definitions for tree-shaking optimization
|
||||
*/
|
||||
|
||||
import { CoreChannel, CorePikkuChannelMiddleware, CorePikkuChannelMiddlewareFactory, wireChannel as wireChannelCore, defineChannelRoutes as defineChannelRoutesCore, addChannelMiddleware as addChannelMiddlewareCore } from '@pikku/core/channel'
|
||||
import { AssertHTTPWiringParams } from '@pikku/core/http'
|
||||
import type { PikkuFunctionConfig, PikkuFunctionSessionless, PikkuPermission, PikkuMiddleware, Services } from '../function/pikku-function-types.gen.js'
|
||||
import type { CorePermissionGroup } from '@pikku/core'
|
||||
import type { StandardSchemaV1 } from '@standard-schema/spec'
|
||||
|
||||
/**
|
||||
* Helper type to infer the output type from a Standard Schema
|
||||
*/
|
||||
type InferSchemaOutput<T> = T extends StandardSchemaV1<any, infer Output> ? Output : never
|
||||
|
||||
/**
|
||||
* Type definition for WebSocket channels with typed data exchange.
|
||||
* Supports connection, disconnection, and message handling.
|
||||
* Accepts both session-based (PikkuFunction) and sessionless (PikkuFunctionSessionless) functions.
|
||||
*
|
||||
* @template ChannelData - Type of data exchanged through the channel
|
||||
* @template Channel - String literal type for the channel name
|
||||
*/
|
||||
type ChannelWiring<ChannelData, Channel extends string> = CoreChannel<
|
||||
ChannelData,
|
||||
Channel,
|
||||
PikkuFunctionConfig<void, any, 'channel' | 'session' | 'rpc'>,
|
||||
PikkuFunctionConfig<void, void, 'channel' | 'session' | 'rpc'>,
|
||||
PikkuFunctionConfig<any, any, 'channel' | 'session' | 'rpc'>,
|
||||
PikkuPermission,
|
||||
PikkuMiddleware
|
||||
>
|
||||
|
||||
/**
|
||||
* Creates a function that handles WebSocket channel connections.
|
||||
* Called when a client connects to a channel.
|
||||
*
|
||||
* @template Out - Output type for connection response
|
||||
* @param func - Function definition, either direct function or configuration object
|
||||
* @returns The normalized configuration object
|
||||
*/
|
||||
export const pikkuChannelConnectionFunc = <Out = unknown>(
|
||||
func:
|
||||
| PikkuFunctionSessionless<void, Out, 'channel' | 'session' | 'rpc'>
|
||||
| PikkuFunctionConfig<void, Out, 'channel' | 'session' | 'rpc'>
|
||||
) => {
|
||||
return typeof func === 'function' ? { func } : func
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function that handles WebSocket channel disconnections.
|
||||
* Called when a client disconnects from a channel.
|
||||
*
|
||||
* @param func - Function definition, either direct function or configuration object
|
||||
* @returns The normalized configuration object
|
||||
*/
|
||||
export const pikkuChannelDisconnectionFunc = (
|
||||
func:
|
||||
| PikkuFunctionSessionless<void, void, 'channel'>
|
||||
| PikkuFunctionConfig<void, void, 'channel' | 'session' | 'rpc'>
|
||||
) => {
|
||||
return typeof func === 'function' ? { func } : func
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration object for channel functions with Zod schema validation.
|
||||
*/
|
||||
type PikkuChannelFuncConfigWithSchema<
|
||||
InputSchema extends StandardSchemaV1,
|
||||
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
||||
> = {
|
||||
name?: string
|
||||
tags?: string[]
|
||||
expose?: boolean
|
||||
remote?: boolean
|
||||
func: PikkuFunctionSessionless<
|
||||
InferSchemaOutput<InputSchema>,
|
||||
OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown,
|
||||
'channel' | 'session' | 'rpc'
|
||||
>
|
||||
auth?: boolean
|
||||
permissions?: CorePermissionGroup<PikkuPermission<InferSchemaOutput<InputSchema>>>
|
||||
middleware?: PikkuMiddleware[]
|
||||
input: InputSchema
|
||||
output?: OutputSchema
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function that handles WebSocket channel messages.
|
||||
* Called when a message is received on a channel.
|
||||
*
|
||||
* Supports two patterns:
|
||||
* 1. Generic types: `pikkuChannelFunc<Input, Output>({ func: ... })`
|
||||
* 2. Zod schemas: `pikkuChannelFunc({ input: z.object(...), func: ... })`
|
||||
*
|
||||
* @template In - Input type for channel messages (inferred from schema if provided)
|
||||
* @template Out - Output type for channel responses (inferred from schema if provided)
|
||||
* @param func - Function definition, either direct function or configuration object
|
||||
* @returns The normalized configuration object
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* // Pattern 1: Using generic types
|
||||
* const handleMessage = pikkuChannelFunc<{text: string}, {received: boolean}>({
|
||||
* func: async (_services, { text }) => ({ received: true })
|
||||
* })
|
||||
*
|
||||
* // Pattern 2: Using Zod schemas
|
||||
* const messageInput = z.object({ text: z.string() })
|
||||
* const messageOutput = z.object({ received: z.boolean() })
|
||||
*
|
||||
* const handleMessage = pikkuChannelFunc({
|
||||
* input: messageInput,
|
||||
* output: messageOutput,
|
||||
* func: async (_services, { text }) => ({ received: true })
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
export function pikkuChannelFunc<
|
||||
InputSchema extends StandardSchemaV1,
|
||||
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
||||
>(
|
||||
config: PikkuChannelFuncConfigWithSchema<InputSchema, OutputSchema>
|
||||
): PikkuFunctionConfig<InferSchemaOutput<InputSchema>, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown, 'channel' | 'session' | 'rpc'>
|
||||
export function pikkuChannelFunc<In, Out = unknown>(
|
||||
func:
|
||||
| PikkuFunctionSessionless<In, Out, 'channel' | 'session' | 'rpc'>
|
||||
| PikkuFunctionConfig<In, Out, 'channel' | 'session' | 'rpc'>
|
||||
): PikkuFunctionConfig<In, Out, 'channel' | 'session' | 'rpc'>
|
||||
export function pikkuChannelFunc(func: any) {
|
||||
return typeof func === 'function' ? { func } : func
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a WebSocket channel with the Pikku framework.
|
||||
*
|
||||
* @template ChannelData - Type of data associated with the channel
|
||||
* @template Channel - String literal type for the channel name
|
||||
* @param channel - Channel definition with connection, disconnection, and message handlers
|
||||
*/
|
||||
export const wireChannel = <ChannelData, Channel extends string>(
|
||||
channel: ChannelWiring<ChannelData, Channel> & AssertHTTPWiringParams<ChannelData, Channel>
|
||||
) => {
|
||||
wireChannelCore(channel as any)
|
||||
}
|
||||
|
||||
/**
|
||||
* Type-safe helper for defining channel message routes that can be composed.
|
||||
* Returns the routes record as-is for use with wireChannel's onMessageWiring.
|
||||
*
|
||||
* @template T - Record of channel route handlers
|
||||
* @param routes - The channel routes record
|
||||
* @returns The same routes record (identity function for type safety)
|
||||
*/
|
||||
export function defineChannelRoutes<T extends Record<string, any>>(routes: T): T {
|
||||
return defineChannelRoutesCore(routes)
|
||||
}
|
||||
|
||||
export type PikkuChannelMiddleware<RequiredServices extends Services = Services, Event = unknown> = CorePikkuChannelMiddleware<RequiredServices, Event>
|
||||
|
||||
export const pikkuChannelMiddleware = <RequiredServices extends Services = Services, Event = unknown>(
|
||||
middleware: PikkuChannelMiddleware<RequiredServices, Event>
|
||||
): PikkuChannelMiddleware<RequiredServices, Event> => {
|
||||
return middleware
|
||||
}
|
||||
|
||||
export const pikkuChannelMiddlewareFactory = <In = any>(
|
||||
factory: CorePikkuChannelMiddlewareFactory<In>
|
||||
): CorePikkuChannelMiddlewareFactory<In> => {
|
||||
return factory
|
||||
}
|
||||
|
||||
export const addChannelMiddleware = (tag: string, middleware: PikkuChannelMiddleware[]) =>
|
||||
addChannelMiddlewareCore(tag, middleware, null)
|
||||
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
/**
|
||||
|
||||
* CLI-specific type definitions for tree-shaking optimization
|
||||
*/
|
||||
|
||||
import { CoreCLI, wireCLI as wireCLICore, CorePikkuCLIRender, CoreCLICommandConfig, defineCLICommands as defineCLICommandsCore } from '@pikku/core/cli'
|
||||
import type { PikkuFunctionConfig, PikkuMiddleware } from '../function/pikku-function-types.gen.js'
|
||||
import type { UserSession } from '../../../../src/application-types.d.js'
|
||||
import type { SingletonServices } from '../../../../src/application-types.d.js'
|
||||
|
||||
|
||||
type Session = UserSession
|
||||
|
||||
/**
|
||||
* Type-safe CLI renderer definition that can access your application's services.
|
||||
* Use this to define custom renderers for CLI command output.
|
||||
*
|
||||
* @template Data - The output data type from the CLI command
|
||||
* @template RequiredServices - The services required for this renderer
|
||||
*/
|
||||
type PikkuCLIRender<Data, RequiredServices extends SingletonServices = SingletonServices> = CorePikkuCLIRender<Data, RequiredServices, Session>
|
||||
|
||||
/**
|
||||
* Creates a type-safe CLI renderer with access to your application's singleton services.
|
||||
* The renderer receives the full singleton services and output data to format and display results.
|
||||
*
|
||||
* @template Data - The output data type from the CLI command
|
||||
* @template RequiredServices - The minimum services required for type checking (defaults to SingletonServices)
|
||||
* @param render - Function that receives singleton services and data to render output
|
||||
* @returns A CLI renderer configuration
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const myRenderer = pikkuCLIRender<MyData>(({ logger }, data) => {
|
||||
* logger.info(data.message)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
export const pikkuCLIRender = <Data, RequiredServices extends SingletonServices = SingletonServices>(
|
||||
render: (services: SingletonServices, data: Data) => void | Promise<void>
|
||||
): PikkuCLIRender<Data, RequiredServices> => {
|
||||
return render as any
|
||||
}
|
||||
|
||||
/**
|
||||
* CLI command configuration with project-specific types.
|
||||
* Uses CoreCLICommandConfig from @pikku/core with local middleware and render types.
|
||||
*/
|
||||
type CLICommandConfig<Func extends PikkuFunctionConfig<In, Out, 'cli' | 'rpc' | 'session'>, In = any, Out = any, Params extends string = string> = CoreCLICommandConfig<Func, PikkuMiddleware, PikkuCLIRender<any>, Params>
|
||||
|
||||
/**
|
||||
* Type definition for CLI applications with commands and global options.
|
||||
*
|
||||
* @template Commands - Type describing the command structure
|
||||
* @template GlobalOptions - Type for global CLI options
|
||||
*/
|
||||
type CLIWiring<Commands extends Record<string, CoreCLICommandConfig<any, PikkuMiddleware, PikkuCLIRender<any>, any>>, GlobalOptions> = CoreCLI<Commands, GlobalOptions, PikkuMiddleware, PikkuCLIRender<any>>
|
||||
|
||||
/**
|
||||
* Registers a CLI application with the Pikku framework.
|
||||
* Creates command-line interfaces with type-safe commands and options.
|
||||
*
|
||||
* @template Commands - Type describing the command structure
|
||||
* @template GlobalOptions - Type for global CLI options
|
||||
* @param cli - CLI definition with program name, commands, and global options
|
||||
*/
|
||||
export const wireCLI = <Commands extends Record<string, CoreCLICommandConfig<any, PikkuMiddleware, PikkuCLIRender<any>, any>>, GlobalOptions>(
|
||||
cli: CLIWiring<Commands, GlobalOptions>
|
||||
) => {
|
||||
wireCLICore(cli as any)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a CLI command definition with automatic option inference from the function's input type.
|
||||
* This allows TypeScript to automatically derive CLI options from the function signature.
|
||||
*
|
||||
* @template FuncConfig - The Pikku function config type
|
||||
* @template Params - The parameters string literal type
|
||||
* @param config - CLI command configuration
|
||||
* @returns CLI command configuration with inferred types
|
||||
*/
|
||||
export const pikkuCLICommand = <
|
||||
FuncConfig extends PikkuFunctionConfig<any, any, 'cli' | 'rpc' | 'session'>,
|
||||
Params extends string
|
||||
>(
|
||||
config: CLICommandConfig<FuncConfig, any, any, Params>
|
||||
): CoreCLICommandConfig<FuncConfig, PikkuMiddleware, PikkuCLIRender<any>, string> => {
|
||||
return config as any
|
||||
}
|
||||
|
||||
/**
|
||||
* Type-safe helper for defining CLI commands that can be composed and spread into wireCLI.
|
||||
*
|
||||
* @template T - Record of CLI command configurations
|
||||
* @param commands - The CLI commands record
|
||||
* @returns The same commands record (identity function for type safety)
|
||||
*/
|
||||
export const defineCLICommands = <T extends Record<string, CoreCLICommandConfig<any, PikkuMiddleware, PikkuCLIRender<any>, any>>>(
|
||||
commands: T
|
||||
): T => {
|
||||
return defineCLICommandsCore(commands as any) as T
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
import type { FlattenedRPCMap } from '../rpc/pikku-rpc-wirings-map.internal.gen.js'
|
||||
|
||||
export type NodeCategory = never
|
||||
|
||||
export type NodeRPCName = keyof FlattenedRPCMap
|
||||
@@ -0,0 +1,709 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
/**
|
||||
* Core function, middleware, and permission types for all wirings
|
||||
*/
|
||||
|
||||
import type { CorePikkuMiddleware, CorePermissionGroup, ListInput, ListOutput, PikkuWire, PickRequired } from '@pikku/core'
|
||||
import type { CorePikkuFunctionConfig, CorePikkuAuth, CorePikkuAuthConfig, CorePikkuPermission } from '@pikku/core/function'
|
||||
import { pikkuAuth as pikkuAuthCore } from '@pikku/core/function'
|
||||
import {
|
||||
addTagMiddleware as addTagMiddlewareCore,
|
||||
addGlobalMiddleware as addGlobalMiddlewareCore,
|
||||
addTagPermission as addTagPermissionCore,
|
||||
addGlobalPermission as addGlobalPermissionCore,
|
||||
} from '@pikku/core/middleware'
|
||||
import { pikkuState as __pikkuState, CreateWireServices } from '@pikku/core/internal'
|
||||
import type { NodeType } from '@pikku/core/node'
|
||||
import type { StandardSchemaV1 } from '@standard-schema/spec'
|
||||
import { CorePikkuFunction, CorePikkuFunctionSessionless } from '@pikku/core/function'
|
||||
|
||||
import type { UserSession } from '../../../../src/application-types.d.js'
|
||||
import type { SingletonServices } from '../../../../src/application-types.d.js'
|
||||
import type { Services } from '../../../../src/application-types.d.js'
|
||||
import type { Config } from '../../../../src/application-types.d.js'
|
||||
import type { TypedPikkuRPC, FlattenedRPCMap } from '../rpc/pikku-rpc-wirings-map.internal.gen.d.js'
|
||||
import type { RequiredSingletonServices, RequiredWireServices } from '../pikku-services.gen.js'
|
||||
import type { TypedWorkflow } from '../workflow/pikku-workflow-types.gen.js'
|
||||
|
||||
export type { SingletonServices as SingletonServices }
|
||||
export type { Services as Services }
|
||||
export type Session = UserSession
|
||||
|
||||
|
||||
/**
|
||||
* Inline node configuration for function definitions.
|
||||
*/
|
||||
export type NodeConfig = {
|
||||
displayName: string
|
||||
category: string
|
||||
type: NodeType
|
||||
errorOutput?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Type-safe API permission definition that integrates with your application's session type.
|
||||
* Use this to define authorization logic for your API endpoints.
|
||||
*
|
||||
* @template In - The input type that the permission check will receive
|
||||
* @template RequiredServices - The services required for this permission check
|
||||
*/
|
||||
export type PikkuPermission<In = unknown, RequiredServices extends Services = Services> = CorePikkuPermission<In, RequiredServices, PikkuWire<In, never, false, Session>>
|
||||
|
||||
/**
|
||||
* Type-safe middleware definition that can access your application's services and session.
|
||||
* Use this to define reusable middleware that can be applied to multiple wirings.
|
||||
*
|
||||
* @template RequiredServices - The services required for this middleware
|
||||
*/
|
||||
export type PikkuMiddleware<RequiredServices extends SingletonServices = SingletonServices> = CorePikkuMiddleware<RequiredServices>
|
||||
|
||||
/**
|
||||
* Configuration object for creating a permission with metadata
|
||||
*/
|
||||
export type PikkuPermissionConfig<In = unknown, RequiredServices extends Services = Services> = {
|
||||
/** The permission function */
|
||||
func: PikkuPermission<In, RequiredServices>
|
||||
/** Optional human-readable name for the permission */
|
||||
name?: string
|
||||
/** Optional description of what the permission checks */
|
||||
description?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory function for creating permissions with tree-shaking support.
|
||||
* Supports both direct function and configuration object syntax.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* // Direct function syntax
|
||||
* const permission = pikkuPermission(async ({ logger }, data, { session }) => {
|
||||
* const session = await session?.get()
|
||||
* return session?.role === 'admin'
|
||||
* })
|
||||
*
|
||||
* // Configuration object syntax with metadata
|
||||
* const adminPermission = pikkuPermission({
|
||||
* name: 'Admin Permission',
|
||||
* description: 'Checks if user has admin role',
|
||||
* func: async ({ logger }, data, { session }) => {
|
||||
* const session = await session?.get()
|
||||
* return session?.role === 'admin'
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
export const pikkuPermission = <In>(
|
||||
permission: PikkuPermission<In> | PikkuPermissionConfig<In>
|
||||
): PikkuPermission<In> => {
|
||||
return typeof permission === 'function' ? permission : permission.func
|
||||
}
|
||||
|
||||
/**
|
||||
* Type-safe auth-only permission that only needs services and session.
|
||||
* Use this for upfront authorization gates (MCP tools, AI agents, workflows)
|
||||
* where request data isn't available yet.
|
||||
*
|
||||
* @template RequiredServices - The services required for this auth check
|
||||
*/
|
||||
export type PikkuAuth<RequiredServices extends SingletonServices = SingletonServices> = CorePikkuAuth<RequiredServices, Session>
|
||||
|
||||
/**
|
||||
* Configuration object for creating an auth permission with metadata
|
||||
*/
|
||||
export type PikkuAuthConfig<RequiredServices extends SingletonServices = SingletonServices> = CorePikkuAuthConfig<RequiredServices, Session>
|
||||
|
||||
/**
|
||||
* Factory function for creating auth-only permissions with tree-shaking support.
|
||||
* Auth permissions only receive services and session (no request data),
|
||||
* making them evaluable before request data is available.
|
||||
*
|
||||
* @example
|
||||
* \`\`\`typescript
|
||||
* const isAuthenticated = pikkuAuth(async ({ logger }, session) => {
|
||||
* return !!session
|
||||
* })
|
||||
*
|
||||
* const isAdmin = pikkuAuth({
|
||||
* name: 'Admin Auth',
|
||||
* description: 'Checks if user is an admin',
|
||||
* func: async ({ logger }, session) => {
|
||||
* return session?.role === 'admin'
|
||||
* }
|
||||
* })
|
||||
* \`\`\`
|
||||
*/
|
||||
export const pikkuAuth = <RequiredServices extends SingletonServices = SingletonServices>(
|
||||
auth: PikkuAuth<RequiredServices> | PikkuAuthConfig<RequiredServices>
|
||||
): PikkuPermission<any, any> => {
|
||||
return pikkuAuthCore(auth as any) as any
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration object for creating middleware with metadata
|
||||
*/
|
||||
export type PikkuMiddlewareConfig<RequiredServices extends SingletonServices = SingletonServices> = {
|
||||
/** The middleware function */
|
||||
func: PikkuMiddleware<RequiredServices>
|
||||
/** Optional human-readable name for the middleware */
|
||||
name?: string
|
||||
/** Optional description of what the middleware does */
|
||||
description?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory function for creating middleware with tree-shaking support.
|
||||
* Supports both direct function and configuration object syntax.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* // Direct function syntax
|
||||
* const middleware = pikkuMiddleware(({ logger }, wires, next) => {
|
||||
* logger.info('Middleware executed')
|
||||
* await next()
|
||||
* })
|
||||
*
|
||||
* // Configuration object syntax with metadata
|
||||
* const logMiddleware = pikkuMiddleware({
|
||||
* name: 'Request Logger',
|
||||
* description: 'Logs all incoming requests',
|
||||
* func: async ({ logger }, wires, next) => {
|
||||
* logger.info('Request started')
|
||||
* await next()
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
export const pikkuMiddleware = <RequiredServices extends SingletonServices = SingletonServices>(
|
||||
middleware: PikkuMiddleware<RequiredServices> | PikkuMiddlewareConfig<RequiredServices>
|
||||
): PikkuMiddleware<RequiredServices> => {
|
||||
return typeof middleware === 'function' ? middleware : middleware.func
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory function for creating middleware factories
|
||||
* Use this when your middleware needs configuration/input parameters
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* export const logMiddleware = pikkuMiddlewareFactory<LogOptions>(({
|
||||
* message,
|
||||
* level = 'info'
|
||||
* }) => {
|
||||
* return pikkuMiddleware(async ({ logger }, next) => {
|
||||
* logger[level](message)
|
||||
* await next()
|
||||
* })
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
export const pikkuMiddlewareFactory = <In = any>(
|
||||
factory: (input: In) => PikkuMiddleware
|
||||
): ((input: In) => PikkuMiddleware) => {
|
||||
return factory
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory function for creating permission factories
|
||||
* Use this when your permission needs configuration/input parameters
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* export const requireRole = pikkuPermissionFactory<{ role: string }>(({
|
||||
* role
|
||||
* }) => {
|
||||
* return pikkuPermission(async ({ logger }, data, { session }) => {
|
||||
* if (!session || session.role !== role) {
|
||||
* logger.warn(`Permission denied: required role '${role}'`)
|
||||
* return false
|
||||
* }
|
||||
* return true
|
||||
* })
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
export const pikkuPermissionFactory = <In = any>(
|
||||
factory: (input: In) => PikkuPermission<any>
|
||||
): ((input: In) => PikkuPermission<any>) => {
|
||||
return factory
|
||||
}
|
||||
|
||||
/**
|
||||
* A function that generates a human-readable description of a pending approval action.
|
||||
* Used by AI agents to show meaningful approval prompts instead of raw tool arguments.
|
||||
*
|
||||
* @template In - The input type (same as the function it describes)
|
||||
* @template RequiredServices - The services required for this description function
|
||||
*/
|
||||
export type PikkuApprovalDescription<In = unknown, RequiredServices extends Services = Services> = (
|
||||
services: RequiredServices,
|
||||
data: In
|
||||
) => Promise<string>
|
||||
|
||||
/**
|
||||
* Factory function for creating approval description functions with tree-shaking support.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* export const deleteTodoApproval = pikkuApprovalDescription(
|
||||
* async ({ todoStore }, { id }) => {
|
||||
* const todo = await todoStore.get(id)
|
||||
* return \`Delete todo: "${todo.title}"\`
|
||||
* }
|
||||
* )
|
||||
* ```
|
||||
*/
|
||||
export const pikkuApprovalDescription = <In = unknown, RequiredServices extends Services = Services>(
|
||||
fn: PikkuApprovalDescription<In, RequiredServices>
|
||||
): PikkuApprovalDescription<In, RequiredServices> => {
|
||||
return fn
|
||||
}
|
||||
|
||||
/**
|
||||
* A sessionless API function that doesn't require user authentication.
|
||||
* Use this for public endpoints, health checks, or operations that don't need user context.
|
||||
*
|
||||
* @template In - The input type
|
||||
* @template Out - The output type that the function returns
|
||||
* @template RequiredServices - Services required by this function
|
||||
*/
|
||||
export type PikkuFunctionSessionless<
|
||||
In = unknown,
|
||||
Out = never,
|
||||
RequiredWires extends keyof PikkuWire = never,
|
||||
RequiredServices extends Services = Services
|
||||
> = CorePikkuFunctionSessionless<
|
||||
In,
|
||||
Out,
|
||||
RequiredServices,
|
||||
Session,
|
||||
PickRequired<PikkuWire<In, Out, false, Session, TypedPikkuRPC, null, any, TypedWorkflow>, RequiredWires>
|
||||
>
|
||||
|
||||
/**
|
||||
* A session-aware API function that requires user authentication.
|
||||
* Use this for protected endpoints that need access to user session data.
|
||||
*
|
||||
* @template In - The input type
|
||||
* @template Out - The output type that the function returns
|
||||
* @template RequiredServices - Services required by this function
|
||||
*/
|
||||
export type PikkuFunction<
|
||||
In = unknown,
|
||||
Out = never,
|
||||
RequiredWires extends keyof PikkuWire = 'session',
|
||||
RequiredServices extends Services = Services
|
||||
> = CorePikkuFunction<
|
||||
In,
|
||||
Out,
|
||||
RequiredServices,
|
||||
Session,
|
||||
PickRequired<PikkuWire<In, Out, true, Session, TypedPikkuRPC, null, any, TypedWorkflow>, RequiredWires>
|
||||
>
|
||||
|
||||
/**
|
||||
* Helper type to infer the output type from a Standard Schema
|
||||
*/
|
||||
export type InferSchemaOutput<T> = T extends StandardSchemaV1<any, infer Output> ? Output : never
|
||||
|
||||
/**
|
||||
* Configuration object for Pikku functions with optional middleware, permissions, tags, and documentation.
|
||||
* This type wraps CorePikkuFunctionConfig with the user's custom types.
|
||||
*
|
||||
* @template In - The input type
|
||||
* @template Out - The output type
|
||||
* @template PikkuFunc - The function type (can be narrowed to PikkuFunction or PikkuFunctionSessionless)
|
||||
*/
|
||||
export type PikkuFunctionConfig<
|
||||
In = unknown,
|
||||
Out = unknown,
|
||||
RequiredWires extends keyof PikkuWire = never,
|
||||
PikkuFunc extends PikkuFunction<In, Out, RequiredWires> | PikkuFunctionSessionless<In, Out, RequiredWires> = PikkuFunction<In, Out, RequiredWires> | PikkuFunctionSessionless<In, Out, RequiredWires>,
|
||||
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
||||
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
||||
> = CorePikkuFunctionConfig<PikkuFunc, PikkuPermission<In>, PikkuMiddleware, InputSchema, OutputSchema>
|
||||
|
||||
/**
|
||||
* Configuration object for Pikku functions with Zod schema validation.
|
||||
* Use this when you want to define input/output schemas using Zod.
|
||||
* Types are automatically inferred from the schemas.
|
||||
*/
|
||||
type SchemaInferred<S, Fallback = unknown> = S extends StandardSchemaV1
|
||||
? InferSchemaOutput<S>
|
||||
: Fallback
|
||||
|
||||
/**
|
||||
* Schema-overload variant for pikkuFunc. Derived from CorePikkuFunctionConfig
|
||||
* so adding a field on the core type automatically propagates here.
|
||||
*/
|
||||
export type PikkuFunctionConfigWithSchema<
|
||||
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
||||
OutputSchema extends StandardSchemaV1 | undefined = undefined,
|
||||
RequiredWires extends keyof PikkuWire = never
|
||||
> = Omit<
|
||||
CorePikkuFunctionConfig<
|
||||
| PikkuFunction<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires>
|
||||
| PikkuFunctionSessionless<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires>
|
||||
>,
|
||||
'func' | 'input' | 'output' | 'permissions' | 'approvalDescription'
|
||||
> & {
|
||||
func:
|
||||
| PikkuFunction<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires>
|
||||
| PikkuFunctionSessionless<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires>
|
||||
input?: InputSchema
|
||||
output?: OutputSchema
|
||||
permissions?: InputSchema extends StandardSchemaV1
|
||||
? CorePermissionGroup<PikkuPermission<InferSchemaOutput<InputSchema>>>
|
||||
: undefined
|
||||
approvalDescription?: InputSchema extends StandardSchemaV1
|
||||
? PikkuApprovalDescription<InferSchemaOutput<InputSchema>>
|
||||
: never
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Pikku function that can be either session-aware or sessionless.
|
||||
* This is the main function wrapper for creating API endpoints.
|
||||
*
|
||||
* Supports two patterns:
|
||||
* 1. Generic types: `pikkuFunc<Input, Output>({ func: ... })`
|
||||
* 2. Zod schemas: `pikkuFunc({ input: z.object(...), output: z.object(...), func: ... })`
|
||||
*
|
||||
* @template In - Input type for the function (inferred from schema if provided)
|
||||
* @template Out - Output type for the function (inferred from schema if provided)
|
||||
* @param func - Function definition, either direct function or configuration object
|
||||
* @returns The normalized configuration object
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* // Pattern 1: Using generic types
|
||||
* const createUser = pikkuFunc<{name: string, email: string}, {id: number}>({
|
||||
* func: async ({db}, input) => {
|
||||
* const user = await db.users.create(input)
|
||||
* return { id: user.id }
|
||||
* }
|
||||
* })
|
||||
*
|
||||
* // Pattern 2: Using Zod schemas (types inferred automatically)
|
||||
* const createUserInput = z.object({ name: z.string(), email: z.string() })
|
||||
* const createUserOutput = z.object({ id: z.number() })
|
||||
*
|
||||
* const createUser = pikkuFunc({
|
||||
* input: createUserInput,
|
||||
* output: createUserOutput,
|
||||
* func: async ({db}, input) => {
|
||||
* // input is typed as { name: string, email: string }
|
||||
* const user = await db.users.create(input)
|
||||
* return { id: user.id } // must match output schema
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
export function pikkuFunc<
|
||||
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
||||
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
||||
>(
|
||||
config: PikkuFunctionConfigWithSchema<InputSchema, OutputSchema, 'session' | 'rpc'>
|
||||
): PikkuFunctionConfig<InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown, 'session' | 'rpc'>
|
||||
export function pikkuFunc<In, Out = unknown>(
|
||||
func:
|
||||
| PikkuFunction<In, Out, 'session' | 'rpc'>
|
||||
| PikkuFunctionConfig<In, Out, 'session' | 'rpc'>
|
||||
): PikkuFunctionConfig<In, Out, 'session' | 'rpc'>
|
||||
export function pikkuFunc(func: any) {
|
||||
return typeof func === 'function' ? { func } : func
|
||||
}
|
||||
|
||||
export type PikkuListFunction<
|
||||
F extends Record<string, unknown> = {},
|
||||
Row = unknown,
|
||||
S extends string = never
|
||||
> =
|
||||
| PikkuFunction<ListInput<F, S>, ListOutput<Row>, 'session' | 'rpc'>
|
||||
| PikkuFunctionSessionless<
|
||||
ListInput<F, S>,
|
||||
ListOutput<Row>,
|
||||
'session' | 'rpc'
|
||||
>
|
||||
|
||||
export const pikkuListFunc = <
|
||||
F extends Record<string, unknown> = {},
|
||||
Row = unknown,
|
||||
S extends string = never
|
||||
>(
|
||||
config: PikkuFunctionConfig<
|
||||
ListInput<F, S>,
|
||||
ListOutput<Row>,
|
||||
'session' | 'rpc'
|
||||
>
|
||||
): PikkuFunctionConfig<ListInput<F, S>, ListOutput<Row>, 'session' | 'rpc'> => {
|
||||
return pikkuFunc(config)
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration object for sessionless Pikku functions with Zod schema validation.
|
||||
*/
|
||||
/**
|
||||
* Schema-overload variant for pikkuSessionlessFunc. Derived from
|
||||
* CorePikkuFunctionConfig to stay in sync with the generic-typed config.
|
||||
*/
|
||||
export type PikkuFunctionSessionlessConfigWithSchema<
|
||||
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
||||
OutputSchema extends StandardSchemaV1 | undefined = undefined,
|
||||
RequiredWires extends keyof PikkuWire = never
|
||||
> = Omit<
|
||||
CorePikkuFunctionConfig<
|
||||
PikkuFunctionSessionless<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires>
|
||||
>,
|
||||
'func' | 'input' | 'output' | 'permissions' | 'approvalDescription'
|
||||
> & {
|
||||
func: PikkuFunctionSessionless<
|
||||
SchemaInferred<InputSchema>,
|
||||
SchemaInferred<OutputSchema>,
|
||||
RequiredWires
|
||||
>
|
||||
input?: InputSchema
|
||||
output?: OutputSchema
|
||||
permissions?: InputSchema extends StandardSchemaV1
|
||||
? CorePermissionGroup<PikkuPermission<InferSchemaOutput<InputSchema>>>
|
||||
: undefined
|
||||
approvalDescription?: InputSchema extends StandardSchemaV1
|
||||
? PikkuApprovalDescription<InferSchemaOutput<InputSchema>>
|
||||
: never
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a sessionless Pikku function that doesn't require user authentication.
|
||||
* Use this for public endpoints, webhooks, or background tasks.
|
||||
*
|
||||
* Supports two patterns:
|
||||
* 1. Generic types: `pikkuSessionlessFunc<Input, Output>({ func: ... })`
|
||||
* 2. Zod schemas: `pikkuSessionlessFunc({ input: z.object(...), func: ... })`
|
||||
*
|
||||
* @template In - Input type for the function (inferred from schema if provided)
|
||||
* @template Out - Output type for the function (inferred from schema if provided)
|
||||
* @param func - Function definition, either direct function or configuration object
|
||||
* @returns The normalized configuration object
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* // Pattern 1: Using generic types
|
||||
* const healthCheck = pikkuSessionlessFunc<void, {status: string}>({
|
||||
* func: async ({logger}) => {
|
||||
* return { status: 'healthy' }
|
||||
* }
|
||||
* })
|
||||
*
|
||||
* // Pattern 2: Using Zod schemas
|
||||
* const greetInput = z.object({ name: z.string() })
|
||||
* const greetOutput = z.object({ message: z.string() })
|
||||
*
|
||||
* const greet = pikkuSessionlessFunc({
|
||||
* input: greetInput,
|
||||
* output: greetOutput,
|
||||
* func: async (_services, { name }) => {
|
||||
* return { message: `Hello, ${name}!` }
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
export function pikkuSessionlessFunc<
|
||||
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
||||
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
||||
>(
|
||||
config: PikkuFunctionSessionlessConfigWithSchema<InputSchema, OutputSchema, 'session' | 'rpc'>
|
||||
): PikkuFunctionConfig<InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown, 'session' | 'rpc'>
|
||||
export function pikkuSessionlessFunc<In, Out = unknown>(
|
||||
func:
|
||||
| PikkuFunctionSessionless<In, Out, 'session' | 'rpc'>
|
||||
| PikkuFunctionConfig<In, Out, 'session' | 'rpc'>
|
||||
): PikkuFunctionConfig<In, Out, 'session' | 'rpc'>
|
||||
export function pikkuSessionlessFunc(func: any) {
|
||||
return typeof func === 'function' ? { func } : func
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function that takes no input and returns no output.
|
||||
* Useful for health checks, triggers, or cleanup operations.
|
||||
*
|
||||
* @param func - Function definition, either direct function or configuration object
|
||||
* @returns The normalized configuration object
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const cleanupTempFiles = pikkuVoidFunc(async ({fileSystem, logger}) => {
|
||||
* logger.info('Starting cleanup of temporary files')
|
||||
* await fileSystem.deleteDirectory('/tmp/uploads')
|
||||
* logger.info('Cleanup completed')
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
export const pikkuVoidFunc = (
|
||||
func:
|
||||
| PikkuFunctionSessionless<void, void, 'session' | 'rpc'>
|
||||
| PikkuFunctionConfig<void, void, 'session' | 'rpc'>
|
||||
) => {
|
||||
return typeof func === 'function' ? { func } : func
|
||||
}
|
||||
|
||||
/**
|
||||
* References a registered function by name for use in any wiring.
|
||||
* Works for both local and addon functions — resolves via RPC at runtime.
|
||||
*
|
||||
* @template Name - The function name (must be a key in FlattenedRPCMap)
|
||||
* @param rpcName - The name of the function to reference
|
||||
* @returns A Pikku function config that proxies calls via RPC
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* // Use in agent tools
|
||||
* tools: [ref('todos:listTodos'), ref('myLocalFunc')]
|
||||
*
|
||||
* // Use in HTTP wiring
|
||||
* wireHTTP({ route: '/greet', method: 'post', func: ref('greet') })
|
||||
* ```
|
||||
*/
|
||||
export const ref = <Name extends keyof FlattenedRPCMap>(
|
||||
rpcName: Name
|
||||
): PikkuFunctionConfig<
|
||||
FlattenedRPCMap[Name]['input'],
|
||||
FlattenedRPCMap[Name]['output'],
|
||||
'session' | 'rpc'
|
||||
> => {
|
||||
return {
|
||||
func: async (_services: any, data: FlattenedRPCMap[Name]['input'], { rpc }: any) => {
|
||||
return rpc.invoke(rpcName, data)
|
||||
}
|
||||
} as PikkuFunctionConfig<
|
||||
FlattenedRPCMap[Name]['input'],
|
||||
FlattenedRPCMap[Name]['output'],
|
||||
'session' | 'rpc'
|
||||
>
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Pikku config factory.
|
||||
* Use this to define your application's configuration factory.
|
||||
*
|
||||
* @param func - Config factory function that returns your application's config
|
||||
* @returns The config factory function
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* export const createConfig = pikkuConfig(async () => {
|
||||
* return {
|
||||
* apiUrl: process.env.API_URL || 'http://localhost:3000',
|
||||
* dbUrl: process.env.DATABASE_URL
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
export const pikkuConfig = (
|
||||
func: (variables?: any, ...args: any[]) => Promise<Config>
|
||||
) => func
|
||||
|
||||
|
||||
/**
|
||||
* Creates a Pikku singleton services factory.
|
||||
* Use this to define services that are created once and shared across all requests.
|
||||
*
|
||||
* @param func - Singleton services factory function
|
||||
* @returns The singleton services factory function
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* export const createSingletonServices = pikkuServices(async (config, existingServices) => {
|
||||
* return {
|
||||
* config,
|
||||
* logger: new CustomLogger(),
|
||||
* db: await createDatabaseConnection(config.dbUrl)
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
export const pikkuServices = (
|
||||
func: (config: Config, existingServices: Partial<SingletonServices>) => Promise<RequiredSingletonServices>
|
||||
) => {
|
||||
return async (config: Config, existingServices: Partial<SingletonServices> = {}) => {
|
||||
const services = await func(config, existingServices)
|
||||
__pikkuState(null, 'package', 'singletonServices', services as any)
|
||||
return services
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Pikku wire services factory.
|
||||
* Use this to define services that are created per-request/session.
|
||||
*
|
||||
* @param func - Wire services factory function
|
||||
* @returns The wire services factory function
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* export const createWireServices = pikkuWireServices(async (services, wire) => {
|
||||
* const session = await wire.session?.get()
|
||||
* return {
|
||||
* userCache: new UserCache(session?.userId)
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
export const pikkuWireServices = (
|
||||
func: (
|
||||
services: SingletonServices,
|
||||
wire: any
|
||||
) => Promise<RequiredWireServices>
|
||||
): CreateWireServices => {
|
||||
const factories = __pikkuState(null, 'package', 'factories')
|
||||
__pikkuState(null, 'package', 'factories', { ...factories, createWireServices: func as any })
|
||||
return func as unknown as CreateWireServices
|
||||
}
|
||||
|
||||
/**
|
||||
* Tag-scoped middleware. Applies to any wiring that carries the matching tag.
|
||||
*
|
||||
* @example
|
||||
* addTagMiddleware('admin', [adminMiddleware])
|
||||
*/
|
||||
export const addTagMiddleware = (tag: string, middleware: PikkuMiddleware[]) => {
|
||||
addTagMiddlewareCore(tag, middleware as any, null)
|
||||
}
|
||||
|
||||
/**
|
||||
* Wire-agnostic global middleware. Runs at the top of every wiring's
|
||||
* middleware chain — before wire-, tag-, and function-level entries.
|
||||
*
|
||||
* Resolution order: global -> wire -> tag -> function.
|
||||
*
|
||||
* @example
|
||||
* addGlobalMiddleware([telemetryMiddleware])
|
||||
*/
|
||||
export const addGlobalMiddleware = (middleware: PikkuMiddleware[]) => {
|
||||
addGlobalMiddlewareCore(middleware as any, null)
|
||||
}
|
||||
|
||||
/**
|
||||
* Tag-scoped permissions. Applies to any wiring that carries the matching tag.
|
||||
*
|
||||
* @example
|
||||
* addTagPermission('admin', [adminPermission])
|
||||
*/
|
||||
export const addTagPermission = <In = unknown>(tag: string, permissions: CorePermissionGroup<PikkuPermission<In>> | PikkuPermission<In>[]) => {
|
||||
addTagPermissionCore(tag, permissions as any, null)
|
||||
}
|
||||
|
||||
/**
|
||||
* Wire-agnostic global permissions. Runs at the top of every wiring's
|
||||
* permission resolution — before wire-, tag-, and function-level entries.
|
||||
*
|
||||
* Resolution order: global -> wire -> tag -> function.
|
||||
*
|
||||
* @example
|
||||
* addGlobalPermission([signedInUser])
|
||||
*/
|
||||
export const addGlobalPermission = <In = unknown>(permissions: CorePermissionGroup<PikkuPermission<In>> | PikkuPermission<In>[]) => {
|
||||
addGlobalPermissionCore(permissions as any, null)
|
||||
}
|
||||
|
||||
export { wireAddon } from '@pikku/core/rpc'
|
||||
export type { WireAddonConfig } from '@pikku/core/rpc'
|
||||
@@ -0,0 +1,728 @@
|
||||
{
|
||||
"pikkuConsoleSetSecret": {
|
||||
"pikkuFuncId": "pikkuConsoleSetSecret",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "pikkuConsoleSetSecret",
|
||||
"services": {
|
||||
"optimized": true,
|
||||
"services": [
|
||||
"secrets"
|
||||
]
|
||||
},
|
||||
"inputSchemaName": "PikkuConsoleSetSecretInput",
|
||||
"outputSchemaName": "PikkuConsoleSetSecretOutput",
|
||||
"inputs": [
|
||||
"PikkuConsoleSetSecretInput"
|
||||
],
|
||||
"outputs": [
|
||||
"PikkuConsoleSetSecretOutput"
|
||||
],
|
||||
"expose": true,
|
||||
"implementationHash": "c33e04e6aff5ca2e",
|
||||
"tags": [
|
||||
"pikku"
|
||||
],
|
||||
"description": "Set the value of a secret",
|
||||
"isDirectFunction": false,
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/console.gen.ts",
|
||||
"exportedName": "pikkuConsoleSetSecret",
|
||||
"contractHash": "fcb625d86fe88b8f",
|
||||
"inputHash": "a0c8a043",
|
||||
"outputHash": "57702b41"
|
||||
},
|
||||
"pikkuConsoleGetVariable": {
|
||||
"pikkuFuncId": "pikkuConsoleGetVariable",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "pikkuConsoleGetVariable",
|
||||
"services": {
|
||||
"optimized": true,
|
||||
"services": [
|
||||
"variables"
|
||||
]
|
||||
},
|
||||
"inputSchemaName": "PikkuConsoleGetVariableInput",
|
||||
"outputSchemaName": "PikkuConsoleGetVariableOutput",
|
||||
"inputs": [
|
||||
"PikkuConsoleGetVariableInput"
|
||||
],
|
||||
"outputs": [
|
||||
"PikkuConsoleGetVariableOutput"
|
||||
],
|
||||
"expose": true,
|
||||
"implementationHash": "45c792dfb6f8b1a5",
|
||||
"tags": [
|
||||
"pikku"
|
||||
],
|
||||
"description": "Get the current value of a variable",
|
||||
"isDirectFunction": false,
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/console.gen.ts",
|
||||
"exportedName": "pikkuConsoleGetVariable",
|
||||
"contractHash": "3b66dda4d82fa48a",
|
||||
"inputHash": "ce4b2e06",
|
||||
"outputHash": "f54f1059"
|
||||
},
|
||||
"pikkuConsoleSetVariable": {
|
||||
"pikkuFuncId": "pikkuConsoleSetVariable",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "pikkuConsoleSetVariable",
|
||||
"services": {
|
||||
"optimized": true,
|
||||
"services": [
|
||||
"variables"
|
||||
]
|
||||
},
|
||||
"inputSchemaName": "PikkuConsoleSetVariableInput",
|
||||
"outputSchemaName": "PikkuConsoleSetVariableOutput",
|
||||
"inputs": [
|
||||
"PikkuConsoleSetVariableInput"
|
||||
],
|
||||
"outputs": [
|
||||
"PikkuConsoleSetVariableOutput"
|
||||
],
|
||||
"expose": true,
|
||||
"implementationHash": "f6806d8dc9d50055",
|
||||
"tags": [
|
||||
"pikku"
|
||||
],
|
||||
"description": "Set the value of a variable",
|
||||
"isDirectFunction": false,
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/console.gen.ts",
|
||||
"exportedName": "pikkuConsoleSetVariable",
|
||||
"contractHash": "9dda40633b173a08",
|
||||
"inputHash": "d91a4af5",
|
||||
"outputHash": "91fe907b"
|
||||
},
|
||||
"pikkuConsoleHasSecret": {
|
||||
"pikkuFuncId": "pikkuConsoleHasSecret",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "pikkuConsoleHasSecret",
|
||||
"services": {
|
||||
"optimized": true,
|
||||
"services": [
|
||||
"secrets"
|
||||
]
|
||||
},
|
||||
"inputSchemaName": "PikkuConsoleHasSecretInput",
|
||||
"outputSchemaName": "PikkuConsoleHasSecretOutput",
|
||||
"inputs": [
|
||||
"PikkuConsoleHasSecretInput"
|
||||
],
|
||||
"outputs": [
|
||||
"PikkuConsoleHasSecretOutput"
|
||||
],
|
||||
"expose": true,
|
||||
"implementationHash": "b8c818fb2291b032",
|
||||
"tags": [
|
||||
"pikku"
|
||||
],
|
||||
"description": "Check if a secret exists without reading its value",
|
||||
"isDirectFunction": false,
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/console.gen.ts",
|
||||
"exportedName": "pikkuConsoleHasSecret",
|
||||
"contractHash": "eeff751c00461679",
|
||||
"inputHash": "a67adc7c",
|
||||
"outputHash": "1da66eac"
|
||||
},
|
||||
"pikkuConsoleGetSecret": {
|
||||
"pikkuFuncId": "pikkuConsoleGetSecret",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "pikkuConsoleGetSecret",
|
||||
"services": {
|
||||
"optimized": true,
|
||||
"services": [
|
||||
"secrets"
|
||||
]
|
||||
},
|
||||
"inputSchemaName": "PikkuConsoleGetSecretInput",
|
||||
"outputSchemaName": "PikkuConsoleGetSecretOutput",
|
||||
"inputs": [
|
||||
"PikkuConsoleGetSecretInput"
|
||||
],
|
||||
"outputs": [
|
||||
"PikkuConsoleGetSecretOutput"
|
||||
],
|
||||
"expose": true,
|
||||
"implementationHash": "5c1e39a4b0cc46a1",
|
||||
"tags": [
|
||||
"pikku"
|
||||
],
|
||||
"description": "Get the current value of a secret",
|
||||
"isDirectFunction": false,
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/console.gen.ts",
|
||||
"exportedName": "pikkuConsoleGetSecret",
|
||||
"contractHash": "d651ad93642eaeed",
|
||||
"inputHash": "329251da",
|
||||
"outputHash": "fb675a26"
|
||||
},
|
||||
"http:get:/workflow-run/:runId/stream": {
|
||||
"pikkuFuncId": "http:get:/workflow-run/:runId/stream",
|
||||
"functionType": "inline",
|
||||
"name": "/workflow-run/:runId/stream",
|
||||
"services": {
|
||||
"optimized": false,
|
||||
"services": []
|
||||
},
|
||||
"inputSchemaName": "StreamWorkflowRunInput",
|
||||
"outputSchemaName": null,
|
||||
"inputs": [
|
||||
"StreamWorkflowRunInput"
|
||||
],
|
||||
"outputs": [],
|
||||
"contractHash": "ab85b338c10d89e8",
|
||||
"inputHash": "76838d3e",
|
||||
"outputHash": "fc2fd4a0"
|
||||
},
|
||||
"remoteRPCHandler": {
|
||||
"pikkuFuncId": "remoteRPCHandler",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "remoteRPCHandler",
|
||||
"services": {
|
||||
"optimized": true,
|
||||
"services": []
|
||||
},
|
||||
"wires": {
|
||||
"optimized": true,
|
||||
"wires": [
|
||||
"rpc"
|
||||
]
|
||||
},
|
||||
"inputSchemaName": "RemoteRPCHandlerInput",
|
||||
"outputSchemaName": null,
|
||||
"inputs": [
|
||||
"RemoteRPCHandlerInput"
|
||||
],
|
||||
"outputs": [],
|
||||
"remote": true,
|
||||
"implementationHash": "105018a823bdb551",
|
||||
"tags": [
|
||||
"pikku"
|
||||
],
|
||||
"isDirectFunction": false,
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/rpc-remote.gen.ts",
|
||||
"exportedName": "remoteRPCHandler"
|
||||
},
|
||||
"workflowStarter": {
|
||||
"pikkuFuncId": "workflowStarter",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "workflowStarter",
|
||||
"services": {
|
||||
"optimized": true,
|
||||
"services": [
|
||||
"workflowService"
|
||||
]
|
||||
},
|
||||
"wires": {
|
||||
"optimized": true,
|
||||
"wires": [
|
||||
"rpc"
|
||||
]
|
||||
},
|
||||
"inputSchemaName": "WorkflowStarterInput",
|
||||
"outputSchemaName": "WorkflowStarterOutput",
|
||||
"inputs": [
|
||||
"WorkflowStarterInput"
|
||||
],
|
||||
"outputs": [
|
||||
"WorkflowStarterOutput"
|
||||
],
|
||||
"implementationHash": "153116058265d9d4",
|
||||
"tags": [
|
||||
"pikku"
|
||||
],
|
||||
"isDirectFunction": false,
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/workflow-routes.gen.ts",
|
||||
"exportedName": "workflowStarter",
|
||||
"contractHash": "770c10618e2d471b",
|
||||
"inputHash": "73e8dfbd",
|
||||
"outputHash": "8f2061b7"
|
||||
},
|
||||
"workflowRunner": {
|
||||
"pikkuFuncId": "workflowRunner",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "workflowRunner",
|
||||
"services": {
|
||||
"optimized": true,
|
||||
"services": [
|
||||
"workflowService"
|
||||
]
|
||||
},
|
||||
"wires": {
|
||||
"optimized": true,
|
||||
"wires": [
|
||||
"rpc"
|
||||
]
|
||||
},
|
||||
"inputSchemaName": "WorkflowRunnerInput",
|
||||
"outputSchemaName": null,
|
||||
"inputs": [
|
||||
"WorkflowRunnerInput"
|
||||
],
|
||||
"outputs": [],
|
||||
"implementationHash": "4807ebd71047f932",
|
||||
"tags": [
|
||||
"pikku"
|
||||
],
|
||||
"isDirectFunction": false,
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/workflow-routes.gen.ts",
|
||||
"exportedName": "workflowRunner",
|
||||
"contractHash": "ca617784c6d9ec8d",
|
||||
"inputHash": "3c634245",
|
||||
"outputHash": "316bdb87"
|
||||
},
|
||||
"workflowStatusChecker": {
|
||||
"pikkuFuncId": "workflowStatusChecker",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "workflowStatusChecker",
|
||||
"services": {
|
||||
"optimized": true,
|
||||
"services": [
|
||||
"workflowService"
|
||||
]
|
||||
},
|
||||
"inputSchemaName": "WorkflowStatusCheckerInput",
|
||||
"outputSchemaName": "WorkflowRunStatus",
|
||||
"inputs": [
|
||||
"WorkflowStatusCheckerInput"
|
||||
],
|
||||
"outputs": [
|
||||
"WorkflowRunStatus"
|
||||
],
|
||||
"implementationHash": "e4159df9ad118a6c",
|
||||
"tags": [
|
||||
"pikku"
|
||||
],
|
||||
"isDirectFunction": false,
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/workflow-routes.gen.ts",
|
||||
"exportedName": "workflowStatusChecker",
|
||||
"contractHash": "1bb7182390464bc0",
|
||||
"inputHash": "458ba7ec",
|
||||
"outputHash": "bc4d864f"
|
||||
},
|
||||
"workflowStatusStream": {
|
||||
"pikkuFuncId": "workflowStatusStream",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "workflowStatusStream",
|
||||
"services": {
|
||||
"optimized": true,
|
||||
"services": [
|
||||
"workflowRunService"
|
||||
]
|
||||
},
|
||||
"wires": {
|
||||
"optimized": true,
|
||||
"wires": [
|
||||
"channel"
|
||||
]
|
||||
},
|
||||
"inputSchemaName": "WorkflowStatusStreamInput",
|
||||
"outputSchemaName": null,
|
||||
"inputs": [
|
||||
"WorkflowStatusStreamInput"
|
||||
],
|
||||
"outputs": [],
|
||||
"implementationHash": "233d0f04a86a4237",
|
||||
"tags": [
|
||||
"pikku"
|
||||
],
|
||||
"isDirectFunction": false,
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/workflow-routes.gen.ts",
|
||||
"exportedName": "workflowStatusStream",
|
||||
"contractHash": "3b99296ba5064030",
|
||||
"inputHash": "c6ee79ff",
|
||||
"outputHash": "6180f124"
|
||||
},
|
||||
"workflowStatusStreamFull": {
|
||||
"pikkuFuncId": "workflowStatusStreamFull",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "workflowStatusStreamFull",
|
||||
"services": {
|
||||
"optimized": true,
|
||||
"services": [
|
||||
"workflowRunService"
|
||||
]
|
||||
},
|
||||
"wires": {
|
||||
"optimized": true,
|
||||
"wires": [
|
||||
"channel"
|
||||
]
|
||||
},
|
||||
"inputSchemaName": "WorkflowStatusStreamFullInput",
|
||||
"outputSchemaName": null,
|
||||
"inputs": [
|
||||
"WorkflowStatusStreamFullInput"
|
||||
],
|
||||
"outputs": [],
|
||||
"implementationHash": "aba5bf474596ee50",
|
||||
"tags": [
|
||||
"pikku"
|
||||
],
|
||||
"isDirectFunction": false,
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/workflow-routes.gen.ts",
|
||||
"exportedName": "workflowStatusStreamFull",
|
||||
"contractHash": "1e7b9f00193d10ae",
|
||||
"inputHash": "2da90ff6",
|
||||
"outputHash": "dcd02549"
|
||||
},
|
||||
"graphStarter": {
|
||||
"pikkuFuncId": "graphStarter",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "graphStarter",
|
||||
"services": {
|
||||
"optimized": true,
|
||||
"services": [
|
||||
"workflowService"
|
||||
]
|
||||
},
|
||||
"wires": {
|
||||
"optimized": true,
|
||||
"wires": [
|
||||
"rpc"
|
||||
]
|
||||
},
|
||||
"inputSchemaName": "GraphStarterInput",
|
||||
"outputSchemaName": "GraphStarterOutput",
|
||||
"inputs": [
|
||||
"GraphStarterInput"
|
||||
],
|
||||
"outputs": [
|
||||
"GraphStarterOutput"
|
||||
],
|
||||
"implementationHash": "d12993125e177525",
|
||||
"isDirectFunction": false,
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/workflow-routes.gen.ts",
|
||||
"exportedName": "graphStarter",
|
||||
"contractHash": "422510c83dee8491",
|
||||
"inputHash": "70868669",
|
||||
"outputHash": "6f988595"
|
||||
},
|
||||
"rpcCaller": {
|
||||
"pikkuFuncId": "rpcCaller",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "rpcCaller",
|
||||
"services": {
|
||||
"optimized": true,
|
||||
"services": []
|
||||
},
|
||||
"wires": {
|
||||
"optimized": true,
|
||||
"wires": [
|
||||
"rpc"
|
||||
]
|
||||
},
|
||||
"inputSchemaName": "RpcCallerInput",
|
||||
"outputSchemaName": null,
|
||||
"inputs": [
|
||||
"RpcCallerInput"
|
||||
],
|
||||
"outputs": [],
|
||||
"implementationHash": "f92b60dda357f483",
|
||||
"tags": [
|
||||
"pikku"
|
||||
],
|
||||
"isDirectFunction": false,
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/rpc-public.gen.ts",
|
||||
"exportedName": "rpcCaller",
|
||||
"contractHash": "f6901fd233740bf4",
|
||||
"inputHash": "a69cacc4",
|
||||
"outputHash": "629e0b5a"
|
||||
},
|
||||
"agentCaller": {
|
||||
"pikkuFuncId": "agentCaller",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "agentCaller",
|
||||
"services": {
|
||||
"optimized": true,
|
||||
"services": []
|
||||
},
|
||||
"wires": {
|
||||
"optimized": true,
|
||||
"wires": [
|
||||
"rpc"
|
||||
]
|
||||
},
|
||||
"inputSchemaName": "AgentCallerInput",
|
||||
"outputSchemaName": null,
|
||||
"inputs": [
|
||||
"AgentCallerInput"
|
||||
],
|
||||
"outputs": [],
|
||||
"implementationHash": "4af198bf5bbd9bd8",
|
||||
"tags": [
|
||||
"pikku"
|
||||
],
|
||||
"isDirectFunction": false,
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/agent.gen.ts",
|
||||
"exportedName": "agentCaller",
|
||||
"contractHash": "76619abd99f23189",
|
||||
"inputHash": "4d1eddbc",
|
||||
"outputHash": "9a3af204"
|
||||
},
|
||||
"agentStreamCaller": {
|
||||
"pikkuFuncId": "agentStreamCaller",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "agentStreamCaller",
|
||||
"services": {
|
||||
"optimized": true,
|
||||
"services": []
|
||||
},
|
||||
"wires": {
|
||||
"optimized": true,
|
||||
"wires": [
|
||||
"rpc"
|
||||
]
|
||||
},
|
||||
"inputSchemaName": "AgentStreamCallerInput",
|
||||
"outputSchemaName": null,
|
||||
"inputs": [
|
||||
"AgentStreamCallerInput"
|
||||
],
|
||||
"outputs": [],
|
||||
"implementationHash": "92b3cd7c92fb3de4",
|
||||
"tags": [
|
||||
"pikku"
|
||||
],
|
||||
"isDirectFunction": false,
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/agent.gen.ts",
|
||||
"exportedName": "agentStreamCaller",
|
||||
"contractHash": "0e5c814e26d3294f",
|
||||
"inputHash": "773d4d52",
|
||||
"outputHash": "641a263e"
|
||||
},
|
||||
"agentApproveCaller": {
|
||||
"pikkuFuncId": "agentApproveCaller",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "agentApproveCaller",
|
||||
"services": {
|
||||
"optimized": true,
|
||||
"services": []
|
||||
},
|
||||
"wires": {
|
||||
"optimized": true,
|
||||
"wires": [
|
||||
"rpc"
|
||||
]
|
||||
},
|
||||
"inputSchemaName": "AgentApproveCallerInput",
|
||||
"outputSchemaName": null,
|
||||
"inputs": [
|
||||
"AgentApproveCallerInput"
|
||||
],
|
||||
"outputs": [],
|
||||
"implementationHash": "ae5d4bfb0293119a",
|
||||
"tags": [
|
||||
"pikku"
|
||||
],
|
||||
"isDirectFunction": false,
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/agent.gen.ts",
|
||||
"exportedName": "agentApproveCaller",
|
||||
"contractHash": "83a9293c4b51d65c",
|
||||
"inputHash": "f1628b7c",
|
||||
"outputHash": "ef71f08a"
|
||||
},
|
||||
"agentResumeCaller": {
|
||||
"pikkuFuncId": "agentResumeCaller",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "agentResumeCaller",
|
||||
"services": {
|
||||
"optimized": true,
|
||||
"services": []
|
||||
},
|
||||
"wires": {
|
||||
"optimized": true,
|
||||
"wires": [
|
||||
"rpc"
|
||||
]
|
||||
},
|
||||
"inputSchemaName": "AgentResumeCallerInput",
|
||||
"outputSchemaName": null,
|
||||
"inputs": [
|
||||
"AgentResumeCallerInput"
|
||||
],
|
||||
"outputs": [],
|
||||
"implementationHash": "d17ccf1259ba4a60",
|
||||
"tags": [
|
||||
"pikku"
|
||||
],
|
||||
"isDirectFunction": false,
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/agent.gen.ts",
|
||||
"exportedName": "agentResumeCaller",
|
||||
"contractHash": "0648ffb2cfa9d861",
|
||||
"inputHash": "f25b50dd",
|
||||
"outputHash": "ee89e454"
|
||||
},
|
||||
"getAgentThreads": {
|
||||
"pikkuFuncId": "getAgentThreads",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "getAgentThreads",
|
||||
"services": {
|
||||
"optimized": true,
|
||||
"services": [
|
||||
"agentRunService"
|
||||
]
|
||||
},
|
||||
"inputSchemaName": "GetAgentThreadsInput",
|
||||
"outputSchemaName": "GetAgentThreadsOutput",
|
||||
"inputs": [
|
||||
"GetAgentThreadsInput"
|
||||
],
|
||||
"outputs": [
|
||||
"GetAgentThreadsOutput"
|
||||
],
|
||||
"expose": true,
|
||||
"implementationHash": "3823f8f3911c48e2",
|
||||
"title": "Get Agent Threads",
|
||||
"tags": [
|
||||
"pikku",
|
||||
"pikku:agent"
|
||||
],
|
||||
"description": "Returns a list of AI agent threads from storage. Accepts optional filters: agentName, resourceId, limit, and offset for pagination.",
|
||||
"isDirectFunction": false,
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/agent.gen.ts",
|
||||
"exportedName": "getAgentThreads",
|
||||
"contractHash": "d629208347702d27",
|
||||
"inputHash": "41f5350c",
|
||||
"outputHash": "6598bdff"
|
||||
},
|
||||
"getAgentThreadMessages": {
|
||||
"pikkuFuncId": "getAgentThreadMessages",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "getAgentThreadMessages",
|
||||
"services": {
|
||||
"optimized": true,
|
||||
"services": [
|
||||
"agentRunService"
|
||||
]
|
||||
},
|
||||
"inputSchemaName": "GetAgentThreadMessagesInput",
|
||||
"outputSchemaName": "GetAgentThreadMessagesOutput",
|
||||
"inputs": [
|
||||
"GetAgentThreadMessagesInput"
|
||||
],
|
||||
"outputs": [
|
||||
"GetAgentThreadMessagesOutput"
|
||||
],
|
||||
"expose": true,
|
||||
"implementationHash": "dffe581287205c6e",
|
||||
"title": "Get Agent Thread Messages",
|
||||
"tags": [
|
||||
"pikku",
|
||||
"pikku:agent"
|
||||
],
|
||||
"description": "Returns all messages for a given AI agent thread, ordered by creation time.",
|
||||
"isDirectFunction": false,
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/agent.gen.ts",
|
||||
"exportedName": "getAgentThreadMessages",
|
||||
"contractHash": "44e43e96024680f3",
|
||||
"inputHash": "a158e652",
|
||||
"outputHash": "04960780"
|
||||
},
|
||||
"getAgentThreadRuns": {
|
||||
"pikkuFuncId": "getAgentThreadRuns",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "getAgentThreadRuns",
|
||||
"services": {
|
||||
"optimized": true,
|
||||
"services": [
|
||||
"agentRunService"
|
||||
]
|
||||
},
|
||||
"inputSchemaName": "GetAgentThreadRunsInput",
|
||||
"outputSchemaName": "GetAgentThreadRunsOutput",
|
||||
"inputs": [
|
||||
"GetAgentThreadRunsInput"
|
||||
],
|
||||
"outputs": [
|
||||
"GetAgentThreadRunsOutput"
|
||||
],
|
||||
"expose": true,
|
||||
"implementationHash": "2e83ec1d0e08772d",
|
||||
"title": "Get Agent Thread Runs",
|
||||
"tags": [
|
||||
"pikku",
|
||||
"pikku:agent"
|
||||
],
|
||||
"description": "Returns the run history for a given AI agent thread, ordered by creation time.",
|
||||
"isDirectFunction": false,
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/agent.gen.ts",
|
||||
"exportedName": "getAgentThreadRuns",
|
||||
"contractHash": "c51892c37c245537",
|
||||
"inputHash": "fb544997",
|
||||
"outputHash": "6352aca1"
|
||||
},
|
||||
"deleteAgentThread": {
|
||||
"pikkuFuncId": "deleteAgentThread",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "deleteAgentThread",
|
||||
"services": {
|
||||
"optimized": true,
|
||||
"services": [
|
||||
"agentRunService"
|
||||
]
|
||||
},
|
||||
"inputSchemaName": "DeleteAgentThreadInput",
|
||||
"outputSchemaName": "DeleteAgentThreadOutput",
|
||||
"inputs": [
|
||||
"DeleteAgentThreadInput"
|
||||
],
|
||||
"outputs": [
|
||||
"DeleteAgentThreadOutput"
|
||||
],
|
||||
"expose": true,
|
||||
"implementationHash": "7c0d0fb40a42fc20",
|
||||
"title": "Delete Agent Thread",
|
||||
"tags": [
|
||||
"pikku",
|
||||
"pikku:agent"
|
||||
],
|
||||
"description": "Deletes an AI agent thread and all of its persisted state.",
|
||||
"isDirectFunction": false,
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/agent.gen.ts",
|
||||
"exportedName": "deleteAgentThread",
|
||||
"contractHash": "b970011db1e0230e",
|
||||
"inputHash": "3ed36ee5",
|
||||
"outputHash": "a2094cc1"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,404 @@
|
||||
{
|
||||
"pikkuConsoleSetSecret": {
|
||||
"pikkuFuncId": "pikkuConsoleSetSecret",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "pikkuConsoleSetSecret",
|
||||
"inputSchemaName": "PikkuConsoleSetSecretInput",
|
||||
"outputSchemaName": "PikkuConsoleSetSecretOutput",
|
||||
"inputs": [
|
||||
"PikkuConsoleSetSecretInput"
|
||||
],
|
||||
"outputs": [
|
||||
"PikkuConsoleSetSecretOutput"
|
||||
],
|
||||
"expose": true,
|
||||
"implementationHash": "c33e04e6aff5ca2e",
|
||||
"contractHash": "fcb625d86fe88b8f",
|
||||
"inputHash": "a0c8a043",
|
||||
"outputHash": "57702b41"
|
||||
},
|
||||
"pikkuConsoleGetVariable": {
|
||||
"pikkuFuncId": "pikkuConsoleGetVariable",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "pikkuConsoleGetVariable",
|
||||
"inputSchemaName": "PikkuConsoleGetVariableInput",
|
||||
"outputSchemaName": "PikkuConsoleGetVariableOutput",
|
||||
"inputs": [
|
||||
"PikkuConsoleGetVariableInput"
|
||||
],
|
||||
"outputs": [
|
||||
"PikkuConsoleGetVariableOutput"
|
||||
],
|
||||
"expose": true,
|
||||
"implementationHash": "45c792dfb6f8b1a5",
|
||||
"contractHash": "3b66dda4d82fa48a",
|
||||
"inputHash": "ce4b2e06",
|
||||
"outputHash": "f54f1059"
|
||||
},
|
||||
"pikkuConsoleSetVariable": {
|
||||
"pikkuFuncId": "pikkuConsoleSetVariable",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "pikkuConsoleSetVariable",
|
||||
"inputSchemaName": "PikkuConsoleSetVariableInput",
|
||||
"outputSchemaName": "PikkuConsoleSetVariableOutput",
|
||||
"inputs": [
|
||||
"PikkuConsoleSetVariableInput"
|
||||
],
|
||||
"outputs": [
|
||||
"PikkuConsoleSetVariableOutput"
|
||||
],
|
||||
"expose": true,
|
||||
"implementationHash": "f6806d8dc9d50055",
|
||||
"contractHash": "9dda40633b173a08",
|
||||
"inputHash": "d91a4af5",
|
||||
"outputHash": "91fe907b"
|
||||
},
|
||||
"pikkuConsoleHasSecret": {
|
||||
"pikkuFuncId": "pikkuConsoleHasSecret",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "pikkuConsoleHasSecret",
|
||||
"inputSchemaName": "PikkuConsoleHasSecretInput",
|
||||
"outputSchemaName": "PikkuConsoleHasSecretOutput",
|
||||
"inputs": [
|
||||
"PikkuConsoleHasSecretInput"
|
||||
],
|
||||
"outputs": [
|
||||
"PikkuConsoleHasSecretOutput"
|
||||
],
|
||||
"expose": true,
|
||||
"implementationHash": "b8c818fb2291b032",
|
||||
"contractHash": "eeff751c00461679",
|
||||
"inputHash": "a67adc7c",
|
||||
"outputHash": "1da66eac"
|
||||
},
|
||||
"pikkuConsoleGetSecret": {
|
||||
"pikkuFuncId": "pikkuConsoleGetSecret",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "pikkuConsoleGetSecret",
|
||||
"inputSchemaName": "PikkuConsoleGetSecretInput",
|
||||
"outputSchemaName": "PikkuConsoleGetSecretOutput",
|
||||
"inputs": [
|
||||
"PikkuConsoleGetSecretInput"
|
||||
],
|
||||
"outputs": [
|
||||
"PikkuConsoleGetSecretOutput"
|
||||
],
|
||||
"expose": true,
|
||||
"implementationHash": "5c1e39a4b0cc46a1",
|
||||
"contractHash": "d651ad93642eaeed",
|
||||
"inputHash": "329251da",
|
||||
"outputHash": "fb675a26"
|
||||
},
|
||||
"http:get:/workflow-run/:runId/stream": {
|
||||
"pikkuFuncId": "http:get:/workflow-run/:runId/stream",
|
||||
"functionType": "inline",
|
||||
"name": "/workflow-run/:runId/stream",
|
||||
"inputSchemaName": "StreamWorkflowRunInput",
|
||||
"outputSchemaName": null,
|
||||
"inputs": [
|
||||
"StreamWorkflowRunInput"
|
||||
],
|
||||
"outputs": [],
|
||||
"contractHash": "ab85b338c10d89e8",
|
||||
"inputHash": "76838d3e",
|
||||
"outputHash": "fc2fd4a0"
|
||||
},
|
||||
"remoteRPCHandler": {
|
||||
"pikkuFuncId": "remoteRPCHandler",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "remoteRPCHandler",
|
||||
"inputSchemaName": "RemoteRPCHandlerInput",
|
||||
"outputSchemaName": null,
|
||||
"inputs": [
|
||||
"RemoteRPCHandlerInput"
|
||||
],
|
||||
"outputs": [],
|
||||
"remote": true,
|
||||
"implementationHash": "105018a823bdb551"
|
||||
},
|
||||
"workflowStarter": {
|
||||
"pikkuFuncId": "workflowStarter",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "workflowStarter",
|
||||
"inputSchemaName": "WorkflowStarterInput",
|
||||
"outputSchemaName": "WorkflowStarterOutput",
|
||||
"inputs": [
|
||||
"WorkflowStarterInput"
|
||||
],
|
||||
"outputs": [
|
||||
"WorkflowStarterOutput"
|
||||
],
|
||||
"implementationHash": "153116058265d9d4",
|
||||
"contractHash": "770c10618e2d471b",
|
||||
"inputHash": "73e8dfbd",
|
||||
"outputHash": "8f2061b7"
|
||||
},
|
||||
"workflowRunner": {
|
||||
"pikkuFuncId": "workflowRunner",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "workflowRunner",
|
||||
"inputSchemaName": "WorkflowRunnerInput",
|
||||
"outputSchemaName": null,
|
||||
"inputs": [
|
||||
"WorkflowRunnerInput"
|
||||
],
|
||||
"outputs": [],
|
||||
"implementationHash": "4807ebd71047f932",
|
||||
"contractHash": "ca617784c6d9ec8d",
|
||||
"inputHash": "3c634245",
|
||||
"outputHash": "316bdb87"
|
||||
},
|
||||
"workflowStatusChecker": {
|
||||
"pikkuFuncId": "workflowStatusChecker",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "workflowStatusChecker",
|
||||
"inputSchemaName": "WorkflowStatusCheckerInput",
|
||||
"outputSchemaName": "WorkflowRunStatus",
|
||||
"inputs": [
|
||||
"WorkflowStatusCheckerInput"
|
||||
],
|
||||
"outputs": [
|
||||
"WorkflowRunStatus"
|
||||
],
|
||||
"implementationHash": "e4159df9ad118a6c",
|
||||
"contractHash": "1bb7182390464bc0",
|
||||
"inputHash": "458ba7ec",
|
||||
"outputHash": "bc4d864f"
|
||||
},
|
||||
"workflowStatusStream": {
|
||||
"pikkuFuncId": "workflowStatusStream",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "workflowStatusStream",
|
||||
"inputSchemaName": "WorkflowStatusStreamInput",
|
||||
"outputSchemaName": null,
|
||||
"inputs": [
|
||||
"WorkflowStatusStreamInput"
|
||||
],
|
||||
"outputs": [],
|
||||
"implementationHash": "233d0f04a86a4237",
|
||||
"contractHash": "3b99296ba5064030",
|
||||
"inputHash": "c6ee79ff",
|
||||
"outputHash": "6180f124"
|
||||
},
|
||||
"workflowStatusStreamFull": {
|
||||
"pikkuFuncId": "workflowStatusStreamFull",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "workflowStatusStreamFull",
|
||||
"inputSchemaName": "WorkflowStatusStreamFullInput",
|
||||
"outputSchemaName": null,
|
||||
"inputs": [
|
||||
"WorkflowStatusStreamFullInput"
|
||||
],
|
||||
"outputs": [],
|
||||
"implementationHash": "aba5bf474596ee50",
|
||||
"contractHash": "1e7b9f00193d10ae",
|
||||
"inputHash": "2da90ff6",
|
||||
"outputHash": "dcd02549"
|
||||
},
|
||||
"graphStarter": {
|
||||
"pikkuFuncId": "graphStarter",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "graphStarter",
|
||||
"inputSchemaName": "GraphStarterInput",
|
||||
"outputSchemaName": "GraphStarterOutput",
|
||||
"inputs": [
|
||||
"GraphStarterInput"
|
||||
],
|
||||
"outputs": [
|
||||
"GraphStarterOutput"
|
||||
],
|
||||
"implementationHash": "d12993125e177525",
|
||||
"contractHash": "422510c83dee8491",
|
||||
"inputHash": "70868669",
|
||||
"outputHash": "6f988595"
|
||||
},
|
||||
"rpcCaller": {
|
||||
"pikkuFuncId": "rpcCaller",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "rpcCaller",
|
||||
"inputSchemaName": "RpcCallerInput",
|
||||
"outputSchemaName": null,
|
||||
"inputs": [
|
||||
"RpcCallerInput"
|
||||
],
|
||||
"outputs": [],
|
||||
"implementationHash": "f92b60dda357f483",
|
||||
"contractHash": "f6901fd233740bf4",
|
||||
"inputHash": "a69cacc4",
|
||||
"outputHash": "629e0b5a"
|
||||
},
|
||||
"agentCaller": {
|
||||
"pikkuFuncId": "agentCaller",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "agentCaller",
|
||||
"inputSchemaName": "AgentCallerInput",
|
||||
"outputSchemaName": null,
|
||||
"inputs": [
|
||||
"AgentCallerInput"
|
||||
],
|
||||
"outputs": [],
|
||||
"implementationHash": "4af198bf5bbd9bd8",
|
||||
"contractHash": "76619abd99f23189",
|
||||
"inputHash": "4d1eddbc",
|
||||
"outputHash": "9a3af204"
|
||||
},
|
||||
"agentStreamCaller": {
|
||||
"pikkuFuncId": "agentStreamCaller",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "agentStreamCaller",
|
||||
"inputSchemaName": "AgentStreamCallerInput",
|
||||
"outputSchemaName": null,
|
||||
"inputs": [
|
||||
"AgentStreamCallerInput"
|
||||
],
|
||||
"outputs": [],
|
||||
"implementationHash": "92b3cd7c92fb3de4",
|
||||
"contractHash": "0e5c814e26d3294f",
|
||||
"inputHash": "773d4d52",
|
||||
"outputHash": "641a263e"
|
||||
},
|
||||
"agentApproveCaller": {
|
||||
"pikkuFuncId": "agentApproveCaller",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "agentApproveCaller",
|
||||
"inputSchemaName": "AgentApproveCallerInput",
|
||||
"outputSchemaName": null,
|
||||
"inputs": [
|
||||
"AgentApproveCallerInput"
|
||||
],
|
||||
"outputs": [],
|
||||
"implementationHash": "ae5d4bfb0293119a",
|
||||
"contractHash": "83a9293c4b51d65c",
|
||||
"inputHash": "f1628b7c",
|
||||
"outputHash": "ef71f08a"
|
||||
},
|
||||
"agentResumeCaller": {
|
||||
"pikkuFuncId": "agentResumeCaller",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "agentResumeCaller",
|
||||
"inputSchemaName": "AgentResumeCallerInput",
|
||||
"outputSchemaName": null,
|
||||
"inputs": [
|
||||
"AgentResumeCallerInput"
|
||||
],
|
||||
"outputs": [],
|
||||
"implementationHash": "d17ccf1259ba4a60",
|
||||
"contractHash": "0648ffb2cfa9d861",
|
||||
"inputHash": "f25b50dd",
|
||||
"outputHash": "ee89e454"
|
||||
},
|
||||
"getAgentThreads": {
|
||||
"pikkuFuncId": "getAgentThreads",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "getAgentThreads",
|
||||
"inputSchemaName": "GetAgentThreadsInput",
|
||||
"outputSchemaName": "GetAgentThreadsOutput",
|
||||
"inputs": [
|
||||
"GetAgentThreadsInput"
|
||||
],
|
||||
"outputs": [
|
||||
"GetAgentThreadsOutput"
|
||||
],
|
||||
"expose": true,
|
||||
"implementationHash": "3823f8f3911c48e2",
|
||||
"contractHash": "d629208347702d27",
|
||||
"inputHash": "41f5350c",
|
||||
"outputHash": "6598bdff"
|
||||
},
|
||||
"getAgentThreadMessages": {
|
||||
"pikkuFuncId": "getAgentThreadMessages",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "getAgentThreadMessages",
|
||||
"inputSchemaName": "GetAgentThreadMessagesInput",
|
||||
"outputSchemaName": "GetAgentThreadMessagesOutput",
|
||||
"inputs": [
|
||||
"GetAgentThreadMessagesInput"
|
||||
],
|
||||
"outputs": [
|
||||
"GetAgentThreadMessagesOutput"
|
||||
],
|
||||
"expose": true,
|
||||
"implementationHash": "dffe581287205c6e",
|
||||
"contractHash": "44e43e96024680f3",
|
||||
"inputHash": "a158e652",
|
||||
"outputHash": "04960780"
|
||||
},
|
||||
"getAgentThreadRuns": {
|
||||
"pikkuFuncId": "getAgentThreadRuns",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "getAgentThreadRuns",
|
||||
"inputSchemaName": "GetAgentThreadRunsInput",
|
||||
"outputSchemaName": "GetAgentThreadRunsOutput",
|
||||
"inputs": [
|
||||
"GetAgentThreadRunsInput"
|
||||
],
|
||||
"outputs": [
|
||||
"GetAgentThreadRunsOutput"
|
||||
],
|
||||
"expose": true,
|
||||
"implementationHash": "2e83ec1d0e08772d",
|
||||
"contractHash": "c51892c37c245537",
|
||||
"inputHash": "fb544997",
|
||||
"outputHash": "6352aca1"
|
||||
},
|
||||
"deleteAgentThread": {
|
||||
"pikkuFuncId": "deleteAgentThread",
|
||||
"functionType": "user",
|
||||
"funcWrapper": "pikkuSessionlessFunc",
|
||||
"sessionless": true,
|
||||
"name": "deleteAgentThread",
|
||||
"inputSchemaName": "DeleteAgentThreadInput",
|
||||
"outputSchemaName": "DeleteAgentThreadOutput",
|
||||
"inputs": [
|
||||
"DeleteAgentThreadInput"
|
||||
],
|
||||
"outputs": [
|
||||
"DeleteAgentThreadOutput"
|
||||
],
|
||||
"expose": true,
|
||||
"implementationHash": "7c0d0fb40a42fc20",
|
||||
"contractHash": "b970011db1e0230e",
|
||||
"inputHash": "3ed36ee5",
|
||||
"outputHash": "a2094cc1"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
import { pikkuState } from '@pikku/core/internal'
|
||||
import type { FunctionsMeta } from '@pikku/core'
|
||||
import metaData from './pikku-functions-meta.gen.json' with { type: 'json' }
|
||||
pikkuState(null, 'function', 'meta', metaData as FunctionsMeta)
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
/* Import and register functions used by RPCs */
|
||||
import { addFunction } from '@pikku/core/function'
|
||||
import { deleteAgentThread } from '../../../../src/scaffold/agent.gen.js'
|
||||
import { getAgentThreadMessages } from '../../../../src/scaffold/agent.gen.js'
|
||||
import { getAgentThreadRuns } from '../../../../src/scaffold/agent.gen.js'
|
||||
import { getAgentThreads } from '../../../../src/scaffold/agent.gen.js'
|
||||
import { pikkuConsoleGetSecret } from '../../../../src/scaffold/console.gen.js'
|
||||
import { pikkuConsoleGetVariable } from '../../../../src/scaffold/console.gen.js'
|
||||
import { pikkuConsoleHasSecret } from '../../../../src/scaffold/console.gen.js'
|
||||
import { pikkuConsoleSetSecret } from '../../../../src/scaffold/console.gen.js'
|
||||
import { pikkuConsoleSetVariable } from '../../../../src/scaffold/console.gen.js'
|
||||
import { remoteRPCHandler } from '../../../../src/scaffold/rpc-remote.gen.js'
|
||||
|
||||
addFunction('deleteAgentThread', deleteAgentThread)
|
||||
addFunction('getAgentThreadMessages', getAgentThreadMessages)
|
||||
addFunction('getAgentThreadRuns', getAgentThreadRuns)
|
||||
addFunction('getAgentThreads', getAgentThreads)
|
||||
addFunction('pikkuConsoleGetSecret', pikkuConsoleGetSecret)
|
||||
addFunction('pikkuConsoleGetVariable', pikkuConsoleGetVariable)
|
||||
addFunction('pikkuConsoleHasSecret', pikkuConsoleHasSecret)
|
||||
addFunction('pikkuConsoleSetSecret', pikkuConsoleSetSecret)
|
||||
addFunction('pikkuConsoleSetVariable', pikkuConsoleSetVariable)
|
||||
addFunction('remoteRPCHandler', remoteRPCHandler)
|
||||
@@ -0,0 +1,147 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
/**
|
||||
* HTTP-specific type definitions for tree-shaking optimization
|
||||
*/
|
||||
|
||||
import { AssertHTTPWiringParams, wireHTTP as wireHTTPCore, addHTTPMiddleware as addHTTPMiddlewareCore, addHTTPPermission as addHTTPPermissionCore, wireHTTPRoutes as wireHTTPRoutesCore, defineHTTPRoutes as defineHTTPRoutesCore } from '@pikku/core/http'
|
||||
import type { PikkuFunction, PikkuFunctionSessionless, PikkuPermission, PikkuMiddleware, PikkuFunctionConfig } from '../function/pikku-function-types.gen.js'
|
||||
import type { CoreHTTPFunctionWiring, HTTPMethod, HTTPRouteBaseConfig } from '@pikku/core/http'
|
||||
|
||||
/**
|
||||
* Type definition for HTTP API wirings with type-safe path parameters.
|
||||
* Supports both authenticated and unauthenticated functions.
|
||||
*
|
||||
* @template In - Input type for the HTTP wiring
|
||||
* @template Out - Output type for the HTTP wiring
|
||||
* @template Route - String literal type for the HTTP path (e.g., "/users/:id")
|
||||
*/
|
||||
type HTTPWiring<In, Out, Route extends string> = CoreHTTPFunctionWiring<In, Out, Route, PikkuFunction<In, Out, 'rpc' | 'session'>, PikkuFunctionSessionless<In, Out, 'rpc' | 'session'>, PikkuPermission<In>, PikkuMiddleware>
|
||||
|
||||
/**
|
||||
* Registers an HTTP wiring with the Pikku framework.
|
||||
*
|
||||
* @template In - Input type for the HTTP wiring
|
||||
* @template Out - Output type for the HTTP wiring
|
||||
* @template Route - String literal type for the HTTP path (e.g., "/users/:id")
|
||||
* @param httpWiring - HTTP wiring definition with handler, method, and optional middleware
|
||||
*/
|
||||
export const wireHTTP = <In, Out, Route extends string>(
|
||||
httpWiring: HTTPWiring<In, Out, Route> & AssertHTTPWiringParams<In, Route>
|
||||
) => {
|
||||
wireHTTPCore(httpWiring as any)
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers HTTP middleware either globally or for a specific route pattern.
|
||||
*
|
||||
* When a string route pattern is provided along with middleware, the middleware
|
||||
* is applied only to that route. Otherwise, if an array is provided, it is treated
|
||||
* as global middleware (applied to all routes).
|
||||
*
|
||||
* @param routeOrMiddleware - Either a global middleware array or a route pattern string
|
||||
* @param middleware - The middleware array to apply when a route pattern is specified
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* // Add global HTTP middleware
|
||||
* addHTTPMiddleware([authMiddleware, loggingMiddleware])
|
||||
*
|
||||
* // Add route-specific middleware
|
||||
* addHTTPMiddleware('/api/admin/*', [adminAuthMiddleware])
|
||||
* ```
|
||||
*/
|
||||
export const addHTTPMiddleware = (
|
||||
routeOrMiddleware: PikkuMiddleware[] | string,
|
||||
middleware?: PikkuMiddleware[]
|
||||
) => {
|
||||
addHTTPMiddlewareCore(routeOrMiddleware as any, middleware as any)
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers HTTP permissions either globally or for a specific route pattern.
|
||||
*
|
||||
* When a string route pattern is provided along with permissions, the permissions
|
||||
* are applied only to that route. Permissions can be passed as an array or as a
|
||||
* permission group object.
|
||||
*
|
||||
* @param pattern - Route pattern string (e.g., '*' for all routes, '/api/*' for specific routes)
|
||||
* @param permissions - The permissions to apply for the specified route pattern
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* // Add global HTTP permissions
|
||||
* addHTTPPermission('*', { global: globalPermission })
|
||||
*
|
||||
* // Add route-specific permissions
|
||||
* addHTTPPermission('/api/admin/*', { admin: adminPermission })
|
||||
* ```
|
||||
*/
|
||||
export const addHTTPPermission = <In = unknown>(
|
||||
pattern: string,
|
||||
permissions: Record<string, PikkuPermission<In>> | PikkuPermission<In>[]
|
||||
) => {
|
||||
addHTTPPermissionCore(pattern, permissions as any)
|
||||
}
|
||||
|
||||
/**
|
||||
* Route configuration for wireHTTPRoutes with proper typing
|
||||
*/
|
||||
type HTTPRouteConfig = HTTPRouteBaseConfig & {
|
||||
method: HTTPMethod
|
||||
route: string
|
||||
func: PikkuFunctionConfig<any, any, any, any, any, any>
|
||||
auth?: boolean
|
||||
permissions?: Record<string, PikkuPermission | PikkuPermission[]>
|
||||
middleware?: PikkuMiddleware[]
|
||||
sse?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Typed route map for wireHTTPRoutes
|
||||
*/
|
||||
type TypedHTTPRouteMap = {
|
||||
[key: string]: HTTPRouteConfig | TypedHTTPRouteMap | TypedHTTPRouteContract
|
||||
}
|
||||
|
||||
/**
|
||||
* Typed route contract for defineHTTPRoutes
|
||||
*/
|
||||
type TypedHTTPRouteContract<T extends TypedHTTPRouteMap = TypedHTTPRouteMap> = TypedHTTPRoutesGroupConfig & {
|
||||
routes: T
|
||||
}
|
||||
|
||||
/**
|
||||
* Group config with typed middleware/permissions
|
||||
*/
|
||||
type TypedHTTPRoutesGroupConfig = {
|
||||
basePath?: string
|
||||
tags?: string[]
|
||||
auth?: boolean
|
||||
middleware?: PikkuMiddleware[]
|
||||
permissions?: Record<string, PikkuPermission | PikkuPermission[]>
|
||||
}
|
||||
|
||||
/**
|
||||
* Full config for wireHTTPRoutes
|
||||
*/
|
||||
type TypedWireHTTPRoutesConfig = TypedHTTPRoutesGroupConfig & {
|
||||
routes: TypedHTTPRouteMap | HTTPRouteConfig[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Type-safe helper for defining route contracts that can be composed.
|
||||
*/
|
||||
export function defineHTTPRoutes<T extends TypedHTTPRouteMap>(routes: T): TypedHTTPRouteContract<T>
|
||||
export function defineHTTPRoutes<T extends TypedHTTPRouteMap>(config: TypedHTTPRoutesGroupConfig & { routes: T }): TypedHTTPRouteContract<T>
|
||||
export function defineHTTPRoutes<T extends TypedHTTPRouteMap>(configOrRoutes: T | (TypedHTTPRoutesGroupConfig & { routes: T })): TypedHTTPRouteContract<T> {
|
||||
return defineHTTPRoutesCore(configOrRoutes as any) as unknown as TypedHTTPRouteContract<T>
|
||||
}
|
||||
|
||||
/**
|
||||
* Wires multiple HTTP routes from a nested map or array configuration.
|
||||
*/
|
||||
export const wireHTTPRoutes = (config: TypedWireHTTPRoutesConfig): void => {
|
||||
wireHTTPRoutesCore(config as any)
|
||||
}
|
||||
129
packages/functions/packages/functions/.pikku/http/pikku-http-wirings-map.gen.d.ts
vendored
Normal file
129
packages/functions/packages/functions/.pikku/http/pikku-http-wirings-map.gen.d.ts
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
/**
|
||||
* This provides the structure needed for typescript to be aware of routes and their return types
|
||||
*/
|
||||
|
||||
import type { StreamWorkflowRunInput } from '@pikku/addon-console/dist/.pikku/rpc/pikku-rpc-wirings-map.internal.gen'
|
||||
import type { WorkflowRunStatus } from '@pikku/core/dist/wirings/workflow/workflow.types'
|
||||
|
||||
|
||||
|
||||
export type AgentApproveCallerInput = { agentName: string; runId: string; approvals: { toolCallId: string; approved: boolean; }[]; }
|
||||
export type AgentCallerInput = { agentName: string; message: string; threadId: string; resourceId: string; }
|
||||
export type AgentResumeCallerInput = { agentName: string; runId: string; toolCallId: string; approved: boolean; }
|
||||
export type AgentStreamCallerInput = { agentName: string; message: string; threadId: string; resourceId: string; }
|
||||
export type DeleteAgentThreadInput = { threadId: string; resourceId?: string; }
|
||||
export type DeleteAgentThreadOutput = { deleted: boolean; }
|
||||
export type GetAgentThreadMessagesInput = { threadId: string; resourceId?: string; }
|
||||
export type GetAgentThreadMessagesOutput = any[]
|
||||
export type GetAgentThreadRunsInput = { threadId: string; resourceId?: string; }
|
||||
export type GetAgentThreadRunsOutput = any[]
|
||||
export type GetAgentThreadsInput = { agentName?: string; resourceId?: string; limit?: number; offset?: number; }
|
||||
export type GetAgentThreadsOutput = any[]
|
||||
export type GraphStarterInput = { workflowName: string; nodeId: string; data?: unknown; }
|
||||
export type GraphStarterOutput = { runId: string; }
|
||||
export type PikkuConsoleGetSecretInput = { secretId: string; }
|
||||
export type PikkuConsoleGetSecretOutput = { exists: boolean; value: unknown; }
|
||||
export type PikkuConsoleGetVariableInput = { variableId: string; }
|
||||
export type PikkuConsoleGetVariableOutput = { exists: boolean; value: unknown; }
|
||||
export type PikkuConsoleHasSecretInput = { secretId: string; }
|
||||
export type PikkuConsoleHasSecretOutput = { exists: boolean; }
|
||||
export type PikkuConsoleSetSecretInput = { secretId: string; value: unknown; }
|
||||
export type PikkuConsoleSetSecretOutput = { success: boolean; }
|
||||
export type PikkuConsoleSetVariableInput = { variableId: string; value: unknown; }
|
||||
export type PikkuConsoleSetVariableOutput = { success: boolean; }
|
||||
export type RemoteRPCHandlerInput = { rpcName: string; data?: unknown; }
|
||||
export type RpcCallerInput = { rpcName: string; data?: unknown; }
|
||||
export type WorkflowRunnerInput = { workflowName: string; data?: unknown; }
|
||||
export type WorkflowStarterInput = { workflowName: string; data?: unknown; }
|
||||
export type WorkflowStarterOutput = { runId: string; }
|
||||
export type WorkflowStatusCheckerInput = { workflowName: string; runId: string; }
|
||||
export type WorkflowStatusStreamFullInput = { workflowName: string; runId: string; }
|
||||
export type WorkflowStatusStreamInput = { workflowName: string; runId: string; }
|
||||
|
||||
// The '& {}' is a workaround for not directly refering to a type since it confuses typescript
|
||||
export type StreamWorkflowRunInputParams = Pick<StreamWorkflowRunInput, 'runId'> & {}
|
||||
export type StreamWorkflowRunInputBody = Omit<StreamWorkflowRunInput, 'runId'> & {}
|
||||
export type RemoteRPCHandlerInputParams = Pick<RemoteRPCHandlerInput, 'rpcName'> & {}
|
||||
export type RemoteRPCHandlerInputBody = Omit<RemoteRPCHandlerInput, 'rpcName'> & {}
|
||||
export type WorkflowStarterInputParams = Pick<WorkflowStarterInput, 'workflowName'> & {}
|
||||
export type WorkflowStarterInputBody = Omit<WorkflowStarterInput, 'workflowName'> & {}
|
||||
export type WorkflowRunnerInputParams = Pick<WorkflowRunnerInput, 'workflowName'> & {}
|
||||
export type WorkflowRunnerInputBody = Omit<WorkflowRunnerInput, 'workflowName'> & {}
|
||||
export type WorkflowStatusCheckerInputParams = Pick<WorkflowStatusCheckerInput, 'workflowName' | 'runId'> & {}
|
||||
export type WorkflowStatusCheckerInputBody = Omit<WorkflowStatusCheckerInput, 'workflowName' | 'runId'> & {}
|
||||
export type WorkflowStatusStreamInputParams = Pick<WorkflowStatusStreamInput, 'workflowName' | 'runId'> & {}
|
||||
export type WorkflowStatusStreamInputBody = Omit<WorkflowStatusStreamInput, 'workflowName' | 'runId'> & {}
|
||||
export type WorkflowStatusStreamFullInputParams = Pick<WorkflowStatusStreamFullInput, 'workflowName' | 'runId'> & {}
|
||||
export type WorkflowStatusStreamFullInputBody = Omit<WorkflowStatusStreamFullInput, 'workflowName' | 'runId'> & {}
|
||||
export type GraphStarterInputParams = Pick<GraphStarterInput, 'workflowName' | 'nodeId'> & {}
|
||||
export type GraphStarterInputBody = Omit<GraphStarterInput, 'workflowName' | 'nodeId'> & {}
|
||||
export type RpcCallerInputParams = Pick<RpcCallerInput, 'rpcName'> & {}
|
||||
export type RpcCallerInputBody = Omit<RpcCallerInput, 'rpcName'> & {}
|
||||
export type AgentCallerInputParams = Pick<AgentCallerInput, 'agentName'> & {}
|
||||
export type AgentCallerInputBody = Omit<AgentCallerInput, 'agentName'> & {}
|
||||
export type AgentStreamCallerInputParams = Pick<AgentStreamCallerInput, 'agentName'> & {}
|
||||
export type AgentStreamCallerInputBody = Omit<AgentStreamCallerInput, 'agentName'> & {}
|
||||
export type AgentApproveCallerInputParams = Pick<AgentApproveCallerInput, 'agentName'> & {}
|
||||
export type AgentApproveCallerInputBody = Omit<AgentApproveCallerInput, 'agentName'> & {}
|
||||
export type AgentResumeCallerInputParams = Pick<AgentResumeCallerInput, 'agentName'> & {}
|
||||
export type AgentResumeCallerInputBody = Omit<AgentResumeCallerInput, 'agentName'> & {}
|
||||
|
||||
interface HTTPWiringHandler<I, O> {
|
||||
input: I;
|
||||
output: O;
|
||||
}
|
||||
|
||||
export type HTTPWiringsMap = {
|
||||
readonly '/workflow-run/:runId/stream': {
|
||||
readonly GET: HTTPWiringHandler<StreamWorkflowRunInput, null>,
|
||||
},
|
||||
readonly '/workflow/:workflowName/status/:runId': {
|
||||
readonly GET: HTTPWiringHandler<WorkflowStatusCheckerInput, WorkflowRunStatus>,
|
||||
},
|
||||
readonly '/workflow/:workflowName/status/:runId/stream': {
|
||||
readonly GET: HTTPWiringHandler<WorkflowStatusStreamInput, null>,
|
||||
},
|
||||
readonly '/workflow/:workflowName/status/:runId/stream/full': {
|
||||
readonly GET: HTTPWiringHandler<WorkflowStatusStreamFullInput, null>,
|
||||
},
|
||||
readonly '/remote/rpc/:rpcName': {
|
||||
readonly POST: HTTPWiringHandler<RemoteRPCHandlerInput, null>,
|
||||
},
|
||||
readonly '/workflow/:workflowName/start': {
|
||||
readonly POST: HTTPWiringHandler<WorkflowStarterInput, WorkflowStarterOutput>,
|
||||
},
|
||||
readonly '/workflow/:workflowName/run': {
|
||||
readonly POST: HTTPWiringHandler<WorkflowRunnerInput, null>,
|
||||
},
|
||||
readonly '/workflow/:workflowName/graph/:nodeId': {
|
||||
readonly POST: HTTPWiringHandler<GraphStarterInput, GraphStarterOutput>,
|
||||
},
|
||||
readonly '/rpc/:rpcName': {
|
||||
readonly POST: HTTPWiringHandler<RpcCallerInput, null>,
|
||||
},
|
||||
readonly '/rpc/agent/:agentName': {
|
||||
readonly POST: HTTPWiringHandler<AgentCallerInput, null>,
|
||||
},
|
||||
readonly '/rpc/agent/:agentName/stream': {
|
||||
readonly POST: HTTPWiringHandler<AgentStreamCallerInput, null>,
|
||||
},
|
||||
readonly '/rpc/agent/:agentName/approve': {
|
||||
readonly POST: HTTPWiringHandler<AgentApproveCallerInput, null>,
|
||||
},
|
||||
readonly '/rpc/agent/:agentName/resume': {
|
||||
readonly POST: HTTPWiringHandler<AgentResumeCallerInput, null>,
|
||||
},
|
||||
};
|
||||
|
||||
export type HTTPWiringHandlerOf<HTTPWiring extends keyof HTTPWiringsMap, Method extends keyof HTTPWiringsMap[HTTPWiring]> =
|
||||
HTTPWiringsMap[HTTPWiring][Method] extends { input: infer I; output: infer O }
|
||||
? HTTPWiringHandler<I, O>
|
||||
: never;
|
||||
|
||||
export type HTTPWiringsWithMethod<Method extends string> = {
|
||||
[HTTPWiring in keyof HTTPWiringsMap]: Method extends keyof HTTPWiringsMap[HTTPWiring] ? HTTPWiring : never;
|
||||
}[keyof HTTPWiringsMap];
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
{
|
||||
"get": {
|
||||
"/workflow-run/:runId/stream": {
|
||||
"pikkuFuncId": "http:get:/workflow-run/:runId/stream",
|
||||
"route": "/workflow-run/:runId/stream",
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/console.gen.ts",
|
||||
"method": "get",
|
||||
"params": [
|
||||
"runId"
|
||||
],
|
||||
"sse": true
|
||||
},
|
||||
"/workflow/:workflowName/status/:runId": {
|
||||
"pikkuFuncId": "workflowStatusChecker",
|
||||
"route": "/workflow/:workflowName/status/:runId",
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/workflow-routes.gen.ts",
|
||||
"method": "get",
|
||||
"params": [
|
||||
"workflowName",
|
||||
"runId"
|
||||
]
|
||||
},
|
||||
"/workflow/:workflowName/status/:runId/stream": {
|
||||
"pikkuFuncId": "workflowStatusStream",
|
||||
"route": "/workflow/:workflowName/status/:runId/stream",
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/workflow-routes.gen.ts",
|
||||
"method": "get",
|
||||
"params": [
|
||||
"workflowName",
|
||||
"runId"
|
||||
],
|
||||
"sse": true
|
||||
},
|
||||
"/workflow/:workflowName/status/:runId/stream/full": {
|
||||
"pikkuFuncId": "workflowStatusStreamFull",
|
||||
"route": "/workflow/:workflowName/status/:runId/stream/full",
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/workflow-routes.gen.ts",
|
||||
"method": "get",
|
||||
"params": [
|
||||
"workflowName",
|
||||
"runId"
|
||||
],
|
||||
"sse": true
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"/remote/rpc/:rpcName": {
|
||||
"pikkuFuncId": "remoteRPCHandler",
|
||||
"route": "/remote/rpc/:rpcName",
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/rpc-remote.gen.ts",
|
||||
"method": "post",
|
||||
"params": [
|
||||
"rpcName"
|
||||
],
|
||||
"middleware": [
|
||||
{
|
||||
"type": "wire",
|
||||
"name": "pikkuRemoteAuthMiddleware",
|
||||
"inline": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"/workflow/:workflowName/start": {
|
||||
"pikkuFuncId": "workflowStarter",
|
||||
"route": "/workflow/:workflowName/start",
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/workflow-routes.gen.ts",
|
||||
"method": "post",
|
||||
"params": [
|
||||
"workflowName"
|
||||
]
|
||||
},
|
||||
"/workflow/:workflowName/run": {
|
||||
"pikkuFuncId": "workflowRunner",
|
||||
"route": "/workflow/:workflowName/run",
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/workflow-routes.gen.ts",
|
||||
"method": "post",
|
||||
"params": [
|
||||
"workflowName"
|
||||
]
|
||||
},
|
||||
"/workflow/:workflowName/graph/:nodeId": {
|
||||
"pikkuFuncId": "graphStarter",
|
||||
"route": "/workflow/:workflowName/graph/:nodeId",
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/workflow-routes.gen.ts",
|
||||
"method": "post",
|
||||
"params": [
|
||||
"workflowName",
|
||||
"nodeId"
|
||||
]
|
||||
},
|
||||
"/rpc/:rpcName": {
|
||||
"pikkuFuncId": "rpcCaller",
|
||||
"route": "/rpc/:rpcName",
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/rpc-public.gen.ts",
|
||||
"method": "post",
|
||||
"params": [
|
||||
"rpcName"
|
||||
]
|
||||
},
|
||||
"/rpc/agent/:agentName": {
|
||||
"pikkuFuncId": "agentCaller",
|
||||
"route": "/rpc/agent/:agentName",
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/agent.gen.ts",
|
||||
"method": "post",
|
||||
"params": [
|
||||
"agentName"
|
||||
],
|
||||
"tags": [
|
||||
"pikku:public"
|
||||
]
|
||||
},
|
||||
"/rpc/agent/:agentName/stream": {
|
||||
"pikkuFuncId": "agentStreamCaller",
|
||||
"route": "/rpc/agent/:agentName/stream",
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/agent.gen.ts",
|
||||
"method": "post",
|
||||
"params": [
|
||||
"agentName"
|
||||
],
|
||||
"tags": [
|
||||
"pikku:public"
|
||||
],
|
||||
"sse": true
|
||||
},
|
||||
"/rpc/agent/:agentName/approve": {
|
||||
"pikkuFuncId": "agentApproveCaller",
|
||||
"route": "/rpc/agent/:agentName/approve",
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/agent.gen.ts",
|
||||
"method": "post",
|
||||
"params": [
|
||||
"agentName"
|
||||
],
|
||||
"tags": [
|
||||
"pikku:public"
|
||||
]
|
||||
},
|
||||
"/rpc/agent/:agentName/resume": {
|
||||
"pikkuFuncId": "agentResumeCaller",
|
||||
"route": "/rpc/agent/:agentName/resume",
|
||||
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/src/scaffold/agent.gen.ts",
|
||||
"method": "post",
|
||||
"params": [
|
||||
"agentName"
|
||||
],
|
||||
"tags": [
|
||||
"pikku:public"
|
||||
],
|
||||
"sse": true
|
||||
}
|
||||
},
|
||||
"put": {},
|
||||
"delete": {},
|
||||
"head": {},
|
||||
"patch": {},
|
||||
"options": {}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
import { pikkuState } from '@pikku/core/internal'
|
||||
import type { HTTPWiringsMeta } from '@pikku/core/http'
|
||||
import metaData from './pikku-http-wirings-meta.gen.json' with { type: 'json' }
|
||||
pikkuState(null, 'http', 'meta', metaData as HTTPWiringsMeta)
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
/* The files with an wireHTTP function call */
|
||||
import '../../../../src/scaffold/agent.gen.js'
|
||||
import '../../../../src/scaffold/console.gen.js'
|
||||
import '../../../../src/scaffold/rpc-public.gen.js'
|
||||
import '../../../../src/scaffold/rpc-remote.gen.js'
|
||||
import '../../../../src/scaffold/workflow-routes.gen.js'
|
||||
@@ -0,0 +1,183 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
/**
|
||||
* MCP-specific type definitions for tree-shaking optimization
|
||||
*/
|
||||
|
||||
import {
|
||||
CoreMCPResource,
|
||||
CoreMCPPrompt,
|
||||
wireMCPResource as wireMCPResourceCore,
|
||||
wireMCPPrompt as wireMCPPromptCore,
|
||||
MCPResourceResponse,
|
||||
MCPToolResponse,
|
||||
MCPPromptResponse,
|
||||
AssertMCPResourceURIParams
|
||||
} from '@pikku/core/mcp'
|
||||
|
||||
import type { PikkuFunctionConfig, PikkuFunctionSessionless, PikkuMiddleware, PikkuPermission, InferSchemaOutput } from '../function/pikku-function-types.gen.js'
|
||||
import type { CorePermissionGroup } from '@pikku/core'
|
||||
import type { StandardSchemaV1 } from '@standard-schema/spec'
|
||||
|
||||
/**
|
||||
* Type definition for MCP resources that provide data to AI models.
|
||||
*
|
||||
* @template In - Input type for the resource request
|
||||
* @template URI - URI template string type for compile-time parameter validation
|
||||
*/
|
||||
type MCPResourceWiring<In, URI extends string> = CoreMCPResource<PikkuFunctionConfig<In, MCPResourceResponse, 'rpc' | 'session' | 'mcp'>> & { uri: URI }
|
||||
|
||||
/**
|
||||
* Type definition for MCP prompts that provide templates to AI models.
|
||||
*
|
||||
* @template In - Input type for the prompt parameters
|
||||
*/
|
||||
type MCPPromptWiring<In> = CoreMCPPrompt<PikkuFunctionConfig<In, MCPPromptResponse, 'rpc' | 'session' | 'mcp'>>
|
||||
|
||||
/**
|
||||
* Registers an MCP resource with the Pikku framework.
|
||||
* Resources provide data that AI models can access.
|
||||
*
|
||||
* @template In - Input type for the resource request
|
||||
* @template URI - URI template string for compile-time parameter validation
|
||||
* @param mcpResource - MCP resource definition with data provider function
|
||||
*/
|
||||
export const wireMCPResource = <In, URI extends string>(
|
||||
mcpResource: MCPResourceWiring<In, URI> & AssertMCPResourceURIParams<In, URI>
|
||||
) => {
|
||||
wireMCPResourceCore(mcpResource as any)
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an MCP prompt with the Pikku framework.
|
||||
* Prompts provide templates that AI models can use.
|
||||
*
|
||||
* @template In - Input type for the prompt parameters
|
||||
* @param mcpPrompt - MCP prompt definition with template function
|
||||
*/
|
||||
export const wireMCPPrompt = <In>(
|
||||
mcpPrompt: MCPPromptWiring<In>
|
||||
) => {
|
||||
wireMCPPromptCore(mcpPrompt as any)
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for MCP prompt with Zod schema input validation.
|
||||
*/
|
||||
type MCPPromptFuncConfigWithSchema<InputSchema extends StandardSchemaV1> = {
|
||||
func: PikkuFunctionSessionless<InferSchemaOutput<InputSchema>, MCPPromptResponse, 'mcp' | 'rpc'>
|
||||
name?: string
|
||||
input: InputSchema
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function for handling MCP prompt requests.
|
||||
* These functions generate prompt templates for AI models.
|
||||
*
|
||||
* Supports two patterns:
|
||||
* 1. Generic types: `pikkuMCPPromptFunc<Input>({ func: ... })`
|
||||
* 2. Zod schemas: `pikkuMCPPromptFunc({ input: z.object(...), func: ... })`
|
||||
*
|
||||
* @template In - Input type for the prompt parameters (inferred from schema if provided)
|
||||
* @param func - Function definition, either direct function or configuration object
|
||||
* @returns The unwrapped function for internal use
|
||||
*/
|
||||
export function pikkuMCPPromptFunc<InputSchema extends StandardSchemaV1>(
|
||||
config: MCPPromptFuncConfigWithSchema<InputSchema>
|
||||
): PikkuFunctionConfig<InferSchemaOutput<InputSchema>, MCPPromptResponse, 'mcp' | 'rpc'>
|
||||
export function pikkuMCPPromptFunc<In>(
|
||||
func:
|
||||
| PikkuFunctionSessionless<In, MCPPromptResponse, 'mcp' | 'rpc'>
|
||||
| {
|
||||
func: PikkuFunctionSessionless<In, MCPPromptResponse, 'mcp' | 'rpc'>
|
||||
name?: string
|
||||
}
|
||||
): PikkuFunctionConfig<In, MCPPromptResponse, 'mcp' | 'rpc'>
|
||||
export function pikkuMCPPromptFunc(func: any): any {
|
||||
return typeof func === 'function' ? { func } : func
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for MCP tool with Zod schema input validation.
|
||||
*/
|
||||
type MCPToolFuncConfigWithSchema<InputSchema extends StandardSchemaV1> = {
|
||||
func: PikkuFunctionSessionless<InferSchemaOutput<InputSchema>, MCPToolResponse, 'mcp' | 'rpc'>
|
||||
description?: string
|
||||
tags?: string[]
|
||||
title?: string
|
||||
summary?: string
|
||||
name?: string
|
||||
middleware?: PikkuMiddleware[]
|
||||
permissions?: CorePermissionGroup<PikkuPermission<InferSchemaOutput<InputSchema>>>
|
||||
input: InputSchema
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function for handling MCP tool invocations.
|
||||
* These functions perform actions that AI models can request.
|
||||
*
|
||||
* Supports two patterns:
|
||||
* 1. Generic types: `pikkuMCPToolFunc<Input>({ func: ... })`
|
||||
* 2. Zod schemas: `pikkuMCPToolFunc({ input: z.object(...), func: ... })`
|
||||
*
|
||||
* @template In - Input type for the tool invocation (inferred from schema if provided)
|
||||
* @param func - Function definition, either direct function or configuration object
|
||||
* @returns The unwrapped function for internal use
|
||||
*/
|
||||
export function pikkuMCPToolFunc<InputSchema extends StandardSchemaV1>(
|
||||
config: MCPToolFuncConfigWithSchema<InputSchema>
|
||||
): PikkuFunctionConfig<InferSchemaOutput<InputSchema>, MCPToolResponse, 'mcp' | 'rpc'>
|
||||
export function pikkuMCPToolFunc<In>(
|
||||
func:
|
||||
| PikkuFunctionSessionless<In, MCPToolResponse, 'mcp' | 'rpc'>
|
||||
| {
|
||||
func: PikkuFunctionSessionless<In, MCPToolResponse, 'mcp' | 'rpc'>
|
||||
description?: string
|
||||
tags?: string[]
|
||||
title?: string
|
||||
summary?: string
|
||||
name?: string
|
||||
middleware?: PikkuMiddleware[]
|
||||
permissions?: CorePermissionGroup<PikkuPermission<In>>
|
||||
}
|
||||
): PikkuFunctionConfig<In, MCPToolResponse, 'mcp' | 'rpc'>
|
||||
export function pikkuMCPToolFunc(func: any): any {
|
||||
return typeof func === 'function' ? { func } : func
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for MCP resource with Zod schema input validation.
|
||||
*/
|
||||
type MCPResourceFuncConfigWithSchema<InputSchema extends StandardSchemaV1> = {
|
||||
func: PikkuFunctionSessionless<InferSchemaOutput<InputSchema>, MCPResourceResponse, 'mcp' | 'rpc'>
|
||||
name?: string
|
||||
input: InputSchema
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function for handling MCP resource requests.
|
||||
* These functions provide data that AI models can access.
|
||||
*
|
||||
* Supports two patterns:
|
||||
* 1. Generic types: `pikkuMCPResourceFunc<Input>({ func: ... })`
|
||||
* 2. Zod schemas: `pikkuMCPResourceFunc({ input: z.object(...), func: ... })`
|
||||
*
|
||||
* @template In - Input type for the resource request (inferred from schema if provided)
|
||||
* @param func - Function definition, either direct function or configuration object
|
||||
* @returns The unwrapped function for internal use
|
||||
*/
|
||||
export function pikkuMCPResourceFunc<InputSchema extends StandardSchemaV1>(
|
||||
config: MCPResourceFuncConfigWithSchema<InputSchema>
|
||||
): PikkuFunctionConfig<InferSchemaOutput<InputSchema>, MCPResourceResponse, 'mcp' | 'rpc'>
|
||||
export function pikkuMCPResourceFunc<In>(
|
||||
func:
|
||||
| PikkuFunctionSessionless<In, MCPResourceResponse, 'mcp' | 'rpc'>
|
||||
| {
|
||||
func: PikkuFunctionSessionless<In, MCPResourceResponse, 'mcp' | 'rpc'>
|
||||
name?: string
|
||||
}
|
||||
): PikkuFunctionConfig<In, MCPResourceResponse, 'mcp' | 'rpc'>
|
||||
export function pikkuMCPResourceFunc(func: any): any {
|
||||
return typeof func === 'function' ? { func } : func
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
import './rpc/pikku-rpc-wirings-meta.internal.gen.js'
|
||||
import './http/pikku-http-wirings-meta.gen.js'
|
||||
import './function/pikku-functions-meta.gen.js'
|
||||
import './queue/pikku-queue-workers-wirings-meta.gen.js'
|
||||
import './schemas/register.gen.js'
|
||||
import './http/pikku-http-wirings.gen.js'
|
||||
import './function/pikku-functions.gen.js'
|
||||
import './queue/pikku-queue-workers-wirings.gen.js'
|
||||
import '../../../src/scaffold/console.gen.js'
|
||||
import '@pikku/addon-console/.pikku/pikku-bootstrap.gen.js'
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
import { LocalMetaService } from '@pikku/core/services/local-meta'
|
||||
|
||||
export class PikkuMetaService extends LocalMetaService {
|
||||
constructor() {
|
||||
super('/Users/yasser/git/pikku/fabric/templates/kanban-board-template/packages/functions/packages/functions/.pikku')
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
import type { SingletonServices } from '../../../src/application-types.d.js'
|
||||
import type { Services } from '../../../src/application-types.d.js'
|
||||
|
||||
// Singleton services map: true if required, false if available but unused
|
||||
export const requiredSingletonServices = {
|
||||
'agentRunService': true,
|
||||
'aiAgentRunner': true,
|
||||
'aiRunState': true,
|
||||
'aiStorage': true,
|
||||
'config': true,
|
||||
'content': false,
|
||||
'credentialService': true,
|
||||
'deploymentService': true,
|
||||
'eventHub': false,
|
||||
'jwt': false,
|
||||
'kysely': false,
|
||||
'logger': true,
|
||||
'metaService': true,
|
||||
'queueService': false,
|
||||
'schedulerService': true,
|
||||
'schema': true,
|
||||
'secrets': true,
|
||||
'sessionStore': false,
|
||||
'variables': true,
|
||||
'workflowRunService': true,
|
||||
'workflowService': true,
|
||||
} as const
|
||||
|
||||
// Wire services map: true if required, false if available but unused
|
||||
export const requiredWireServices = {
|
||||
} as const
|
||||
|
||||
// Type exports
|
||||
export type RequiredSingletonServices = Pick<SingletonServices, 'agentRunService' | 'aiAgentRunner' | 'aiRunState' | 'aiStorage' | 'config' | 'credentialService' | 'deploymentService' | 'logger' | 'metaService' | 'schedulerService' | 'schema' | 'secrets' | 'variables' | 'workflowRunService' | 'workflowService'> & Partial<Omit<SingletonServices, 'agentRunService' | 'aiAgentRunner' | 'aiRunState' | 'aiStorage' | 'config' | 'credentialService' | 'deploymentService' | 'logger' | 'metaService' | 'schedulerService' | 'schema' | 'secrets' | 'variables' | 'workflowRunService' | 'workflowService'>>
|
||||
|
||||
export type RequiredWireServices = Partial<Services>
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
/**
|
||||
* Main type export hub - re-exports all wiring-specific types
|
||||
*/
|
||||
|
||||
// Core function, middleware, and permission types
|
||||
export * from './function/pikku-function-types.gen.js'
|
||||
|
||||
// HTTP wiring types
|
||||
export * from './http/pikku-http-types.gen.js'
|
||||
|
||||
// Channel wiring types
|
||||
export * from './channel/pikku-channel-types.gen.js'
|
||||
|
||||
// Trigger wiring types
|
||||
export * from './trigger/pikku-trigger-types.gen.js'
|
||||
|
||||
// Scheduler wiring types
|
||||
export * from './scheduler/pikku-scheduler-types.gen.js'
|
||||
|
||||
// Queue wiring types
|
||||
export * from './queue/pikku-queue-types.gen.js'
|
||||
|
||||
// MCP wiring types
|
||||
export * from './mcp/pikku-mcp-types.gen.js'
|
||||
|
||||
// CLI wiring types
|
||||
export * from './cli/pikku-cli-types.gen.js'
|
||||
|
||||
// Node wiring types
|
||||
export * from './console/pikku-node-types.gen.js'
|
||||
|
||||
// Secret definition types
|
||||
export * from './secrets/pikku-secret-types.gen.js'
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
/**
|
||||
* Queue-specific type definitions for tree-shaking optimization
|
||||
*/
|
||||
|
||||
import { CoreQueueWorker, wireQueueWorker as wireQueueWorkerCore } from '@pikku/core/queue'
|
||||
import type { PikkuFunctionConfig } from '../function/pikku-function-types.gen.js'
|
||||
|
||||
/**
|
||||
* Type definition for queue workers that process background jobs.
|
||||
*
|
||||
* @template In - Input type for the queue job
|
||||
* @template Out - Output type for the queue job
|
||||
*/
|
||||
type QueueWiring<In, Out> = CoreQueueWorker<PikkuFunctionConfig<In, Out, 'session' | 'rpc'>>
|
||||
|
||||
/**
|
||||
* Registers a queue worker with the Pikku framework.
|
||||
* Workers process background jobs from queues.
|
||||
*
|
||||
* @param queueWorker - Queue worker definition with job handler
|
||||
*/
|
||||
export const wireQueueWorker = (queueWorker: QueueWiring<any, any>) => {
|
||||
wireQueueWorkerCore(queueWorker as any)
|
||||
}
|
||||
78
packages/functions/packages/functions/.pikku/queue/pikku-queue-workers-wirings-map.gen.d.ts
vendored
Normal file
78
packages/functions/packages/functions/.pikku/queue/pikku-queue-workers-wirings-map.gen.d.ts
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
/**
|
||||
* This provides the structure needed for typescript to be aware of Queue workers and their input/output types
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
export type AgentApproveCallerInput = { agentName: string; runId: string; approvals: { toolCallId: string; approved: boolean; }[]; }
|
||||
export type AgentCallerInput = { agentName: string; message: string; threadId: string; resourceId: string; }
|
||||
export type AgentResumeCallerInput = { agentName: string; runId: string; toolCallId: string; approved: boolean; }
|
||||
export type AgentStreamCallerInput = { agentName: string; message: string; threadId: string; resourceId: string; }
|
||||
export type DeleteAgentThreadInput = { threadId: string; resourceId?: string; }
|
||||
export type DeleteAgentThreadOutput = { deleted: boolean; }
|
||||
export type GetAgentThreadMessagesInput = { threadId: string; resourceId?: string; }
|
||||
export type GetAgentThreadMessagesOutput = any[]
|
||||
export type GetAgentThreadRunsInput = { threadId: string; resourceId?: string; }
|
||||
export type GetAgentThreadRunsOutput = any[]
|
||||
export type GetAgentThreadsInput = { agentName?: string; resourceId?: string; limit?: number; offset?: number; }
|
||||
export type GetAgentThreadsOutput = any[]
|
||||
export type GraphStarterInput = { workflowName: string; nodeId: string; data?: unknown; }
|
||||
export type GraphStarterOutput = { runId: string; }
|
||||
export type PikkuConsoleGetSecretInput = { secretId: string; }
|
||||
export type PikkuConsoleGetSecretOutput = { exists: boolean; value: unknown; }
|
||||
export type PikkuConsoleGetVariableInput = { variableId: string; }
|
||||
export type PikkuConsoleGetVariableOutput = { exists: boolean; value: unknown; }
|
||||
export type PikkuConsoleHasSecretInput = { secretId: string; }
|
||||
export type PikkuConsoleHasSecretOutput = { exists: boolean; }
|
||||
export type PikkuConsoleSetSecretInput = { secretId: string; value: unknown; }
|
||||
export type PikkuConsoleSetSecretOutput = { success: boolean; }
|
||||
export type PikkuConsoleSetVariableInput = { variableId: string; value: unknown; }
|
||||
export type PikkuConsoleSetVariableOutput = { success: boolean; }
|
||||
export type RemoteRPCHandlerInput = { rpcName: string; data?: unknown; }
|
||||
export type RpcCallerInput = { rpcName: string; data?: unknown; }
|
||||
export type WorkflowRunnerInput = { workflowName: string; data?: unknown; }
|
||||
export type WorkflowStarterInput = { workflowName: string; data?: unknown; }
|
||||
export type WorkflowStarterOutput = { runId: string; }
|
||||
export type WorkflowStatusCheckerInput = { workflowName: string; runId: string; }
|
||||
export type WorkflowStatusStreamFullInput = { workflowName: string; runId: string; }
|
||||
export type WorkflowStatusStreamInput = { workflowName: string; runId: string; }
|
||||
|
||||
import type { QueueJob } from '@pikku/core/queue'
|
||||
|
||||
interface QueueHandler<I, O> {
|
||||
input: I;
|
||||
output: O;
|
||||
}
|
||||
|
||||
export type QueueMap = {
|
||||
readonly 'pikku-remote-internal-rpc': QueueHandler<RemoteRPCHandlerInput, null>,
|
||||
};
|
||||
|
||||
|
||||
type QueueAdd = <Name extends keyof QueueMap>(
|
||||
name: Name,
|
||||
data: QueueMap[Name]['input'],
|
||||
options?: {
|
||||
priority?: number
|
||||
delay?: number
|
||||
attempts?: number
|
||||
removeOnComplete?: number
|
||||
removeOnFail?: number
|
||||
jobId?: string
|
||||
}
|
||||
) => Promise<string>
|
||||
|
||||
type QueueGetJob = <Name extends keyof QueueMap>(
|
||||
name: Name,
|
||||
jobId: string
|
||||
) => Promise<QueueJob<QueueMap[Name]['input'], QueueMap[Name]['output']> | null>
|
||||
|
||||
export type TypedPikkuQueue = {
|
||||
add: QueueAdd;
|
||||
getJob: QueueGetJob;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"pikku-remote-internal-rpc": {
|
||||
"pikkuFuncId": "remoteRPCHandler",
|
||||
"name": "pikku-remote-internal-rpc"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
import { pikkuState } from '@pikku/core/internal'
|
||||
import { QueueWorkersMeta } from '@pikku/core/queue'
|
||||
import metaData from './pikku-queue-workers-wirings-meta.gen.json' with { type: 'json' }
|
||||
|
||||
pikkuState(null, 'queue', 'meta', metaData as QueueWorkersMeta)
|
||||
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
/* The files with an addQueueWorkers function call */
|
||||
import '../../../../src/scaffold/rpc-remote.gen.js'
|
||||
148
packages/functions/packages/functions/.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts
vendored
Normal file
148
packages/functions/packages/functions/.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
/**
|
||||
* This provides the structure needed for typescript to be aware of RPCs and their return types
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export type AgentApproveCallerInput = { agentName: string; runId: string; approvals: { toolCallId: string; approved: boolean; }[]; }
|
||||
export type AgentCallerInput = { agentName: string; message: string; threadId: string; resourceId: string; }
|
||||
export type AgentResumeCallerInput = { agentName: string; runId: string; toolCallId: string; approved: boolean; }
|
||||
export type AgentStreamCallerInput = { agentName: string; message: string; threadId: string; resourceId: string; }
|
||||
export type DeleteAgentThreadInput = { threadId: string; resourceId?: string; }
|
||||
export type DeleteAgentThreadOutput = { deleted: boolean; }
|
||||
export type GetAgentThreadMessagesInput = { threadId: string; resourceId?: string; }
|
||||
export type GetAgentThreadMessagesOutput = any[]
|
||||
export type GetAgentThreadRunsInput = { threadId: string; resourceId?: string; }
|
||||
export type GetAgentThreadRunsOutput = any[]
|
||||
export type GetAgentThreadsInput = { agentName?: string; resourceId?: string; limit?: number; offset?: number; }
|
||||
export type GetAgentThreadsOutput = any[]
|
||||
export type GraphStarterInput = { workflowName: string; nodeId: string; data?: unknown; }
|
||||
export type GraphStarterOutput = { runId: string; }
|
||||
export type PikkuConsoleGetSecretInput = { secretId: string; }
|
||||
export type PikkuConsoleGetSecretOutput = { exists: boolean; value: unknown; }
|
||||
export type PikkuConsoleGetVariableInput = { variableId: string; }
|
||||
export type PikkuConsoleGetVariableOutput = { exists: boolean; value: unknown; }
|
||||
export type PikkuConsoleHasSecretInput = { secretId: string; }
|
||||
export type PikkuConsoleHasSecretOutput = { exists: boolean; }
|
||||
export type PikkuConsoleSetSecretInput = { secretId: string; value: unknown; }
|
||||
export type PikkuConsoleSetSecretOutput = { success: boolean; }
|
||||
export type PikkuConsoleSetVariableInput = { variableId: string; value: unknown; }
|
||||
export type PikkuConsoleSetVariableOutput = { success: boolean; }
|
||||
export type RemoteRPCHandlerInput = { rpcName: string; data?: unknown; }
|
||||
export type RpcCallerInput = { rpcName: string; data?: unknown; }
|
||||
export type WorkflowRunnerInput = { workflowName: string; data?: unknown; }
|
||||
export type WorkflowStarterInput = { workflowName: string; data?: unknown; }
|
||||
export type WorkflowStarterOutput = { runId: string; }
|
||||
export type WorkflowStatusCheckerInput = { workflowName: string; runId: string; }
|
||||
export type WorkflowStatusStreamFullInput = { workflowName: string; runId: string; }
|
||||
export type WorkflowStatusStreamInput = { workflowName: string; runId: string; }
|
||||
|
||||
interface RPCHandler<I, O> {
|
||||
input: I;
|
||||
output: O;
|
||||
}
|
||||
|
||||
export type RPCMap = {
|
||||
readonly 'pikkuConsoleSetSecret': RPCHandler<PikkuConsoleSetSecretInput, PikkuConsoleSetSecretOutput>,
|
||||
readonly 'pikkuConsoleGetVariable': RPCHandler<PikkuConsoleGetVariableInput, PikkuConsoleGetVariableOutput>,
|
||||
readonly 'pikkuConsoleSetVariable': RPCHandler<PikkuConsoleSetVariableInput, PikkuConsoleSetVariableOutput>,
|
||||
readonly 'pikkuConsoleHasSecret': RPCHandler<PikkuConsoleHasSecretInput, PikkuConsoleHasSecretOutput>,
|
||||
readonly 'pikkuConsoleGetSecret': RPCHandler<PikkuConsoleGetSecretInput, PikkuConsoleGetSecretOutput>,
|
||||
readonly 'getAgentThreads': RPCHandler<GetAgentThreadsInput, GetAgentThreadsOutput>,
|
||||
readonly 'getAgentThreadMessages': RPCHandler<GetAgentThreadMessagesInput, GetAgentThreadMessagesOutput>,
|
||||
readonly 'getAgentThreadRuns': RPCHandler<GetAgentThreadRunsInput, GetAgentThreadRunsOutput>,
|
||||
readonly 'deleteAgentThread': RPCHandler<DeleteAgentThreadInput, DeleteAgentThreadOutput>,
|
||||
};
|
||||
|
||||
|
||||
// Addon package RPC maps
|
||||
import type { RPCMap as ConsoleRPCMap } from '@pikku/addon-console/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.js'
|
||||
|
||||
|
||||
// Utility type to prefix keys with namespace (skips 'any' to prevent type poisoning)
|
||||
type PrefixKeys<T, Prefix extends string> = unknown extends T ? {} : {
|
||||
[K in keyof T as `${Prefix}:${string & K}`]: T[K]
|
||||
}
|
||||
|
||||
// Merge all RPC maps with namespace prefixes
|
||||
export type FlattenedRPCMap =
|
||||
RPCMap & PrefixKeys<ConsoleRPCMap, 'console'>
|
||||
|
||||
type IsAny<T> = 0 extends (1 & T) ? true : false
|
||||
type IsVoidishInput<T> = IsAny<T> extends true
|
||||
? false
|
||||
: [T] extends [void | null | undefined]
|
||||
? true
|
||||
: false
|
||||
|
||||
|
||||
export type RPCInvoke = <Name extends keyof FlattenedRPCMap>(
|
||||
...args: IsVoidishInput<FlattenedRPCMap[Name]['input']> extends true
|
||||
? [name: Name]
|
||||
: [name: Name, data: FlattenedRPCMap[Name]['input']]
|
||||
) => Promise<FlattenedRPCMap[Name]['output']>
|
||||
|
||||
export type RPCRemote = <Name extends keyof FlattenedRPCMap>(
|
||||
...args: IsVoidishInput<FlattenedRPCMap[Name]['input']> extends true
|
||||
? [name: Name]
|
||||
: [name: Name, data: FlattenedRPCMap[Name]['input']]
|
||||
) => Promise<FlattenedRPCMap[Name]['output']>
|
||||
|
||||
import type { FlattenedWorkflowMap } from '../workflow/pikku-workflow-map.gen.d.js'
|
||||
|
||||
import type { AgentMap } from '../agent/pikku-agent-map.gen.d.js'
|
||||
|
||||
// Addon package Agent maps
|
||||
import type { AgentMap as ConsoleAgentMap } from '@pikku/addon-console/.pikku/agent/pikku-agent-map.gen.d.js'
|
||||
|
||||
|
||||
type FlattenedAgentMap =
|
||||
AgentMap & PrefixKeys<ConsoleAgentMap, 'console'>
|
||||
|
||||
|
||||
import type { PikkuRPC } from '@pikku/core/rpc'
|
||||
|
||||
interface AIAgentInput {
|
||||
message: string
|
||||
threadId: string
|
||||
resourceId: string
|
||||
}
|
||||
|
||||
export type TypedStartWorkflow = <Name extends keyof FlattenedWorkflowMap>(
|
||||
name: Name,
|
||||
input: FlattenedWorkflowMap[Name]['input'],
|
||||
options?: { startNode?: string }
|
||||
) => Promise<{ runId: string }>
|
||||
|
||||
export type TypedRunWorkflow = <Name extends keyof FlattenedWorkflowMap>(
|
||||
name: Name,
|
||||
input: FlattenedWorkflowMap[Name]['input']
|
||||
) => Promise<FlattenedWorkflowMap[Name]['output']>
|
||||
|
||||
export type TypedWorkflowStatus = (
|
||||
workflowName: string,
|
||||
runId: string
|
||||
) => Promise<{ id: string; status: 'running' | 'suspended' | 'completed' | 'failed' | 'cancelled'; output?: unknown; error?: { message?: string } }>
|
||||
|
||||
type TypedAgentRun = [keyof FlattenedAgentMap] extends [never]
|
||||
? (name: string, input: AIAgentInput) => Promise<any>
|
||||
: <Name extends keyof FlattenedAgentMap>(
|
||||
name: Name,
|
||||
input: AIAgentInput
|
||||
) => Promise<{ runId: string; result: FlattenedAgentMap[Name]['output']; usage: { inputTokens: number; outputTokens: number } }>
|
||||
|
||||
type TypedAgentStream = [keyof FlattenedAgentMap] extends [never]
|
||||
? (name: string, input: AIAgentInput, options?: { requiresToolApproval?: 'all' | 'explicit' | false }) => Promise<void>
|
||||
: <Name extends keyof FlattenedAgentMap>(
|
||||
name: Name,
|
||||
input: AIAgentInput,
|
||||
options?: { requiresToolApproval?: 'all' | 'explicit' | false }
|
||||
) => Promise<void>
|
||||
|
||||
export type TypedPikkuRPC = PikkuRPC<RPCInvoke, RPCRemote, TypedStartWorkflow, TypedAgentRun, TypedAgentStream>
|
||||
|
||||
160
packages/functions/packages/functions/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts
vendored
Normal file
160
packages/functions/packages/functions/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts
vendored
Normal file
@@ -0,0 +1,160 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
/**
|
||||
* This provides the structure needed for typescript to be aware of RPCs and their return types
|
||||
*/
|
||||
|
||||
|
||||
import type { WorkflowRunStatus } from '@pikku/core/dist/wirings/workflow/workflow.types'
|
||||
|
||||
|
||||
export type AgentApproveCallerInput = { agentName: string; runId: string; approvals: { toolCallId: string; approved: boolean; }[]; }
|
||||
export type AgentCallerInput = { agentName: string; message: string; threadId: string; resourceId: string; }
|
||||
export type AgentResumeCallerInput = { agentName: string; runId: string; toolCallId: string; approved: boolean; }
|
||||
export type AgentStreamCallerInput = { agentName: string; message: string; threadId: string; resourceId: string; }
|
||||
export type DeleteAgentThreadInput = { threadId: string; resourceId?: string; }
|
||||
export type DeleteAgentThreadOutput = { deleted: boolean; }
|
||||
export type GetAgentThreadMessagesInput = { threadId: string; resourceId?: string; }
|
||||
export type GetAgentThreadMessagesOutput = any[]
|
||||
export type GetAgentThreadRunsInput = { threadId: string; resourceId?: string; }
|
||||
export type GetAgentThreadRunsOutput = any[]
|
||||
export type GetAgentThreadsInput = { agentName?: string; resourceId?: string; limit?: number; offset?: number; }
|
||||
export type GetAgentThreadsOutput = any[]
|
||||
export type GraphStarterInput = { workflowName: string; nodeId: string; data?: unknown; }
|
||||
export type GraphStarterOutput = { runId: string; }
|
||||
export type PikkuConsoleGetSecretInput = { secretId: string; }
|
||||
export type PikkuConsoleGetSecretOutput = { exists: boolean; value: unknown; }
|
||||
export type PikkuConsoleGetVariableInput = { variableId: string; }
|
||||
export type PikkuConsoleGetVariableOutput = { exists: boolean; value: unknown; }
|
||||
export type PikkuConsoleHasSecretInput = { secretId: string; }
|
||||
export type PikkuConsoleHasSecretOutput = { exists: boolean; }
|
||||
export type PikkuConsoleSetSecretInput = { secretId: string; value: unknown; }
|
||||
export type PikkuConsoleSetSecretOutput = { success: boolean; }
|
||||
export type PikkuConsoleSetVariableInput = { variableId: string; value: unknown; }
|
||||
export type PikkuConsoleSetVariableOutput = { success: boolean; }
|
||||
export type RemoteRPCHandlerInput = { rpcName: string; data?: unknown; }
|
||||
export type RpcCallerInput = { rpcName: string; data?: unknown; }
|
||||
export type WorkflowRunnerInput = { workflowName: string; data?: unknown; }
|
||||
export type WorkflowStarterInput = { workflowName: string; data?: unknown; }
|
||||
export type WorkflowStarterOutput = { runId: string; }
|
||||
export type WorkflowStatusCheckerInput = { workflowName: string; runId: string; }
|
||||
export type WorkflowStatusStreamFullInput = { workflowName: string; runId: string; }
|
||||
export type WorkflowStatusStreamInput = { workflowName: string; runId: string; }
|
||||
|
||||
interface RPCHandler<I, O> {
|
||||
input: I;
|
||||
output: O;
|
||||
}
|
||||
|
||||
export type RPCMap = {
|
||||
readonly 'pikkuConsoleSetSecret': RPCHandler<PikkuConsoleSetSecretInput, PikkuConsoleSetSecretOutput>,
|
||||
readonly 'pikkuConsoleGetVariable': RPCHandler<PikkuConsoleGetVariableInput, PikkuConsoleGetVariableOutput>,
|
||||
readonly 'pikkuConsoleSetVariable': RPCHandler<PikkuConsoleSetVariableInput, PikkuConsoleSetVariableOutput>,
|
||||
readonly 'pikkuConsoleHasSecret': RPCHandler<PikkuConsoleHasSecretInput, PikkuConsoleHasSecretOutput>,
|
||||
readonly 'pikkuConsoleGetSecret': RPCHandler<PikkuConsoleGetSecretInput, PikkuConsoleGetSecretOutput>,
|
||||
readonly 'remoteRPCHandler': RPCHandler<RemoteRPCHandlerInput, null>,
|
||||
readonly 'workflowStarter': RPCHandler<WorkflowStarterInput, WorkflowStarterOutput>,
|
||||
readonly 'workflowRunner': RPCHandler<WorkflowRunnerInput, null>,
|
||||
readonly 'workflowStatusChecker': RPCHandler<WorkflowStatusCheckerInput, WorkflowRunStatus>,
|
||||
readonly 'workflowStatusStream': RPCHandler<WorkflowStatusStreamInput, null>,
|
||||
readonly 'workflowStatusStreamFull': RPCHandler<WorkflowStatusStreamFullInput, null>,
|
||||
readonly 'graphStarter': RPCHandler<GraphStarterInput, GraphStarterOutput>,
|
||||
readonly 'rpcCaller': RPCHandler<RpcCallerInput, null>,
|
||||
readonly 'agentCaller': RPCHandler<AgentCallerInput, null>,
|
||||
readonly 'agentStreamCaller': RPCHandler<AgentStreamCallerInput, null>,
|
||||
readonly 'agentApproveCaller': RPCHandler<AgentApproveCallerInput, null>,
|
||||
readonly 'agentResumeCaller': RPCHandler<AgentResumeCallerInput, null>,
|
||||
readonly 'getAgentThreads': RPCHandler<GetAgentThreadsInput, GetAgentThreadsOutput>,
|
||||
readonly 'getAgentThreadMessages': RPCHandler<GetAgentThreadMessagesInput, GetAgentThreadMessagesOutput>,
|
||||
readonly 'getAgentThreadRuns': RPCHandler<GetAgentThreadRunsInput, GetAgentThreadRunsOutput>,
|
||||
readonly 'deleteAgentThread': RPCHandler<DeleteAgentThreadInput, DeleteAgentThreadOutput>,
|
||||
};
|
||||
|
||||
|
||||
// Addon package RPC maps
|
||||
import type { RPCMap as ConsoleRPCMap } from '@pikku/addon-console/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.js'
|
||||
|
||||
|
||||
// Utility type to prefix keys with namespace (skips 'any' to prevent type poisoning)
|
||||
type PrefixKeys<T, Prefix extends string> = unknown extends T ? {} : {
|
||||
[K in keyof T as `${Prefix}:${string & K}`]: T[K]
|
||||
}
|
||||
|
||||
// Merge all RPC maps with namespace prefixes
|
||||
export type FlattenedRPCMap =
|
||||
RPCMap & PrefixKeys<ConsoleRPCMap, 'console'>
|
||||
|
||||
type IsAny<T> = 0 extends (1 & T) ? true : false
|
||||
type IsVoidishInput<T> = IsAny<T> extends true
|
||||
? false
|
||||
: [T] extends [void | null | undefined]
|
||||
? true
|
||||
: false
|
||||
|
||||
|
||||
export type RPCInvoke = <Name extends keyof FlattenedRPCMap>(
|
||||
...args: IsVoidishInput<FlattenedRPCMap[Name]['input']> extends true
|
||||
? [name: Name]
|
||||
: [name: Name, data: FlattenedRPCMap[Name]['input']]
|
||||
) => Promise<FlattenedRPCMap[Name]['output']>
|
||||
|
||||
export type RPCRemote = <Name extends keyof FlattenedRPCMap>(
|
||||
...args: IsVoidishInput<FlattenedRPCMap[Name]['input']> extends true
|
||||
? [name: Name]
|
||||
: [name: Name, data: FlattenedRPCMap[Name]['input']]
|
||||
) => Promise<FlattenedRPCMap[Name]['output']>
|
||||
|
||||
import type { FlattenedWorkflowMap } from '../workflow/pikku-workflow-map.gen.d.js'
|
||||
|
||||
import type { AgentMap } from '../agent/pikku-agent-map.gen.d.js'
|
||||
|
||||
// Addon package Agent maps
|
||||
import type { AgentMap as ConsoleAgentMap } from '@pikku/addon-console/.pikku/agent/pikku-agent-map.gen.d.js'
|
||||
|
||||
|
||||
type FlattenedAgentMap =
|
||||
AgentMap & PrefixKeys<ConsoleAgentMap, 'console'>
|
||||
|
||||
|
||||
import type { PikkuRPC } from '@pikku/core/rpc'
|
||||
|
||||
interface AIAgentInput {
|
||||
message: string
|
||||
threadId: string
|
||||
resourceId: string
|
||||
}
|
||||
|
||||
export type TypedStartWorkflow = <Name extends keyof FlattenedWorkflowMap>(
|
||||
name: Name,
|
||||
input: FlattenedWorkflowMap[Name]['input'],
|
||||
options?: { startNode?: string }
|
||||
) => Promise<{ runId: string }>
|
||||
|
||||
export type TypedRunWorkflow = <Name extends keyof FlattenedWorkflowMap>(
|
||||
name: Name,
|
||||
input: FlattenedWorkflowMap[Name]['input']
|
||||
) => Promise<FlattenedWorkflowMap[Name]['output']>
|
||||
|
||||
export type TypedWorkflowStatus = (
|
||||
workflowName: string,
|
||||
runId: string
|
||||
) => Promise<{ id: string; status: 'running' | 'suspended' | 'completed' | 'failed' | 'cancelled'; output?: unknown; error?: { message?: string } }>
|
||||
|
||||
type TypedAgentRun = [keyof FlattenedAgentMap] extends [never]
|
||||
? (name: string, input: AIAgentInput) => Promise<any>
|
||||
: <Name extends keyof FlattenedAgentMap>(
|
||||
name: Name,
|
||||
input: AIAgentInput
|
||||
) => Promise<{ runId: string; result: FlattenedAgentMap[Name]['output']; usage: { inputTokens: number; outputTokens: number } }>
|
||||
|
||||
type TypedAgentStream = [keyof FlattenedAgentMap] extends [never]
|
||||
? (name: string, input: AIAgentInput, options?: { requiresToolApproval?: 'all' | 'explicit' | false }) => Promise<void>
|
||||
: <Name extends keyof FlattenedAgentMap>(
|
||||
name: Name,
|
||||
input: AIAgentInput,
|
||||
options?: { requiresToolApproval?: 'all' | 'explicit' | false }
|
||||
) => Promise<void>
|
||||
|
||||
export type TypedPikkuRPC = PikkuRPC<RPCInvoke, RPCRemote, TypedStartWorkflow, TypedAgentRun, TypedAgentStream>
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"pikkuConsoleSetSecret": "pikkuConsoleSetSecret",
|
||||
"pikkuConsoleGetVariable": "pikkuConsoleGetVariable",
|
||||
"pikkuConsoleSetVariable": "pikkuConsoleSetVariable",
|
||||
"pikkuConsoleHasSecret": "pikkuConsoleHasSecret",
|
||||
"pikkuConsoleGetSecret": "pikkuConsoleGetSecret",
|
||||
"remoteRPCHandler": "remoteRPCHandler",
|
||||
"workflowStarter": "workflowStarter",
|
||||
"workflowRunner": "workflowRunner",
|
||||
"workflowStatusChecker": "workflowStatusChecker",
|
||||
"workflowStatusStream": "workflowStatusStream",
|
||||
"workflowStatusStreamFull": "workflowStatusStreamFull",
|
||||
"graphStarter": "graphStarter",
|
||||
"rpcCaller": "rpcCaller",
|
||||
"agentCaller": "agentCaller",
|
||||
"agentStreamCaller": "agentStreamCaller",
|
||||
"agentApproveCaller": "agentApproveCaller",
|
||||
"agentResumeCaller": "agentResumeCaller",
|
||||
"getAgentThreads": "getAgentThreads",
|
||||
"getAgentThreadMessages": "getAgentThreadMessages",
|
||||
"getAgentThreadRuns": "getAgentThreadRuns",
|
||||
"deleteAgentThread": "deleteAgentThread"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
import { pikkuState } from '@pikku/core/internal'
|
||||
import metaData from './pikku-rpc-wirings-meta.internal.gen.json' with { type: 'json' }
|
||||
pikkuState(null, 'rpc', 'meta', metaData as Record<string, string>)
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
/**
|
||||
* Scheduler-specific type definitions for tree-shaking optimization
|
||||
*/
|
||||
|
||||
import { CoreScheduledTask, wireScheduler as wireSchedulerCore } from '@pikku/core/scheduler'
|
||||
import type { PikkuFunctionConfig, PikkuMiddleware } from '../function/pikku-function-types.gen.js'
|
||||
|
||||
/**
|
||||
* Type definition for scheduled tasks that run at specified intervals.
|
||||
* These are sessionless functions that execute based on cron expressions.
|
||||
*/
|
||||
type SchedulerWiring = CoreScheduledTask<PikkuFunctionConfig<void, void, 'session' | 'rpc'>, PikkuMiddleware>
|
||||
|
||||
/**
|
||||
* Registers a scheduled task with the Pikku framework.
|
||||
* Tasks run based on cron expressions and are sessionless.
|
||||
*
|
||||
* @param task - Scheduled task definition with cron expression and handler
|
||||
*/
|
||||
export const wireScheduler = (task: SchedulerWiring) => {
|
||||
wireSchedulerCore(task as any)
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
import { addSchema } from '@pikku/core/schema'
|
||||
|
||||
import * as PikkuConsoleSetSecretInput from './schemas/PikkuConsoleSetSecretInput.schema.json' with { type: 'json' }
|
||||
addSchema('PikkuConsoleSetSecretInput', PikkuConsoleSetSecretInput)
|
||||
|
||||
|
||||
import * as PikkuConsoleSetSecretOutput from './schemas/PikkuConsoleSetSecretOutput.schema.json' with { type: 'json' }
|
||||
addSchema('PikkuConsoleSetSecretOutput', PikkuConsoleSetSecretOutput)
|
||||
|
||||
|
||||
import * as PikkuConsoleGetVariableInput from './schemas/PikkuConsoleGetVariableInput.schema.json' with { type: 'json' }
|
||||
addSchema('PikkuConsoleGetVariableInput', PikkuConsoleGetVariableInput)
|
||||
|
||||
|
||||
import * as PikkuConsoleGetVariableOutput from './schemas/PikkuConsoleGetVariableOutput.schema.json' with { type: 'json' }
|
||||
addSchema('PikkuConsoleGetVariableOutput', PikkuConsoleGetVariableOutput)
|
||||
|
||||
|
||||
import * as PikkuConsoleSetVariableInput from './schemas/PikkuConsoleSetVariableInput.schema.json' with { type: 'json' }
|
||||
addSchema('PikkuConsoleSetVariableInput', PikkuConsoleSetVariableInput)
|
||||
|
||||
|
||||
import * as PikkuConsoleSetVariableOutput from './schemas/PikkuConsoleSetVariableOutput.schema.json' with { type: 'json' }
|
||||
addSchema('PikkuConsoleSetVariableOutput', PikkuConsoleSetVariableOutput)
|
||||
|
||||
|
||||
import * as PikkuConsoleHasSecretInput from './schemas/PikkuConsoleHasSecretInput.schema.json' with { type: 'json' }
|
||||
addSchema('PikkuConsoleHasSecretInput', PikkuConsoleHasSecretInput)
|
||||
|
||||
|
||||
import * as PikkuConsoleHasSecretOutput from './schemas/PikkuConsoleHasSecretOutput.schema.json' with { type: 'json' }
|
||||
addSchema('PikkuConsoleHasSecretOutput', PikkuConsoleHasSecretOutput)
|
||||
|
||||
|
||||
import * as PikkuConsoleGetSecretInput from './schemas/PikkuConsoleGetSecretInput.schema.json' with { type: 'json' }
|
||||
addSchema('PikkuConsoleGetSecretInput', PikkuConsoleGetSecretInput)
|
||||
|
||||
|
||||
import * as PikkuConsoleGetSecretOutput from './schemas/PikkuConsoleGetSecretOutput.schema.json' with { type: 'json' }
|
||||
addSchema('PikkuConsoleGetSecretOutput', PikkuConsoleGetSecretOutput)
|
||||
|
||||
|
||||
import * as StreamWorkflowRunInput from './schemas/StreamWorkflowRunInput.schema.json' with { type: 'json' }
|
||||
addSchema('StreamWorkflowRunInput', StreamWorkflowRunInput)
|
||||
|
||||
|
||||
import * as RemoteRPCHandlerInput from './schemas/RemoteRPCHandlerInput.schema.json' with { type: 'json' }
|
||||
addSchema('RemoteRPCHandlerInput', RemoteRPCHandlerInput)
|
||||
|
||||
|
||||
import * as WorkflowStarterInput from './schemas/WorkflowStarterInput.schema.json' with { type: 'json' }
|
||||
addSchema('WorkflowStarterInput', WorkflowStarterInput)
|
||||
|
||||
|
||||
import * as WorkflowStarterOutput from './schemas/WorkflowStarterOutput.schema.json' with { type: 'json' }
|
||||
addSchema('WorkflowStarterOutput', WorkflowStarterOutput)
|
||||
|
||||
|
||||
import * as WorkflowRunnerInput from './schemas/WorkflowRunnerInput.schema.json' with { type: 'json' }
|
||||
addSchema('WorkflowRunnerInput', WorkflowRunnerInput)
|
||||
|
||||
|
||||
import * as WorkflowStatusCheckerInput from './schemas/WorkflowStatusCheckerInput.schema.json' with { type: 'json' }
|
||||
addSchema('WorkflowStatusCheckerInput', WorkflowStatusCheckerInput)
|
||||
|
||||
|
||||
import * as WorkflowRunStatus from './schemas/WorkflowRunStatus.schema.json' with { type: 'json' }
|
||||
addSchema('WorkflowRunStatus', WorkflowRunStatus)
|
||||
|
||||
|
||||
import * as WorkflowStatusStreamInput from './schemas/WorkflowStatusStreamInput.schema.json' with { type: 'json' }
|
||||
addSchema('WorkflowStatusStreamInput', WorkflowStatusStreamInput)
|
||||
|
||||
|
||||
import * as WorkflowStatusStreamFullInput from './schemas/WorkflowStatusStreamFullInput.schema.json' with { type: 'json' }
|
||||
addSchema('WorkflowStatusStreamFullInput', WorkflowStatusStreamFullInput)
|
||||
|
||||
|
||||
import * as GraphStarterInput from './schemas/GraphStarterInput.schema.json' with { type: 'json' }
|
||||
addSchema('GraphStarterInput', GraphStarterInput)
|
||||
|
||||
|
||||
import * as GraphStarterOutput from './schemas/GraphStarterOutput.schema.json' with { type: 'json' }
|
||||
addSchema('GraphStarterOutput', GraphStarterOutput)
|
||||
|
||||
|
||||
import * as RpcCallerInput from './schemas/RpcCallerInput.schema.json' with { type: 'json' }
|
||||
addSchema('RpcCallerInput', RpcCallerInput)
|
||||
|
||||
|
||||
import * as AgentCallerInput from './schemas/AgentCallerInput.schema.json' with { type: 'json' }
|
||||
addSchema('AgentCallerInput', AgentCallerInput)
|
||||
|
||||
|
||||
import * as AgentStreamCallerInput from './schemas/AgentStreamCallerInput.schema.json' with { type: 'json' }
|
||||
addSchema('AgentStreamCallerInput', AgentStreamCallerInput)
|
||||
|
||||
|
||||
import * as AgentApproveCallerInput from './schemas/AgentApproveCallerInput.schema.json' with { type: 'json' }
|
||||
addSchema('AgentApproveCallerInput', AgentApproveCallerInput)
|
||||
|
||||
|
||||
import * as AgentResumeCallerInput from './schemas/AgentResumeCallerInput.schema.json' with { type: 'json' }
|
||||
addSchema('AgentResumeCallerInput', AgentResumeCallerInput)
|
||||
|
||||
|
||||
import * as GetAgentThreadsInput from './schemas/GetAgentThreadsInput.schema.json' with { type: 'json' }
|
||||
addSchema('GetAgentThreadsInput', GetAgentThreadsInput)
|
||||
|
||||
|
||||
import * as GetAgentThreadsOutput from './schemas/GetAgentThreadsOutput.schema.json' with { type: 'json' }
|
||||
addSchema('GetAgentThreadsOutput', GetAgentThreadsOutput)
|
||||
|
||||
|
||||
import * as GetAgentThreadMessagesInput from './schemas/GetAgentThreadMessagesInput.schema.json' with { type: 'json' }
|
||||
addSchema('GetAgentThreadMessagesInput', GetAgentThreadMessagesInput)
|
||||
|
||||
|
||||
import * as GetAgentThreadMessagesOutput from './schemas/GetAgentThreadMessagesOutput.schema.json' with { type: 'json' }
|
||||
addSchema('GetAgentThreadMessagesOutput', GetAgentThreadMessagesOutput)
|
||||
|
||||
|
||||
import * as GetAgentThreadRunsInput from './schemas/GetAgentThreadRunsInput.schema.json' with { type: 'json' }
|
||||
addSchema('GetAgentThreadRunsInput', GetAgentThreadRunsInput)
|
||||
|
||||
|
||||
import * as GetAgentThreadRunsOutput from './schemas/GetAgentThreadRunsOutput.schema.json' with { type: 'json' }
|
||||
addSchema('GetAgentThreadRunsOutput', GetAgentThreadRunsOutput)
|
||||
|
||||
|
||||
import * as DeleteAgentThreadInput from './schemas/DeleteAgentThreadInput.schema.json' with { type: 'json' }
|
||||
addSchema('DeleteAgentThreadInput', DeleteAgentThreadInput)
|
||||
|
||||
|
||||
import * as DeleteAgentThreadOutput from './schemas/DeleteAgentThreadOutput.schema.json' with { type: 'json' }
|
||||
addSchema('DeleteAgentThreadOutput', DeleteAgentThreadOutput)
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"agentName":{"type":"string"},"runId":{"type":"string"},"approvals":{"type":"array","items":{"type":"object","properties":{"toolCallId":{"type":"string"},"approved":{"type":"boolean"}},"required":["toolCallId","approved"],"additionalProperties":false}}},"required":["agentName","runId","approvals"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"agentName":{"type":"string"},"message":{"type":"string"},"threadId":{"type":"string"},"resourceId":{"type":"string"}},"required":["agentName","message","threadId","resourceId"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"agentName":{"type":"string"},"runId":{"type":"string"},"toolCallId":{"type":"string"},"approved":{"type":"boolean"}},"required":["agentName","runId","toolCallId","approved"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"agentName":{"type":"string"},"message":{"type":"string"},"threadId":{"type":"string"},"resourceId":{"type":"string"}},"required":["agentName","message","threadId","resourceId"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"threadId":{"type":"string"},"resourceId":{"type":"string"}},"required":["threadId"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"deleted":{"type":"boolean"}},"required":["deleted"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"threadId":{"type":"string"},"resourceId":{"type":"string"}},"required":["threadId"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"array","items":{},"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"threadId":{"type":"string"},"resourceId":{"type":"string"}},"required":["threadId"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"array","items":{},"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"agentName":{"type":"string"},"resourceId":{"type":"string"},"limit":{"type":"number"},"offset":{"type":"number"}},"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"array","items":{},"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"workflowName":{"type":"string"},"nodeId":{"type":"string"},"data":{}},"required":["workflowName","nodeId"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"runId":{"type":"string"}},"required":["runId"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"secretId":{"type":"string"}},"required":["secretId"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"exists":{"type":"boolean"},"value":{}},"required":["exists","value"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"variableId":{"type":"string"}},"required":["variableId"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"exists":{"type":"boolean"},"value":{}},"required":["exists","value"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"secretId":{"type":"string"}},"required":["secretId"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"exists":{"type":"boolean"}},"required":["exists"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"secretId":{"type":"string"},"value":{}},"required":["secretId","value"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"success":{"type":"boolean"}},"required":["success"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"variableId":{"type":"string"},"value":{}},"required":["variableId","value"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"success":{"type":"boolean"}},"required":["success"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"rpcName":{"type":"string"},"data":{}},"required":["rpcName"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"rpcName":{"type":"string"},"data":{}},"required":["rpcName"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"runId":{"type":"string"}},"required":["runId"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"id":{"type":"string"},"status":{"$ref":"#/definitions/WorkflowStatus"},"startedAt":{"type":"string","format":"date-time"},"completedAt":{"type":"string","format":"date-time"},"deterministic":{"type":"boolean"},"plannedSteps":{"type":"array","items":{"$ref":"#/definitions/WorkflowPlannedStep"}},"steps":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"status":{"$ref":"#/definitions/StepStatus"},"duration":{"type":"number"}},"required":["name","status"],"additionalProperties":false}},"output":{},"error":{"type":"object","properties":{"message":{"type":"string"}},"required":["message"],"additionalProperties":false}},"required":["id","status","startedAt","steps"],"additionalProperties":false,"definitions":{"WorkflowStatus":{"type":"string","enum":["running","suspended","completed","failed","cancelled"],"description":"Workflow run status"},"WorkflowPlannedStep":{"type":"object","properties":{"stepName":{"type":"string","description":"Human-readable step label for UI timeline"}},"required":["stepName"],"additionalProperties":false},"StepStatus":{"type":"string","enum":["pending","running","scheduled","succeeded","failed","suspended"],"description":"Workflow step status"}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"workflowName":{"type":"string"},"data":{}},"required":["workflowName"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"workflowName":{"type":"string"},"data":{}},"required":["workflowName"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"runId":{"type":"string"}},"required":["runId"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"workflowName":{"type":"string"},"runId":{"type":"string"}},"required":["workflowName","runId"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"workflowName":{"type":"string"},"runId":{"type":"string"}},"required":["workflowName","runId"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1 @@
|
||||
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"workflowName":{"type":"string"},"runId":{"type":"string"}},"required":["workflowName","runId"],"additionalProperties":false,"definitions":{}}
|
||||
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
export { wireSecret } from '@pikku/core/secret'
|
||||
export type { CoreSecret, SecretDefinitionMeta, SecretDefinitionsMeta } from '@pikku/core/secret'
|
||||
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
import { TypedSecretService as CoreTypedSecretService, type CredentialMeta } from '@pikku/core/services'
|
||||
import type { SecretService } from '@pikku/core/services'
|
||||
|
||||
export interface CredentialsMap {
|
||||
|
||||
}
|
||||
|
||||
export type SecretId = keyof CredentialsMap
|
||||
|
||||
const CREDENTIALS_META: Record<string, CredentialMeta> = {
|
||||
|
||||
}
|
||||
|
||||
export class TypedSecretService extends CoreTypedSecretService<CredentialsMap> {
|
||||
constructor(secrets: SecretService) {
|
||||
super(secrets, CREDENTIALS_META)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
/**
|
||||
* Trigger-specific type definitions for tree-shaking optimization
|
||||
*/
|
||||
|
||||
import { CorePikkuTriggerFunction, CorePikkuTriggerFunctionConfig, CoreTrigger, wireTrigger as wireTriggerCore, wireTriggerSource as wireTriggerSourceCore } from '@pikku/core/trigger'
|
||||
import type { CoreNodeConfig } from '@pikku/core/node'
|
||||
import type { SingletonServices } from '../../../../src/application-types.d.js'
|
||||
import type { StandardSchemaV1 } from '@standard-schema/spec'
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A trigger function that sets up a subscription and returns a teardown function.
|
||||
* The trigger is fired via wire.trigger.invoke(data).
|
||||
*
|
||||
* @template TInput - Input type (configuration passed when wired)
|
||||
* @template TOutput - Output type produced when trigger fires
|
||||
*/
|
||||
export type PikkuTriggerFunction<
|
||||
TInput = unknown,
|
||||
TOutput = unknown
|
||||
> = CorePikkuTriggerFunction<TInput, TOutput, SingletonServices>
|
||||
|
||||
/**
|
||||
* Configuration object for creating a trigger function with metadata
|
||||
*/
|
||||
export type PikkuTriggerFunctionConfig<
|
||||
TInput = unknown,
|
||||
TOutput = unknown,
|
||||
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
||||
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
||||
> = CorePikkuTriggerFunctionConfig<TInput, TOutput, SingletonServices, InputSchema, OutputSchema>
|
||||
|
||||
/**
|
||||
* Helper type to infer the output type from a Standard Schema
|
||||
*/
|
||||
type InferSchemaOutput<T> = T extends StandardSchemaV1<any, infer Output> ? Output : never
|
||||
|
||||
/**
|
||||
* Configuration object for trigger functions with Zod schema validation.
|
||||
* Use this when you want to define input/output schemas using Zod.
|
||||
* Types are automatically inferred from the schemas.
|
||||
*/
|
||||
export type PikkuTriggerFunctionConfigWithSchema<
|
||||
InputSchema extends StandardSchemaV1,
|
||||
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
||||
> = {
|
||||
title?: string
|
||||
description?: string
|
||||
tags?: string[]
|
||||
func: PikkuTriggerFunction<
|
||||
InferSchemaOutput<InputSchema>,
|
||||
OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown
|
||||
>
|
||||
input: InputSchema
|
||||
output?: OutputSchema
|
||||
node?: CoreNodeConfig
|
||||
}
|
||||
|
||||
/**
|
||||
* Type definition for trigger wirings.
|
||||
* Declares a trigger name and its target pikku function.
|
||||
*/
|
||||
export type TriggerWiring = CoreTrigger
|
||||
|
||||
/**
|
||||
* A trigger source with the subscription function, using project-specific services.
|
||||
*
|
||||
* @template TInput - Input type passed to the trigger function
|
||||
* @template TOutput - Output type produced when trigger fires
|
||||
*/
|
||||
export type TriggerSource<
|
||||
TInput = unknown,
|
||||
TOutput = unknown
|
||||
> = {
|
||||
name: string
|
||||
func: PikkuTriggerFunctionConfig<TInput, TOutput>
|
||||
} & (unknown extends TInput ? { input?: TInput } : { input: TInput })
|
||||
|
||||
/**
|
||||
* Creates a trigger function configuration.
|
||||
* Use this to define trigger functions that set up subscriptions.
|
||||
*
|
||||
* @param triggerOrConfig - Function definition or configuration object
|
||||
* @returns The normalized configuration object
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* export const redisSubscribeTrigger = pikkuTriggerFunc<
|
||||
* { channel: string },
|
||||
* { message: string }
|
||||
* >(async ({ redis }, { channel }, { trigger }) => {
|
||||
* const subscriber = redis.duplicate()
|
||||
* await subscriber.subscribe(channel, (msg) => {
|
||||
* trigger.invoke({ message: msg })
|
||||
* })
|
||||
* return () => subscriber.unsubscribe()
|
||||
* })
|
||||
*
|
||||
* export const redisSubscribeTrigger = pikkuTriggerFunc({
|
||||
* title: 'Redis Subscribe Trigger',
|
||||
* description: 'Listens to Redis pub/sub channel',
|
||||
* input: z.object({ channel: z.string() }),
|
||||
* output: z.object({ message: z.string() }),
|
||||
* func: async ({ redis }, { channel }, { trigger }) => {
|
||||
* const subscriber = redis.duplicate()
|
||||
* await subscriber.subscribe(channel, (msg) => {
|
||||
* trigger.invoke({ message: msg })
|
||||
* })
|
||||
* return () => subscriber.unsubscribe()
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
export function pikkuTriggerFunc<
|
||||
InputSchema extends StandardSchemaV1,
|
||||
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
||||
>(
|
||||
config: PikkuTriggerFunctionConfigWithSchema<InputSchema, OutputSchema>
|
||||
): PikkuTriggerFunctionConfig<InferSchemaOutput<InputSchema>, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown, InputSchema, OutputSchema>
|
||||
export function pikkuTriggerFunc<TInput, TOutput = unknown>(
|
||||
triggerOrConfig:
|
||||
| PikkuTriggerFunction<TInput, TOutput>
|
||||
| PikkuTriggerFunctionConfig<TInput, TOutput>
|
||||
): PikkuTriggerFunctionConfig<TInput, TOutput>
|
||||
export function pikkuTriggerFunc(triggerOrConfig: any) {
|
||||
if (typeof triggerOrConfig === 'function') {
|
||||
return { func: triggerOrConfig }
|
||||
}
|
||||
return triggerOrConfig
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a trigger with the Pikku framework.
|
||||
* Declares a trigger name and its target pikku function.
|
||||
* Runs everywhere — inspector extracts at build time.
|
||||
*
|
||||
* @param trigger - Trigger definition with name and function config
|
||||
*/
|
||||
export const wireTrigger = (
|
||||
trigger: TriggerWiring
|
||||
) => {
|
||||
wireTriggerCore(trigger as any)
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a trigger source with the Pikku framework.
|
||||
* Provides the subscription function and input data.
|
||||
* Only imported in the trigger worker process.
|
||||
*
|
||||
* @param source - Trigger source with name, func, and input
|
||||
*/
|
||||
export const wireTriggerSource = <TInput = unknown, TOutput = unknown>(
|
||||
source: TriggerSource<TInput, TOutput>
|
||||
) => {
|
||||
wireTriggerSourceCore(source as any)
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
export { wireVariable } from '@pikku/core/variable'
|
||||
export type { CoreVariable, VariableDefinitionMeta, VariableDefinitionsMeta } from '@pikku/core/variable'
|
||||
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
import { TypedVariablesService as CoreTypedVariablesService, type VariableMeta } from '@pikku/core/services'
|
||||
import type { VariablesService } from '@pikku/core/services'
|
||||
|
||||
export interface VariablesMap {
|
||||
|
||||
}
|
||||
|
||||
export type VariableId = keyof VariablesMap
|
||||
|
||||
const VARIABLES_META: Record<string, VariableMeta> = {
|
||||
|
||||
}
|
||||
|
||||
export class TypedVariablesService extends CoreTypedVariablesService<VariablesMap> {
|
||||
constructor(variables: VariablesService) {
|
||||
super(variables, VARIABLES_META)
|
||||
}
|
||||
}
|
||||
46
packages/functions/packages/functions/.pikku/workflow/pikku-workflow-map.gen.d.ts
vendored
Normal file
46
packages/functions/packages/functions/.pikku/workflow/pikku-workflow-map.gen.d.ts
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
/**
|
||||
* Workflow type map with input/output types for each workflow
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
// Addon package Workflow maps
|
||||
import type { WorkflowMap as ConsoleWorkflowMap } from '@pikku/addon-console/.pikku/workflow/pikku-workflow-map.gen.d.js'
|
||||
|
||||
|
||||
interface WorkflowHandler<I, O> {
|
||||
input: I;
|
||||
output: O;
|
||||
}
|
||||
|
||||
interface GraphNodeHandler<I> {
|
||||
input: I;
|
||||
}
|
||||
|
||||
export type WorkflowMap = {
|
||||
};
|
||||
|
||||
export type GraphsMap = {
|
||||
};
|
||||
|
||||
type PrefixWorkflowKeys<T, Prefix extends string> = unknown extends T ? {} : {
|
||||
[K in keyof T as `${Prefix}:${string & K}`]: T[K]
|
||||
}
|
||||
|
||||
export type FlattenedWorkflowMap =
|
||||
WorkflowMap & PrefixWorkflowKeys<ConsoleWorkflowMap, 'console'>
|
||||
|
||||
|
||||
export type WorkflowClient<Name extends keyof FlattenedWorkflowMap> = {
|
||||
start: (input: FlattenedWorkflowMap[Name]['input']) => Promise<{ runId: string }>;
|
||||
getRun: <output extends keyof FlattenedWorkflowMap[Name]>(runId: string) => Promise<FlattenedWorkflowMap[Name][output]>;
|
||||
cancelRun: (runId: string) => Promise<boolean>;
|
||||
}
|
||||
|
||||
export type TypedWorkflowClients = {
|
||||
[Name in keyof FlattenedWorkflowMap]: WorkflowClient<Name>;
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
import { WorkflowCancelledException } from '@pikku/core/workflow'
|
||||
import { template } from '@pikku/core/workflow'
|
||||
import {
|
||||
pikkuWorkflowGraph as corePikkuWorkflowGraph,
|
||||
type PikkuWorkflowGraphConfig,
|
||||
type PikkuWorkflowGraphResult,
|
||||
} from '@pikku/core/workflow'
|
||||
import type { PikkuWorkflowWire, WorkflowStepOptions } from '@pikku/core/workflow'
|
||||
|
||||
export { WorkflowCancelledException }
|
||||
import type { PikkuFunctionSessionless, PikkuFunctionConfig } from '../function/pikku-function-types.gen.js'
|
||||
import type { FlattenedRPCMap } from '../rpc/pikku-rpc-wirings-map.internal.gen.d.js'
|
||||
import type { FlattenedWorkflowMap } from './pikku-workflow-map.gen.d.js'
|
||||
|
||||
export { template }
|
||||
|
||||
export interface TypedWorkflow extends PikkuWorkflowWire {
|
||||
do<K extends keyof FlattenedRPCMap>(
|
||||
stepName: string,
|
||||
rpcName: K,
|
||||
data: FlattenedRPCMap[K]['input'],
|
||||
options?: WorkflowStepOptions
|
||||
): Promise<FlattenedRPCMap[K]['output']>
|
||||
|
||||
do<K extends keyof FlattenedWorkflowMap>(
|
||||
stepName: string,
|
||||
workflowName: K,
|
||||
data: FlattenedWorkflowMap[K]['input'],
|
||||
options?: WorkflowStepOptions
|
||||
): Promise<FlattenedWorkflowMap[K]['output']>
|
||||
|
||||
do<T>(
|
||||
stepName: string,
|
||||
fn: () => T | Promise<T>,
|
||||
options?: WorkflowStepOptions
|
||||
): Promise<T>
|
||||
}
|
||||
|
||||
import type { StandardSchemaV1 } from '@standard-schema/spec'
|
||||
import type { InferSchemaOutput, PikkuPermission, PikkuMiddleware, NodeConfig, PikkuApprovalDescription } from '../function/pikku-function-types.gen.js'
|
||||
import { PikkuError } from '@pikku/core/errors'
|
||||
import type { CorePermissionGroup } from '@pikku/core'
|
||||
|
||||
export type PikkuFunctionWorkflow<
|
||||
In = unknown,
|
||||
Out = never
|
||||
> = PikkuFunctionSessionless<In, Out, 'workflow'>
|
||||
|
||||
export type PikkuWorkflowConfigWithSchema<
|
||||
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
||||
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
||||
> = {
|
||||
title?: string
|
||||
description?: string
|
||||
tags?: string[]
|
||||
expose?: boolean
|
||||
internal?: boolean
|
||||
override?: string
|
||||
version?: number
|
||||
remote?: boolean
|
||||
mcp?: boolean
|
||||
readonly?: boolean
|
||||
approvalRequired?: boolean
|
||||
approvalDescription?: InputSchema extends StandardSchemaV1 ? PikkuApprovalDescription<InferSchemaOutput<InputSchema>> : never
|
||||
func: PikkuFunctionWorkflow<
|
||||
InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown,
|
||||
OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown
|
||||
>
|
||||
auth?: boolean
|
||||
permissions?: InputSchema extends StandardSchemaV1 ? CorePermissionGroup<PikkuPermission<InferSchemaOutput<InputSchema>>> : undefined
|
||||
middleware?: PikkuMiddleware[]
|
||||
input?: InputSchema
|
||||
output?: OutputSchema
|
||||
node?: NodeConfig
|
||||
errors?: Array<typeof PikkuError>
|
||||
inline?: boolean
|
||||
}
|
||||
|
||||
export function pikkuWorkflowFunc<
|
||||
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
||||
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
||||
>(
|
||||
config: PikkuWorkflowConfigWithSchema<InputSchema, OutputSchema>
|
||||
): PikkuFunctionConfig<InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown, 'workflow', PikkuFunctionWorkflow<InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown>, InputSchema, OutputSchema>
|
||||
export function pikkuWorkflowFunc<In, Out = unknown>(
|
||||
func:
|
||||
| PikkuFunctionWorkflow<In, Out>
|
||||
| PikkuFunctionConfig<In, Out, 'workflow', PikkuFunctionWorkflow<In, Out>>
|
||||
): PikkuFunctionConfig<In, Out, 'workflow'>
|
||||
export function pikkuWorkflowFunc(func: any) {
|
||||
return typeof func === 'function' ? { func } : func
|
||||
}
|
||||
|
||||
export function pikkuWorkflowComplexFunc<
|
||||
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
||||
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
||||
>(
|
||||
config: PikkuWorkflowConfigWithSchema<InputSchema, OutputSchema>
|
||||
): PikkuFunctionConfig<InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown, 'workflow', PikkuFunctionWorkflow<InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown>, InputSchema, OutputSchema>
|
||||
export function pikkuWorkflowComplexFunc<In, Out = unknown>(
|
||||
func:
|
||||
| PikkuFunctionWorkflow<In, Out>
|
||||
| PikkuFunctionConfig<In, Out, 'workflow', PikkuFunctionWorkflow<In, Out>>
|
||||
): PikkuFunctionConfig<In, Out, 'workflow'>
|
||||
export function pikkuWorkflowComplexFunc(func: any) {
|
||||
return typeof func === 'function' ? { func } : func
|
||||
}
|
||||
|
||||
type TypedRef<T> = { $ref: string; path?: string } & { __phantomType?: T }
|
||||
|
||||
type TemplateString = {
|
||||
$template: {
|
||||
parts: string[]
|
||||
expressions: Array<{ $ref: string; path?: string }>
|
||||
}
|
||||
} & { __brand: 'TemplateString' }
|
||||
|
||||
type InputWithRefs<T> = {
|
||||
[K in keyof T]?: T[K] | TypedRef<T[K]> | TypedRef<unknown> | TemplateString
|
||||
}
|
||||
|
||||
type NodeInputType<FuncMap extends Record<string, string>, K extends keyof FuncMap> =
|
||||
FuncMap[K] extends keyof FlattenedRPCMap
|
||||
? InputWithRefs<FlattenedRPCMap[FuncMap[K]]['input']>
|
||||
: Record<string, unknown>
|
||||
|
||||
type NodeOutputKeys<FuncMap extends Record<string, string>, N extends string> =
|
||||
N extends keyof FuncMap
|
||||
? FuncMap[N] extends keyof FlattenedRPCMap
|
||||
? keyof FlattenedRPCMap[FuncMap[N]]['output'] & string
|
||||
: string
|
||||
: string
|
||||
|
||||
type RefFunction<FuncMap extends Record<string, string>> = {
|
||||
<N extends Extract<keyof FuncMap, string>>(
|
||||
nodeId: N,
|
||||
path: NodeOutputKeys<FuncMap, N>
|
||||
): TypedRef<unknown>
|
||||
(nodeId: 'trigger' | '$item', path?: string): TypedRef<unknown>
|
||||
}
|
||||
|
||||
type TemplateFunction = (templateStr: string, refs: TypedRef<unknown>[]) => TemplateString
|
||||
|
||||
type GraphNodeConfigMap<FuncMap extends Record<string, string>> = {
|
||||
[K in Extract<keyof FuncMap, string>]?: {
|
||||
next?: NextConfig<Extract<keyof FuncMap, string>>
|
||||
input?:
|
||||
| NodeInputType<FuncMap, K>
|
||||
| (() => NodeInputType<FuncMap, K>)
|
||||
| ((ref: RefFunction<FuncMap>, template: TemplateFunction) => NodeInputType<FuncMap, K>)
|
||||
onError?: Extract<keyof FuncMap, string> | Extract<keyof FuncMap, string>[]
|
||||
}
|
||||
}
|
||||
|
||||
type NextConfig<NodeIds extends string> = NodeIds | NodeIds[] | { if: string; then: NodeIds; else?: NodeIds }
|
||||
|
||||
export function pikkuWorkflowGraph<
|
||||
const FuncMap extends Record<string, keyof FlattenedRPCMap & string>
|
||||
>(
|
||||
config: PikkuWorkflowGraphConfig<FuncMap, GraphNodeConfigMap<FuncMap>>
|
||||
): PikkuWorkflowGraphResult {
|
||||
return corePikkuWorkflowGraph(config as any)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
import { pikkuState } from '@pikku/core/internal'
|
||||
import type { SerializedWorkflowGraphs } from '@pikku/inspector/workflow-graph'
|
||||
|
||||
const workflowsMeta: SerializedWorkflowGraphs = {}
|
||||
|
||||
pikkuState(null, 'workflows', 'meta', workflowsMeta)
|
||||
@@ -0,0 +1,3 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.23
|
||||
*/
|
||||
203
packages/functions/scripts/local-server.ts
Normal file
203
packages/functions/scripts/local-server.ts
Normal file
@@ -0,0 +1,203 @@
|
||||
// Local single-process harness for end-to-end testing the kanban workflow
|
||||
// path WITHOUT Cloudflare. Hosts the kanban HTTP wirings, fakes the fabric
|
||||
// `/tenant/enqueue` endpoint, and runs queue jobs in-process via the same
|
||||
// `runQueueJob` the CF handler-factories use. Workflow services are wired
|
||||
// the same way the generated CF entry does (SQLiteKyselyWorkflowService +
|
||||
// SQLiteKyselyWorkflowRunService over libsql).
|
||||
//
|
||||
// Usage:
|
||||
// export DATABASE_URL='libsql://...?authToken=...' # MUST be set
|
||||
// npx tsx scripts/local-server.ts
|
||||
//
|
||||
// Then:
|
||||
// curl -X POST http://127.0.0.1:9100/workflow/cardOnboardingWorkflow/start \
|
||||
// -H 'content-type: application/json' \
|
||||
// -d '{"data":{"title":"local-e2e","status":"todo"}}'
|
||||
// # poll /workflow/cardOnboardingWorkflow/status/<runId>
|
||||
|
||||
import http from 'node:http'
|
||||
import { randomUUID } from 'node:crypto'
|
||||
import { Kysely, CamelCasePlugin } from 'kysely'
|
||||
import {
|
||||
LibsqlWebDialect,
|
||||
SQLiteKyselyWorkflowService,
|
||||
SQLiteKyselyWorkflowRunService,
|
||||
type KyselyPikkuDB,
|
||||
} from '@pikku/kysely-sqlite'
|
||||
import { SerializePlugin } from '@pikku/kysely'
|
||||
import { runQueueJob, type QueueJob, type QueueJobStatus } from '@pikku/core/queue'
|
||||
import { fetchData, PikkuFetchHTTPResponse } from '@pikku/core/http'
|
||||
import { compileAllSchemas } from '@pikku/core/schema'
|
||||
import { incomingMessageToRequest, writeResponse } from '@pikku/node-http-server'
|
||||
import { createConfig } from '../src/config.js'
|
||||
import { createSingletonServices } from '../src/services.js'
|
||||
import '../.pikku/pikku-bootstrap.gen.js'
|
||||
|
||||
const PORT = Number(process.env.PORT ?? 9100)
|
||||
const HOST = process.env.HOST ?? '127.0.0.1'
|
||||
const STAGE_ID = process.env.FABRIC_STAGE_ID ?? 'local-stage'
|
||||
const DATABASE_URL = process.env.DATABASE_URL
|
||||
if (!DATABASE_URL) {
|
||||
console.error(
|
||||
'DATABASE_URL required (libsql URL with embedded authToken). Pull one from app.stage.database_url.',
|
||||
)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// Mirrors the inline FabricTenantQueueService used by the deploy runtime.
|
||||
// Same body shape, no HMAC since the local /tenant/enqueue endpoint accepts
|
||||
// any caller.
|
||||
class FabricTenantQueueServiceLocal {
|
||||
supportsResults = false
|
||||
constructor(
|
||||
private readonly endpoint: string,
|
||||
private readonly stageId: string,
|
||||
) {}
|
||||
async add(queueName: string, data: unknown, options?: { jobId?: string }): Promise<string> {
|
||||
const body = JSON.stringify({
|
||||
stageId: this.stageId,
|
||||
pikkuQueueName: queueName,
|
||||
payload: data,
|
||||
jobId: options?.jobId,
|
||||
})
|
||||
const res = await fetch(this.endpoint, {
|
||||
method: 'POST',
|
||||
headers: { 'content-type': 'application/json' },
|
||||
body,
|
||||
})
|
||||
if (!res.ok) {
|
||||
const text = await res.text().catch(() => '')
|
||||
throw new Error(
|
||||
`local tenant-queue: enqueue ${queueName} → ${res.status} ${text.slice(0, 200)}`,
|
||||
)
|
||||
}
|
||||
const json = (await res.json()) as { jobId: string }
|
||||
return json.jobId
|
||||
}
|
||||
async getJob(): Promise<null> {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
function mkJob(queueName: string, data: unknown, id: string): QueueJob {
|
||||
return {
|
||||
queueName,
|
||||
id,
|
||||
data,
|
||||
status: async () => 'active' as QueueJobStatus,
|
||||
metadata: () => ({
|
||||
processedAt: new Date(),
|
||||
attemptsMade: 0,
|
||||
maxAttempts: undefined,
|
||||
result: undefined,
|
||||
progress: 0,
|
||||
createdAt: new Date(),
|
||||
completedAt: undefined,
|
||||
failedAt: undefined,
|
||||
error: undefined,
|
||||
}),
|
||||
waitForCompletion: async () => {
|
||||
throw new Error('local: waitForCompletion not supported')
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
async function readBody(req: http.IncomingMessage): Promise<string> {
|
||||
const chunks: Buffer[] = []
|
||||
for await (const c of req as AsyncIterable<Buffer>) chunks.push(c)
|
||||
return Buffer.concat(chunks).toString('utf-8')
|
||||
}
|
||||
|
||||
async function main(): Promise<void> {
|
||||
const config = await createConfig()
|
||||
|
||||
const queueEndpoint = `http://${HOST}:${PORT}/tenant/enqueue`
|
||||
const queueService = new FabricTenantQueueServiceLocal(queueEndpoint, STAGE_ID)
|
||||
|
||||
// Pass queueService through existingServices — the template's
|
||||
// createSingletonServices preserves anything in existingServices that
|
||||
// it doesn't explicitly override.
|
||||
const services = (await createSingletonServices(config, {
|
||||
queueService: queueService as never,
|
||||
})) as Record<string, unknown>
|
||||
|
||||
const workflowKysely = new Kysely<KyselyPikkuDB>({
|
||||
dialect: new LibsqlWebDialect({ url: DATABASE_URL! }),
|
||||
plugins: [new CamelCasePlugin(), new SerializePlugin()],
|
||||
})
|
||||
const workflowService = new SQLiteKyselyWorkflowService(workflowKysely)
|
||||
await workflowService.init()
|
||||
services.workflowService = workflowService
|
||||
services.workflowRunService = new SQLiteKyselyWorkflowRunService(workflowKysely)
|
||||
|
||||
compileAllSchemas((services as { logger: { info: (s: string) => void } }).logger as never)
|
||||
|
||||
const log = (services as { logger: { info: (s: string) => void; error: (s: string) => void } })
|
||||
.logger
|
||||
|
||||
const server = http.createServer(async (req, res) => {
|
||||
try {
|
||||
if (req.method === 'POST' && req.url === '/tenant/enqueue') {
|
||||
const text = await readBody(req)
|
||||
let body: {
|
||||
stageId?: string
|
||||
pikkuQueueName: string
|
||||
payload: unknown
|
||||
jobId?: string
|
||||
}
|
||||
try {
|
||||
body = JSON.parse(text)
|
||||
} catch {
|
||||
res.writeHead(400, { 'content-type': 'application/json' })
|
||||
res.end(JSON.stringify({ error: 'invalid_json' }))
|
||||
return
|
||||
}
|
||||
const jobId = body.jobId ?? randomUUID()
|
||||
log.info(`[enqueue] queue=${body.pikkuQueueName} jobId=${jobId} stage=${body.stageId}`)
|
||||
// Async, fire-and-forget — mirrors pg-boss behaviour: the producer
|
||||
// gets an immediate ack and the job runs on the worker side.
|
||||
void (async () => {
|
||||
try {
|
||||
await runQueueJob({
|
||||
job: mkJob(body.pikkuQueueName, body.payload, jobId),
|
||||
})
|
||||
log.info(`[queue:${body.pikkuQueueName}] ${jobId} done`)
|
||||
} catch (e) {
|
||||
const err = e as Error
|
||||
log.error(
|
||||
`[queue:${body.pikkuQueueName}] ${jobId} FAILED: ${err.message}\n${err.stack ?? ''}`,
|
||||
)
|
||||
}
|
||||
})()
|
||||
res.writeHead(200, { 'content-type': 'application/json' })
|
||||
res.end(JSON.stringify({ jobId }))
|
||||
return
|
||||
}
|
||||
|
||||
const request = incomingMessageToRequest(req)
|
||||
const pikkuResponse = new PikkuFetchHTTPResponse()
|
||||
await fetchData(request, pikkuResponse, { respondWith404: true })
|
||||
await writeResponse(res, pikkuResponse.toResponse())
|
||||
} catch (err) {
|
||||
log.error(`local-server: ${(err as Error).message}`)
|
||||
if (!res.headersSent) {
|
||||
res.writeHead(500, { 'content-type': 'application/json' })
|
||||
}
|
||||
try {
|
||||
res.end(JSON.stringify({ error: 'internal_error' }))
|
||||
} catch {
|
||||
// already ended
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
server.listen(PORT, HOST, () => {
|
||||
log.info(`local-server: listening on http://${HOST}:${PORT}`)
|
||||
log.info(`local-server: stage=${STAGE_ID} db=${DATABASE_URL!.split('?')[0]}`)
|
||||
})
|
||||
}
|
||||
|
||||
main().catch((e) => {
|
||||
console.error('local-server: fatal', e)
|
||||
process.exit(1)
|
||||
})
|
||||
19
packages/functions/src/application-types.d.ts
vendored
Normal file
19
packages/functions/src/application-types.d.ts
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import type { CoreServices, CoreSingletonServices, CoreConfig, CoreUserSession } from '@pikku/core'
|
||||
import type { Kysely } from 'kysely'
|
||||
import type { DB } from './types/db.types.js'
|
||||
import type { TypedSecretService } from '../.pikku/secrets/pikku-secrets.gen.js'
|
||||
import type { TypedVariablesService } from '../.pikku/variables/pikku-variables.gen.js'
|
||||
|
||||
export interface UserSession extends CoreUserSession {
|
||||
userId: string
|
||||
}
|
||||
|
||||
export interface Config extends CoreConfig {}
|
||||
|
||||
export interface SingletonServices extends CoreSingletonServices<Config> {
|
||||
variables: TypedVariablesService
|
||||
secrets: TypedSecretService
|
||||
kysely: Kysely<DB>
|
||||
}
|
||||
|
||||
export interface Services extends CoreServices<SingletonServices> {}
|
||||
6
packages/functions/src/config.ts
Normal file
6
packages/functions/src/config.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { pikkuConfig } from '../.pikku/pikku-types.gen.js'
|
||||
|
||||
export const createConfig = pikkuConfig(async () => ({
|
||||
content: {},
|
||||
sqliteDb: '.pikku-runtime/dev.db',
|
||||
}))
|
||||
@@ -0,0 +1,7 @@
|
||||
import { pikkuSessionlessFunc } from '#pikku/pikku-types.gen.js'
|
||||
|
||||
export const archiveStaleCards = pikkuSessionlessFunc({
|
||||
func: async () => {
|
||||
// no-op: intentionally empty, used to exercise the scheduler wireType
|
||||
},
|
||||
})
|
||||
76
packages/functions/src/functions/cards-channel.function.ts
Normal file
76
packages/functions/src/functions/cards-channel.function.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import { pikkuChannelFunc, pikkuChannelConnectionFunc, pikkuChannelDisconnectionFunc } from '#pikku'
|
||||
|
||||
/**
|
||||
* On WebSocket connect — greet the client with the current card list.
|
||||
* Subsequent updates are pushed by `processCardEvent` (queue worker)
|
||||
* via the eventHub.
|
||||
*/
|
||||
// NOTE: no generic on pikkuChannelConnectionFunc. A connect handler has no
|
||||
// input message and no validated output — `channel.send` is fire-and-forget.
|
||||
// Passing an output-shaped generic here makes the inspector mis-assign it as
|
||||
// the connect INPUT schema, so the WS handshake (empty openingData) fails
|
||||
// schema validation and the connection is rejected 403. See pikku inspector
|
||||
// swap-bug: pikkuChannelConnectionFunc<Out>'s single generic is OUTPUT, but
|
||||
// generic[0] is read as input.
|
||||
export const onCardsConnect = pikkuChannelConnectionFunc(async ({ kysely, logger }, _, { channel }) => {
|
||||
const rows = await kysely.selectFrom('kanbanCard').selectAll().execute()
|
||||
channel.send({ type: 'hello', count: rows.length })
|
||||
logger.info(`cards-channel: connected (${rows.length} cards)`)
|
||||
})
|
||||
|
||||
export const onCardsDisconnect = pikkuChannelDisconnectionFunc(
|
||||
async ({ logger }, _, { channel }) => {
|
||||
logger.info(`cards-channel: disconnected channel=${channel.channelId}`)
|
||||
},
|
||||
)
|
||||
|
||||
/**
|
||||
* Echo any incoming message back to confirm the channel is bidirectional.
|
||||
* Wired via `onMessageWiring` so pikku JSON-parses the WS frame and
|
||||
* dispatches by the `action` discriminator. Send `{action:'echo', text:'…'}`
|
||||
* to receive `{echo:'…'}`.
|
||||
*/
|
||||
export const onCardsEcho = pikkuChannelFunc<{ text: string }, { echo: string }>(
|
||||
async (_services, { text }, { channel }) => {
|
||||
channel.send({ echo: text })
|
||||
},
|
||||
)
|
||||
|
||||
/**
|
||||
* Channel-session round-trip handlers — used by smoke-websocket-deploy.ts to
|
||||
* verify that `setSession`/`getSession`/`clearSession` are wired up to the
|
||||
* channel store on the deployed runtime (CF: WebSocketHibernationServer DO).
|
||||
*
|
||||
* NOTE (OSS gap): pikku's current SessionService writes to
|
||||
* `sessionStore[pikkuUserId]`, which is the wrong scope for channels — channel
|
||||
* session state belongs to the channelId, not the user. This smoke is
|
||||
* intentionally kept in tree as a regression target that will start passing
|
||||
* once OSS lands channel-scoped session storage on the ChannelStore (see
|
||||
* docs/work-log.md for proposed fix).
|
||||
*
|
||||
* Handlers RETURN their reply object instead of calling `channel.send`; the
|
||||
* pikku channel runner forwards the return and stamps the `action`
|
||||
* discriminator onto it. Calling `channel.send` in addition would emit two
|
||||
* frames per message and desync any client reading one reply per request.
|
||||
*/
|
||||
export const onCardsSetSession = pikkuChannelFunc<
|
||||
{ userId: string; label: string },
|
||||
{ set: true; label: string }
|
||||
>(async (_services, payload, { setSession }) => {
|
||||
await setSession({ userId: payload.userId })
|
||||
return { set: true, label: payload.label }
|
||||
})
|
||||
|
||||
export const onCardsGetSession = pikkuChannelFunc<Record<string, never>, { session: unknown }>(
|
||||
async (_services, _input, { getSession }) => {
|
||||
const session = await getSession()
|
||||
return { session: session ?? null }
|
||||
},
|
||||
)
|
||||
|
||||
export const onCardsClearSession = pikkuChannelFunc<Record<string, never>, { cleared: true }>(
|
||||
async (_services, _input, { clearSession }) => {
|
||||
await clearSession()
|
||||
return { cleared: true }
|
||||
},
|
||||
)
|
||||
46
packages/functions/src/functions/create-card.function.ts
Normal file
46
packages/functions/src/functions/create-card.function.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { z } from 'zod'
|
||||
import { randomUUID } from 'node:crypto'
|
||||
import { pikkuSessionlessFunc } from '#pikku'
|
||||
|
||||
export const CreateCardInput = z.object({
|
||||
title: z.string().min(1),
|
||||
status: z.enum(['todo', 'doing', 'done']).default('todo'),
|
||||
priority: z.enum(['low', 'medium', 'high']).default('medium').optional(),
|
||||
})
|
||||
|
||||
export const CreateCardOutput = z.object({
|
||||
cardId: z.string(),
|
||||
title: z.string(),
|
||||
status: z.string(),
|
||||
position: z.number(),
|
||||
createdAt: z.string(),
|
||||
})
|
||||
|
||||
export const createCard = pikkuSessionlessFunc({
|
||||
inline: false,
|
||||
expose: true,
|
||||
description: 'Create a kanban card.',
|
||||
input: CreateCardInput,
|
||||
output: CreateCardOutput,
|
||||
func: async ({ kysely, logger, queueService }, { title, status }) => {
|
||||
const cardId = randomUUID()
|
||||
const createdAt = new Date().toISOString()
|
||||
|
||||
const max = await kysely
|
||||
.selectFrom('kanbanCard')
|
||||
.select(({ fn }) => fn.max<number>('position').as('max'))
|
||||
.where('status', '=', status)
|
||||
.executeTakeFirst()
|
||||
const position = (max?.max ?? 0) + 1
|
||||
|
||||
await kysely
|
||||
.insertInto('kanbanCard')
|
||||
.values({ cardId, title, status, position, createdAt })
|
||||
.execute()
|
||||
|
||||
await queueService.add('process-card-event', { cardId, action: 'created', status, createdAt })
|
||||
|
||||
logger.info(`createCard ${cardId} (${status})`)
|
||||
return { cardId, title, status, position, createdAt }
|
||||
},
|
||||
})
|
||||
31
packages/functions/src/functions/enrich-card.function.ts
Normal file
31
packages/functions/src/functions/enrich-card.function.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { z } from 'zod'
|
||||
import { pikkuSessionlessFunc } from '#pikku'
|
||||
|
||||
export const EnrichCardInput = z.object({
|
||||
title: z.string().min(1),
|
||||
status: z.enum(['todo', 'doing', 'done']).default('todo'),
|
||||
})
|
||||
|
||||
export const EnrichCardOutput = z.object({
|
||||
title: z.string(),
|
||||
status: z.string(),
|
||||
priority: z.enum(['low', 'medium', 'high']),
|
||||
labels: z.array(z.string()),
|
||||
})
|
||||
|
||||
export const enrichCard = pikkuSessionlessFunc({
|
||||
inline: false,
|
||||
input: EnrichCardInput,
|
||||
output: EnrichCardOutput,
|
||||
func: async ({ logger }, { title, status }) => {
|
||||
const lower = title.toLowerCase()
|
||||
let priority: 'low' | 'medium' | 'high' = 'medium'
|
||||
if (/\b(urgent|asap|critical|p0|outage)\b/.test(lower)) priority = 'high'
|
||||
else if (/\b(later|someday|maybe|nice to have)\b/.test(lower)) priority = 'low'
|
||||
const labels: string[] = []
|
||||
if (/\b(bug|fix|broken|error)\b/.test(lower)) labels.push('bug')
|
||||
if (/\b(feat|feature|add)\b/.test(lower)) labels.push('feature')
|
||||
logger.info(`enrichCard: '${title}' → ${priority}`)
|
||||
return { title, status, priority, labels }
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,41 @@
|
||||
import { z } from 'zod'
|
||||
import { pikkuSessionlessFunc } from '#pikku'
|
||||
|
||||
export const GetCardFileUploadUrlInput = z.object({
|
||||
cardId: z.string().min(1),
|
||||
fileName: z.string().min(1),
|
||||
contentType: z.string().min(1),
|
||||
})
|
||||
|
||||
export const GetCardFileUploadUrlOutput = z.object({
|
||||
uploadUrl: z.string(),
|
||||
fileKey: z.string(),
|
||||
expiresAt: z.string(),
|
||||
uploadMethod: z.enum(['PUT', 'POST']).optional(),
|
||||
uploadHeaders: z.record(z.string(), z.string()).optional(),
|
||||
})
|
||||
|
||||
export const getCardFileUploadUrl = pikkuSessionlessFunc({
|
||||
expose: true,
|
||||
description: 'Return a presigned upload URL for attaching a file to a card.',
|
||||
input: GetCardFileUploadUrlInput,
|
||||
output: GetCardFileUploadUrlOutput,
|
||||
func: async ({ content }, { cardId, fileName, contentType }) => {
|
||||
if (!content) {
|
||||
throw new Error('Content service not configured')
|
||||
}
|
||||
const fileKey = `${cardId}/${fileName}`
|
||||
const { uploadUrl, uploadMethod, uploadHeaders } = await content.getUploadURL({
|
||||
bucket: 'cards',
|
||||
fileKey,
|
||||
contentType,
|
||||
})
|
||||
return {
|
||||
uploadUrl,
|
||||
fileKey,
|
||||
expiresAt: new Date(Date.now() + 3_600_000).toISOString(),
|
||||
uploadMethod,
|
||||
uploadHeaders,
|
||||
}
|
||||
},
|
||||
})
|
||||
12
packages/functions/src/functions/kanban.agent.ts
Normal file
12
packages/functions/src/functions/kanban.agent.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { pikkuAIAgent } from '#pikku/agent/pikku-agent-types.gen.js'
|
||||
import { ref } from '#pikku/pikku-types.gen.js'
|
||||
|
||||
export const kanbanAgent = pikkuAIAgent({
|
||||
name: 'kanbanAgent',
|
||||
description: 'Manages the kanban board — create and list cards on behalf of the user',
|
||||
goal: 'You are a kanban board assistant. You can list existing cards and create new cards. When creating a card you need a title and optionally a status (todo, doing, or done). Default status is "todo".',
|
||||
model: 'openai/deepseek-v4-flash',
|
||||
tools: [ref('listCards'), ref('createCard')],
|
||||
maxSteps: 5,
|
||||
toolChoice: 'auto',
|
||||
})
|
||||
32
packages/functions/src/functions/list-cards.function.ts
Normal file
32
packages/functions/src/functions/list-cards.function.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { z } from 'zod'
|
||||
import { pikkuSessionlessFunc } from '#pikku'
|
||||
|
||||
export const ListCardsInput = z.object({
|
||||
status: z.enum(['todo', 'doing', 'done']).optional(),
|
||||
})
|
||||
export const ListCardsOutput = z.object({
|
||||
cards: z.array(
|
||||
z.object({
|
||||
cardId: z.string(),
|
||||
title: z.string(),
|
||||
status: z.string(),
|
||||
position: z.number(),
|
||||
createdAt: z.string(),
|
||||
}),
|
||||
),
|
||||
})
|
||||
|
||||
export const listCards = pikkuSessionlessFunc({
|
||||
expose: true,
|
||||
description: 'List all kanban cards, optionally filtered by status.',
|
||||
input: ListCardsInput,
|
||||
output: ListCardsOutput,
|
||||
func: async ({ kysely, logger }, input) => {
|
||||
const status = input?.status
|
||||
let query = kysely.selectFrom('kanbanCard').selectAll().orderBy('position', 'asc')
|
||||
if (status) query = query.where('status', '=', status)
|
||||
const cards = await query.execute()
|
||||
logger.info(`listCards: ${cards.length} cards`)
|
||||
return { cards }
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,17 @@
|
||||
import { z } from 'zod'
|
||||
import { pikkuSessionlessFunc } from '#pikku'
|
||||
|
||||
export const NotifyCardCreatedInput = z.object({
|
||||
cardId: z.string(),
|
||||
title: z.string(),
|
||||
priority: z.enum(['low', 'medium', 'high']),
|
||||
labels: z.array(z.string()),
|
||||
})
|
||||
|
||||
export const notifyCardCreated = pikkuSessionlessFunc({
|
||||
inline: false,
|
||||
input: NotifyCardCreatedInput,
|
||||
func: async ({ logger }, { cardId, title, priority }) => {
|
||||
logger.info(`notify ${priority} card=${cardId} '${title}'`)
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,37 @@
|
||||
import { z } from 'zod'
|
||||
import { pikkuSessionlessFunc } from '#pikku'
|
||||
import { randomUUID } from 'node:crypto'
|
||||
|
||||
export const OnCardEventTriggerInput = z.object({
|
||||
title: z.string(),
|
||||
status: z.enum(['todo', 'doing', 'done']).default('todo'),
|
||||
source: z.string().optional(),
|
||||
})
|
||||
|
||||
export const OnCardEventTriggerOutput = z.object({
|
||||
cardId: z.string(),
|
||||
title: z.string(),
|
||||
status: z.string(),
|
||||
})
|
||||
|
||||
export const onCardEventTrigger = pikkuSessionlessFunc({
|
||||
input: OnCardEventTriggerInput,
|
||||
output: OnCardEventTriggerOutput,
|
||||
remote: true,
|
||||
func: async ({ kysely, logger }, { title, status, source }) => {
|
||||
const cardId = randomUUID()
|
||||
const createdAt = new Date().toISOString()
|
||||
const max = await kysely
|
||||
.selectFrom('kanbanCard')
|
||||
.select(({ fn }) => fn.max<number>('position').as('max'))
|
||||
.where('status', '=', status)
|
||||
.executeTakeFirst()
|
||||
const position = (max?.max ?? 0) + 1
|
||||
await kysely
|
||||
.insertInto('kanbanCard')
|
||||
.values({ cardId, title, status, position, createdAt })
|
||||
.execute()
|
||||
logger.info(`onCardEventTrigger: created card ${cardId} from source=${source ?? 'unknown'}`)
|
||||
return { cardId, title, status }
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,21 @@
|
||||
import { z } from 'zod'
|
||||
import { pikkuSessionlessFunc } from '#pikku'
|
||||
|
||||
export const ProcessCardEventInput = z.object({
|
||||
cardId: z.string(),
|
||||
action: z.string(),
|
||||
status: z.string(),
|
||||
createdAt: z.string(),
|
||||
})
|
||||
|
||||
/**
|
||||
* Queue worker for `cardEvents`. Just logs the event for now — real
|
||||
* implementations would fan out to webhooks, refresh search indexes, push
|
||||
* mobile notifications, etc.
|
||||
*/
|
||||
export const processCardEvent = pikkuSessionlessFunc({
|
||||
input: ProcessCardEventInput,
|
||||
func: async ({ logger }, { cardId, action, status }) => {
|
||||
logger.info(`processCardEvent ${action} card=${cardId} status=${status}`)
|
||||
},
|
||||
})
|
||||
35
packages/functions/src/functions/sign-card-file.function.ts
Normal file
35
packages/functions/src/functions/sign-card-file.function.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { z } from 'zod'
|
||||
import { pikkuSessionlessFunc } from '#pikku'
|
||||
|
||||
export const SignCardFileInput = z.object({
|
||||
cardId: z.string().min(1),
|
||||
fileName: z.string().min(1),
|
||||
})
|
||||
|
||||
export const SignCardFileOutput = z.object({
|
||||
signedUrl: z.string(),
|
||||
expiresAt: z.string(),
|
||||
})
|
||||
|
||||
export const signCardFile = pikkuSessionlessFunc({
|
||||
expose: true,
|
||||
description: 'Return a time-limited signed download URL for a card attachment.',
|
||||
input: SignCardFileInput,
|
||||
output: SignCardFileOutput,
|
||||
func: async ({ content }, { cardId, fileName }) => {
|
||||
if (!content) {
|
||||
throw new Error('Content service not configured')
|
||||
}
|
||||
const fileKey = `${cardId}/${fileName}`
|
||||
const dateLessThan = new Date(Date.now() + 3_600_000)
|
||||
const signedUrl = await content.signContentKey({
|
||||
bucket: 'cards',
|
||||
contentKey: fileKey,
|
||||
dateLessThan,
|
||||
})
|
||||
return {
|
||||
signedUrl,
|
||||
expiresAt: dateLessThan.toISOString(),
|
||||
}
|
||||
},
|
||||
})
|
||||
14
packages/functions/src/middleware/cors.middleware.ts
Normal file
14
packages/functions/src/middleware/cors.middleware.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { addHTTPMiddleware } from '@pikku/core/http'
|
||||
import { cors } from '@pikku/core/middleware'
|
||||
|
||||
// The Better Auth session-bridge middleware (betterAuthSession) is generated and
|
||||
// registered globally by the pikku CLI from src/wirings/auth.ts — see
|
||||
// src/scaffold/auth.gen.ts — so it is NOT wired here. This file only configures
|
||||
// CORS for the browser client.
|
||||
addHTTPMiddleware('*', [
|
||||
cors({
|
||||
origin: true,
|
||||
credentials: true,
|
||||
headers: ['Content-Type', 'Authorization', 'X-Auth-Return-Redirect'],
|
||||
}),
|
||||
])
|
||||
162
packages/functions/src/scaffold/agent.gen.ts
Normal file
162
packages/functions/src/scaffold/agent.gen.ts
Normal file
@@ -0,0 +1,162 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.45
|
||||
*/
|
||||
import { MissingServiceError } from '@pikku/core/errors'
|
||||
import { pikkuSessionlessFunc, defineHTTPRoutes, wireHTTPRoutes } from '../../../../../../../../../../../tmp/ag/.pikku/pikku-types.gen.js'
|
||||
|
||||
export const agentCaller = pikkuSessionlessFunc<
|
||||
{ agentName: string; message: string; threadId: string; resourceId: string },
|
||||
unknown
|
||||
>({
|
||||
tags: ['pikku'],
|
||||
auth: false,
|
||||
func: async (_services, data, { rpc }) => {
|
||||
return await rpc.agent.run(data.agentName as any, {
|
||||
message: data.message,
|
||||
threadId: data.threadId,
|
||||
resourceId: data.resourceId,
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
export const agentStreamCaller = pikkuSessionlessFunc<
|
||||
{ agentName: string; message: string; threadId: string; resourceId: string; context?: string },
|
||||
void
|
||||
>({
|
||||
tags: ['pikku'],
|
||||
auth: false,
|
||||
func: async (_services, data, { rpc }) => {
|
||||
await rpc.agent.stream(data.agentName as any, {
|
||||
message: data.message,
|
||||
threadId: data.threadId,
|
||||
resourceId: data.resourceId,
|
||||
...(data.context ? { context: data.context } : {}),
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
export const agentApproveCaller = pikkuSessionlessFunc<
|
||||
{ agentName: string; runId: string; approvals: { toolCallId: string; approved: boolean }[] },
|
||||
unknown
|
||||
>({
|
||||
tags: ['pikku'],
|
||||
auth: false,
|
||||
func: async (_services, { runId, approvals, agentName }, { rpc }) => {
|
||||
return await rpc.agent.approve(runId, approvals, agentName)
|
||||
},
|
||||
})
|
||||
|
||||
export const agentResumeCaller = pikkuSessionlessFunc<
|
||||
{ agentName: string; runId: string; toolCallId: string; approved: boolean },
|
||||
void
|
||||
>({
|
||||
tags: ['pikku'],
|
||||
auth: false,
|
||||
func: async (_services, data, { rpc }) => {
|
||||
await rpc.agent.resume(data.runId, {
|
||||
toolCallId: data.toolCallId,
|
||||
approved: data.approved,
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
export const getAgentThreads = pikkuSessionlessFunc<
|
||||
{ agentName?: string; resourceId?: string; limit?: number; offset?: number },
|
||||
any[]
|
||||
>({
|
||||
tags: ['pikku', 'pikku:agent'],
|
||||
title: 'Get Agent Threads',
|
||||
description:
|
||||
'Returns a list of AI agent threads from storage. Accepts optional filters: agentName, resourceId, limit, and offset for pagination.',
|
||||
expose: true,
|
||||
auth: false,
|
||||
func: async ({ agentRunService }, input) => {
|
||||
if (!agentRunService) throw new MissingServiceError('agentRunService is not available')
|
||||
return await agentRunService.listThreads({
|
||||
agentName: input?.agentName,
|
||||
resourceId: input?.resourceId,
|
||||
limit: input?.limit,
|
||||
offset: input?.offset,
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
export const getAgentThreadMessages = pikkuSessionlessFunc<
|
||||
{ threadId: string; resourceId?: string },
|
||||
any[]
|
||||
>({
|
||||
tags: ['pikku', 'pikku:agent'],
|
||||
title: 'Get Agent Thread Messages',
|
||||
description:
|
||||
'Returns all messages for a given AI agent thread, ordered by creation time.',
|
||||
expose: true,
|
||||
auth: false,
|
||||
func: async ({ agentRunService }, input) => {
|
||||
if (!agentRunService) throw new MissingServiceError('agentRunService is not available')
|
||||
return await agentRunService.getThreadMessages(input.threadId)
|
||||
},
|
||||
})
|
||||
|
||||
export const getAgentThreadRuns = pikkuSessionlessFunc<
|
||||
{ threadId: string; resourceId?: string },
|
||||
any[]
|
||||
>({
|
||||
tags: ['pikku', 'pikku:agent'],
|
||||
title: 'Get Agent Thread Runs',
|
||||
description:
|
||||
'Returns the run history for a given AI agent thread, ordered by creation time.',
|
||||
expose: true,
|
||||
auth: false,
|
||||
func: async ({ agentRunService }, input) => {
|
||||
if (!agentRunService) throw new MissingServiceError('agentRunService is not available')
|
||||
return await agentRunService.getThreadRuns(input.threadId)
|
||||
},
|
||||
})
|
||||
|
||||
export const deleteAgentThread = pikkuSessionlessFunc<
|
||||
{ threadId: string; resourceId?: string },
|
||||
{ deleted: boolean }
|
||||
>({
|
||||
tags: ['pikku', 'pikku:agent'],
|
||||
title: 'Delete Agent Thread',
|
||||
description:
|
||||
'Deletes an AI agent thread and all of its persisted state.',
|
||||
expose: true,
|
||||
auth: false,
|
||||
func: async ({ agentRunService }, input) => {
|
||||
if (!agentRunService) throw new MissingServiceError('agentRunService is not available')
|
||||
const deleted = await agentRunService.deleteThread(input.threadId)
|
||||
return { deleted }
|
||||
},
|
||||
})
|
||||
|
||||
export const agentRoutes = defineHTTPRoutes({
|
||||
auth: false,
|
||||
tags: ['pikku:public'],
|
||||
routes: {
|
||||
agentRun: {
|
||||
route: '/rpc/agent/:agentName',
|
||||
method: 'post',
|
||||
func: agentCaller,
|
||||
},
|
||||
agentStream: {
|
||||
route: '/rpc/agent/:agentName/stream',
|
||||
method: 'post',
|
||||
sse: true,
|
||||
func: agentStreamCaller,
|
||||
},
|
||||
agentApprove: {
|
||||
route: '/rpc/agent/:agentName/approve',
|
||||
method: 'post',
|
||||
func: agentApproveCaller,
|
||||
},
|
||||
agentResume: {
|
||||
route: '/rpc/agent/:agentName/resume',
|
||||
method: 'post',
|
||||
sse: true,
|
||||
func: agentResumeCaller,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
wireHTTPRoutes({ routes: { agent: agentRoutes } })
|
||||
9
packages/functions/src/scaffold/auth-middleware.gen.ts
Normal file
9
packages/functions/src/scaffold/auth-middleware.gen.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.45
|
||||
*/
|
||||
// AUTO-GENERATED by pikku CLI — do not edit
|
||||
|
||||
import { addHTTPMiddleware } from '../../../../../../../../../../../tmp/acc/.pikku/pikku-types.gen.js'
|
||||
import { betterAuthStatelessSession } from '@pikku/better-auth'
|
||||
|
||||
addHTTPMiddleware('*', [betterAuthStatelessSession()])
|
||||
17
packages/functions/src/scaffold/auth-secrets.gen.ts
Normal file
17
packages/functions/src/scaffold/auth-secrets.gen.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.45
|
||||
*/
|
||||
// AUTO-GENERATED by pikku CLI — do not edit
|
||||
|
||||
import { wireSecret } from '@pikku/core/secret'
|
||||
import { z } from 'zod'
|
||||
|
||||
export const BetterAuthSecretSchema = z.string()
|
||||
|
||||
wireSecret({
|
||||
name: 'betterAuthSecret',
|
||||
displayName: 'Better Auth Secret',
|
||||
description: 'Signing secret for better-auth sessions',
|
||||
secretId: 'BETTER_AUTH_SECRET',
|
||||
schema: BetterAuthSecretSchema,
|
||||
})
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user