@sixb/sqlite 0.1.8 → 0.1.9
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/action-run-storage.d.ts.map +1 -1
- package/dist/agents/rows.d.ts +0 -1
- package/dist/agents/rows.d.ts.map +1 -1
- package/dist/agents/runs.d.ts.map +1 -1
- package/dist/ai-cost-storage.d.ts.map +1 -1
- package/dist/ai-usage-storage.d.ts.map +1 -1
- package/dist/execution-storage.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +89 -64
- package/dist/index.js.map +14 -14
- package/dist/migrations.d.ts.map +1 -1
- package/dist/pipeline-run-storage.d.ts.map +1 -1
- package/dist/sync-run-storage.d.ts.map +1 -1
- package/dist/workflow-run-storage.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/action-run-storage.ts +6 -7
- package/src/agents/rows.ts +0 -2
- package/src/agents/runs.ts +3 -7
- package/src/ai-cost-groups.ts +3 -0
- package/src/ai-cost-storage.ts +11 -2
- package/src/ai-usage-storage.ts +1 -2
- package/src/execution-storage.ts +7 -5
- package/src/index.ts +4 -2
- package/src/migrations/037-execution-requester-groups.sql +24 -0
- package/src/migrations.ts +5 -0
- package/src/pipeline-run-storage.ts +2 -5
- package/src/sync-run-storage.ts +2 -5
- package/src/workflow-run-storage.ts +1 -6
package/dist/migrations.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../src/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAIrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAGV,YAAY,EACZ,aAAa,EACb,oBAAoB,EACrB,MAAM,oBAAoB,CAAA;AA+F3B,eAAO,MAAM,yBAAyB,sBAAsB,CAAA;AAC5D,eAAO,MAAM,mBAAmB,mBAAmB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
-
{"version":3,"file":"pipeline-run-storage.d.ts","sourceRoot":"","sources":["../src/pipeline-run-storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pipeline-run-storage.d.ts","sourceRoot":"","sources":["../src/pipeline-run-storage.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,gBAAgB,EAChB,sBAAsB,EACtB,0BAA0B,EAC1B,2BAA2B,EAC3B,4BAA4B,EAC5B,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,EAC1B,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,yBAAyB,EAC1B,MAAM,oBAAoB,CAAA;AAW3B,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,gBAAgB,CAAA;AAEvB,MAAM,WAAW,+BAA+B;IAC9C,8DAA8D;IAC9D,UAAU,EAAE,gBAAgB,CAAA;IAC5B,mFAAmF;IACnF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,gEAAgE;IAChE,UAAU,CAAC,EAAE,qBAAqB,CAAA;CACnC;AAED,qBAAa,wBAAyB,YAAW,kBAAkB;IACjE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuB;IAClD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAU;IAC7B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkB;gBAEjC,OAAO,EAAE,+BAA+B;IAU9C,KAAK,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC;YAmDvD,0BAA0B;IAmClC,KAAK,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAgC/D,MAAM,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAwDjE,SAAS,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAgF3E,UAAU,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA2D7E,OAAO,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAQrF,IAAI,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAyCnE,uBAAuB,CAC3B,KAAK,EAAE,2BAA2B,GACjC,OAAO,CAAC,4BAA4B,CAAC;IAelC,SAAS,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAmDtF,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-run-storage.d.ts","sourceRoot":"","sources":["../src/sync-run-storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sync-run-storage.d.ts","sourceRoot":"","sources":["../src/sync-run-storage.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACf,MAAM,oBAAoB,CAAA;AAU3B,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,gBAAgB,CAAA;AAEvB,MAAM,WAAW,2BAA2B;IAC1C,8DAA8D;IAC9D,UAAU,EAAE,gBAAgB,CAAA;IAC5B,mFAAmF;IACnF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,gEAAgE;IAChE,UAAU,CAAC,EAAE,qBAAqB,CAAA;CACnC;AAED,qBAAa,oBAAqB,YAAW,cAAc;IACzD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuB;IAClD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAU;IAC7B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkB;gBAEjC,OAAO,EAAE,2BAA2B;IAU1C,KAAK,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;YA2D/C,0BAA0B;IAgClC,KAAK,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;IAgCvD,MAAM,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC;IAyEzD,OAAO,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAQjF,IAAI,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA8C3D,mBAAmB,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAe5F,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-run-storage.d.ts","sourceRoot":"","sources":["../src/workflow-run-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"workflow-run-storage.d.ts","sourceRoot":"","sources":["../src/workflow-run-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAO1C,OAAO,KAAK,EACV,+BAA+B,EAC/B,kDAAkD,EAClD,yCAAyC,EACzC,+BAA+B,EAC/B,gBAAgB,EAChB,+BAA+B,EAC/B,0BAA0B,EAC1B,sBAAsB,EACtB,2BAA2B,EAC3B,4BAA4B,EAC5B,8BAA8B,EAC9B,+BAA+B,EAC/B,yBAAyB,EACzB,0BAA0B,EAC1B,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,gCAAgC,EAChC,uBAAuB,EACvB,sBAAsB,EACtB,8BAA8B,EAC9B,yBAAyB,E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AoBtB;AAED,qBAAa,4BAA6B,YAAW,sBAAsB;IAC7D,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,QAAQ;IAEnC,KAAK,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAqFvE,MAAM,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAkDzE,IAAI,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAyCrE,OAAO,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IAQzF,IAAI,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAwDjF,OAAO,CAAC,yBAAyB;CAOlC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sixb/sqlite",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "SQLite storage provider for Sixb",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sixb",
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
"prepack": "bun run build"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@sixb/core": "0.1.
|
|
39
|
+
"@sixb/core": "0.1.9"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@sixb/core": "0.1.
|
|
42
|
+
"@sixb/core": "0.1.9",
|
|
43
43
|
"@types/bun": "latest",
|
|
44
44
|
"typescript": "^5.7.0"
|
|
45
45
|
},
|
|
46
46
|
"license": "MIT",
|
|
47
47
|
"engines": {
|
|
48
|
-
"bun": ">=1.
|
|
48
|
+
"bun": ">=1.4.2"
|
|
49
49
|
},
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
|
@@ -5,6 +5,11 @@ import {
|
|
|
5
5
|
serializeActionRunFailure,
|
|
6
6
|
} from "@sixb/core/internal/action-run-storage"
|
|
7
7
|
import { assertActionRunExecution } from "@sixb/core/internal/action-run-storage-provider"
|
|
8
|
+
import {
|
|
9
|
+
actionRunPhaseRecordsEqual,
|
|
10
|
+
canRequeueActionRunAfterEnqueueFailure,
|
|
11
|
+
finishActionRunPhase,
|
|
12
|
+
} from "@sixb/core/internal/storage"
|
|
8
13
|
import type {
|
|
9
14
|
ActionRunEffectsRecord,
|
|
10
15
|
ActionRunFailure,
|
|
@@ -24,13 +29,7 @@ import type {
|
|
|
24
29
|
RecordActionWritebackInput,
|
|
25
30
|
StartActionRunInput,
|
|
26
31
|
} from "@sixb/core/storage"
|
|
27
|
-
import {
|
|
28
|
-
ActionRunError,
|
|
29
|
-
actionRunPhaseRecordsEqual,
|
|
30
|
-
canRequeueActionRunAfterEnqueueFailure,
|
|
31
|
-
finishActionRunPhase,
|
|
32
|
-
isTerminalActionRun,
|
|
33
|
-
} from "@sixb/core/storage"
|
|
32
|
+
import { ActionRunError, isTerminalActionRun } from "@sixb/core/storage"
|
|
34
33
|
import { installFreshSqliteSchema } from "./migrations"
|
|
35
34
|
import {
|
|
36
35
|
closeSqliteStoreConnection,
|
package/src/agents/rows.ts
CHANGED
|
@@ -42,7 +42,6 @@ export interface AgentRunRow {
|
|
|
42
42
|
spawn_key: string | null
|
|
43
43
|
spec: string | null
|
|
44
44
|
result: string | null
|
|
45
|
-
requester_group_ids: string
|
|
46
45
|
status: AgentRunRecord["status"]
|
|
47
46
|
model_id: string | null
|
|
48
47
|
finish_reason: string | null
|
|
@@ -111,7 +110,6 @@ export function rowToRunRecord(row: AgentRunRow): AgentRunRecord {
|
|
|
111
110
|
id: row.id,
|
|
112
111
|
projectId: row.project_id,
|
|
113
112
|
executionId: row.execution_id,
|
|
114
|
-
requesterGroupIds: JSON.parse(row.requester_group_ids) as string[],
|
|
115
113
|
status: row.status,
|
|
116
114
|
modelId: row.model_id ?? undefined,
|
|
117
115
|
finishReason: coerceAgentRunFinishReason(row.finish_reason),
|
package/src/agents/runs.ts
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
assertSubagentRunResult,
|
|
7
7
|
subagentRunMatchesCreateInput,
|
|
8
8
|
} from "@sixb/core/internal/agent-run-storage-provider"
|
|
9
|
-
import { normalizeRequesterGroupIds } from "@sixb/core/internal/auth"
|
|
10
9
|
import { serializeSixbFailure } from "@sixb/core/internal/errors"
|
|
11
10
|
import {
|
|
12
11
|
AGENT_RUN_FAILURE_CODES,
|
|
@@ -83,11 +82,10 @@ export class SqliteAgentRunStore implements AgentRunStore {
|
|
|
83
82
|
thread_id,
|
|
84
83
|
trigger_message_id,
|
|
85
84
|
spec,
|
|
86
|
-
requester_group_ids,
|
|
87
85
|
status,
|
|
88
86
|
attempt,
|
|
89
87
|
created_at
|
|
90
|
-
) VALUES (?, ?, ?, 'conversation', ?, ?, ?,
|
|
88
|
+
) VALUES (?, ?, ?, 'conversation', ?, ?, ?, 'queued', 0, ?)
|
|
91
89
|
`
|
|
92
90
|
)
|
|
93
91
|
.run(
|
|
@@ -97,7 +95,6 @@ export class SqliteAgentRunStore implements AgentRunStore {
|
|
|
97
95
|
input.threadId,
|
|
98
96
|
input.triggerMessageId,
|
|
99
97
|
JSON.stringify(input.spec),
|
|
100
|
-
JSON.stringify(normalizeRequesterGroupIds(input.requesterGroupIds)),
|
|
101
98
|
createdAt.toISOString()
|
|
102
99
|
)
|
|
103
100
|
} catch (error) {
|
|
@@ -197,8 +194,8 @@ export class SqliteAgentRunStore implements AgentRunStore {
|
|
|
197
194
|
`
|
|
198
195
|
INSERT INTO agent_runs (
|
|
199
196
|
project_id, id, execution_id, kind, parent_run_id, spawn_key, spec,
|
|
200
|
-
|
|
201
|
-
) VALUES (?, ?, ?, 'subagent', ?, ?, ?,
|
|
197
|
+
status, attempt, created_at
|
|
198
|
+
) VALUES (?, ?, ?, 'subagent', ?, ?, ?, 'queued', 0, ?)
|
|
202
199
|
`
|
|
203
200
|
)
|
|
204
201
|
.run(
|
|
@@ -208,7 +205,6 @@ export class SqliteAgentRunStore implements AgentRunStore {
|
|
|
208
205
|
input.parentRunId,
|
|
209
206
|
input.spawnKey,
|
|
210
207
|
JSON.stringify(input.spec),
|
|
211
|
-
parentRow.requester_group_ids,
|
|
212
208
|
(input.createdAt ?? new Date()).toISOString()
|
|
213
209
|
)
|
|
214
210
|
} catch (error) {
|
package/src/ai-cost-groups.ts
CHANGED
|
@@ -37,6 +37,7 @@ WITH filtered AS (
|
|
|
37
37
|
SELECT COALESCE(root_agent.execution_id, usage.execution_id) AS root_execution_id,
|
|
38
38
|
usage.execution_id, usage.provider_id, usage.requested_model_id, usage.occurred_at,
|
|
39
39
|
usage.total_tokens,
|
|
40
|
+
execution.executor_kind, execution.executor_id, execution.authority_primitive_id AS primitive_id,
|
|
40
41
|
COALESCE(cost.status, 'unvalued') AS valuation_status,
|
|
41
42
|
cost.currency AS amount_currency, cost.amount_nanos,
|
|
42
43
|
root_agent.id AS root_agent_run_id,
|
|
@@ -49,6 +50,7 @@ WITH filtered AS (
|
|
|
49
50
|
workflow_node.workflow_id AS workflow_id,
|
|
50
51
|
workflow_node.workflow_run_id AS workflow_run_id
|
|
51
52
|
FROM ai_model_call_usage AS usage
|
|
53
|
+
JOIN executions AS execution ON execution.project_id = usage.project_id AND execution.id = usage.execution_id
|
|
52
54
|
LEFT JOIN agent_runs AS direct_agent
|
|
53
55
|
ON direct_agent.project_id = usage.project_id AND direct_agent.execution_id = usage.execution_id
|
|
54
56
|
LEFT JOIN agent_runs AS root_agent
|
|
@@ -86,6 +88,7 @@ SELECT filtered.root_execution_id, execution_id, provider_id, requested_model_id
|
|
|
86
88
|
CAST(SUM((amount_nanos / 1000000) % 1000000) AS TEXT) AS amount_middle,
|
|
87
89
|
CAST(SUM(amount_nanos % 1000000) AS TEXT) AS amount_low,
|
|
88
90
|
MAX(root_agent_run_id) AS root_agent_run_id,
|
|
91
|
+
MAX(executor_kind) AS executor_kind, MAX(executor_id) AS executor_id, MAX(primitive_id) AS primitive_id,
|
|
89
92
|
MAX(root_thread_id) AS root_thread_id,
|
|
90
93
|
MAX(direct_kind) AS direct_kind,
|
|
91
94
|
MAX(direct_run_id) AS direct_run_id,
|
package/src/ai-cost-storage.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
aiModelCallCostDetails,
|
|
5
5
|
aiModelCallCostMatchesUsage,
|
|
6
6
|
buildAiAccountingOverviewFromFragments,
|
|
7
|
+
directModelCallAttribution,
|
|
7
8
|
normalizeAiAccountingQuery,
|
|
8
9
|
normalizeAiModelCallAccountingQuery,
|
|
9
10
|
normalizeAiModelCallCostRecord,
|
|
@@ -199,6 +200,7 @@ const SQLITE_ACCOUNTING_LIST_PAGE_SQL = `
|
|
|
199
200
|
workflow_agent.node_run_id AS attribution_node_run_id,
|
|
200
201
|
workflow_node.workflow_id AS attribution_workflow_id,
|
|
201
202
|
workflow_node.workflow_run_id AS attribution_workflow_run_id,
|
|
203
|
+
execution.executor_kind, execution.executor_id, execution.authority_primitive_id AS primitive_id,
|
|
202
204
|
COALESCE((
|
|
203
205
|
SELECT json_group_array(group_id) FROM (
|
|
204
206
|
SELECT group_id FROM ai_model_call_usage_groups
|
|
@@ -215,6 +217,7 @@ const SQLITE_ACCOUNTING_LIST_PAGE_SQL = `
|
|
|
215
217
|
cost.details AS cost_details,
|
|
216
218
|
cost.rated_at AS cost_rated_at
|
|
217
219
|
FROM ai_model_call_usage AS usage
|
|
220
|
+
JOIN executions AS execution ON execution.project_id = usage.project_id AND execution.id = usage.execution_id
|
|
218
221
|
LEFT JOIN agent_runs AS direct_agent
|
|
219
222
|
ON direct_agent.project_id = usage.project_id
|
|
220
223
|
AND direct_agent.execution_id = usage.execution_id
|
|
@@ -250,7 +253,9 @@ const SQLITE_ACCOUNTING_OVERVIEW_SQL = `
|
|
|
250
253
|
ELSE NULL
|
|
251
254
|
END AS attribution_agent_kind,
|
|
252
255
|
workflow_node.node_id AS attribution_agent_step_id,
|
|
253
|
-
workflow_node.workflow_id
|
|
256
|
+
COALESCE(workflow_node.workflow_id,
|
|
257
|
+
CASE WHEN execution.executor_kind = 'workflow' THEN execution.authority_primitive_id END
|
|
258
|
+
) AS attribution_workflow_id,
|
|
254
259
|
CASE
|
|
255
260
|
WHEN cost.status = 'rated' THEN 'rated'
|
|
256
261
|
WHEN cost.status = 'unpriceable' THEN 'unpriceable'
|
|
@@ -259,6 +264,7 @@ const SQLITE_ACCOUNTING_OVERVIEW_SQL = `
|
|
|
259
264
|
CASE WHEN cost.status = 'rated' THEN cost.currency ELSE NULL END AS amount_currency,
|
|
260
265
|
CASE WHEN cost.status = 'rated' THEN cost.amount_nanos ELSE NULL END AS amount_nanos
|
|
261
266
|
FROM ai_model_call_usage AS usage
|
|
267
|
+
JOIN executions AS execution ON execution.project_id = usage.project_id AND execution.id = usage.execution_id
|
|
262
268
|
LEFT JOIN agent_runs AS direct_agent
|
|
263
269
|
ON direct_agent.project_id = usage.project_id
|
|
264
270
|
AND direct_agent.execution_id = usage.execution_id
|
|
@@ -393,6 +399,9 @@ interface UsageRow {
|
|
|
393
399
|
}
|
|
394
400
|
|
|
395
401
|
interface JoinedRow extends UsageRow {
|
|
402
|
+
readonly executor_kind: string | null
|
|
403
|
+
readonly executor_id: string | null
|
|
404
|
+
readonly primitive_id: string | null
|
|
396
405
|
readonly attribution_kind: "agent" | "subagent" | "workflowAgent" | null
|
|
397
406
|
readonly attribution_agent_step_id: string | null
|
|
398
407
|
readonly attribution_agent_run_id: string | null
|
|
@@ -534,7 +543,7 @@ function accountingItemFromRow(row: JoinedRow): AiAccountingRecordSetItem {
|
|
|
534
543
|
const cost = row.cost_status === null ? undefined : costFromJoinedRow(row)
|
|
535
544
|
const attribution =
|
|
536
545
|
row.attribution_kind === null
|
|
537
|
-
?
|
|
546
|
+
? directModelCallAttribution(row.executor_kind, row.executor_id, row.primitive_id)
|
|
538
547
|
: row.attribution_kind === "agent"
|
|
539
548
|
? {
|
|
540
549
|
kind: "agent" as const,
|
package/src/ai-usage-storage.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assertAiUsageExecutionId, normalizeAiModelCallRecord } from "@sixb/core/internal/storage"
|
|
1
2
|
import { isModelReasoning, normalizeModelProviderIds } from "@sixb/core/models"
|
|
2
3
|
import type { ReadonlyJsonObject } from "@sixb/core/storage"
|
|
3
4
|
import {
|
|
@@ -7,9 +8,7 @@ import {
|
|
|
7
8
|
type AiUsageStorage,
|
|
8
9
|
AiUsageStorageError,
|
|
9
10
|
aggregateAiModelCallUsage,
|
|
10
|
-
assertAiUsageExecutionId,
|
|
11
11
|
type GetLatestAiModelCallForExecutionInput,
|
|
12
|
-
normalizeAiModelCallRecord,
|
|
13
12
|
type RecordAiModelCallInput,
|
|
14
13
|
type RecordAiModelCallResult,
|
|
15
14
|
type SummarizeAiUsageExecutionInput,
|
package/src/execution-storage.ts
CHANGED
|
@@ -3,8 +3,7 @@ import {
|
|
|
3
3
|
type ExecutionStorageRow,
|
|
4
4
|
executionRecordFromStorageRow,
|
|
5
5
|
executionRecordToStorageRow,
|
|
6
|
-
|
|
7
|
-
validateExecutionRecordReferences,
|
|
6
|
+
prepareExecutionRecord,
|
|
8
7
|
} from "@sixb/core/internal/execution-storage"
|
|
9
8
|
import type {
|
|
10
9
|
CreateExecutionInput,
|
|
@@ -23,8 +22,7 @@ export class SqliteExecutionStorage implements ExecutionStorage {
|
|
|
23
22
|
) {}
|
|
24
23
|
|
|
25
24
|
async create(input: CreateExecutionInput): Promise<ExecutionRecord> {
|
|
26
|
-
const record =
|
|
27
|
-
await validateExecutionRecordReferences(record, {
|
|
25
|
+
const record = await prepareExecutionRecord(input, {
|
|
28
26
|
auth: this.auth,
|
|
29
27
|
getExecution: (params) => this.getById(params),
|
|
30
28
|
getShareSession: (params) => this.shareSessions.getById(params),
|
|
@@ -44,6 +42,7 @@ export class SqliteExecutionStorage implements ExecutionStorage {
|
|
|
44
42
|
source_id,
|
|
45
43
|
requested_by_user_id,
|
|
46
44
|
requested_by_service_account_id,
|
|
45
|
+
requester_group_ids,
|
|
47
46
|
correlation_id,
|
|
48
47
|
parent_execution_id,
|
|
49
48
|
authority_kind,
|
|
@@ -58,7 +57,7 @@ export class SqliteExecutionStorage implements ExecutionStorage {
|
|
|
58
57
|
authority_delegation_id,
|
|
59
58
|
authority_delegation_session_id,
|
|
60
59
|
created_at
|
|
61
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
60
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
62
61
|
`
|
|
63
62
|
)
|
|
64
63
|
.run(
|
|
@@ -70,6 +69,7 @@ export class SqliteExecutionStorage implements ExecutionStorage {
|
|
|
70
69
|
row.sourceId,
|
|
71
70
|
row.requestedByUserId,
|
|
72
71
|
row.requestedByServiceAccountId,
|
|
72
|
+
JSON.stringify(row.requesterGroupIds),
|
|
73
73
|
row.correlationId,
|
|
74
74
|
row.parentExecutionId,
|
|
75
75
|
row.authorityKind,
|
|
@@ -127,6 +127,7 @@ function toStorageRow(row: SqliteExecutionRow): ExecutionStorageRow {
|
|
|
127
127
|
sourceId: row.source_id,
|
|
128
128
|
requestedByUserId: row.requested_by_user_id,
|
|
129
129
|
requestedByServiceAccountId: row.requested_by_service_account_id,
|
|
130
|
+
requesterGroupIds: JSON.parse(row.requester_group_ids),
|
|
130
131
|
correlationId: row.correlation_id,
|
|
131
132
|
parentExecutionId: row.parent_execution_id,
|
|
132
133
|
authorityKind: row.authority_kind,
|
|
@@ -160,6 +161,7 @@ interface SqliteExecutionRow {
|
|
|
160
161
|
readonly source_id: string
|
|
161
162
|
readonly requested_by_user_id: string | null
|
|
162
163
|
readonly requested_by_service_account_id: string | null
|
|
164
|
+
readonly requester_group_ids: string
|
|
163
165
|
readonly correlation_id: string
|
|
164
166
|
readonly parent_execution_id: string | null
|
|
165
167
|
readonly authority_kind: ExecutionStorageRow["authorityKind"]
|
package/src/index.ts
CHANGED
|
@@ -10,6 +10,10 @@ import type {
|
|
|
10
10
|
StorageTransactionOptions,
|
|
11
11
|
} from "@sixb/core"
|
|
12
12
|
import { ProviderMaterializationTransactionLifecycle } from "@sixb/core/internal/ontology-storage-provider"
|
|
13
|
+
import {
|
|
14
|
+
createTransactionStorageProxy,
|
|
15
|
+
throwNestedStorageTransaction,
|
|
16
|
+
} from "@sixb/core/internal/storage"
|
|
13
17
|
import {
|
|
14
18
|
createAgentOperationScope,
|
|
15
19
|
createAuthOperationScope,
|
|
@@ -23,11 +27,9 @@ import {
|
|
|
23
27
|
type AiCostStorage,
|
|
24
28
|
type AiLimitStorage,
|
|
25
29
|
type AiUsageStorage,
|
|
26
|
-
createTransactionStorageProxy,
|
|
27
30
|
type ShareGrantStorage,
|
|
28
31
|
type ShareSessionStorage,
|
|
29
32
|
StorageTransactionError,
|
|
30
|
-
throwNestedStorageTransaction,
|
|
31
33
|
} from "@sixb/core/storage"
|
|
32
34
|
import { SqliteActionRunStorage } from "./action-run-storage"
|
|
33
35
|
import { SqliteAgentStorage } from "./agents"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
ALTER TABLE executions ADD COLUMN requester_group_ids TEXT NOT NULL DEFAULT '[]';
|
|
2
|
+
|
|
3
|
+
-- Preserve each admitted snapshot, including an intentionally empty one. Executions without
|
|
4
|
+
-- their own historical snapshot inherit from their parent; historical roots remain unknown/empty.
|
|
5
|
+
WITH RECURSIVE attribution(project_id, id, groups) AS (
|
|
6
|
+
SELECT e.project_id, e.id, COALESCE(w.requester_group_ids, a.requester_group_ids, '[]')
|
|
7
|
+
FROM executions e
|
|
8
|
+
LEFT JOIN workflow_runs w ON w.project_id = e.project_id AND w.execution_id = e.id
|
|
9
|
+
LEFT JOIN agent_runs a ON a.project_id = e.project_id AND a.execution_id = e.id
|
|
10
|
+
WHERE e.parent_execution_id IS NULL
|
|
11
|
+
UNION ALL
|
|
12
|
+
SELECT e.project_id, e.id, COALESCE(w.requester_group_ids, a.requester_group_ids, p.groups)
|
|
13
|
+
FROM executions e
|
|
14
|
+
JOIN attribution p ON p.project_id = e.project_id AND p.id = e.parent_execution_id
|
|
15
|
+
LEFT JOIN workflow_runs w ON w.project_id = e.project_id AND w.execution_id = e.id
|
|
16
|
+
LEFT JOIN agent_runs a ON a.project_id = e.project_id AND a.execution_id = e.id
|
|
17
|
+
)
|
|
18
|
+
UPDATE executions SET requester_group_ids = (
|
|
19
|
+
SELECT groups FROM attribution
|
|
20
|
+
WHERE attribution.project_id = executions.project_id AND attribution.id = executions.id
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
ALTER TABLE workflow_runs DROP COLUMN requester_group_ids;
|
|
24
|
+
ALTER TABLE agent_runs DROP COLUMN requester_group_ids;
|
package/src/migrations.ts
CHANGED
|
@@ -181,6 +181,7 @@ export const sqliteStorageMigrations = defineMigrations({
|
|
|
181
181
|
sqliteSql("034-device-authorizations", deviceAuthorizationsSql),
|
|
182
182
|
sqliteSql("035-share-grants", shareGrantsSql),
|
|
183
183
|
sqliteSql("036-share-sessions", shareSessionsSql),
|
|
184
|
+
sqliteSql("037-execution-requester-groups", executionRequesterGroupsSql),
|
|
184
185
|
],
|
|
185
186
|
})
|
|
186
187
|
|
|
@@ -396,3 +397,7 @@ function rollbackQuietly(db: Database): void {
|
|
|
396
397
|
// Ignore rollback errors so the original migration failure is preserved.
|
|
397
398
|
}
|
|
398
399
|
}
|
|
400
|
+
|
|
401
|
+
import executionRequesterGroupsSql from "./migrations/037-execution-requester-groups.sql" with {
|
|
402
|
+
type: "text",
|
|
403
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Database } from "bun:sqlite"
|
|
2
2
|
import { parseSixbFailure, serializeSixbFailure } from "@sixb/core/internal/errors"
|
|
3
3
|
import { assertPipelineRunExecution } from "@sixb/core/internal/pipeline-run-storage-provider"
|
|
4
|
+
import { canRequeuePipelineRunAfterEnqueueFailure } from "@sixb/core/internal/storage"
|
|
4
5
|
import type { DatasetVersionRef } from "@sixb/core/lake-storage"
|
|
5
6
|
import type {
|
|
6
7
|
ExecutionStorage,
|
|
@@ -19,11 +20,7 @@ import type {
|
|
|
19
20
|
StartPipelineRunInput,
|
|
20
21
|
StartPipelineStepRunInput,
|
|
21
22
|
} from "@sixb/core/storage"
|
|
22
|
-
import {
|
|
23
|
-
canRequeuePipelineRunAfterEnqueueFailure,
|
|
24
|
-
PIPELINE_RUN_FAILURE_CODES,
|
|
25
|
-
PipelineRunError,
|
|
26
|
-
} from "@sixb/core/storage"
|
|
23
|
+
import { PIPELINE_RUN_FAILURE_CODES, PipelineRunError } from "@sixb/core/storage"
|
|
27
24
|
import { queryLatestRunsByOwnerId } from "./latest-run-query"
|
|
28
25
|
import { installFreshSqliteSchema } from "./migrations"
|
|
29
26
|
import {
|
package/src/sync-run-storage.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Database } from "bun:sqlite"
|
|
2
2
|
import type { JsonValue } from "@sixb/core"
|
|
3
3
|
import { parseSixbFailure, serializeSixbFailure } from "@sixb/core/internal/errors"
|
|
4
|
+
import { canRequeueSyncRunAfterEnqueueFailure } from "@sixb/core/internal/storage"
|
|
4
5
|
import { assertSyncRunExecution } from "@sixb/core/internal/sync-run-storage-provider"
|
|
5
6
|
import type {
|
|
6
7
|
ExecutionStorage,
|
|
@@ -14,11 +15,7 @@ import type {
|
|
|
14
15
|
SyncRunRecord,
|
|
15
16
|
SyncRunStorage,
|
|
16
17
|
} from "@sixb/core/storage"
|
|
17
|
-
import {
|
|
18
|
-
canRequeueSyncRunAfterEnqueueFailure,
|
|
19
|
-
SYNC_RUN_FAILURE_CODES,
|
|
20
|
-
SyncRunError,
|
|
21
|
-
} from "@sixb/core/storage"
|
|
18
|
+
import { SYNC_RUN_FAILURE_CODES, SyncRunError } from "@sixb/core/storage"
|
|
22
19
|
import { queryLatestRunsByOwnerId } from "./latest-run-query"
|
|
23
20
|
import { installFreshSqliteSchema } from "./migrations"
|
|
24
21
|
import {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Database } from "bun:sqlite"
|
|
2
|
-
import { normalizeRequesterGroupIds } from "@sixb/core/internal/auth"
|
|
3
2
|
import { parseSixbFailure, serializeSixbFailure } from "@sixb/core/internal/errors"
|
|
4
3
|
import {
|
|
5
4
|
assertWorkflowAgentNodeRunExecution,
|
|
@@ -112,9 +111,8 @@ export class SqliteWorkflowRunStorage implements WorkflowRunStorage {
|
|
|
112
111
|
input,
|
|
113
112
|
queued_at,
|
|
114
113
|
started_at,
|
|
115
|
-
requester_group_ids,
|
|
116
114
|
attempt
|
|
117
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?,
|
|
115
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
118
116
|
`
|
|
119
117
|
)
|
|
120
118
|
.run(
|
|
@@ -126,7 +124,6 @@ export class SqliteWorkflowRunStorage implements WorkflowRunStorage {
|
|
|
126
124
|
serializeRecord(input.input),
|
|
127
125
|
queuedAt.toISOString(),
|
|
128
126
|
queuedAt.toISOString(),
|
|
129
|
-
JSON.stringify(normalizeRequesterGroupIds(input.requesterGroupIds)),
|
|
130
127
|
0
|
|
131
128
|
)
|
|
132
129
|
} catch (error) {
|
|
@@ -983,7 +980,6 @@ function rowToWorkflowRunRecord(row: WorkflowRunDatabaseRow): WorkflowRunRecord
|
|
|
983
980
|
startedAt: new Date(row.started_at),
|
|
984
981
|
finishedAt: row.finished_at ? new Date(row.finished_at) : undefined,
|
|
985
982
|
error: row.error === null ? undefined : parseSixbFailure(row.error, WORKFLOW_RUN_FAILURE_CODES),
|
|
986
|
-
requesterGroupIds: JSON.parse(row.requester_group_ids) as string[],
|
|
987
983
|
attempt: row.attempt,
|
|
988
984
|
...(row.execution_token && row.execution_queue_lease_expires_at
|
|
989
985
|
? {
|
|
@@ -1046,7 +1042,6 @@ interface WorkflowRunDatabaseRow {
|
|
|
1046
1042
|
started_at: string
|
|
1047
1043
|
finished_at: string | null
|
|
1048
1044
|
error: string | null
|
|
1049
|
-
requester_group_ids: string
|
|
1050
1045
|
attempt: number
|
|
1051
1046
|
execution_token: string | null
|
|
1052
1047
|
execution_queue_lease_expires_at: string | null
|