chore: server-and-serverless template

This commit is contained in:
e2e
2026-06-26 14:41:47 +02:00
commit facba843e5
202 changed files with 9060 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
export type AgentMap = {}

View File

@@ -0,0 +1,82 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
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'
>
}

View File

@@ -0,0 +1,26 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
// AUTO-GENERATED by pikku CLI — do not edit
import { pikkuBetterAuth as _pikkuBetterAuth } from '@pikku/better-auth'
import type { BetterAuthInstance, PikkuBetterAuthFactory } from '@pikku/better-auth'
import type { SingletonServices } from '../function/pikku-function-types.gen.js'
import { TypedSecretService } from '../secrets/pikku-secrets.gen.js'
import { TypedVariablesService } from '../variables/pikku-variables.gen.js'
type AuthSingletonServices = Omit<SingletonServices, 'secrets' | 'variables'> & {
secrets: TypedSecretService
variables: TypedVariablesService
}
export const pikkuBetterAuth = <I extends BetterAuthInstance>(
factory: (services: AuthSingletonServices) => I | Promise<I>
): PikkuBetterAuthFactory<I> =>
_pikkuBetterAuth((services) =>
factory({
...services,
secrets: new TypedSecretService(services.secrets),
variables: new TypedVariablesService(services.variables),
} as AuthSingletonServices)
)

View File

@@ -0,0 +1,6 @@
{
"basePath": "/api/auth",
"hasCredentials": true,
"providers": [],
"plugins": []
}

View File

@@ -0,0 +1,177 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
/**
* 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)

View File

@@ -0,0 +1,105 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
/**
* 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
}

View File

@@ -0,0 +1,14 @@
{
"nodes": {},
"secrets": {
"betterAuthSecret": {
"name": "betterAuthSecret",
"displayName": "Better Auth Secret",
"description": "Signing secret for better-auth sessions",
"secretId": "BETTER_AUTH_SECRET",
"schema": "SecretSchema_betterAuthSecret",
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/src/scaffold/auth-secrets.gen.ts"
}
},
"package": {}
}

View File

@@ -0,0 +1,8 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
import type { FlattenedRPCMap } from '../rpc/pikku-rpc-wirings-map.internal.gen.js'
export type NodeCategory = never
export type NodeRPCName = keyof FlattenedRPCMap

View File

@@ -0,0 +1,89 @@
// Generated by @pikku/cli — do not edit by hand.
// Run `pikku db migrate` to refresh.
// Use this type in db/classifications.ts:
// import type { DbClassificationMap } from './.pikku/db/classification-map.gen.d.ts'
// export const classifications = { ... } satisfies DbClassificationMap
export type ColumnEntry = {
/** Privacy level. Defaults to 'private' when omitted. */
security?: 'public' | 'private' | 'pii' | 'secret' | 'encrypted'
/** Anonymize strategy used by `pikku db anonymize`. */
classification?: 'fake:email' | 'fake:name' | 'hash' | 'keep'
/** Column kind override for codegen coercion + typing. */
kind?: 'date' | 'bool' | 'json' | 'uuid'
/** TypeScript type override, e.g. `string[]` or `MyJson`. Wins over `kind`. */
tsType?: string
/** Zod string-format validator (keeps the TS type as `string`). */
format?: 'email' | 'url' | 'emoji' | 'e164' | 'jwt' | 'cuid' | 'cuid2' | 'ulid' | 'nanoid' | 'base64' | 'base64url' | 'ipv4' | 'ipv6' | 'cidrv4' | 'cidrv6' | 'isoDate' | 'isoTime' | 'isoDatetime' | 'isoDuration'
description?: string
}
export type DbClassificationMap = {
"account": {
"id": ColumnEntry
"account_id": ColumnEntry
"provider_id": ColumnEntry
"user_id": ColumnEntry
"access_token": ColumnEntry
"refresh_token": ColumnEntry
"id_token": ColumnEntry
"access_token_expires_at": ColumnEntry
"refresh_token_expires_at": ColumnEntry
"scope": ColumnEntry
"password": ColumnEntry
"created_at": ColumnEntry
"updated_at": ColumnEntry
}
"audit": {
"audit_id": ColumnEntry
"occurred_at": ColumnEntry
"type": ColumnEntry
"source": ColumnEntry
"outcome": ColumnEntry
"function_id": ColumnEntry
"wire_type": ColumnEntry
"trace_id": ColumnEntry
"transaction_id": ColumnEntry
"query_id": ColumnEntry
"actor_user_id": ColumnEntry
"actor_org_id": ColumnEntry
"tables": ColumnEntry
"changed_cols": ColumnEntry
"event": ColumnEntry
"old": ColumnEntry
"data": ColumnEntry
}
"message_state": {
"id": ColumnEntry
"message": ColumnEntry
"updated_at": ColumnEntry
"updated_by_user_id": ColumnEntry
}
"session": {
"id": ColumnEntry
"expires_at": ColumnEntry
"token": ColumnEntry
"created_at": ColumnEntry
"updated_at": ColumnEntry
"ip_address": ColumnEntry
"user_agent": ColumnEntry
"user_id": ColumnEntry
}
"user": {
"id": ColumnEntry
"name": ColumnEntry
"email": ColumnEntry
"email_verified": ColumnEntry
"image": ColumnEntry
"created_at": ColumnEntry
"updated_at": ColumnEntry
}
"verification": {
"id": ColumnEntry
"identifier": ColumnEntry
"value": ColumnEntry
"expires_at": ColumnEntry
"created_at": ColumnEntry
"updated_at": ColumnEntry
}
}

View File

@@ -0,0 +1,75 @@
// Generated by @pikku/cli — do not edit by hand.
// Run `pikku db migrate` to refresh.
export const classificationManifest = {
version: 1 as const,
tables: {
"account": {
"id": { classification: 'private', anonymize_strategy: null },
"account_id": { classification: 'private', anonymize_strategy: null },
"provider_id": { classification: 'private', anonymize_strategy: null },
"user_id": { classification: 'private', anonymize_strategy: null },
"access_token": { classification: 'private', anonymize_strategy: null },
"refresh_token": { classification: 'private', anonymize_strategy: null },
"id_token": { classification: 'private', anonymize_strategy: null },
"access_token_expires_at": { classification: 'private', anonymize_strategy: null },
"refresh_token_expires_at": { classification: 'private', anonymize_strategy: null },
"scope": { classification: 'private', anonymize_strategy: null },
"password": { classification: 'private', anonymize_strategy: null },
"created_at": { classification: 'private', anonymize_strategy: null },
"updated_at": { classification: 'private', anonymize_strategy: null }
},
"audit": {
"audit_id": { classification: 'private', anonymize_strategy: null },
"occurred_at": { classification: 'private', anonymize_strategy: null },
"type": { classification: 'private', anonymize_strategy: null },
"source": { classification: 'private', anonymize_strategy: null },
"outcome": { classification: 'private', anonymize_strategy: null },
"function_id": { classification: 'private', anonymize_strategy: null },
"wire_type": { classification: 'private', anonymize_strategy: null },
"trace_id": { classification: 'private', anonymize_strategy: null },
"transaction_id": { classification: 'private', anonymize_strategy: null },
"query_id": { classification: 'private', anonymize_strategy: null },
"actor_user_id": { classification: 'private', anonymize_strategy: null },
"actor_org_id": { classification: 'private', anonymize_strategy: null },
"tables": { classification: 'private', anonymize_strategy: null },
"changed_cols": { classification: 'private', anonymize_strategy: null },
"event": { classification: 'private', anonymize_strategy: null },
"old": { classification: 'private', anonymize_strategy: null },
"data": { classification: 'private', anonymize_strategy: null }
},
"message_state": {
"id": { classification: 'private', anonymize_strategy: null },
"message": { classification: 'private', anonymize_strategy: null },
"updated_at": { classification: 'private', anonymize_strategy: null },
"updated_by_user_id": { classification: 'private', anonymize_strategy: null }
},
"session": {
"id": { classification: 'private', anonymize_strategy: null },
"expires_at": { classification: 'private', anonymize_strategy: null },
"token": { classification: 'private', anonymize_strategy: null },
"created_at": { classification: 'private', anonymize_strategy: null },
"updated_at": { classification: 'private', anonymize_strategy: null },
"ip_address": { classification: 'private', anonymize_strategy: null },
"user_agent": { classification: 'private', anonymize_strategy: null },
"user_id": { classification: 'private', anonymize_strategy: null }
},
"user": {
"id": { classification: 'private', anonymize_strategy: null },
"name": { classification: 'private', anonymize_strategy: null },
"email": { classification: 'private', anonymize_strategy: null },
"email_verified": { classification: 'private', anonymize_strategy: null },
"image": { classification: 'private', anonymize_strategy: null },
"created_at": { classification: 'private', anonymize_strategy: null },
"updated_at": { classification: 'private', anonymize_strategy: null }
},
"verification": {
"id": { classification: 'private', anonymize_strategy: null },
"identifier": { classification: 'private', anonymize_strategy: null },
"value": { classification: 'private', anonymize_strategy: null },
"expires_at": { classification: 'private', anonymize_strategy: null },
"created_at": { classification: 'private', anonymize_strategy: null },
"updated_at": { classification: 'private', anonymize_strategy: null }
}
},
} as const

View File

@@ -0,0 +1,6 @@
// Generated by @pikku/cli — do not edit by hand.
// Run `pikku db migrate` to refresh.
export const coercionMap = {
} as const

View File

