@pikku/cli 0.12.0 → 0.12.2
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-DRJQtv3c.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 +77 -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 +280 -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 +426 -93
- package/dist/.pikku/function/pikku-functions.gen.js +5 -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 +16 -2
- 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 -3
- package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuGatewayOutput.schema.json +1 -0
- 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 +236 -9
- package/dist/src/functions/commands/all.js +13 -8
- package/dist/src/functions/commands/enable.d.ts +4 -0
- package/dist/src/functions/commands/enable.js +39 -0
- 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/fetch/index.js +2 -1
- package/dist/src/functions/runtimes/nextjs/pikku-command-nextjs.js +4 -1
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.js +0 -4
- package/dist/src/functions/runtimes/websocket/pikku-command-websocket-typed.js +2 -1
- 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/pikku-command-public-agent.js +3 -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 +4 -5
- package/dist/src/functions/wirings/console/pikku-command-nodes-meta.js +2 -2
- 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/gateway/pikku-command-gateway.d.ts +1 -0
- package/dist/src/functions/wirings/gateway/pikku-command-gateway.js +22 -0
- 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-json.js +1 -1
- 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/pikku-command-queue-service.js +2 -1
- 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-public-rpc.js +3 -5
- package/dist/src/functions/wirings/rpc/pikku-command-remote-rpc.js +3 -5
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-client.js +2 -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 +5 -12
- 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 +14 -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 +51 -30
- 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 +4 -4
- 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,8 +1,9 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const serializeAddonTypes = (singletonServicesTypeImport, singletonServicesTypeName, configTypeImport, requiredServicesTypeImport, typedSecretServiceImport, typedVariablesServiceImport) => {
|
|
2
2
|
return `/**
|
|
3
|
-
*
|
|
3
|
+
* Addon package types for pikkuAddonConfig and pikkuAddonServices
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import type { CreateConfig } from '@pikku/core'
|
|
6
7
|
${singletonServicesTypeImport}
|
|
7
8
|
${configTypeImport}
|
|
8
9
|
${requiredServicesTypeImport}
|
|
@@ -13,40 +14,40 @@ ${singletonServicesTypeName !== 'SingletonServices' ? `type SingletonServices =
|
|
|
13
14
|
${configTypeImport.includes('Config type not found') ? 'type Config = any' : ''}
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
|
-
* Base services provided to
|
|
17
|
+
* Base services provided to addon package service factories.
|
|
17
18
|
* These are always available from the parent application.
|
|
18
19
|
*/
|
|
19
|
-
export type
|
|
20
|
+
export type AddonBaseServices = {
|
|
20
21
|
logger: SingletonServices['logger']
|
|
21
22
|
variables: TypedVariablesService
|
|
22
23
|
secrets: TypedSecretService
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
|
-
* Creates a Pikku config factory for
|
|
27
|
-
* Unlike pikkuConfig, this receives
|
|
28
|
-
* from the parent application, so
|
|
27
|
+
* Creates a Pikku config factory for addon packages.
|
|
28
|
+
* Unlike pikkuConfig, this receives AddonBaseServices (logger, variables, secrets)
|
|
29
|
+
* from the parent application, so addon packages can read variables/secrets during config creation.
|
|
29
30
|
*/
|
|
30
|
-
export const
|
|
31
|
+
export const pikkuAddonConfig = <ExistingServices extends Omit<Partial<SingletonServices>, 'variables' | 'secrets'> & AddonBaseServices>(
|
|
31
32
|
func: (services: ExistingServices) => Promise<Config>
|
|
32
|
-
) => {
|
|
33
|
-
return async (_variables: any, existingServices?: Partial<SingletonServices>): Promise<Config> => {
|
|
33
|
+
): CreateConfig<Config> => {
|
|
34
|
+
return (async (_variables: any, existingServices?: Partial<SingletonServices>): Promise<Config> => {
|
|
34
35
|
const { secrets, variables, ...rest } = (existingServices ?? {}) as unknown as SingletonServices
|
|
35
36
|
return func({ ...rest, secrets: new TypedSecretService(secrets), variables: new TypedVariablesService(variables) } as ExistingServices)
|
|
36
|
-
}
|
|
37
|
+
}) as unknown as CreateConfig<Config>
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
|
-
* Creates a Pikku singleton services factory for
|
|
41
|
+
* Creates a Pikku singleton services factory for addon packages.
|
|
41
42
|
* Unlike pikkuServices, this expects the parent application to provide
|
|
42
43
|
* logger, variables, and secrets - no fallbacks needed.
|
|
43
44
|
*
|
|
44
|
-
* @param func -
|
|
45
|
+
* @param func - Addon services factory function that receives config and base services
|
|
45
46
|
* @returns The singleton services factory function
|
|
46
47
|
*
|
|
47
48
|
* @example
|
|
48
49
|
* \`\`\`typescript
|
|
49
|
-
* export const createSingletonServices =
|
|
50
|
+
* export const createSingletonServices = pikkuAddonServices(async (
|
|
50
51
|
* config,
|
|
51
52
|
* { secrets }
|
|
52
53
|
* ) => {
|
|
@@ -56,7 +57,7 @@ export const pikkuExternalConfig = <ExistingServices extends Omit<Partial<Single
|
|
|
56
57
|
* })
|
|
57
58
|
* \`\`\`
|
|
58
59
|
*/
|
|
59
|
-
export const
|
|
60
|
+
export const pikkuAddonServices = <T extends Record<string, any>, ExistingServices extends Omit<Partial<SingletonServices>, 'variables' | 'secrets'> & AddonBaseServices>(
|
|
60
61
|
func: (config: Config, services: ExistingServices) => Promise<T>
|
|
61
62
|
) => {
|
|
62
63
|
return async (config: Config, existingServices?: Partial<SingletonServices>): Promise<RequiredSingletonServices> => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FunctionsMeta } from '@pikku/core';
|
|
1
|
+
import type { FunctionsMeta } from '@pikku/core';
|
|
2
2
|
export declare const serializeFunctionImports: (outputPath: string, functionsMap: Map<string, {
|
|
3
3
|
path: string;
|
|
4
4
|
exportedName: string;
|
|
5
5
|
}>, functionsMeta: FunctionsMeta, packageMappings?: Record<string, string>,
|
|
6
|
-
/** Package name for
|
|
7
|
-
|
|
6
|
+
/** Package name for addon packages (e.g., '@pikku/templates-function-addon') */
|
|
7
|
+
addonName?: string) => string;
|
|
@@ -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)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const pikkuGateway: import("#pikku").PikkuFunctionConfig<void, boolean | undefined, "session" | "rpc", import("#pikku").PikkuFunctionSessionless<void, boolean | undefined, "session" | "rpc", import("#pikku").Services> | import("#pikku").PikkuFunction<void, boolean | undefined, "session" | "rpc", import("#pikku").Services>, undefined, undefined>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { pikkuSessionlessFunc } from '#pikku';
|
|
2
|
+
import { serializeFileImports } from '../../../utils/file-imports-serializer.js';
|
|
3
|
+
import { writeFileInDir } from '../../../utils/file-writer.js';
|
|
4
|
+
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js';
|
|
5
|
+
export const pikkuGateway = pikkuSessionlessFunc({
|
|
6
|
+
func: async ({ logger, config, getInspectorState }) => {
|
|
7
|
+
const visitState = await getInspectorState();
|
|
8
|
+
const { gatewaysWiringFile, packageMappings } = config;
|
|
9
|
+
const { gateways } = visitState;
|
|
10
|
+
if (Object.keys(gateways.meta).length === 0) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
await writeFileInDir(logger, gatewaysWiringFile, serializeFileImports('wireGateway', gatewaysWiringFile, gateways.files, packageMappings));
|
|
14
|
+
return true;
|
|
15
|
+
},
|
|
16
|
+
middleware: [
|
|
17
|
+
logCommandInfoAndTime({
|
|
18
|
+
commandStart: 'Finding gateways',
|
|
19
|
+
commandEnd: 'Found gateways',
|
|
20
|
+
}),
|
|
21
|
+
],
|
|
22
|
+
});
|
|
@@ -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;
|
|
@@ -5,7 +5,7 @@ import { serializeMCPJson } from '@pikku/inspector';
|
|
|
5
5
|
export const pikkuMCPJSON = pikkuSessionlessFunc({
|
|
6
6
|
func: async ({ logger, config, getInspectorState }) => {
|
|
7
7
|
const state = await getInspectorState();
|
|
8
|
-
const
|
|
8
|
+
const mcpJsonFile = config.clientFiles?.mcpJsonFile;
|
|
9
9
|
if (mcpJsonFile) {
|
|
10
10
|
const mcpJson = serializeMCPJson(logger, state);
|
|
11
11
|
await writeFileInDir(logger, mcpJsonFile, mcpJson, {
|
|
@@ -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
|
}
|
|
@@ -5,7 +5,8 @@ import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-
|
|
|
5
5
|
import { serializeQueueWrapper } from './serialize-queue-wrapper.js';
|
|
6
6
|
export const pikkuQueueService = pikkuSessionlessFunc({
|
|
7
7
|
func: async ({ logger, config }) => {
|
|
8
|
-
const
|
|
8
|
+
const queueWiringsFile = config.clientFiles?.queueWiringsFile;
|
|
9
|
+
const { queueMapDeclarationFile, packageMappings } = config;
|
|
9
10
|
// If queueWiringsFile is not set, clean up any existing file and return
|
|
10
11
|
if (!queueWiringsFile) {
|
|
11
12
|
logger.debug({
|
|
@@ -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;
|
|
@@ -3,13 +3,11 @@ import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
|
|
|
3
3
|
import { writeFileInDir } from '../../../utils/file-writer.js';
|
|
4
4
|
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js';
|
|
5
5
|
import { serializePublicRPC } from './serialize-public-rpc.js';
|
|
6
|
-
import { join } from 'path';
|
|
7
6
|
export const pikkuPublicRPC = pikkuSessionlessFunc({
|
|
8
7
|
func: async ({ logger, config }) => {
|
|
9
|
-
if (config.rpc
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
await writeFileInDir(logger, publicRpcPath, serializePublicRPC(pathToPikkuTypes, config.rpc.publicRpcRequireAuth ?? true));
|
|
8
|
+
if (config.scaffold?.rpc) {
|
|
9
|
+
const pathToPikkuTypes = getFileImportRelativePath(config.publicRpcFile, config.typesDeclarationFile, config.packageMappings);
|
|
10
|
+
await writeFileInDir(logger, config.publicRpcFile, serializePublicRPC(pathToPikkuTypes, config.scaffold.rpc === 'auth'));
|
|
13
11
|
return true;
|
|
14
12
|
}
|
|
15
13
|
return false;
|
|
@@ -3,13 +3,11 @@ import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
|
|
|
3
3
|
import { writeFileInDir } from '../../../utils/file-writer.js';
|
|
4
4
|
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js';
|
|
5
5
|
import { serializeRemoteRPC } from './serialize-remote-rpc.js';
|
|
6
|
-
import { join } from 'path';
|
|
7
6
|
export const pikkuRemoteRPC = pikkuSessionlessFunc({
|
|
8
7
|
func: async ({ logger, config }) => {
|
|
9
|
-
if (config.
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
await writeFileInDir(logger, remoteRpcPath, serializeRemoteRPC(pathToPikkuTypes));
|
|
8
|
+
if (config.remoteRpcWorkersFile) {
|
|
9
|
+
const pathToPikkuTypes = getFileImportRelativePath(config.remoteRpcWorkersFile, config.typesDeclarationFile, config.packageMappings);
|
|
10
|
+
await writeFileInDir(logger, config.remoteRpcWorkersFile, serializeRemoteRPC(pathToPikkuTypes));
|
|
13
11
|
return true;
|
|
14
12
|
}
|
|
15
13
|
return false;
|
|
@@ -5,7 +5,8 @@ import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-
|
|
|
5
5
|
import { serializeRPCWrapper } from './serialize-rpc-wrapper.js';
|
|
6
6
|
export const pikkuRPCClient = pikkuSessionlessFunc({
|
|
7
7
|
func: async ({ logger, config }) => {
|
|
8
|
-
const
|
|
8
|
+
const rpcWiringsFile = config.clientFiles?.rpcWiringsFile;
|
|
9
|
+
const { rpcMapDeclarationFile, packageMappings } = config;
|
|
9
10
|
// If rpcWiringsFile is not set, clean up any existing file and return
|
|
10
11
|
if (!rpcWiringsFile) {
|
|
11
12
|
logger.debug({
|
|
@@ -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
|
|