@pikku/addon-ollama 0.1.3 → 0.1.4
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/dist/.pikku/addon/pikku-addon-types.gen.d.ts +2 -2
- package/dist/.pikku/addon/pikku-addon-types.gen.js +2 -2
- package/dist/.pikku/addon/pikku-addon-types.gen.ts +2 -2
- package/dist/.pikku/addon/pikku-package.gen.js +3 -2
- package/dist/.pikku/addon/pikku-package.gen.js.map +1 -1
- package/dist/.pikku/addon/pikku-package.gen.ts +4 -2
- package/dist/.pikku/agent/pikku-agent-map.gen.d.ts +1 -1
- package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +6 -2
- package/dist/.pikku/agent/pikku-agent-types.gen.d.ts.map +1 -1
- package/dist/.pikku/agent/pikku-agent-types.gen.js +3 -0
- package/dist/.pikku/agent/pikku-agent-types.gen.js.map +1 -1
- package/dist/.pikku/agent/pikku-agent-types.gen.ts +15 -2
- package/dist/.pikku/agent/pikku-model-aliases.gen.d.ts +2 -0
- package/dist/.pikku/agent/pikku-model-aliases.gen.d.ts.map +1 -0
- package/dist/.pikku/agent/pikku-model-aliases.gen.js +6 -0
- package/dist/.pikku/agent/pikku-model-aliases.gen.js.map +1 -0
- package/dist/.pikku/agent/pikku-model-aliases.gen.ts +6 -0
- package/dist/.pikku/agent/pikku-scorer-names.gen.d.ts +8 -0
- 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-channel-types.gen.ts +1 -1
- package/dist/.pikku/console/pikku-node-types.gen.d.ts +1 -1
- package/dist/.pikku/console/pikku-node-types.gen.ts +1 -1
- package/dist/.pikku/function/pikku-function-types.gen.d.ts +20 -24
- package/dist/.pikku/function/pikku-function-types.gen.d.ts.map +1 -1
- package/dist/.pikku/function/pikku-function-types.gen.js +2 -2
- package/dist/.pikku/function/pikku-function-types.gen.js.map +1 -1
- package/dist/.pikku/function/pikku-function-types.gen.ts +32 -27
- package/dist/.pikku/function/pikku-functions-meta.gen.js +2 -2
- package/dist/.pikku/function/pikku-functions-meta.gen.js.map +1 -1
- package/dist/.pikku/function/pikku-functions-meta.gen.ts +2 -2
- package/dist/.pikku/function/pikku-functions.gen.js +1 -1
- package/dist/.pikku/function/pikku-functions.gen.ts +1 -1
- 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-types.gen.ts +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-types.gen.ts +1 -1
- package/dist/.pikku/pikku-bootstrap-scenarios.gen.d.ts +1 -1
- package/dist/.pikku/pikku-bootstrap-scenarios.gen.js +1 -1
- package/dist/.pikku/pikku-bootstrap-scenarios.gen.ts +1 -1
- package/dist/.pikku/pikku-bootstrap.gen.d.ts +2 -1
- package/dist/.pikku/pikku-bootstrap.gen.d.ts.map +1 -1
- package/dist/.pikku/pikku-bootstrap.gen.js +2 -1
- package/dist/.pikku/pikku-bootstrap.gen.js.map +1 -1
- package/dist/.pikku/pikku-bootstrap.gen.ts +2 -1
- package/dist/.pikku/pikku-meta-service.gen.d.ts +1 -1
- package/dist/.pikku/pikku-meta-service.gen.js +1 -1
- package/dist/.pikku/pikku-meta-service.gen.ts +1 -1
- package/dist/.pikku/pikku-services.gen.d.ts +2 -1
- package/dist/.pikku/pikku-services.gen.d.ts.map +1 -1
- package/dist/.pikku/pikku-services.gen.js +1 -0
- package/dist/.pikku/pikku-services.gen.js.map +1 -1
- package/dist/.pikku/pikku-services.gen.ts +2 -1
- package/dist/.pikku/pikku-types.gen.d.ts +1 -1
- package/dist/.pikku/pikku-types.gen.js +1 -1
- package/dist/.pikku/pikku-types.gen.ts +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-types.gen.ts +1 -1
- package/dist/.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts +2 -7
- package/dist/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts +2 -7
- package/dist/.pikku/rpc/pikku-rpc-wirings-map.remote.gen.d.ts +2 -7
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +2 -2
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js.map +1 -1
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts +2 -2
- package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.js +2 -2
- package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.js.map +1 -1
- package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.ts +2 -2
- package/dist/.pikku/scenarios/pikku-scenario-functions.gen.d.ts +1 -1
- package/dist/.pikku/scenarios/pikku-scenario-functions.gen.ts +1 -1
- package/dist/.pikku/scenarios/pikku-scenario-wirings-meta.gen.js +2 -2
- package/dist/.pikku/scenarios/pikku-scenario-wirings-meta.gen.js.map +1 -1
- package/dist/.pikku/scenarios/pikku-scenario-wirings-meta.gen.ts +2 -2
- package/dist/.pikku/scenarios/pikku-scenario-wirings.gen.d.ts +1 -1
- package/dist/.pikku/scenarios/pikku-scenario-wirings.gen.ts +1 -1
- package/dist/.pikku/scenarios/schemas/register.gen.d.ts +1 -1
- package/dist/.pikku/scenarios/schemas/register.gen.js +1 -1
- package/dist/.pikku/scenarios/schemas/register.gen.ts +1 -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/scheduler/pikku-scheduler-types.gen.ts +1 -1
- package/dist/.pikku/schemas/register.gen.js +1 -1
- package/dist/.pikku/schemas/register.gen.ts +1 -1
- package/dist/.pikku/scopes/pikku-personas.gen.js +1 -1
- package/dist/.pikku/scopes/pikku-personas.gen.ts +1 -1
- package/dist/.pikku/scopes/pikku-roles.gen.d.ts +1 -1
- package/dist/.pikku/scopes/pikku-roles.gen.ts +1 -1
- package/dist/.pikku/scopes/pikku-scope-types.gen.d.ts +1 -1
- package/dist/.pikku/scopes/pikku-scope-types.gen.js +1 -1
- package/dist/.pikku/scopes/pikku-scope-types.gen.ts +1 -1
- package/dist/.pikku/scopes/pikku-scopes.gen.d.ts +1 -1
- package/dist/.pikku/scopes/pikku-scopes.gen.ts +1 -1
- 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-secret-types.gen.ts +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/secrets/pikku-secrets.gen.ts +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/trigger/pikku-trigger-types.gen.ts +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-variable-types.gen.ts +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/variables/pikku-variables.gen.ts +1 -1
- package/dist/.pikku/workflow/pikku-personas.gen.d.ts +2 -1
- package/dist/.pikku/workflow/pikku-personas.gen.d.ts.map +1 -1
- package/dist/.pikku/workflow/pikku-personas.gen.js +1 -1
- package/dist/.pikku/workflow/pikku-personas.gen.js.map +1 -1
- package/dist/.pikku/workflow/pikku-personas.gen.ts +3 -6
- package/dist/.pikku/workflow/pikku-scenario-step-map.gen.d.ts +2 -2
- package/dist/.pikku/workflow/pikku-workflow-map.gen.d.ts +1 -1
- package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +25 -16
- package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts.map +1 -1
- package/dist/.pikku/workflow/pikku-workflow-types.gen.js +1 -1
- package/dist/.pikku/workflow/pikku-workflow-types.gen.js.map +1 -1
- package/dist/.pikku/workflow/pikku-workflow-types.gen.ts +33 -27
- package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +2 -2
- package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js.map +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.ts +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/.pikku/workflow/pikku-workflow-wirings.gen.ts +1 -1
- package/dist/src/functions/embeddings/embed-many.function.d.ts +1 -1
- package/dist/src/functions/embeddings/embed.function.d.ts +1 -1
- package/dist/src/functions/text/generate-object.function.d.ts +1 -1
- package/dist/src/functions/text/generate.function.d.ts +1 -1
- package/dist/types/application-types.d.ts +17 -0
- package/package.json +6 -7
- package/.pikku/addon/pikku-addon-types.gen.ts +0 -105
- package/.pikku/addon/pikku-package.gen.ts +0 -11
- package/.pikku/agent/pikku-agent-map.gen.d.ts +0 -4
- package/.pikku/agent/pikku-agent-types.gen.ts +0 -84
- package/.pikku/channel/pikku-channel-types.gen.ts +0 -177
- package/.pikku/console/pikku-addon-meta.gen.json +0 -61
- package/.pikku/console/pikku-node-types.gen.ts +0 -8
- package/.pikku/function/pikku-function-types.gen.ts +0 -797
- package/.pikku/function/pikku-functions-meta-verbose.gen.json +0 -126
- package/.pikku/function/pikku-functions-meta.gen.json +0 -102
- package/.pikku/function/pikku-functions-meta.gen.ts +0 -7
- package/.pikku/function/pikku-functions.gen.ts +0 -14
- package/.pikku/http/pikku-http-types.gen.ts +0 -119
- package/.pikku/mcp/pikku-mcp-types.gen.ts +0 -183
- package/.pikku/pikku-bootstrap-scenarios.gen.ts +0 -9
- package/.pikku/pikku-bootstrap.gen.ts +0 -8
- package/.pikku/pikku-meta-service.gen.ts +0 -10
- package/.pikku/pikku-services.gen.ts +0 -50
- package/.pikku/pikku-types.gen.ts +0 -24
- package/.pikku/queue/pikku-queue-types.gen.ts +0 -27
- package/.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts +0 -207
- package/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts +0 -211
- package/.pikku/rpc/pikku-rpc-wirings-map.remote.gen.d.ts +0 -207
- package/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +0 -6
- package/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts +0 -6
- package/.pikku/scenarios/features.gen.json +0 -1
- package/.pikku/scenarios/pikku-scenario-functions-meta.gen.json +0 -1
- package/.pikku/scenarios/pikku-scenario-functions-meta.gen.ts +0 -12
- package/.pikku/scenarios/pikku-scenario-functions.gen.ts +0 -4
- package/.pikku/scenarios/pikku-scenario-wirings-meta.gen.ts +0 -15
- package/.pikku/scenarios/pikku-scenario-wirings.gen.ts +0 -4
- package/.pikku/scenarios/schemas/register.gen.ts +0 -4
- package/.pikku/scheduler/pikku-scheduler-types.gen.ts +0 -25
- package/.pikku/schemas/register.gen.ts +0 -39
- package/.pikku/schemas/schemas/OllamaEmbedInput.schema.json +0 -1
- package/.pikku/schemas/schemas/OllamaEmbedManyInput.schema.json +0 -1
- package/.pikku/schemas/schemas/OllamaEmbedManyOutput.schema.json +0 -1
- package/.pikku/schemas/schemas/OllamaEmbedOutput.schema.json +0 -1
- package/.pikku/schemas/schemas/OllamaGenerateObjectInput.schema.json +0 -1
- package/.pikku/schemas/schemas/OllamaGenerateObjectOutput.schema.json +0 -1
- package/.pikku/schemas/schemas/OllamaGenerateTextInput.schema.json +0 -1
- package/.pikku/schemas/schemas/OllamaGenerateTextOutput.schema.json +0 -1
- package/.pikku/schemas/schemas/VariableSchema_ollama_base_url.schema.json +0 -1
- package/.pikku/scopes/pikku-personas-meta.gen.json +0 -1
- package/.pikku/scopes/pikku-personas.gen.ts +0 -52
- package/.pikku/scopes/pikku-roles-meta.gen.json +0 -1
- package/.pikku/scopes/pikku-roles.gen.ts +0 -41
- package/.pikku/scopes/pikku-scope-types.gen.ts +0 -7
- package/.pikku/scopes/pikku-scopes-meta.gen.json +0 -1
- package/.pikku/scopes/pikku-scopes.gen.ts +0 -58
- package/.pikku/secrets/pikku-secret-types.gen.ts +0 -5
- package/.pikku/secrets/pikku-secrets-meta.gen.json +0 -1
- package/.pikku/secrets/pikku-secrets.gen.ts +0 -34
- package/.pikku/trigger/pikku-trigger-types.gen.ts +0 -160
- package/.pikku/variables/pikku-variable-types.gen.ts +0 -5
- package/.pikku/variables/pikku-variables-meta.gen.json +0 -10
- package/.pikku/variables/pikku-variables.gen.ts +0 -36
- package/.pikku/workflow/personas.gen.json +0 -1
- package/.pikku/workflow/pikku-personas.gen.ts +0 -38
- package/.pikku/workflow/pikku-scenario-step-map.gen.d.ts +0 -18
- package/.pikku/workflow/pikku-workflow-map.gen.d.ts +0 -38
- package/.pikku/workflow/pikku-workflow-types.gen.ts +0 -591
- package/.pikku/workflow/pikku-workflow-wirings-meta.gen.ts +0 -9
- package/.pikku/workflow/pikku-workflow-wirings.gen.ts +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was generated by @pikku/cli@0.12.
|
|
2
|
+
* This file was generated by @pikku/cli@0.12.103
|
|
3
3
|
*/
|
|
4
4
|
import { WorkflowCancelledException } from '@pikku/core/workflow'
|
|
5
5
|
import { template } from '@pikku/core/workflow'
|
|
@@ -8,10 +8,11 @@ import {
|
|
|
8
8
|
type PikkuWorkflowGraphConfig,
|
|
9
9
|
type PikkuWorkflowGraphResult,
|
|
10
10
|
} from '@pikku/core/workflow'
|
|
11
|
-
import type { PikkuWorkflowWire,
|
|
11
|
+
import type { PikkuWorkflowWire, WorkflowStepOptions } from '@pikku/core/workflow'
|
|
12
|
+
import type { PikkuScenarioWire, ScenarioStepOptions } from '@pikku/core/scenario'
|
|
12
13
|
|
|
13
14
|
export { WorkflowCancelledException }
|
|
14
|
-
import type { PikkuFunctionSessionless, PikkuFunctionConfig } from '../function/pikku-function-types.gen.js'
|
|
15
|
+
import type { PikkuFunctionSessionless, PikkuFunctionConfig, WiredServices } from '../function/pikku-function-types.gen.js'
|
|
15
16
|
import type { FlattenedRPCMap } from '../rpc/pikku-rpc-wirings-map.internal.gen.d.js'
|
|
16
17
|
import type { FlattenedWorkflowMap } from './pikku-workflow-map.gen.d.js'
|
|
17
18
|
import type { AgentMap as FlattenedAgentMap } from '../agent/pikku-agent-map.gen.d.js'
|
|
@@ -45,18 +46,12 @@ export interface TypedWorkflow extends PikkuWorkflowWire {
|
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
/**
|
|
48
|
-
* The typed half of a scenario wire: `
|
|
49
|
-
*
|
|
50
|
-
*
|
|
49
|
+
* The typed half of a scenario wire: `given`/`when`/`then`, narrowed to the
|
|
50
|
+
* names declared by `pikkuScenarioStep` in this project. `given` and `when`
|
|
51
|
+
* differ only in the prose the reporter renders; `then` additionally makes the
|
|
52
|
+
* step's bindings witnesses rather than alternatives.
|
|
51
53
|
*/
|
|
52
54
|
export interface TypedScenarioSteps {
|
|
53
|
-
step<K extends keyof FlattenedScenarioStepMap>(
|
|
54
|
-
stepName: string,
|
|
55
|
-
stepFunc: K,
|
|
56
|
-
data?: FlattenedScenarioStepMap[K]['input'],
|
|
57
|
-
options?: ScenarioStepOptions
|
|
58
|
-
): Promise<FlattenedScenarioStepMap[K]['output']>
|
|
59
|
-
|
|
60
55
|
given<K extends keyof FlattenedScenarioStepMap>(
|
|
61
56
|
stepName: string,
|
|
62
57
|
stepFunc: K,
|
|
@@ -79,8 +74,9 @@ export interface TypedScenarioSteps {
|
|
|
79
74
|
): Promise<FlattenedScenarioStepMap[K]['output']>
|
|
80
75
|
}
|
|
81
76
|
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
/** `Out` types `scenario.context`. */
|
|
78
|
+
export type TypedScenario<Out = unknown> = TypedWorkflow &
|
|
79
|
+
Omit<PikkuScenarioWire<Out>, keyof PikkuWorkflowWire | keyof TypedScenarioSteps> &
|
|
84
80
|
TypedScenarioSteps
|
|
85
81
|
|
|
86
82
|
import type { StandardSchemaV1 } from '@standard-schema/spec'
|
|
@@ -94,10 +90,16 @@ export type PikkuFunctionWorkflow<
|
|
|
94
90
|
Out = never
|
|
95
91
|
> = PikkuFunctionSessionless<In, Out, 'workflow'>
|
|
96
92
|
|
|
93
|
+
/**
|
|
94
|
+
* `Ctx` types `scenario.context`, defaulting to the body's own output. A hook
|
|
95
|
+
* returns void but shares the scenario's context, so it passes that scenario's
|
|
96
|
+
* output here instead.
|
|
97
|
+
*/
|
|
97
98
|
export type PikkuFunctionScenario<
|
|
98
99
|
In = unknown,
|
|
99
|
-
Out = never
|
|
100
|
-
|
|
100
|
+
Out = never,
|
|
101
|
+
Ctx = Out
|
|
102
|
+
> = PikkuFunctionSessionless<In, Out, 'scenario' | 'actors', WiredServices, Ctx>
|
|
101
103
|
|
|
102
104
|
export type PikkuWorkflowConfigWithSchema<
|
|
103
105
|
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
|
@@ -178,14 +180,15 @@ export type PikkuScenarioConfigWithSchema<
|
|
|
178
180
|
* on the ladder. Throwing skips the body and fails the run; `after` still
|
|
179
181
|
* runs.
|
|
180
182
|
*/
|
|
181
|
-
before?: PikkuScenarioHook<InputSchema>
|
|
183
|
+
before?: PikkuScenarioHook<InputSchema, OutputSchema>
|
|
182
184
|
/**
|
|
183
185
|
* Always runs after the scenario body, in a `finally`, whether it passed or
|
|
184
186
|
* failed. Throwing fails a run that would otherwise have passed; on an
|
|
185
187
|
* already-failed run it attaches as the `cause` and never replaces the
|
|
186
|
-
* original error.
|
|
188
|
+
* original error. Reads `scenario.context` for whatever the body managed to
|
|
189
|
+
* record before it stopped.
|
|
187
190
|
*/
|
|
188
|
-
after?: PikkuScenarioHook<InputSchema>
|
|
191
|
+
after?: PikkuScenarioHook<InputSchema, OutputSchema>
|
|
189
192
|
/**
|
|
190
193
|
* Why this scenario is held out of a default run, stated where the scenario
|
|
191
194
|
* is. The scenario still appears in the plan and is reported as skipped
|
|
@@ -197,13 +200,16 @@ export type PikkuScenarioConfigWithSchema<
|
|
|
197
200
|
|
|
198
201
|
/**
|
|
199
202
|
* A scenario lifecycle hook: the scenario's own `(services, data, wire)`
|
|
200
|
-
* signature with its result discarded.
|
|
203
|
+
* signature with its result discarded. `OutputSchema` types
|
|
204
|
+
* `scenario.context` while the return type stays `void`.
|
|
201
205
|
*/
|
|
202
206
|
export type PikkuScenarioHook<
|
|
203
|
-
InputSchema extends StandardSchemaV1 | undefined = undefined
|
|
207
|
+
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
|
208
|
+
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
|
204
209
|
> = PikkuFunctionScenario<
|
|
205
210
|
InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown,
|
|
206
|
-
void
|
|
211
|
+
void,
|
|
212
|
+
OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown
|
|
207
213
|
>
|
|
208
214
|
|
|
209
215
|
/**
|
|
@@ -211,9 +217,9 @@ export type PikkuScenarioHook<
|
|
|
211
217
|
* registered, so this exists purely to give an inline hook a call site to be
|
|
212
218
|
* contextually typed from, the way every other pikku primitive is.
|
|
213
219
|
*/
|
|
214
|
-
export function pikkuScenarioHook<In = unknown>(
|
|
215
|
-
hook: PikkuFunctionScenario<In, void>
|
|
216
|
-
): PikkuFunctionScenario<In, void> {
|
|
220
|
+
export function pikkuScenarioHook<In = unknown, Ctx = unknown>(
|
|
221
|
+
hook: PikkuFunctionScenario<In, void, Ctx>
|
|
222
|
+
): PikkuFunctionScenario<In, void, Ctx> {
|
|
217
223
|
return hook
|
|
218
224
|
}
|
|
219
225
|
|
|
@@ -331,7 +337,7 @@ export type PikkuScenarioStepConfigWithSchema<
|
|
|
331
337
|
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
|
332
338
|
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
|
333
339
|
> = {
|
|
334
|
-
/** Registered name — this is the string `scenario.
|
|
340
|
+
/** Registered name — this is the string `scenario.given()` references. */
|
|
335
341
|
name: string
|
|
336
342
|
/**
|
|
337
343
|
* What this step does, for the console and for whoever reads the source. It
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was generated by @pikku/cli@0.12.
|
|
2
|
+
* This file was generated by @pikku/cli@0.12.103
|
|
3
3
|
*/
|
|
4
|
-
import { pikkuState } from '@pikku/core/
|
|
4
|
+
import { pikkuState } from '@pikku/core/ecosystem';
|
|
5
5
|
const workflowsMeta = {};
|
|
6
6
|
pikkuState('@pikku/addon-ollama', 'workflows', 'meta', workflowsMeta);
|
|
7
7
|
//# sourceMappingURL=pikku-workflow-wirings-meta.gen.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pikku-workflow-wirings-meta.gen.js","sourceRoot":"","sources":["../../../.pikku/workflow/pikku-workflow-wirings-meta.gen.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"pikku-workflow-wirings-meta.gen.js","sourceRoot":"","sources":["../../../.pikku/workflow/pikku-workflow-wirings-meta.gen.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAGlD,MAAM,aAAa,GAAyB,EAAE,CAAA;AAE9C,UAAU,CAAC,qBAAqB,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,CAAC,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was generated by @pikku/cli@0.12.
|
|
2
|
+
* This file was generated by @pikku/cli@0.12.103
|
|
3
3
|
*/
|
|
4
|
-
import { pikkuState } from '@pikku/core/
|
|
4
|
+
import { pikkuState } from '@pikku/core/ecosystem'
|
|
5
5
|
import type { WorkflowsRuntimeMeta } from '@pikku/core/workflow/types'
|
|
6
6
|
|
|
7
7
|
const workflowsMeta: WorkflowsRuntimeMeta = {}
|
|
@@ -28,7 +28,7 @@ export declare const ollamaEmbedMany: import("#pikku").PikkuFunctionConfig<{
|
|
|
28
28
|
usage: {
|
|
29
29
|
tokens: number;
|
|
30
30
|
};
|
|
31
|
-
}, "rpc" | "session", import("#pikku").WiredServices> | import("#pikku").PikkuFunction<{
|
|
31
|
+
}, "rpc" | "session", import("#pikku").WiredServices, unknown> | import("#pikku").PikkuFunction<{
|
|
32
32
|
model: string;
|
|
33
33
|
values: string[];
|
|
34
34
|
}, {
|
|
@@ -28,7 +28,7 @@ export declare const ollamaEmbed: import("#pikku").PikkuFunctionConfig<{
|
|
|
28
28
|
usage: {
|
|
29
29
|
tokens: number;
|
|
30
30
|
};
|
|
31
|
-
}, "rpc" | "session", import("#pikku").WiredServices> | import("#pikku").PikkuFunction<{
|
|
31
|
+
}, "rpc" | "session", import("#pikku").WiredServices, unknown> | import("#pikku").PikkuFunction<{
|
|
32
32
|
model: string;
|
|
33
33
|
value: string;
|
|
34
34
|
}, {
|
|
@@ -88,7 +88,7 @@ export declare const ollamaGenerateObject: import("#pikku").PikkuFunctionConfig<
|
|
|
88
88
|
completionTokens: number;
|
|
89
89
|
totalTokens: number;
|
|
90
90
|
};
|
|
91
|
-
}, "rpc" | "session", import("#pikku").WiredServices> | import("#pikku").PikkuFunction<{
|
|
91
|
+
}, "rpc" | "session", import("#pikku").WiredServices, unknown> | import("#pikku").PikkuFunction<{
|
|
92
92
|
model: string;
|
|
93
93
|
schema: Record<string, any>;
|
|
94
94
|
prompt?: string | undefined;
|
|
@@ -78,7 +78,7 @@ export declare const ollamaGenerateText: import("#pikku").PikkuFunctionConfig<{
|
|
|
78
78
|
completionTokens: number;
|
|
79
79
|
totalTokens: number;
|
|
80
80
|
};
|
|
81
|
-
}, "rpc" | "session", import("#pikku").WiredServices> | import("#pikku").PikkuFunction<{
|
|
81
|
+
}, "rpc" | "session", import("#pikku").WiredServices, unknown> | import("#pikku").PikkuFunction<{
|
|
82
82
|
model: string;
|
|
83
83
|
prompt?: string | undefined;
|
|
84
84
|
messages?: {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CoreConfig,
|
|
3
|
+
CoreServices,
|
|
4
|
+
CoreSingletonServices,
|
|
5
|
+
CoreUserSession,
|
|
6
|
+
} from '@pikku/core'
|
|
7
|
+
import type { createOpenAI } from '@ai-sdk/openai'
|
|
8
|
+
|
|
9
|
+
export interface Config extends CoreConfig {}
|
|
10
|
+
|
|
11
|
+
export interface UserSession extends CoreUserSession {}
|
|
12
|
+
|
|
13
|
+
export interface SingletonServices extends CoreSingletonServices<Config> {
|
|
14
|
+
ollama: ReturnType<typeof createOpenAI>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface Services extends CoreServices<SingletonServices> {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikku/addon-ollama",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#pikku": "./dist/.pikku/pikku-types.gen.js"
|
|
@@ -17,23 +17,22 @@
|
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
|
-
"dist"
|
|
21
|
-
".pikku"
|
|
20
|
+
"dist"
|
|
22
21
|
],
|
|
23
22
|
"scripts": {
|
|
24
23
|
"prebuild": "pikku all",
|
|
25
|
-
"build": "tsc && cp -r .pikku dist/",
|
|
24
|
+
"build": "tsc && cp -r .pikku types dist/",
|
|
26
25
|
"pikku": "pikku all",
|
|
27
26
|
"ncu": "npx npm-check-updates",
|
|
28
27
|
"test": "cd test && yarn test"
|
|
29
28
|
},
|
|
30
29
|
"peerDependencies": {
|
|
31
|
-
"@pikku/core": "^0.12.
|
|
30
|
+
"@pikku/core": "^0.12.83",
|
|
32
31
|
"zod": "^4"
|
|
33
32
|
},
|
|
34
33
|
"devDependencies": {
|
|
35
|
-
"@pikku/cli": "^0.12.
|
|
36
|
-
"@pikku/core": "^0.12.
|
|
34
|
+
"@pikku/cli": "^0.12.103",
|
|
35
|
+
"@pikku/core": "^0.12.83",
|
|
37
36
|
"typescript": "^5.7.2",
|
|
38
37
|
"zod": "^4"
|
|
39
38
|
},
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was generated by @pikku/cli@0.12.96
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Addon package types for pikkuAddonConfig and pikkuAddonServices
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { CreateConfig, PikkuWire } from '@pikku/core'
|
|
9
|
-
import type { SingletonServices } from '../../types/application-types.d.js'
|
|
10
|
-
import type { Config } from '../../types/application-types.d.js'
|
|
11
|
-
import type { RequiredSingletonServices } from '../pikku-services.gen.js'
|
|
12
|
-
import { TypedSecretService } from '../secrets/pikku-secrets.gen.js'
|
|
13
|
-
import { TypedVariablesService } from '../variables/pikku-variables.gen.js'
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Base services provided to addon package service factories.
|
|
21
|
-
* These are always available from the parent application.
|
|
22
|
-
*/
|
|
23
|
-
export type AddonBaseServices = {
|
|
24
|
-
logger: SingletonServices['logger']
|
|
25
|
-
variables: TypedVariablesService
|
|
26
|
-
secrets: TypedSecretService
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Creates a Pikku config factory for addon packages.
|
|
31
|
-
* Unlike pikkuConfig, this receives AddonBaseServices (logger, variables, secrets)
|
|
32
|
-
* from the parent application, so addon packages can read variables/secrets during config creation.
|
|
33
|
-
*/
|
|
34
|
-
export const pikkuAddonConfig = <ExistingServices extends Omit<Partial<SingletonServices>, 'variables' | 'secrets'> & AddonBaseServices>(
|
|
35
|
-
func: (services: ExistingServices) => Promise<Config>
|
|
36
|
-
): CreateConfig<Config> => {
|
|
37
|
-
return (async (_variables: any, existingServices?: Partial<SingletonServices>): Promise<Config> => {
|
|
38
|
-
const { secrets, variables, ...rest } = (existingServices ?? {}) as unknown as SingletonServices
|
|
39
|
-
return func({ ...rest, secrets: new TypedSecretService(secrets), variables: new TypedVariablesService(variables) } as ExistingServices)
|
|
40
|
-
}) as unknown as CreateConfig<Config>
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Creates a Pikku singleton services factory for addon packages.
|
|
45
|
-
* Unlike pikkuServices, this expects the parent application to provide
|
|
46
|
-
* logger, variables, and secrets - no fallbacks needed.
|
|
47
|
-
*
|
|
48
|
-
* @param func - Addon services factory function that receives config and base services
|
|
49
|
-
* @returns The singleton services factory function
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* ```typescript
|
|
53
|
-
* export const createSingletonServices = pikkuAddonServices(async (
|
|
54
|
-
* config,
|
|
55
|
-
* { secrets }
|
|
56
|
-
* ) => {
|
|
57
|
-
* const creds = await secrets.getSecret<GithubCredentials>('GITHUB_CREDENTIALS')
|
|
58
|
-
* const github = new GithubService(creds)
|
|
59
|
-
* return { github }
|
|
60
|
-
* })
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
export const pikkuAddonServices = <T extends Record<string, any>, ExistingServices extends Omit<Partial<SingletonServices>, 'variables' | 'secrets'> & AddonBaseServices>(
|
|
64
|
-
func: (config: Config, services: ExistingServices) => Promise<T>
|
|
65
|
-
) => {
|
|
66
|
-
return async (config: Config, existingServices?: Partial<SingletonServices>): Promise<RequiredSingletonServices> => {
|
|
67
|
-
const { logger, variables, secrets, schema } = (existingServices ?? {}) as unknown as SingletonServices
|
|
68
|
-
const typedVariables = new TypedVariablesService(variables)
|
|
69
|
-
const typedSecrets = new TypedSecretService(secrets)
|
|
70
|
-
const result = await func(config, { ...existingServices, logger, variables: typedVariables, secrets: typedSecrets } as ExistingServices)
|
|
71
|
-
return {
|
|
72
|
-
config,
|
|
73
|
-
logger,
|
|
74
|
-
schema,
|
|
75
|
-
variables: typedVariables,
|
|
76
|
-
secrets: typedSecrets,
|
|
77
|
-
...result,
|
|
78
|
-
} as unknown as RequiredSingletonServices
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Creates a Pikku wire services factory for addon packages.
|
|
84
|
-
* Wire services are created per-request and have access to the HTTP request context.
|
|
85
|
-
*
|
|
86
|
-
* @param func - Wire services factory function that receives singleton services and the wire context
|
|
87
|
-
* @returns The wire services factory function
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* ```typescript
|
|
91
|
-
* export const createWireServices = pikkuAddonWireServices(async (services, wire) => {
|
|
92
|
-
* const authHeader = wire.http?.request?.header('authorization')
|
|
93
|
-
* return { myService: new MyService(authHeader) }
|
|
94
|
-
* })
|
|
95
|
-
* ```
|
|
96
|
-
*/
|
|
97
|
-
export const pikkuAddonWireServices = <ExistingServices extends Omit<Partial<SingletonServices>, 'variables' | 'secrets'> & AddonBaseServices>(
|
|
98
|
-
func: (services: ExistingServices, wire: PikkuWire) => Promise<Record<string, any>>
|
|
99
|
-
) => {
|
|
100
|
-
return ((services: any, wire: PikkuWire) => {
|
|
101
|
-
const typedVariables = new TypedVariablesService(services.variables)
|
|
102
|
-
const typedSecrets = new TypedSecretService(services.secrets)
|
|
103
|
-
return func({ ...services, variables: typedVariables, secrets: typedSecrets } as ExistingServices, wire)
|
|
104
|
-
}) as any
|
|
105
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was generated by @pikku/cli@0.12.96
|
|
3
|
-
*/
|
|
4
|
-
import { pikkuState } from '@pikku/core/internal'
|
|
5
|
-
import { createSingletonServices as createSingletonServices } from '../../src/services.js'
|
|
6
|
-
|
|
7
|
-
pikkuState('@pikku/addon-ollama', 'package', 'factories', {
|
|
8
|
-
createSingletonServices,
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
pikkuState('@pikku/addon-ollama', 'package', 'requiredParentServices', ["variables"])
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was generated by @pikku/cli@0.12.96
|
|
3
|
-
*/
|
|
4
|
-
import {
|
|
5
|
-
CoreAIAgent,
|
|
6
|
-
PikkuAIMiddlewareHooks,
|
|
7
|
-
} from '@pikku/core/ai-agent'
|
|
8
|
-
import {
|
|
9
|
-
agent as coreAgent,
|
|
10
|
-
agentStream as coreAgentStream,
|
|
11
|
-
agentResume as coreAgentResume,
|
|
12
|
-
agentApprove as coreAgentApprove,
|
|
13
|
-
} from '@pikku/core/ai-agent'
|
|
14
|
-
import type { PikkuPermission, PikkuMiddleware, Services, PikkuFunctionConfig } from '../function/pikku-function-types.gen.js'
|
|
15
|
-
import type { StandardSchemaV1 } from '@standard-schema/spec'
|
|
16
|
-
import type { AIAgentMemoryConfig, AIAgentInput } from '@pikku/core/ai-agent'
|
|
17
|
-
import type { AgentMap } from './pikku-agent-map.gen.d.js'
|
|
18
|
-
import type { ScopeId } from '../scopes/pikku-scopes.gen.js'
|
|
19
|
-
|
|
20
|
-
type AIAgentConfig<
|
|
21
|
-
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
|
22
|
-
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
|
23
|
-
> = Omit<CoreAIAgent<PikkuPermission, PikkuMiddleware, ScopeId>, 'tools' | 'agents' | 'workflows' | 'memory' | 'input' | 'output'> & {
|
|
24
|
-
input?: InputSchema
|
|
25
|
-
output?: OutputSchema
|
|
26
|
-
memory?: Omit<AIAgentMemoryConfig, 'workingMemory'> & { workingMemory?: StandardSchemaV1 }
|
|
27
|
-
tools?: object[]
|
|
28
|
-
agents?: AIAgentConfig<StandardSchemaV1 | undefined, StandardSchemaV1 | undefined>[]
|
|
29
|
-
workflows?: object[]
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const pikkuAIAgent = <
|
|
33
|
-
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
|
34
|
-
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
|
35
|
-
>(
|
|
36
|
-
agent: AIAgentConfig<InputSchema, OutputSchema>
|
|
37
|
-
) => {
|
|
38
|
-
return agent
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const pikkuAIMiddleware = <
|
|
42
|
-
State extends Record<string, unknown> = Record<string, unknown>,
|
|
43
|
-
RequiredServices extends Services = Services,
|
|
44
|
-
>(
|
|
45
|
-
hooks: PikkuAIMiddlewareHooks<State, RequiredServices>
|
|
46
|
-
): PikkuAIMiddlewareHooks<State, RequiredServices> => hooks
|
|
47
|
-
|
|
48
|
-
export const agent = <Name extends keyof AgentMap>(
|
|
49
|
-
agentName: Name
|
|
50
|
-
) => {
|
|
51
|
-
return coreAgent<AgentMap>(agentName as string & keyof AgentMap) as PikkuFunctionConfig<
|
|
52
|
-
AIAgentInput,
|
|
53
|
-
{ runId: string; result: AgentMap[Name]['output']; usage: { inputTokens: number; outputTokens: number } },
|
|
54
|
-
'session' | 'rpc'
|
|
55
|
-
>
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export const agentStream = <Name extends keyof AgentMap>(
|
|
59
|
-
agentName?: Name
|
|
60
|
-
) => {
|
|
61
|
-
return coreAgentStream<AgentMap>(agentName as string & keyof AgentMap) as PikkuFunctionConfig<
|
|
62
|
-
{ agentName?: string; message: string; threadId: string; resourceId: string },
|
|
63
|
-
void,
|
|
64
|
-
'session' | 'rpc'
|
|
65
|
-
>
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export const agentResume = () => {
|
|
69
|
-
return coreAgentResume() as PikkuFunctionConfig<
|
|
70
|
-
{ runId: string; toolCallId: string; approved: boolean },
|
|
71
|
-
void,
|
|
72
|
-
'session' | 'rpc'
|
|
73
|
-
>
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export const agentApprove = <Name extends keyof AgentMap>(
|
|
77
|
-
agentName: Name
|
|
78
|
-
) => {
|
|
79
|
-
return coreAgentApprove<AgentMap>(agentName as string & keyof AgentMap) as PikkuFunctionConfig<
|
|
80
|
-
{ runId: string; approvals: { toolCallId: string; approved: boolean }[] },
|
|
81
|
-
unknown,
|
|
82
|
-
'session' | 'rpc'
|
|
83
|
-
>
|
|
84
|
-
}
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was generated by @pikku/cli@0.12.96
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Channel-specific type definitions for tree-shaking optimization
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { CoreChannel, CorePikkuChannelMiddleware, CorePikkuChannelMiddlewareFactory, wireChannel as wireChannelCore, defineChannelRoutes as defineChannelRoutesCore, addChannelMiddleware as addChannelMiddlewareCore } from '@pikku/core/channel'
|
|
9
|
-
import { AssertHTTPWiringParams } from '@pikku/core/http'
|
|
10
|
-
import type { PikkuFunctionConfig, PikkuFunctionSessionless, PikkuPermission, PikkuMiddleware, Services } from '../function/pikku-function-types.gen.js'
|
|
11
|
-
import type { CorePermissionGroup } from '@pikku/core'
|
|
12
|
-
import type { StandardSchemaV1 } from '@standard-schema/spec'
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Helper type to infer the output type from a Standard Schema
|
|
16
|
-
*/
|
|
17
|
-
type InferSchemaOutput<T> = T extends StandardSchemaV1<any, infer Output> ? Output : never
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Type definition for WebSocket channels with typed data exchange.
|
|
21
|
-
* Supports connection, disconnection, and message handling.
|
|
22
|
-
* Accepts both session-based (PikkuFunction) and sessionless (PikkuFunctionSessionless) functions.
|
|
23
|
-
*
|
|
24
|
-
* @template ChannelData - Type of data exchanged through the channel
|
|
25
|
-
* @template Channel - String literal type for the channel name
|
|
26
|
-
*/
|
|
27
|
-
type ChannelWiring<ChannelData, Channel extends string> = CoreChannel<
|
|
28
|
-
ChannelData,
|
|
29
|
-
Channel,
|
|
30
|
-
PikkuFunctionConfig<void, any, 'channel' | 'session' | 'rpc'>,
|
|
31
|
-
PikkuFunctionConfig<void, void, 'channel' | 'session' | 'rpc'>,
|
|
32
|
-
PikkuFunctionConfig<any, any, 'channel' | 'session' | 'rpc'>,
|
|
33
|
-
PikkuPermission,
|
|
34
|
-
PikkuMiddleware
|
|
35
|
-
>
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Creates a function that handles WebSocket channel connections.
|
|
39
|
-
* Called when a client connects to a channel.
|
|
40
|
-
*
|
|
41
|
-
* @template Out - Output type for connection response
|
|
42
|
-
* @param func - Function definition, either direct function or configuration object
|
|
43
|
-
* @returns The normalized configuration object
|
|
44
|
-
*/
|
|
45
|
-
export const pikkuChannelConnectionFunc = <Out = unknown>(
|
|
46
|
-
func:
|
|
47
|
-
| PikkuFunctionSessionless<void, Out, 'channel' | 'session' | 'rpc'>
|
|
48
|
-
| PikkuFunctionConfig<void, Out, 'channel' | 'session' | 'rpc'>
|
|
49
|
-
) => {
|
|
50
|
-
return typeof func === 'function' ? { func } : func
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Creates a function that handles WebSocket channel disconnections.
|
|
55
|
-
* Called when a client disconnects from a channel.
|
|
56
|
-
*
|
|
57
|
-
* @param func - Function definition, either direct function or configuration object
|
|
58
|
-
* @returns The normalized configuration object
|
|
59
|
-
*/
|
|
60
|
-
export const pikkuChannelDisconnectionFunc = (
|
|
61
|
-
func:
|
|
62
|
-
| PikkuFunctionSessionless<void, void, 'channel'>
|
|
63
|
-
| PikkuFunctionConfig<void, void, 'channel' | 'session' | 'rpc'>
|
|
64
|
-
) => {
|
|
65
|
-
return typeof func === 'function' ? { func } : func
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Configuration object for channel functions with Zod schema validation.
|
|
70
|
-
*/
|
|
71
|
-
type PikkuChannelFuncConfigWithSchema<
|
|
72
|
-
InputSchema extends StandardSchemaV1,
|
|
73
|
-
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
|
74
|
-
> = {
|
|
75
|
-
name?: string
|
|
76
|
-
tags?: string[]
|
|
77
|
-
expose?: boolean
|
|
78
|
-
remote?: boolean
|
|
79
|
-
func: PikkuFunctionSessionless<
|
|
80
|
-
InferSchemaOutput<InputSchema>,
|
|
81
|
-
OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown,
|
|
82
|
-
'channel' | 'session' | 'rpc'
|
|
83
|
-
>
|
|
84
|
-
auth?: boolean
|
|
85
|
-
permissions?: CorePermissionGroup<PikkuPermission<InferSchemaOutput<InputSchema>>>
|
|
86
|
-
middleware?: PikkuMiddleware[]
|
|
87
|
-
input: InputSchema
|
|
88
|
-
output?: OutputSchema
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Creates a function that handles WebSocket channel messages.
|
|
93
|
-
* Called when a message is received on a channel.
|
|
94
|
-
*
|
|
95
|
-
* Supports two patterns:
|
|
96
|
-
* 1. Generic types: `pikkuChannelFunc<Input, Output>({ func: ... })`
|
|
97
|
-
* 2. Zod schemas: `pikkuChannelFunc({ input: z.object(...), func: ... })`
|
|
98
|
-
*
|
|
99
|
-
* @template In - Input type for channel messages (inferred from schema if provided)
|
|
100
|
-
* @template Out - Output type for channel responses (inferred from schema if provided)
|
|
101
|
-
* @param func - Function definition, either direct function or configuration object
|
|
102
|
-
* @returns The normalized configuration object
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* ```typescript
|
|
106
|
-
* // Pattern 1: Using generic types
|
|
107
|
-
* const handleMessage = pikkuChannelFunc<{text: string}, {received: boolean}>({
|
|
108
|
-
* func: async (_services, { text }) => ({ received: true })
|
|
109
|
-
* })
|
|
110
|
-
*
|
|
111
|
-
* // Pattern 2: Using Zod schemas
|
|
112
|
-
* const messageInput = z.object({ text: z.string() })
|
|
113
|
-
* const messageOutput = z.object({ received: z.boolean() })
|
|
114
|
-
*
|
|
115
|
-
* const handleMessage = pikkuChannelFunc({
|
|
116
|
-
* input: messageInput,
|
|
117
|
-
* output: messageOutput,
|
|
118
|
-
* func: async (_services, { text }) => ({ received: true })
|
|
119
|
-
* })
|
|
120
|
-
* ```
|
|
121
|
-
*/
|
|
122
|
-
export function pikkuChannelFunc<
|
|
123
|
-
InputSchema extends StandardSchemaV1,
|
|
124
|
-
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
|
125
|
-
>(
|
|
126
|
-
config: PikkuChannelFuncConfigWithSchema<InputSchema, OutputSchema>
|
|
127
|
-
): PikkuFunctionConfig<InferSchemaOutput<InputSchema>, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown, 'channel' | 'session' | 'rpc'>
|
|
128
|
-
export function pikkuChannelFunc<In, Out = unknown>(
|
|
129
|
-
func:
|
|
130
|
-
| PikkuFunctionSessionless<In, Out, 'channel' | 'session' | 'rpc'>
|
|
131
|
-
| PikkuFunctionConfig<In, Out, 'channel' | 'session' | 'rpc'>
|
|
132
|
-
): PikkuFunctionConfig<In, Out, 'channel' | 'session' | 'rpc'>
|
|
133
|
-
export function pikkuChannelFunc(func: any) {
|
|
134
|
-
return typeof func === 'function' ? { func } : func
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Registers a WebSocket channel with the Pikku framework.
|
|
139
|
-
*
|
|
140
|
-
* @template ChannelData - Type of data associated with the channel
|
|
141
|
-
* @template Channel - String literal type for the channel name
|
|
142
|
-
* @param channel - Channel definition with connection, disconnection, and message handlers
|
|
143
|
-
*/
|
|
144
|
-
export const wireChannel = <ChannelData, Channel extends string>(
|
|
145
|
-
channel: ChannelWiring<ChannelData, Channel> & AssertHTTPWiringParams<ChannelData, Channel>
|
|
146
|
-
) => {
|
|
147
|
-
wireChannelCore(channel as any)
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Type-safe helper for defining channel message routes that can be composed.
|
|
152
|
-
* Returns the routes record as-is for use with wireChannel's onMessageWiring.
|
|
153
|
-
*
|
|
154
|
-
* @template T - Record of channel route handlers
|
|
155
|
-
* @param routes - The channel routes record
|
|
156
|
-
* @returns The same routes record (identity function for type safety)
|
|
157
|
-
*/
|
|
158
|
-
export function defineChannelRoutes<T extends Record<string, any>>(routes: T): T {
|
|
159
|
-
return defineChannelRoutesCore(routes)
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export type PikkuChannelMiddleware<RequiredServices extends Services = Services, Event = unknown> = CorePikkuChannelMiddleware<RequiredServices, Event>
|
|
163
|
-
|
|
164
|
-
export const pikkuChannelMiddleware = <RequiredServices extends Services = Services, Event = unknown>(
|
|
165
|
-
middleware: PikkuChannelMiddleware<RequiredServices, Event>
|
|
166
|
-
): PikkuChannelMiddleware<RequiredServices, Event> => {
|
|
167
|
-
return middleware
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export const pikkuChannelMiddlewareFactory = <In = any>(
|
|
171
|
-
factory: CorePikkuChannelMiddlewareFactory<In>
|
|
172
|
-
): CorePikkuChannelMiddlewareFactory<In> => {
|
|
173
|
-
return factory
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export const addChannelMiddleware = (tag: string, middleware: PikkuChannelMiddleware[]) =>
|
|
177
|
-
addChannelMiddlewareCore(tag, middleware, '@pikku/addon-ollama')
|