@@ -0,0 +1,377 @@
{
"tables": [
{
"name": "account",
"columns": [
{
"name": "id",
"type": "TEXT",
"nullable": false,
"isPrimaryKey": true
},
{
"name": "account_id",
"type": "TEXT",
"nullable": false,
"isPrimaryKey": false
},
{
"name": "provider_id",
"type": "TEXT",
"nullable": false,
"isPrimaryKey": false
},
{
"name": "user_id",
"type": "TEXT",
"nullable": false,
"isPrimaryKey": false,
"foreignKey": {
"table": "user",
"column": "id"
}
},
{
"name": "access_token",
"type": "TEXT",
"nullable": true,
"isPrimaryKey": false
},
{
"name": "refresh_token",
"type": "TEXT",
"nullable": true,
"isPrimaryKey": false
},
{
"name": "id_token",
"type": "TEXT",
"nullable": true,
"isPrimaryKey": false
},
{
"name": "access_token_expires_at",
"type": "date",
"nullable": true,
"isPrimaryKey": false
},
{
"name": "refresh_token_expires_at",
"type": "date",
"nullable": true,
"isPrimaryKey": false
},
{
"name": "scope",
"type": "TEXT",
"nullable": true,
"isPrimaryKey": false
},
{
"name": "password",
"type": "TEXT",
"nullable": true,
"isPrimaryKey": false
},
{
"name": "created_at",
"type": "date",
"nullable": false,
"isPrimaryKey": false
},
{
"name": "updated_at",
"type": "date",
"nullable": false,
"isPrimaryKey": false
}
]
},
{
"name": "audit",
"columns": [
{
"name": "audit_id",
"type": "TEXT",
"nullable": false,
"isPrimaryKey": true
},
{
"name": "occurred_at",
"type": "TEXT",
"nullable": false,
"isPrimaryKey": false
},
{
"name": "type",
"type": "TEXT",
"nullable": false,
"isPrimaryKey": false
},
{
"name": "source",
"type": "TEXT",
"nullable": false,
"isPrimaryKey": false
},
{
"name": "outcome",
"type": "TEXT",
"nullable": true,
"isPrimaryKey": false
},
{
"name": "function_id",
"type": "TEXT",
"nullable": true,
"isPrimaryKey": false
},
{
"name": "wire_type",
"type": "TEXT",
"nullable": true,
"isPrimaryKey": false
},
{
"name": "trace_id",
"type": "TEXT",
"nullable": true,
"isPrimaryKey": false
},
{
"name": "transaction_id",
"type": "TEXT",
"nullable": true,
"isPrimaryKey": false
},
{
"name": "query_id",
"type": "TEXT",
"nullable": true,
"isPrimaryKey": false
},
{
"name": "actor_user_id",
"type": "TEXT",
"nullable": true,
"isPrimaryKey": false
},
{
"name": "actor_org_id",
"type": "TEXT",
"nullable": true,
"isPrimaryKey": false
},
{
"name": "tables",
"type": "TEXT",
"nullable": true,
"isPrimaryKey": false
},
{
"name": "changed_cols",
"type": "TEXT",
"nullable": true,
"isPrimaryKey": false
},
{
"name": "event",
"type": "TEXT",
"nullable": true,
"isPrimaryKey": false
},
{
"name": "old",
"type": "TEXT",
"nullable": true,
"isPrimaryKey": false
},
{
"name": "data",
"type": "TEXT",
"nullable": true,
"isPrimaryKey": false
}
]
},
{
"name": "message_state",
"columns": [
{
"name": "id",
"type": "INTEGER",
"nullable": false,
"isPrimaryKey": true
},
{
"name": "message",
"type": "TEXT",
"nullable": false,
"isPrimaryKey": false
},
{
"name": "updated_at",
"type": "TEXT",
"nullable": false,
"isPrimaryKey": false
},
{
"name": "updated_by_user_id",
"type": "TEXT",
"nullable": true,
"isPrimaryKey": false,
"foreignKey": {
"table": "user",
"column": "id"
}
}
]
},
{
"name": "session",
"columns": [
{
"name": "id",
"type": "TEXT",
"nullable": false,
"isPrimaryKey": true
},
{
"name": "expires_at",
"type": "date",
"nullable": false,
"isPrimaryKey": false
},
{
"name": "token",
"type": "TEXT",
"nullable": false,
"isPrimaryKey": false
},
{
"name": "created_at",
"type": "date",
"nullable": false,
"isPrimaryKey": false
},
{
"name": "updated_at",
"type": "date",
"nullable": false,
"isPrimaryKey": false
},
{
"name": "ip_address",
"type": "TEXT",
"nullable": true,
"isPrimaryKey": false
},
{
"name": "user_agent",
"type": "TEXT",
"nullable": true,
"isPrimaryKey": false
},
{
"name": "user_id",
"type": "TEXT",
"nullable": false,
"isPrimaryKey": false,
"foreignKey": {
"table": "user",
"column": "id"
}
}
]
},
{
"name": "user",
"columns": [
{
"name": "id",
"type": "TEXT",
"nullable": false,
"isPrimaryKey": true
},
{
"name": "name",
"type": "TEXT",
"nullable": false,
"isPrimaryKey": false
},
{
"name": "email",
"type": "TEXT",
"nullable": false,
"isPrimaryKey": false
},
{
"name": "email_verified",
"type": "INTEGER",
"nullable": false,
"isPrimaryKey": false
},
{
"name": "image",
"type": "TEXT",
"nullable": true,
"isPrimaryKey": false
},
{
"name": "created_at",
"type": "date",
"nullable": false,
"isPrimaryKey": false
},
{
"name": "updated_at",
"type": "date",
"nullable": false,
"isPrimaryKey": false
}
]
},
{
"name": "verification",
"columns": [
{
"name": "id",
"type": "TEXT",
"nullable": false,
"isPrimaryKey": true
},
{
"name": "identifier",
"type": "TEXT",
"nullable": false,
"isPrimaryKey": false
},
{
"name": "value",
"type": "TEXT",
"nullable": false,
"isPrimaryKey": false
},
{
"name": "expires_at",
"type": "date",
"nullable": false,
"isPrimaryKey": false
},
{
"name": "created_at",
"type": "date",
"nullable": false,
"isPrimaryKey": false
},
{
"name": "updated_at",
"type": "date",
"nullable": false,
"isPrimaryKey": false
}
]
}
],
"enums": []
}

View File

@@ -0,0 +1,95 @@
// Generated by @pikku/cli — do not edit by hand.
// Run `pikku db migrate` to refresh.
import type { ColumnType } from 'kysely'
export type Generated<T> = T extends ColumnType<infer S, infer I, infer U>
? ColumnType<S, I | undefined, U>
: ColumnType<T, T | undefined, T>
export type Private<T> = T & { readonly __classification__?: 'private' }
export type Pii<T> = T & { readonly __classification__?: 'pii' }
export type Secret<T> = T & { readonly __classification__?: 'secret' }
export type Uuid = string
export interface Account {
id: ColumnType<Private<string>, string, string>
accountId: ColumnType<Private<string>, string, string>
providerId: ColumnType<Private<string>, string, string>
userId: ColumnType<Private<string>, string, string>
accessToken: ColumnType<Private<string> | null, string | null, string | null>
refreshToken: ColumnType<Private<string> | null, string | null, string | null>
idToken: ColumnType<Private<string> | null, string | null, string | null>
accessTokenExpiresAt: ColumnType<Private<string> | null, string | null, string | null>
refreshTokenExpiresAt: ColumnType<Private<string> | null, string | null, string | null>
scope: ColumnType<Private<string> | null, string | null, string | null>
password: ColumnType<Private<string> | null, string | null, string | null>
createdAt: ColumnType<Private<string>, string, string>
updatedAt: ColumnType<Private<string>, string, string>
}
export interface Audit {
auditId: ColumnType<Private<string>, string | undefined, string>
occurredAt: ColumnType<Private<string>, string | undefined, string>
type: ColumnType<Private<string>, string, string>
source: ColumnType<Private<string>, string | undefined, string>
outcome: ColumnType<Private<string> | null, string | null, string | null>
functionId: ColumnType<Private<string> | null, string | null, string | null>
wireType: ColumnType<Private<string> | null, string | null, string | null>
traceId: ColumnType<Private<string> | null, string | null, string | null>
transactionId: ColumnType<Private<string> | null, string | null, string | null>
queryId: ColumnType<Private<string> | null, string | null, string | null>
actorUserId: ColumnType<Private<string> | null, string | null, string | null>
actorOrgId: ColumnType<Private<string> | null, string | null, string | null>
tables: ColumnType<Private<string> | null, string | null, string | null>
changedCols: ColumnType<Private<string> | null, string | null, string | null>
event: ColumnType<Private<string> | null, string | null, string | null>
old: ColumnType<Private<string> | null, string | null, string | null>
data: ColumnType<Private<string> | null, string | null, string | null>
}
export interface MessageState {
id: ColumnType<Private<number>, number | undefined, number>
message: ColumnType<Private<string>, string, string>
updatedAt: ColumnType<Private<string>, string | undefined, string>
updatedByUserId: ColumnType<Private<string> | null, string | null, string | null>
}
export interface Session {
id: ColumnType<Private<string>, string, string>
expiresAt: ColumnType<Private<string>, string, string>
token: ColumnType<Private<string>, string, string>
createdAt: ColumnType<Private<string>, string, string>
updatedAt: ColumnType<Private<string>, string, string>
ipAddress: ColumnType<Private<string> | null, string | null, string | null>
userAgent: ColumnType<Private<string> | null, string | null, string | null>
userId: ColumnType<Private<string>, string, string>
}
export interface User {
id: ColumnType<Private<string>, string, string>
name: ColumnType<Private<string>, string, string>
email: ColumnType<Private<string>, string, string>
emailVerified: ColumnType<Private<number>, number, number>
image: ColumnType<Private<string> | null, string | null, string | null>
createdAt: ColumnType<Private<string>, string, string>
updatedAt: ColumnType<Private<string>, string, string>
}
export interface Verification {
id: ColumnType<Private<string>, string, string>
identifier: ColumnType<Private<string>, string, string>
value: ColumnType<Private<string>, string, string>
expiresAt: ColumnType<Private<string>, string, string>
createdAt: ColumnType<Private<string>, string, string>
updatedAt: ColumnType<Private<string>, string, string>
}
export interface DB {
account: Account
audit: Audit
messageState: MessageState
session: Session
user: User
verification: Verification
}

View File

