@pikku/cli 0.12.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.schema.json +1 -1
- package/console-app/assets/index-DiYPTQU_.js +676 -0
- package/console-app/index.html +6 -1
- package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +30 -3
- package/dist/.pikku/agent/pikku-agent-types.gen.js +13 -0
- package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.js +2 -2
- package/dist/.pikku/agent/pikku-agent-wirings.gen.d.ts +1 -1
- package/dist/.pikku/agent/pikku-agent-wirings.gen.js +1 -1
- package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +1 -1
- package/dist/.pikku/channel/pikku-channel-types.gen.js +1 -1
- package/dist/.pikku/channel/pikku-channels-meta.gen.js +2 -2
- package/dist/.pikku/channel/pikku-channels.gen.d.ts +1 -1
- package/dist/.pikku/channel/pikku-channels.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-channel.js +57 -3
- package/dist/.pikku/cli/pikku-cli-client.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-client.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-types.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +2 -2
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.json +228 -10
- package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli.gen.js +1 -1
- package/dist/.pikku/console/pikku-node-types.gen.d.ts +1 -1
- package/dist/.pikku/function/pikku-function-types.gen.d.ts +14 -11
- package/dist/.pikku/function/pikku-function-types.gen.js +25 -13
- package/dist/.pikku/function/pikku-functions-meta.gen.js +2 -2
- package/dist/.pikku/function/pikku-functions-meta.gen.json +359 -105
- package/dist/.pikku/function/pikku-functions.gen.js +3 -3
- package/dist/.pikku/http/pikku-http-types.gen.d.ts +1 -1
- package/dist/.pikku/http/pikku-http-types.gen.js +1 -1
- package/dist/.pikku/http/pikku-http-wirings-meta.gen.js +2 -2
- package/dist/.pikku/http/pikku-http-wirings.gen.d.ts +1 -1
- package/dist/.pikku/http/pikku-http-wirings.gen.js +1 -1
- package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +1 -1
- package/dist/.pikku/mcp/pikku-mcp-types.gen.js +1 -1
- package/dist/.pikku/mcp/pikku-mcp-wirings-meta.gen.js +2 -2
- package/dist/.pikku/mcp/pikku-mcp-wirings.gen.d.ts +1 -1
- package/dist/.pikku/mcp/pikku-mcp-wirings.gen.js +1 -1
- package/dist/.pikku/pikku-bootstrap.gen.js +2 -2
- package/dist/.pikku/pikku-services.gen.d.ts +2 -1
- package/dist/.pikku/pikku-services.gen.js +1 -0
- package/dist/.pikku/pikku-types.gen.d.ts +1 -1
- package/dist/.pikku/pikku-types.gen.js +1 -1
- package/dist/.pikku/pikku-websocket.gen.d.ts +1 -1
- package/dist/.pikku/pikku-websocket.gen.js +1 -1
- package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +1 -1
- package/dist/.pikku/queue/pikku-queue-types.gen.js +1 -1
- package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +2 -2
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +1 -1
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +1 -1
- package/dist/.pikku/rpc/pikku-remote-rpc-workers.gen.js +1 -1
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +2 -2
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +15 -6
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +1 -1
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +1 -1
- package/dist/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.js +2 -2
- package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.d.ts +1 -1
- package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.js +1 -1
- package/dist/.pikku/schemas/register.gen.js +15 -5
- package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuNewAddonInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuNewFunctionInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuNewMiddlewareInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuNewPermissionInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuNewWiringInput.schema.json +1 -0
- package/dist/.pikku/secrets/pikku-secret-types.gen.d.ts +1 -1
- package/dist/.pikku/secrets/pikku-secret-types.gen.js +1 -1
- package/dist/.pikku/secrets/pikku-secrets.gen.d.ts +1 -1
- package/dist/.pikku/secrets/pikku-secrets.gen.js +1 -1
- package/dist/.pikku/trigger/pikku-trigger-types.gen.d.ts +1 -1
- package/dist/.pikku/trigger/pikku-trigger-types.gen.js +1 -1
- package/dist/.pikku/variables/pikku-variable-types.gen.d.ts +1 -1
- package/dist/.pikku/variables/pikku-variable-types.gen.js +1 -1
- package/dist/.pikku/variables/pikku-variables.gen.d.ts +1 -1
- package/dist/.pikku/variables/pikku-variables.gen.js +1 -1
- package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +1 -1
- package/dist/.pikku/workflow/pikku-workflow-types.gen.js +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +2 -2
- package/dist/.pikku/workflow/pikku-workflow-wirings.gen.d.ts +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +1 -1
- package/dist/src/cli.wiring.js +190 -9
- package/dist/src/functions/commands/all.js +6 -6
- package/dist/src/functions/commands/info.d.ts +9 -0
- package/dist/src/functions/commands/info.js +283 -0
- package/dist/src/functions/commands/new-addon.d.ts +34 -0
- package/dist/src/functions/commands/new-addon.js +636 -0
- package/dist/src/functions/commands/new-function.d.ts +10 -0
- package/dist/src/functions/commands/new-function.js +79 -0
- package/dist/src/functions/commands/new-middleware.d.ts +10 -0
- package/dist/src/functions/commands/new-middleware.js +48 -0
- package/dist/src/functions/commands/new-permission.d.ts +10 -0
- package/dist/src/functions/commands/new-permission.js +45 -0
- package/dist/src/functions/commands/new-wiring.d.ts +10 -0
- package/dist/src/functions/commands/new-wiring.js +102 -0
- package/dist/src/functions/commands/pikku-command-bootstrap.js +11 -40
- package/dist/src/functions/commands/versions-check.js +85 -3
- package/dist/src/functions/commands/versions-update.js +1 -1
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.js +0 -4
- package/dist/src/functions/wirings/ai-agent/pikku-command-ai-agent-types.js +3 -2
- package/dist/src/functions/wirings/ai-agent/pikku-command-ai-agent.js +5 -5
- package/dist/src/functions/wirings/ai-agent/serialize-agent-map.d.ts +1 -1
- package/dist/src/functions/wirings/ai-agent/serialize-ai-agent-types.d.ts +1 -1
- package/dist/src/functions/wirings/ai-agent/serialize-ai-agent-types.js +48 -3
- package/dist/src/functions/wirings/ai-agent/serialize-public-agent.js +30 -52
- package/dist/src/functions/wirings/channels/pikku-channels.js +1 -1
- package/dist/src/functions/wirings/channels/pikku-command-channel-types.js +2 -2
- package/dist/src/functions/wirings/channels/pikku-command-channels.js +1 -1
- package/dist/src/functions/wirings/channels/serialize-typed-channel-map.d.ts +4 -4
- package/dist/src/functions/wirings/cli/pikku-command-cli.js +1 -1
- package/dist/src/functions/wirings/cli/serialize-channel-cli-client.d.ts +2 -2
- package/dist/src/functions/wirings/cli/serialize-channel-cli.d.ts +1 -1
- package/dist/src/functions/wirings/cli/serialize-local-cli-bootstrap.d.ts +1 -1
- package/dist/src/functions/wirings/console/pikku-command-console-functions.js +2 -1
- package/dist/src/functions/wirings/console/pikku-command-nodes-meta.js +1 -1
- package/dist/src/functions/wirings/console/serialize-console-functions.d.ts +1 -1
- package/dist/src/functions/wirings/console/serialize-console-functions.js +18 -157
- package/dist/src/functions/wirings/functions/pikku-command-addon-types.d.ts +1 -0
- package/dist/src/functions/wirings/functions/pikku-command-addon-types.js +33 -0
- package/dist/src/functions/wirings/functions/pikku-command-function-types-split.js +1 -1
- package/dist/src/functions/wirings/functions/pikku-command-function-types.js +4 -4
- package/dist/src/functions/wirings/functions/pikku-command-functions.js +8 -14
- package/dist/src/functions/wirings/functions/schemas.js +1 -1
- package/dist/src/functions/wirings/functions/serialize-addon-types.d.ts +1 -0
- package/dist/src/functions/wirings/functions/{serialize-external-types.js → serialize-addon-types.js} +16 -15
- package/dist/src/functions/wirings/functions/serialize-function-imports.d.ts +3 -3
- package/dist/src/functions/wirings/functions/serialize-function-imports.js +3 -3
- package/dist/src/functions/wirings/functions/serialize-function-types.js +28 -14
- package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.d.ts +1 -1
- package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.js +2 -2
- package/dist/src/functions/wirings/http/pikku-command-http-routes.js +1 -1
- package/dist/src/functions/wirings/http/pikku-http-routes.js +1 -1
- package/dist/src/functions/wirings/http/serialize-typed-http-map.d.ts +3 -3
- package/dist/src/functions/wirings/mcp/pikku-command-mcp.js +1 -1
- package/dist/src/functions/wirings/package/pikku-command-package.js +5 -5
- package/dist/src/functions/wirings/package/serialize-package.js +2 -2
- package/dist/src/functions/wirings/permissions/pikku-command-permissions.js +0 -5
- package/dist/src/functions/wirings/queue/serialize-queue-map.d.ts +2 -2
- package/dist/src/functions/wirings/queue/serialize-queue-meta.d.ts +1 -1
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-map.js +6 -6
- package/dist/src/functions/wirings/rpc/pikku-command-rpc.js +2 -4
- package/dist/src/functions/wirings/rpc/serialize-public-rpc.js +25 -16
- package/dist/src/functions/wirings/rpc/serialize-rpc-wrapper.js +43 -7
- package/dist/src/functions/wirings/rpc/serialize-typed-rpc-map.d.ts +8 -3
- package/dist/src/functions/wirings/rpc/serialize-typed-rpc-map.js +41 -31
- package/dist/src/functions/wirings/scheduler/serialize-scheduler-meta.d.ts +1 -1
- package/dist/src/functions/wirings/secrets/serialize-secrets-types.d.ts +2 -2
- package/dist/src/functions/wirings/triggers/serialize-trigger-meta.d.ts +1 -1
- package/dist/src/functions/wirings/triggers/serialize-trigger-meta.js +2 -2
- package/dist/src/functions/wirings/variables/serialize-variables-types.d.ts +2 -2
- package/dist/src/functions/wirings/workflow/pikku-command-workflow.js +2 -2
- package/dist/src/functions/wirings/workflow/serialize-workflow-map.d.ts +2 -2
- package/dist/src/functions/wirings/workflow/serialize-workflow-meta.js +2 -2
- package/dist/src/services/cli-logger-forwarder.service.d.ts +4 -3
- package/dist/src/services/cli-logger.service.d.ts +3 -2
- package/dist/src/services.d.ts +4 -3
- package/dist/src/services.js +2 -3
- package/dist/src/utils/check-required-types.d.ts +1 -1
- package/dist/src/utils/contract-versions.d.ts +1 -1
- package/dist/src/utils/file-writer.d.ts +6 -1
- package/dist/src/utils/file-writer.js +14 -1
- package/dist/src/utils/generate-bootstrap-file.d.ts +2 -2
- package/dist/src/utils/openapi/codegen.d.ts +19 -0
- package/dist/src/utils/openapi/codegen.js +288 -0
- package/dist/src/utils/openapi/naming.d.ts +30 -0
- package/dist/src/utils/openapi/naming.js +167 -0
- package/dist/src/utils/openapi/parse-openapi.d.ts +36 -0
- package/dist/src/utils/openapi/parse-openapi.js +196 -0
- package/dist/src/utils/openapi/zod-codegen.d.ts +53 -0
- package/dist/src/utils/openapi/zod-codegen.js +251 -0
- package/dist/src/utils/pikku-cli-config.d.ts +2 -2
- package/dist/src/utils/pikku-cli-config.js +8 -14
- package/dist/src/utils/pikku-files-and-methods.d.ts +1 -1
- package/dist/src/utils/pikku-files-and-methods.js +1 -1
- package/dist/src/utils/serialize-import-map.d.ts +2 -2
- package/dist/src/utils/serialize-import-map.js +1 -1
- package/dist/src/utils/serialize-meta-ts.js +1 -1
- package/dist/src/utils/serialize-schemas.d.ts +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/console-app/assets/index-C19L3UJu.js +0 -637
- package/dist/src/functions/wirings/functions/pikku-command-external-types.d.ts +0 -1
- package/dist/src/functions/wirings/functions/pikku-command-external-types.js +0 -33
- package/dist/src/functions/wirings/functions/serialize-external-types.d.ts +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
|
|
2
2
|
export const serializeFunctionImports = (outputPath, functionsMap, functionsMeta, packageMappings = {},
|
|
3
|
-
/** Package name for
|
|
4
|
-
|
|
3
|
+
/** Package name for addon packages (e.g., '@pikku/templates-function-addon') */
|
|
4
|
+
addonName) => {
|
|
5
5
|
const serializedImports = [
|
|
6
6
|
`/* Import and register functions used by RPCs */`,
|
|
7
7
|
`import { addFunction } from '@pikku/core'`,
|
|
@@ -10,7 +10,7 @@ externalPackageName) => {
|
|
|
10
10
|
// Sort by function name for consistent output
|
|
11
11
|
const sortedEntries = Array.from(functionsMap.entries()).sort((a, b) => a[0].localeCompare(b[0]));
|
|
12
12
|
// Third argument to addFunction is the package name (null for main package)
|
|
13
|
-
const packageArg =
|
|
13
|
+
const packageArg = addonName ? `, '${addonName}'` : '';
|
|
14
14
|
const usedAliases = new Set();
|
|
15
15
|
for (const [name, { path, exportedName }] of sortedEntries) {
|
|
16
16
|
const filePath = getFileImportRelativePath(outputPath, path, packageMappings);
|
|
@@ -12,7 +12,8 @@ export const serializeFunctionTypes = (userSessionTypeImport, userSessionTypeNam
|
|
|
12
12
|
* Core function, middleware, and permission types for all wirings
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { CorePikkuFunctionConfig, CorePikkuAuth, CorePikkuAuthConfig, CorePikkuPermission, CorePikkuMiddleware, CorePermissionGroup, addMiddleware as addMiddlewareCore, addPermission as addPermissionCore, PikkuWire, PickRequired
|
|
15
|
+
import { CorePikkuFunctionConfig, CorePikkuAuth, CorePikkuAuthConfig, CorePikkuPermission, CorePikkuMiddleware, CorePermissionGroup, addMiddleware as addMiddlewareCore, addPermission as addPermissionCore, PikkuWire, PickRequired } from '@pikku/core'
|
|
16
|
+
import { pikkuState as __pikkuState, CreateWireServices } from '@pikku/core/internal'
|
|
16
17
|
import { pikkuAuth as pikkuAuthCore } from '@pikku/core'
|
|
17
18
|
import type { NodeType } from '@pikku/core/node'
|
|
18
19
|
import type { StandardSchemaV1 } from '@standard-schema/spec'
|
|
@@ -480,27 +481,27 @@ export const pikkuVoidFunc = (
|
|
|
480
481
|
}
|
|
481
482
|
|
|
482
483
|
/**
|
|
483
|
-
* Creates a wrapper function for
|
|
484
|
-
* This allows you to wire
|
|
484
|
+
* Creates a wrapper function for addon package functions that are exposed via RPC.
|
|
485
|
+
* This allows you to wire addon functions to any wiring type (HTTP, queue, etc.)
|
|
485
486
|
* without type compatibility issues.
|
|
486
487
|
*
|
|
487
488
|
* @template Name - The RPC method name (must be a key in FlattenedRPCMap)
|
|
488
489
|
* @param rpcName - The name of the RPC method to invoke
|
|
489
|
-
* @returns A Pikku function that proxies calls to the
|
|
490
|
+
* @returns A Pikku function that proxies calls to the addon RPC method
|
|
490
491
|
*
|
|
491
492
|
* @example
|
|
492
493
|
* \`\`\`typescript
|
|
493
|
-
* // Wire an
|
|
494
|
+
* // Wire an addon function via HTTP
|
|
494
495
|
* wireHTTP({
|
|
495
496
|
* auth: false,
|
|
496
497
|
* method: 'get',
|
|
497
|
-
* route: '/
|
|
498
|
-
* func:
|
|
499
|
-
* tags: ['
|
|
498
|
+
* route: '/addon/hello',
|
|
499
|
+
* func: addon('ext:hello'),
|
|
500
|
+
* tags: ['addon'],
|
|
500
501
|
* })
|
|
501
502
|
* \`\`\`
|
|
502
503
|
*/
|
|
503
|
-
export const
|
|
504
|
+
export const addon = <Name extends keyof FlattenedRPCMap>(
|
|
504
505
|
rpcName: Name
|
|
505
506
|
): PikkuFunctionConfig<
|
|
506
507
|
FlattenedRPCMap[Name]['input'],
|
|
@@ -508,9 +509,9 @@ export const external = <Name extends keyof FlattenedRPCMap>(
|
|
|
508
509
|
'session' | 'rpc'
|
|
509
510
|
> => {
|
|
510
511
|
return {
|
|
511
|
-
func:
|
|
512
|
+
func: async (_services: any, data: FlattenedRPCMap[Name]['input'], { rpc }: any) => {
|
|
512
513
|
return rpc.invoke(rpcName, data)
|
|
513
|
-
}
|
|
514
|
+
}
|
|
514
515
|
} as PikkuFunctionConfig<
|
|
515
516
|
FlattenedRPCMap[Name]['input'],
|
|
516
517
|
FlattenedRPCMap[Name]['output'],
|
|
@@ -559,8 +560,14 @@ export const pikkuConfig = (
|
|
|
559
560
|
* \`\`\`
|
|
560
561
|
*/
|
|
561
562
|
export const pikkuServices = (
|
|
562
|
-
func: (config: Config, existingServices
|
|
563
|
-
) =>
|
|
563
|
+
func: (config: Config, existingServices: Partial<SingletonServices>) => Promise<RequiredSingletonServices>
|
|
564
|
+
) => {
|
|
565
|
+
return async (config: Config, existingServices: Partial<SingletonServices> = {}) => {
|
|
566
|
+
const services = await func(config, existingServices)
|
|
567
|
+
__pikkuState(null, 'package', 'singletonServices', services as any)
|
|
568
|
+
return services
|
|
569
|
+
}
|
|
570
|
+
}
|
|
564
571
|
|
|
565
572
|
/**
|
|
566
573
|
* Creates a Pikku wire services factory.
|
|
@@ -584,7 +591,11 @@ export const pikkuWireServices = (
|
|
|
584
591
|
services: SingletonServices,
|
|
585
592
|
wire: any
|
|
586
593
|
) => Promise<RequiredWireServices>
|
|
587
|
-
): CreateWireServices =>
|
|
594
|
+
): CreateWireServices => {
|
|
595
|
+
const factories = __pikkuState(null, 'package', 'factories')
|
|
596
|
+
__pikkuState(null, 'package', 'factories', { ...factories, createWireServices: func as any })
|
|
597
|
+
return func as unknown as CreateWireServices
|
|
598
|
+
}
|
|
588
599
|
|
|
589
600
|
/**
|
|
590
601
|
* Adds global middleware for a specific tag.
|
|
@@ -639,5 +650,8 @@ export const addMiddleware = (tag: string, middleware: PikkuMiddleware[]) => {
|
|
|
639
650
|
export const addPermission = <In = unknown>(tag: string, permissions: CorePermissionGroup<PikkuPermission<In>> | PikkuPermission<In>[]) => {
|
|
640
651
|
addPermissionCore(tag, permissions as any, ${packageNameValue})
|
|
641
652
|
}
|
|
653
|
+
|
|
654
|
+
export { wireAddon } from '@pikku/core'
|
|
655
|
+
export type { WireAddonConfig } from '@pikku/core'
|
|
642
656
|
`;
|
|
643
657
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Generates the main pikku-types.gen.ts file as a re-export hub
|
|
3
3
|
*/
|
|
4
|
-
export declare const serializePikkuTypesHub: (functionTypesImportPath: string, httpTypesImportPath: string | null, channelTypesImportPath: string | null, triggerTypesImportPath: string | null, schedulerTypesImportPath: string | null, queueTypesImportPath: string | null, mcpTypesImportPath: string | null, cliTypesImportPath: string | null, nodeTypesImportPath: string | null, secretTypesImportPath: string | null,
|
|
4
|
+
export declare const serializePikkuTypesHub: (functionTypesImportPath: string, httpTypesImportPath: string | null, channelTypesImportPath: string | null, triggerTypesImportPath: string | null, schedulerTypesImportPath: string | null, queueTypesImportPath: string | null, mcpTypesImportPath: string | null, cliTypesImportPath: string | null, nodeTypesImportPath: string | null, secretTypesImportPath: string | null, addonTypesImportPath: string | null) => string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Generates the main pikku-types.gen.ts file as a re-export hub
|
|
3
3
|
*/
|
|
4
|
-
export const serializePikkuTypesHub = (functionTypesImportPath, httpTypesImportPath, channelTypesImportPath, triggerTypesImportPath, schedulerTypesImportPath, queueTypesImportPath, mcpTypesImportPath, cliTypesImportPath, nodeTypesImportPath, secretTypesImportPath,
|
|
4
|
+
export const serializePikkuTypesHub = (functionTypesImportPath, httpTypesImportPath, channelTypesImportPath, triggerTypesImportPath, schedulerTypesImportPath, queueTypesImportPath, mcpTypesImportPath, cliTypesImportPath, nodeTypesImportPath, secretTypesImportPath, addonTypesImportPath) => {
|
|
5
5
|
const exports = [
|
|
6
6
|
{
|
|
7
7
|
comment: 'Core function, middleware, and permission types',
|
|
@@ -16,7 +16,7 @@ export const serializePikkuTypesHub = (functionTypesImportPath, httpTypesImportP
|
|
|
16
16
|
{ comment: 'CLI wiring types', path: cliTypesImportPath },
|
|
17
17
|
{ comment: 'Node wiring types', path: nodeTypesImportPath },
|
|
18
18
|
{ comment: 'Secret definition types', path: secretTypesImportPath },
|
|
19
|
-
{ comment: '
|
|
19
|
+
{ comment: 'Addon types', path: addonTypesImportPath },
|
|
20
20
|
];
|
|
21
21
|
const exportStatements = exports
|
|
22
22
|
.filter((e) => e.path)
|
|
@@ -24,7 +24,7 @@ export const pikkuHTTP = pikkuSessionlessFunc({
|
|
|
24
24
|
const importStatement = supportsImportAttributes
|
|
25
25
|
? `import metaData from '${jsonImportPath}' with { type: 'json' }`
|
|
26
26
|
: `import metaData from '${jsonImportPath}'`;
|
|
27
|
-
await writeFileInDir(logger, httpWiringMetaFile, `import { pikkuState } from '@pikku/core'\nimport type { HTTPWiringsMeta } from '@pikku/core/http'\n${importStatement}\npikkuState(null, 'http', 'meta', metaData as HTTPWiringsMeta)`);
|
|
27
|
+
await writeFileInDir(logger, httpWiringMetaFile, `import { pikkuState } from '@pikku/core/internal'\nimport type { HTTPWiringsMeta } from '@pikku/core/http'\n${importStatement}\npikkuState(null, 'http', 'meta', metaData as HTTPWiringsMeta)`);
|
|
28
28
|
return true;
|
|
29
29
|
},
|
|
30
30
|
middleware: [
|
|
@@ -15,7 +15,7 @@ export const pikkuHTTP = pikkuSessionlessFunc({
|
|
|
15
15
|
const importStatement = supportsImportAttributes
|
|
16
16
|
? `import metaData from '${jsonImportPath}' with { type: 'json' }`
|
|
17
17
|
: `import metaData from '${jsonImportPath}'`;
|
|
18
|
-
await writeFileInDir(logger, httpWiringMetaFile, `import { pikkuState } from '@pikku/core'\nimport type { HTTPWiringsMeta } from '@pikku/core/http'\n${importStatement}\npikkuState(null, 'http', 'meta', metaData as HTTPWiringsMeta)`);
|
|
18
|
+
await writeFileInDir(logger, httpWiringMetaFile, `import { pikkuState } from '@pikku/core/internal'\nimport type { HTTPWiringsMeta } from '@pikku/core/http'\n${importStatement}\npikkuState(null, 'http', 'meta', metaData as HTTPWiringsMeta)`);
|
|
19
19
|
return true;
|
|
20
20
|
},
|
|
21
21
|
middleware: [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HTTPWiringsMeta } from '@pikku/core/http';
|
|
2
|
-
import { MetaInputTypes, TypesMap } from '@pikku/inspector';
|
|
3
|
-
import { Logger } from '@pikku/core/services';
|
|
1
|
+
import type { HTTPWiringsMeta } from '@pikku/core/http';
|
|
2
|
+
import type { MetaInputTypes, TypesMap } from '@pikku/inspector';
|
|
3
|
+
import type { Logger } from '@pikku/core/services';
|
|
4
4
|
export declare const serializeTypedHTTPWiringsMap: (logger: Logger, relativeToPath: string, packageMappings: Record<string, string>, typesMap: TypesMap, wiringsMeta: HTTPWiringsMeta, metaTypes: MetaInputTypes, resolvedIOTypes: Record<string, {
|
|
5
5
|
inputType: string;
|
|
6
6
|
outputType: string;
|
|
@@ -81,7 +81,7 @@ export const pikkuMCP = pikkuSessionlessFunc({
|
|
|
81
81
|
const importStatement = supportsImportAttributes
|
|
82
82
|
? `import metaData from '${jsonImportPath}' with { type: 'json' }`
|
|
83
83
|
: `import metaData from '${jsonImportPath}'`;
|
|
84
|
-
await writeFileInDir(logger, mcpWiringsMetaFile, `import { pikkuState } from '@pikku/core'
|
|
84
|
+
await writeFileInDir(logger, mcpWiringsMetaFile, `import { pikkuState } from '@pikku/core/internal'
|
|
85
85
|
import type { MCPResourceMeta, MCPToolMeta, MCPPromptMeta } from '@pikku/core/mcp'
|
|
86
86
|
${importStatement}
|
|
87
87
|
pikkuState(null, 'mcp', 'resourcesMeta', metaData.resourcesMeta as MCPResourceMeta)
|
|
@@ -4,11 +4,11 @@ import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-
|
|
|
4
4
|
import { serializePackageFactories } from './serialize-package.js';
|
|
5
5
|
export const pikkuPackage = pikkuSessionlessFunc({
|
|
6
6
|
func: async ({ logger, config, getInspectorState }) => {
|
|
7
|
-
const {
|
|
8
|
-
// Only generate for
|
|
9
|
-
if (!
|
|
7
|
+
const { addonName, packageMappings, packageFile } = config;
|
|
8
|
+
// Only generate for addon packages
|
|
9
|
+
if (!addonName) {
|
|
10
10
|
logger.debug({
|
|
11
|
-
message: 'Skipping package factories - not an
|
|
11
|
+
message: 'Skipping package factories - not an addon package (addonName not set)',
|
|
12
12
|
type: 'skip',
|
|
13
13
|
});
|
|
14
14
|
return false;
|
|
@@ -23,7 +23,7 @@ export const pikkuPackage = pikkuSessionlessFunc({
|
|
|
23
23
|
const state = await getInspectorState();
|
|
24
24
|
const { filesAndMethods } = state;
|
|
25
25
|
const { pikkuConfigFactory, singletonServicesFactory, wireServicesFactory, } = filesAndMethods;
|
|
26
|
-
const content = serializePackageFactories(packageFile,
|
|
26
|
+
const content = serializePackageFactories(packageFile, addonName, pikkuConfigFactory
|
|
27
27
|
? {
|
|
28
28
|
file: pikkuConfigFactory.file,
|
|
29
29
|
variable: pikkuConfigFactory.variable,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
|
|
2
2
|
export const serializePackageFactories = (outputPath, packageName, configFactory, singletonServicesFactory, wireServicesFactory, packageMappings = {}) => {
|
|
3
3
|
const imports = [
|
|
4
|
-
`import {
|
|
4
|
+
`import { pikkuState } from '@pikku/core/internal'`,
|
|
5
5
|
];
|
|
6
6
|
const factoryEntries = [];
|
|
7
7
|
if (configFactory) {
|
|
@@ -25,7 +25,7 @@ export const serializePackageFactories = (outputPath, packageName, configFactory
|
|
|
25
25
|
}
|
|
26
26
|
return `${imports.join('\n')}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
pikkuState('${packageName}', 'package', 'factories', {
|
|
29
29
|
${factoryEntries.join('\n')}
|
|
30
30
|
})
|
|
31
31
|
`;
|
|
@@ -14,11 +14,6 @@ export const pikkuPermissions = pikkuSessionlessFunc({
|
|
|
14
14
|
if (hasHTTPGroups || hasTagGroups || hasIndividual) {
|
|
15
15
|
const metaData = state.permissionsGroupsMeta;
|
|
16
16
|
await writeFileInDir(logger, config.permissionsGroupsMetaJsonFile, JSON.stringify(metaData, null, 2));
|
|
17
|
-
filesGenerated = true;
|
|
18
|
-
}
|
|
19
|
-
const hasHTTPFactories = Array.from(state.http.routePermissions.values()).some((meta) => meta.exportName && meta.isFactory);
|
|
20
|
-
const hasTagFactories = Array.from(state.permissions.tagPermissions.values()).some((meta) => meta.exportName && meta.isFactory);
|
|
21
|
-
if (hasHTTPFactories || hasTagFactories) {
|
|
22
17
|
await writeFileInDir(logger, permissionsFile, serializePermissionsImports(permissionsFile, permissions, state.http, packageMappings));
|
|
23
18
|
filesGenerated = true;
|
|
24
19
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { QueueWorkersMeta } from '@pikku/core/queue';
|
|
2
|
-
import { TypesMap } from '@pikku/inspector';
|
|
3
|
-
import { Logger } from '@pikku/core/services';
|
|
2
|
+
import type { TypesMap } from '@pikku/inspector';
|
|
3
|
+
import type { Logger } from '@pikku/core/services';
|
|
4
4
|
export declare const serializeQueueMap: (logger: Logger, relativeToPath: string, packageMappings: Record<string, string>, typesMap: TypesMap, queueWorkersMeta: QueueWorkersMeta, resolvedIOTypes: Record<string, {
|
|
5
5
|
inputType: string;
|
|
6
6
|
outputType: string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { QueueWorkersMeta } from '@pikku/core/queue';
|
|
1
|
+
import type { QueueWorkersMeta } from '@pikku/core/queue';
|
|
2
2
|
export declare const serializeQueueMeta: (queueWorkersMeta: QueueWorkersMeta) => QueueWorkersMeta;
|
|
3
3
|
export declare const serializeQueueMetaTS: (jsonImportPath: string, supportsImportAttributes: boolean) => string;
|
|
@@ -6,10 +6,10 @@ import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
|
|
|
6
6
|
export const pikkuRPCInternalMap = pikkuSessionlessFunc({
|
|
7
7
|
func: async ({ logger, config, getInspectorState }) => {
|
|
8
8
|
const { functions, rpc, resolvedIOTypes } = await getInspectorState();
|
|
9
|
-
const { rpcInternalMapDeclarationFile, packageMappings,
|
|
9
|
+
const { rpcInternalMapDeclarationFile, packageMappings, workflowMapDeclarationFile, agentMapDeclarationFile, } = config;
|
|
10
10
|
const workflowMapPath = getFileImportRelativePath(rpcInternalMapDeclarationFile, workflowMapDeclarationFile, packageMappings);
|
|
11
11
|
const agentMapPath = getFileImportRelativePath(rpcInternalMapDeclarationFile, agentMapDeclarationFile, packageMappings);
|
|
12
|
-
const content = serializeTypedRPCMap(logger, rpcInternalMapDeclarationFile, packageMappings, functions.typesMap, rpc.internalMeta, resolvedIOTypes,
|
|
12
|
+
const content = serializeTypedRPCMap(logger, rpcInternalMapDeclarationFile, packageMappings, functions.typesMap, rpc.internalMeta, resolvedIOTypes, rpc.wireAddonDeclarations, workflowMapPath, agentMapPath);
|
|
13
13
|
await writeFileInDir(logger, rpcInternalMapDeclarationFile, content);
|
|
14
14
|
},
|
|
15
15
|
middleware: [
|
|
@@ -22,16 +22,16 @@ export const pikkuRPCInternalMap = pikkuSessionlessFunc({
|
|
|
22
22
|
export const pikkuRPCExposedMap = pikkuSessionlessFunc({
|
|
23
23
|
func: async ({ logger, config, getInspectorState }) => {
|
|
24
24
|
const { functions, rpc, resolvedIOTypes } = await getInspectorState();
|
|
25
|
-
const { rpcMapDeclarationFile, packageMappings,
|
|
25
|
+
const { rpcMapDeclarationFile, packageMappings, workflowMapDeclarationFile, agentMapDeclarationFile, } = config;
|
|
26
26
|
const workflowMapPath = getFileImportRelativePath(rpcMapDeclarationFile, workflowMapDeclarationFile, packageMappings);
|
|
27
27
|
const agentMapPath = getFileImportRelativePath(rpcMapDeclarationFile, agentMapDeclarationFile, packageMappings);
|
|
28
|
-
const content = serializeTypedRPCMap(logger, rpcMapDeclarationFile, packageMappings, functions.typesMap, rpc.exposedMeta, resolvedIOTypes,
|
|
28
|
+
const content = serializeTypedRPCMap(logger, rpcMapDeclarationFile, packageMappings, functions.typesMap, rpc.exposedMeta, resolvedIOTypes, rpc.wireAddonDeclarations, workflowMapPath, agentMapPath);
|
|
29
29
|
await writeFileInDir(logger, rpcMapDeclarationFile, content);
|
|
30
30
|
},
|
|
31
31
|
middleware: [
|
|
32
32
|
logCommandInfoAndTime({
|
|
33
|
-
commandStart: 'Creating RPC
|
|
34
|
-
commandEnd: 'Created RPC
|
|
33
|
+
commandStart: 'Creating RPC addon map',
|
|
34
|
+
commandEnd: 'Created RPC addon map',
|
|
35
35
|
}),
|
|
36
36
|
],
|
|
37
37
|
});
|
|
@@ -13,10 +13,8 @@ export const pikkuRPC = pikkuSessionlessFunc({
|
|
|
13
13
|
const importStatement = supportsImportAttributes
|
|
14
14
|
? `import metaData from '${jsonImportPath}' with { type: 'json' }`
|
|
15
15
|
: `import metaData from '${jsonImportPath}'`;
|
|
16
|
-
const packageNameArg = config.
|
|
17
|
-
|
|
18
|
-
: 'null';
|
|
19
|
-
await writeFileInDir(logger, rpcInternalWiringMetaFile, `import { pikkuState } from '@pikku/core'\n${importStatement}\npikkuState(${packageNameArg}, 'rpc', 'meta', metaData as Record<string, string>)`);
|
|
16
|
+
const packageNameArg = config.addonName ? `'${config.addonName}'` : 'null';
|
|
17
|
+
await writeFileInDir(logger, rpcInternalWiringMetaFile, `import { pikkuState } from '@pikku/core/internal'\n${importStatement}\npikkuState(${packageNameArg}, 'rpc', 'meta', metaData as Record<string, string>)`);
|
|
20
18
|
return true;
|
|
21
19
|
}
|
|
22
20
|
return false;
|
|
@@ -7,12 +7,8 @@ export const serializePublicRPC = (pathToPikkuTypes, requireAuth = true) => {
|
|
|
7
7
|
* Auto-generated public RPC HTTP endpoint
|
|
8
8
|
* Do not edit manually - regenerate with 'npx pikku'
|
|
9
9
|
*/
|
|
10
|
-
import { pikkuSessionlessFunc,
|
|
10
|
+
import { pikkuSessionlessFunc, defineHTTPRoutes, wireHTTPRoutes } from '${pathToPikkuTypes}'
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* Public RPC endpoint that invokes any exposed RPC by name
|
|
14
|
-
* This is used for public HTTP access to exposed server functions
|
|
15
|
-
*/
|
|
16
12
|
export const rpcCaller = pikkuSessionlessFunc<
|
|
17
13
|
{ rpcName: string; data?: unknown },
|
|
18
14
|
unknown
|
|
@@ -23,20 +19,33 @@ export const rpcCaller = pikkuSessionlessFunc<
|
|
|
23
19
|
},
|
|
24
20
|
})
|
|
25
21
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
export const workflowCaller = pikkuSessionlessFunc<
|
|
23
|
+
{ workflowName: string; input?: unknown },
|
|
24
|
+
{ runId: string }
|
|
25
|
+
>({
|
|
30
26
|
auth: ${authFlag},
|
|
31
|
-
func:
|
|
32
|
-
})
|
|
27
|
+
func: async (_services, { workflowName, input }, { rpc }) => {
|
|
28
|
+
return await rpc.startWorkflow(workflowName, input || {})
|
|
29
|
+
},
|
|
30
|
+
})
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
route: '/rpc/:rpcName',
|
|
36
|
-
method: 'post',
|
|
37
|
-
tags: ['pikku:public'],
|
|
32
|
+
export const rpcRoutes = defineHTTPRoutes({
|
|
38
33
|
auth: ${authFlag},
|
|
39
|
-
|
|
34
|
+
tags: ['pikku:public'],
|
|
35
|
+
routes: {
|
|
36
|
+
rpc: {
|
|
37
|
+
route: '/rpc/:rpcName',
|
|
38
|
+
method: 'post',
|
|
39
|
+
func: rpcCaller,
|
|
40
|
+
},
|
|
41
|
+
workflow: {
|
|
42
|
+
route: '/rpc/workflow/:workflowName',
|
|
43
|
+
method: 'post',
|
|
44
|
+
func: workflowCaller,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
40
47
|
})
|
|
48
|
+
|
|
49
|
+
wireHTTPRoutes({ routes: { rpc: rpcRoutes } })
|
|
41
50
|
`;
|
|
42
51
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const serializeRPCWrapper = (rpcMapPath) => {
|
|
2
2
|
return `
|
|
3
3
|
import { PikkuFetch } from "./pikku-fetch.gen.js"
|
|
4
|
-
import type { RPCInvoke,
|
|
4
|
+
import type { RPCInvoke, TypedAgentRun, TypedStartWorkflow } from '${rpcMapPath}'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* PikkuRPC provides a type-safe client for making Remote Procedure Calls (RPC)
|
|
@@ -63,14 +63,50 @@ export class PikkuRPC {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
66
|
+
* Starts a workflow by name with the given input.
|
|
67
|
+
* Posts to \\\`/rpc/workflow/:workflowName\\\`.
|
|
67
68
|
*
|
|
68
|
-
* @param
|
|
69
|
-
* @param input - The
|
|
70
|
-
* @returns A promise that resolves with the
|
|
69
|
+
* @param workflowName - The registered workflow name
|
|
70
|
+
* @param input - The workflow input data
|
|
71
|
+
* @returns A promise that resolves with the new run ID
|
|
71
72
|
*/
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
startWorkflow: TypedStartWorkflow = async (workflowName, input) => {
|
|
74
|
+
return await this.pikkuFetch.post(\`/rpc/workflow/\${String(workflowName)}\` as never, { workflowName: String(workflowName), input }) as any
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Agent namespace — methods for running, streaming, and approving AI agents.
|
|
79
|
+
* All methods post to \\\`/rpc/agent/:agentName/*\\\`.
|
|
80
|
+
*/
|
|
81
|
+
agent = {
|
|
82
|
+
/**
|
|
83
|
+
* Runs an agent to completion and returns the result.
|
|
84
|
+
*
|
|
85
|
+
* @param agentName - The registered agent name
|
|
86
|
+
* @param input - The agent input (message, threadId, resourceId)
|
|
87
|
+
* @returns A promise with runId, result, and token usage
|
|
88
|
+
*/
|
|
89
|
+
run: (async (agentName, input) => {
|
|
90
|
+
return await this.pikkuFetch.post(\`/rpc/agent/\${String(agentName)}\` as never, input) as any
|
|
91
|
+
}) as TypedAgentRun,
|
|
92
|
+
/**
|
|
93
|
+
* Streams agent responses via SSE. Used for real-time chat interfaces.
|
|
94
|
+
*
|
|
95
|
+
* @param agentName - The registered agent name
|
|
96
|
+
* @param input - The agent input (message, threadId, resourceId)
|
|
97
|
+
*/
|
|
98
|
+
stream: async (agentName: string, input: Record<string, unknown>) => {
|
|
99
|
+
return await this.pikkuFetch.post(\`/rpc/agent/\${String(agentName)}/stream\` as never, input) as any
|
|
100
|
+
},
|
|
101
|
+
/**
|
|
102
|
+
* Approves or denies pending tool calls for an agent run.
|
|
103
|
+
*
|
|
104
|
+
* @param agentName - The registered agent name
|
|
105
|
+
* @param input - The approval payload (runId, approvals array)
|
|
106
|
+
*/
|
|
107
|
+
approve: async (agentName: string, input: Record<string, unknown>) => {
|
|
108
|
+
return await this.pikkuFetch.post(\`/rpc/agent/\${String(agentName)}/approve\` as never, input) as any
|
|
109
|
+
},
|
|
74
110
|
}
|
|
75
111
|
}
|
|
76
112
|
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { TypesMap
|
|
2
|
-
import { Logger } from '@pikku/core/services';
|
|
1
|
+
import type { TypesMap } from '@pikku/inspector';
|
|
2
|
+
import type { Logger } from '@pikku/core/services';
|
|
3
|
+
type WireAddonDeclarations = Map<string, {
|
|
4
|
+
package: string;
|
|
5
|
+
rpcEndpoint?: string;
|
|
6
|
+
}>;
|
|
3
7
|
export declare const serializeTypedRPCMap: (logger: Logger, relativeToPath: string, packageMappings: Record<string, string>, typesMap: TypesMap, rpcMeta: Record<string, string>, resolvedIOTypes: Record<string, {
|
|
4
8
|
inputType: string;
|
|
5
9
|
outputType: string;
|
|
6
|
-
}>,
|
|
10
|
+
}>, wireAddonDeclarations?: WireAddonDeclarations, workflowMapPath?: string, agentMapPath?: string) => string;
|
|
11
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { serializeImportMap } from '../../../utils/serialize-import-map.js';
|
|
2
|
-
import { generateCustomTypes
|
|
3
|
-
export const serializeTypedRPCMap = (logger, relativeToPath, packageMappings, typesMap, rpcMeta, resolvedIOTypes,
|
|
2
|
+
import { generateCustomTypes } from '@pikku/inspector';
|
|
3
|
+
export const serializeTypedRPCMap = (logger, relativeToPath, packageMappings, typesMap, rpcMeta, resolvedIOTypes, wireAddonDeclarations, workflowMapPath, agentMapPath) => {
|
|
4
4
|
const requiredTypes = new Set();
|
|
5
5
|
const serializedCustomTypes = generateCustomTypes(typesMap, requiredTypes);
|
|
6
6
|
const serializedRPCs = generateRPCs(rpcMeta, resolvedIOTypes, requiredTypes);
|
|
@@ -21,8 +21,8 @@ export const serializeTypedRPCMap = (logger, relativeToPath, packageMappings, ty
|
|
|
21
21
|
.split('\n')
|
|
22
22
|
.filter((line) => !line.startsWith('import '))
|
|
23
23
|
.join('\n');
|
|
24
|
-
const
|
|
25
|
-
const mergedRPCMap = generateMergedRPCMap(
|
|
24
|
+
const addonImports = generateAddonImports(wireAddonDeclarations, relativeToPath);
|
|
25
|
+
const mergedRPCMap = generateMergedRPCMap(wireAddonDeclarations);
|
|
26
26
|
return `/**
|
|
27
27
|
* This provides the structure needed for typescript to be aware of RPCs and their return types
|
|
28
28
|
*/
|
|
@@ -37,7 +37,7 @@ interface RPCHandler<I, O> {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
${serializedRPCs}
|
|
40
|
-
${
|
|
40
|
+
${addonImports}
|
|
41
41
|
${mergedRPCMap}
|
|
42
42
|
|
|
43
43
|
export type RPCInvoke = <Name extends keyof FlattenedRPCMap>(
|
|
@@ -53,8 +53,8 @@ export type RPCRemote = <Name extends keyof FlattenedRPCMap>(
|
|
|
53
53
|
${workflowMapPath ? `import type { WorkflowMap } from '${workflowMapPath}'` : `type WorkflowMap = {}`}
|
|
54
54
|
|
|
55
55
|
${agentMapPath ? `import type { AgentMap } from '${agentMapPath}'` : `type AgentMap = {}`}
|
|
56
|
-
${
|
|
57
|
-
${generateMergedAgentMap(
|
|
56
|
+
${generateAddonAgentImports(wireAddonDeclarations)}
|
|
57
|
+
${generateMergedAgentMap(wireAddonDeclarations)}
|
|
58
58
|
|
|
59
59
|
import type { PikkuRPC } from '@pikku/core/rpc'
|
|
60
60
|
|
|
@@ -64,36 +64,46 @@ interface AIAgentInput {
|
|
|
64
64
|
resourceId: string
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
type TypedStartWorkflow = <Name extends keyof WorkflowMap>(
|
|
67
|
+
export type TypedStartWorkflow = <Name extends keyof WorkflowMap>(
|
|
68
68
|
name: Name,
|
|
69
69
|
input: WorkflowMap[Name]['input'],
|
|
70
70
|
options?: { startNode?: string }
|
|
71
71
|
) => Promise<{ runId: string }>
|
|
72
72
|
|
|
73
|
-
type
|
|
74
|
-
name:
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
type TypedAgentRun = [keyof FlattenedAgentMap] extends [never]
|
|
74
|
+
? (name: string, input: AIAgentInput) => Promise<any>
|
|
75
|
+
: <Name extends keyof FlattenedAgentMap>(
|
|
76
|
+
name: Name,
|
|
77
|
+
input: AIAgentInput
|
|
78
|
+
) => Promise<{ runId: string; result: FlattenedAgentMap[Name]['output']; usage: { inputTokens: number; outputTokens: number } }>
|
|
79
|
+
|
|
80
|
+
type TypedAgentStream = [keyof FlattenedAgentMap] extends [never]
|
|
81
|
+
? (name: string, input: AIAgentInput, options?: { requiresToolApproval?: 'all' | 'explicit' | false }) => Promise<void>
|
|
82
|
+
: <Name extends keyof FlattenedAgentMap>(
|
|
83
|
+
name: Name,
|
|
84
|
+
input: AIAgentInput,
|
|
85
|
+
options?: { requiresToolApproval?: 'all' | 'explicit' | false }
|
|
86
|
+
) => Promise<void>
|
|
77
87
|
|
|
78
|
-
export type TypedPikkuRPC = PikkuRPC<RPCInvoke, RPCRemote, TypedStartWorkflow,
|
|
88
|
+
export type TypedPikkuRPC = PikkuRPC<RPCInvoke, RPCRemote, TypedStartWorkflow, TypedAgentRun, TypedAgentStream>
|
|
79
89
|
`;
|
|
80
90
|
};
|
|
81
|
-
function
|
|
82
|
-
if (!
|
|
91
|
+
function generateAddonImports(wireAddonDeclarations, relativeToPath) {
|
|
92
|
+
if (!wireAddonDeclarations || wireAddonDeclarations.size === 0) {
|
|
83
93
|
return '';
|
|
84
94
|
}
|
|
85
|
-
let imports = '\n//
|
|
86
|
-
for (const [namespace,
|
|
87
|
-
// Import the RPCMap from each
|
|
95
|
+
let imports = '\n// Addon package RPC maps\n';
|
|
96
|
+
for (const [namespace, decl] of wireAddonDeclarations.entries()) {
|
|
97
|
+
// Import the RPCMap from each addon package's internal RPC map
|
|
88
98
|
// Use .js extension - package.json exports will resolve to .d.ts for types
|
|
89
|
-
imports += `import type { RPCMap as ${toPascalCase(namespace)}RPCMap } from '${
|
|
99
|
+
imports += `import type { RPCMap as ${toPascalCase(namespace)}RPCMap } from '${decl.package}/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.js'\n`;
|
|
90
100
|
}
|
|
91
101
|
return imports;
|
|
92
102
|
}
|
|
93
|
-
function generateMergedRPCMap(
|
|
94
|
-
if (!
|
|
103
|
+
function generateMergedRPCMap(wireAddonDeclarations) {
|
|
104
|
+
if (!wireAddonDeclarations || wireAddonDeclarations.size === 0) {
|
|
95
105
|
return `
|
|
96
|
-
// No
|
|
106
|
+
// No addon packages, use RPCMap directly
|
|
97
107
|
export type FlattenedRPCMap = RPCMap
|
|
98
108
|
`;
|
|
99
109
|
}
|
|
@@ -106,7 +116,7 @@ type PrefixKeys<T, Prefix extends string> = {
|
|
|
106
116
|
|
|
107
117
|
// Merge all RPC maps with namespace prefixes
|
|
108
118
|
export type FlattenedRPCMap =
|
|
109
|
-
RPCMap${
|
|
119
|
+
RPCMap${Array.from(wireAddonDeclarations.keys())
|
|
110
120
|
.map((namespace) => ` & PrefixKeys<${toPascalCase(namespace)}RPCMap, '${namespace}'>`)
|
|
111
121
|
.join('')}
|
|
112
122
|
`;
|
|
@@ -118,25 +128,25 @@ function toPascalCase(str) {
|
|
|
118
128
|
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
119
129
|
.join('');
|
|
120
130
|
}
|
|
121
|
-
function
|
|
122
|
-
if (!
|
|
131
|
+
function generateAddonAgentImports(wireAddonDeclarations) {
|
|
132
|
+
if (!wireAddonDeclarations || wireAddonDeclarations.size === 0) {
|
|
123
133
|
return '';
|
|
124
134
|
}
|
|
125
|
-
let imports = '\n//
|
|
126
|
-
for (const [namespace,
|
|
127
|
-
imports += `import type { AgentMap as ${toPascalCase(namespace)}AgentMap } from '${
|
|
135
|
+
let imports = '\n// Addon package Agent maps\n';
|
|
136
|
+
for (const [namespace, decl] of wireAddonDeclarations.entries()) {
|
|
137
|
+
imports += `import type { AgentMap as ${toPascalCase(namespace)}AgentMap } from '${decl.package}/.pikku/agent/pikku-agent-map.gen.d.js'\n`;
|
|
128
138
|
}
|
|
129
139
|
return imports;
|
|
130
140
|
}
|
|
131
|
-
function generateMergedAgentMap(
|
|
132
|
-
if (!
|
|
141
|
+
function generateMergedAgentMap(wireAddonDeclarations) {
|
|
142
|
+
if (!wireAddonDeclarations || wireAddonDeclarations.size === 0) {
|
|
133
143
|
return `
|
|
134
144
|
type FlattenedAgentMap = AgentMap
|
|
135
145
|
`;
|
|
136
146
|
}
|
|
137
147
|
return `
|
|
138
148
|
type FlattenedAgentMap =
|
|
139
|
-
AgentMap${
|
|
149
|
+
AgentMap${Array.from(wireAddonDeclarations.keys())
|
|
140
150
|
.map((namespace) => ` & PrefixKeys<${toPascalCase(namespace)}AgentMap, '${namespace}'>`)
|
|
141
151
|
.join('')}
|
|
142
152
|
`;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ScheduledTasksMeta } from '@pikku/core/scheduler';
|
|
1
|
+
import type { ScheduledTasksMeta } from '@pikku/core/scheduler';
|
|
2
2
|
export declare const serializeSchedulerMeta: (scheduledTasksMeta: ScheduledTasksMeta) => ScheduledTasksMeta;
|
|
3
3
|
export declare const serializeSchedulerMetaTS: (scheduledTasksMeta: ScheduledTasksMeta, jsonImportPath: string, supportsImportAttributes: boolean) => string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SecretDefinitions } from '@pikku/core/secret';
|
|
2
|
-
import { SchemaRef } from '@pikku/inspector';
|
|
1
|
+
import type { SecretDefinitions } from '@pikku/core/secret';
|
|
2
|
+
import type { SchemaRef } from '@pikku/inspector';
|
|
3
3
|
export interface SerializeSecretsOptions {
|
|
4
4
|
definitions: SecretDefinitions;
|
|
5
5
|
schemaLookup: Map<string, SchemaRef>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TriggerMeta, TriggerSourceMeta } from '@pikku/core/trigger';
|
|
1
|
+
import type { TriggerMeta, TriggerSourceMeta } from '@pikku/core/trigger';
|
|
2
2
|
export declare const serializeTriggerMeta: (triggerMeta: TriggerMeta) => TriggerMeta;
|
|
3
3
|
export declare const serializeTriggerMetaTS: (triggerMeta: TriggerMeta, jsonImportPath: string, supportsImportAttributes: boolean) => string;
|
|
4
4
|
export declare const serializeTriggerSourceMeta: (sourceMeta: TriggerSourceMeta) => TriggerSourceMeta;
|