@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,11 +1,18 @@
|
|
|
1
|
-
export const serializeAIAgentTypes = (functionTypesImportPath) => {
|
|
1
|
+
export const serializeAIAgentTypes = (functionTypesImportPath, agentMapImportPath) => {
|
|
2
2
|
return `import {
|
|
3
3
|
CoreAIAgent,
|
|
4
4
|
PikkuAIMiddlewareHooks,
|
|
5
5
|
} from '@pikku/core/ai-agent'
|
|
6
|
-
import
|
|
6
|
+
import {
|
|
7
|
+
agent as coreAgent,
|
|
8
|
+
agentStream as coreAgentStream,
|
|
9
|
+
agentResume as coreAgentResume,
|
|
10
|
+
agentApprove as coreAgentApprove,
|
|
11
|
+
} from '@pikku/core/ai-agent'
|
|
12
|
+
import type { PikkuPermission, PikkuMiddleware, Services, PikkuFunctionConfig } from '${functionTypesImportPath}'
|
|
7
13
|
import type { StandardSchemaV1 } from '@standard-schema/spec'
|
|
8
|
-
import type { AIAgentMemoryConfig } from '@pikku/core/ai-agent'
|
|
14
|
+
import type { AIAgentMemoryConfig, AIAgentInput } from '@pikku/core/ai-agent'
|
|
15
|
+
import type { AgentMap } from '${agentMapImportPath}'
|
|
9
16
|
|
|
10
17
|
type AIAgentConfig = Omit<CoreAIAgent<PikkuPermission, PikkuMiddleware>, 'tools' | 'agents' | 'memory'> & {
|
|
11
18
|
input?: StandardSchemaV1
|
|
@@ -27,5 +34,43 @@ export const pikkuAIMiddleware = <
|
|
|
27
34
|
>(
|
|
28
35
|
hooks: PikkuAIMiddlewareHooks<State, RequiredServices>
|
|
29
36
|
): PikkuAIMiddlewareHooks<State, RequiredServices> => hooks
|
|
37
|
+
|
|
38
|
+
export const agent = <Name extends keyof AgentMap>(
|
|
39
|
+
agentName: Name
|
|
40
|
+
) => {
|
|
41
|
+
return coreAgent<AgentMap>(agentName as string & keyof AgentMap) as PikkuFunctionConfig<
|
|
42
|
+
AIAgentInput,
|
|
43
|
+
{ runId: string; result: AgentMap[Name]['output']; usage: { inputTokens: number; outputTokens: number } },
|
|
44
|
+
'session' | 'rpc'
|
|
45
|
+
>
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const agentStream = <Name extends keyof AgentMap>(
|
|
49
|
+
agentName?: Name
|
|
50
|
+
) => {
|
|
51
|
+
return coreAgentStream<AgentMap>(agentName as string & keyof AgentMap) as PikkuFunctionConfig<
|
|
52
|
+
{ agentName?: string; message: string; threadId: string; resourceId: string },
|
|
53
|
+
void,
|
|
54
|
+
'session' | 'rpc'
|
|
55
|
+
>
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const agentResume = () => {
|
|
59
|
+
return coreAgentResume() as PikkuFunctionConfig<
|
|
60
|
+
{ runId: string; toolCallId: string; approved: boolean },
|
|
61
|
+
void,
|
|
62
|
+
'session' | 'rpc'
|
|
63
|
+
>
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const agentApprove = <Name extends keyof AgentMap>(
|
|
67
|
+
agentName: Name
|
|
68
|
+
) => {
|
|
69
|
+
return coreAgentApprove<AgentMap>(agentName as string & keyof AgentMap) as PikkuFunctionConfig<
|
|
70
|
+
{ runId: string; approvals: { toolCallId: string; approved: boolean }[] },
|
|
71
|
+
unknown,
|
|
72
|
+
'session' | 'rpc'
|
|
73
|
+
>
|
|
74
|
+
}
|
|
30
75
|
`;
|
|
31
76
|
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export const serializePublicAgent = (pathToPikkuTypes, requireAuth = true) => {
|
|
2
2
|
const authFlag = requireAuth ? 'true' : 'false';
|
|
3
|
-
return `import { pikkuSessionlessFunc,
|
|
4
|
-
import { streamAIAgent, approveAIAgent } from '@pikku/core/ai-agent'
|
|
5
|
-
import type { AIStreamChannel } from '@pikku/core/ai-agent'
|
|
3
|
+
return `import { pikkuSessionlessFunc, defineHTTPRoutes, wireHTTPRoutes } from '${pathToPikkuTypes}'
|
|
6
4
|
|
|
7
5
|
export const agentCaller = pikkuSessionlessFunc<
|
|
8
6
|
{ agentName: string; message: string; threadId: string; resourceId: string },
|
|
@@ -10,7 +8,7 @@ export const agentCaller = pikkuSessionlessFunc<
|
|
|
10
8
|
>({
|
|
11
9
|
auth: ${authFlag},
|
|
12
10
|
func: async (_services, data, { rpc }) => {
|
|
13
|
-
return await
|
|
11
|
+
return await rpc.agent.run(data.agentName as any, {
|
|
14
12
|
message: data.message,
|
|
15
13
|
threadId: data.threadId,
|
|
16
14
|
resourceId: data.resourceId,
|
|
@@ -23,13 +21,12 @@ export const agentStreamCaller = pikkuSessionlessFunc<
|
|
|
23
21
|
void
|
|
24
22
|
>({
|
|
25
23
|
auth: ${authFlag},
|
|
26
|
-
func: async (
|
|
27
|
-
await
|
|
28
|
-
data.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
)
|
|
24
|
+
func: async (_services, data, { rpc }) => {
|
|
25
|
+
await rpc.agent.stream(data.agentName as any, {
|
|
26
|
+
message: data.message,
|
|
27
|
+
threadId: data.threadId,
|
|
28
|
+
resourceId: data.resourceId,
|
|
29
|
+
})
|
|
33
30
|
},
|
|
34
31
|
})
|
|
35
32
|
|
|
@@ -38,53 +35,34 @@ export const agentApproveCaller = pikkuSessionlessFunc<
|
|
|
38
35
|
unknown
|
|
39
36
|
>({
|
|
40
37
|
auth: ${authFlag},
|
|
41
|
-
func: async (
|
|
42
|
-
|
|
43
|
-
throw new Error('AIRunStateService not available')
|
|
44
|
-
}
|
|
45
|
-
return await approveAIAgent(aiRunState, runId, approvals, agentName)
|
|
38
|
+
func: async (_services, { runId, approvals, agentName }, { rpc }) => {
|
|
39
|
+
return await rpc.agent.approve(runId, approvals, agentName)
|
|
46
40
|
},
|
|
47
41
|
})
|
|
48
42
|
|
|
49
|
-
|
|
50
|
-
route: '/rpc/agent/:agentName',
|
|
51
|
-
method: 'options',
|
|
52
|
-
tags: ['pikku:public'],
|
|
43
|
+
export const agentRoutes = defineHTTPRoutes({
|
|
53
44
|
auth: ${authFlag},
|
|
54
|
-
func: pikkuSessionlessFunc<{ agentName: string }>(async () => void 0),
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
wireHTTP({
|
|
58
|
-
route: '/rpc/agent/:agentName',
|
|
59
|
-
method: 'post',
|
|
60
45
|
tags: ['pikku:public'],
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
func: agentStreamCaller,
|
|
46
|
+
routes: {
|
|
47
|
+
agentRun: {
|
|
48
|
+
route: '/rpc/agent/:agentName',
|
|
49
|
+
method: 'post',
|
|
50
|
+
func: agentCaller,
|
|
51
|
+
},
|
|
52
|
+
agentStream: {
|
|
53
|
+
route: '/rpc/agent/:agentName/stream',
|
|
54
|
+
method: 'post',
|
|
55
|
+
sse: true,
|
|
56
|
+
func: agentStreamCaller,
|
|
57
|
+
},
|
|
58
|
+
agentApprove: {
|
|
59
|
+
route: '/rpc/agent/:agentName/approve',
|
|
60
|
+
method: 'post',
|
|
61
|
+
func: agentApproveCaller,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
80
64
|
})
|
|
81
65
|
|
|
82
|
-
|
|
83
|
-
route: '/rpc/agent/:agentName/approve',
|
|
84
|
-
method: 'post',
|
|
85
|
-
tags: ['pikku:public'],
|
|
86
|
-
auth: ${authFlag},
|
|
87
|
-
func: agentApproveCaller,
|
|
88
|
-
})
|
|
66
|
+
wireHTTPRoutes({ routes: { agent: agentRoutes } })
|
|
89
67
|
`;
|
|
90
68
|
};
|
|
@@ -15,7 +15,7 @@ export const pikkuChannels = pikkuVoidFunc({
|
|
|
15
15
|
const importStatement = supportsImportAttributes
|
|
16
16
|
? `import metaData from '${jsonImportPath}' with { type: 'json' }`
|
|
17
17
|
: `import metaData from '${jsonImportPath}'`;
|
|
18
|
-
await writeFileInDir(logger, channelsWiringMetaFile, `import { pikkuState } from '@pikku/core'\nimport { ChannelsMeta } from '@pikku/core/channel'\n${importStatement}\npikkuState(null, 'channel', 'meta', metaData as ChannelsMeta)`);
|
|
18
|
+
await writeFileInDir(logger, channelsWiringMetaFile, `import { pikkuState } from '@pikku/core/internal'\nimport { ChannelsMeta } from '@pikku/core/channel'\n${importStatement}\npikkuState(null, 'channel', 'meta', metaData as ChannelsMeta)`);
|
|
19
19
|
},
|
|
20
20
|
middleware: [
|
|
21
21
|
logCommandInfoAndTime({
|
|
@@ -5,9 +5,9 @@ import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-
|
|
|
5
5
|
import { serializeChannelTypes } from './serialize-channel-types.js';
|
|
6
6
|
export const pikkuChannelTypes = pikkuSessionlessFunc({
|
|
7
7
|
func: async ({ logger, config }) => {
|
|
8
|
-
const { channelsTypesFile, functionTypesFile, packageMappings,
|
|
8
|
+
const { channelsTypesFile, functionTypesFile, packageMappings, addonName } = config;
|
|
9
9
|
const functionTypesImportPath = getFileImportRelativePath(channelsTypesFile, functionTypesFile, packageMappings);
|
|
10
|
-
const content = serializeChannelTypes(functionTypesImportPath,
|
|
10
|
+
const content = serializeChannelTypes(functionTypesImportPath, addonName);
|
|
11
11
|
await writeFileInDir(logger, channelsTypesFile, content);
|
|
12
12
|
},
|
|
13
13
|
middleware: [
|
|
@@ -24,7 +24,7 @@ export const pikkuChannels = 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, channelsWiringMetaFile, `import { pikkuState } from '@pikku/core'\nimport type { ChannelsMeta } from '@pikku/core/channel'\n${importStatement}\npikkuState(null, 'channel', 'meta', metaData as ChannelsMeta)`);
|
|
27
|
+
await writeFileInDir(logger, channelsWiringMetaFile, `import { pikkuState } from '@pikku/core/internal'\nimport type { ChannelsMeta } from '@pikku/core/channel'\n${importStatement}\npikkuState(null, 'channel', 'meta', metaData as ChannelsMeta)`);
|
|
28
28
|
return true;
|
|
29
29
|
},
|
|
30
30
|
middleware: [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChannelsMeta } from '@pikku/core/channel';
|
|
2
|
-
import { TypesMap } from '@pikku/inspector';
|
|
3
|
-
import { FunctionsMeta } from '@pikku/core';
|
|
4
|
-
import { Logger } from '@pikku/core/services';
|
|
1
|
+
import type { ChannelsMeta } from '@pikku/core/channel';
|
|
2
|
+
import type { TypesMap } from '@pikku/inspector';
|
|
3
|
+
import type { FunctionsMeta } from '@pikku/core';
|
|
4
|
+
import type { Logger } from '@pikku/core/services';
|
|
5
5
|
export declare const serializeTypedChannelsMap: (logger: Logger, relativeToPath: string, packageMappings: Record<string, string>, typesMap: TypesMap, functionsMeta: FunctionsMeta, channelsMeta: ChannelsMeta) => string;
|
|
@@ -24,7 +24,7 @@ export const pikkuCLI = 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, cliWiringMetaFile, `import { pikkuState } from '@pikku/core'\nimport { CLIMeta } from '@pikku/core/cli'\n${importStatement}\npikkuState(null, 'cli', 'meta', metaData as CLIMeta)`);
|
|
27
|
+
await writeFileInDir(logger, cliWiringMetaFile, `import { pikkuState } from '@pikku/core/internal'\nimport { CLIMeta } from '@pikku/core/cli'\n${importStatement}\npikkuState(null, 'cli', 'meta', metaData as CLIMeta)`);
|
|
28
28
|
return true;
|
|
29
29
|
},
|
|
30
30
|
middleware: [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CLIProgramMeta } from '@pikku/core/cli';
|
|
2
|
-
import { Config } from '../../../../types/application-types.js';
|
|
1
|
+
import type { CLIProgramMeta } from '@pikku/core/cli';
|
|
2
|
+
import type { Config } from '../../../../types/application-types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Collect all unique renderer names from CLI metadata (populated by inspector)
|
|
5
5
|
*/
|
|
@@ -3,13 +3,12 @@ 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 { serializeConsoleFunctions } from './serialize-console-functions.js';
|
|
6
|
-
import { join } from 'path';
|
|
7
6
|
export const pikkuConsoleFunctions = pikkuSessionlessFunc({
|
|
8
7
|
func: async ({ logger, config }) => {
|
|
9
|
-
if (config.console
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
await writeFileInDir(logger,
|
|
8
|
+
if (config.scaffold?.console) {
|
|
9
|
+
const pathToPikkuTypes = getFileImportRelativePath(config.consoleFunctionsFile, config.typesDeclarationFile, config.packageMappings);
|
|
10
|
+
const pathToAgentTypes = getFileImportRelativePath(config.consoleFunctionsFile, config.agentTypesFile, config.packageMappings);
|
|
11
|
+
await writeFileInDir(logger, config.consoleFunctionsFile, serializeConsoleFunctions(pathToPikkuTypes, pathToAgentTypes));
|
|
13
12
|
return true;
|
|
14
13
|
}
|
|
15
14
|
return false;
|
|
@@ -19,7 +19,7 @@ const loadIcon = async (iconPath, rootDir, logger) => {
|
|
|
19
19
|
}
|
|
20
20
|
return trimmed.replace(/<\?xml[^?]*\?>\s*/g, '').trim();
|
|
21
21
|
}
|
|
22
|
-
catch
|
|
22
|
+
catch {
|
|
23
23
|
logger.warn(`Could not load icon: ${fullPath}`);
|
|
24
24
|
return undefined;
|
|
25
25
|
}
|
|
@@ -60,7 +60,7 @@ export const pikkuNodesMeta = pikkuSessionlessFunc({
|
|
|
60
60
|
categories: node?.categories,
|
|
61
61
|
},
|
|
62
62
|
};
|
|
63
|
-
if (nodesMetaJsonFile) {
|
|
63
|
+
if (nodesMetaJsonFile && config.scaffold?.console) {
|
|
64
64
|
const minimalMeta = stripVerboseFields(metaData);
|
|
65
65
|
await writeFileInDir(logger, nodesMetaJsonFile, JSON.stringify(minimalMeta, null, 2), { ignoreModifyComment: true });
|
|
66
66
|
if (hasVerboseFields(metaData)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const serializeConsoleFunctions: (pathToPikkuTypes: string) => string;
|
|
1
|
+
export declare const serializeConsoleFunctions: (pathToPikkuTypes: string, _pathToAgentTypes: string) => string;
|
|
@@ -1,66 +1,12 @@
|
|
|
1
|
-
export const serializeConsoleFunctions = (pathToPikkuTypes) => {
|
|
2
|
-
return `import { pikkuSessionlessFunc, defineHTTPRoutes, wireHTTPRoutes,
|
|
3
|
-
import { streamAIAgent, resumeAIAgent } from '@pikku/core/ai-agent'
|
|
4
|
-
import type { AIStreamChannel } from '@pikku/core/ai-agent'
|
|
1
|
+
export const serializeConsoleFunctions = (pathToPikkuTypes, _pathToAgentTypes) => {
|
|
2
|
+
return `import { pikkuSessionlessFunc, defineHTTPRoutes, wireHTTPRoutes, addon, wireAddon } from '${pathToPikkuTypes}'
|
|
5
3
|
|
|
6
|
-
export const
|
|
7
|
-
{ agentName: string; message: string; threadId: string; resourceId?: string },
|
|
8
|
-
any
|
|
9
|
-
>({
|
|
10
|
-
title: 'Stream Agent Run',
|
|
11
|
-
description: 'SSE stream of agent conversation responses.',
|
|
12
|
-
expose: false,
|
|
13
|
-
auth: false,
|
|
14
|
-
func: async (services, data, { channel }) => {
|
|
15
|
-
if (!channel) return
|
|
16
|
-
await streamAIAgent(
|
|
17
|
-
data.agentName,
|
|
18
|
-
{
|
|
19
|
-
message: data.message,
|
|
20
|
-
threadId: data.threadId,
|
|
21
|
-
resourceId: data.resourceId || 'console-playground',
|
|
22
|
-
},
|
|
23
|
-
channel as unknown as AIStreamChannel,
|
|
24
|
-
{ singletonServices: services }
|
|
25
|
-
)
|
|
26
|
-
},
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
export const resumeAgentRun = pikkuSessionlessFunc<
|
|
30
|
-
{
|
|
31
|
-
agentName: string
|
|
32
|
-
toolCallId: string
|
|
33
|
-
approved: boolean
|
|
34
|
-
},
|
|
35
|
-
any
|
|
36
|
-
>({
|
|
37
|
-
title: 'Resume Agent Run',
|
|
38
|
-
description: 'Resume an agent run after tool approval/denial.',
|
|
39
|
-
expose: false,
|
|
40
|
-
auth: false,
|
|
41
|
-
func: async (services, data, { channel }) => {
|
|
42
|
-
if (!channel) return
|
|
43
|
-
await resumeAIAgent(
|
|
44
|
-
{
|
|
45
|
-
toolCallId: data.toolCallId,
|
|
46
|
-
approved: data.approved,
|
|
47
|
-
},
|
|
48
|
-
channel as unknown as AIStreamChannel,
|
|
49
|
-
{ singletonServices: services }
|
|
50
|
-
)
|
|
51
|
-
},
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
export interface SetSecretInput {
|
|
4
|
+
export const pikkuConsoleSetSecret = pikkuSessionlessFunc<{
|
|
55
5
|
secretId: string
|
|
56
6
|
value: unknown
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface SetSecretOutput {
|
|
7
|
+
}, {
|
|
60
8
|
success: boolean
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export const setSecret = pikkuSessionlessFunc<SetSecretInput, SetSecretOutput>({
|
|
9
|
+
}>({
|
|
64
10
|
description: 'Set the value of a secret',
|
|
65
11
|
expose: true,
|
|
66
12
|
auth: false,
|
|
@@ -70,18 +16,9 @@ export const setSecret = pikkuSessionlessFunc<SetSecretInput, SetSecretOutput>({
|
|
|
70
16
|
},
|
|
71
17
|
})
|
|
72
18
|
|
|
73
|
-
export
|
|
74
|
-
variableId: string
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export interface GetVariableOutput {
|
|
78
|
-
exists: boolean
|
|
79
|
-
value: unknown | null
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export const getVariable = pikkuSessionlessFunc<
|
|
83
|
-
GetVariableInput,
|
|
84
|
-
GetVariableOutput
|
|
19
|
+
export const pikkuConsoleGetVariable = pikkuSessionlessFunc<
|
|
20
|
+
{ variableId: string },
|
|
21
|
+
{ exists: boolean; value: unknown | null }
|
|
85
22
|
>({
|
|
86
23
|
description: 'Get the current value of a variable',
|
|
87
24
|
expose: true,
|
|
@@ -101,18 +38,9 @@ export const getVariable = pikkuSessionlessFunc<
|
|
|
101
38
|
},
|
|
102
39
|
})
|
|
103
40
|
|
|
104
|
-
export
|
|
105
|
-
variableId: string
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export interface SetVariableOutput {
|
|
110
|
-
success: boolean
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export const setVariable = pikkuSessionlessFunc<
|
|
114
|
-
SetVariableInput,
|
|
115
|
-
SetVariableOutput
|
|
41
|
+
export const pikkuConsoleSetVariable = pikkuSessionlessFunc<
|
|
42
|
+
{ variableId: string; value: unknown },
|
|
43
|
+
{ success: boolean }
|
|
116
44
|
>({
|
|
117
45
|
description: 'Set the value of a variable',
|
|
118
46
|
expose: true,
|
|
@@ -127,18 +55,9 @@ export const setVariable = pikkuSessionlessFunc<
|
|
|
127
55
|
},
|
|
128
56
|
})
|
|
129
57
|
|
|
130
|
-
export
|
|
131
|
-
secretId: string
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export interface GetSecretOutput {
|
|
135
|
-
exists: boolean
|
|
136
|
-
value: unknown | null
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export const getSecret = pikkuSessionlessFunc<
|
|
140
|
-
GetSecretInput,
|
|
141
|
-
GetSecretOutput
|
|
58
|
+
export const pikkuConsoleGetSecret = pikkuSessionlessFunc<
|
|
59
|
+
{ secretId: string },
|
|
60
|
+
{ exists: boolean; value: unknown | null }
|
|
142
61
|
>({
|
|
143
62
|
description: 'Get the current value of a secret',
|
|
144
63
|
expose: true,
|
|
@@ -153,77 +72,19 @@ export const getSecret = pikkuSessionlessFunc<
|
|
|
153
72
|
},
|
|
154
73
|
})
|
|
155
74
|
|
|
156
|
-
export interface StartWorkflowRunInput {
|
|
157
|
-
workflowName: string
|
|
158
|
-
input?: any
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export interface StartWorkflowRunOutput {
|
|
162
|
-
runId: string
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export const startWorkflowRun = pikkuSessionlessFunc<
|
|
166
|
-
StartWorkflowRunInput,
|
|
167
|
-
StartWorkflowRunOutput
|
|
168
|
-
>({
|
|
169
|
-
title: 'Start Workflow Run',
|
|
170
|
-
description: 'Starts a new workflow run by name with optional input.',
|
|
171
|
-
expose: true,
|
|
172
|
-
auth: false,
|
|
173
|
-
func: async (_services, { workflowName, input }, { rpc }) => {
|
|
174
|
-
return await (rpc as any).startWorkflow(workflowName, input || {})
|
|
175
|
-
},
|
|
176
|
-
})
|
|
177
|
-
|
|
178
75
|
export const consoleRoutes = defineHTTPRoutes({
|
|
179
76
|
auth: false,
|
|
180
77
|
routes: {
|
|
181
|
-
externalIconOptions: {
|
|
182
|
-
route: '/external/icon/:alias',
|
|
183
|
-
method: 'options',
|
|
184
|
-
func: pikkuSessionlessFunc<{ alias: string }>(async () => void 0),
|
|
185
|
-
},
|
|
186
|
-
externalIcon: {
|
|
187
|
-
route: '/external/icon/:alias',
|
|
188
|
-
method: 'get',
|
|
189
|
-
func: external('console:getExternalIcon'),
|
|
190
|
-
},
|
|
191
|
-
agentStreamOptions: {
|
|
192
|
-
route: '/api/agents/:agentName/stream',
|
|
193
|
-
method: 'options',
|
|
194
|
-
func: pikkuSessionlessFunc<{ agentName: string }>(async () => void 0),
|
|
195
|
-
},
|
|
196
|
-
agentStream: {
|
|
197
|
-
route: '/api/agents/:agentName/stream',
|
|
198
|
-
method: 'post',
|
|
199
|
-
sse: true,
|
|
200
|
-
func: streamAgentRun,
|
|
201
|
-
},
|
|
202
|
-
agentResumeOptions: {
|
|
203
|
-
route: '/api/agents/:agentName/resume',
|
|
204
|
-
method: 'options',
|
|
205
|
-
func: pikkuSessionlessFunc<{ agentName: string }>(async () => void 0),
|
|
206
|
-
},
|
|
207
|
-
agentResume: {
|
|
208
|
-
route: '/api/agents/:agentName/resume',
|
|
209
|
-
method: 'post',
|
|
210
|
-
sse: true,
|
|
211
|
-
func: resumeAgentRun,
|
|
212
|
-
},
|
|
213
|
-
workflowRunStreamOptions: {
|
|
214
|
-
route: '/api/workflow-run/:runId/stream',
|
|
215
|
-
method: 'options',
|
|
216
|
-
func: pikkuSessionlessFunc<{ runId: string }>(async () => void 0),
|
|
217
|
-
},
|
|
218
78
|
workflowRunStream: {
|
|
219
|
-
route: '/
|
|
79
|
+
route: '/workflow-run/:runId/stream',
|
|
220
80
|
method: 'get',
|
|
221
81
|
sse: true,
|
|
222
|
-
func:
|
|
82
|
+
func: addon('console:streamWorkflowRun'),
|
|
223
83
|
},
|
|
224
84
|
},
|
|
225
85
|
})
|
|
226
86
|
|
|
227
|
-
|
|
87
|
+
wireAddon({ name: 'console', package: '@pikku/addon-console' })
|
|
88
|
+
wireHTTPRoutes({ baseRoute: '/api', routes: { console: consoleRoutes } })
|
|
228
89
|
`;
|
|
229
90
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const pikkuAddonTypes: 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>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { pikkuSessionlessFunc } from '#pikku';
|
|
2
|
+
import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
|
|
3
|
+
import { checkRequiredTypes } from '../../../utils/check-required-types.js';
|
|
4
|
+
import { writeFileInDir } from '../../../utils/file-writer.js';
|
|
5
|
+
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js';
|
|
6
|
+
import { serializeAddonTypes } from './serialize-addon-types.js';
|
|
7
|
+
export const pikkuAddonTypes = pikkuSessionlessFunc({
|
|
8
|
+
func: async ({ logger, config, getInspectorState }) => {
|
|
9
|
+
if (!config.addon) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const visitState = await getInspectorState();
|
|
13
|
+
const { addonTypesFile, packageMappings, servicesFile, secretsFile, variablesFile, } = config;
|
|
14
|
+
checkRequiredTypes(visitState.filesAndMethodsErrors, {
|
|
15
|
+
singletonServicesType: true,
|
|
16
|
+
});
|
|
17
|
+
const { singletonServicesType, pikkuConfigType } = visitState.filesAndMethods;
|
|
18
|
+
if (!singletonServicesType) {
|
|
19
|
+
throw new Error('Required types not found');
|
|
20
|
+
}
|
|
21
|
+
const configTypeImport = pikkuConfigType
|
|
22
|
+
? `import type { ${pikkuConfigType.type} } from '${getFileImportRelativePath(addonTypesFile, pikkuConfigType.typePath, packageMappings)}'`
|
|
23
|
+
: '// Config type not found, will use fallback';
|
|
24
|
+
const content = serializeAddonTypes(`import type { ${singletonServicesType.type} } from '${getFileImportRelativePath(addonTypesFile, singletonServicesType.typePath, packageMappings)}'`, singletonServicesType.type, configTypeImport, `import type { RequiredSingletonServices } from '${getFileImportRelativePath(addonTypesFile, servicesFile, packageMappings)}'`, `import { TypedSecretService } from '${getFileImportRelativePath(addonTypesFile, secretsFile, packageMappings)}'`, `import { TypedVariablesService } from '${getFileImportRelativePath(addonTypesFile, variablesFile, packageMappings)}'`);
|
|
25
|
+
await writeFileInDir(logger, addonTypesFile, content);
|
|
26
|
+
},
|
|
27
|
+
middleware: [
|
|
28
|
+
logCommandInfoAndTime({
|
|
29
|
+
commandStart: 'Creating addon types',
|
|
30
|
+
commandEnd: 'Created addon types',
|
|
31
|
+
}),
|
|
32
|
+
],
|
|
33
|
+
});
|
|
@@ -21,7 +21,7 @@ export const pikkuFunctionTypesSplit = pikkuSessionlessFunc({
|
|
|
21
21
|
const configTypeImport = pikkuConfigType
|
|
22
22
|
? `import type { ${pikkuConfigType.type} } from '${getFileImportRelativePath(functionTypesFile, pikkuConfigType.typePath, packageMappings)}'`
|
|
23
23
|
: '// Config type not found, will use fallback';
|
|
24
|
-
const content = serializeFunctionTypes(`import type { ${userSessionType.type} } from '${getFileImportRelativePath(functionTypesFile, userSessionType.typePath, packageMappings)}'`, userSessionType.type, `import type { ${singletonServicesType.type} } from '${getFileImportRelativePath(functionTypesFile, singletonServicesType.typePath, packageMappings)}'`, singletonServicesType.type, `import type { ${wireServicesType.type} } from '${getFileImportRelativePath(functionTypesFile, wireServicesType.typePath, packageMappings)}'`, wireServicesType.type, `import type { TypedPikkuRPC, FlattenedRPCMap } from '${getFileImportRelativePath(functionTypesFile, rpcInternalMapDeclarationFile, packageMappings)}'`, `import type { RequiredSingletonServices, RequiredWireServices } from '${getFileImportRelativePath(functionTypesFile, servicesFile, packageMappings)}'`, configTypeImport, config.
|
|
24
|
+
const content = serializeFunctionTypes(`import type { ${userSessionType.type} } from '${getFileImportRelativePath(functionTypesFile, userSessionType.typePath, packageMappings)}'`, userSessionType.type, `import type { ${singletonServicesType.type} } from '${getFileImportRelativePath(functionTypesFile, singletonServicesType.typePath, packageMappings)}'`, singletonServicesType.type, `import type { ${wireServicesType.type} } from '${getFileImportRelativePath(functionTypesFile, wireServicesType.typePath, packageMappings)}'`, wireServicesType.type, `import type { TypedPikkuRPC, FlattenedRPCMap } from '${getFileImportRelativePath(functionTypesFile, rpcInternalMapDeclarationFile, packageMappings)}'`, `import type { RequiredSingletonServices, RequiredWireServices } from '${getFileImportRelativePath(functionTypesFile, servicesFile, packageMappings)}'`, configTypeImport, config.addonName, undefined, config.node?.categories);
|
|
25
25
|
await writeFileInDir(logger, functionTypesFile, content);
|
|
26
26
|
},
|
|
27
27
|
middleware: [
|
|
@@ -5,13 +5,13 @@ import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-
|
|
|
5
5
|
import { serializePikkuTypesHub } from './serialize-pikku-types-hub.js';
|
|
6
6
|
export const pikkuFunctionTypes = pikkuSessionlessFunc({
|
|
7
7
|
func: async ({ logger, config }) => {
|
|
8
|
-
const { typesDeclarationFile: typesFile, packageMappings, functionTypesFile, httpTypesFile, channelsTypesFile, triggersTypesFile, schedulersTypesFile, queueTypesFile, mcpTypesFile, cliTypesFile, nodeTypesFile, secretTypesFile,
|
|
9
|
-
const getImportPath = (file) => config.
|
|
8
|
+
const { typesDeclarationFile: typesFile, packageMappings, functionTypesFile, httpTypesFile, channelsTypesFile, triggersTypesFile, schedulersTypesFile, queueTypesFile, mcpTypesFile, cliTypesFile, nodeTypesFile, secretTypesFile, addonTypesFile, } = config;
|
|
9
|
+
const getImportPath = (file) => config.addon
|
|
10
10
|
? null
|
|
11
11
|
: getFileImportRelativePath(typesFile, file, packageMappings);
|
|
12
|
-
// Node and trigger types are included for
|
|
12
|
+
// Node and trigger types are included for addon packages
|
|
13
13
|
const getAlwaysImportPath = (file) => getFileImportRelativePath(typesFile, file, packageMappings);
|
|
14
|
-
const content = serializePikkuTypesHub(getFileImportRelativePath(typesFile, functionTypesFile, packageMappings), getImportPath(httpTypesFile), getImportPath(channelsTypesFile), getAlwaysImportPath(triggersTypesFile), getImportPath(schedulersTypesFile), getImportPath(queueTypesFile), getImportPath(mcpTypesFile), getImportPath(cliTypesFile), getAlwaysImportPath(nodeTypesFile), getAlwaysImportPath(secretTypesFile), config.
|
|
14
|
+
const content = serializePikkuTypesHub(getFileImportRelativePath(typesFile, functionTypesFile, packageMappings), getImportPath(httpTypesFile), getImportPath(channelsTypesFile), getAlwaysImportPath(triggersTypesFile), getImportPath(schedulersTypesFile), getImportPath(queueTypesFile), getImportPath(mcpTypesFile), getImportPath(cliTypesFile), getAlwaysImportPath(nodeTypesFile), getAlwaysImportPath(secretTypesFile), config.addon ? getAlwaysImportPath(addonTypesFile) : null);
|
|
15
15
|
await writeFileInDir(logger, typesFile, content);
|
|
16
16
|
},
|
|
17
17
|
middleware: [
|
|
@@ -21,24 +21,18 @@ export const pikkuFunctions = pikkuSessionlessFunc({
|
|
|
21
21
|
const importStatement = supportsImportAttributes
|
|
22
22
|
? `import metaData from '${jsonImportPath}' with { type: 'json' }`
|
|
23
23
|
: `import metaData from '${jsonImportPath}'`;
|
|
24
|
-
const packageName = config.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
await writeFileInDir(logger, functionsMetaFile, `import { pikkuState, FunctionsMeta } from '@pikku/core'\n${importStatement}\npikkuState(${packageName}, 'function', 'meta', metaData as FunctionsMeta)`);
|
|
28
|
-
// For external packages, register ALL functions (they'll be invoked by consumers)
|
|
24
|
+
const packageName = config.addonName ? `'${config.addonName}'` : 'null';
|
|
25
|
+
await writeFileInDir(logger, functionsMetaFile, `import { pikkuState } from '@pikku/core/internal'\nimport type { FunctionsMeta } from '@pikku/core'\n${importStatement}\npikkuState(${packageName}, 'function', 'meta', metaData as FunctionsMeta)`);
|
|
26
|
+
// For addon packages, register ALL functions (they'll be invoked by consumers)
|
|
29
27
|
// For main packages, only register functions that are invoked via internal RPCs
|
|
30
|
-
const
|
|
28
|
+
const isAddon = !!config.addonName;
|
|
31
29
|
const hasRPCs = rpc.exposedFiles.size > 0 || rpc.internalFiles.size > 0;
|
|
32
30
|
const hasFunctions = functions.files.size > 0;
|
|
33
|
-
const shouldGenerateFunctionsFile =
|
|
34
|
-
? hasFunctions
|
|
35
|
-
: hasRPCs;
|
|
31
|
+
const shouldGenerateFunctionsFile = isAddon ? hasFunctions : hasRPCs;
|
|
36
32
|
if (shouldGenerateFunctionsFile) {
|
|
37
|
-
// For
|
|
38
|
-
const filesToRegister =
|
|
39
|
-
|
|
40
|
-
: rpc.internalFiles;
|
|
41
|
-
await writeFileInDir(logger, functionsFile, serializeFunctionImports(functionsFile, filesToRegister, functions.meta, packageMappings, config.externalPackageName));
|
|
33
|
+
// For addon packages, use all function files; for main packages, use internal RPC files
|
|
34
|
+
const filesToRegister = isAddon ? functions.files : rpc.internalFiles;
|
|
35
|
+
await writeFileInDir(logger, functionsFile, serializeFunctionImports(functionsFile, filesToRegister, functions.meta, packageMappings, config.addonName));
|
|
42
36
|
}
|
|
43
37
|
return shouldGenerateFunctionsFile;
|
|
44
38
|
},
|
|
@@ -7,7 +7,7 @@ export const pikkuSchemas = pikkuSessionlessFunc({
|
|
|
7
7
|
if (Object.keys(visitState.schemas).length === 0) {
|
|
8
8
|
return undefined;
|
|
9
9
|
}
|
|
10
|
-
await saveSchemas(logger, config.schemaDirectory, visitState.schemas, visitState.requiredSchemas, config.schema?.supportsImportAttributes ?? true, config.
|
|
10
|
+
await saveSchemas(logger, config.schemaDirectory, visitState.schemas, visitState.requiredSchemas, config.schema?.supportsImportAttributes ?? true, config.addonName || null);
|
|
11
11
|
return true;
|
|
12
12
|
},
|
|
13
13
|
middleware: [
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const serializeAddonTypes: (singletonServicesTypeImport: string, singletonServicesTypeName: string, configTypeImport: string, requiredServicesTypeImport: string, typedSecretServiceImport: string, typedVariablesServiceImport: string) => string;
|