@@ -0,0 +1,163 @@
// Generated by @pikku/cli — do not edit by hand.
// Run `pikku db migrate` to refresh.
import { z } from 'zod'
export const AccountZ = z.object({
id: z.string(),
accountId: z.string(),
providerId: z.string(),
userId: z.string(),
accessToken: z.string().nullable(),
refreshToken: z.string().nullable(),
idToken: z.string().nullable(),
accessTokenExpiresAt: z.string().nullable(),
refreshTokenExpiresAt: z.string().nullable(),
scope: z.string().nullable(),
password: z.string().nullable(),
createdAt: z.string(),
updatedAt: z.string(),
})
export const AccountInsertZ = z.object({
id: z.string(),
accountId: z.string(),
providerId: z.string(),
userId: z.string(),
accessToken: z.string().nullable(),
refreshToken: z.string().nullable(),
idToken: z.string().nullable(),
accessTokenExpiresAt: z.string().nullable(),
refreshTokenExpiresAt: z.string().nullable(),
scope: z.string().nullable(),
password: z.string().nullable(),
createdAt: z.string(),
updatedAt: z.string(),
})
export const AccountPatchZ = AccountZ.partial()
export const AuditZ = z.object({
auditId: z.string(),
occurredAt: z.string(),
type: z.string(),
source: z.string(),
outcome: z.string().nullable(),
functionId: z.string().nullable(),
wireType: z.string().nullable(),
traceId: z.string().nullable(),
transactionId: z.string().nullable(),
queryId: z.string().nullable(),
actorUserId: z.string().nullable(),
actorOrgId: z.string().nullable(),
tables: z.string().nullable(),
changedCols: z.string().nullable(),
event: z.string().nullable(),
old: z.string().nullable(),
data: z.string().nullable(),
})
export const AuditInsertZ = z.object({
auditId: z.string().optional(),
occurredAt: z.string().optional(),
type: z.string(),
source: z.string().optional(),
outcome: z.string().nullable(),
functionId: z.string().nullable(),
wireType: z.string().nullable(),
traceId: z.string().nullable(),
transactionId: z.string().nullable(),
queryId: z.string().nullable(),
actorUserId: z.string().nullable(),
actorOrgId: z.string().nullable(),
tables: z.string().nullable(),
changedCols: z.string().nullable(),
event: z.string().nullable(),
old: z.string().nullable(),
data: z.string().nullable(),
})
export const AuditPatchZ = AuditZ.partial()
export const MessageStateZ = z.object({
id: z.number(),
message: z.string(),
updatedAt: z.string(),
updatedByUserId: z.string().nullable(),
})
export const MessageStateInsertZ = z.object({
id: z.number().optional(),
message: z.string(),
updatedAt: z.string().optional(),
updatedByUserId: z.string().nullable(),
})
export const MessageStatePatchZ = MessageStateZ.partial()
export const SessionZ = z.object({
id: z.string(),
expiresAt: z.string(),
token: z.string(),
createdAt: z.string(),
updatedAt: z.string(),
ipAddress: z.string().nullable(),
userAgent: z.string().nullable(),
userId: z.string(),
})
export const SessionInsertZ = z.object({
id: z.string(),
expiresAt: z.string(),
token: z.string(),
createdAt: z.string(),
updatedAt: z.string(),
ipAddress: z.string().nullable(),
userAgent: z.string().nullable(),
userId: z.string(),
})
export const SessionPatchZ = SessionZ.partial()
export const UserZ = z.object({
id: z.string(),
name: z.string(),
email: z.string(),
emailVerified: z.number(),
image: z.string().nullable(),
createdAt: z.string(),
updatedAt: z.string(),
})
export const UserInsertZ = z.object({
id: z.string(),
name: z.string(),
email: z.string(),
emailVerified: z.number(),
image: z.string().nullable(),
createdAt: z.string(),
updatedAt: z.string(),
})
export const UserPatchZ = UserZ.partial()
export const VerificationZ = z.object({
id: z.string(),
identifier: z.string(),
value: z.string(),
expiresAt: z.string(),
createdAt: z.string(),
updatedAt: z.string(),
})
export const VerificationInsertZ = z.object({
id: z.string(),
identifier: z.string(),
value: z.string(),
expiresAt: z.string(),
createdAt: z.string(),
updatedAt: z.string(),
})
export const VerificationPatchZ = VerificationZ.partial()

View File

@@ -0,0 +1,24 @@
{
"src": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/emails",
"themeHash": "1f7772ad7fb7b18f109bd67f2459cc5ea173b0f66929474bebc4522a2d24213c",
"templates": {
"confirm-email": {
"variables": [
"appName",
"confirmUrl",
"email"
],
"hasHtml": true,
"hasSubject": true,
"hasText": true,
"locales": {
"en": {
"contentHash": "fa3ef0d0ff652703fc0586c5c78b4c4820206a09bd47651c56a9f1c26a5d2cfd",
"htmlHash": "c4b9403e096b1f6c439e120f701bf8cbc6bdba9fdb8e4f21fbad524961343a39",
"subjectHash": "209d4ac15c8f7e70e14de04c81724beb00dac7f4ea450a6e8ce527faf4a0ad75",
"textHash": "4b494839407f2817290b9b08103cd84103e53a6339ff4e4f24e71dd89ebb7d13"
}
}
}
}
}

View File

@@ -0,0 +1,211 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
type EmailPrimitive = string | number | boolean | null | undefined
type EmailTemplateValue = EmailPrimitive | Record<string, unknown> | Array<unknown>
const EMAIL_THEME = {
"appName": "Pikku Starter",
"fonts": {
"body": "Inter, Arial, sans-serif"
},
"colors": {
"canvas": "#0b1020",
"surface": "#11182d",
"border": "#263252",
"text": "#f7f8fb",
"muted": "#a8b0c5",
"accent": "#7dd3fc",
"button": "#f59e0b",
"buttonText": "#111827"
}
} as const
const EMAIL_LOCALES = {
"en": {
"common": {
"footer": "If you did not create this account, you can safely ignore this email."
},
"confirmEmail": {
"subject": "Confirm your email for {{appName}}",
"preview": "Confirm your email address to finish setting up your account.",
"heading": "Confirm your email",
"intro": "Thanks for signing up for {{appName}}! Confirm {{email}} to finish setting up your account.",
"cta": "Confirm email",
"fallback": "If the button does not work, copy and paste this URL into your browser:",
"expiry": "This link expires in 24 hours."
}
}
} as const
const EMAIL_PARTIALS = {
"footer": "<p style=\"margin:32px 0 0;color:{{theme.colors.muted}};font-size:13px;line-height:1.6;\">\n {{t.common.footer}}\n</p>\n",
"layout": "<!doctype html>\n<html lang=\"{{locale}}\">\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <title>{{subject}}</title>\n </head>\n <body style=\"margin:0;padding:0;background:{{theme.colors.canvas}};font-family:{{theme.fonts.body}};\">\n <div style=\"max-width:560px;margin:0 auto;padding:32px 16px;\">\n {{content}}\n </div>\n </body>\n</html>\n"
} as const
const EMAIL_TEMPLATES = {
"confirm-email": {
"html": "<p style=\"margin:0 0 12px;color:{{theme.colors.accent}};font-size:12px;font-weight:700;letter-spacing:0.12em;text-transform:uppercase;\">\n {{appName}}\n</p>\n<h1 style=\"margin:0 0 16px;color:{{theme.colors.text}};font-size:28px;line-height:1.1;\">\n {{t.confirmEmail.heading}}\n</h1>\n<p style=\"margin:0 0 24px;color:{{theme.colors.muted}};font-size:16px;line-height:1.6;\">\n {{t.confirmEmail.intro}}\n</p>\n<p style=\"margin:0 0 24px;\">\n <a\n href=\"{{confirmUrl}}\"\n style=\"display:inline-block;background:{{theme.colors.button}};color:{{theme.colors.buttonText}};text-decoration:none;padding:14px 22px;border-radius:999px;font-weight:700;\"\n >\n {{t.confirmEmail.cta}}\n </a>\n</p>\n<p style=\"margin:0 0 8px;color:{{theme.colors.text}};font-size:14px;line-height:1.6;\">\n {{t.confirmEmail.fallback}}\n</p>\n<p style=\"margin:0;color:{{theme.colors.muted}};font-size:14px;line-height:1.6;word-break:break-all;\">\n {{confirmUrl}}\n</p>\n<p style=\"margin:24px 0 0;color:{{theme.colors.muted}};font-size:13px;line-height:1.6;\">\n {{t.confirmEmail.expiry}}\n</p>\n{{> footer}}\n",
"subject": "{{t.confirmEmail.subject}}\n",
"text": "{{t.confirmEmail.heading}}\n\n{{t.confirmEmail.intro}}\n\n{{confirmUrl}}\n\n{{t.confirmEmail.expiry}}\n",
"variables": [
"appName",
"confirmUrl",
"email"
],
"hashes": {
"en": {
"contentHash": "fa3ef0d0ff652703fc0586c5c78b4c4820206a09bd47651c56a9f1c26a5d2cfd",
"htmlHash": "c4b9403e096b1f6c439e120f701bf8cbc6bdba9fdb8e4f21fbad524961343a39",
"subjectHash": "209d4ac15c8f7e70e14de04c81724beb00dac7f4ea450a6e8ce527faf4a0ad75",
"textHash": "4b494839407f2817290b9b08103cd84103e53a6339ff4e4f24e71dd89ebb7d13"
}
}
}
} as const
export type EmailTemplateName = keyof typeof EMAIL_TEMPLATES
export type EmailLocale = keyof typeof EMAIL_LOCALES
type TemplateVariableMap = {
"confirm-email": {
"appName"?: EmailTemplateValue
"confirmUrl"?: EmailTemplateValue
"email"?: EmailTemplateValue
}
}
export type EmailTemplateVariables<TName extends EmailTemplateName> =
TemplateVariableMap[TName]
export type RenderEmailInput<TName extends EmailTemplateName> = {
name: TName
locale?: EmailLocale
data: EmailTemplateVariables<TName>
}
export type RenderedEmail<TName extends EmailTemplateName> = {
name: TName
locale: EmailLocale
subject: string
html: string
text?: string
variables: ReadonlyArray<string>
hash: (typeof EMAIL_TEMPLATES)[TName]['hashes'][EmailLocale]['contentHash']
}
function getNestedValue(source: Record<string, unknown>, path: string): string {
const segments = path.split('.')
let current: unknown = source
for (const segment of segments) {
if (!current || typeof current !== 'object' || !(segment in current)) {
return ''
}
current = (current as Record<string, unknown>)[segment]
}
return typeof current === 'string' || typeof current === 'number'
? String(current)
: ''
}
function applyTemplate(source: string, context: Record<string, unknown>): string {
return source.replace(/\{\{\s*([^}]+?)\s*\}\}/g, (_match, rawKey) => {
const key = String(rawKey).trim()
if (key === 'content') {
return typeof context.content === 'string' ? context.content : ''
}
if (key.startsWith('>')) {
return ''
}
return getNestedValue(context, key)
})
}
function renderTemplate(source: string, context: Record<string, unknown>): string {
let rendered = source
for (let i = 0; i < 5; i += 1) {
const next = applyTemplate(rendered, context)
if (next === rendered) break
rendered = next
}
return rendered
}
function renderPartial(name: string, context: Record<string, unknown>): string {
const partial = EMAIL_PARTIALS[name as keyof typeof EMAIL_PARTIALS]
return partial ? renderTemplate(partial, context) : ''
}
export const EMAILS = EMAIL_TEMPLATES
export function renderEmailTemplate<TName extends EmailTemplateName>(
input: RenderEmailInput<TName>
): RenderedEmail<TName> {
const locale = (input.locale ?? 'en') as EmailLocale
const template = EMAIL_TEMPLATES[input.name]
if (!template) {
throw new Error(`Unknown email template: ${String(input.name)}`)
}
const strings = EMAIL_LOCALES[locale]
if (!strings) {
throw new Error(`Unknown email locale: ${String(locale)}`)
}
const data = (input.data ?? {}) as Record<string, unknown>
const appName =
(typeof data.appName === 'string' && data.appName) ||
getNestedValue(EMAIL_THEME as Record<string, unknown>, 'appName')
const baseContext = {
...data,
locale,
theme: EMAIL_THEME,
t: strings,
appName,
}
const subject = renderTemplate(template.subject, baseContext).trim()
const htmlWithPartials = template.html.replace(
/\{\{\s*>\s*([a-zA-Z0-9-_/.]+)\s*\}\}/g,
(_match, partialName) => `@@PARTIAL:${String(partialName).trim()}@@`
)
let htmlBody = renderTemplate(htmlWithPartials, {
...baseContext,
subject,
})
const partialMatches = [...htmlBody.matchAll(/@@PARTIAL:([^@]+)@@/g)]
for (const match of partialMatches) {
const rendered = renderPartial(match[1], {
...baseContext,
subject,
})
htmlBody = htmlBody.replace(match[0], rendered)
}
const html = EMAIL_PARTIALS.layout
? renderTemplate(EMAIL_PARTIALS.layout, {
...baseContext,
subject,
content: htmlBody,
})
: htmlBody
const text = template.text
? renderTemplate(template.text, {
...baseContext,
subject,
}).trim()
: undefined
const hash = (template.hashes[locale]?.contentHash ??
'') as RenderedEmail<TName>['hash']
return {
name: input.name,
locale,
subject,
html,
...(text ? { text } : {}),
variables: template.variables,
hash,
}
}

