@pikku/kysely 0.12.6 → 0.12.7
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 +6 -0
- package/dist/src/kysely-agent-run-service.js +59 -59
- package/dist/src/kysely-ai-storage-service.js +174 -174
- package/dist/src/kysely-channel-store.js +12 -12
- package/dist/src/kysely-credential-service.js +29 -29
- package/dist/src/kysely-deployment-service.js +22 -22
- package/dist/src/kysely-eventhub-store.js +8 -8
- package/dist/src/kysely-secret-service.js +19 -19
- package/dist/src/kysely-tables.d.ts +91 -91
- package/dist/src/kysely-workflow-run-service.js +73 -73
- package/dist/src/kysely-workflow-service.js +127 -127
- package/package.json +1 -1
- package/src/kysely-agent-run-service.ts +59 -59
- package/src/kysely-ai-storage-service.ts +174 -174
- package/src/kysely-channel-store.ts +12 -12
- package/src/kysely-credential-service.ts +29 -29
- package/src/kysely-deployment-service.ts +24 -24
- package/src/kysely-eventhub-store.ts +8 -8
- package/src/kysely-secret-service.ts +19 -19
- package/src/kysely-services.test.ts +19 -18
- package/src/kysely-tables.ts +91 -91
- package/src/kysely-workflow-run-service.ts +76 -76
- package/src/kysely-workflow-service.ts +129 -129
package/src/kysely-tables.ts
CHANGED
|
@@ -6,21 +6,21 @@ import type {
|
|
|
6
6
|
} from '@pikku/core/workflow'
|
|
7
7
|
|
|
8
8
|
export interface ChannelsTable {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
channelId: string
|
|
10
|
+
channelName: string
|
|
11
|
+
createdAt: Generated<Date>
|
|
12
|
+
openingData: string
|
|
13
|
+
userSession: string | null
|
|
14
|
+
lastWire: Generated<Date>
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export interface ChannelSubscriptionsTable {
|
|
18
|
-
|
|
18
|
+
channelId: string
|
|
19
19
|
topic: string
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export interface WorkflowRunsTable {
|
|
23
|
-
|
|
23
|
+
workflowRunId: Generated<string>
|
|
24
24
|
workflow: string
|
|
25
25
|
status: WorkflowStatus
|
|
26
26
|
input: string
|
|
@@ -28,169 +28,169 @@ export interface WorkflowRunsTable {
|
|
|
28
28
|
error: string | null
|
|
29
29
|
state: Generated<string>
|
|
30
30
|
inline: Generated<boolean>
|
|
31
|
-
|
|
31
|
+
graphHash: string | null
|
|
32
32
|
wire: string | null
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
createdAt: Generated<Date>
|
|
34
|
+
updatedAt: Generated<Date>
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export interface WorkflowStepTable {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
workflowStepId: Generated<string>
|
|
39
|
+
workflowRunId: string
|
|
40
|
+
stepName: string
|
|
41
|
+
rpcName: string | null
|
|
42
42
|
data: string | null
|
|
43
43
|
status: Generated<StepStatus>
|
|
44
44
|
result: string | null
|
|
45
45
|
error: string | null
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
childRunId: string | null
|
|
47
|
+
branchTaken: string | null
|
|
48
48
|
retries: number | null
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
retryDelay: string | null
|
|
50
|
+
createdAt: Generated<Date>
|
|
51
|
+
updatedAt: Generated<Date>
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
export interface WorkflowStepHistoryTable {
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
historyId: Generated<string>
|
|
56
|
+
workflowStepId: string
|
|
57
57
|
status: StepStatus
|
|
58
58
|
result: string | null
|
|
59
59
|
error: string | null
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
createdAt: Generated<Date>
|
|
61
|
+
runningAt: Date | null
|
|
62
|
+
scheduledAt: Date | null
|
|
63
|
+
succeededAt: Date | null
|
|
64
|
+
failedAt: Date | null
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
export interface WorkflowVersionsTable {
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
workflowName: string
|
|
69
|
+
graphHash: string
|
|
70
70
|
graph: string
|
|
71
71
|
source: string
|
|
72
72
|
status: Generated<WorkflowVersionStatus>
|
|
73
|
-
|
|
73
|
+
createdAt: Generated<Date>
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
export interface AIThreadsTable {
|
|
77
77
|
id: string
|
|
78
|
-
|
|
78
|
+
resourceId: string
|
|
79
79
|
title: string | null
|
|
80
80
|
metadata: string | null
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
createdAt: Generated<Date>
|
|
82
|
+
updatedAt: Generated<Date>
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
export interface AIMessageTable {
|
|
86
86
|
id: string
|
|
87
|
-
|
|
87
|
+
threadId: string
|
|
88
88
|
role: 'system' | 'user' | 'assistant' | 'tool'
|
|
89
89
|
content: string | null
|
|
90
|
-
|
|
90
|
+
createdAt: Generated<Date>
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
export interface AIToolCallTable {
|
|
94
94
|
id: string
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
threadId: string
|
|
96
|
+
messageId: string
|
|
97
|
+
runId: string | null
|
|
98
|
+
toolName: string
|
|
99
99
|
args: string
|
|
100
100
|
result: string | null
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
101
|
+
approvalStatus: 'approved' | 'denied' | 'pending' | null
|
|
102
|
+
approvalType: 'agent-call' | 'tool-call' | null
|
|
103
|
+
agentRunId: string | null
|
|
104
|
+
displayToolName: string | null
|
|
105
|
+
displayArgs: string | null
|
|
106
|
+
createdAt: Generated<Date>
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
export interface AIWorkingMemoryTable {
|
|
110
110
|
id: string
|
|
111
111
|
scope: string
|
|
112
112
|
data: string
|
|
113
|
-
|
|
113
|
+
updatedAt: Generated<Date>
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
export interface AIRunTable {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
runId: Generated<string>
|
|
118
|
+
agentName: string
|
|
119
|
+
threadId: string
|
|
120
|
+
resourceId: string
|
|
121
121
|
status: Generated<'running' | 'suspended' | 'completed' | 'failed'>
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
122
|
+
errorMessage: string | null
|
|
123
|
+
suspendReason: 'approval' | 'rpc-missing' | null
|
|
124
|
+
missingRpcs: string | null
|
|
125
|
+
usageInputTokens: Generated<number>
|
|
126
|
+
usageOutputTokens: Generated<number>
|
|
127
|
+
usageModel: Generated<string>
|
|
128
|
+
createdAt: Generated<Date>
|
|
129
|
+
updatedAt: Generated<Date>
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
export interface PikkuDeploymentsTable {
|
|
133
|
-
|
|
133
|
+
deploymentId: string
|
|
134
134
|
endpoint: string
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
lastHeartbeat: Generated<Date>
|
|
136
|
+
createdAt: Generated<Date>
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
export interface PikkuDeploymentFunctionsTable {
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
deploymentId: string
|
|
141
|
+
functionName: string
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
export interface SecretsTable {
|
|
145
145
|
key: string
|
|
146
146
|
ciphertext: string
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
147
|
+
wrappedDek: string
|
|
148
|
+
keyVersion: number
|
|
149
|
+
createdAt: Generated<Date>
|
|
150
|
+
updatedAt: Generated<Date>
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
export interface SecretsAuditTable {
|
|
154
154
|
id: string
|
|
155
|
-
|
|
155
|
+
secretKey: string
|
|
156
156
|
action: string
|
|
157
|
-
|
|
157
|
+
performedAt: Generated<Date>
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
export interface CredentialsTable {
|
|
161
161
|
name: string
|
|
162
|
-
|
|
162
|
+
userId: string | null
|
|
163
163
|
ciphertext: string
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
164
|
+
wrappedDek: string
|
|
165
|
+
keyVersion: number
|
|
166
|
+
createdAt: Generated<Date>
|
|
167
|
+
updatedAt: Generated<Date>
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
export interface CredentialsAuditTable {
|
|
171
171
|
id: string
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
credentialName: string
|
|
173
|
+
userId: string | null
|
|
174
174
|
action: string
|
|
175
|
-
|
|
175
|
+
performedAt: Generated<Date>
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
export interface KyselyPikkuDB {
|
|
179
179
|
channels: ChannelsTable
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
180
|
+
channelSubscriptions: ChannelSubscriptionsTable
|
|
181
|
+
workflowRuns: WorkflowRunsTable
|
|
182
|
+
workflowStep: WorkflowStepTable
|
|
183
|
+
workflowStepHistory: WorkflowStepHistoryTable
|
|
184
|
+
workflowVersions: WorkflowVersionsTable
|
|
185
|
+
aiThreads: AIThreadsTable
|
|
186
|
+
aiMessage: AIMessageTable
|
|
187
|
+
aiToolCall: AIToolCallTable
|
|
188
|
+
aiWorkingMemory: AIWorkingMemoryTable
|
|
189
|
+
aiRun: AIRunTable
|
|
190
|
+
pikkuDeployments: PikkuDeploymentsTable
|
|
191
|
+
pikkuDeploymentFunctions: PikkuDeploymentFunctionsTable
|
|
192
192
|
secrets: SecretsTable
|
|
193
|
-
|
|
193
|
+
secretsAudit: SecretsAuditTable
|
|
194
194
|
credentials: CredentialsTable
|
|
195
|
-
|
|
195
|
+
credentialsAudit: CredentialsAuditTable
|
|
196
196
|
}
|
|
@@ -20,19 +20,19 @@ export class KyselyWorkflowRunService implements WorkflowRunService {
|
|
|
20
20
|
const { workflowName, status, limit = 50, offset = 0 } = options ?? {}
|
|
21
21
|
|
|
22
22
|
let query = this.db
|
|
23
|
-
.selectFrom('
|
|
23
|
+
.selectFrom('workflowRuns')
|
|
24
24
|
.select([
|
|
25
|
-
'
|
|
25
|
+
'workflowRunId',
|
|
26
26
|
'workflow',
|
|
27
27
|
'status',
|
|
28
28
|
'input',
|
|
29
29
|
'output',
|
|
30
30
|
'error',
|
|
31
31
|
'inline',
|
|
32
|
-
'
|
|
32
|
+
'graphHash',
|
|
33
33
|
'wire',
|
|
34
|
-
'
|
|
35
|
-
'
|
|
34
|
+
'createdAt',
|
|
35
|
+
'updatedAt',
|
|
36
36
|
])
|
|
37
37
|
|
|
38
38
|
if (workflowName) {
|
|
@@ -44,7 +44,7 @@ export class KyselyWorkflowRunService implements WorkflowRunService {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
const result = await query
|
|
47
|
-
.orderBy('
|
|
47
|
+
.orderBy('createdAt', 'desc')
|
|
48
48
|
.limit(limit)
|
|
49
49
|
.offset(offset)
|
|
50
50
|
.execute()
|
|
@@ -54,21 +54,21 @@ export class KyselyWorkflowRunService implements WorkflowRunService {
|
|
|
54
54
|
|
|
55
55
|
async getRun(id: string): Promise<WorkflowRun | null> {
|
|
56
56
|
const row = await this.db
|
|
57
|
-
.selectFrom('
|
|
57
|
+
.selectFrom('workflowRuns')
|
|
58
58
|
.select([
|
|
59
|
-
'
|
|
59
|
+
'workflowRunId',
|
|
60
60
|
'workflow',
|
|
61
61
|
'status',
|
|
62
62
|
'input',
|
|
63
63
|
'output',
|
|
64
64
|
'error',
|
|
65
65
|
'inline',
|
|
66
|
-
'
|
|
66
|
+
'graphHash',
|
|
67
67
|
'wire',
|
|
68
|
-
'
|
|
69
|
-
'
|
|
68
|
+
'createdAt',
|
|
69
|
+
'updatedAt',
|
|
70
70
|
])
|
|
71
|
-
.where('
|
|
71
|
+
.where('workflowRunId', '=', id)
|
|
72
72
|
.executeTakeFirst()
|
|
73
73
|
|
|
74
74
|
if (!row) return null
|
|
@@ -81,50 +81,50 @@ export class KyselyWorkflowRunService implements WorkflowRunService {
|
|
|
81
81
|
Array<StepState & { stepName: string; rpcName?: string; data?: any }>
|
|
82
82
|
> {
|
|
83
83
|
const result = await this.db
|
|
84
|
-
.selectFrom('
|
|
84
|
+
.selectFrom('workflowStep as s')
|
|
85
85
|
.select([
|
|
86
|
-
's.
|
|
87
|
-
's.
|
|
88
|
-
's.
|
|
86
|
+
's.workflowStepId',
|
|
87
|
+
's.stepName',
|
|
88
|
+
's.rpcName',
|
|
89
89
|
's.data',
|
|
90
90
|
's.status',
|
|
91
91
|
's.result',
|
|
92
92
|
's.error',
|
|
93
|
-
's.
|
|
93
|
+
's.childRunId',
|
|
94
94
|
's.retries',
|
|
95
|
-
's.
|
|
96
|
-
's.
|
|
97
|
-
's.
|
|
95
|
+
's.retryDelay',
|
|
96
|
+
's.createdAt',
|
|
97
|
+
's.updatedAt',
|
|
98
98
|
])
|
|
99
99
|
.select((eb) =>
|
|
100
100
|
eb
|
|
101
|
-
.selectFrom('
|
|
101
|
+
.selectFrom('workflowStepHistory')
|
|
102
102
|
.select(eb.fn.countAll<number>().as('cnt'))
|
|
103
103
|
.whereRef(
|
|
104
|
-
'
|
|
104
|
+
'workflowStepHistory.workflowStepId',
|
|
105
105
|
'=',
|
|
106
|
-
's.
|
|
106
|
+
's.workflowStepId'
|
|
107
107
|
)
|
|
108
|
-
.as('
|
|
108
|
+
.as('attemptCount')
|
|
109
109
|
)
|
|
110
|
-
.where('s.
|
|
111
|
-
.orderBy('s.
|
|
110
|
+
.where('s.workflowRunId', '=', runId)
|
|
111
|
+
.orderBy('s.createdAt', 'asc')
|
|
112
112
|
.execute()
|
|
113
113
|
|
|
114
114
|
return result.map((row) => ({
|
|
115
|
-
stepId: row.
|
|
116
|
-
stepName: row.
|
|
117
|
-
rpcName: row.
|
|
115
|
+
stepId: row.workflowStepId,
|
|
116
|
+
stepName: row.stepName,
|
|
117
|
+
rpcName: row.rpcName ?? undefined,
|
|
118
118
|
data: parseJson(row.data),
|
|
119
119
|
status: row.status as StepState['status'],
|
|
120
120
|
result: parseJson(row.result),
|
|
121
121
|
error: parseJson(row.error),
|
|
122
|
-
childRunId: row.
|
|
123
|
-
attemptCount: Number(row.
|
|
122
|
+
childRunId: row.childRunId ?? undefined,
|
|
123
|
+
attemptCount: Number(row.attemptCount || 1),
|
|
124
124
|
retries: row.retries != null ? Number(row.retries) : undefined,
|
|
125
|
-
retryDelay: row.
|
|
126
|
-
createdAt: new Date(row.
|
|
127
|
-
updatedAt: new Date(row.
|
|
125
|
+
retryDelay: row.retryDelay ?? undefined,
|
|
126
|
+
createdAt: new Date(row.createdAt as unknown as string),
|
|
127
|
+
updatedAt: new Date(row.updatedAt as unknown as string),
|
|
128
128
|
}))
|
|
129
129
|
}
|
|
130
130
|
|
|
@@ -132,57 +132,57 @@ export class KyselyWorkflowRunService implements WorkflowRunService {
|
|
|
132
132
|
runId: string
|
|
133
133
|
): Promise<Array<StepState & { stepName: string }>> {
|
|
134
134
|
const result = await this.db
|
|
135
|
-
.selectFrom('
|
|
135
|
+
.selectFrom('workflowStep as s')
|
|
136
136
|
.innerJoin(
|
|
137
|
-
'
|
|
138
|
-
'h.
|
|
139
|
-
's.
|
|
137
|
+
'workflowStepHistory as h',
|
|
138
|
+
'h.workflowStepId',
|
|
139
|
+
's.workflowStepId'
|
|
140
140
|
)
|
|
141
141
|
.select([
|
|
142
|
-
's.
|
|
143
|
-
's.
|
|
142
|
+
's.workflowStepId',
|
|
143
|
+
's.stepName',
|
|
144
144
|
's.retries',
|
|
145
|
-
's.
|
|
145
|
+
's.retryDelay',
|
|
146
146
|
'h.status',
|
|
147
147
|
'h.result',
|
|
148
148
|
'h.error',
|
|
149
|
-
'h.
|
|
150
|
-
'h.
|
|
151
|
-
'h.
|
|
152
|
-
'h.
|
|
153
|
-
'h.
|
|
149
|
+
'h.createdAt',
|
|
150
|
+
'h.runningAt',
|
|
151
|
+
'h.scheduledAt',
|
|
152
|
+
'h.succeededAt',
|
|
153
|
+
'h.failedAt',
|
|
154
154
|
])
|
|
155
|
-
.where('s.
|
|
156
|
-
.orderBy('h.
|
|
155
|
+
.where('s.workflowRunId', '=', runId)
|
|
156
|
+
.orderBy('h.createdAt', 'asc')
|
|
157
157
|
.execute()
|
|
158
158
|
|
|
159
159
|
let attemptCounters: Record<string, number> = {}
|
|
160
160
|
return result.map((row) => {
|
|
161
|
-
const stepId = row.
|
|
161
|
+
const stepId = row.workflowStepId
|
|
162
162
|
attemptCounters[stepId] = (attemptCounters[stepId] ?? 0) + 1
|
|
163
163
|
|
|
164
164
|
return {
|
|
165
165
|
stepId,
|
|
166
|
-
stepName: row.
|
|
166
|
+
stepName: row.stepName,
|
|
167
167
|
status: row.status as StepState['status'],
|
|
168
168
|
result: parseJson(row.result),
|
|
169
169
|
error: parseJson(row.error),
|
|
170
170
|
attemptCount: attemptCounters[stepId]!,
|
|
171
171
|
retries: row.retries != null ? Number(row.retries) : undefined,
|
|
172
|
-
retryDelay: row.
|
|
173
|
-
createdAt: new Date(row.
|
|
174
|
-
updatedAt: new Date(row.
|
|
175
|
-
runningAt: row.
|
|
176
|
-
? new Date(row.
|
|
172
|
+
retryDelay: row.retryDelay ?? undefined,
|
|
173
|
+
createdAt: new Date(row.createdAt as unknown as string),
|
|
174
|
+
updatedAt: new Date(row.createdAt as unknown as string),
|
|
175
|
+
runningAt: row.runningAt
|
|
176
|
+
? new Date(row.runningAt as unknown as string)
|
|
177
177
|
: undefined,
|
|
178
|
-
scheduledAt: row.
|
|
179
|
-
? new Date(row.
|
|
178
|
+
scheduledAt: row.scheduledAt
|
|
179
|
+
? new Date(row.scheduledAt as unknown as string)
|
|
180
180
|
: undefined,
|
|
181
|
-
succeededAt: row.
|
|
182
|
-
? new Date(row.
|
|
181
|
+
succeededAt: row.succeededAt
|
|
182
|
+
? new Date(row.succeededAt as unknown as string)
|
|
183
183
|
: undefined,
|
|
184
|
-
failedAt: row.
|
|
185
|
-
? new Date(row.
|
|
184
|
+
failedAt: row.failedAt
|
|
185
|
+
? new Date(row.failedAt as unknown as string)
|
|
186
186
|
: undefined,
|
|
187
187
|
}
|
|
188
188
|
})
|
|
@@ -190,7 +190,7 @@ export class KyselyWorkflowRunService implements WorkflowRunService {
|
|
|
190
190
|
|
|
191
191
|
async getDistinctWorkflowNames(): Promise<string[]> {
|
|
192
192
|
const result = await this.db
|
|
193
|
-
.selectFrom('
|
|
193
|
+
.selectFrom('workflowRuns')
|
|
194
194
|
.select('workflow')
|
|
195
195
|
.distinct()
|
|
196
196
|
.orderBy('workflow')
|
|
@@ -204,10 +204,10 @@ export class KyselyWorkflowRunService implements WorkflowRunService {
|
|
|
204
204
|
graphHash: string
|
|
205
205
|
): Promise<{ graph: any; source: string } | null> {
|
|
206
206
|
const row = await this.db
|
|
207
|
-
.selectFrom('
|
|
207
|
+
.selectFrom('workflowVersions')
|
|
208
208
|
.select(['graph', 'source'])
|
|
209
|
-
.where('
|
|
210
|
-
.where('
|
|
209
|
+
.where('workflowName', '=', name)
|
|
210
|
+
.where('graphHash', '=', graphHash)
|
|
211
211
|
.executeTakeFirst()
|
|
212
212
|
|
|
213
213
|
if (!row) return null
|
|
@@ -221,25 +221,25 @@ export class KyselyWorkflowRunService implements WorkflowRunService {
|
|
|
221
221
|
agentName?: string
|
|
222
222
|
): Promise<Array<{ workflowName: string; graphHash: string; graph: any }>> {
|
|
223
223
|
let query = this.db
|
|
224
|
-
.selectFrom('
|
|
225
|
-
.select(['
|
|
224
|
+
.selectFrom('workflowVersions')
|
|
225
|
+
.select(['workflowName', 'graphHash', 'graph'])
|
|
226
226
|
.where('source', '=', 'ai-agent')
|
|
227
227
|
.where('status', '=', 'active')
|
|
228
228
|
if (agentName) {
|
|
229
|
-
query = query.where('
|
|
229
|
+
query = query.where('workflowName', 'like', `ai:${agentName}:%`)
|
|
230
230
|
}
|
|
231
231
|
const rows = await query.execute()
|
|
232
232
|
return rows.map((row) => ({
|
|
233
|
-
workflowName: row.
|
|
234
|
-
graphHash: row.
|
|
233
|
+
workflowName: row.workflowName,
|
|
234
|
+
graphHash: row.graphHash,
|
|
235
235
|
graph: parseJson(row.graph),
|
|
236
236
|
}))
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
async deleteRun(id: string): Promise<boolean> {
|
|
240
240
|
const result = await this.db
|
|
241
|
-
.deleteFrom('
|
|
242
|
-
.where('
|
|
241
|
+
.deleteFrom('workflowRuns')
|
|
242
|
+
.where('workflowRunId', '=', id)
|
|
243
243
|
.executeTakeFirst()
|
|
244
244
|
|
|
245
245
|
return BigInt(result.numDeletedRows) > 0n
|
|
@@ -247,17 +247,17 @@ export class KyselyWorkflowRunService implements WorkflowRunService {
|
|
|
247
247
|
|
|
248
248
|
private mapRunRow(row: any): WorkflowRun {
|
|
249
249
|
return {
|
|
250
|
-
id: row.
|
|
250
|
+
id: row.workflowRunId as string,
|
|
251
251
|
workflow: row.workflow as string,
|
|
252
252
|
status: row.status as WorkflowStatus,
|
|
253
253
|
input: parseJson(row.input),
|
|
254
254
|
output: parseJson(row.output),
|
|
255
255
|
error: parseJson(row.error),
|
|
256
256
|
inline: row.inline as boolean | undefined,
|
|
257
|
-
graphHash: row.
|
|
257
|
+
graphHash: row.graphHash as string | undefined,
|
|
258
258
|
wire: parseJson(row.wire) ?? { type: 'unknown' },
|
|
259
|
-
createdAt: new Date(row.
|
|
260
|
-
updatedAt: new Date(row.
|
|
259
|
+
createdAt: new Date(row.createdAt as string),
|
|
260
|
+
updatedAt: new Date(row.updatedAt as string),
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
}
|