@pikku/core 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/CHANGELOG.md +40 -0
- package/dist/errors/errors.d.ts +6 -0
- package/dist/errors/errors.js +10 -0
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.js +1 -0
- package/dist/function/function-runner.d.ts +3 -3
- package/dist/function/function-runner.js +66 -44
- package/dist/function/functions.types.d.ts +1 -0
- package/dist/handle-error.d.ts +2 -2
- package/dist/handle-error.js +2 -2
- package/dist/index.d.ts +5 -3
- package/dist/index.js +2 -1
- package/dist/internal.d.ts +3 -0
- package/dist/internal.js +2 -0
- package/dist/middleware/auth-bearer.d.ts +1 -1
- package/dist/middleware/auth-bearer.js +1 -1
- package/dist/middleware/auth-cookie.d.ts +2 -2
- package/dist/middleware/auth-cookie.js +1 -1
- package/dist/middleware/cors.d.ts +2 -2
- package/dist/middleware/cors.js +45 -37
- package/dist/middleware-runner.d.ts +1 -1
- package/dist/middleware-runner.js +1 -0
- package/dist/permissions.d.ts +2 -2
- package/dist/permissions.js +1 -0
- package/dist/pikku-state.d.ts +9 -8
- package/dist/pikku-state.js +34 -17
- package/dist/schema.d.ts +4 -4
- package/dist/schema.js +9 -5
- package/dist/services/ai-agent-runner-service.d.ts +22 -3
- package/dist/services/ai-run-state-service.d.ts +1 -1
- package/dist/services/ai-storage-service.d.ts +1 -1
- package/dist/services/content-service.d.ts +6 -0
- package/dist/services/gateway-service.d.ts +19 -0
- package/dist/services/gopass-secrets.d.ts +1 -1
- package/dist/services/gopass-secrets.js +3 -0
- package/dist/services/in-memory-ai-run-state-service.d.ts +15 -0
- package/dist/services/in-memory-ai-run-state-service.js +44 -0
- package/dist/services/in-memory-trigger-service.d.ts +0 -1
- package/dist/services/in-memory-trigger-service.js +6 -8
- package/dist/services/index.d.ts +5 -2
- package/dist/services/index.js +2 -0
- package/dist/services/local-content.d.ts +2 -1
- package/dist/services/local-content.js +6 -1
- package/dist/services/local-gateway-service.d.ts +22 -0
- package/dist/services/local-gateway-service.js +51 -0
- package/dist/services/local-secrets.d.ts +2 -2
- package/dist/services/local-variables.d.ts +1 -1
- package/dist/services/logger-console.d.ts +2 -1
- package/dist/services/scheduler-service.d.ts +0 -12
- package/dist/services/scheduler-service.js +0 -6
- package/dist/services/scoped-secret-service.d.ts +1 -1
- package/dist/services/trigger-service.d.ts +0 -7
- package/dist/services/user-session-service.d.ts +3 -3
- package/dist/services/workflow-service.d.ts +2 -3
- package/dist/types/core.types.d.ts +27 -19
- package/dist/types/state.types.d.ts +22 -15
- package/dist/utils.d.ts +5 -5
- package/dist/utils.js +12 -9
- package/dist/wirings/ai-agent/ai-agent-assistant-ui.d.ts +5 -0
- package/dist/wirings/ai-agent/ai-agent-assistant-ui.js +168 -0
- package/dist/wirings/ai-agent/ai-agent-helpers.d.ts +28 -0
- package/dist/wirings/ai-agent/ai-agent-helpers.js +40 -0
- package/dist/wirings/ai-agent/ai-agent-memory.js +13 -2
- package/dist/wirings/ai-agent/ai-agent-prepare.d.ts +4 -5
- package/dist/wirings/ai-agent/ai-agent-prepare.js +80 -31
- package/dist/wirings/ai-agent/ai-agent-registry.d.ts +1 -1
- package/dist/wirings/ai-agent/ai-agent-runner.js +107 -8
- package/dist/wirings/ai-agent/ai-agent-stream.d.ts +2 -1
- package/dist/wirings/ai-agent/ai-agent-stream.js +263 -89
- package/dist/wirings/ai-agent/ai-agent.types.d.ts +96 -4
- package/dist/wirings/ai-agent/index.d.ts +3 -1
- package/dist/wirings/ai-agent/index.js +2 -0
- package/dist/wirings/channel/channel-common.d.ts +2 -2
- package/dist/wirings/channel/channel-handler.d.ts +7 -4
- package/dist/wirings/channel/channel-handler.js +15 -5
- package/dist/wirings/channel/channel-middleware-runner.js +1 -0
- package/dist/wirings/channel/channel-runner.d.ts +5 -5
- package/dist/wirings/channel/channel-runner.js +3 -2
- package/dist/wirings/channel/channel-store.d.ts +1 -1
- package/dist/wirings/channel/channel.types.d.ts +10 -6
- package/dist/wirings/channel/index.d.ts +1 -1
- package/dist/wirings/channel/local/local-channel-handler.d.ts +7 -0
- package/dist/wirings/channel/local/local-channel-handler.js +17 -0
- package/dist/wirings/channel/local/local-channel-runner.d.ts +7 -2
- package/dist/wirings/channel/local/local-channel-runner.js +18 -4
- package/dist/wirings/channel/local/local-eventhub-service.d.ts +2 -2
- package/dist/wirings/channel/log-channels.d.ts +1 -1
- package/dist/wirings/channel/pikku-abstract-channel-handler.d.ts +2 -1
- package/dist/wirings/channel/pikku-abstract-channel-handler.js +1 -0
- package/dist/wirings/channel/serverless/serverless-channel-runner.d.ts +4 -4
- package/dist/wirings/channel/serverless/serverless-channel-runner.js +26 -20
- package/dist/wirings/cli/channel/cli-channel-runner.d.ts +1 -1
- package/dist/wirings/cli/cli-runner.d.ts +2 -2
- package/dist/wirings/cli/cli-runner.js +3 -0
- package/dist/wirings/cli/cli.types.d.ts +3 -3
- package/dist/wirings/cli/command-parser.d.ts +1 -1
- package/dist/wirings/gateway/gateway-runner.d.ts +24 -0
- package/dist/wirings/gateway/gateway-runner.js +325 -0
- package/dist/wirings/gateway/gateway.types.d.ts +127 -0
- package/dist/wirings/gateway/index.d.ts +2 -0
- package/dist/wirings/gateway/index.js +1 -0
- package/dist/wirings/http/http-runner.d.ts +9 -9
- package/dist/wirings/http/http-runner.js +36 -14
- package/dist/wirings/http/http.types.d.ts +2 -6
- package/dist/wirings/http/log-http-routes.d.ts +1 -1
- package/dist/wirings/http/pikku-fetch-http-request.d.ts +1 -1
- package/dist/wirings/http/pikku-fetch-http-response.d.ts +2 -2
- package/dist/wirings/http/pikku-fetch-http-response.js +6 -1
- package/dist/wirings/http/routers/http-router.d.ts +1 -1
- package/dist/wirings/http/routers/path-to-regex.d.ts +2 -2
- package/dist/wirings/mcp/mcp-endpoint-registry.d.ts +1 -1
- package/dist/wirings/mcp/mcp-runner.d.ts +0 -3
- package/dist/wirings/mcp/mcp-runner.js +4 -2
- package/dist/wirings/mcp/mcp.types.d.ts +2 -2
- package/dist/wirings/oauth2/oauth2-client.d.ts +3 -3
- package/dist/wirings/oauth2/wire-oauth2-credential.d.ts +1 -1
- package/dist/wirings/queue/index.d.ts +1 -1
- package/dist/wirings/queue/index.js +1 -1
- package/dist/wirings/queue/queue-runner.d.ts +1 -12
- package/dist/wirings/queue/queue-runner.js +4 -12
- package/dist/wirings/queue/queue.types.d.ts +3 -9
- package/dist/wirings/queue/register-queue-helper.d.ts +2 -2
- package/dist/wirings/queue/register-queue-helper.js +1 -1
- package/dist/wirings/queue/validate-worker-config.d.ts +1 -1
- package/dist/wirings/rpc/index.d.ts +2 -0
- package/dist/wirings/rpc/index.js +1 -0
- package/dist/wirings/rpc/rpc-runner.d.ts +36 -14
- package/dist/wirings/rpc/rpc-runner.js +56 -28
- package/dist/wirings/rpc/rpc-types.d.ts +14 -2
- package/dist/wirings/rpc/wire-addon.d.ts +10 -0
- package/dist/wirings/rpc/wire-addon.js +9 -0
- package/dist/wirings/scheduler/index.d.ts +1 -1
- package/dist/wirings/scheduler/index.js +1 -1
- package/dist/wirings/scheduler/log-schedulers.d.ts +1 -1
- package/dist/wirings/scheduler/scheduler-runner.d.ts +3 -10
- package/dist/wirings/scheduler/scheduler-runner.js +4 -25
- package/dist/wirings/scheduler/scheduler.types.d.ts +2 -2
- package/dist/wirings/trigger/pikku-trigger-service.d.ts +2 -6
- package/dist/wirings/trigger/pikku-trigger-service.js +11 -16
- package/dist/wirings/trigger/trigger-runner.d.ts +1 -5
- package/dist/wirings/trigger/trigger-runner.js +4 -3
- package/dist/wirings/workflow/pikku-workflow-service.d.ts +2 -6
- package/dist/wirings/workflow/pikku-workflow-service.js +20 -29
- package/dist/wirings/workflow/workflow.types.d.ts +2 -2
- package/package.json +4 -2
- package/src/crypto-utils.test.ts +116 -0
- package/src/errors/error.test.ts +143 -2
- package/src/errors/errors.ts +10 -0
- package/src/errors/index.ts +1 -0
- package/src/function/function-runner.test.ts +2 -2
- package/src/function/function-runner.ts +72 -49
- package/src/function/functions.types.ts +1 -0
- package/src/handle-error.test.ts +361 -0
- package/src/handle-error.ts +4 -4
- package/src/index.ts +3 -10
- package/src/internal.ts +6 -0
- package/src/middleware/auth-apikey.test.ts +1 -1
- package/src/middleware/auth-bearer.test.ts +1 -1
- package/src/middleware/auth-bearer.ts +2 -5
- package/src/middleware/auth-cookie.test.ts +1 -1
- package/src/middleware/auth-cookie.ts +3 -5
- package/src/middleware/cors.test.ts +424 -0
- package/src/middleware/cors.ts +14 -6
- package/src/middleware/remote-auth.test.ts +488 -0
- package/src/middleware-runner.test.ts +1 -1
- package/src/middleware-runner.ts +2 -1
- package/src/permissions.test.ts +2 -2
- package/src/permissions.ts +3 -2
- package/src/pikku-state.test.ts +224 -0
- package/src/pikku-state.ts +45 -28
- package/src/schema.test.ts +198 -6
- package/src/schema.ts +11 -7
- package/src/services/ai-agent-runner-service.ts +15 -3
- package/src/services/ai-run-state-service.ts +1 -1
- package/src/services/ai-storage-service.ts +1 -1
- package/src/services/content-service.ts +7 -0
- package/src/services/gateway-service.ts +20 -0
- package/src/services/gopass-secrets.ts +4 -1
- package/src/services/in-memory-ai-run-state-service.ts +73 -0
- package/src/services/in-memory-trigger-service.ts +6 -10
- package/src/services/in-memory-workflow-service.test.ts +351 -0
- package/src/services/index.ts +4 -1
- package/src/services/local-content.ts +9 -3
- package/src/services/local-gateway-service.ts +62 -0
- package/src/services/local-secrets.test.ts +80 -0
- package/src/services/local-secrets.ts +2 -2
- package/src/services/local-variables.test.ts +61 -0
- package/src/services/local-variables.ts +1 -1
- package/src/services/logger-console.test.ts +118 -0
- package/src/services/logger-console.ts +2 -1
- package/src/services/scheduler-service.ts +0 -18
- package/src/services/scoped-secret-service.test.ts +74 -0
- package/src/services/scoped-secret-service.ts +1 -1
- package/src/services/trigger-service.ts +0 -21
- package/src/services/typed-secret-service.test.ts +93 -0
- package/src/services/typed-variables-service.test.ts +73 -0
- package/src/services/user-session-service.test.ts +113 -0
- package/src/services/user-session-service.ts +3 -3
- package/src/services/workflow-service.ts +2 -12
- package/src/time-utils.test.ts +1 -1
- package/src/types/core.types.ts +28 -19
- package/src/types/state.types.ts +32 -15
- package/src/utils.test.ts +350 -0
- package/src/utils.ts +14 -13
- package/src/wirings/ai-agent/ai-agent-assistant-ui.test.ts +363 -0
- package/src/wirings/ai-agent/ai-agent-assistant-ui.ts +238 -0
- package/src/wirings/ai-agent/ai-agent-helpers.test.ts +152 -0
- package/src/wirings/ai-agent/ai-agent-helpers.ts +76 -0
- package/src/wirings/ai-agent/ai-agent-memory.ts +10 -1
- package/src/wirings/ai-agent/ai-agent-model-config.test.ts +115 -0
- package/src/wirings/ai-agent/ai-agent-prepare.ts +98 -46
- package/src/wirings/ai-agent/ai-agent-registry.ts +1 -1
- package/src/wirings/ai-agent/ai-agent-runner.test.ts +245 -3
- package/src/wirings/ai-agent/ai-agent-runner.ts +121 -7
- package/src/wirings/ai-agent/ai-agent-stream.test.ts +430 -24
- package/src/wirings/ai-agent/ai-agent-stream.ts +390 -104
- package/src/wirings/ai-agent/ai-agent.types.ts +91 -4
- package/src/wirings/ai-agent/index.ts +13 -0
- package/src/wirings/channel/channel-common.ts +2 -2
- package/src/wirings/channel/channel-handler.ts +43 -11
- package/src/wirings/channel/channel-middleware-runner.ts +1 -0
- package/src/wirings/channel/channel-runner.ts +6 -6
- package/src/wirings/channel/channel-store.ts +1 -1
- package/src/wirings/channel/channel.types.ts +15 -8
- package/src/wirings/channel/index.ts +1 -0
- package/src/wirings/channel/local/local-channel-handler.ts +26 -0
- package/src/wirings/channel/local/local-channel-runner.test.ts +19 -12
- package/src/wirings/channel/local/local-channel-runner.ts +33 -14
- package/src/wirings/channel/local/local-eventhub-service.test.ts +2 -2
- package/src/wirings/channel/local/local-eventhub-service.ts +2 -2
- package/src/wirings/channel/log-channels.ts +1 -1
- package/src/wirings/channel/pikku-abstract-channel-handler.test.ts +2 -0
- package/src/wirings/channel/pikku-abstract-channel-handler.ts +8 -1
- package/src/wirings/channel/serverless/serverless-channel-runner.ts +38 -33
- package/src/wirings/cli/channel/cli-channel-runner.ts +1 -1
- package/src/wirings/cli/cli-runner.test.ts +1 -1
- package/src/wirings/cli/cli-runner.ts +14 -4
- package/src/wirings/cli/cli.types.ts +3 -3
- package/src/wirings/cli/command-parser.test.ts +1 -1
- package/src/wirings/cli/command-parser.ts +1 -1
- package/src/wirings/gateway/gateway-runner.test.ts +474 -0
- package/src/wirings/gateway/gateway-runner.ts +411 -0
- package/src/wirings/gateway/gateway.types.ts +149 -0
- package/src/wirings/gateway/index.ts +13 -0
- package/src/wirings/http/http-routes.test.ts +1 -1
- package/src/wirings/http/http-runner.test.ts +9 -17
- package/src/wirings/http/http-runner.ts +46 -27
- package/src/wirings/http/http.types.ts +1 -14
- package/src/wirings/http/log-http-routes.ts +1 -1
- package/src/wirings/http/pikku-fetch-http-request.ts +1 -1
- package/src/wirings/http/pikku-fetch-http-response.ts +12 -5
- package/src/wirings/http/routers/http-router.ts +1 -1
- package/src/wirings/http/routers/path-to-regex.test.ts +1 -1
- package/src/wirings/http/routers/path-to-regex.ts +4 -3
- package/src/wirings/mcp/mcp-endpoint-registry.ts +5 -1
- package/src/wirings/mcp/mcp-runner.ts +9 -15
- package/src/wirings/mcp/mcp.types.ts +2 -2
- package/src/wirings/oauth2/oauth2-client.ts +3 -3
- package/src/wirings/oauth2/wire-oauth2-credential.ts +1 -1
- package/src/wirings/queue/index.ts +0 -1
- package/src/wirings/queue/queue-runner.test.ts +52 -25
- package/src/wirings/queue/queue-runner.ts +8 -30
- package/src/wirings/queue/queue.types.ts +3 -13
- package/src/wirings/queue/register-queue-helper.ts +3 -5
- package/src/wirings/queue/validate-worker-config.test.ts +108 -0
- package/src/wirings/queue/validate-worker-config.ts +4 -1
- package/src/wirings/rpc/index.ts +2 -0
- package/src/wirings/rpc/rpc-runner.ts +92 -49
- package/src/wirings/rpc/rpc-types.ts +17 -2
- package/src/wirings/rpc/wire-addon.ts +20 -0
- package/src/wirings/scheduler/index.ts +0 -1
- package/src/wirings/scheduler/log-schedulers.ts +1 -1
- package/src/wirings/scheduler/scheduler-runner.test.ts +49 -60
- package/src/wirings/scheduler/scheduler-runner.ts +9 -56
- package/src/wirings/scheduler/scheduler.types.ts +2 -2
- package/src/wirings/secret/validate-secret-definitions.test.ts +140 -0
- package/src/wirings/trigger/pikku-trigger-service.ts +17 -39
- package/src/wirings/trigger/trigger-runner.test.ts +79 -0
- package/src/wirings/trigger/trigger-runner.ts +8 -11
- package/src/wirings/variable/validate-variable-definitions.test.ts +91 -0
- package/src/wirings/workflow/graph/graph-runner.test.ts +14 -22
- package/src/wirings/workflow/graph/template.test.ts +49 -0
- package/src/wirings/workflow/pikku-workflow-service.test.ts +15 -27
- package/src/wirings/workflow/pikku-workflow-service.ts +29 -45
- package/src/wirings/workflow/workflow-helpers.test.ts +129 -0
- package/src/wirings/workflow/workflow.types.ts +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/src/wirings/workflow/workflow-utils.ts +0 -0
- /package/dist/{wirings/workflow/workflow-utils.d.ts → services/gateway-service.js} +0 -0
- /package/dist/wirings/{workflow/workflow-utils.js → gateway/gateway.types.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SerializedError
|
|
2
|
-
import { WorkflowRun, WorkflowRunWire, StepState, WorkflowStatus } from '../wirings/workflow/workflow.types.js';
|
|
1
|
+
import type { SerializedError } from '../types/core.types.js';
|
|
2
|
+
import type { WorkflowRun, WorkflowRunWire, StepState, WorkflowStatus } from '../wirings/workflow/workflow.types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Interface for workflow orchestration
|
|
5
5
|
* Handles workflow execution, replay, orchestration logic, and run-level state
|
|
@@ -14,7 +14,6 @@ export interface WorkflowService {
|
|
|
14
14
|
withRunLock<T>(id: string, fn: () => Promise<T>): Promise<T>;
|
|
15
15
|
close(): Promise<void>;
|
|
16
16
|
resumeWorkflow(runId: string): Promise<void>;
|
|
17
|
-
setServices(singletonServices: CoreSingletonServices, createWireServices: CreateWireServices | undefined, config: CoreConfig): void;
|
|
18
17
|
startWorkflow<I>(name: string, input: I, wire: WorkflowRunWire, rpcService: any, options?: {
|
|
19
18
|
inline?: boolean;
|
|
20
19
|
startNode?: string;
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import type { Logger, LogLevel } from '../services/logger.js';
|
|
2
|
-
import { VariablesService } from '../services/variables-service.js';
|
|
3
|
-
import { SecretService } from '../services/secret-service.js';
|
|
4
|
-
import { SchemaService } from '../services/schema-service.js';
|
|
5
|
-
import { JWTService } from '../services/jwt-service.js';
|
|
6
|
-
import { PikkuHTTP } from '../wirings/http/http.types.js';
|
|
7
|
-
import { PikkuChannel, CorePikkuChannelMiddleware, CorePikkuChannelMiddlewareFactory } from '../wirings/channel/channel.types.js';
|
|
8
|
-
import { PikkuRPC } from '../wirings/rpc/rpc-types.js';
|
|
9
|
-
import { PikkuMCP } from '../wirings/mcp/mcp.types.js';
|
|
10
|
-
import { PikkuScheduledTask } from '../wirings/scheduler/scheduler.types.js';
|
|
11
|
-
import { PikkuQueue, QueueService } from '../wirings/queue/queue.types.js';
|
|
12
|
-
import { PikkuCLI } from '../wirings/cli/cli.types.js';
|
|
13
|
-
import { PikkuWorkflowWire, WorkflowService, WorkflowServiceConfig, WorkflowStepWire } from '../wirings/workflow/workflow.types.js';
|
|
2
|
+
import type { VariablesService } from '../services/variables-service.js';
|
|
3
|
+
import type { SecretService } from '../services/secret-service.js';
|
|
4
|
+
import type { SchemaService } from '../services/schema-service.js';
|
|
5
|
+
import type { JWTService } from '../services/jwt-service.js';
|
|
6
|
+
import type { PikkuHTTP } from '../wirings/http/http.types.js';
|
|
7
|
+
import type { PikkuChannel, CorePikkuChannelMiddleware, CorePikkuChannelMiddlewareFactory } from '../wirings/channel/channel.types.js';
|
|
8
|
+
import type { PikkuRPC } from '../wirings/rpc/rpc-types.js';
|
|
9
|
+
import type { PikkuMCP } from '../wirings/mcp/mcp.types.js';
|
|
10
|
+
import type { PikkuScheduledTask } from '../wirings/scheduler/scheduler.types.js';
|
|
11
|
+
import type { PikkuQueue, QueueService } from '../wirings/queue/queue.types.js';
|
|
12
|
+
import type { PikkuCLI } from '../wirings/cli/cli.types.js';
|
|
13
|
+
import type { PikkuWorkflowWire, WorkflowService, WorkflowServiceConfig, WorkflowStepWire } from '../wirings/workflow/workflow.types.js';
|
|
14
14
|
import type { PikkuGraphWire } from '../wirings/workflow/graph/workflow-graph.types.js';
|
|
15
|
-
import { PikkuTrigger } from '../wirings/trigger/trigger.types.js';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
15
|
+
import type { PikkuTrigger } from '../wirings/trigger/trigger.types.js';
|
|
16
|
+
import type { PikkuGateway } from '../wirings/gateway/gateway.types.js';
|
|
17
|
+
import type { SchedulerService } from '../services/scheduler-service.js';
|
|
18
|
+
import type { DeploymentService } from '../services/deployment-service.js';
|
|
19
|
+
import type { AIStorageService } from '../services/ai-storage-service.js';
|
|
20
|
+
import type { ContentService } from '../services/content-service.js';
|
|
21
|
+
import type { AIAgentRunnerService } from '../services/ai-agent-runner-service.js';
|
|
22
|
+
import type { AIRunStateService } from '../services/ai-run-state-service.js';
|
|
21
23
|
import type { PikkuAIMiddlewareHooks } from '../wirings/ai-agent/ai-agent.types.js';
|
|
22
|
-
export type PikkuWiringTypes = 'http' | 'scheduler' | 'trigger' | 'channel' | 'rpc' | 'queue' | 'mcp' | 'cli' | 'workflow' | 'agent';
|
|
24
|
+
export type PikkuWiringTypes = 'http' | 'scheduler' | 'trigger' | 'channel' | 'rpc' | 'queue' | 'mcp' | 'cli' | 'workflow' | 'agent' | 'gateway';
|
|
23
25
|
export interface FunctionServicesMeta {
|
|
24
26
|
optimized: boolean;
|
|
25
27
|
services: string[];
|
|
@@ -69,10 +71,13 @@ export type FunctionRuntimeMeta = {
|
|
|
69
71
|
expose?: boolean;
|
|
70
72
|
remote?: boolean;
|
|
71
73
|
mcp?: boolean;
|
|
74
|
+
readonly?: boolean;
|
|
72
75
|
sessionless?: boolean;
|
|
73
76
|
version?: number;
|
|
74
77
|
requiresApproval?: boolean;
|
|
75
78
|
contractHash?: string;
|
|
79
|
+
inputHash?: string;
|
|
80
|
+
outputHash?: string;
|
|
76
81
|
};
|
|
77
82
|
export type FunctionMeta = FunctionRuntimeMeta & Partial<{
|
|
78
83
|
name: string;
|
|
@@ -154,6 +159,8 @@ export interface CoreSingletonServices<Config extends CoreConfig = CoreConfig> {
|
|
|
154
159
|
deploymentService?: DeploymentService;
|
|
155
160
|
/** AI agent storage service (threads, messages, working memory) */
|
|
156
161
|
aiStorage?: AIStorageService;
|
|
162
|
+
/** Content service for file storage and retrieval */
|
|
163
|
+
content?: ContentService;
|
|
157
164
|
/** AI agent runner service (model calls + tool loop) */
|
|
158
165
|
aiAgentRunner?: AIAgentRunnerService;
|
|
159
166
|
/** AI run state service (run lifecycle + approval persistence) */
|
|
@@ -176,6 +183,7 @@ export type PikkuWire<In = unknown, Out = unknown, HasInitialSession extends boo
|
|
|
176
183
|
workflowStep: WorkflowStepWire;
|
|
177
184
|
graph: PikkuGraphWire;
|
|
178
185
|
trigger: PikkuTrigger<TriggerOutput>;
|
|
186
|
+
gateway: PikkuGateway;
|
|
179
187
|
session: HasInitialSession extends true ? UserSession : UserSession | undefined;
|
|
180
188
|
/** Update and persist the current session */
|
|
181
189
|
setSession: (session: CoreUserSession) => Promise<void> | void;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { PikkuError, ErrorDetails } from '../errors/error-handler.js';
|
|
2
|
-
import { CorePikkuFunctionConfig, CorePermissionGroup, CorePikkuPermission } from '../function/functions.types.js';
|
|
3
|
-
import { CorePikkuTriggerFunctionConfig } from '../wirings/trigger/trigger.types.js';
|
|
4
|
-
import { CoreChannel, ChannelsMeta } from '../wirings/channel/channel.types.js';
|
|
5
|
-
import { CLIMeta, CLIProgramState } from '../wirings/cli/cli.types.js';
|
|
6
|
-
import { HTTPMethod, CoreHTTPFunctionWiring, HTTPWiringsMeta } from '../wirings/http/http.types.js';
|
|
7
|
-
import { CoreMCPResource, MCPResourceMeta, MCPToolMeta, CoreMCPPrompt, MCPPromptMeta } from '../wirings/mcp/mcp.types.js';
|
|
8
|
-
import { CoreAIAgent, AIAgentMeta } from '../wirings/ai-agent/ai-agent.types.js';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
1
|
+
import type { PikkuError, ErrorDetails } from '../errors/error-handler.js';
|
|
2
|
+
import type { CorePikkuFunctionConfig, CorePermissionGroup, CorePikkuPermission } from '../function/functions.types.js';
|
|
3
|
+
import type { CorePikkuTriggerFunctionConfig } from '../wirings/trigger/trigger.types.js';
|
|
4
|
+
import type { CoreChannel, ChannelsMeta } from '../wirings/channel/channel.types.js';
|
|
5
|
+
import type { CLIMeta, CLIProgramState } from '../wirings/cli/cli.types.js';
|
|
6
|
+
import type { HTTPMethod, CoreHTTPFunctionWiring, HTTPWiringsMeta } from '../wirings/http/http.types.js';
|
|
7
|
+
import type { CoreMCPResource, MCPResourceMeta, MCPToolMeta, CoreMCPPrompt, MCPPromptMeta } from '../wirings/mcp/mcp.types.js';
|
|
8
|
+
import type { CoreAIAgent, AIAgentMeta } from '../wirings/ai-agent/ai-agent.types.js';
|
|
9
|
+
import type { CoreGateway, GatewaysMeta } from '../wirings/gateway/gateway.types.js';
|
|
10
|
+
import type { CoreQueueWorker, QueueWorkersMeta } from '../wirings/queue/queue.types.js';
|
|
11
|
+
import type { CoreScheduledTask, ScheduledTasksMeta } from '../wirings/scheduler/scheduler.types.js';
|
|
12
|
+
import type { CoreWorkflow, WorkflowsRuntimeMeta } from '../wirings/workflow/workflow.types.js';
|
|
13
|
+
import type { CoreTrigger, CoreTriggerSource, TriggerMeta, TriggerSourceMeta } from '../wirings/trigger/trigger.types.js';
|
|
14
|
+
import type { FunctionsMeta, CorePikkuMiddleware, CorePikkuMiddlewareGroup, CreateConfig, CreateSingletonServices, CreateWireServices, CoreConfig, CoreSingletonServices, CoreServices, CoreUserSession } from './core.types.js';
|
|
14
15
|
import type { CorePikkuChannelMiddleware } from '../wirings/channel/channel.types.js';
|
|
15
16
|
/**
|
|
16
17
|
* State structure for an individual package
|
|
@@ -27,9 +28,11 @@ export interface PikkuPackageState {
|
|
|
27
28
|
path: string;
|
|
28
29
|
}>;
|
|
29
30
|
/** Maps namespace aliases to package config (e.g., 'ext' -> { package: '@pikku/...', rpcEndpoint: '...' }) */
|
|
30
|
-
|
|
31
|
+
addons: Map<string, {
|
|
31
32
|
package: string;
|
|
32
33
|
rpcEndpoint?: string;
|
|
34
|
+
auth?: boolean;
|
|
35
|
+
tags?: string[];
|
|
33
36
|
}>;
|
|
34
37
|
};
|
|
35
38
|
http: {
|
|
@@ -72,6 +75,10 @@ export interface PikkuPackageState {
|
|
|
72
75
|
agents: Map<string, CoreAIAgent>;
|
|
73
76
|
agentsMeta: AIAgentMeta;
|
|
74
77
|
};
|
|
78
|
+
gateway: {
|
|
79
|
+
gateways: Map<string, CoreGateway>;
|
|
80
|
+
meta: GatewaysMeta;
|
|
81
|
+
};
|
|
75
82
|
cli: {
|
|
76
83
|
meta: CLIMeta | Record<string, any>;
|
|
77
84
|
programs: Record<string, CLIProgramState>;
|
|
@@ -113,7 +120,7 @@ export interface PikkuPackageState {
|
|
|
113
120
|
} | null;
|
|
114
121
|
};
|
|
115
122
|
package: {
|
|
116
|
-
/** Service factory functions for
|
|
123
|
+
/** Service factory functions for addon packages */
|
|
117
124
|
factories: {
|
|
118
125
|
createConfig?: CreateConfig<CoreConfig>;
|
|
119
126
|
createSingletonServices?: CreateSingletonServices<CoreConfig, CoreSingletonServices>;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Logger } from './services/logger.js';
|
|
2
|
-
import {
|
|
1
|
+
import type { Logger } from './services/logger.js';
|
|
2
|
+
import type { WireServices } from './types/core.types.js';
|
|
3
3
|
export declare const closeWireServices: (logger: Logger, wireServices: WireServices) => Promise<void>;
|
|
4
4
|
export declare const createWeakUID: () => string;
|
|
5
5
|
export declare const isSerializable: (data: any) => boolean;
|
|
6
6
|
export declare const getTagGroups: <T>(tagGroups: Record<string, T>, tag: string) => T[];
|
|
7
7
|
export declare const freezeDedupe: <T>(arr?: readonly T[] | T[] | undefined) => readonly T[];
|
|
8
8
|
/**
|
|
9
|
-
* Stop all singleton services, including
|
|
10
|
-
*
|
|
9
|
+
* Stop all singleton services, including addon package services.
|
|
10
|
+
* Addon package services are stopped first, then the parent services.
|
|
11
11
|
*
|
|
12
12
|
* @param singletonServices - The parent singleton services to stop
|
|
13
13
|
*/
|
|
14
|
-
export declare const stopSingletonServices: (
|
|
14
|
+
export declare const stopSingletonServices: () => Promise<void>;
|
package/dist/utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getSingletonServices, getAllPackageStates } from './pikku-state.js';
|
|
1
2
|
export const closeWireServices = async (logger, wireServices) => {
|
|
2
3
|
await Promise.all(Object.values(wireServices).map(async (service) => {
|
|
3
4
|
if (service?.close) {
|
|
@@ -10,9 +11,9 @@ export const closeWireServices = async (logger, wireServices) => {
|
|
|
10
11
|
}
|
|
11
12
|
}));
|
|
12
13
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
14
|
+
const _uidPrefix = Date.now().toString(36);
|
|
15
|
+
let _uidCounter = 0;
|
|
16
|
+
export const createWeakUID = () => `${_uidPrefix}-${++_uidCounter}`;
|
|
16
17
|
export const isSerializable = (data) => {
|
|
17
18
|
return !(typeof data === 'string' ||
|
|
18
19
|
data instanceof ArrayBuffer ||
|
|
@@ -73,16 +74,18 @@ const stopService = async (logger, name, service) => {
|
|
|
73
74
|
}
|
|
74
75
|
};
|
|
75
76
|
/**
|
|
76
|
-
* Stop all singleton services, including
|
|
77
|
-
*
|
|
77
|
+
* Stop all singleton services, including addon package services.
|
|
78
|
+
* Addon package services are stopped first, then the parent services.
|
|
78
79
|
*
|
|
79
80
|
* @param singletonServices - The parent singleton services to stop
|
|
80
81
|
*/
|
|
81
|
-
export const stopSingletonServices = async (
|
|
82
|
+
export const stopSingletonServices = async () => {
|
|
83
|
+
const singletonServices = getSingletonServices();
|
|
82
84
|
const logger = singletonServices.logger;
|
|
83
|
-
//
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
// Stop all addon package singleton services
|
|
86
|
+
const stateMap = getAllPackageStates();
|
|
87
|
+
if (stateMap.size > 0) {
|
|
88
|
+
for (const [packageName, packageState] of stateMap) {
|
|
86
89
|
// Skip main package - we handle it separately
|
|
87
90
|
if (packageName === '__main__')
|
|
88
91
|
continue;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AIStreamChannel, AIAgentInput } from './ai-agent.types.js';
|
|
2
|
+
export declare function createAssistantUIChannel(parent: AIStreamChannel): AIStreamChannel;
|
|
3
|
+
export declare function parseAssistantUIInput(input: Record<string, unknown>, defaults?: {
|
|
4
|
+
resourceId?: string;
|
|
5
|
+
}): AIAgentInput;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { randomUUID } from 'crypto';
|
|
2
|
+
export function createAssistantUIChannel(parent) {
|
|
3
|
+
const messageId = randomUUID();
|
|
4
|
+
let started = false;
|
|
5
|
+
let totalInputTokens = 0;
|
|
6
|
+
let totalOutputTokens = 0;
|
|
7
|
+
let pendingToolResults = [];
|
|
8
|
+
let hasToolCalls = false;
|
|
9
|
+
let hasPendingApproval = false;
|
|
10
|
+
const sendChunk = (chunk) => {
|
|
11
|
+
parent.send(chunk);
|
|
12
|
+
};
|
|
13
|
+
const ensureStarted = () => {
|
|
14
|
+
if (!started) {
|
|
15
|
+
started = true;
|
|
16
|
+
sendChunk({ type: 'start', messageId });
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const flushToolResults = () => {
|
|
20
|
+
for (const chunk of pendingToolResults) {
|
|
21
|
+
sendChunk(chunk);
|
|
22
|
+
}
|
|
23
|
+
pendingToolResults = [];
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
channelId: parent.channelId,
|
|
27
|
+
openingData: parent.openingData,
|
|
28
|
+
get state() {
|
|
29
|
+
return parent.state;
|
|
30
|
+
},
|
|
31
|
+
close: () => parent.close(),
|
|
32
|
+
sendBinary: (data) => parent.sendBinary(data),
|
|
33
|
+
send: (event) => {
|
|
34
|
+
switch (event.type) {
|
|
35
|
+
case 'text-delta':
|
|
36
|
+
ensureStarted();
|
|
37
|
+
sendChunk({ type: 'text-delta', textDelta: event.text });
|
|
38
|
+
break;
|
|
39
|
+
case 'reasoning-delta':
|
|
40
|
+
ensureStarted();
|
|
41
|
+
sendChunk({ type: 'reasoning-delta', delta: event.text });
|
|
42
|
+
break;
|
|
43
|
+
case 'audio-delta':
|
|
44
|
+
ensureStarted();
|
|
45
|
+
sendChunk({ type: 'audio-delta', data: event });
|
|
46
|
+
break;
|
|
47
|
+
case 'audio-done':
|
|
48
|
+
ensureStarted();
|
|
49
|
+
sendChunk({ type: 'audio-done', data: event });
|
|
50
|
+
break;
|
|
51
|
+
case 'tool-call':
|
|
52
|
+
ensureStarted();
|
|
53
|
+
hasToolCalls = true;
|
|
54
|
+
sendChunk({
|
|
55
|
+
type: 'tool-call-start',
|
|
56
|
+
id: event.toolCallId,
|
|
57
|
+
toolCallId: event.toolCallId,
|
|
58
|
+
toolName: event.toolName,
|
|
59
|
+
});
|
|
60
|
+
sendChunk({
|
|
61
|
+
type: 'tool-call-delta',
|
|
62
|
+
argsText: typeof event.args === 'string'
|
|
63
|
+
? event.args
|
|
64
|
+
: JSON.stringify(event.args),
|
|
65
|
+
});
|
|
66
|
+
sendChunk({ type: 'tool-call-end' });
|
|
67
|
+
break;
|
|
68
|
+
case 'tool-result':
|
|
69
|
+
ensureStarted();
|
|
70
|
+
pendingToolResults.push({
|
|
71
|
+
type: 'tool-result',
|
|
72
|
+
toolCallId: event.toolCallId,
|
|
73
|
+
result: event.result,
|
|
74
|
+
});
|
|
75
|
+
break;
|
|
76
|
+
case 'agent-call':
|
|
77
|
+
case 'agent-result':
|
|
78
|
+
break;
|
|
79
|
+
case 'usage': {
|
|
80
|
+
ensureStarted();
|
|
81
|
+
totalInputTokens += event.tokens.input;
|
|
82
|
+
totalOutputTokens += event.tokens.output;
|
|
83
|
+
const hasPending = pendingToolResults.length > 0;
|
|
84
|
+
sendChunk({
|
|
85
|
+
type: 'finish-step',
|
|
86
|
+
finishReason: hasToolCalls ? 'tool-calls' : 'stop',
|
|
87
|
+
usage: {
|
|
88
|
+
promptTokens: event.tokens.input,
|
|
89
|
+
completionTokens: event.tokens.output,
|
|
90
|
+
},
|
|
91
|
+
isContinued: hasPending,
|
|
92
|
+
});
|
|
93
|
+
flushToolResults();
|
|
94
|
+
hasToolCalls = false;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
case 'error':
|
|
98
|
+
ensureStarted();
|
|
99
|
+
sendChunk({ type: 'error', errorText: event.message });
|
|
100
|
+
break;
|
|
101
|
+
case 'approval-request':
|
|
102
|
+
ensureStarted();
|
|
103
|
+
hasPendingApproval = true;
|
|
104
|
+
sendChunk({ type: 'data-approval-request', data: event });
|
|
105
|
+
break;
|
|
106
|
+
case 'suspended':
|
|
107
|
+
ensureStarted();
|
|
108
|
+
sendChunk({ type: 'data-suspended', data: event });
|
|
109
|
+
break;
|
|
110
|
+
case 'done':
|
|
111
|
+
ensureStarted();
|
|
112
|
+
flushToolResults();
|
|
113
|
+
sendChunk({
|
|
114
|
+
type: 'finish',
|
|
115
|
+
finishReason: hasPendingApproval ? 'tool-calls' : 'stop',
|
|
116
|
+
usage: {
|
|
117
|
+
promptTokens: totalInputTokens,
|
|
118
|
+
completionTokens: totalOutputTokens,
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
parent.send('[DONE]');
|
|
122
|
+
parent.close();
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
export function parseAssistantUIInput(input, defaults) {
|
|
129
|
+
const messages = input.messages;
|
|
130
|
+
if (!messages || !Array.isArray(messages) || messages.length === 0) {
|
|
131
|
+
throw new Error('assistant-ui input must contain a non-empty messages array');
|
|
132
|
+
}
|
|
133
|
+
const lastUserMessage = [...messages].reverse().find((m) => m.role === 'user');
|
|
134
|
+
if (!lastUserMessage) {
|
|
135
|
+
throw new Error('No user message found in assistant-ui input');
|
|
136
|
+
}
|
|
137
|
+
let messageText;
|
|
138
|
+
let attachments;
|
|
139
|
+
const extractFromParts = (parts) => {
|
|
140
|
+
const textParts = parts.filter((p) => p.type === 'text');
|
|
141
|
+
messageText = textParts.map((p) => String(p.text)).join(' ') || '';
|
|
142
|
+
const nonTextParts = parts.filter((p) => p.type === 'image' || p.type === 'file');
|
|
143
|
+
if (nonTextParts.length > 0) {
|
|
144
|
+
attachments = nonTextParts.map((p) => ({
|
|
145
|
+
type: p.type,
|
|
146
|
+
data: p.data,
|
|
147
|
+
url: p.url,
|
|
148
|
+
mediaType: p.mediaType,
|
|
149
|
+
filename: p.filename,
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
if (typeof lastUserMessage.content === 'string') {
|
|
154
|
+
messageText = lastUserMessage.content;
|
|
155
|
+
}
|
|
156
|
+
else if (Array.isArray(lastUserMessage.parts)) {
|
|
157
|
+
extractFromParts(lastUserMessage.parts);
|
|
158
|
+
}
|
|
159
|
+
else if (Array.isArray(lastUserMessage.content)) {
|
|
160
|
+
extractFromParts(lastUserMessage.content);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
messageText = '';
|
|
164
|
+
}
|
|
165
|
+
const threadId = input.threadId ?? input.id ?? randomUUID();
|
|
166
|
+
const resourceId = defaults?.resourceId ?? 'default';
|
|
167
|
+
return { message: messageText, threadId, resourceId, attachments };
|
|
168
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare function agent<TAgentMap extends Record<string, {
|
|
2
|
+
output: any;
|
|
3
|
+
}>>(agentName: string & keyof TAgentMap): {
|
|
4
|
+
func: (services: any, data: any, wire: any) => Promise<any>;
|
|
5
|
+
};
|
|
6
|
+
export declare function agentStream<TAgentMap extends Record<string, {
|
|
7
|
+
output: any;
|
|
8
|
+
}>>(agentName?: string & keyof TAgentMap): {
|
|
9
|
+
func: (services: any, data: any, wire: any) => Promise<void>;
|
|
10
|
+
};
|
|
11
|
+
export declare function agentResume(): {
|
|
12
|
+
func: (services: any, data: {
|
|
13
|
+
runId: string;
|
|
14
|
+
toolCallId: string;
|
|
15
|
+
approved: boolean;
|
|
16
|
+
}, wire: any) => Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
export declare function agentApprove<TAgentMap extends Record<string, {
|
|
19
|
+
output: any;
|
|
20
|
+
}>>(_agentName: string & keyof TAgentMap): {
|
|
21
|
+
func: (services: any, data: {
|
|
22
|
+
runId: string;
|
|
23
|
+
approvals: {
|
|
24
|
+
toolCallId: string;
|
|
25
|
+
approved: boolean;
|
|
26
|
+
}[];
|
|
27
|
+
}, wire: any) => Promise<any>;
|
|
28
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export function agent(agentName) {
|
|
2
|
+
return {
|
|
3
|
+
func: async (_services, data, { rpc }) => {
|
|
4
|
+
return rpc.agent.run(agentName, data);
|
|
5
|
+
},
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export function agentStream(agentName) {
|
|
9
|
+
return {
|
|
10
|
+
func: async (_services, data, { rpc }) => {
|
|
11
|
+
if (agentName) {
|
|
12
|
+
await rpc.agent.stream(agentName, data);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
const { agentName: name, ...rest } = data;
|
|
16
|
+
if (!name) {
|
|
17
|
+
throw new Error('agentStream requires an agentName either as a parameter or in the input data');
|
|
18
|
+
}
|
|
19
|
+
await rpc.agent.stream(name, rest);
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export function agentResume() {
|
|
25
|
+
return {
|
|
26
|
+
func: async (_services, data, { rpc }) => {
|
|
27
|
+
await rpc.agent.resume(data.runId, {
|
|
28
|
+
toolCallId: data.toolCallId,
|
|
29
|
+
approved: data.approved,
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export function agentApprove(_agentName) {
|
|
35
|
+
return {
|
|
36
|
+
func: async (_services, data, { rpc }) => {
|
|
37
|
+
return rpc.agent.approve(data.runId, data.approvals);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -175,8 +175,19 @@ function sanitizeToolMessages(messages) {
|
|
|
175
175
|
}
|
|
176
176
|
function estimateTokens(msg) {
|
|
177
177
|
let chars = 0;
|
|
178
|
-
if (msg.content)
|
|
179
|
-
|
|
178
|
+
if (msg.content) {
|
|
179
|
+
if (typeof msg.content === 'string') {
|
|
180
|
+
chars += msg.content.length;
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
for (const part of msg.content) {
|
|
184
|
+
if (part.type === 'text')
|
|
185
|
+
chars += part.text.length;
|
|
186
|
+
else
|
|
187
|
+
chars += 1000;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
180
191
|
if (msg.toolCalls)
|
|
181
192
|
chars += JSON.stringify(msg.toolCalls).length;
|
|
182
193
|
if (msg.toolResults)
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { CoreAIAgent, AIAgentInput, AIAgentToolDef, AIMessage, AIStreamChannel } from './ai-agent.types.js';
|
|
1
|
+
import type { CoreUserSession } from '../../types/core.types.js';
|
|
2
|
+
import type { CoreAIAgent, AIAgentInput, AIAgentToolDef, AIMessage, AIStreamChannel, PikkuAIMiddlewareHooks } from './ai-agent.types.js';
|
|
3
3
|
import type { AIAgentRunnerParams } from '../../services/ai-agent-runner-service.js';
|
|
4
4
|
import { PikkuError } from '../../errors/error-handler.js';
|
|
5
5
|
import type { SessionService } from '../../services/user-session-service.js';
|
|
6
6
|
export type RunAIAgentParams = {
|
|
7
|
-
singletonServices: CoreSingletonServices;
|
|
8
7
|
sessionService?: SessionService<CoreUserSession>;
|
|
9
|
-
createWireServices?: CreateWireServices<CoreSingletonServices, CoreServices<CoreSingletonServices>, CoreUserSession>;
|
|
10
8
|
};
|
|
11
9
|
export type StreamAIAgentOptions = {
|
|
12
10
|
requiresToolApproval?: 'all' | 'explicit' | false;
|
|
@@ -40,7 +38,7 @@ export type ScopedChannel = AIStreamChannel & {
|
|
|
40
38
|
} | null;
|
|
41
39
|
};
|
|
42
40
|
export declare function createScopedChannel(parent: AIStreamChannel, agentName: string, session: string): ScopedChannel;
|
|
43
|
-
export declare function buildToolDefs(
|
|
41
|
+
export declare function buildToolDefs(params: RunAIAgentParams, agentSessionMap: Map<string, string>, resourceId: string, agentName: string, packageName: string | null, streamContext?: StreamContext, aiMiddlewares?: PikkuAIMiddlewareHooks[]): {
|
|
44
42
|
tools: AIAgentToolDef[];
|
|
45
43
|
missingRpcs: string[];
|
|
46
44
|
};
|
|
@@ -54,6 +52,7 @@ export declare function prepareAgentRun(agentName: string, input: AIAgentInput,
|
|
|
54
52
|
threadId: string;
|
|
55
53
|
userMessage: AIMessage;
|
|
56
54
|
runnerParams: AIAgentRunnerParams;
|
|
55
|
+
maxSteps: number;
|
|
57
56
|
missingRpcs: string[];
|
|
58
57
|
workingMemoryJsonSchema: any;
|
|
59
58
|
workingMemorySchemaName: string | null;
|