View File

@@ -0,0 +1,754 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
/**
* 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<Partial<Omit<RequiredSingletonServices, 'auth'>>>
) => {
return async (config: Config, existingServices: Partial<SingletonServices> = {}) => {
const createdServices = await func(config, existingServices)
const services = { ...existingServices, ...createdServices }
const authFactory = __pikkuState(null, 'package', 'authFactory')
if (authFactory) {
let authInstance: Promise<unknown> | undefined
;(services as any).auth = () => {
authInstance ??= Promise.resolve()
.then(() => authFactory(services as any))
.catch((error) => {
authInstance = undefined
throw error
})
return authInstance
}
}
const resolved = services as RequiredSingletonServices
__pikkuState(null, 'package', 'singletonServices', resolved as any)
return resolved
}
}
/**
* 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'
/**
* Addon contract references. Generated from each wired addon's published
* contract metadata — no addon source is imported. Functions are proxied via
* ref() (RPC) exactly like ref('namespace:fn').
*/
const __addonHttp = {} as const
const __addonChannel = {} as const
const __addonCli = {} as const
export const refHTTP = <Name extends keyof typeof __addonHttp>(
name: Name,
options?: { basePath?: string }
): (typeof __addonHttp)[Name] => {
const contract = __addonHttp[name] as any
return (
options?.basePath !== undefined
? { ...contract, basePath: options.basePath }
: contract
) as (typeof __addonHttp)[Name]
}
export const refChannel = <Name extends keyof typeof __addonChannel>(
name: Name
): (typeof __addonChannel)[Name] => __addonChannel[name]
export const refCLI = <Name extends keyof typeof __addonCli>(
name: Name
): (typeof __addonCli)[Name] => __addonCli[name]

View File

@@ -0,0 +1,763 @@
{
"edgeEcho": {
"pikkuFuncId": "edgeEcho",
"functionType": "user",
"funcWrapper": "pikkuSessionlessFunc",
"sessionless": true,
"name": "edgeEcho",
"services": {
"optimized": true,
"services": []
},
"inputSchemaName": "EdgeEchoInput",
"outputSchemaName": "EdgeEchoOutput",
"inputs": [
"EdgeEchoInput"
],
"outputs": [
"EdgeEchoOutput"
],
"expose": true,
"implementationHash": "e1dd1c485212e3ea",
"description": "Echoes a message back from a serverless edge Worker.",
"isDirectFunction": false,
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/src/functions/edge-echo.function.ts",
"exportedName": "edgeEcho",
"contractHash": "91dda37cd8231346",
"inputHash": "3bb62634",
"outputHash": "10641e1c"
},
"getMessage": {
"pikkuFuncId": "getMessage",
"functionType": "user",
"funcWrapper": "pikkuFunc",
"sessionless": false,
"name": "getMessage",
"services": {
"optimized": true,
"services": [
"kysely"
]
},
"inputSchemaName": "GetMessageInput",
"outputSchemaName": "GetMessageOutput",
"inputs": [
"GetMessageInput"
],
"outputs": [
"GetMessageOutput"
],
"expose": true,
"readonly": true,
"implementationHash": "90fc43e8778db110",
"description": "Returns the current starter message for the signed-in user.",
"isDirectFunction": false,
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/src/functions/get-message.function.ts",
"exportedName": "getMessage",
"contractHash": "0b953679c3613f47",
"inputHash": "cd075fe2",
"outputHash": "d188ad31"
},
"getSession": {
"pikkuFuncId": "getSession",
"functionType": "user",
"funcWrapper": "pikkuFunc",
"sessionless": false,
"name": "getSession",
"services": {
"optimized": true,
"services": [
"kysely"
]
},
"wires": {
"optimized": true,
"wires": [
"session"
]
},
"inputSchemaName": "GetSessionInput",
"outputSchemaName": "GetSessionOutput",
"inputs": [
"GetSessionInput"
],
"outputs": [
"GetSessionOutput"
],
"expose": true,
"readonly": true,
"implementationHash": "2ed4f21ea016c7e3",
"description": "Returns the current signed-in user.",
"isDirectFunction": false,
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/src/functions/get-session.function.ts",
"exportedName": "getSession",
"contractHash": "493320ce1e00cb69",
"inputHash": "ba4ab2e7",
"outputHash": "386fe409"
},
"serverCounter": {
"pikkuFuncId": "serverCounter",
"functionType": "user",
"funcWrapper": "pikkuSessionlessFunc",
"sessionless": true,
"name": "serverCounter",
"services": {
"optimized": true,
"services": []
},
"inputSchemaName": "ServerCounterInput",
"outputSchemaName": "ServerCounterOutput",
"inputs": [
"ServerCounterInput"
],
"outputs": [
"ServerCounterOutput"
],
"expose": true,
"deploy": "server",
"implementationHash": "8a956f633eb3a4a4",
"description": "Increments an in-memory counter held by the container instance.",
"isDirectFunction": false,
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/src/functions/server-counter.function.ts",
"exportedName": "serverCounter",
"contractHash": "a891b2fe0608177d",
"inputHash": "d8945f99",
"outputHash": "56e3de15"
},
"serverUptime": {
"pikkuFuncId": "serverUptime",
"functionType": "user",
"funcWrapper": "pikkuSessionlessFunc",
"sessionless": true,
"name": "serverUptime",
"services": {
"optimized": true,
"services": []
},
"inputSchemaName": "ServerUptimeInput",
"outputSchemaName": "ServerUptimeOutput",
"inputs": [
"ServerUptimeInput"
],
"outputs": [
"ServerUptimeOutput"
],
"expose": true,
"readonly": true,
"deploy": "server",
"implementationHash": "046d656adb63b531",
"description": "Reports the serving container process uptime and runtime.",
"isDirectFunction": false,
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/src/functions/server-uptime.function.ts",
"exportedName": "serverUptime",
"contractHash": "d62f18b9b2739cd6",
"inputHash": "5425fd1f",
"outputHash": "4c1b3905"
},
"updateMessage": {
"pikkuFuncId": "updateMessage",
"functionType": "user",
"funcWrapper": "pikkuFunc",
"sessionless": false,
"name": "updateMessage",
"services": {
"optimized": true,
"services": [
"kysely"
]
},
"wires": {
"optimized": true,
"wires": [
"session"
]
},
"inputSchemaName": "UpdateMessageInput",
"outputSchemaName": "UpdateMessageOutput",
"inputs": [
"UpdateMessageInput"
],
"outputs": [
"UpdateMessageOutput"
],
"expose": true,
"implementationHash": "bfb74857a2ee5d16",
"description": "Updates the current starter message.",
"isDirectFunction": false,
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/src/functions/update-message.function.ts",
"exportedName": "updateMessage",
"contractHash": "16e17af7cea46c7a",
"inputHash": "77b14595",
"outputHash": "bca77943"
},
"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/server-and-serverless/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": "5d475a264b62cc63",
"tags": [
"pikku"
],
"isDirectFunction": false,
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/src/scaffold/agent.gen.ts",
"exportedName": "agentStreamCaller",
"contractHash": "440ca8bea8919cc6",
"inputHash": "6b434982",
"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/server-and-serverless/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/server-and-serverless/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/server-and-serverless/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/server-and-serverless/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/server-and-serverless/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/server-and-serverless/packages/functions/src/scaffold/agent.gen.ts",
"exportedName": "deleteAgentThread",
"contractHash": "b970011db1e0230e",
"inputHash": "3ed36ee5",
"outputHash": "a2094cc1"
},
"authHandler": {
"pikkuFuncId": "authHandler",
"functionType": "user",
"funcWrapper": "pikkuSessionlessFunc",
"sessionless": true,
"name": "authHandler",
"services": {
"optimized": true,
"services": [
"kysely",
"secrets"
]
},
"wires": {
"optimized": false,
"wires": []
},
"inputSchemaName": null,
"outputSchemaName": "AuthHandlerOutput",
"inputs": [],
"outputs": [
"AuthHandlerOutput"
],
"implementationHash": "7b1988fee5ec048e",
"isDirectFunction": false,
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/src/scaffold/auth.gen.ts",
"exportedName": "authHandler",
"contractHash": "56ca81afb5965d88",
"inputHash": "3db46710",
"outputHash": "4a0c6eec"
},
"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": "403f267c2ff0edad",
"tags": [
"pikku"
],
"description": "Set the value of a secret",
"isDirectFunction": false,
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/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": "a2637db8df0daa91",
"tags": [
"pikku"
],
"description": "Get the current value of a variable",
"isDirectFunction": false,
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/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": "4fac80de849be6c9",
"tags": [
"pikku"
],
"description": "Set the value of a variable",
"isDirectFunction": false,
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/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/server-and-serverless/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": "6808aead5cd1896a",
"tags": [
"pikku"
],
"description": "Get the current value of a secret",
"isDirectFunction": false,
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/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": [],
"sessionless": true,
"contractHash": "b693c43c3c0f10d5",
"inputHash": "e0a18a17",
"outputHash": "fc2fd4a0"
},
"http:get:/function-tests/stream": {
"pikkuFuncId": "http:get:/function-tests/stream",
"functionType": "inline",
"name": "/function-tests/stream",
"services": {
"optimized": false,
"services": []
},
"inputSchemaName": null,
"outputSchemaName": "StreamFunctionTestsOutput",
"inputs": [],
"outputs": [
"StreamFunctionTestsOutput"
],
"sessionless": true,
"contractHash": "de6cfac52a493763",
"inputHash": "748d80cf",
"outputHash": "2090bce5"
},
"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/server-and-serverless/packages/functions/src/scaffold/rpc-public.gen.ts",
"exportedName": "rpcCaller",
"contractHash": "f6901fd233740bf4",
"inputHash": "a69cacc4",
"outputHash": "629e0b5a"
},
"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/server-and-serverless/packages/functions/src/scaffold/rpc-remote.gen.ts",
"exportedName": "remoteRPCHandler"
}
}

