@sogni-ai/sogni-protocol 1.0.0-alpha.2 → 1.0.0-alpha.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/README.md +10 -1
- package/catalogs/audio-models.json +68 -7
- package/catalogs/quality-presets.json +3 -3
- package/catalogs/seedance-reference-limits.json +35 -0
- package/enums/tool-names.json +2 -0
- package/manifests/composition-tools.json +3 -3
- package/manifests/generation-tools.json +153 -77
- package/manifests/openai-tools.json +140 -65
- package/package.json +1 -1
- package/prompts/tools/animate_photo.json +1 -1
- package/prompts/tools/compose_script.json +1 -1
- package/prompts/tools/compose_workflow.json +1 -1
- package/prompts/tools/compose_workflow_template.json +1 -1
- package/prompts/tools/edit_image.json +1 -1
- package/prompts/tools/enhance_prompt.json +1 -1
- package/prompts/tools/extend_video.json +2 -2
- package/prompts/tools/generate_image.json +2 -2
- package/prompts/tools/generate_video.json +1 -1
- package/prompts/tools/map_assets_for_model.json +1 -1
- package/prompts/tools/replace_video_segment.json +2 -2
- package/prompts/tools/resolve_personas.json +1 -1
- package/prompts/tools/sound_to_video.json +3 -2
- package/prompts/tools/video_to_video.json +2 -2
- package/schemas/agent/intent-input.schema.json +128 -0
- package/schemas/agent/turn-analysis.schema.json +75 -0
- package/schemas/artifacts/artifact-graph.schema.json +42 -0
- package/schemas/artifacts/artifact-node.schema.json +137 -0
- package/schemas/billing/spend-gate.schema.json +151 -0
- package/schemas/billing/workflow-authorization.schema.json +83 -0
- package/schemas/events/run-event.schema.json +122 -0
- package/schemas/tools/animate_photo.schema.json +23 -12
- package/schemas/tools/compose_script.schema.json +1 -1
- package/schemas/tools/compose_workflow.schema.json +2 -2
- package/schemas/tools/compose_workflow_template.schema.json +2 -2
- package/schemas/tools/edit_image.schema.json +8 -7
- package/schemas/tools/enhance_prompt.schema.json +1 -1
- package/schemas/tools/extend_video.schema.json +8 -5
- package/schemas/tools/generate_image.schema.json +12 -9
- package/schemas/tools/generate_music.schema.json +3 -2
- package/schemas/tools/generate_video.schema.json +24 -14
- package/schemas/tools/replace_video_segment.schema.json +5 -2
- package/schemas/tools/sound_to_video.schema.json +16 -8
- package/schemas/tools/tool-metadata.schema.json +78 -0
- package/schemas/tools/upscale_image.schema.json +31 -0
- package/schemas/tools/video_to_video.schema.json +13 -10
- package/schemas/workflows/durable-workflow-run.schema.json +1 -0
- package/version.json +1 -1
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://schemas.sogni.ai/creative-agent/2026-05-20.1/artifacts/artifact-node.schema.json",
|
|
4
|
+
"title": "Artifact graph node",
|
|
5
|
+
"schemaVersion": "2026-05-20.1",
|
|
6
|
+
"description": "One node in the v2 ArtifactGraph. ArtifactNode replaces positional URL arrays (resultUrls / videoResultUrls / audioResultUrls) deleted in plan Phase 5. Every tool result auto-registers one node. Lineage edges resolve continuation ('use the second image', 'make it cinematic') without transcript scraping. Per-model token shape lives in modelRefs (gpt-image-2 'Image 1', seedance-2 '@Image1', ltx-2.3 'context_image_0').",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"$defs": {
|
|
10
|
+
"ArtifactEdge": {
|
|
11
|
+
"type": "object",
|
|
12
|
+
"additionalProperties": false,
|
|
13
|
+
"description": "Typed lineage edge from this artifact to one of its parents.",
|
|
14
|
+
"properties": {
|
|
15
|
+
"parentId": { "type": "string" },
|
|
16
|
+
"relation": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"enum": [
|
|
19
|
+
"derived_from",
|
|
20
|
+
"edited_from",
|
|
21
|
+
"styled_from",
|
|
22
|
+
"animated_from",
|
|
23
|
+
"stitched_from",
|
|
24
|
+
"extended_from",
|
|
25
|
+
"segmented_from",
|
|
26
|
+
"reference_for"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"required": ["parentId", "relation"]
|
|
31
|
+
},
|
|
32
|
+
"ArtifactVersion": {
|
|
33
|
+
"type": "object",
|
|
34
|
+
"additionalProperties": false,
|
|
35
|
+
"description": "One version of an artifact. Retries, refinements, and user-driven redos all append a version rather than mutating an existing one.",
|
|
36
|
+
"properties": {
|
|
37
|
+
"versionId": { "type": "string" },
|
|
38
|
+
"uri": { "type": "string" },
|
|
39
|
+
"createdAt": { "type": "string", "format": "date-time" },
|
|
40
|
+
"reason": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"enum": ["initial", "retry", "refinement", "audit_repair", "user_redo"]
|
|
43
|
+
},
|
|
44
|
+
"jobId": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"description": "Optional sogni-socket job id that produced this version."
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"required": ["versionId", "createdAt", "reason"]
|
|
50
|
+
},
|
|
51
|
+
"ArtifactSource": {
|
|
52
|
+
"oneOf": [
|
|
53
|
+
{
|
|
54
|
+
"type": "object",
|
|
55
|
+
"additionalProperties": false,
|
|
56
|
+
"properties": {
|
|
57
|
+
"type": { "const": "upload" },
|
|
58
|
+
"uploadId": { "type": "string" }
|
|
59
|
+
},
|
|
60
|
+
"required": ["type", "uploadId"]
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"type": "object",
|
|
64
|
+
"additionalProperties": false,
|
|
65
|
+
"properties": {
|
|
66
|
+
"type": { "const": "tool_result" },
|
|
67
|
+
"runId": { "type": "string" },
|
|
68
|
+
"toolCallId": { "type": "string" }
|
|
69
|
+
},
|
|
70
|
+
"required": ["type", "toolCallId"]
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"type": "object",
|
|
74
|
+
"additionalProperties": false,
|
|
75
|
+
"properties": {
|
|
76
|
+
"type": { "const": "workflow_stage" },
|
|
77
|
+
"workflowRunId": { "type": "string" },
|
|
78
|
+
"stageId": { "type": "string" },
|
|
79
|
+
"itemId": { "type": "string" }
|
|
80
|
+
},
|
|
81
|
+
"required": ["type", "workflowRunId", "stageId"]
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"properties": {
|
|
87
|
+
"artifactId": {
|
|
88
|
+
"type": "string",
|
|
89
|
+
"pattern": "^art_(?:[0-9A-Z]{26}|[0-9a-fA-F]{32}|[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$",
|
|
90
|
+
"description": "Stable artifact id. ULID form (`art_` + 26-char Crockford base32 body) is RECOMMENDED for new ids — use `generateUlidArtifactId()` from `@sogni-ai/sogni-intelligence-client/artifacts`. Two legacy forms remain accepted so existing in-wild ids stay valid: `art_` + 32 hex chars (UUID with hyphens stripped, the historical `createArtifactNode` output) and `art_` + canonical UUID with hyphens. Read-side validators must keep accepting all three; write-side code SHOULD enforce ULID via `preferUlid()`."
|
|
91
|
+
},
|
|
92
|
+
"kind": {
|
|
93
|
+
"type": "string",
|
|
94
|
+
"enum": ["image", "video", "audio", "text", "workflow", "collection"]
|
|
95
|
+
},
|
|
96
|
+
"uri": {
|
|
97
|
+
"type": "string",
|
|
98
|
+
"description": "Canonical resolvable URI for the current version (mirrors versions[last].uri for convenience)."
|
|
99
|
+
},
|
|
100
|
+
"mimeType": { "type": "string" },
|
|
101
|
+
"userLabel": {
|
|
102
|
+
"type": "string",
|
|
103
|
+
"description": "Friendly label the user (or the system on the user's behalf) chose. Optional; planner falls back to artifactId + kind."
|
|
104
|
+
},
|
|
105
|
+
"modelRefs": {
|
|
106
|
+
"type": "object",
|
|
107
|
+
"additionalProperties": { "type": "string" },
|
|
108
|
+
"description": "Per-model formatter mapping. Keys are model ids; values are the token that model expects in prompts. Examples: gpt-image-2 -> 'Image 1', seedance-2 -> '@Image1', ltx-2.3 -> 'context_image_0'. Use the asset-reference helpers in @sogni/creative-agent rather than hand-formatting."
|
|
109
|
+
},
|
|
110
|
+
"source": { "$ref": "#/$defs/ArtifactSource" },
|
|
111
|
+
"parents": {
|
|
112
|
+
"type": "array",
|
|
113
|
+
"items": { "$ref": "#/$defs/ArtifactEdge" }
|
|
114
|
+
},
|
|
115
|
+
"versions": {
|
|
116
|
+
"type": "array",
|
|
117
|
+
"minItems": 1,
|
|
118
|
+
"items": { "$ref": "#/$defs/ArtifactVersion" }
|
|
119
|
+
},
|
|
120
|
+
"metadata": {
|
|
121
|
+
"type": "object",
|
|
122
|
+
"additionalProperties": true,
|
|
123
|
+
"description": "Free-form artifact metadata (width/height, durationSeconds, seed, prompt summary, etc.). Boundary code populates known fields; consumers must not assume any specific field is present."
|
|
124
|
+
},
|
|
125
|
+
"createdAt": { "type": "string", "format": "date-time" }
|
|
126
|
+
},
|
|
127
|
+
"required": [
|
|
128
|
+
"artifactId",
|
|
129
|
+
"kind",
|
|
130
|
+
"modelRefs",
|
|
131
|
+
"source",
|
|
132
|
+
"parents",
|
|
133
|
+
"versions",
|
|
134
|
+
"metadata",
|
|
135
|
+
"createdAt"
|
|
136
|
+
]
|
|
137
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://schemas.sogni.ai/creative-agent/2026-05-20.1/billing/spend-gate.schema.json",
|
|
4
|
+
"title": "Spend gate request and state",
|
|
5
|
+
"schemaVersion": "2026-05-20.1",
|
|
6
|
+
"description": "Single shared spend-approval state machine for atomic tool calls (scope='tool_call'), grouped concurrent dispatches (scope='parallel_batch'), and workflow authorizations (scope='workflow_run'). One envelope, one state enum, one transition log. Per-job settlement remains on the sogni-socket project+N path — this gate authorizes spend, it does not move funds. Note: additionalProperties:false is applied per oneOf branch, not at the root — a root-level additionalProperties has no sibling properties to whitelist against and would reject every payload.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"$defs": {
|
|
9
|
+
"SpendGateState": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "Canonical lifecycle states for a spend gate. 'not_required' = free / no-cost tool. 'preview_required' = estimate must be shown to the user. 'waiting_for_user' = awaiting confirm or cancel. 'confirmed' = user accepted; runner may dispatch. 'cancelled' = user declined. 'insufficient_credit' = wallet balance below estimate. 'safety_review_required' = blocked pending human or automated safety review. 'failed' = unrecoverable error in the gate itself.",
|
|
12
|
+
"enum": [
|
|
13
|
+
"not_required",
|
|
14
|
+
"preview_required",
|
|
15
|
+
"waiting_for_user",
|
|
16
|
+
"confirmed",
|
|
17
|
+
"cancelled",
|
|
18
|
+
"insufficient_credit",
|
|
19
|
+
"safety_review_required",
|
|
20
|
+
"failed"
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
"SpendGateDecision": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "Decision recorded when the gate leaves waiting_for_user. Three historical vocabularies are accepted: 'confirm'/'cancel' (canonical), 'approved'/'rejected' (pre-2026-05-20 aliases still emitted by sogni-api and sogni-creative-agent durable runs), and 'cancelled' (alternate past-tense spelling collapsing to 'cancel'). Consumers normalize via normalizeSpendDecision so business logic only sees the canonical pair.",
|
|
26
|
+
"enum": ["confirm", "cancel", "approved", "rejected", "cancelled"]
|
|
27
|
+
},
|
|
28
|
+
"SpendEstimateLineItem": {
|
|
29
|
+
"type": "object",
|
|
30
|
+
"additionalProperties": false,
|
|
31
|
+
"description": "One row of the spend estimate breakdown. Sum of (units * model price) across line items yields the estimate's capacityUnits.",
|
|
32
|
+
"properties": {
|
|
33
|
+
"model": { "type": "string" },
|
|
34
|
+
"units": { "type": "number", "minimum": 0 },
|
|
35
|
+
"tokenType": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"enum": ["spark", "sogni"]
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"required": ["model", "units", "tokenType"]
|
|
41
|
+
},
|
|
42
|
+
"SpendGateEstimate": {
|
|
43
|
+
"type": "object",
|
|
44
|
+
"additionalProperties": false,
|
|
45
|
+
"description": "Estimate payload carried on the gate itself. capacityUnits = sum of breakdown units; tokenType = denomination the breakdown is in; maxAcceptableUnits = optional caller-supplied cap.",
|
|
46
|
+
"properties": {
|
|
47
|
+
"capacityUnits": { "type": "number", "minimum": 0 },
|
|
48
|
+
"breakdown": {
|
|
49
|
+
"type": "array",
|
|
50
|
+
"minItems": 1,
|
|
51
|
+
"items": { "$ref": "#/$defs/SpendEstimateLineItem" }
|
|
52
|
+
},
|
|
53
|
+
"tokenType": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"enum": ["spark", "sogni"]
|
|
56
|
+
},
|
|
57
|
+
"maxAcceptableUnits": { "type": "number", "minimum": 0 }
|
|
58
|
+
},
|
|
59
|
+
"required": ["capacityUnits", "breakdown", "tokenType"]
|
|
60
|
+
},
|
|
61
|
+
"PendingToolCall": {
|
|
62
|
+
"type": "object",
|
|
63
|
+
"additionalProperties": false,
|
|
64
|
+
"description": "Minimal reference to a tool call this gate covers (when scope='tool_call' the array has one entry; when scope='parallel_batch' it carries the constituent calls of the fan-out; when scope='workflow_run' the gate authorizes the umbrella and pendingToolCalls may be empty).",
|
|
65
|
+
"properties": {
|
|
66
|
+
"toolCallId": { "type": "string" },
|
|
67
|
+
"toolName": { "type": "string" },
|
|
68
|
+
"estimateUnits": { "type": "number", "minimum": 0 }
|
|
69
|
+
},
|
|
70
|
+
"required": ["toolCallId", "toolName"]
|
|
71
|
+
},
|
|
72
|
+
"PendingWorkflowPlan": {
|
|
73
|
+
"type": "object",
|
|
74
|
+
"additionalProperties": false,
|
|
75
|
+
"description": "Reference to the workflow run this gate authorizes (only meaningful when scope='workflow_run').",
|
|
76
|
+
"properties": {
|
|
77
|
+
"workflowRunId": { "type": "string" },
|
|
78
|
+
"templateId": { "type": "string" }
|
|
79
|
+
},
|
|
80
|
+
"required": ["workflowRunId", "templateId"]
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"oneOf": [
|
|
84
|
+
{
|
|
85
|
+
"type": "object",
|
|
86
|
+
"additionalProperties": false,
|
|
87
|
+
"properties": {
|
|
88
|
+
"gateId": { "type": "string" },
|
|
89
|
+
"runId": { "type": "string" },
|
|
90
|
+
"scope": { "const": "tool_call" },
|
|
91
|
+
"toolCallId": { "type": "string" },
|
|
92
|
+
"pendingToolCalls": {
|
|
93
|
+
"type": "array",
|
|
94
|
+
"items": { "$ref": "#/$defs/PendingToolCall" }
|
|
95
|
+
},
|
|
96
|
+
"estimate": { "$ref": "#/$defs/SpendGateEstimate" },
|
|
97
|
+
"state": { "$ref": "#/$defs/SpendGateState" },
|
|
98
|
+
"reason": { "type": "string" },
|
|
99
|
+
"decision": { "$ref": "#/$defs/SpendGateDecision" },
|
|
100
|
+
"createdAt": { "type": "string", "format": "date-time" },
|
|
101
|
+
"decidedAt": { "type": "string", "format": "date-time" },
|
|
102
|
+
"updatedAt": { "type": "string", "format": "date-time" },
|
|
103
|
+
"failureReason": { "type": "string" }
|
|
104
|
+
},
|
|
105
|
+
"required": ["gateId", "scope", "toolCallId", "estimate", "state", "updatedAt"]
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"type": "object",
|
|
109
|
+
"additionalProperties": false,
|
|
110
|
+
"properties": {
|
|
111
|
+
"gateId": { "type": "string" },
|
|
112
|
+
"runId": { "type": "string" },
|
|
113
|
+
"scope": { "const": "parallel_batch" },
|
|
114
|
+
"pendingToolCalls": {
|
|
115
|
+
"type": "array",
|
|
116
|
+
"minItems": 1,
|
|
117
|
+
"items": { "$ref": "#/$defs/PendingToolCall" }
|
|
118
|
+
},
|
|
119
|
+
"estimate": { "$ref": "#/$defs/SpendGateEstimate" },
|
|
120
|
+
"state": { "$ref": "#/$defs/SpendGateState" },
|
|
121
|
+
"reason": { "type": "string" },
|
|
122
|
+
"decision": { "$ref": "#/$defs/SpendGateDecision" },
|
|
123
|
+
"createdAt": { "type": "string", "format": "date-time" },
|
|
124
|
+
"decidedAt": { "type": "string", "format": "date-time" },
|
|
125
|
+
"updatedAt": { "type": "string", "format": "date-time" },
|
|
126
|
+
"failureReason": { "type": "string" }
|
|
127
|
+
},
|
|
128
|
+
"required": ["gateId", "scope", "pendingToolCalls", "estimate", "state", "updatedAt"]
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"type": "object",
|
|
132
|
+
"additionalProperties": false,
|
|
133
|
+
"properties": {
|
|
134
|
+
"gateId": { "type": "string" },
|
|
135
|
+
"runId": { "type": "string" },
|
|
136
|
+
"scope": { "const": "workflow_run" },
|
|
137
|
+
"workflowRunId": { "type": "string" },
|
|
138
|
+
"pendingWorkflowPlan": { "$ref": "#/$defs/PendingWorkflowPlan" },
|
|
139
|
+
"estimate": { "$ref": "#/$defs/SpendGateEstimate" },
|
|
140
|
+
"state": { "$ref": "#/$defs/SpendGateState" },
|
|
141
|
+
"reason": { "type": "string" },
|
|
142
|
+
"decision": { "$ref": "#/$defs/SpendGateDecision" },
|
|
143
|
+
"createdAt": { "type": "string", "format": "date-time" },
|
|
144
|
+
"decidedAt": { "type": "string", "format": "date-time" },
|
|
145
|
+
"updatedAt": { "type": "string", "format": "date-time" },
|
|
146
|
+
"failureReason": { "type": "string" }
|
|
147
|
+
},
|
|
148
|
+
"required": ["gateId", "scope", "workflowRunId", "estimate", "state", "updatedAt"]
|
|
149
|
+
}
|
|
150
|
+
]
|
|
151
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://schemas.sogni.ai/creative-agent/2026-05-20.1/billing/workflow-authorization.schema.json",
|
|
4
|
+
"title": "Workflow authorization ticket",
|
|
5
|
+
"schemaVersion": "2026-05-20.1",
|
|
6
|
+
"description": "Umbrella authorization ticket recorded once at workflow run start. The executor consults it before dispatching each stage and pauses for re-authorization if cumulative settled + reserved + next-estimate would exceed authorizedCapacityUnits. Per-job settlement continues through the existing sogni-socket 'project + N identical jobs' path; the workflow layer is an authorization umbrella, not a new transaction ledger.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"$defs": {
|
|
10
|
+
"StageSettlementStatus": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"enum": ["pending", "in_flight", "settled", "failed", "cancelled"]
|
|
13
|
+
},
|
|
14
|
+
"StageSettlement": {
|
|
15
|
+
"type": "object",
|
|
16
|
+
"additionalProperties": false,
|
|
17
|
+
"description": "Per-stage ledger row. estimatedUnits comes from the WorkflowCostPreview; settledUnits is filled in as the sogni-socket worker(s) for this stage finish.",
|
|
18
|
+
"properties": {
|
|
19
|
+
"stageId": { "type": "string" },
|
|
20
|
+
"projectId": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "sogni-socket project id. Null until dispatched."
|
|
23
|
+
},
|
|
24
|
+
"jobIds": {
|
|
25
|
+
"type": "array",
|
|
26
|
+
"description": "sogni-socket job ids. Empty until dispatched. May have multiple entries for fan-out stages.",
|
|
27
|
+
"items": { "type": "string" }
|
|
28
|
+
},
|
|
29
|
+
"estimatedUnits": { "type": "number", "minimum": 0 },
|
|
30
|
+
"settledUnits": {
|
|
31
|
+
"type": "number",
|
|
32
|
+
"minimum": 0,
|
|
33
|
+
"description": "Cumulative settled units for this stage. Null until at least one worker completes."
|
|
34
|
+
},
|
|
35
|
+
"status": { "$ref": "#/$defs/StageSettlementStatus" }
|
|
36
|
+
},
|
|
37
|
+
"required": ["stageId", "estimatedUnits", "status"]
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"properties": {
|
|
41
|
+
"workflowRunId": { "type": "string" },
|
|
42
|
+
"authorizedCapacityUnits": {
|
|
43
|
+
"type": "number",
|
|
44
|
+
"minimum": 0,
|
|
45
|
+
"description": "Umbrella cap. Per-job settlements stay within this; if next dispatch would exceed by more than the documented drift tolerance the run pauses for re-authorization."
|
|
46
|
+
},
|
|
47
|
+
"tokenType": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"enum": ["spark", "sogni"]
|
|
50
|
+
},
|
|
51
|
+
"authorizedAt": { "type": "string", "format": "date-time" },
|
|
52
|
+
"expiresAt": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"format": "date-time",
|
|
55
|
+
"description": "Past expiry, the run pauses with cost_approval_required for re-authorization. Template declares an expected duration; expiry is duration + retry grace."
|
|
56
|
+
},
|
|
57
|
+
"cumulativeSettledUnits": {
|
|
58
|
+
"type": "number",
|
|
59
|
+
"minimum": 0,
|
|
60
|
+
"description": "Sum of stageSettlements[].settledUnits to date."
|
|
61
|
+
},
|
|
62
|
+
"cumulativeReservedUnits": {
|
|
63
|
+
"type": "number",
|
|
64
|
+
"minimum": 0,
|
|
65
|
+
"description": "Estimated units for in-flight jobs not yet settled."
|
|
66
|
+
},
|
|
67
|
+
"stageSettlements": {
|
|
68
|
+
"type": "array",
|
|
69
|
+
"description": "Per-stage ledger. May be empty pre-dispatch; populated as the executor dispatches each stage.",
|
|
70
|
+
"items": { "$ref": "#/$defs/StageSettlement" }
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"required": [
|
|
74
|
+
"workflowRunId",
|
|
75
|
+
"authorizedCapacityUnits",
|
|
76
|
+
"tokenType",
|
|
77
|
+
"authorizedAt",
|
|
78
|
+
"expiresAt",
|
|
79
|
+
"cumulativeSettledUnits",
|
|
80
|
+
"cumulativeReservedUnits",
|
|
81
|
+
"stageSettlements"
|
|
82
|
+
]
|
|
83
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://schemas.sogni.ai/creative-agent/2026-05-20.1/events/run-event.schema.json",
|
|
4
|
+
"title": "Unified run event",
|
|
5
|
+
"schemaVersion": "2026-05-20.1",
|
|
6
|
+
"description": "Single event vocabulary across chat runs and workflow runs. Both persist into the shared `runs` substrate (plan §13.5) and differ only by the runKind discriminator. SSE replay key is (runId, sequence). idempotencyKey covers reentrant transitions such as cost confirmation. Per-event-type payload shapes are deliberately not enforced at this layer — payload shapes are documented per type and tightened in a Phase 1 follow-up to avoid an enormous union in this round.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"$defs": {
|
|
10
|
+
"RunEventType": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "All event types — superset of every type emitted by any current consumer (sogni-creative-agent-v2, sogni-chat, sogni-api) plus the schema-mandated set; mirrors RUN_EVENT_TYPES in sogni-intelligence-client src/events/runEvent.ts. Clusters: lifecycle (run_created, run_queued, run_started, run_resumed, run_completed, run_partial_failure, run_failed, run_cancelled), LLM (llm_round_started, llm_token, llm_round_completed, assistant_message_delta, assistant_message_completed), tools (tool_call_proposed, tool_call_dispatched, tool_call_progress, tool_call_resolved), artifacts (artifact_created, artifact_updated, artifact_referenced), media context (media_context_updated, media_turn_intent_classified, asset_manifest_updated), waiting (run_waiting_for_user), spend/billing (billing_preview_updated, spend_gate_opened, spend_preview_emitted, spend_confirmed, spend_cancelled, spend_insufficient, run_awaiting_cost_confirmation, run_cost_confirmation_resolved), workflow-stage (stage_started, stage_completed, stage_failed, stage_waiting_for_user), audit (audit_evaluated, repair_requested).",
|
|
13
|
+
"enum": [
|
|
14
|
+
"run_created",
|
|
15
|
+
"run_queued",
|
|
16
|
+
"run_started",
|
|
17
|
+
"run_resumed",
|
|
18
|
+
"run_completed",
|
|
19
|
+
"run_partial_failure",
|
|
20
|
+
"run_failed",
|
|
21
|
+
"run_cancelled",
|
|
22
|
+
"llm_round_started",
|
|
23
|
+
"llm_token",
|
|
24
|
+
"llm_round_completed",
|
|
25
|
+
"assistant_message_delta",
|
|
26
|
+
"assistant_message_completed",
|
|
27
|
+
"tool_call_proposed",
|
|
28
|
+
"tool_call_dispatched",
|
|
29
|
+
"tool_call_progress",
|
|
30
|
+
"tool_call_resolved",
|
|
31
|
+
"artifact_created",
|
|
32
|
+
"artifact_updated",
|
|
33
|
+
"artifact_referenced",
|
|
34
|
+
"media_context_updated",
|
|
35
|
+
"media_turn_intent_classified",
|
|
36
|
+
"asset_manifest_updated",
|
|
37
|
+
"run_waiting_for_user",
|
|
38
|
+
"billing_preview_updated",
|
|
39
|
+
"spend_gate_opened",
|
|
40
|
+
"spend_preview_emitted",
|
|
41
|
+
"spend_confirmed",
|
|
42
|
+
"spend_cancelled",
|
|
43
|
+
"spend_insufficient",
|
|
44
|
+
"run_awaiting_cost_confirmation",
|
|
45
|
+
"run_cost_confirmation_resolved",
|
|
46
|
+
"stage_started",
|
|
47
|
+
"stage_completed",
|
|
48
|
+
"stage_failed",
|
|
49
|
+
"stage_waiting_for_user",
|
|
50
|
+
"audit_evaluated",
|
|
51
|
+
"repair_requested"
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
"RunStatus": {
|
|
55
|
+
"type": "string",
|
|
56
|
+
"description": "Unified status enum across chat and workflow runs.",
|
|
57
|
+
"enum": [
|
|
58
|
+
"queued",
|
|
59
|
+
"running",
|
|
60
|
+
"completed",
|
|
61
|
+
"partial_failure",
|
|
62
|
+
"waiting_for_user",
|
|
63
|
+
"failed",
|
|
64
|
+
"cancelled"
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
"WaitingReason": {
|
|
68
|
+
"type": "string",
|
|
69
|
+
"description": "Why a run paused. Carried inside the payload of a run_waiting_for_user event (and stage_waiting_for_user where applicable).",
|
|
70
|
+
"enum": [
|
|
71
|
+
"ask_clarifying_question",
|
|
72
|
+
"select_media_required",
|
|
73
|
+
"cost_approval_required",
|
|
74
|
+
"safety_review_required",
|
|
75
|
+
"workflow_user_input_required",
|
|
76
|
+
"insufficient_credit",
|
|
77
|
+
"other"
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"properties": {
|
|
82
|
+
"runId": { "type": "string" },
|
|
83
|
+
"runKind": {
|
|
84
|
+
"type": "string",
|
|
85
|
+
"enum": ["chat", "workflow", "tool_batch"],
|
|
86
|
+
"description": "Substrate discriminator (plan §13.5). chat and workflow runs share persistence, lease, heartbeat, event log, waiting semantics, cancellation, cost confirmation, and resume. tool_batch is used by sogni-creative-agent-v2 for fan-out tool-call runs that share the same event substrate without being a full chat or workflow run."
|
|
87
|
+
},
|
|
88
|
+
"sequence": {
|
|
89
|
+
"type": "integer",
|
|
90
|
+
"minimum": 0,
|
|
91
|
+
"description": "Strictly increasing per runId. SSE replay key is (runId, sequence)."
|
|
92
|
+
},
|
|
93
|
+
"type": { "$ref": "#/$defs/RunEventType" },
|
|
94
|
+
"status": { "$ref": "#/$defs/RunStatus" },
|
|
95
|
+
"payload": {
|
|
96
|
+
"type": "object",
|
|
97
|
+
"additionalProperties": true,
|
|
98
|
+
"description": "Per-type payload. Documented shapes: run_waiting_for_user -> { reason: WaitingReason, ... }; tool_call_proposed/_dispatched/_progress/_resolved -> { toolCallId, toolName, ... }; artifact_* -> { artifactId, ... }; spend_* -> { gateId, scope, ... }; audit_evaluated -> { toolCallId, passed, ... }; repair_requested -> { toolCallId, reason, retryCount }; stage_* -> { stageId, ... }. Schema-level enforcement of these shapes is intentionally deferred to Phase 1 to avoid an unwieldy union here."
|
|
99
|
+
},
|
|
100
|
+
"createdAt": { "type": "string", "format": "date-time" },
|
|
101
|
+
"resumable": {
|
|
102
|
+
"type": "boolean",
|
|
103
|
+
"description": "True when the run is in a state the client can resume from (typically paired with run_waiting_for_user)."
|
|
104
|
+
},
|
|
105
|
+
"terminal": {
|
|
106
|
+
"type": "boolean",
|
|
107
|
+
"description": "True for the final event of a run (run_completed / run_failed / run_cancelled / run_partial_failure)."
|
|
108
|
+
},
|
|
109
|
+
"idempotencyKey": {
|
|
110
|
+
"type": "string",
|
|
111
|
+
"description": "Stable key for reentrant transitions (e.g. POST /confirm-cost). Re-submitting the same key MUST be a no-op."
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"required": [
|
|
115
|
+
"runId",
|
|
116
|
+
"runKind",
|
|
117
|
+
"sequence",
|
|
118
|
+
"type",
|
|
119
|
+
"payload",
|
|
120
|
+
"createdAt"
|
|
121
|
+
]
|
|
122
|
+
}
|