@pikku/cli 0.12.15 → 0.12.16
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-CzMWJFqj.js +700 -0
- package/console-app/index.html +1 -1
- package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +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/cli/pikku-cli-channel.js +16 -1
- 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 +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.json +68 -5
- 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 +16 -19
- package/dist/.pikku/function/pikku-function-types.gen.js +15 -19
- package/dist/.pikku/function/pikku-functions-meta.gen.js +1 -1
- package/dist/.pikku/function/pikku-functions-meta.gen.json +190 -107
- package/dist/.pikku/function/pikku-functions.gen.js +6 -2
- 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 +1 -1
- package/dist/.pikku/http/pikku-http-wirings-meta.gen.json +18 -1
- package/dist/.pikku/http/pikku-http-wirings.gen.d.ts +2 -2
- package/dist/.pikku/http/pikku-http-wirings.gen.js +3 -3
- 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/pikku-bootstrap.gen.d.ts +3 -10
- package/dist/.pikku/pikku-bootstrap.gen.js +1 -18
- package/dist/.pikku/pikku-meta-service.gen.d.ts +7 -0
- package/dist/.pikku/pikku-meta-service.gen.js +9 -0
- 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/queue/pikku-queue-types.gen.d.ts +1 -1
- package/dist/.pikku/queue/pikku-queue-types.gen.js +1 -1
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +1 -1
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +5 -1
- 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/schemas/register.gen.js +15 -7
- package/dist/.pikku/schemas/schemas/DeployApplyInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/DeployPlanInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuNewAddonInput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuWorkflowRoutesOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/RemoteRPCHandlerInput.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 +3 -24
- package/dist/.pikku/workflow/pikku-workflow-types.gen.js +1 -14
- package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +1 -1
- 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 +63 -4
- package/dist/src/deploy/analyzer/analyzer.d.ts +16 -0
- package/dist/src/deploy/analyzer/analyzer.js +557 -0
- package/dist/src/deploy/analyzer/index.d.ts +3 -0
- package/dist/src/deploy/analyzer/index.js +1 -0
- package/dist/src/deploy/analyzer/manifest.d.ts +112 -0
- package/dist/src/deploy/analyzer/manifest.js +8 -0
- package/dist/src/deploy/build-pipeline.d.ts +39 -0
- package/dist/src/deploy/build-pipeline.js +209 -0
- package/dist/src/deploy/bundler/bundler.d.ts +30 -0
- package/dist/src/deploy/bundler/bundler.js +196 -0
- package/dist/src/deploy/bundler/dep-extractor.d.ts +35 -0
- package/dist/src/deploy/bundler/dep-extractor.js +213 -0
- package/dist/src/deploy/bundler/index.d.ts +3 -0
- package/dist/src/deploy/bundler/index.js +2 -0
- package/dist/src/deploy/bundler/types.d.ts +21 -0
- package/dist/src/deploy/bundler/types.js +5 -0
- package/dist/src/deploy/codegen/index.d.ts +2 -0
- package/dist/src/deploy/codegen/index.js +1 -0
- package/dist/src/deploy/codegen/per-unit-codegen.d.ts +44 -0
- package/dist/src/deploy/codegen/per-unit-codegen.js +216 -0
- package/dist/src/deploy/plan/executor.d.ts +9 -0
- package/dist/src/deploy/plan/executor.js +49 -0
- package/dist/src/deploy/plan/formatter.d.ts +4 -0
- package/dist/src/deploy/plan/formatter.js +114 -0
- package/dist/src/deploy/plan/index.d.ts +5 -0
- package/dist/src/deploy/plan/index.js +3 -0
- package/dist/src/deploy/plan/planner.d.ts +4 -0
- package/dist/src/deploy/plan/planner.js +220 -0
- package/dist/src/deploy/plan/provider.d.ts +30 -0
- package/dist/src/deploy/plan/provider.js +1 -0
- package/dist/src/deploy/plan/types.d.ts +29 -0
- package/dist/src/deploy/plan/types.js +1 -0
- package/dist/src/deploy/provider-adapter.d.ts +111 -0
- package/dist/src/deploy/provider-adapter.js +10 -0
- package/dist/src/functions/commands/all.js +6 -2
- package/dist/src/functions/commands/deploy-apply.d.ts +22 -0
- package/dist/src/functions/commands/deploy-apply.js +206 -0
- package/dist/src/functions/commands/deploy-info.d.ts +1 -0
- package/dist/src/functions/commands/deploy-info.js +122 -0
- package/dist/src/functions/commands/deploy-plan.d.ts +10 -0
- package/dist/src/functions/commands/deploy-plan.js +96 -0
- package/dist/src/functions/commands/enable.js +1 -1
- package/dist/src/functions/commands/new-addon.d.ts +3 -0
- package/dist/src/functions/commands/new-addon.js +68 -2
- package/dist/src/functions/commands/pikku-command-bootstrap.js +30 -20
- package/dist/src/functions/runtimes/nextjs/pikku-command-nextjs.js +7 -3
- package/dist/src/functions/wirings/ai-agent/pikku-command-ai-agent.js +7 -5
- package/dist/src/functions/wirings/channels/pikku-channels.js +3 -0
- package/dist/src/functions/wirings/channels/pikku-command-channels.js +3 -0
- package/dist/src/functions/wirings/cli/pikku-command-cli.js +3 -0
- package/dist/src/functions/wirings/cli/serialize-channel-cli.js +2 -2
- package/dist/src/functions/wirings/console/serialize-console-functions.js +2 -2
- package/dist/src/functions/wirings/functions/pikku-command-services.d.ts +1 -1
- package/dist/src/functions/wirings/functions/pikku-command-services.js +9 -2
- package/dist/src/functions/wirings/functions/serialize-function-imports.js +5 -3
- package/dist/src/functions/wirings/functions/serialize-function-types.js +17 -19
- package/dist/src/functions/wirings/http/pikku-command-http-routes.js +3 -0
- package/dist/src/functions/wirings/http/pikku-http-routes.js +3 -0
- package/dist/src/functions/wirings/mcp/pikku-command-mcp.js +6 -0
- package/dist/src/functions/wirings/package/pikku-command-package.js +1 -1
- package/dist/src/functions/wirings/package/serialize-package.d.ts +1 -1
- package/dist/src/functions/wirings/package/serialize-package.js +5 -2
- package/dist/src/functions/wirings/queue/pikku-command-queue.js +4 -0
- package/dist/src/functions/wirings/queue/pikku-queue.js +4 -0
- package/dist/src/functions/wirings/queue/serialize-queue-map.js +4 -1
- package/dist/src/functions/wirings/rpc/pikku-command-rpc.js +10 -3
- package/dist/src/functions/wirings/rpc/serialize-public-rpc.js +5 -27
- package/dist/src/functions/wirings/rpc/serialize-remote-rpc.js +11 -14
- package/dist/src/functions/wirings/rpc/serialize-rpc-wrapper.js +28 -3
- package/dist/src/functions/wirings/rpc/serialize-typed-rpc-map.js +15 -5
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler.js +4 -0
- package/dist/src/functions/wirings/workflow/pikku-command-workflow-routes.d.ts +1 -0
- package/dist/src/functions/wirings/workflow/pikku-command-workflow-routes.js +21 -0
- package/dist/src/functions/wirings/workflow/pikku-command-workflow.js +10 -9
- package/dist/src/functions/wirings/workflow/serialize-workflow-map.d.ts +6 -1
- package/dist/src/functions/wirings/workflow/serialize-workflow-map.js +42 -5
- package/dist/src/functions/wirings/workflow/serialize-workflow-registration.d.ts +1 -1
- package/dist/src/functions/wirings/workflow/serialize-workflow-registration.js +3 -2
- package/dist/src/functions/wirings/workflow/serialize-workflow-routes.d.ts +4 -0
- package/dist/src/functions/wirings/workflow/serialize-workflow-routes.js +139 -0
- package/dist/src/functions/wirings/workflow/serialize-workflow-types.js +4 -51
- package/dist/src/scaffold/rpc-remote.gen.d.ts +10 -0
- package/dist/src/scaffold/rpc-remote.gen.js +22 -0
- package/dist/src/services.js +12 -7
- package/dist/src/utils/pikku-cli-config.d.ts +1 -1
- package/dist/src/utils/pikku-cli-config.js +30 -28
- package/dist/src/utils/strip-verbose-meta.js +2 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -4
- package/console-app/assets/index-robZPL3O.js +0 -672
- package/dist/src/functions/wirings/workflow/serialize-workflow-workers.d.ts +0 -4
- package/dist/src/functions/wirings/workflow/serialize-workflow-workers.js +0 -47
|
@@ -8,16 +8,18 @@ export const pikkuAIAgent = pikkuSessionlessFunc({
|
|
|
8
8
|
func: async ({ logger, config, getInspectorState }) => {
|
|
9
9
|
const { agents, functions } = await getInspectorState();
|
|
10
10
|
const { agentWiringsFile, agentWiringMetaFile, agentWiringMetaJsonFile, agentMapDeclarationFile, packageMappings, schema, addonName, } = config;
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const agentFiles = agents.files;
|
|
12
|
+
if (agentFiles.size === 0 || Object.keys(agents.agentsMeta).length === 0) {
|
|
13
|
+
// Still need to generate an empty agent map for the types import
|
|
14
|
+
await writeFileInDir(logger, agentMapDeclarationFile, `export type AgentMap = {}\n`);
|
|
15
|
+
return undefined;
|
|
15
16
|
}
|
|
17
|
+
const lines = [];
|
|
18
|
+
lines.push(`import { addAIAgent } from '@pikku/core/ai-agent'`);
|
|
16
19
|
const metaImportPath = getFileImportRelativePath(agentWiringsFile, agentWiringMetaFile, packageMappings);
|
|
17
20
|
if (Object.keys(agents.agentsMeta).length > 0) {
|
|
18
21
|
lines.push(`import '${metaImportPath}'`);
|
|
19
22
|
}
|
|
20
|
-
const agentFiles = agents.files;
|
|
21
23
|
const sortedAgents = Array.from(agentFiles.entries()).sort((a, b) => a[0].localeCompare(b[0]));
|
|
22
24
|
for (const [, { path, exportedName }] of sortedAgents) {
|
|
23
25
|
const importPath = getFileImportRelativePath(agentWiringsFile, path, packageMappings);
|
|
@@ -8,6 +8,9 @@ export const pikkuChannels = pikkuVoidFunc({
|
|
|
8
8
|
const visitState = await getInspectorState();
|
|
9
9
|
const { channelsWiringFile, channelsWiringMetaFile, channelsWiringMetaJsonFile, packageMappings, schema, } = config;
|
|
10
10
|
const { channels } = visitState;
|
|
11
|
+
if (channels.files.size === 0 || Object.keys(channels.meta).length === 0) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
11
14
|
await writeFileInDir(logger, channelsWiringFile, serializeFileImports('addChannel', channelsWiringFile, channels.files, packageMappings));
|
|
12
15
|
await writeFileInDir(logger, channelsWiringMetaJsonFile, JSON.stringify(channels.meta, null, 2));
|
|
13
16
|
const jsonImportPath = getFileImportRelativePath(channelsWiringMetaFile, channelsWiringMetaJsonFile, packageMappings);
|
|
@@ -9,6 +9,9 @@ export const pikkuChannels = pikkuSessionlessFunc({
|
|
|
9
9
|
const visitState = await getInspectorState();
|
|
10
10
|
const { channelsWiringFile, channelsWiringMetaFile, channelsWiringMetaJsonFile, packageMappings, schema, } = config;
|
|
11
11
|
const { channels } = visitState;
|
|
12
|
+
if (channels.files.size === 0 || Object.keys(channels.meta).length === 0) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
12
15
|
await writeFileInDir(logger, channelsWiringFile, serializeFileImports('addChannel', channelsWiringFile, channels.files, packageMappings));
|
|
13
16
|
// Write minimal JSON (runtime-only fields)
|
|
14
17
|
const minimalMeta = stripVerboseFields(channels.meta);
|
|
@@ -9,6 +9,9 @@ export const pikkuCLI = pikkuSessionlessFunc({
|
|
|
9
9
|
const visitState = await getInspectorState();
|
|
10
10
|
const { cliWiringsFile, cliWiringMetaFile, cliWiringMetaJsonFile, packageMappings, schema, } = config;
|
|
11
11
|
const { cli } = visitState;
|
|
12
|
+
if (cli.files.size === 0 || Object.keys(cli.meta).length === 0) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
12
15
|
// Generate CLI wirings file
|
|
13
16
|
await writeFileInDir(logger, cliWiringsFile, serializeFileImports('wireCLI', cliWiringsFile, cli.files, packageMappings));
|
|
14
17
|
// Write minimal JSON (runtime-only fields)
|
|
@@ -48,7 +48,7 @@ export function serializeChannelCLI(programName, programMeta, channelFile, funct
|
|
|
48
48
|
* WebSocket channel backend for '${programName}' CLI commands
|
|
49
49
|
*/
|
|
50
50
|
import { wireChannel } from '${channelTypesPath}'
|
|
51
|
-
import { pikkuMiddleware${hasAddonFuncs ? ',
|
|
51
|
+
import { pikkuMiddleware${hasAddonFuncs ? ', ref' : ''}, pikkuSessionlessFunc } from '${functionTypesPath}'
|
|
52
52
|
import { generateCommandHelp } from '@pikku/core/cli'
|
|
53
53
|
import { handleRawCLI } from '@pikku/core/cli/channel'
|
|
54
54
|
import { pikkuState } from '@pikku/core/internal'
|
|
@@ -115,7 +115,7 @@ wireChannel({
|
|
|
115
115
|
${Object.entries(commandMap)
|
|
116
116
|
.map(([commandKey, { pikkuFuncId, isAddon }]) => {
|
|
117
117
|
const funcRef = isAddon
|
|
118
|
-
? `
|
|
118
|
+
? `ref('${pikkuFuncId}')`
|
|
119
119
|
: (functionFiles.get(pikkuFuncId)?.exportedName ?? pikkuFuncId);
|
|
120
120
|
return ` '${commandKey}': {
|
|
121
121
|
func: ${funcRef},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const serializeConsoleFunctions = (pathToPikkuTypes, _pathToAgentTypes, globalHTTPPrefix = '') => {
|
|
2
|
-
return `import { pikkuSessionlessFunc, defineHTTPRoutes, wireHTTPRoutes,
|
|
2
|
+
return `import { pikkuSessionlessFunc, defineHTTPRoutes, wireHTTPRoutes, ref, wireAddon } from '${pathToPikkuTypes}'
|
|
3
3
|
|
|
4
4
|
export const pikkuConsoleSetSecret = pikkuSessionlessFunc<{
|
|
5
5
|
secretId: string
|
|
@@ -92,7 +92,7 @@ export const consoleRoutes = defineHTTPRoutes({
|
|
|
92
92
|
route: '/workflow-run/:runId/stream',
|
|
93
93
|
method: 'get',
|
|
94
94
|
sse: true,
|
|
95
|
-
func:
|
|
95
|
+
func: ref('console:streamWorkflowRun'),
|
|
96
96
|
},
|
|
97
97
|
},
|
|
98
98
|
})
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const serializeServicesMap: (allSingletonServices: string[], allWireServices: string[], requiredServices: Set<string>, forceRequiredServices: string[] | undefined, servicesImport: string, wireServicesImport: string) => string;
|
|
1
|
+
export declare const serializeServicesMap: (allSingletonServices: string[], allWireServices: string[], requiredServices: Set<string>, forceRequiredServices: string[] | undefined, servicesImport: string, wireServicesImport: string, addonRequiredParentServices?: string[]) => string;
|
|
2
2
|
export declare const pikkuServices: import("#pikku").PikkuFunctionConfig<void, void, "session" | "rpc", import("#pikku").PikkuFunctionSessionless<void, void, "session" | "rpc", import("#pikku").Services> | import("#pikku").PikkuFunction<void, void, "session" | "rpc", import("#pikku").Services>, undefined, undefined>;
|
|
@@ -3,7 +3,7 @@ import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
|
|
|
3
3
|
import { checkRequiredTypes } from '../../../utils/check-required-types.js';
|
|
4
4
|
import { writeFileInDir } from '../../../utils/file-writer.js';
|
|
5
5
|
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js';
|
|
6
|
-
export const serializeServicesMap = (allSingletonServices, allWireServices, requiredServices, forceRequiredServices = [], servicesImport, wireServicesImport) => {
|
|
6
|
+
export const serializeServicesMap = (allSingletonServices, allWireServices, requiredServices, forceRequiredServices = [], servicesImport, wireServicesImport, addonRequiredParentServices = []) => {
|
|
7
7
|
// Use pre-aggregated services from inspector state
|
|
8
8
|
// This includes services from:
|
|
9
9
|
// - Wired functions (HTTP, channels, queues, schedulers, MCP, CLI, RPC)
|
|
@@ -79,6 +79,13 @@ export const serializeServicesMap = (allSingletonServices, allWireServices, requ
|
|
|
79
79
|
? `export type RequiredWireServices = Pick<Services, ${requiredWireServiceNames.map((key) => `'${key}'`).join(' | ')}> & Partial<Omit<Services, ${requiredWireServiceNames.map((key) => `'${key}'`).join(' | ')}>>`
|
|
80
80
|
: 'export type RequiredWireServices = Partial<Services>',
|
|
81
81
|
'',
|
|
82
|
+
...(addonRequiredParentServices.length > 0
|
|
83
|
+
? [
|
|
84
|
+
'// Services this addon needs from the parent project',
|
|
85
|
+
`export const requiredParentServices = ${JSON.stringify(addonRequiredParentServices)} as const`,
|
|
86
|
+
'',
|
|
87
|
+
]
|
|
88
|
+
: []),
|
|
82
89
|
].join('\n');
|
|
83
90
|
return code;
|
|
84
91
|
};
|
|
@@ -96,7 +103,7 @@ export const pikkuServices = pikkuSessionlessFunc({
|
|
|
96
103
|
}
|
|
97
104
|
const servicesImport = `import type { ${singletonServicesType.type} } from '${getFileImportRelativePath(config.typesDeclarationFile, singletonServicesType.typePath, config.packageMappings)}'`;
|
|
98
105
|
const wireServicesImport = `import type { ${wireServicesType.type} } from '${getFileImportRelativePath(config.typesDeclarationFile, wireServicesType.typePath, config.packageMappings)}'`;
|
|
99
|
-
const servicesCode = serializeServicesMap(visitState.serviceAggregation.allSingletonServices, visitState.serviceAggregation.allWireServices, visitState.serviceAggregation.requiredServices, config.forceRequiredServices, servicesImport, wireServicesImport);
|
|
106
|
+
const servicesCode = serializeServicesMap(visitState.serviceAggregation.allSingletonServices, visitState.serviceAggregation.allWireServices, visitState.serviceAggregation.requiredServices, config.forceRequiredServices, servicesImport, wireServicesImport, config.addonName ? visitState.addonRequiredParentServices : []);
|
|
100
107
|
await writeFileInDir(logger, config.servicesFile, servicesCode);
|
|
101
108
|
},
|
|
102
109
|
middleware: [
|
|
@@ -4,11 +4,13 @@ export const serializeFunctionImports = (outputPath, functionsMap, functionsMeta
|
|
|
4
4
|
addonName) => {
|
|
5
5
|
const serializedImports = [
|
|
6
6
|
`/* Import and register functions used by RPCs */`,
|
|
7
|
-
`import { addFunction } from '@pikku/core'`,
|
|
7
|
+
`import { addFunction } from '@pikku/core/function'`,
|
|
8
8
|
];
|
|
9
9
|
const serializedRegistrations = [];
|
|
10
|
-
// Sort by function name for consistent output
|
|
11
|
-
const sortedEntries = Array.from(functionsMap.entries())
|
|
10
|
+
// Sort by function name for consistent output, only include functions in meta
|
|
11
|
+
const sortedEntries = Array.from(functionsMap.entries())
|
|
12
|
+
.filter(([name]) => name in functionsMeta)
|
|
13
|
+
.sort((a, b) => a[0].localeCompare(b[0]));
|
|
12
14
|
// Third argument to addFunction is the package name (null for main package)
|
|
13
15
|
const packageArg = addonName ? `, '${addonName}'` : '';
|
|
14
16
|
const usedAliases = new Set();
|
|
@@ -12,9 +12,11 @@ export const serializeFunctionTypes = (userSessionTypeImport, userSessionTypeNam
|
|
|
12
12
|
* Core function, middleware, and permission types for all wirings
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import type { CorePikkuMiddleware, CorePermissionGroup, PikkuWire, PickRequired } from '@pikku/core'
|
|
16
|
+
import type { CorePikkuFunctionConfig, CorePikkuAuth, CorePikkuAuthConfig, CorePikkuPermission } from '@pikku/core/function'
|
|
17
|
+
import { pikkuAuth as pikkuAuthCore } from '@pikku/core/function'
|
|
18
|
+
import { addMiddleware as addMiddlewareCore, addPermission as addPermissionCore } from '@pikku/core/middleware'
|
|
16
19
|
import { pikkuState as __pikkuState, CreateWireServices } from '@pikku/core/internal'
|
|
17
|
-
import { pikkuAuth as pikkuAuthCore } from '@pikku/core'
|
|
18
20
|
import { PikkuError } from '@pikku/core/errors'
|
|
19
21
|
import type { NodeType } from '@pikku/core/node'
|
|
20
22
|
import type { StandardSchemaV1 } from '@standard-schema/spec'
|
|
@@ -519,27 +521,23 @@ export const pikkuVoidFunc = (
|
|
|
519
521
|
}
|
|
520
522
|
|
|
521
523
|
/**
|
|
522
|
-
*
|
|
523
|
-
*
|
|
524
|
-
* without type compatibility issues.
|
|
524
|
+
* References a registered function by name for use in any wiring.
|
|
525
|
+
* Works for both local and addon functions — resolves via RPC at runtime.
|
|
525
526
|
*
|
|
526
|
-
* @template Name - The
|
|
527
|
-
* @param rpcName - The name of the
|
|
528
|
-
* @returns A Pikku function that proxies calls
|
|
527
|
+
* @template Name - The function name (must be a key in FlattenedRPCMap)
|
|
528
|
+
* @param rpcName - The name of the function to reference
|
|
529
|
+
* @returns A Pikku function config that proxies calls via RPC
|
|
529
530
|
*
|
|
530
531
|
* @example
|
|
531
532
|
* \`\`\`typescript
|
|
532
|
-
* //
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
*
|
|
537
|
-
* func: addon('ext:hello'),
|
|
538
|
-
* tags: ['addon'],
|
|
539
|
-
* })
|
|
533
|
+
* // Use in agent tools
|
|
534
|
+
* tools: [ref('todos:listTodos'), ref('myLocalFunc')]
|
|
535
|
+
*
|
|
536
|
+
* // Use in HTTP wiring
|
|
537
|
+
* wireHTTP({ route: '/greet', method: 'post', func: ref('greet') })
|
|
540
538
|
* \`\`\`
|
|
541
539
|
*/
|
|
542
|
-
export const
|
|
540
|
+
export const ref = <Name extends keyof FlattenedRPCMap>(
|
|
543
541
|
rpcName: Name
|
|
544
542
|
): PikkuFunctionConfig<
|
|
545
543
|
FlattenedRPCMap[Name]['input'],
|
|
@@ -689,7 +687,7 @@ export const addPermission = <In = unknown>(tag: string, permissions: CorePermis
|
|
|
689
687
|
addPermissionCore(tag, permissions as any, ${packageNameValue})
|
|
690
688
|
}
|
|
691
689
|
|
|
692
|
-
export { wireAddon } from '@pikku/core'
|
|
693
|
-
export type { WireAddonConfig } from '@pikku/core'
|
|
690
|
+
export { wireAddon } from '@pikku/core/rpc'
|
|
691
|
+
export type { WireAddonConfig } from '@pikku/core/rpc'
|
|
694
692
|
`;
|
|
695
693
|
};
|
|
@@ -9,6 +9,9 @@ export const pikkuHTTP = pikkuSessionlessFunc({
|
|
|
9
9
|
const visitState = await getInspectorState();
|
|
10
10
|
const { httpWiringsFile, httpWiringMetaFile, httpWiringMetaJsonFile, packageMappings, schema, } = config;
|
|
11
11
|
const { http } = visitState;
|
|
12
|
+
if (http.files.size === 0 || Object.keys(http.meta).length === 0) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
12
15
|
await writeFileInDir(logger, httpWiringsFile, serializeFileImports('wireHTTP', httpWiringsFile, http.files, packageMappings));
|
|
13
16
|
// Write minimal JSON (runtime-only fields)
|
|
14
17
|
const minimalMeta = stripVerboseFields(http.meta);
|
|
@@ -8,6 +8,9 @@ export const pikkuHTTP = pikkuSessionlessFunc({
|
|
|
8
8
|
const visitState = await getInspectorState();
|
|
9
9
|
const { httpWiringsFile, httpWiringMetaFile, httpWiringMetaJsonFile, packageMappings, schema, } = config;
|
|
10
10
|
const { http } = visitState;
|
|
11
|
+
if (http.files.size === 0 || Object.keys(http.meta).length === 0) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
11
14
|
await writeFileInDir(logger, httpWiringsFile, serializeFileImports('wireHTTP', httpWiringsFile, http.files, packageMappings));
|
|
12
15
|
await writeFileInDir(logger, httpWiringMetaJsonFile, JSON.stringify(http.meta, null, 2));
|
|
13
16
|
const jsonImportPath = getFileImportRelativePath(httpWiringMetaFile, httpWiringMetaJsonFile, packageMappings);
|
|
@@ -53,6 +53,12 @@ export const pikkuMCP = pikkuSessionlessFunc({
|
|
|
53
53
|
func: async ({ logger, config, getInspectorState }) => {
|
|
54
54
|
const { mcpEndpoints, functions } = await getInspectorState();
|
|
55
55
|
const { mcpWiringsFile, mcpWiringsMetaFile, packageMappings, schemaDirectory, schema, } = config;
|
|
56
|
+
const hasMcpContent = Object.keys(mcpEndpoints.toolsMeta).length > 0 ||
|
|
57
|
+
Object.keys(mcpEndpoints.resourcesMeta).length > 0 ||
|
|
58
|
+
Object.keys(mcpEndpoints.promptsMeta).length > 0;
|
|
59
|
+
if (mcpEndpoints.files.size === 0 || !hasMcpContent) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
56
62
|
await writeFileInDir(logger, mcpWiringsFile, serializeFileImports('wireMCPResource', mcpWiringsFile, mcpEndpoints.files, packageMappings));
|
|
57
63
|
// Populate arguments for prompts meta before serializing
|
|
58
64
|
const promptsMetaWithArguments = { ...mcpEndpoints.promptsMeta };
|
|
@@ -50,7 +50,7 @@ export const pikkuPackage = pikkuSessionlessFunc({
|
|
|
50
50
|
file: wireServicesFactory.file,
|
|
51
51
|
variable: wireServicesFactory.variable,
|
|
52
52
|
}
|
|
53
|
-
: undefined, packageMappings, Object.keys(credentialsMeta).length > 0 ? credentialsMeta : undefined);
|
|
53
|
+
: undefined, packageMappings, Object.keys(credentialsMeta).length > 0 ? credentialsMeta : undefined, state.addonRequiredParentServices);
|
|
54
54
|
if (!content) {
|
|
55
55
|
logger.info({
|
|
56
56
|
message: 'Skipping package factories - no service factories found',
|
|
@@ -8,4 +8,4 @@ export interface CredentialMetaForPackage {
|
|
|
8
8
|
type: 'singleton' | 'wire';
|
|
9
9
|
oauth2?: boolean;
|
|
10
10
|
}
|
|
11
|
-
export declare const serializePackageFactories: (outputPath: string, packageName: string, configFactory: PackageFactoryInfo | undefined, singletonServicesFactory: PackageFactoryInfo | undefined, wireServicesFactory: PackageFactoryInfo | undefined, packageMappings?: Record<string, string>, credentialsMeta?: Record<string, CredentialMetaForPackage
|
|
11
|
+
export declare const serializePackageFactories: (outputPath: string, packageName: string, configFactory: PackageFactoryInfo | undefined, singletonServicesFactory: PackageFactoryInfo | undefined, wireServicesFactory: PackageFactoryInfo | undefined, packageMappings?: Record<string, string>, credentialsMeta?: Record<string, CredentialMetaForPackage>, requiredParentServices?: string[]) => string | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
|
|
2
|
-
export const serializePackageFactories = (outputPath, packageName, configFactory, singletonServicesFactory, wireServicesFactory, packageMappings = {}, credentialsMeta) => {
|
|
2
|
+
export const serializePackageFactories = (outputPath, packageName, configFactory, singletonServicesFactory, wireServicesFactory, packageMappings = {}, credentialsMeta, requiredParentServices) => {
|
|
3
3
|
const imports = [
|
|
4
4
|
`import { pikkuState } from '@pikku/core/internal'`,
|
|
5
5
|
];
|
|
@@ -26,10 +26,13 @@ export const serializePackageFactories = (outputPath, packageName, configFactory
|
|
|
26
26
|
const credentialsLine = credentialsMeta && Object.keys(credentialsMeta).length > 0
|
|
27
27
|
? `\npikkuState('${packageName}', 'package', 'credentialsMeta', ${JSON.stringify(credentialsMeta)})\n`
|
|
28
28
|
: '';
|
|
29
|
+
const requiredParentServicesLine = requiredParentServices && requiredParentServices.length > 0
|
|
30
|
+
? `\npikkuState('${packageName}', 'package', 'requiredParentServices', ${JSON.stringify(requiredParentServices)})\n`
|
|
31
|
+
: '';
|
|
29
32
|
return `${imports.join('\n')}
|
|
30
33
|
|
|
31
34
|
pikkuState('${packageName}', 'package', 'factories', {
|
|
32
35
|
${factoryEntries.join('\n')}
|
|
33
36
|
})
|
|
34
|
-
${credentialsLine}`;
|
|
37
|
+
${credentialsLine}${requiredParentServicesLine}`;
|
|
35
38
|
};
|
|
@@ -10,6 +10,10 @@ export const pikkuQueue = pikkuSessionlessFunc({
|
|
|
10
10
|
const visitState = await getInspectorState();
|
|
11
11
|
const { queueWorkersWiringFile, queueWorkersWiringMetaFile, queueWorkersWiringMetaJsonFile, packageMappings, schema, } = config;
|
|
12
12
|
const { queueWorkers } = visitState;
|
|
13
|
+
if (queueWorkers.files.size === 0 ||
|
|
14
|
+
Object.keys(queueWorkers.meta).length === 0) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
13
17
|
const fullMeta = serializeQueueMeta(queueWorkers.meta);
|
|
14
18
|
// Write minimal JSON file (runtime-only fields)
|
|
15
19
|
const minimalMeta = stripVerboseFields(fullMeta);
|
|
@@ -9,6 +9,10 @@ export const pikkuQueue = pikkuSessionlessFunc({
|
|
|
9
9
|
const visitState = await getInspectorState();
|
|
10
10
|
const { queueWorkersWiringFile, queueWorkersWiringMetaFile, queueWorkersWiringMetaJsonFile, packageMappings, schema, } = config;
|
|
11
11
|
const { queueWorkers } = visitState;
|
|
12
|
+
if (queueWorkers.files.size === 0 ||
|
|
13
|
+
Object.keys(queueWorkers.meta).length === 0) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
12
16
|
// Write JSON file
|
|
13
17
|
await writeFileInDir(logger, queueWorkersWiringMetaJsonFile, JSON.stringify(serializeQueueMeta(queueWorkers.meta), null, 2));
|
|
14
18
|
// Calculate relative path from TS file to JSON file
|
|
@@ -50,7 +50,10 @@ function generateQueues(queueWorkersMeta, resolvedIOTypes, requiredTypes) {
|
|
|
50
50
|
for (const [queueName, { pikkuFuncId }] of Object.entries(queueWorkersMeta)) {
|
|
51
51
|
const resolved = resolvedIOTypes[pikkuFuncId];
|
|
52
52
|
if (!resolved) {
|
|
53
|
-
|
|
53
|
+
// Synthetic workflow queue workers (pikkuWorkflowWorker:*, pikkuWorkflowOrchestrator:*)
|
|
54
|
+
// don't have resolved types — use null for their queue map entries
|
|
55
|
+
queuesObj[queueName] = { inputType: 'null', outputType: 'null' };
|
|
56
|
+
continue;
|
|
54
57
|
}
|
|
55
58
|
requiredTypes.add(resolved.inputType);
|
|
56
59
|
requiredTypes.add(resolved.outputType);
|
|
@@ -4,10 +4,17 @@ import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-
|
|
|
4
4
|
import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
|
|
5
5
|
export const pikkuRPC = pikkuSessionlessFunc({
|
|
6
6
|
func: async ({ logger, config, getInspectorState }) => {
|
|
7
|
-
const { rpc } = await getInspectorState();
|
|
7
|
+
const { rpc, functions } = await getInspectorState();
|
|
8
8
|
const { rpcInternalWiringMetaFile, rpcInternalWiringMetaJsonFile, packageMappings, schema, } = config;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
// Filter internal RPC meta to only include functions in the filtered meta
|
|
10
|
+
const filteredInternalMeta = {};
|
|
11
|
+
for (const [key, value] of Object.entries(rpc.internalMeta)) {
|
|
12
|
+
if (key in functions.meta) {
|
|
13
|
+
filteredInternalMeta[key] = value;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (Object.keys(filteredInternalMeta).length > 0) {
|
|
17
|
+
await writeFileInDir(logger, rpcInternalWiringMetaJsonFile, JSON.stringify(filteredInternalMeta, null, 2));
|
|
11
18
|
const jsonImportPath = getFileImportRelativePath(rpcInternalWiringMetaFile, rpcInternalWiringMetaJsonFile, packageMappings);
|
|
12
19
|
const supportsImportAttributes = schema?.supportsImportAttributes ?? false;
|
|
13
20
|
const importStatement = supportsImportAttributes
|
|
@@ -7,7 +7,7 @@ export const serializePublicRPC = (pathToPikkuTypes, requireAuth = true, globalH
|
|
|
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, wireHTTP } from '${pathToPikkuTypes}'
|
|
11
11
|
|
|
12
12
|
export const rpcCaller = pikkuSessionlessFunc<
|
|
13
13
|
{ rpcName: string; data?: unknown },
|
|
@@ -19,33 +19,11 @@ export const rpcCaller = pikkuSessionlessFunc<
|
|
|
19
19
|
},
|
|
20
20
|
})
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
>({
|
|
22
|
+
wireHTTP({
|
|
23
|
+
route: '${globalHTTPPrefix}/rpc/:rpcName',
|
|
24
|
+
method: 'post',
|
|
26
25
|
auth: ${authFlag},
|
|
27
|
-
func:
|
|
28
|
-
return await (rpc.startWorkflow as Function)(workflowName, input || {})
|
|
29
|
-
},
|
|
26
|
+
func: rpcCaller,
|
|
30
27
|
})
|
|
31
|
-
|
|
32
|
-
export const rpcRoutes = defineHTTPRoutes({
|
|
33
|
-
auth: ${authFlag},
|
|
34
|
-
tags: ['pikku:public'],
|
|
35
|
-
routes: {
|
|
36
|
-
rpc: {
|
|
37
|
-
route: '${globalHTTPPrefix}/rpc/:rpcName',
|
|
38
|
-
method: 'post',
|
|
39
|
-
func: rpcCaller,
|
|
40
|
-
},
|
|
41
|
-
workflow: {
|
|
42
|
-
route: '${globalHTTPPrefix}/rpc/workflow/:workflowName',
|
|
43
|
-
method: 'post',
|
|
44
|
-
func: workflowCaller,
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
wireHTTPRoutes({ routes: { rpc: rpcRoutes } })
|
|
50
28
|
`;
|
|
51
29
|
};
|
|
@@ -6,18 +6,12 @@ export const serializeRemoteRPC = (pathToPikkuTypes) => {
|
|
|
6
6
|
* Auto-generated remote internal RPC queue worker and HTTP endpoint
|
|
7
7
|
* Do not edit manually - regenerate with 'npx pikku'
|
|
8
8
|
*/
|
|
9
|
-
import { pikkuSessionlessFunc,
|
|
9
|
+
import { pikkuSessionlessFunc, wireHTTP } from '${pathToPikkuTypes}'
|
|
10
|
+
import { pikkuRemoteAuthMiddleware } from '@pikku/core/middleware'
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
* TODO: Security risk - this allows any RPC to be invoked by name. Should validate
|
|
16
|
-
* that rpcName is in an allowlist of permitted internal RPCs to prevent unauthorized access.
|
|
17
|
-
*/
|
|
18
|
-
export const pikkuRemoteInternalRPC = pikkuSessionlessFunc<
|
|
19
|
-
{ rpcName: string, data?: any },
|
|
20
|
-
any
|
|
12
|
+
export const remoteRPCHandler = pikkuSessionlessFunc<
|
|
13
|
+
{ rpcName: string, data?: unknown },
|
|
14
|
+
unknown
|
|
21
15
|
>({
|
|
22
16
|
func: async (_services, { rpcName, data }, { rpc }) => {
|
|
23
17
|
return await (rpc.invoke as any)(rpcName, data)
|
|
@@ -25,9 +19,12 @@ export const pikkuRemoteInternalRPC = pikkuSessionlessFunc<
|
|
|
25
19
|
remote: true,
|
|
26
20
|
})
|
|
27
21
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
wireHTTP({
|
|
23
|
+
route: '/remote/rpc/:rpcName',
|
|
24
|
+
method: 'post',
|
|
25
|
+
auth: false,
|
|
26
|
+
middleware: [pikkuRemoteAuthMiddleware],
|
|
27
|
+
func: remoteRPCHandler,
|
|
31
28
|
})
|
|
32
29
|
`;
|
|
33
30
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export const serializeRPCWrapper = (rpcMapPath, globalHTTPPrefix = '') => {
|
|
2
2
|
return `
|
|
3
3
|
import { PikkuFetch } from "./pikku-fetch.gen.js"
|
|
4
|
-
import type { RPCInvoke, TypedAgentRun, TypedStartWorkflow } from '${rpcMapPath}'
|
|
4
|
+
import type { RPCInvoke, TypedAgentRun, TypedStartWorkflow, TypedRunWorkflow, TypedWorkflowStatus } from '${rpcMapPath}'
|
|
5
|
+
import type { WorkflowRunStatus } from '@pikku/core/workflow'
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* PikkuRPC provides a type-safe client for making Remote Procedure Calls (RPC)
|
|
@@ -64,14 +65,38 @@ export class PikkuRPC {
|
|
|
64
65
|
|
|
65
66
|
/**
|
|
66
67
|
* Starts a workflow by name with the given input.
|
|
67
|
-
* Posts to \\\`/
|
|
68
|
+
* Posts to \\\`/workflow/:workflowName/start\\\`.
|
|
68
69
|
*
|
|
69
70
|
* @param workflowName - The registered workflow name
|
|
70
71
|
* @param input - The workflow input data
|
|
71
72
|
* @returns A promise that resolves with the new run ID
|
|
72
73
|
*/
|
|
73
74
|
startWorkflow: TypedStartWorkflow = async (workflowName, input) => {
|
|
74
|
-
return await this.pikkuFetch.post(\`${globalHTTPPrefix}/
|
|
75
|
+
return await this.pikkuFetch.post(\`${globalHTTPPrefix}/workflow/\${String(workflowName)}/start\` as never, { data: input }) as any
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Runs a workflow to completion and returns the output.
|
|
80
|
+
* Posts to \\\`/workflow/:workflowName/run\\\`.
|
|
81
|
+
*
|
|
82
|
+
* @param workflowName - The registered workflow name
|
|
83
|
+
* @param input - The workflow input data
|
|
84
|
+
* @returns A promise that resolves with the workflow output
|
|
85
|
+
*/
|
|
86
|
+
runWorkflow: TypedRunWorkflow = async (workflowName, input) => {
|
|
87
|
+
return await this.pikkuFetch.post(\`${globalHTTPPrefix}/workflow/\${String(workflowName)}/run\` as never, { data: input }) as any
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Gets the current status of a workflow run.
|
|
92
|
+
* GET \\\`/workflow/:workflowName/status/:runId\\\`.
|
|
93
|
+
*
|
|
94
|
+
* @param workflowName - The registered workflow name
|
|
95
|
+
* @param runId - The workflow run ID
|
|
96
|
+
* @returns A promise with the minimal run status
|
|
97
|
+
*/
|
|
98
|
+
workflowStatus: TypedWorkflowStatus = async (workflowName, runId) => {
|
|
99
|
+
return await this.pikkuFetch.get(\`${globalHTTPPrefix}/workflow/\${String(workflowName)}/status/\${runId}\` as never) as unknown as WorkflowRunStatus
|
|
75
100
|
}
|
|
76
101
|
|
|
77
102
|
/**
|
|
@@ -50,7 +50,7 @@ export type RPCRemote = <Name extends keyof FlattenedRPCMap>(
|
|
|
50
50
|
data: FlattenedRPCMap[Name]['input']
|
|
51
51
|
) => Promise<FlattenedRPCMap[Name]['output']>
|
|
52
52
|
|
|
53
|
-
${workflowMapPath ? `import type {
|
|
53
|
+
${workflowMapPath ? `import type { FlattenedWorkflowMap } from '${workflowMapPath}'` : `type FlattenedWorkflowMap = {}`}
|
|
54
54
|
|
|
55
55
|
${agentMapPath ? `import type { AgentMap } from '${agentMapPath}'` : `type AgentMap = {}`}
|
|
56
56
|
${generateAddonAgentImports(wireAddonDeclarations)}
|
|
@@ -64,12 +64,22 @@ interface AIAgentInput {
|
|
|
64
64
|
resourceId: string
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
export type TypedStartWorkflow = <Name extends keyof
|
|
67
|
+
export type TypedStartWorkflow = <Name extends keyof FlattenedWorkflowMap>(
|
|
68
68
|
name: Name,
|
|
69
|
-
input:
|
|
69
|
+
input: FlattenedWorkflowMap[Name]['input'],
|
|
70
70
|
options?: { startNode?: string }
|
|
71
71
|
) => Promise<{ runId: string }>
|
|
72
72
|
|
|
73
|
+
export type TypedRunWorkflow = <Name extends keyof FlattenedWorkflowMap>(
|
|
74
|
+
name: Name,
|
|
75
|
+
input: FlattenedWorkflowMap[Name]['input']
|
|
76
|
+
) => Promise<FlattenedWorkflowMap[Name]['output']>
|
|
77
|
+
|
|
78
|
+
export type TypedWorkflowStatus = (
|
|
79
|
+
workflowName: string,
|
|
80
|
+
runId: string
|
|
81
|
+
) => Promise<{ id: string; status: 'running' | 'suspended' | 'completed' | 'failed' | 'cancelled'; output?: unknown; error?: { message?: string } }>
|
|
82
|
+
|
|
73
83
|
type TypedAgentRun = [keyof FlattenedAgentMap] extends [never]
|
|
74
84
|
? (name: string, input: AIAgentInput) => Promise<any>
|
|
75
85
|
: <Name extends keyof FlattenedAgentMap>(
|
|
@@ -109,8 +119,8 @@ export type FlattenedRPCMap = RPCMap
|
|
|
109
119
|
}
|
|
110
120
|
// TypeScript utility to flatten namespaced RPC maps
|
|
111
121
|
const utilityTypes = `
|
|
112
|
-
// Utility type to prefix keys with namespace
|
|
113
|
-
type PrefixKeys<T, Prefix extends string> = {
|
|
122
|
+
// Utility type to prefix keys with namespace (skips 'any' to prevent type poisoning)
|
|
123
|
+
type PrefixKeys<T, Prefix extends string> = unknown extends T ? {} : {
|
|
114
124
|
[K in keyof T as \`\${Prefix}:\${string & K}\`]: T[K]
|
|
115
125
|
}
|
|
116
126
|
|
|
@@ -10,6 +10,10 @@ export const pikkuScheduler = pikkuSessionlessFunc({
|
|
|
10
10
|
const visitState = await getInspectorState();
|
|
11
11
|
const { schedulersWiringFile, schedulersWiringMetaFile, schedulersWiringMetaJsonFile, packageMappings, schema, } = config;
|
|
12
12
|
const { scheduledTasks } = visitState;
|
|
13
|
+
if (scheduledTasks.files.size === 0 ||
|
|
14
|
+
Object.keys(scheduledTasks.meta).length === 0) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
13
17
|
const fullMeta = serializeSchedulerMeta(scheduledTasks.meta);
|
|
14
18
|
// Write minimal JSON (runtime-only fields)
|
|
15
19
|
const minimalMeta = stripVerboseFields(fullMeta);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const pikkuWorkflowRoutes: import("#pikku").PikkuFunctionConfig<void, boolean, "session" | "rpc", import("#pikku").PikkuFunctionSessionless<void, boolean, "session" | "rpc", import("#pikku").Services> | import("#pikku").PikkuFunction<void, boolean, "session" | "rpc", import("#pikku").Services>, undefined, undefined>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { pikkuSessionlessFunc } from '#pikku';
|
|
2
|
+
import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
|
|
3
|
+
import { writeFileInDir } from '../../../utils/file-writer.js';
|
|
4
|
+
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js';
|
|
5
|
+
import { serializeWorkflowRoutes } from './serialize-workflow-routes.js';
|
|
6
|
+
export const pikkuWorkflowRoutes = pikkuSessionlessFunc({
|
|
7
|
+
func: async ({ logger, config }) => {
|
|
8
|
+
if (config.workflowRoutesFile) {
|
|
9
|
+
const pathToPikkuTypes = getFileImportRelativePath(config.workflowRoutesFile, config.typesDeclarationFile, config.packageMappings);
|
|
10
|
+
await writeFileInDir(logger, config.workflowRoutesFile, serializeWorkflowRoutes(pathToPikkuTypes, config.scaffold?.workflow === 'auth'));
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
},
|
|
15
|
+
middleware: [
|
|
16
|
+
logCommandInfoAndTime({
|
|
17
|
+
commandStart: 'Generating Workflow Routes',
|
|
18
|
+
commandEnd: 'Generated Workflow Routes',
|
|
19
|
+
}),
|
|
20
|
+
],
|
|
21
|
+
});
|
|
@@ -6,18 +6,23 @@ import { serializeWorkflowTypes } from './serialize-workflow-types.js';
|
|
|
6
6
|
import { serializeWorkflowRegistration } from './serialize-workflow-registration.js';
|
|
7
7
|
import { serializeWorkflowMap } from './serialize-workflow-map.js';
|
|
8
8
|
import { serializeWorkflowMeta } from './serialize-workflow-meta.js';
|
|
9
|
-
import { serializeWorkflowWorkers } from './serialize-workflow-workers.js';
|
|
10
9
|
import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
|
|
11
10
|
import { stripVerboseFields, hasVerboseFields, } from '../../../utils/strip-verbose-meta.js';
|
|
12
11
|
import { join } from 'path';
|
|
13
12
|
export const pikkuWorkflow = pikkuSessionlessFunc({
|
|
14
13
|
func: async ({ logger, config, getInspectorState }) => {
|
|
15
14
|
const visitState = await getInspectorState();
|
|
16
|
-
const { workflowsWiringFile, workflowsWiringMetaFile, workflowMetaDir, workflowMapDeclarationFile, workflowTypesFile, functionTypesFile,
|
|
15
|
+
const { workflowsWiringFile, workflowsWiringMetaFile, workflowMetaDir, workflowMapDeclarationFile, workflowTypesFile, functionTypesFile, packageMappings, schema, } = config;
|
|
17
16
|
const { workflows, functions: functionState } = visitState;
|
|
18
17
|
const { typesMap } = functionState;
|
|
19
|
-
const allWorkflowNames =
|
|
20
|
-
|
|
18
|
+
const allWorkflowNames = [
|
|
19
|
+
...new Set([
|
|
20
|
+
...Object.keys(workflows.graphMeta),
|
|
21
|
+
...Object.keys(workflows.meta),
|
|
22
|
+
]),
|
|
23
|
+
];
|
|
24
|
+
const hasRelevantWorkflows = allWorkflowNames.length > 0;
|
|
25
|
+
const hasWorkflows = hasRelevantWorkflows;
|
|
21
26
|
if (hasWorkflows) {
|
|
22
27
|
const hasWorkflowState = visitState.serviceAggregation.allSingletonServices.includes('workflowService');
|
|
23
28
|
if (!hasWorkflowState) {
|
|
@@ -45,11 +50,7 @@ export const pikkuWorkflow = pikkuSessionlessFunc({
|
|
|
45
50
|
const rpcMapImportPath = getFileImportRelativePath(workflowTypesFile, config.rpcInternalMapDeclarationFile, packageMappings);
|
|
46
51
|
const workflowMapImportPath = getFileImportRelativePath(workflowTypesFile, workflowMapDeclarationFile, packageMappings);
|
|
47
52
|
await writeFileInDir(logger, workflowTypesFile, serializeWorkflowTypes(functionTypesImportPath, rpcMapImportPath, workflowMapImportPath));
|
|
48
|
-
await writeFileInDir(logger, workflowMapDeclarationFile, serializeWorkflowMap(logger, workflowMapDeclarationFile, packageMappings, typesMap, functionState.meta, workflows.meta, workflows.graphMeta));
|
|
49
|
-
if (config.scaffold?.workflow) {
|
|
50
|
-
const pathToPikkuTypes = getFileImportRelativePath(config.workflowWorkersFile, typesDeclarationFile, packageMappings);
|
|
51
|
-
await writeFileInDir(logger, config.workflowWorkersFile, serializeWorkflowWorkers(pathToPikkuTypes));
|
|
52
|
-
}
|
|
53
|
+
await writeFileInDir(logger, workflowMapDeclarationFile, serializeWorkflowMap(logger, workflowMapDeclarationFile, packageMappings, typesMap, functionState.meta, workflows.meta, workflows.graphMeta, visitState.rpc?.wireAddonDeclarations));
|
|
53
54
|
return hasWorkflows;
|
|
54
55
|
},
|
|
55
56
|
middleware: [
|