View File

@@ -0,0 +1,454 @@
{
"edgeEcho": {
"pikkuFuncId": "edgeEcho",
"functionType": "user",
"funcWrapper": "pikkuSessionlessFunc",
"sessionless": true,
"name": "edgeEcho",
"inputSchemaName": "EdgeEchoInput",
"outputSchemaName": "EdgeEchoOutput",
"inputs": [
"EdgeEchoInput"
],
"outputs": [
"EdgeEchoOutput"
],
"expose": true,
"implementationHash": "e1dd1c485212e3ea",
"contractHash": "91dda37cd8231346",
"inputHash": "3bb62634",
"outputHash": "10641e1c"
},
"getMessage": {
"pikkuFuncId": "getMessage",
"functionType": "user",
"funcWrapper": "pikkuFunc",
"sessionless": false,
"name": "getMessage",
"inputSchemaName": "GetMessageInput",
"outputSchemaName": "GetMessageOutput",
"inputs": [
"GetMessageInput"
],
"outputs": [
"GetMessageOutput"
],
"expose": true,
"readonly": true,
"implementationHash": "90fc43e8778db110",
"contractHash": "0b953679c3613f47",
"inputHash": "cd075fe2",
"outputHash": "d188ad31"
},
"getSession": {
"pikkuFuncId": "getSession",
"functionType": "user",
"funcWrapper": "pikkuFunc",
"sessionless": false,
"name": "getSession",
"inputSchemaName": "GetSessionInput",
"outputSchemaName": "GetSessionOutput",
"inputs": [
"GetSessionInput"
],
"outputs": [
"GetSessionOutput"
],
"expose": true,
"readonly": true,
"implementationHash": "2ed4f21ea016c7e3",
"contractHash": "493320ce1e00cb69",
"inputHash": "ba4ab2e7",
"outputHash": "386fe409"
},
"serverCounter": {
"pikkuFuncId": "serverCounter",
"functionType": "user",
"funcWrapper": "pikkuSessionlessFunc",
"sessionless": true,
"name": "serverCounter",
"inputSchemaName": "ServerCounterInput",
"outputSchemaName": "ServerCounterOutput",
"inputs": [
"ServerCounterInput"
],
"outputs": [
"ServerCounterOutput"
],
"expose": true,
"deploy": "server",
"implementationHash": "8a956f633eb3a4a4",
"contractHash": "a891b2fe0608177d",
"inputHash": "d8945f99",
"outputHash": "56e3de15"
},
"serverUptime": {
"pikkuFuncId": "serverUptime",
"functionType": "user",
"funcWrapper": "pikkuSessionlessFunc",
"sessionless": true,
"name": "serverUptime",
"inputSchemaName": "ServerUptimeInput",
"outputSchemaName": "ServerUptimeOutput",
"inputs": [
"ServerUptimeInput"
],
"outputs": [
"ServerUptimeOutput"
],
"expose": true,
"readonly": true,
"deploy": "server",
"implementationHash": "046d656adb63b531",
"contractHash": "d62f18b9b2739cd6",
"inputHash": "5425fd1f",
"outputHash": "4c1b3905"
},
"updateMessage": {
"pikkuFuncId": "updateMessage",
"functionType": "user",
"funcWrapper": "pikkuFunc",
"sessionless": false,
"name": "updateMessage",
"inputSchemaName": "UpdateMessageInput",
"outputSchemaName": "UpdateMessageOutput",
"inputs": [
"UpdateMessageInput"
],
"outputs": [
"UpdateMessageOutput"
],
"expose": true,
"implementationHash": "bfb74857a2ee5d16",
"contractHash": "16e17af7cea46c7a",
"inputHash": "77b14595",
"outputHash": "bca77943"
},
"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": "5d475a264b62cc63",
"contractHash": "440ca8bea8919cc6",
"inputHash": "6b434982",
"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"
},
"authHandler": {
"pikkuFuncId": "authHandler",
"functionType": "user",
"funcWrapper": "pikkuSessionlessFunc",
"sessionless": true,
"name": "authHandler",
"inputSchemaName": null,
"outputSchemaName": "AuthHandlerOutput",
"inputs": [],
"outputs": [
"AuthHandlerOutput"
],
"implementationHash": "7b1988fee5ec048e",
"contractHash": "56ca81afb5965d88",
"inputHash": "3db46710",
"outputHash": "4a0c6eec"
},
"pikkuConsoleSetSecret": {
"pikkuFuncId": "pikkuConsoleSetSecret",
"functionType": "user",
"funcWrapper": "pikkuSessionlessFunc",
"sessionless": true,
"name": "pikkuConsoleSetSecret",
"inputSchemaName": "PikkuConsoleSetSecretInput",
"outputSchemaName": "PikkuConsoleSetSecretOutput",
"inputs": [
"PikkuConsoleSetSecretInput"
],
"outputs": [
"PikkuConsoleSetSecretOutput"
],
"expose": true,
"implementationHash": "403f267c2ff0edad",
"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": "a2637db8df0daa91",
"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": "4fac80de849be6c9",
"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": "6808aead5cd1896a",
"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": [],
"sessionless": true,
"contractHash": "b693c43c3c0f10d5",
"inputHash": "e0a18a17",
"outputHash": "fc2fd4a0"
},
"http:get:/function-tests/stream": {
"pikkuFuncId": "http:get:/function-tests/stream",
"functionType": "inline",
"name": "/function-tests/stream",
"inputSchemaName": null,
"outputSchemaName": "StreamFunctionTestsOutput",
"inputs": [],
"outputs": [
"StreamFunctionTestsOutput"
],
"sessionless": true,
"contractHash": "de6cfac52a493763",
"inputHash": "748d80cf",
"outputHash": "2090bce5"
},
"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"
},
"remoteRPCHandler": {
"pikkuFuncId": "remoteRPCHandler",
"functionType": "user",
"funcWrapper": "pikkuSessionlessFunc",
"sessionless": true,
"name": "remoteRPCHandler",
"inputSchemaName": "RemoteRPCHandlerInput",
"outputSchemaName": null,
"inputs": [
"RemoteRPCHandlerInput"
],
"outputs": [],
"remote": true,
"implementationHash": "105018a823bdb551"
}
}

View File

@@ -0,0 +1,7 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
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)

View File

@@ -0,0 +1,38 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
/* Import and register functions used by RPCs */
import { addFunction } from '@pikku/core/function'
import { deleteAgentThread } from '../../src/scaffold/agent.gen.js'
import { edgeEcho } from '../../src/functions/edge-echo.function.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 { getMessage } from '../../src/functions/get-message.function.js'
import { getSession } from '../../src/functions/get-session.function.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'
import { serverCounter } from '../../src/functions/server-counter.function.js'
import { serverUptime } from '../../src/functions/server-uptime.function.js'
import { updateMessage } from '../../src/functions/update-message.function.js'
addFunction('deleteAgentThread', deleteAgentThread)
addFunction('edgeEcho', edgeEcho)
addFunction('getAgentThreadMessages', getAgentThreadMessages)
addFunction('getAgentThreadRuns', getAgentThreadRuns)
addFunction('getAgentThreads', getAgentThreads)
addFunction('getMessage', getMessage)
addFunction('getSession', getSession)
addFunction('pikkuConsoleGetSecret', pikkuConsoleGetSecret)
addFunction('pikkuConsoleGetVariable', pikkuConsoleGetVariable)
addFunction('pikkuConsoleHasSecret', pikkuConsoleHasSecret)
addFunction('pikkuConsoleSetSecret', pikkuConsoleSetSecret)
addFunction('pikkuConsoleSetVariable', pikkuConsoleSetVariable)
addFunction('remoteRPCHandler', remoteRPCHandler)
addFunction('serverCounter', serverCounter)
addFunction('serverUptime', serverUptime)
addFunction('updateMessage', updateMessage)

View File

@@ -0,0 +1,86 @@
{
"agentRoutes": {
"basePath": "",
"tags": [
"pikku:public"
],
"auth": false,
"routes": {
"agentRun": {
"auth": null,
"contentType": null,
"method": "post",
"route": "/rpc/agent/:agentName",
"sse": null,
"timeout": null,
"func": {
"pikkuFuncId": "agentCaller"
}
},
"agentStream": {
"auth": null,
"contentType": null,
"method": "post",
"route": "/rpc/agent/:agentName/stream",
"sse": true,
"timeout": null,
"func": {
"pikkuFuncId": "agentStreamCaller"
}
},
"agentApprove": {
"auth": null,
"contentType": null,
"method": "post",
"route": "/rpc/agent/:agentName/approve",
"sse": null,
"timeout": null,
"func": {
"pikkuFuncId": "agentApproveCaller"
}
},
"agentResume": {
"auth": null,
"contentType": null,
"method": "post",
"route": "/rpc/agent/:agentName/resume",
"sse": true,
"timeout": null,
"func": {
"pikkuFuncId": "agentResumeCaller"
}
}
}
},
"consoleRoutes": {
"basePath": "",
"tags": [],
"auth": false,
"routes": {
"workflowRunStream": {
"auth": null,
"contentType": null,
"method": "get",
"route": "/workflow-run/:runId/stream",
"sse": true,
"timeout": null,
"func": {
"pikkuFuncId": "console:streamWorkflowRun",
"packageName": "@pikku/addon-console"
}
},
"functionTestsStream": {
"auth": null,
"contentType": null,
"method": "get",
"route": "/function-tests/stream",
"sse": true,
"timeout": null,
"func": {
"pikkuFuncId": "console:streamFunctionTests",
"packageName": "@pikku/addon-console"
}
}
}
}
}

