@sixb/pg 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/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/index.d.ts.map +1 -1
- package/dist/index.js +93 -74
- package/dist/index.js.map +14 -14
- package/dist/migrations.d.ts.map +1 -1
- package/dist/pg-action-run-storage.d.ts.map +1 -1
- package/dist/pg-ai-cost-storage.d.ts.map +1 -1
- package/dist/pg-ai-usage-storage.d.ts.map +1 -1
- package/dist/pg-execution-storage.d.ts.map +1 -1
- package/dist/pg-pipeline-run-storage.d.ts.map +1 -1
- package/dist/pg-sync-run-storage.d.ts.map +1 -1
- package/dist/pg-workflow-run-storage.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/agents/rows.ts +0 -5
- package/src/agents/runs.ts +1 -6
- package/src/ai-cost-groups.ts +3 -0
- package/src/index.ts +4 -2
- package/src/migrations/037-execution-requester-groups.sql +21 -0
- package/src/migrations.ts +5 -0
- package/src/pg-action-run-storage.ts +6 -7
- package/src/pg-ai-cost-storage.ts +11 -2
- package/src/pg-ai-usage-storage.ts +1 -2
- package/src/pg-execution-storage.ts +6 -4
- package/src/pg-pipeline-run-storage.ts +2 -5
- package/src/pg-sync-run-storage.ts +2 -5
- package/src/pg-workflow-run-storage.ts +0 -5
package/dist/migrations.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../src/migrations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAGV,YAAY,EACZ,aAAa,EACb,oBAAoB,EACrB,MAAM,oBAAoB,CAAA;AAiF3B,OAAO,KAAK,EAAE,GAAG,EAAa,MAAM,aAAa,CAAA;AAEjD,MAAM,WAAW,wBAAw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-run-storage.d.ts","sourceRoot":"","sources":["../src/pg-action-run-storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pg-action-run-storage.d.ts","sourceRoot":"","sources":["../src/pg-action-run-storage.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAKV,eAAe,EACf,gBAAgB,EAEhB,wBAAwB,EACxB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,iCAAiC,EACjC,mBAAmB,EACnB,wBAAwB,EACxB,0BAA0B,EAC1B,mBAAmB,EACpB,MAAM,oBAAoB,CAAA;AAI3B,OAAO,EAAE,KAAK,aAAa,EAAoB,MAAM,gBAAgB,CAAA;AAErE,qBAAa,kBAAmB,YAAW,gBAAgB;IAEvD,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,UAAU;gBADV,GAAG,EAAE,aAAa,EAClB,UAAU,EAAE,gBAAgB;IAGzC,sBAAsB,CAAC,KAAK,EAAE,iCAAiC,GAAG,OAAO,CAAC,eAAe,CAAC;IAyB1F,KAAK,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,eAAe,CAAC;YAuEnD,0BAA0B;IAyClC,KAAK,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,eAAe,CAAC;IA8B3D,UAAU,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,eAAe,CAAC;IAerE,eAAe,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,eAAe,CAAC;IAqC5E,aAAa,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,eAAe,CAAC;IA+BxE,MAAM,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,eAAe,CAAC;IAqC7D,OAAO,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IASnF,IAAI,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;YAkHvD,iBAAiB;CAwBhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pg-ai-cost-storage.d.ts","sourceRoot":"","sources":["../src/pg-ai-cost-storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pg-ai-cost-storage.d.ts","sourceRoot":"","sources":["../src/pg-ai-cost-storage.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAElB,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAE1B,KAAK,8BAA8B,EACnC,KAAK,+BAA+B,EACpC,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,EAChC,KAAK,8BAA8B,EACnC,KAAK,8BAA8B,EACpC,MAAM,oBAAoB,CAAA;AAG3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAGnD,8EAA8E;AAC9E,qBAAa,eAAgB,YAAW,aAAa;IACvC,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEzC,mBAAmB,CACvB,KAAK,EAAE,0BAA0B,GAChC,OAAO,CAAC,2BAA2B,CAAC;IAIjC,mBAAmB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IA6BhE,mBAAmB,CACvB,KAAK,EAAE,8BAA8B,GACpC,OAAO,CAAC,SAAS,aAAa,EAAE,CAAC;IAsB9B,oBAAoB,CAAC,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAuH1F,cAAc,CAClB,KAAK,EAAE,8BAA8B,GACpC,OAAO,CAAC,+BAA+B,CAAC;CA0F5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pg-ai-usage-storage.d.ts","sourceRoot":"","sources":["../src/pg-ai-usage-storage.ts"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AAK,EAAE,OAAO,CAAC,UAAU,CAAC,qBAAqB,CAAC,EAAE,IAAI,CAAC,GACtD,sBAAsB,CAAC,oBAAoB,CAAC,CAS9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pg-execution-storage.d.ts","sourceRoot":"","sources":["../src/pg-execution-storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pg-execution-storage.d.ts","sourceRoot":"","sources":["../src/pg-execution-storage.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,qBAAa,kBAAmB,YAAW,gBAAgB;IAEvD,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAFb,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,aAAa,EACnB,aAAa,EAAE,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAAC;IAGhE,MAAM,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,eAAe,CAAC;IA8E7D,OAAO,CAAC,MAAM,EAAE;QACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;QAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;KACpB,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;CAQpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pg-pipeline-run-storage.d.ts","sourceRoot":"","sources":["../src/pg-pipeline-run-storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pg-pipeline-run-storage.d.ts","sourceRoot":"","sources":["../src/pg-pipeline-run-storage.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AC,0BAA0B,CAAC;CAqDvF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pg-sync-run-storage.d.ts","sourceRoot":"","sources":["../src/pg-sync-run-storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pg-sync-run-storage.d.ts","sourceRoot":"","sources":["../src/pg-sync-run-storage.ts"],"names":[],"mappings":"AAIA,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;AAM3B,OAAO,EAAE,KAAK,aAAa,EAAoB,MAAM,gBAAgB,CAAA;AAErE,qBAAa,gBAAiB,YAAW,cAAc;IAEnD,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,UAAU;gBADV,GAAG,EAAE,aAAa,EAClB,UAAU,EAAE,gBAAgB;IAGzC,KAAK,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;YAgD/C,0BAA0B;IAyBlC,KAAK,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;IAqBvD,MAAM,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC;IAoEzD,OAAO,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IASjF,IAAI,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAwD3D,mBAAmB,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,wBAAwB,CAAC;CAe7F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pg-workflow-run-storage.d.ts","sourceRoot":"","sources":["../src/pg-workflow-run-storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pg-workflow-run-storage.d.ts","sourceRoot":"","sources":["../src/pg-workflow-run-storage.ts"],"names":[],"mappings":"AAOA,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,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,0BAA0B,EAC1B,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,oBAAoB,CAAA;AAU3B,OAAO,EAAE,KAAK,aAAa,EAAoB,MAAM,gBAAgB,CAAA;AAErE,qBAAa,oBAAqB,YAAW,kBAAkB;IAK3D,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAL7B,QAAQ,CAAC,KAAK,EAAE,wBAAwB,CAAA;IACxC,QAAQ,CAAC,UAAU,EAAE,6BAA6B,CAAA;gBAG/B,GAAG,EAAE,aAAa,EAClB,UAAU,EAAE,gBAAgB;IAMzC,KAAK,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAgD/D,KAAK,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAmC/D,OAAO,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAenE,yBAAyB,CAC7B,KAAK,EAAE,yCAAyC,G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,MAAM,CAAA;KAClB,GAAG,OAAO,CAAC,0BAA0B,GAAG,IAAI,CAAC;IAQxC,IAAI,CAAC,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,+BAA+B,CAAC;CAsB5F;AAED,qBAAa,wBAAyB,YAAW,sBAAsB;IACzD,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEzC,KAAK,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAwEvE,MAAM,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAgDzE,IAAI,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAoCrE,OAAO,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IASzF,IAAI,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,0BAA0B,CAAC;CA0DlF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sixb/pg",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "PostgreSQL storage provider for Sixb",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sixb",
|
|
@@ -40,16 +40,16 @@
|
|
|
40
40
|
"postgres": "^3.4.5"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@sixb/core": "0.1.
|
|
43
|
+
"@sixb/core": "0.1.9"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@sixb/core": "0.1.
|
|
46
|
+
"@sixb/core": "0.1.9",
|
|
47
47
|
"@types/bun": "latest",
|
|
48
48
|
"typescript": "^5.7.0"
|
|
49
49
|
},
|
|
50
50
|
"license": "MIT",
|
|
51
51
|
"engines": {
|
|
52
|
-
"bun": ">=1.
|
|
52
|
+
"bun": ">=1.4.2"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
package/src/agents/rows.ts
CHANGED
|
@@ -42,7 +42,6 @@ export interface AgentRunRow {
|
|
|
42
42
|
spawn_key: string | null
|
|
43
43
|
spec: ConversationAgentRunSpec | SubagentRunSpec | string | null
|
|
44
44
|
result: SubagentRunResult | string | null
|
|
45
|
-
requester_group_ids: string[] | string
|
|
46
45
|
status: AgentRunRecord["status"]
|
|
47
46
|
model_id: string | null
|
|
48
47
|
finish_reason: string | null
|
|
@@ -111,10 +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:
|
|
115
|
-
typeof row.requester_group_ids === "string"
|
|
116
|
-
? (JSON.parse(row.requester_group_ids) as string[])
|
|
117
|
-
: row.requester_group_ids,
|
|
118
113
|
status: row.status,
|
|
119
114
|
modelId: row.model_id ?? undefined,
|
|
120
115
|
finishReason: coerceAgentRunFinishReason(row.finish_reason),
|
package/src/agents/runs.ts
CHANGED
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
assertSubagentRunResult,
|
|
6
6
|
subagentRunMatchesCreateInput,
|
|
7
7
|
} from "@sixb/core/internal/agent-run-storage-provider"
|
|
8
|
-
import { normalizeRequesterGroupIds } from "@sixb/core/internal/auth"
|
|
9
8
|
import { serializeSixbFailure } from "@sixb/core/internal/errors"
|
|
10
9
|
import {
|
|
11
10
|
AGENT_RUN_FAILURE_CODES,
|
|
@@ -79,7 +78,6 @@ export class PgAgentRunStore implements AgentRunStore {
|
|
|
79
78
|
thread_id,
|
|
80
79
|
trigger_message_id,
|
|
81
80
|
spec,
|
|
82
|
-
requester_group_ids,
|
|
83
81
|
status,
|
|
84
82
|
attempt,
|
|
85
83
|
created_at
|
|
@@ -91,7 +89,6 @@ export class PgAgentRunStore implements AgentRunStore {
|
|
|
91
89
|
${input.threadId},
|
|
92
90
|
${input.triggerMessageId},
|
|
93
91
|
${JSON.stringify(input.spec)}::text::jsonb,
|
|
94
|
-
${JSON.stringify(normalizeRequesterGroupIds(input.requesterGroupIds))}::text::jsonb,
|
|
95
92
|
${"queued"},
|
|
96
93
|
${0},
|
|
97
94
|
${createdAt}
|
|
@@ -178,7 +175,6 @@ export class PgAgentRunStore implements AgentRunStore {
|
|
|
178
175
|
`[SixbPg] Parent Agent run '${parent.id}' is no longer owned by this execution.`
|
|
179
176
|
)
|
|
180
177
|
}
|
|
181
|
-
const parentRecord = rowToRunRecord(parent)
|
|
182
178
|
|
|
183
179
|
const [countRow] = await tx<{ count: string | number }[]>`
|
|
184
180
|
SELECT COUNT(*)::bigint AS count FROM agent_runs
|
|
@@ -197,12 +193,11 @@ export class PgAgentRunStore implements AgentRunStore {
|
|
|
197
193
|
const [row] = await tx<AgentRunRow[]>`
|
|
198
194
|
INSERT INTO agent_runs (
|
|
199
195
|
project_id, id, execution_id, kind, parent_run_id, spawn_key, spec,
|
|
200
|
-
|
|
196
|
+
status, attempt, created_at
|
|
201
197
|
) VALUES (
|
|
202
198
|
${input.projectId}, ${input.id}, ${input.executionId}, ${"subagent"},
|
|
203
199
|
${input.parentRunId}, ${input.spawnKey},
|
|
204
200
|
${JSON.stringify(input.spec)}::text::jsonb,
|
|
205
|
-
${JSON.stringify(parentRecord.requesterGroupIds)}::text::jsonb,
|
|
206
201
|
${"queued"}, ${0}, ${input.createdAt ?? new Date()}
|
|
207
202
|
)
|
|
208
203
|
RETURNING *
|
package/src/ai-cost-groups.ts
CHANGED
|
@@ -39,6 +39,7 @@ WITH filtered AS (
|
|
|
39
39
|
SELECT COALESCE(root_agent.execution_id, usage.execution_id) AS root_execution_id,
|
|
40
40
|
usage.execution_id, usage.provider_id, usage.requested_model_id, usage.occurred_at,
|
|
41
41
|
usage.total_tokens,
|
|
42
|
+
execution.executor_kind, execution.executor_id, execution.authority_primitive_id AS primitive_id,
|
|
42
43
|
COALESCE(cost.status, 'unvalued') AS valuation_status,
|
|
43
44
|
cost.currency AS amount_currency, cost.amount_nanos,
|
|
44
45
|
root_agent.id AS root_agent_run_id,
|
|
@@ -51,6 +52,7 @@ WITH filtered AS (
|
|
|
51
52
|
workflow_node.workflow_id AS workflow_id,
|
|
52
53
|
workflow_node.workflow_run_id AS workflow_run_id
|
|
53
54
|
FROM ai_model_call_usage AS usage
|
|
55
|
+
JOIN executions AS execution ON execution.project_id = usage.project_id AND execution.id = usage.execution_id
|
|
54
56
|
LEFT JOIN agent_runs AS direct_agent
|
|
55
57
|
ON direct_agent.project_id = usage.project_id AND direct_agent.execution_id = usage.execution_id
|
|
56
58
|
LEFT JOIN agent_runs AS root_agent
|
|
@@ -88,6 +90,7 @@ SELECT filtered.root_execution_id, execution_id, provider_id, requested_model_id
|
|
|
88
90
|
CAST(SUM((amount_nanos / 1000000) % 1000000) AS TEXT) AS amount_middle,
|
|
89
91
|
CAST(SUM(amount_nanos % 1000000) AS TEXT) AS amount_low,
|
|
90
92
|
MAX(root_agent_run_id) AS root_agent_run_id,
|
|
93
|
+
MAX(executor_kind) AS executor_kind, MAX(executor_id) AS executor_id, MAX(primitive_id) AS primitive_id,
|
|
91
94
|
MAX(root_thread_id) AS root_thread_id,
|
|
92
95
|
MAX(direct_kind) AS direct_kind,
|
|
93
96
|
MAX(direct_run_id) AS direct_run_id,
|
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,10 +27,8 @@ import {
|
|
|
23
27
|
type AiCostStorage,
|
|
24
28
|
type AiLimitStorage,
|
|
25
29
|
type AiUsageStorage,
|
|
26
|
-
createTransactionStorageProxy,
|
|
27
30
|
type ObjectStorage,
|
|
28
31
|
StorageTransactionError,
|
|
29
|
-
throwNestedStorageTransaction,
|
|
30
32
|
} from "@sixb/core/storage"
|
|
31
33
|
import { PgAgentStorage } from "./agents"
|
|
32
34
|
import { PgAuthStorage } from "./auth-storage"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
ALTER TABLE executions ADD COLUMN requester_group_ids JSONB NOT NULL DEFAULT '[]'::jsonb;
|
|
2
|
+
|
|
3
|
+
-- Keep historical admission snapshots; never reconstruct them from current memberships.
|
|
4
|
+
WITH RECURSIVE attribution(project_id, id, groups) AS (
|
|
5
|
+
SELECT e.project_id, e.id, COALESCE(w.requester_group_ids, a.requester_group_ids, '[]'::jsonb)
|
|
6
|
+
FROM executions e
|
|
7
|
+
LEFT JOIN workflow_runs w ON w.project_id = e.project_id AND w.execution_id = e.id
|
|
8
|
+
LEFT JOIN agent_runs a ON a.project_id = e.project_id AND a.execution_id = e.id
|
|
9
|
+
WHERE e.parent_execution_id IS NULL
|
|
10
|
+
UNION ALL
|
|
11
|
+
SELECT e.project_id, e.id, COALESCE(w.requester_group_ids, a.requester_group_ids, p.groups)
|
|
12
|
+
FROM executions e
|
|
13
|
+
JOIN attribution p ON p.project_id = e.project_id AND p.id = e.parent_execution_id
|
|
14
|
+
LEFT JOIN workflow_runs w ON w.project_id = e.project_id AND w.execution_id = e.id
|
|
15
|
+
LEFT JOIN agent_runs a ON a.project_id = e.project_id AND a.execution_id = e.id
|
|
16
|
+
)
|
|
17
|
+
UPDATE executions e SET requester_group_ids = a.groups
|
|
18
|
+
FROM attribution a WHERE a.project_id = e.project_id AND a.id = e.id;
|
|
19
|
+
|
|
20
|
+
ALTER TABLE workflow_runs DROP COLUMN requester_group_ids;
|
|
21
|
+
ALTER TABLE agent_runs DROP COLUMN requester_group_ids;
|
package/src/migrations.ts
CHANGED
|
@@ -376,6 +376,7 @@ export const postgresStorageMigrations = defineMigrations<PostgresMigrationConte
|
|
|
376
376
|
pgSql("034-device-authorizations", deviceAuthorizationsSql),
|
|
377
377
|
pgSql("035-share-grants", shareGrantsSql),
|
|
378
378
|
pgSql("036-share-sessions", shareSessionsSql),
|
|
379
|
+
pgSql("037-execution-requester-groups", executionRequesterGroupsSql),
|
|
379
380
|
],
|
|
380
381
|
})
|
|
381
382
|
|
|
@@ -388,3 +389,7 @@ interface PostgresMigrationRow {
|
|
|
388
389
|
readonly started_at: Date | string
|
|
389
390
|
readonly finished_at: Date | string | null
|
|
390
391
|
}
|
|
392
|
+
|
|
393
|
+
import executionRequesterGroupsSql from "./migrations/037-execution-requester-groups.sql" with {
|
|
394
|
+
type: "text",
|
|
395
|
+
}
|
|
@@ -4,6 +4,11 @@ import {
|
|
|
4
4
|
serializeActionRunFailure,
|
|
5
5
|
} from "@sixb/core/internal/action-run-storage"
|
|
6
6
|
import { assertActionRunExecution } from "@sixb/core/internal/action-run-storage-provider"
|
|
7
|
+
import {
|
|
8
|
+
actionRunPhaseRecordsEqual,
|
|
9
|
+
canRequeueActionRunAfterEnqueueFailure,
|
|
10
|
+
finishActionRunPhase,
|
|
11
|
+
} from "@sixb/core/internal/storage"
|
|
7
12
|
import type {
|
|
8
13
|
ActionRunEffectsRecord,
|
|
9
14
|
ActionRunFailure,
|
|
@@ -23,13 +28,7 @@ import type {
|
|
|
23
28
|
RecordActionWritebackInput,
|
|
24
29
|
StartActionRunInput,
|
|
25
30
|
} from "@sixb/core/storage"
|
|
26
|
-
import {
|
|
27
|
-
ActionRunError,
|
|
28
|
-
actionRunPhaseRecordsEqual,
|
|
29
|
-
canRequeueActionRunAfterEnqueueFailure,
|
|
30
|
-
finishActionRunPhase,
|
|
31
|
-
isTerminalActionRun,
|
|
32
|
-
} from "@sixb/core/storage"
|
|
31
|
+
import { ActionRunError, isTerminalActionRun } from "@sixb/core/storage"
|
|
33
32
|
import type { SQLClient, SqlParameter } from "./pg-client"
|
|
34
33
|
import { isUniqueViolation } from "./storage-errors"
|
|
35
34
|
import { type PgStoreClient, runPgTransaction } from "./transactions"
|
|
@@ -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,
|
|
@@ -117,11 +118,14 @@ export class PgAiCostStorage implements AiCostStorage {
|
|
|
117
118
|
ELSE NULL
|
|
118
119
|
END AS attribution_agent_kind,
|
|
119
120
|
workflow_node.node_id AS attribution_agent_step_id,
|
|
120
|
-
workflow_node.workflow_id
|
|
121
|
+
COALESCE(workflow_node.workflow_id,
|
|
122
|
+
CASE WHEN execution.executor_kind = 'workflow' THEN execution.authority_primitive_id END
|
|
123
|
+
) AS attribution_workflow_id,
|
|
121
124
|
cost.status AS cost_status,
|
|
122
125
|
cost.currency AS cost_currency,
|
|
123
126
|
cost.amount_nanos AS cost_amount_nanos
|
|
124
127
|
FROM ai_model_call_usage AS usage
|
|
128
|
+
JOIN executions AS execution ON execution.project_id = usage.project_id AND execution.id = usage.execution_id
|
|
125
129
|
LEFT JOIN agent_runs AS direct_agent
|
|
126
130
|
ON direct_agent.project_id = usage.project_id
|
|
127
131
|
AND direct_agent.execution_id = usage.execution_id
|
|
@@ -251,6 +255,7 @@ export class PgAiCostStorage implements AiCostStorage {
|
|
|
251
255
|
workflow_agent.node_run_id AS attribution_node_run_id,
|
|
252
256
|
workflow_node.workflow_id AS attribution_workflow_id,
|
|
253
257
|
workflow_node.workflow_run_id AS attribution_workflow_run_id,
|
|
258
|
+
execution.executor_kind, execution.executor_id, execution.authority_primitive_id AS primitive_id,
|
|
254
259
|
COALESCE((
|
|
255
260
|
SELECT jsonb_agg(groups.group_id ORDER BY groups.group_id)
|
|
256
261
|
FROM ai_model_call_usage_groups AS groups
|
|
@@ -265,6 +270,7 @@ export class PgAiCostStorage implements AiCostStorage {
|
|
|
265
270
|
cost.details AS cost_details,
|
|
266
271
|
cost.rated_at AS cost_rated_at
|
|
267
272
|
FROM ai_model_call_usage AS usage
|
|
273
|
+
JOIN executions AS execution ON execution.project_id = usage.project_id AND execution.id = usage.execution_id
|
|
268
274
|
LEFT JOIN agent_runs AS direct_agent
|
|
269
275
|
ON direct_agent.project_id = usage.project_id
|
|
270
276
|
AND direct_agent.execution_id = usage.execution_id
|
|
@@ -342,6 +348,9 @@ interface UsageRow {
|
|
|
342
348
|
}
|
|
343
349
|
|
|
344
350
|
interface JoinedRow extends UsageRow {
|
|
351
|
+
readonly executor_kind: string | null
|
|
352
|
+
readonly executor_id: string | null
|
|
353
|
+
readonly primitive_id: string | null
|
|
345
354
|
readonly attribution_kind: "agent" | "subagent" | "workflowAgent" | null
|
|
346
355
|
readonly attribution_agent_step_id: string | null
|
|
347
356
|
readonly attribution_agent_run_id: string | null
|
|
@@ -491,7 +500,7 @@ function accountingItemFromRow(row: JoinedRow): AiAccountingRecordSetItem {
|
|
|
491
500
|
const cost = row.cost_status === null ? undefined : costFromJoinedRow(row)
|
|
492
501
|
const attribution =
|
|
493
502
|
row.attribution_kind === null
|
|
494
|
-
?
|
|
503
|
+
? directModelCallAttribution(row.executor_kind, row.executor_id, row.primitive_id)
|
|
495
504
|
: row.attribution_kind === "agent"
|
|
496
505
|
? {
|
|
497
506
|
kind: "agent" as const,
|
|
@@ -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,
|
|
@@ -2,8 +2,7 @@ import {
|
|
|
2
2
|
type ExecutionStorageRow,
|
|
3
3
|
executionRecordFromStorageRow,
|
|
4
4
|
executionRecordToStorageRow,
|
|
5
|
-
|
|
6
|
-
validateExecutionRecordReferences,
|
|
5
|
+
prepareExecutionRecord,
|
|
7
6
|
} from "@sixb/core/internal/execution-storage"
|
|
8
7
|
import type {
|
|
9
8
|
CreateExecutionInput,
|
|
@@ -24,8 +23,7 @@ export class PgExecutionStorage implements ExecutionStorage {
|
|
|
24
23
|
) {}
|
|
25
24
|
|
|
26
25
|
async create(input: CreateExecutionInput): Promise<ExecutionRecord> {
|
|
27
|
-
const record =
|
|
28
|
-
await validateExecutionRecordReferences(record, {
|
|
26
|
+
const record = await prepareExecutionRecord(input, {
|
|
29
27
|
auth: this.auth,
|
|
30
28
|
getExecution: (params) => this.getById(params),
|
|
31
29
|
getShareSession: (params) => this.shareSessions.getById(params),
|
|
@@ -43,6 +41,7 @@ export class PgExecutionStorage implements ExecutionStorage {
|
|
|
43
41
|
source_id,
|
|
44
42
|
requested_by_user_id,
|
|
45
43
|
requested_by_service_account_id,
|
|
44
|
+
requester_group_ids,
|
|
46
45
|
correlation_id,
|
|
47
46
|
parent_execution_id,
|
|
48
47
|
authority_kind,
|
|
@@ -66,6 +65,7 @@ export class PgExecutionStorage implements ExecutionStorage {
|
|
|
66
65
|
${row.sourceId},
|
|
67
66
|
${row.requestedByUserId},
|
|
68
67
|
${row.requestedByServiceAccountId},
|
|
68
|
+
${JSON.stringify(row.requesterGroupIds)}::text::jsonb,
|
|
69
69
|
${row.correlationId},
|
|
70
70
|
${row.parentExecutionId},
|
|
71
71
|
${row.authorityKind},
|
|
@@ -123,6 +123,7 @@ function toStorageRow(row: PgExecutionRow): ExecutionStorageRow {
|
|
|
123
123
|
sourceId: row.source_id,
|
|
124
124
|
requestedByUserId: row.requested_by_user_id,
|
|
125
125
|
requestedByServiceAccountId: row.requested_by_service_account_id,
|
|
126
|
+
requesterGroupIds: row.requester_group_ids,
|
|
126
127
|
correlationId: row.correlation_id,
|
|
127
128
|
parentExecutionId: row.parent_execution_id,
|
|
128
129
|
authorityKind: row.authority_kind,
|
|
@@ -149,6 +150,7 @@ interface PgExecutionRow {
|
|
|
149
150
|
readonly source_id: string
|
|
150
151
|
readonly requested_by_user_id: string | null
|
|
151
152
|
readonly requested_by_service_account_id: string | null
|
|
153
|
+
readonly requester_group_ids: string[]
|
|
152
154
|
readonly correlation_id: string
|
|
153
155
|
readonly parent_execution_id: string | null
|
|
154
156
|
readonly authority_kind: ExecutionStorageRow["authorityKind"]
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { JsonValue } from "@sixb/core"
|
|
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 type { SqlParameter } from "./pg-client"
|
|
29
26
|
import { appendRunListFilters, hasEmptyStatuses, queryRunList } from "./run-list-query"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { JsonValue } from "@sixb/core"
|
|
2
2
|
import { parseSixbFailure, serializeSixbFailure } from "@sixb/core/internal/errors"
|
|
3
|
+
import { canRequeueSyncRunAfterEnqueueFailure } from "@sixb/core/internal/storage"
|
|
3
4
|
import { assertSyncRunExecution } from "@sixb/core/internal/sync-run-storage-provider"
|
|
4
5
|
import type {
|
|
5
6
|
ExecutionStorage,
|
|
@@ -13,11 +14,7 @@ import type {
|
|
|
13
14
|
SyncRunRecord,
|
|
14
15
|
SyncRunStorage,
|
|
15
16
|
} from "@sixb/core/storage"
|
|
16
|
-
import {
|
|
17
|
-
canRequeueSyncRunAfterEnqueueFailure,
|
|
18
|
-
SYNC_RUN_FAILURE_CODES,
|
|
19
|
-
SyncRunError,
|
|
20
|
-
} from "@sixb/core/storage"
|
|
17
|
+
import { SYNC_RUN_FAILURE_CODES, SyncRunError } from "@sixb/core/storage"
|
|
21
18
|
import { queryLatestRunsByOwnerId } from "./latest-run-query"
|
|
22
19
|
import type { SqlParameter } from "./pg-client"
|
|
23
20
|
import { appendRunListFilters, hasEmptyStatuses, queryRunList } from "./run-list-query"
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { JsonValue } from "@sixb/core"
|
|
2
|
-
import { normalizeRequesterGroupIds } from "@sixb/core/internal/auth"
|
|
3
2
|
import { parseSixbFailure, serializeSixbFailure } from "@sixb/core/internal/errors"
|
|
4
3
|
import {
|
|
5
4
|
assertWorkflowAgentNodeRunExecution,
|
|
@@ -83,7 +82,6 @@ export class PgWorkflowRunStorage implements WorkflowRunStorage {
|
|
|
83
82
|
input,
|
|
84
83
|
queued_at,
|
|
85
84
|
started_at,
|
|
86
|
-
requester_group_ids,
|
|
87
85
|
attempt
|
|
88
86
|
) VALUES (
|
|
89
87
|
${input.projectId},
|
|
@@ -94,7 +92,6 @@ export class PgWorkflowRunStorage implements WorkflowRunStorage {
|
|
|
94
92
|
${serializeRecord(input.input)}::text::jsonb,
|
|
95
93
|
${queuedAt},
|
|
96
94
|
${queuedAt},
|
|
97
|
-
${JSON.stringify(normalizeRequesterGroupIds(input.requesterGroupIds))}::text::jsonb,
|
|
98
95
|
${0}
|
|
99
96
|
)
|
|
100
97
|
RETURNING *
|
|
@@ -822,7 +819,6 @@ function rowToWorkflowRunRecord(row: WorkflowRunDatabaseRow): WorkflowRunRecord
|
|
|
822
819
|
startedAt: new Date(row.started_at),
|
|
823
820
|
finishedAt: row.finished_at ? new Date(row.finished_at) : undefined,
|
|
824
821
|
error: row.error === null ? undefined : parseSixbFailure(row.error, WORKFLOW_RUN_FAILURE_CODES),
|
|
825
|
-
requesterGroupIds: parseJson(row.requester_group_ids),
|
|
826
822
|
attempt: Number(row.attempt),
|
|
827
823
|
...(row.execution_token && row.execution_queue_lease_expires_at
|
|
828
824
|
? {
|
|
@@ -883,7 +879,6 @@ interface WorkflowRunDatabaseRow {
|
|
|
883
879
|
started_at: Date | string
|
|
884
880
|
finished_at: Date | string | null
|
|
885
881
|
error: JsonValue | null
|
|
886
|
-
requester_group_ids: string[] | string
|
|
887
882
|
attempt: number | string
|
|
888
883
|
execution_token: string | null
|
|
889
884
|
execution_queue_lease_expires_at: Date | string | null
|