@pikku/core 0.12.19 → 0.12.21
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 +77 -0
- package/dist/dev/hot-reload.js +20 -6
- package/dist/errors/error-handler.d.ts +1 -1
- package/dist/errors/error-handler.js +2 -2
- package/dist/function/function-runner.js +53 -3
- package/dist/function/functions.types.d.ts +3 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/middleware/index.d.ts +2 -2
- package/dist/middleware/index.js +2 -2
- package/dist/middleware/telemetry.d.ts +2 -2
- package/dist/middleware/telemetry.js +2 -2
- package/dist/middleware-runner.d.ts +15 -27
- package/dist/middleware-runner.js +25 -30
- package/dist/permissions.d.ts +15 -22
- package/dist/permissions.js +30 -25
- package/dist/pikku-request.js +1 -1
- package/dist/pikku-state.js +2 -3
- package/dist/services/ai-agent-runner-service.d.ts +1 -0
- package/dist/services/content-service.d.ts +66 -37
- package/dist/services/in-memory-queue-service.js +1 -1
- package/dist/services/in-memory-workflow-service.d.ts +15 -13
- package/dist/services/in-memory-workflow-service.js +31 -13
- package/dist/services/index.d.ts +1 -1
- package/dist/services/local-content.d.ts +10 -12
- package/dist/services/local-content.js +54 -38
- package/dist/services/user-session-service.d.ts +1 -1
- package/dist/testing/service-tests.js +24 -0
- package/dist/types/core.types.d.ts +4 -0
- package/dist/types/state.types.d.ts +2 -18
- package/dist/wirings/ai-agent/ai-agent-memory.d.ts +24 -5
- package/dist/wirings/ai-agent/ai-agent-memory.js +128 -23
- package/dist/wirings/ai-agent/ai-agent-model-config.d.ts +10 -1
- package/dist/wirings/ai-agent/ai-agent-model-config.js +15 -35
- package/dist/wirings/ai-agent/ai-agent-prepare.js +4 -1
- package/dist/wirings/ai-agent/ai-agent-runner.js +45 -31
- package/dist/wirings/ai-agent/ai-agent-stream.js +63 -34
- package/dist/wirings/ai-agent/ai-agent.types.d.ts +20 -0
- package/dist/wirings/channel/channel-handler.js +1 -1
- package/dist/wirings/channel/channel-store.d.ts +13 -0
- package/dist/wirings/channel/channel.types.d.ts +3 -0
- package/dist/wirings/channel/local/local-channel-runner.js +23 -5
- package/dist/wirings/channel/pikku-abstract-channel-handler.js +8 -0
- package/dist/wirings/channel/serverless/serverless-channel-runner.js +9 -0
- package/dist/wirings/cli/cli-runner.js +24 -5
- package/dist/wirings/cli/command-parser.js +19 -4
- package/dist/wirings/http/http-runner.js +72 -36
- package/dist/wirings/http/http.types.d.ts +1 -0
- package/dist/wirings/http/pikku-fetch-http-request.js +3 -1
- package/dist/wirings/http/web-request.js +32 -0
- package/dist/wirings/rpc/rpc-runner.d.ts +3 -2
- package/dist/wirings/rpc/rpc-runner.js +45 -11
- package/dist/wirings/workflow/graph/graph-node.d.ts +8 -0
- package/dist/wirings/workflow/graph/graph-node.js +4 -0
- package/dist/wirings/workflow/graph/graph-runner.js +12 -10
- package/dist/wirings/workflow/graph/workflow-graph.types.d.ts +4 -0
- package/dist/wirings/workflow/index.d.ts +1 -1
- package/dist/wirings/workflow/pikku-workflow-service.d.ts +81 -16
- package/dist/wirings/workflow/pikku-workflow-service.js +266 -45
- package/dist/wirings/workflow/workflow.types.d.ts +34 -0
- package/package.json +1 -1
- package/run-tests.sh +4 -1
- package/src/dev/hot-reload.test.ts +62 -11
- package/src/dev/hot-reload.ts +28 -7
- package/src/errors/error-handler.ts +8 -2
- package/src/errors/error.test.ts +2 -0
- package/src/function/function-runner.test.ts +500 -10
- package/src/function/function-runner.ts +68 -3
- package/src/function/functions.types.ts +3 -2
- package/src/index.ts +22 -3
- package/src/middleware/index.ts +11 -2
- package/src/middleware/telemetry.ts +2 -2
- package/src/middleware-runner.test.ts +16 -16
- package/src/middleware-runner.ts +42 -30
- package/src/permissions.test.ts +27 -24
- package/src/permissions.ts +41 -25
- package/src/pikku-request.test.ts +35 -0
- package/src/pikku-request.ts +1 -1
- package/src/pikku-state.ts +2 -3
- package/src/run-tests-script.test.ts +18 -0
- package/src/services/ai-agent-runner-service.ts +1 -0
- package/src/services/content-service.ts +79 -51
- package/src/services/in-memory-queue-service.ts +1 -1
- package/src/services/in-memory-session-store.ts +1 -2
- package/src/services/in-memory-workflow-service.test.ts +33 -11
- package/src/services/in-memory-workflow-service.ts +49 -13
- package/src/services/index.ts +10 -1
- package/src/services/local-content.test.ts +54 -0
- package/src/services/local-content.ts +80 -53
- package/src/services/typed-credential-service.ts +3 -3
- package/src/services/typed-secret-service.ts +3 -3
- package/src/services/typed-variables-service.ts +3 -3
- package/src/services/user-session-service.ts +4 -4
- package/src/testing/service-tests.ts +30 -0
- package/src/types/core.types.ts +6 -2
- package/src/types/state.types.ts +2 -13
- package/src/wirings/ai-agent/ai-agent-memory.test.ts +324 -0
- package/src/wirings/ai-agent/ai-agent-memory.ts +187 -36
- package/src/wirings/ai-agent/ai-agent-model-config.test.ts +12 -90
- package/src/wirings/ai-agent/ai-agent-model-config.ts +14 -38
- package/src/wirings/ai-agent/ai-agent-prepare.test.ts +292 -0
- package/src/wirings/ai-agent/ai-agent-prepare.ts +4 -1
- package/src/wirings/ai-agent/ai-agent-registry.test.ts +230 -3
- package/src/wirings/ai-agent/ai-agent-runner.test.ts +625 -6
- package/src/wirings/ai-agent/ai-agent-runner.ts +65 -50
- package/src/wirings/ai-agent/ai-agent-stream.test.ts +544 -5
- package/src/wirings/ai-agent/ai-agent-stream.ts +71 -69
- package/src/wirings/ai-agent/ai-agent.types.ts +24 -0
- package/src/wirings/channel/channel-handler.test.ts +272 -0
- package/src/wirings/channel/channel-handler.ts +1 -1
- package/src/wirings/channel/channel-middleware-runner.test.ts +163 -0
- package/src/wirings/channel/channel-store.ts +19 -0
- package/src/wirings/channel/channel.types.ts +4 -0
- package/src/wirings/channel/local/local-channel-runner.test.ts +63 -0
- package/src/wirings/channel/local/local-channel-runner.ts +41 -5
- package/src/wirings/channel/local/local-eventhub-service.ts +3 -3
- package/src/wirings/channel/pikku-abstract-channel-handler.ts +9 -2
- package/src/wirings/channel/serverless/serverless-channel-runner.ts +23 -5
- package/src/wirings/cli/channel/cli-raw-channel-runner.ts +7 -2
- package/src/wirings/cli/cli-runner.test.ts +255 -2
- package/src/wirings/cli/cli-runner.ts +31 -10
- package/src/wirings/cli/cli.types.ts +4 -8
- package/src/wirings/cli/command-parser.test.ts +83 -0
- package/src/wirings/cli/command-parser.ts +23 -4
- package/src/wirings/http/http-runner.test.ts +296 -1
- package/src/wirings/http/http-runner.ts +87 -57
- package/src/wirings/http/http.types.ts +11 -26
- package/src/wirings/http/pikku-fetch-http-request.ts +8 -4
- package/src/wirings/http/pikku-fetch-http-response.test.ts +41 -0
- package/src/wirings/http/web-request.test.ts +115 -0
- package/src/wirings/http/web-request.ts +43 -5
- package/src/wirings/mcp/mcp-runner.test.ts +367 -0
- package/src/wirings/queue/queue.types.ts +2 -5
- package/src/wirings/rpc/rpc-runner.test.ts +511 -0
- package/src/wirings/rpc/rpc-runner.ts +60 -21
- package/src/wirings/rpc/wire-addon.test.ts +57 -0
- package/src/wirings/workflow/graph/graph-node.ts +12 -0
- package/src/wirings/workflow/graph/graph-runner.test.ts +98 -0
- package/src/wirings/workflow/graph/graph-runner.ts +28 -10
- package/src/wirings/workflow/graph/workflow-graph.types.ts +4 -0
- package/src/wirings/workflow/index.ts +1 -0
- package/src/wirings/workflow/pikku-workflow-service.test.ts +19 -2
- package/src/wirings/workflow/pikku-workflow-service.ts +370 -71
- package/src/wirings/workflow/workflow-queue-workers.test.ts +131 -0
- package/src/wirings/workflow/workflow.types.ts +68 -5
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { createReadStream, createWriteStream, promises } from 'fs'
|
|
2
2
|
import { mkdir, readFile } from 'fs/promises'
|
|
3
3
|
import { resolve, normalize } from 'path'
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
BucketKeyArgs,
|
|
6
|
+
ContentService,
|
|
7
|
+
CopyFileArgs,
|
|
8
|
+
GetUploadURLArgs,
|
|
9
|
+
JWTService,
|
|
10
|
+
Logger,
|
|
11
|
+
SignContentKeyArgs,
|
|
12
|
+
SignURLArgs,
|
|
13
|
+
UploadURLResult,
|
|
14
|
+
WriteFileArgs,
|
|
15
|
+
} from '@pikku/core/services'
|
|
5
16
|
import { pipeline } from 'stream/promises'
|
|
6
17
|
import type { Readable } from 'stream'
|
|
7
18
|
|
|
@@ -20,15 +31,20 @@ export class LocalContent implements ContentService {
|
|
|
20
31
|
private jwt?: JWTService
|
|
21
32
|
) {}
|
|
22
33
|
|
|
23
|
-
private safePath(
|
|
34
|
+
private safePath(bucket: string, key: string): string {
|
|
24
35
|
const base = resolve(this.config.localFileUploadPath)
|
|
25
|
-
const
|
|
36
|
+
const scoped = resolve(base, normalize(bucket))
|
|
37
|
+
const target = resolve(scoped, normalize(key))
|
|
26
38
|
if (!target.startsWith(base + '/') && target !== base) {
|
|
27
39
|
throw new Error('Invalid asset key')
|
|
28
40
|
}
|
|
29
41
|
return target
|
|
30
42
|
}
|
|
31
43
|
|
|
44
|
+
private joinKey(bucket: string, key: string): string {
|
|
45
|
+
return `${bucket}/${key}`
|
|
46
|
+
}
|
|
47
|
+
|
|
32
48
|
public async init() {}
|
|
33
49
|
|
|
34
50
|
private async signParams(
|
|
@@ -49,114 +65,125 @@ export class LocalContent implements ContentService {
|
|
|
49
65
|
1,
|
|
50
66
|
Math.floor((expiresAt - signedAt) / 1000)
|
|
51
67
|
)
|
|
68
|
+
const payload: {
|
|
69
|
+
signedAt: number
|
|
70
|
+
expiresAt: number
|
|
71
|
+
notBefore?: number
|
|
72
|
+
} = {
|
|
73
|
+
signedAt,
|
|
74
|
+
expiresAt,
|
|
75
|
+
}
|
|
76
|
+
if (dateGreaterThan) {
|
|
77
|
+
payload.notBefore = dateGreaterThan.getTime()
|
|
78
|
+
}
|
|
52
79
|
const signature = await this.jwt.encode(
|
|
53
80
|
{ value: expiresInSeconds, unit: 'second' },
|
|
54
|
-
|
|
81
|
+
payload
|
|
55
82
|
)
|
|
56
83
|
params.set('signature', signature)
|
|
57
84
|
}
|
|
58
85
|
return params.toString()
|
|
59
86
|
}
|
|
60
87
|
|
|
61
|
-
public async signURL(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return `${url}?${params}`
|
|
88
|
+
public async signURL(args: SignURLArgs): Promise<string> {
|
|
89
|
+
const params = await this.signParams(
|
|
90
|
+
args.dateLessThan,
|
|
91
|
+
args.dateGreaterThan
|
|
92
|
+
)
|
|
93
|
+
return `${args.url}?${params}`
|
|
68
94
|
}
|
|
69
95
|
|
|
70
|
-
public async signContentKey(
|
|
71
|
-
|
|
72
|
-
dateLessThan: Date,
|
|
73
|
-
dateGreaterThan?: Date
|
|
74
|
-
): Promise<string> {
|
|
96
|
+
public async signContentKey(args: SignContentKeyArgs): Promise<string> {
|
|
97
|
+
const fullKey = this.joinKey(args.bucket, args.contentKey)
|
|
75
98
|
const base = this.config.server
|
|
76
|
-
? `${this.config.server}${this.config.assetUrlPrefix}/${
|
|
77
|
-
: `${this.config.assetUrlPrefix}/${
|
|
78
|
-
return this.signURL(
|
|
99
|
+
? `${this.config.server}${this.config.assetUrlPrefix}/${fullKey}`
|
|
100
|
+
: `${this.config.assetUrlPrefix}/${fullKey}`
|
|
101
|
+
return this.signURL({
|
|
102
|
+
url: base,
|
|
103
|
+
dateLessThan: args.dateLessThan,
|
|
104
|
+
dateGreaterThan: args.dateGreaterThan,
|
|
105
|
+
})
|
|
79
106
|
}
|
|
80
107
|
|
|
81
|
-
public async getUploadURL(
|
|
82
|
-
this.
|
|
108
|
+
public async getUploadURL(args: GetUploadURLArgs): Promise<UploadURLResult> {
|
|
109
|
+
const fullKey = this.joinKey(args.bucket, args.fileKey)
|
|
110
|
+
this.logger.debug(`Going to upload with key: ${fullKey}`)
|
|
83
111
|
return {
|
|
84
|
-
uploadUrl: `${this.config.uploadUrlPrefix}/${
|
|
85
|
-
assetKey,
|
|
112
|
+
uploadUrl: `${this.config.uploadUrlPrefix}/${fullKey}`,
|
|
113
|
+
assetKey: fullKey,
|
|
86
114
|
}
|
|
87
115
|
}
|
|
88
116
|
|
|
89
|
-
public async writeFile(
|
|
90
|
-
|
|
91
|
-
stream: ReadableStream | NodeJS.ReadableStream
|
|
92
|
-
): Promise<boolean> {
|
|
93
|
-
this.logger.debug(`Writing file: ${assetKey}`)
|
|
117
|
+
public async writeFile(args: WriteFileArgs): Promise<boolean> {
|
|
118
|
+
this.logger.debug(`Writing file: ${args.bucket}/${args.key}`)
|
|
94
119
|
|
|
95
|
-
const path = this.safePath(
|
|
120
|
+
const path = this.safePath(args.bucket, args.key)
|
|
96
121
|
|
|
97
122
|
try {
|
|
98
123
|
await this.createDirectoryForFile(path)
|
|
99
124
|
const fileStream = createWriteStream(path)
|
|
100
|
-
|
|
101
|
-
await pipeline(stream as Readable, fileStream)
|
|
125
|
+
await pipeline(args.stream as Readable, fileStream)
|
|
102
126
|
return true
|
|
103
127
|
} catch (e) {
|
|
104
128
|
console.error(e)
|
|
105
|
-
this.logger.error(`Error writing content ${
|
|
129
|
+
this.logger.error(`Error writing content ${args.bucket}/${args.key}`, e)
|
|
106
130
|
return false
|
|
107
131
|
}
|
|
108
132
|
}
|
|
109
133
|
|
|
110
|
-
public async copyFile(
|
|
111
|
-
|
|
112
|
-
fromAbsolutePath: string
|
|
113
|
-
): Promise<boolean> {
|
|
114
|
-
this.logger.debug(`Writing file: ${assetKey}`)
|
|
134
|
+
public async copyFile(args: CopyFileArgs): Promise<boolean> {
|
|
135
|
+
this.logger.debug(`Writing file: ${args.bucket}/${args.key}`)
|
|
115
136
|
try {
|
|
116
|
-
const path = this.safePath(
|
|
137
|
+
const path = this.safePath(args.bucket, args.key)
|
|
117
138
|
await this.createDirectoryForFile(path)
|
|
118
|
-
await promises.copyFile(fromAbsolutePath, path)
|
|
139
|
+
await promises.copyFile(args.fromAbsolutePath, path)
|
|
140
|
+
return true
|
|
119
141
|
} catch (e) {
|
|
120
142
|
console.error(e)
|
|
121
|
-
this.logger.error(`Error inserting content ${
|
|
143
|
+
this.logger.error(`Error inserting content ${args.bucket}/${args.key}`, e)
|
|
122
144
|
}
|
|
123
145
|
return false
|
|
124
146
|
}
|
|
125
147
|
|
|
126
148
|
public async readFile(
|
|
127
|
-
|
|
149
|
+
args: BucketKeyArgs
|
|
128
150
|
): Promise<ReadableStream | NodeJS.ReadableStream> {
|
|
129
|
-
this.logger.debug(`Getting key: ${
|
|
151
|
+
this.logger.debug(`Getting key: ${args.bucket}/${args.key}`)
|
|
130
152
|
|
|
131
|
-
const filePath = this.safePath(
|
|
153
|
+
const filePath = this.safePath(args.bucket, args.key)
|
|
132
154
|
|
|
133
155
|
try {
|
|
134
156
|
const stream = createReadStream(filePath)
|
|
135
|
-
// Handle early stream errors (like file not found, permission denied, etc.)
|
|
136
157
|
stream.on('error', (err) => {
|
|
137
|
-
this.logger.error(
|
|
158
|
+
this.logger.error(
|
|
159
|
+
`Error getting content ${args.bucket}/${args.key}`,
|
|
160
|
+
err
|
|
161
|
+
)
|
|
138
162
|
})
|
|
139
163
|
|
|
140
164
|
return stream
|
|
141
165
|
} catch (e) {
|
|
142
|
-
this.logger.error(
|
|
166
|
+
this.logger.error(
|
|
167
|
+
`Error setting up stream for ${args.bucket}/${args.key}`,
|
|
168
|
+
e
|
|
169
|
+
)
|
|
143
170
|
throw e
|
|
144
171
|
}
|
|
145
172
|
}
|
|
146
173
|
|
|
147
|
-
public async readFileAsBuffer(
|
|
148
|
-
const filePath = this.safePath(
|
|
149
|
-
this.logger.debug(`Reading file as buffer: ${
|
|
174
|
+
public async readFileAsBuffer(args: BucketKeyArgs): Promise<Buffer> {
|
|
175
|
+
const filePath = this.safePath(args.bucket, args.key)
|
|
176
|
+
this.logger.debug(`Reading file as buffer: ${args.bucket}/${args.key}`)
|
|
150
177
|
return readFile(filePath)
|
|
151
178
|
}
|
|
152
179
|
|
|
153
|
-
public async deleteFile(
|
|
154
|
-
this.logger.debug(`deleting key: ${
|
|
180
|
+
public async deleteFile(args: BucketKeyArgs): Promise<boolean> {
|
|
181
|
+
this.logger.debug(`deleting key: ${args.bucket}/${args.key}`)
|
|
155
182
|
try {
|
|
156
|
-
await promises.unlink(this.safePath(
|
|
183
|
+
await promises.unlink(this.safePath(args.bucket, args.key))
|
|
157
184
|
return true
|
|
158
185
|
} catch (e: any) {
|
|
159
|
-
this.logger.error(`Error deleting content ${
|
|
186
|
+
this.logger.error(`Error deleting content ${args.bucket}/${args.key}`, e)
|
|
160
187
|
}
|
|
161
188
|
return false
|
|
162
189
|
}
|
|
@@ -15,9 +15,9 @@ export type CredentialMetaInfo = {
|
|
|
15
15
|
oauth2?: boolean
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export class TypedCredentialService<
|
|
19
|
-
|
|
20
|
-
{
|
|
18
|
+
export class TypedCredentialService<
|
|
19
|
+
TMap = Record<string, unknown>,
|
|
20
|
+
> implements CredentialService {
|
|
21
21
|
constructor(
|
|
22
22
|
private credentials: CredentialService,
|
|
23
23
|
private credentialsMeta: Record<string, CredentialMetaInfo>
|
|
@@ -14,9 +14,9 @@ export type CredentialMeta = {
|
|
|
14
14
|
oauth2?: { tokenSecretId: string }
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export class TypedSecretService<
|
|
18
|
-
|
|
19
|
-
{
|
|
17
|
+
export class TypedSecretService<
|
|
18
|
+
TMap = Record<string, unknown>,
|
|
19
|
+
> implements SecretService {
|
|
20
20
|
constructor(
|
|
21
21
|
private secrets: SecretService,
|
|
22
22
|
private credentialsMeta: Record<string, CredentialMeta>
|
|
@@ -12,9 +12,9 @@ export type VariableMeta = {
|
|
|
12
12
|
displayName: string
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export class TypedVariablesService<
|
|
16
|
-
|
|
17
|
-
{
|
|
15
|
+
export class TypedVariablesService<
|
|
16
|
+
TMap = Record<string, unknown>,
|
|
17
|
+
> implements VariablesService {
|
|
18
18
|
constructor(
|
|
19
19
|
private variables: VariablesService,
|
|
20
20
|
private variablesMeta: Record<string, VariableMeta>
|
|
@@ -11,12 +11,12 @@ export interface SessionService<UserSession extends CoreUserSession> {
|
|
|
11
11
|
get(): UserSession | undefined
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export class PikkuSessionService<
|
|
15
|
-
|
|
16
|
-
{
|
|
14
|
+
export class PikkuSessionService<
|
|
15
|
+
UserSession extends CoreUserSession,
|
|
16
|
+
> implements SessionService<UserSession> {
|
|
17
17
|
public sessionChanged = false
|
|
18
18
|
public initial: UserSession | undefined
|
|
19
|
-
|
|
19
|
+
protected session: UserSession | undefined
|
|
20
20
|
private pikkuUserId?: string
|
|
21
21
|
|
|
22
22
|
constructor(private sessionStore?: SessionStore<UserSession>) {}
|
|
@@ -102,6 +102,36 @@ export function defineServiceTests(config: ServiceTestConfig): void {
|
|
|
102
102
|
test('removeChannels with empty array is no-op', async () => {
|
|
103
103
|
await store.removeChannels([])
|
|
104
104
|
})
|
|
105
|
+
|
|
106
|
+
test('session round-trip — set / get / clear', async () => {
|
|
107
|
+
await store.addChannel({
|
|
108
|
+
channelId: 'ch-state',
|
|
109
|
+
channelName: 'test-channel',
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
// initially undefined
|
|
113
|
+
const empty = await store.getState('ch-state')
|
|
114
|
+
assert.equal(empty, undefined)
|
|
115
|
+
|
|
116
|
+
// set + get
|
|
117
|
+
const payload = { userId: 'u-7', meta: { foo: 1 } }
|
|
118
|
+
await store.setState('ch-state', payload)
|
|
119
|
+
const got = await store.getState('ch-state')
|
|
120
|
+
assert.deepEqual(got, payload)
|
|
121
|
+
|
|
122
|
+
// overwrite
|
|
123
|
+
const next = { userId: 'u-8' }
|
|
124
|
+
await store.setState('ch-state', next)
|
|
125
|
+
const got2 = await store.getState('ch-state')
|
|
126
|
+
assert.deepEqual(got2, next)
|
|
127
|
+
|
|
128
|
+
// clear
|
|
129
|
+
await store.clearState('ch-state')
|
|
130
|
+
const after = await store.getState('ch-state')
|
|
131
|
+
assert.equal(after, undefined)
|
|
132
|
+
|
|
133
|
+
await store.removeChannels(['ch-state'])
|
|
134
|
+
})
|
|
105
135
|
})
|
|
106
136
|
}
|
|
107
137
|
|
package/src/types/core.types.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
CorePikkuChannelMiddleware,
|
|
10
10
|
CorePikkuChannelMiddlewareFactory,
|
|
11
11
|
} from '../wirings/channel/channel.types.js'
|
|
12
|
+
import type { EventHubService } from '../wirings/channel/eventhub-service.js'
|
|
12
13
|
import type { PikkuRPC } from '../wirings/rpc/rpc-types.js'
|
|
13
14
|
import type { PikkuMCP } from '../wirings/mcp/mcp.types.js'
|
|
14
15
|
import type { PikkuScheduledTask } from '../wirings/scheduler/scheduler.types.js'
|
|
@@ -115,6 +116,7 @@ export type FunctionRuntimeMeta = {
|
|
|
115
116
|
version?: number
|
|
116
117
|
approvalRequired?: boolean
|
|
117
118
|
approvalDescription?: string
|
|
119
|
+
implementationHash?: string
|
|
118
120
|
contractHash?: string
|
|
119
121
|
inputHash?: string
|
|
120
122
|
outputHash?: string
|
|
@@ -216,6 +218,8 @@ export interface CoreSingletonServices<Config extends CoreConfig = CoreConfig> {
|
|
|
216
218
|
workflowService?: WorkflowService
|
|
217
219
|
/** The queue service */
|
|
218
220
|
queueService?: QueueService
|
|
221
|
+
/** Event hub for realtime pub/sub across channels */
|
|
222
|
+
eventHub?: EventHubService<Record<string, any>>
|
|
219
223
|
/** The scheduler service */
|
|
220
224
|
schedulerService?: SchedulerService
|
|
221
225
|
/** The deployment service for service discovery */
|
|
@@ -485,8 +489,8 @@ export type CreateSingletonServices<
|
|
|
485
489
|
*/
|
|
486
490
|
export type CreateWireServices<
|
|
487
491
|
SingletonServices extends CoreSingletonServices = CoreSingletonServices,
|
|
488
|
-
Services extends
|
|
489
|
-
CoreServices<SingletonServices
|
|
492
|
+
Services extends CoreServices<SingletonServices> =
|
|
493
|
+
CoreServices<SingletonServices>,
|
|
490
494
|
UserSession extends CoreUserSession = CoreUserSession,
|
|
491
495
|
> = (
|
|
492
496
|
services: SingletonServices,
|
package/src/types/state.types.ts
CHANGED
|
@@ -138,6 +138,7 @@ export interface PikkuPackageState {
|
|
|
138
138
|
middleware: {
|
|
139
139
|
tagGroup: Record<string, CorePikkuMiddlewareGroup>
|
|
140
140
|
httpGroup: Record<string, CorePikkuMiddlewareGroup>
|
|
141
|
+
global: CorePikkuMiddlewareGroup
|
|
141
142
|
}
|
|
142
143
|
channelMiddleware: {
|
|
143
144
|
tagGroup: Record<string, CorePikkuChannelMiddleware[]>
|
|
@@ -145,6 +146,7 @@ export interface PikkuPackageState {
|
|
|
145
146
|
permissions: {
|
|
146
147
|
tagGroup: Record<string, CorePermissionGroup | CorePikkuPermission[]>
|
|
147
148
|
httpGroup: Record<string, CorePermissionGroup | CorePikkuPermission[]>
|
|
149
|
+
global: (CorePermissionGroup | CorePikkuPermission)[]
|
|
148
150
|
}
|
|
149
151
|
misc: {
|
|
150
152
|
errors: Map<PikkuError, ErrorDetails>
|
|
@@ -153,19 +155,6 @@ export interface PikkuPackageState {
|
|
|
153
155
|
channelMiddleware: Record<string, CorePikkuChannelMiddleware[]>
|
|
154
156
|
permissions: Record<string, CorePermissionGroup | CorePikkuPermission[]>
|
|
155
157
|
}
|
|
156
|
-
models: {
|
|
157
|
-
config: {
|
|
158
|
-
models?: Record<
|
|
159
|
-
string,
|
|
160
|
-
string | { model: string; temperature?: number; maxSteps?: number }
|
|
161
|
-
>
|
|
162
|
-
agentDefaults?: { temperature?: number; maxSteps?: number }
|
|
163
|
-
agentOverrides?: Record<
|
|
164
|
-
string,
|
|
165
|
-
{ model?: string; temperature?: number; maxSteps?: number }
|
|
166
|
-
>
|
|
167
|
-
} | null
|
|
168
|
-
}
|
|
169
158
|
package: {
|
|
170
159
|
/** Service factory functions for addon packages */
|
|
171
160
|
factories: {
|