View File

@@ -0,0 +1,5 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
import contractsMeta from './pikku-http-contracts-meta.gen.json' with { type: 'json' }
export default contractsMeta

View File

@@ -0,0 +1,147 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
/**
* 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)
}

View File

@@ -0,0 +1,151 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
/**
* This provides the structure needed for typescript to be aware of routes and their return types
*/
import type { StreamWorkflowRunInput, StreamFunctionTestsOutput } from '@pikku/addon-console/dist/.pikku/rpc/pikku-rpc-wirings-map.internal.gen'
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; context?: string; }
export type AuthHandlerOutput = Promise<any> | Promise<void>
export type DeleteAgentThreadInput = { threadId: string; resourceId?: string; }
export type DeleteAgentThreadOutput = { deleted: boolean; }
export type EdgeEchoInput = {
message: string;
}
export type EdgeEchoOutput = {
echoed: string;
serverless: 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 GetMessageInput = {}
export type GetMessageOutput = {
message: string;
updatedAt: string;
updatedBy: {
email: string;
name: string | null;
} | null;
}
export type GetSessionInput = {}
export type GetSessionOutput = {
userId: string;
email: string;
name: string | null;
}
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 SecretSchema_betterAuthSecret = string
export type ServerCounterInput = {}
export type ServerCounterOutput = {
count: number;
pid: number;
}
export type ServerUptimeInput = {}
export type ServerUptimeOutput = {
uptimeSeconds: number;
nodeVersion: string;
rssMb: number;
}
export type UpdateMessageInput = {
message: string;
}
export type UpdateMessageOutput = {
message: string;
updatedAt: string;
updatedBy: {
email: string;
name: string | null;
} | null;
}
// The '& {}' is a workaround for not directly refering to a type since it confuses typescript
export type ServerUptimeInputBody = ServerUptimeInput & {}
export type ServerCounterInputBody = ServerCounterInput & {}
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'> & {}
export type StreamWorkflowRunInputParams = Pick<StreamWorkflowRunInput, 'runId'> & {}
export type StreamWorkflowRunInputBody = Omit<StreamWorkflowRunInput, 'runId'> & {}
export type RpcCallerInputParams = Pick<RpcCallerInput, 'rpcName'> & {}
export type RpcCallerInputBody = Omit<RpcCallerInput, 'rpcName'> & {}
export type RemoteRPCHandlerInputParams = Pick<RemoteRPCHandlerInput, 'rpcName'> & {}
export type RemoteRPCHandlerInputBody = Omit<RemoteRPCHandlerInput, 'rpcName'> & {}
interface HTTPWiringHandler<I, O> {
input: I;
output: O;
}
export type HTTPWiringsMap = {
readonly '/api/auth{/*splat}': {
readonly GET: HTTPWiringHandler<null, AuthHandlerOutput>,
readonly POST: HTTPWiringHandler<null, AuthHandlerOutput>,
},
readonly '/workflow-run/:runId/stream': {
readonly GET: HTTPWiringHandler<StreamWorkflowRunInput, null>,
},
readonly '/function-tests/stream': {
readonly GET: HTTPWiringHandler<null, StreamFunctionTestsOutput>,
},
readonly '/server/uptime': {
readonly POST: HTTPWiringHandler<ServerUptimeInput, ServerUptimeOutput>,
},
readonly '/server/counter': {
readonly POST: HTTPWiringHandler<ServerCounterInput, ServerCounterOutput>,
},
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>,
},
readonly '/rpc/:rpcName': {
readonly POST: HTTPWiringHandler<RpcCallerInput, null>,
},
readonly '/remote/rpc/:rpcName': {
readonly POST: HTTPWiringHandler<RemoteRPCHandlerInput, 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];

View File

@@ -0,0 +1,197 @@
{
"get": {
"/api/auth{/*splat}": {
"pikkuFuncId": "authHandler",
"route": "/api/auth{/*splat}",
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/src/scaffold/auth.gen.ts",
"method": "get",
"middleware": [
{
"type": "http",
"route": "*"
}
]
},
"/workflow-run/:runId/stream": {
"pikkuFuncId": "http:get:/workflow-run/:runId/stream",
"route": "/workflow-run/:runId/stream",
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/src/scaffold/console.gen.ts",
"method": "get",
"params": [
"runId"
],
"middleware": [
{
"type": "http",
"route": "*"
}
],
"sse": true
},
"/function-tests/stream": {
"pikkuFuncId": "http:get:/function-tests/stream",
"route": "/function-tests/stream",
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/src/scaffold/console.gen.ts",
"method": "get",
"middleware": [
{
"type": "http",
"route": "*"
}
],
"sse": true
}
},
"post": {
"/server/uptime": {
"pikkuFuncId": "serverUptime",
"route": "/server/uptime",
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/src/wirings/server.http.ts",
"method": "post",
"middleware": [
{
"type": "http",
"route": "*"
}
]
},
"/server/counter": {
"pikkuFuncId": "serverCounter",
"route": "/server/counter",
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/src/wirings/server.http.ts",
"method": "post",
"middleware": [
{
"type": "http",
"route": "*"
}
]
},
"/rpc/agent/:agentName": {
"pikkuFuncId": "agentCaller",
"route": "/rpc/agent/:agentName",
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/src/scaffold/agent.gen.ts",
"method": "post",
"params": [
"agentName"
],
"tags": [
"pikku:public"
],
"middleware": [
{
"type": "http",
"route": "*"
}
]
},
"/rpc/agent/:agentName/stream": {
"pikkuFuncId": "agentStreamCaller",
"route": "/rpc/agent/:agentName/stream",
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/src/scaffold/agent.gen.ts",
"method": "post",
"params": [
"agentName"
],
"tags": [
"pikku:public"
],
"middleware": [
{
"type": "http",
"route": "*"
}
],
"sse": true
},
"/rpc/agent/:agentName/approve": {
"pikkuFuncId": "agentApproveCaller",
"route": "/rpc/agent/:agentName/approve",
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/src/scaffold/agent.gen.ts",
"method": "post",
"params": [
"agentName"
],
"tags": [
"pikku:public"
],
"middleware": [
{
"type": "http",
"route": "*"
}
]
},
"/rpc/agent/:agentName/resume": {
"pikkuFuncId": "agentResumeCaller",
"route": "/rpc/agent/:agentName/resume",
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/src/scaffold/agent.gen.ts",
"method": "post",
"params": [
"agentName"
],
"tags": [
"pikku:public"
],
"middleware": [
{
"type": "http",
"route": "*"
}
],
"sse": true
},
"/api/auth{/*splat}": {
"pikkuFuncId": "authHandler",
"route": "/api/auth{/*splat}",
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/src/scaffold/auth.gen.ts",
"method": "post",
"middleware": [
{
"type": "http",
"route": "*"
}
]
},
"/rpc/:rpcName": {
"pikkuFuncId": "rpcCaller",
"route": "/rpc/:rpcName",
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/src/scaffold/rpc-public.gen.ts",
"method": "post",
"params": [
"rpcName"
],
"middleware": [
{
"type": "http",
"route": "*"
}
]
},
"/remote/rpc/:rpcName": {
"pikkuFuncId": "remoteRPCHandler",
"route": "/remote/rpc/:rpcName",
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/src/scaffold/rpc-remote.gen.ts",
"method": "post",
"params": [
"rpcName"
],
"middleware": [
{
"type": "http",
"route": "*"
},
{
"type": "wire",
"name": "pikkuRemoteAuthMiddleware",
"inline": false
}
]
}
},
"put": {},
"delete": {},
"head": {},
"patch": {},
"options": {}
}

View File

@@ -0,0 +1,7 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
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)

View File

@@ -0,0 +1,12 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
/* The files with an wireHTTP function call */
import '../../src/middleware/cors.middleware.js'
import '../../src/scaffold/agent.gen.js'
import '../../src/scaffold/auth-middleware.gen.js'
import '../../src/scaffold/auth.gen.js'
import '../../src/scaffold/console.gen.js'
import '../../src/scaffold/rpc-public.gen.js'
import '../../src/scaffold/rpc-remote.gen.js'
import '../../src/wirings/server.http.js'

View File

@@ -0,0 +1,5 @@
{
"tools": [],
"resources": [],
"prompts": []
}

View File

@@ -0,0 +1,183 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
/**
* 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
}

View File

@@ -0,0 +1,33 @@
{
"definitions": {},
"instances": {
"http:*:0": {
"definitionId": "betterAuthStatelessSession",
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/src/scaffold/auth-middleware.gen.ts",
"position": 236,
"isFactoryCall": true
}
},
"httpGroups": {
"*": {
"exportName": null,
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/src/scaffold/auth-middleware.gen.ts",
"position": 236,
"services": {
"optimized": false,
"services": []
},
"count": 1,
"instanceIds": [
"http:*:0"
],
"isFactory": false
}
},
"tagGroups": {},
"channelMiddleware": {
"definitions": {},
"instances": {},
"tagGroups": {}
}
}

View File

@@ -0,0 +1,5 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
/* Side-effect imports for direct middleware registration calls */
import '../../src/scaffold/auth-middleware.gen.js'

View File

@@ -0,0 +1,14 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
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 './middleware/pikku-middleware.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'

View File

@@ -0,0 +1,10 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
import { LocalMetaService } from '@pikku/core/services/local-meta'
export class PikkuMetaService extends LocalMetaService {
constructor() {
super('/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/.pikku')
}
}

View File

@@ -0,0 +1,43 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
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,
'audit': false,
'auditLog': false,
'auth': true,
'config': true,
'content': false,
'credentialService': true,
'deploymentService': true,
'emailService': false,
'eventHub': false,
'jwt': false,
'kysely': true,
'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 = Required<Pick<SingletonServices, 'agentRunService' | 'aiAgentRunner' | 'aiRunState' | 'aiStorage' | 'auth' | 'config' | 'credentialService' | 'deploymentService' | 'kysely' | 'logger' | 'metaService' | 'schedulerService' | 'schema' | 'secrets' | 'variables' | 'workflowRunService' | 'workflowService'>> & Partial<Omit<SingletonServices, 'agentRunService' | 'aiAgentRunner' | 'aiRunState' | 'aiStorage' | 'auth' | 'config' | 'credentialService' | 'deploymentService' | 'kysely' | 'logger' | 'metaService' | 'schedulerService' | 'schema' | 'secrets' | 'variables' | 'workflowRunService' | 'workflowService'>>
export type RequiredWireServices = Partial<Services>

View File

@@ -0,0 +1,39 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
/**
* 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'
// Auth types (typed pikkuBetterAuth re-export)
export * from './auth/auth.types.js'

View File

@@ -0,0 +1,27 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
/**
* 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)
}

View File

@@ -0,0 +1,116 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
/**
* 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; context?: string; }
export type AuthHandlerOutput = Promise<any> | Promise<void>
export type DeleteAgentThreadInput = { threadId: string; resourceId?: string; }
export type DeleteAgentThreadOutput = { deleted: boolean; }
export type EdgeEchoInput = {
message: string;
}
export type EdgeEchoOutput = {
echoed: string;
serverless: 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 GetMessageInput = {}
export type GetMessageOutput = {
message: string;
updatedAt: string;
updatedBy: {
email: string;
name: string | null;
} | null;
}
export type GetSessionInput = {}
export type GetSessionOutput = {
userId: string;
email: string;
name: string | null;
}
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 SecretSchema_betterAuthSecret = string
export type ServerCounterInput = {}
export type ServerCounterOutput = {
count: number;
pid: number;
}
export type ServerUptimeInput = {}
export type ServerUptimeOutput = {
uptimeSeconds: number;
nodeVersion: string;
rssMb: number;
}
export type UpdateMessageInput = {
message: string;
}
export type UpdateMessageOutput = {
message: string;
updatedAt: string;
updatedBy: {
email: string;
name: string | null;
} | null;
}
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;
}

View File

@@ -0,0 +1,6 @@
{
"pikku-remote-internal-rpc": {
"pikkuFuncId": "remoteRPCHandler",
"name": "pikku-remote-internal-rpc"
}
}

View File

@@ -0,0 +1,8 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
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)

View File

@@ -0,0 +1,5 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
/* The files with an addQueueWorkers function call */
import '../../src/scaffold/rpc-remote.gen.js'

View File

@@ -0,0 +1,192 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
/**
* 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; context?: string; }
export type AuthHandlerOutput = Promise<any> | Promise<void>
export type DeleteAgentThreadInput = { threadId: string; resourceId?: string; }
export type DeleteAgentThreadOutput = { deleted: boolean; }
export type EdgeEchoInput = {
message: string;
}
export type EdgeEchoOutput = {
echoed: string;
serverless: 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 GetMessageInput = {}
export type GetMessageOutput = {
message: string;
updatedAt: string;
updatedBy: {
email: string;
name: string | null;
} | null;
}
export type GetSessionInput = {}
export type GetSessionOutput = {
userId: string;
email: string;
name: string | null;
}
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 SecretSchema_betterAuthSecret = string
export type ServerCounterInput = {}
export type ServerCounterOutput = {
count: number;
pid: number;
}
export type ServerUptimeInput = {}
export type ServerUptimeOutput = {
uptimeSeconds: number;
nodeVersion: string;
rssMb: number;
}
export type UpdateMessageInput = {
message: string;
}
export type UpdateMessageOutput = {
message: string;
updatedAt: string;
updatedBy: {
email: string;
name: string | null;
} | null;
}
interface RPCHandler<I, O> {
input: I;
output: O;
}
export type RPCMap = {
readonly 'edgeEcho': RPCHandler<EdgeEchoInput, EdgeEchoOutput>,
readonly 'getMessage': RPCHandler<GetMessageInput, GetMessageOutput>,
readonly 'getSession': RPCHandler<GetSessionInput, GetSessionOutput>,
readonly 'serverCounter': RPCHandler<ServerCounterInput, ServerCounterOutput>,
readonly 'serverUptime': RPCHandler<ServerUptimeInput, ServerUptimeOutput>,
readonly 'updateMessage': RPCHandler<UpdateMessageInput, UpdateMessageOutput>,
readonly 'getAgentThreads': RPCHandler<GetAgentThreadsInput, GetAgentThreadsOutput>,
readonly 'getAgentThreadMessages': RPCHandler<GetAgentThreadMessagesInput, GetAgentThreadMessagesOutput>,
readonly 'getAgentThreadRuns': RPCHandler<GetAgentThreadRunsInput, GetAgentThreadRunsOutput>,
readonly 'deleteAgentThread': RPCHandler<DeleteAgentThreadInput, DeleteAgentThreadOutput>,
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>,
};
// 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>

View File

@@ -0,0 +1,199 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
/**
* 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; context?: string; }
export type AuthHandlerOutput = Promise<any> | Promise<void>
export type DeleteAgentThreadInput = { threadId: string; resourceId?: string; }
export type DeleteAgentThreadOutput = { deleted: boolean; }
export type EdgeEchoInput = {
message: string;
}
export type EdgeEchoOutput = {
echoed: string;
serverless: 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 GetMessageInput = {}
export type GetMessageOutput = {
message: string;
updatedAt: string;
updatedBy: {
email: string;
name: string | null;
} | null;
}
export type GetSessionInput = {}
export type GetSessionOutput = {
userId: string;
email: string;
name: string | null;
}
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 SecretSchema_betterAuthSecret = string
export type ServerCounterInput = {}
export type ServerCounterOutput = {
count: number;
pid: number;
}
export type ServerUptimeInput = {}
export type ServerUptimeOutput = {
uptimeSeconds: number;
nodeVersion: string;
rssMb: number;
}
export type UpdateMessageInput = {
message: string;
}
export type UpdateMessageOutput = {
message: string;
updatedAt: string;
updatedBy: {
email: string;
name: string | null;
} | null;
}
interface RPCHandler<I, O> {
input: I;
output: O;
}
export type RPCMap = {
readonly 'edgeEcho': RPCHandler<EdgeEchoInput, EdgeEchoOutput>,
readonly 'getMessage': RPCHandler<GetMessageInput, GetMessageOutput>,
readonly 'getSession': RPCHandler<GetSessionInput, GetSessionOutput>,
readonly 'serverCounter': RPCHandler<ServerCounterInput, ServerCounterOutput>,
readonly 'serverUptime': RPCHandler<ServerUptimeInput, ServerUptimeOutput>,
readonly 'updateMessage': RPCHandler<UpdateMessageInput, UpdateMessageOutput>,
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>,
readonly 'authHandler': RPCHandler<null, AuthHandlerOutput>,
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 'rpcCaller': RPCHandler<RpcCallerInput, null>,
readonly 'remoteRPCHandler': RPCHandler<RemoteRPCHandlerInput, null>,
};
// 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>

View File

@@ -0,0 +1,24 @@
{
"edgeEcho": "edgeEcho",
"getMessage": "getMessage",
"getSession": "getSession",
"serverCounter": "serverCounter",
"serverUptime": "serverUptime",
"updateMessage": "updateMessage",
"agentCaller": "agentCaller",
"agentStreamCaller": "agentStreamCaller",
"agentApproveCaller": "agentApproveCaller",
"agentResumeCaller": "agentResumeCaller",
"getAgentThreads": "getAgentThreads",
"getAgentThreadMessages": "getAgentThreadMessages",
"getAgentThreadRuns": "getAgentThreadRuns",
"deleteAgentThread": "deleteAgentThread",
"authHandler": "authHandler",
"pikkuConsoleSetSecret": "pikkuConsoleSetSecret",
"pikkuConsoleGetVariable": "pikkuConsoleGetVariable",
"pikkuConsoleSetVariable": "pikkuConsoleSetVariable",
"pikkuConsoleHasSecret": "pikkuConsoleHasSecret",
"pikkuConsoleGetSecret": "pikkuConsoleGetSecret",
"rpcCaller": "rpcCaller",
"remoteRPCHandler": "remoteRPCHandler"
}

View File

@@ -0,0 +1,6 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
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>)

View File

@@ -0,0 +1,25 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
/**
* 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)
}

View File

@@ -0,0 +1,163 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
import { addSchema } from '@pikku/core/schema'
import * as EdgeEchoInput from './schemas/EdgeEchoInput.schema.json' with { type: 'json' }
addSchema('EdgeEchoInput', EdgeEchoInput)
import * as EdgeEchoOutput from './schemas/EdgeEchoOutput.schema.json' with { type: 'json' }
addSchema('EdgeEchoOutput', EdgeEchoOutput)
import * as GetMessageInput from './schemas/GetMessageInput.schema.json' with { type: 'json' }
addSchema('GetMessageInput', GetMessageInput)
import * as GetMessageOutput from './schemas/GetMessageOutput.schema.json' with { type: 'json' }
addSchema('GetMessageOutput', GetMessageOutput)
import * as GetSessionInput from './schemas/GetSessionInput.schema.json' with { type: 'json' }
addSchema('GetSessionInput', GetSessionInput)
import * as GetSessionOutput from './schemas/GetSessionOutput.schema.json' with { type: 'json' }
addSchema('GetSessionOutput', GetSessionOutput)
import * as ServerCounterInput from './schemas/ServerCounterInput.schema.json' with { type: 'json' }
addSchema('ServerCounterInput', ServerCounterInput)
import * as ServerCounterOutput from './schemas/ServerCounterOutput.schema.json' with { type: 'json' }
addSchema('ServerCounterOutput', ServerCounterOutput)
import * as ServerUptimeInput from './schemas/ServerUptimeInput.schema.json' with { type: 'json' }
addSchema('ServerUptimeInput', ServerUptimeInput)
import * as ServerUptimeOutput from './schemas/ServerUptimeOutput.schema.json' with { type: 'json' }
addSchema('ServerUptimeOutput', ServerUptimeOutput)
import * as UpdateMessageInput from './schemas/UpdateMessageInput.schema.json' with { type: 'json' }
addSchema('UpdateMessageInput', UpdateMessageInput)
import * as UpdateMessageOutput from './schemas/UpdateMessageOutput.schema.json' with { type: 'json' }
addSchema('UpdateMessageOutput', UpdateMessageOutput)
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)
import * as AuthHandlerOutput from './schemas/AuthHandlerOutput.schema.json' with { type: 'json' }
addSchema('AuthHandlerOutput', AuthHandlerOutput)
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 StreamFunctionTestsOutput from './schemas/StreamFunctionTestsOutput.schema.json' with { type: 'json' }
addSchema('StreamFunctionTestsOutput', StreamFunctionTestsOutput)
import * as RpcCallerInput from './schemas/RpcCallerInput.schema.json' with { type: 'json' }
addSchema('RpcCallerInput', RpcCallerInput)
import * as RemoteRPCHandlerInput from './schemas/RemoteRPCHandlerInput.schema.json' with { type: 'json' }
addSchema('RemoteRPCHandlerInput', RemoteRPCHandlerInput)
import * as SecretSchema_betterAuthSecret from './schemas/SecretSchema_betterAuthSecret.schema.json' with { type: 'json' }
addSchema('SecretSchema_betterAuthSecret', SecretSchema_betterAuthSecret)

View File

@@ -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":{}}

View File

@@ -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":{}}

View File

@@ -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":{}}

View File

@@ -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"},"context":{"type":"string"}},"required":["agentName","message","threadId","resourceId"],"additionalProperties":false,"definitions":{}}

View File

@@ -0,0 +1 @@
{"$schema":"http://json-schema.org/draft-07/schema#","anyOf":[{},{"type":"null"}],"definitions":{}}

View File

@@ -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":{}}

View File

@@ -0,0 +1 @@
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"deleted":{"type":"boolean"}},"required":["deleted"],"additionalProperties":false,"definitions":{}}

View File

@@ -0,0 +1 @@
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"message":{"type":"string","minLength":1,"maxLength":280}},"required":["message"],"additionalProperties":false}

View File

@@ -0,0 +1 @@
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"echoed":{"type":"string"},"serverless":{"type":"boolean"}},"required":["echoed","serverless"],"additionalProperties":false}

View File

@@ -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":{}}

View File

@@ -0,0 +1 @@
{"$schema":"http://json-schema.org/draft-07/schema#","type":"array","items":{},"definitions":{}}

View File

@@ -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":{}}

View File

@@ -0,0 +1 @@
{"$schema":"http://json-schema.org/draft-07/schema#","type":"array","items":{},"definitions":{}}

View File

@@ -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":{}}

View File

@@ -0,0 +1 @@
{"$schema":"http://json-schema.org/draft-07/schema#","type":"array","items":{},"definitions":{}}

View File

@@ -0,0 +1 @@
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{},"additionalProperties":false}

View File

@@ -0,0 +1 @@
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"message":{"type":"string"},"updatedAt":{"type":"string"},"updatedBy":{"anyOf":[{"type":"object","properties":{"email":{"type":"string","format":"email","pattern":"^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"},"name":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["email","name"],"additionalProperties":false},{"type":"null"}]}},"required":["message","updatedAt","updatedBy"],"additionalProperties":false}

View File

@@ -0,0 +1 @@
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{},"additionalProperties":false}

View File

@@ -0,0 +1 @@
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"userId":{"type":"string"},"email":{"type":"string","format":"email","pattern":"^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"},"name":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["userId","email","name"],"additionalProperties":false}

View File

@@ -0,0 +1 @@
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"secretId":{"type":"string"}},"required":["secretId"],"additionalProperties":false,"definitions":{}}

View File

@@ -0,0 +1 @@
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"exists":{"type":"boolean"},"value":{}},"required":["exists","value"],"additionalProperties":false,"definitions":{}}

View File

@@ -0,0 +1 @@
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"variableId":{"type":"string"}},"required":["variableId"],"additionalProperties":false,"definitions":{}}

View File

@@ -0,0 +1 @@
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"exists":{"type":"boolean"},"value":{}},"required":["exists","value"],"additionalProperties":false,"definitions":{}}

View File

@@ -0,0 +1 @@
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"secretId":{"type":"string"}},"required":["secretId"],"additionalProperties":false,"definitions":{}}

View File

@@ -0,0 +1 @@
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"exists":{"type":"boolean"}},"required":["exists"],"additionalProperties":false,"definitions":{}}

View File

@@ -0,0 +1 @@
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"secretId":{"type":"string"},"value":{}},"required":["secretId","value"],"additionalProperties":false,"definitions":{}}

View File

@@ -0,0 +1 @@
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"success":{"type":"boolean"}},"required":["success"],"additionalProperties":false,"definitions":{}}

View File

@@ -0,0 +1 @@
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"variableId":{"type":"string"},"value":{}},"required":["variableId","value"],"additionalProperties":false,"definitions":{}}

View File

@@ -0,0 +1 @@
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"success":{"type":"boolean"}},"required":["success"],"additionalProperties":false,"definitions":{}}

View File

@@ -0,0 +1 @@
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"rpcName":{"type":"string"},"data":{}},"required":["rpcName"],"additionalProperties":false,"definitions":{}}

View File

@@ -0,0 +1 @@
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"rpcName":{"type":"string"},"data":{}},"required":["rpcName"],"additionalProperties":false,"definitions":{}}

View File

@@ -0,0 +1 @@
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"string"}

View File

@@ -0,0 +1 @@
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{},"additionalProperties":false}

View File

@@ -0,0 +1 @@
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"count":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"pid":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}},"required":["count","pid"],"additionalProperties":false}

View File

@@ -0,0 +1 @@
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{},"additionalProperties":false}

View File

@@ -0,0 +1 @@
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"uptimeSeconds":{"type":"number"},"nodeVersion":{"type":"string"},"rssMb":{"type":"number"}},"required":["uptimeSeconds","nodeVersion","rssMb"],"additionalProperties":false}

View File

@@ -0,0 +1 @@
{"$schema":"http://json-schema.org/draft-07/schema#","anyOf":[{"type":"object","properties":{"type":{"type":"string","const":"run-start"},"scenarios":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"uri":{"type":"string"},"steps":{"type":"array","items":{"type":"string"}}},"required":["id","name","uri","steps"],"additionalProperties":false}}},"required":["type","scenarios"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","const":"scenario-start"},"id":{"type":"string"},"name":{"type":"string"},"uri":{"type":"string"}},"required":["type","id","name","uri"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","const":"step"},"scenarioId":{"type":"string"},"step":{"type":"string"},"status":{},"duration":{"type":"number"},"message":{"type":"string"}},"required":["type","scenarioId","step","status","duration"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","const":"scenario-done"},"id":{"type":"string"},"name":{"type":"string"},"status":{}},"required":["type","id","name","status"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","const":"done"},"coverage":{"$ref":"#/definitions/FunctionCoverageReport"}},"required":["type","coverage"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","const":"error"},"message":{"type":"string"}},"required":["type","message"],"additionalProperties":false}],"definitions":{"FunctionCoverageReport":{"type":"object","properties":{"generatedAt":{"type":"string"},"summary":{"type":"object","properties":{"total":{"type":"number"},"covered":{"type":"number"},"partial":{"type":"number"},"uncovered":{"type":"number"},"unknown":{"type":"number"},"overallRatio":{"type":"number"}},"required":["total","covered","partial","uncovered","unknown","overallRatio"],"additionalProperties":false},"functions":{"type":"array","items":{"$ref":"#/definitions/FunctionCoverageEntry"}}},"required":["generatedAt","summary","functions"],"additionalProperties":false},"FunctionCoverageEntry":{"type":"object","properties":{"name":{"type":"string"},"sourceFile":{"type":"string"},"exposed":{"type":"boolean"},"description":{"type":["string","null"]},"coveredLines":{"type":"number"},"totalLines":{"type":"number"},"missedLines":{"type":"array","items":{"type":"number"}},"ratio":{"type":"number"},"status":{"$ref":"#/definitions/CoverageStatus"}},"required":["name","sourceFile","exposed","description","coveredLines","totalLines","missedLines","ratio","status"],"additionalProperties":false},"CoverageStatus":{"type":"string","enum":["covered","partial","uncovered","unknown"]}}}

View File

@@ -0,0 +1 @@
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{"runId":{"type":"string"}},"required":["runId"],"additionalProperties":false,"definitions":{}}

View File

@@ -0,0 +1 @@
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"message":{"type":"string","minLength":1,"maxLength":160}},"required":["message"],"additionalProperties":false}

View File

@@ -0,0 +1 @@
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"message":{"type":"string"},"updatedAt":{"type":"string"},"updatedBy":{"anyOf":[{"type":"object","properties":{"email":{"type":"string","format":"email","pattern":"^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"},"name":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["email","name"],"additionalProperties":false},{"type":"null"}]}},"required":["message","updatedAt","updatedBy"],"additionalProperties":false}

View File

@@ -0,0 +1,5 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
export { wireSecret } from '@pikku/core/secret'
export type { CoreSecret, SecretDefinitionMeta, SecretDefinitionsMeta } from '@pikku/core/secret'

View File

@@ -0,0 +1,10 @@
{
"betterAuthSecret": {
"name": "betterAuthSecret",
"displayName": "Better Auth Secret",
"description": "Signing secret for better-auth sessions",
"secretId": "BETTER_AUTH_SECRET",
"schema": "SecretSchema_betterAuthSecret",
"sourceFile": "/Users/yasser/git/pikku/fabric/templates/server-and-serverless/packages/functions/src/scaffold/auth-secrets.gen.ts"
}
}

View File

@@ -0,0 +1,23 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
import { TypedSecretService as CoreTypedSecretService, type CredentialMeta } from '@pikku/core/services'
import type { SecretService } from '@pikku/core/services'
import type { z } from 'zod'
import { BetterAuthSecretSchema } from '../../src/scaffold/auth-secrets.gen.js'
export interface CredentialsMap {
'BETTER_AUTH_SECRET': z.infer<typeof BetterAuthSecretSchema>
}
export type SecretId = keyof CredentialsMap
const CREDENTIALS_META: Record<string, CredentialMeta> = {
'BETTER_AUTH_SECRET': { name: 'betterAuthSecret', displayName: 'Better Auth Secret' }
}
export class TypedSecretService extends CoreTypedSecretService<CredentialsMap> {
constructor(secrets: SecretService) {
super(secrets, CREDENTIALS_META)
}
}

View File

@@ -0,0 +1,160 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
/**
* 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)
}

View File

@@ -0,0 +1,5 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
export { wireVariable } from '@pikku/core/variable'
export type { CoreVariable, VariableDefinitionMeta, VariableDefinitionsMeta } from '@pikku/core/variable'

View File

@@ -0,0 +1 @@
{}

View File

@@ -0,0 +1,21 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
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)
}
}

View File

@@ -0,0 +1,46 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
/**
* 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>;
}

View File

@@ -0,0 +1,167 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
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)
}

View File

@@ -0,0 +1,9 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/
import { pikkuState } from '@pikku/core/internal'
import type { SerializedWorkflowGraphs } from '@pikku/inspector/workflow-graph'
const workflowsMeta: SerializedWorkflowGraphs = {}
pikkuState(null, 'workflows', 'meta', workflowsMeta)

View File

@@ -0,0 +1,3 @@
/**
* This file was generated by @pikku/cli@0.12.48
*/