@independo/inderun-contracts 0.2.2-dev.1 → 0.3.0-dev.1
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/generated/index.d.ts +3 -0
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/schemas.d.ts +539 -0
- package/dist/generated/schemas.d.ts.map +1 -1
- package/dist/generated/schemas.js +674 -0
- package/dist/generated/stream-event.d.ts +139 -0
- package/dist/generated/stream-event.d.ts.map +1 -0
- package/dist/generated/stream-event.js +2 -0
- package/dist/generated/stream-run.d.ts +31 -0
- package/dist/generated/stream-run.d.ts.map +1 -0
- package/dist/generated/stream-run.js +2 -0
- package/dist/generated/stream-terminal-outcome.d.ts +165 -0
- package/dist/generated/stream-terminal-outcome.d.ts.map +1 -0
- package/dist/generated/stream-terminal-outcome.js +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/validators.d.ts +9 -0
- package/dist/validators.d.ts.map +1 -1
- package/dist/validators.js +26 -1
- package/package.json +1 -1
|
@@ -945,3 +945,677 @@ export const modelPackageSchema = {
|
|
|
945
945
|
}
|
|
946
946
|
}
|
|
947
947
|
};
|
|
948
|
+
export const streamRunSchema = {
|
|
949
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
950
|
+
"$id": "https://schemas.inderun.dev/1.0/stream-run.schema.json",
|
|
951
|
+
"title": "StreamRunHandle",
|
|
952
|
+
"description": "The serializable acknowledgment returned when a Mode 2 stream is opened, before any StreamEvent has arrived. This is the identity/correlation contract only: the live, consumable stream itself is a platform-idiomatic construct (an AsyncIterable<StreamEvent> in TypeScript, a Flow<StreamEvent> in Kotlin, an AsyncThrowingStream<StreamEvent, Error> in Swift) that is never serialized and is out of scope for this schema. Design seam only; no engine or provider implementation exists yet (see docs/architecture/architecture.md).",
|
|
953
|
+
"type": "object",
|
|
954
|
+
"additionalProperties": true,
|
|
955
|
+
"required": [
|
|
956
|
+
"schemaVersion",
|
|
957
|
+
"runId",
|
|
958
|
+
"startedAt"
|
|
959
|
+
],
|
|
960
|
+
"properties": {
|
|
961
|
+
"schemaVersion": {
|
|
962
|
+
"description": "Contract schema version used to interpret this handle payload.",
|
|
963
|
+
"const": "1.0"
|
|
964
|
+
},
|
|
965
|
+
"runId": {
|
|
966
|
+
"description": "A unique, opaque identifier assigned by the engine for this stream run. Every StreamEvent and the terminal StreamTerminalOutcome for this run carry the same runId, matching the identity convention used by TaskResult.runId and IndeRunError.runId.",
|
|
967
|
+
"type": "string",
|
|
968
|
+
"minLength": 1
|
|
969
|
+
},
|
|
970
|
+
"startedAt": {
|
|
971
|
+
"description": "Wall-clock time the stream run was opened, in Unix epoch milliseconds.",
|
|
972
|
+
"type": "number",
|
|
973
|
+
"minimum": 0
|
|
974
|
+
},
|
|
975
|
+
"providerId": {
|
|
976
|
+
"description": "Identifier of the provider selected to service this stream, if routing has completed by the time the handle is returned. Absent while route selection is still pending.",
|
|
977
|
+
"type": "string",
|
|
978
|
+
"minLength": 1
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
};
|
|
982
|
+
export const streamEventSchema = {
|
|
983
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
984
|
+
"$id": "https://schemas.inderun.dev/1.0/stream-event.schema.json",
|
|
985
|
+
"title": "StreamEvent",
|
|
986
|
+
"description": "The canonical Mode 2 streaming event union, discriminated by 'type'. Every variant shares an envelope of schemaVersion, runId, sequence, timestamp, and type. 'sequence' is the ordering authority for events within a run (a monotonically increasing integer starting at 0 per runId) — consumers must order by 'sequence', not by arrival order, since a bridge hop (e.g. a future Capacitor bridge) could reorder delivery. Known event types are split into user-visible content ('content_delta', 'content_snapshot') and mechanical/diagnostic types ('lifecycle', 'diagnostic', 'terminal') so SDKs can distinguish what belongs in a chat UI from what is orchestration detail. Forward compatibility: this union closes with an open 'unknown_event' branch so a consumer built against an older revision of this schema does not hard-fail when a newer, additive minor revision introduces a new known type; per contracts/README.md's schema evolution policy, SDKs must treat an unrecognized 'type' as ignore-or-pass-through-for-diagnostics, never as a hard error. Design seam only; no engine or provider implementation exists yet (see docs/architecture/architecture.md).",
|
|
987
|
+
"oneOf": [
|
|
988
|
+
{
|
|
989
|
+
"type": "object",
|
|
990
|
+
"additionalProperties": true,
|
|
991
|
+
"required": [
|
|
992
|
+
"schemaVersion",
|
|
993
|
+
"runId",
|
|
994
|
+
"sequence",
|
|
995
|
+
"timestamp",
|
|
996
|
+
"type",
|
|
997
|
+
"payload"
|
|
998
|
+
],
|
|
999
|
+
"properties": {
|
|
1000
|
+
"schemaVersion": {
|
|
1001
|
+
"description": "Contract schema version used to interpret this event payload.",
|
|
1002
|
+
"const": "1.0"
|
|
1003
|
+
},
|
|
1004
|
+
"runId": {
|
|
1005
|
+
"description": "Opaque run identifier this event belongs to, matching StreamRunHandle.runId.",
|
|
1006
|
+
"type": "string",
|
|
1007
|
+
"minLength": 1
|
|
1008
|
+
},
|
|
1009
|
+
"sequence": {
|
|
1010
|
+
"description": "Zero-based, monotonically increasing event index within this run. The ordering authority; do not rely on delivery/arrival order.",
|
|
1011
|
+
"type": "integer",
|
|
1012
|
+
"minimum": 0
|
|
1013
|
+
},
|
|
1014
|
+
"timestamp": {
|
|
1015
|
+
"description": "Wall-clock event timestamp in Unix epoch milliseconds.",
|
|
1016
|
+
"type": "number",
|
|
1017
|
+
"minimum": 0
|
|
1018
|
+
},
|
|
1019
|
+
"type": {
|
|
1020
|
+
"description": "User-visible content: an incremental text increment since the previous content_delta or content_snapshot event. Mirrors ProviderDescriptor.streamingStyle 'tokens'/'chunks' (packages/inderun-web/src/core/provider.ts) — providers reporting either style normalize to content_delta.",
|
|
1021
|
+
"const": "content_delta"
|
|
1022
|
+
},
|
|
1023
|
+
"payload": {
|
|
1024
|
+
"type": "object",
|
|
1025
|
+
"additionalProperties": true,
|
|
1026
|
+
"required": [
|
|
1027
|
+
"text"
|
|
1028
|
+
],
|
|
1029
|
+
"properties": {
|
|
1030
|
+
"text": {
|
|
1031
|
+
"description": "The incremental text produced since the previous content event.",
|
|
1032
|
+
"type": "string"
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
},
|
|
1038
|
+
{
|
|
1039
|
+
"type": "object",
|
|
1040
|
+
"additionalProperties": true,
|
|
1041
|
+
"required": [
|
|
1042
|
+
"schemaVersion",
|
|
1043
|
+
"runId",
|
|
1044
|
+
"sequence",
|
|
1045
|
+
"timestamp",
|
|
1046
|
+
"type",
|
|
1047
|
+
"payload"
|
|
1048
|
+
],
|
|
1049
|
+
"properties": {
|
|
1050
|
+
"schemaVersion": {
|
|
1051
|
+
"description": "Contract schema version used to interpret this event payload.",
|
|
1052
|
+
"const": "1.0"
|
|
1053
|
+
},
|
|
1054
|
+
"runId": {
|
|
1055
|
+
"description": "Opaque run identifier this event belongs to, matching StreamRunHandle.runId.",
|
|
1056
|
+
"type": "string",
|
|
1057
|
+
"minLength": 1
|
|
1058
|
+
},
|
|
1059
|
+
"sequence": {
|
|
1060
|
+
"description": "Zero-based, monotonically increasing event index within this run. The ordering authority; do not rely on delivery/arrival order.",
|
|
1061
|
+
"type": "integer",
|
|
1062
|
+
"minimum": 0
|
|
1063
|
+
},
|
|
1064
|
+
"timestamp": {
|
|
1065
|
+
"description": "Wall-clock event timestamp in Unix epoch milliseconds.",
|
|
1066
|
+
"type": "number",
|
|
1067
|
+
"minimum": 0
|
|
1068
|
+
},
|
|
1069
|
+
"type": {
|
|
1070
|
+
"description": "User-visible content: the full cumulative text produced so far. Mirrors ProviderDescriptor.streamingStyle 'snapshots' (packages/inderun-web/src/core/provider.ts) — providers reporting that style normalize to content_snapshot rather than content_delta.",
|
|
1071
|
+
"const": "content_snapshot"
|
|
1072
|
+
},
|
|
1073
|
+
"payload": {
|
|
1074
|
+
"type": "object",
|
|
1075
|
+
"additionalProperties": true,
|
|
1076
|
+
"required": [
|
|
1077
|
+
"text"
|
|
1078
|
+
],
|
|
1079
|
+
"properties": {
|
|
1080
|
+
"text": {
|
|
1081
|
+
"description": "The full cumulative text produced by the run so far.",
|
|
1082
|
+
"type": "string"
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
},
|
|
1088
|
+
{
|
|
1089
|
+
"type": "object",
|
|
1090
|
+
"additionalProperties": true,
|
|
1091
|
+
"required": [
|
|
1092
|
+
"schemaVersion",
|
|
1093
|
+
"runId",
|
|
1094
|
+
"sequence",
|
|
1095
|
+
"timestamp",
|
|
1096
|
+
"type",
|
|
1097
|
+
"payload"
|
|
1098
|
+
],
|
|
1099
|
+
"properties": {
|
|
1100
|
+
"schemaVersion": {
|
|
1101
|
+
"description": "Contract schema version used to interpret this event payload.",
|
|
1102
|
+
"const": "1.0"
|
|
1103
|
+
},
|
|
1104
|
+
"runId": {
|
|
1105
|
+
"description": "Opaque run identifier this event belongs to, matching StreamRunHandle.runId.",
|
|
1106
|
+
"type": "string",
|
|
1107
|
+
"minLength": 1
|
|
1108
|
+
},
|
|
1109
|
+
"sequence": {
|
|
1110
|
+
"description": "Zero-based, monotonically increasing event index within this run. The ordering authority; do not rely on delivery/arrival order.",
|
|
1111
|
+
"type": "integer",
|
|
1112
|
+
"minimum": 0
|
|
1113
|
+
},
|
|
1114
|
+
"timestamp": {
|
|
1115
|
+
"description": "Wall-clock event timestamp in Unix epoch milliseconds.",
|
|
1116
|
+
"type": "number",
|
|
1117
|
+
"minimum": 0
|
|
1118
|
+
},
|
|
1119
|
+
"type": {
|
|
1120
|
+
"description": "Mechanical/diagnostic: a run lifecycle transition (e.g. provider selection, execution start). Not user-visible content; not part of the generated text.",
|
|
1121
|
+
"const": "lifecycle"
|
|
1122
|
+
},
|
|
1123
|
+
"payload": {
|
|
1124
|
+
"type": "object",
|
|
1125
|
+
"additionalProperties": true,
|
|
1126
|
+
"required": [
|
|
1127
|
+
"phase"
|
|
1128
|
+
],
|
|
1129
|
+
"properties": {
|
|
1130
|
+
"phase": {
|
|
1131
|
+
"description": "The lifecycle phase reached.",
|
|
1132
|
+
"enum": [
|
|
1133
|
+
"provider_selected",
|
|
1134
|
+
"started"
|
|
1135
|
+
]
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
},
|
|
1141
|
+
{
|
|
1142
|
+
"type": "object",
|
|
1143
|
+
"additionalProperties": true,
|
|
1144
|
+
"required": [
|
|
1145
|
+
"schemaVersion",
|
|
1146
|
+
"runId",
|
|
1147
|
+
"sequence",
|
|
1148
|
+
"timestamp",
|
|
1149
|
+
"type",
|
|
1150
|
+
"payload"
|
|
1151
|
+
],
|
|
1152
|
+
"properties": {
|
|
1153
|
+
"schemaVersion": {
|
|
1154
|
+
"description": "Contract schema version used to interpret this event payload.",
|
|
1155
|
+
"const": "1.0"
|
|
1156
|
+
},
|
|
1157
|
+
"runId": {
|
|
1158
|
+
"description": "Opaque run identifier this event belongs to, matching StreamRunHandle.runId.",
|
|
1159
|
+
"type": "string",
|
|
1160
|
+
"minLength": 1
|
|
1161
|
+
},
|
|
1162
|
+
"sequence": {
|
|
1163
|
+
"description": "Zero-based, monotonically increasing event index within this run. The ordering authority; do not rely on delivery/arrival order.",
|
|
1164
|
+
"type": "integer",
|
|
1165
|
+
"minimum": 0
|
|
1166
|
+
},
|
|
1167
|
+
"timestamp": {
|
|
1168
|
+
"description": "Wall-clock event timestamp in Unix epoch milliseconds.",
|
|
1169
|
+
"type": "number",
|
|
1170
|
+
"minimum": 0
|
|
1171
|
+
},
|
|
1172
|
+
"type": {
|
|
1173
|
+
"description": "Mechanical/diagnostic: free-form orchestration or provider diagnostic detail. Not user-visible content.",
|
|
1174
|
+
"const": "diagnostic"
|
|
1175
|
+
},
|
|
1176
|
+
"payload": {
|
|
1177
|
+
"description": "Event-specific diagnostic metadata. It must not contain prompt payloads or raw secrets, matching the same guardrail as TelemetryEvent.payload.",
|
|
1178
|
+
"type": "object",
|
|
1179
|
+
"additionalProperties": true
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
},
|
|
1183
|
+
{
|
|
1184
|
+
"type": "object",
|
|
1185
|
+
"additionalProperties": true,
|
|
1186
|
+
"required": [
|
|
1187
|
+
"schemaVersion",
|
|
1188
|
+
"runId",
|
|
1189
|
+
"sequence",
|
|
1190
|
+
"timestamp",
|
|
1191
|
+
"type",
|
|
1192
|
+
"payload"
|
|
1193
|
+
],
|
|
1194
|
+
"properties": {
|
|
1195
|
+
"schemaVersion": {
|
|
1196
|
+
"description": "Contract schema version used to interpret this event payload.",
|
|
1197
|
+
"const": "1.0"
|
|
1198
|
+
},
|
|
1199
|
+
"runId": {
|
|
1200
|
+
"description": "Opaque run identifier this event belongs to, matching StreamRunHandle.runId.",
|
|
1201
|
+
"type": "string",
|
|
1202
|
+
"minLength": 1
|
|
1203
|
+
},
|
|
1204
|
+
"sequence": {
|
|
1205
|
+
"description": "Zero-based, monotonically increasing event index within this run. This is always the highest sequence number for the run: the terminal event.",
|
|
1206
|
+
"type": "integer",
|
|
1207
|
+
"minimum": 0
|
|
1208
|
+
},
|
|
1209
|
+
"timestamp": {
|
|
1210
|
+
"description": "Wall-clock event timestamp in Unix epoch milliseconds.",
|
|
1211
|
+
"type": "number",
|
|
1212
|
+
"minimum": 0
|
|
1213
|
+
},
|
|
1214
|
+
"type": {
|
|
1215
|
+
"description": "Terminal: the last event of the run, carrying the mutually-exclusive completion/error/cancellation outcome. No further StreamEvent is delivered for this runId after this event.",
|
|
1216
|
+
"const": "terminal"
|
|
1217
|
+
},
|
|
1218
|
+
"payload": {
|
|
1219
|
+
"description": "Structurally identical to StreamTerminalOutcome (contracts/schemas/stream-terminal-outcome.schema.json), duplicated by value here rather than by $ref, matching this repo's schema convention of no cross-file references. Keep both shapes in sync; a cross-check test asserts a shared fixture validates against both schemas.",
|
|
1220
|
+
"oneOf": [
|
|
1221
|
+
{
|
|
1222
|
+
"type": "object",
|
|
1223
|
+
"additionalProperties": true,
|
|
1224
|
+
"required": [
|
|
1225
|
+
"schemaVersion",
|
|
1226
|
+
"runId",
|
|
1227
|
+
"outcome",
|
|
1228
|
+
"finalText"
|
|
1229
|
+
],
|
|
1230
|
+
"properties": {
|
|
1231
|
+
"schemaVersion": {
|
|
1232
|
+
"const": "1.0"
|
|
1233
|
+
},
|
|
1234
|
+
"runId": {
|
|
1235
|
+
"type": "string",
|
|
1236
|
+
"minLength": 1
|
|
1237
|
+
},
|
|
1238
|
+
"outcome": {
|
|
1239
|
+
"const": "completed"
|
|
1240
|
+
},
|
|
1241
|
+
"finalText": {
|
|
1242
|
+
"type": "string"
|
|
1243
|
+
},
|
|
1244
|
+
"usage": {
|
|
1245
|
+
"type": "object",
|
|
1246
|
+
"additionalProperties": true,
|
|
1247
|
+
"properties": {
|
|
1248
|
+
"inputTokens": {
|
|
1249
|
+
"type": "integer",
|
|
1250
|
+
"minimum": 0
|
|
1251
|
+
},
|
|
1252
|
+
"outputTokens": {
|
|
1253
|
+
"type": "integer",
|
|
1254
|
+
"minimum": 0
|
|
1255
|
+
},
|
|
1256
|
+
"totalTokens": {
|
|
1257
|
+
"type": "integer",
|
|
1258
|
+
"minimum": 0
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
},
|
|
1262
|
+
"telemetry": {
|
|
1263
|
+
"type": "object",
|
|
1264
|
+
"additionalProperties": true,
|
|
1265
|
+
"required": [
|
|
1266
|
+
"providerUsed",
|
|
1267
|
+
"totalMs"
|
|
1268
|
+
],
|
|
1269
|
+
"properties": {
|
|
1270
|
+
"providerUsed": {
|
|
1271
|
+
"type": "string",
|
|
1272
|
+
"minLength": 1
|
|
1273
|
+
},
|
|
1274
|
+
"totalMs": {
|
|
1275
|
+
"type": "number",
|
|
1276
|
+
"minimum": 0
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
},
|
|
1282
|
+
{
|
|
1283
|
+
"type": "object",
|
|
1284
|
+
"additionalProperties": true,
|
|
1285
|
+
"required": [
|
|
1286
|
+
"schemaVersion",
|
|
1287
|
+
"runId",
|
|
1288
|
+
"outcome",
|
|
1289
|
+
"error"
|
|
1290
|
+
],
|
|
1291
|
+
"properties": {
|
|
1292
|
+
"schemaVersion": {
|
|
1293
|
+
"const": "1.0"
|
|
1294
|
+
},
|
|
1295
|
+
"runId": {
|
|
1296
|
+
"type": "string",
|
|
1297
|
+
"minLength": 1
|
|
1298
|
+
},
|
|
1299
|
+
"outcome": {
|
|
1300
|
+
"const": "error"
|
|
1301
|
+
},
|
|
1302
|
+
"error": {
|
|
1303
|
+
"type": "object",
|
|
1304
|
+
"additionalProperties": true,
|
|
1305
|
+
"required": [
|
|
1306
|
+
"schemaVersion",
|
|
1307
|
+
"errorClass",
|
|
1308
|
+
"message"
|
|
1309
|
+
],
|
|
1310
|
+
"properties": {
|
|
1311
|
+
"schemaVersion": {
|
|
1312
|
+
"const": "1.0"
|
|
1313
|
+
},
|
|
1314
|
+
"errorClass": {
|
|
1315
|
+
"enum": [
|
|
1316
|
+
"CapabilityMismatch",
|
|
1317
|
+
"Offline",
|
|
1318
|
+
"AuthError",
|
|
1319
|
+
"RateLimited",
|
|
1320
|
+
"Timeout",
|
|
1321
|
+
"Unavailable",
|
|
1322
|
+
"Internal"
|
|
1323
|
+
]
|
|
1324
|
+
},
|
|
1325
|
+
"message": {
|
|
1326
|
+
"type": "string",
|
|
1327
|
+
"minLength": 1
|
|
1328
|
+
},
|
|
1329
|
+
"providerId": {
|
|
1330
|
+
"type": "string",
|
|
1331
|
+
"minLength": 1
|
|
1332
|
+
},
|
|
1333
|
+
"retryable": {
|
|
1334
|
+
"type": "boolean"
|
|
1335
|
+
},
|
|
1336
|
+
"retryAfterMs": {
|
|
1337
|
+
"type": "integer",
|
|
1338
|
+
"minimum": 0
|
|
1339
|
+
},
|
|
1340
|
+
"details": {
|
|
1341
|
+
"type": "object",
|
|
1342
|
+
"additionalProperties": true
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
},
|
|
1348
|
+
{
|
|
1349
|
+
"type": "object",
|
|
1350
|
+
"additionalProperties": true,
|
|
1351
|
+
"required": [
|
|
1352
|
+
"schemaVersion",
|
|
1353
|
+
"runId",
|
|
1354
|
+
"outcome",
|
|
1355
|
+
"partialText"
|
|
1356
|
+
],
|
|
1357
|
+
"properties": {
|
|
1358
|
+
"schemaVersion": {
|
|
1359
|
+
"const": "1.0"
|
|
1360
|
+
},
|
|
1361
|
+
"runId": {
|
|
1362
|
+
"type": "string",
|
|
1363
|
+
"minLength": 1
|
|
1364
|
+
},
|
|
1365
|
+
"outcome": {
|
|
1366
|
+
"const": "cancelled"
|
|
1367
|
+
},
|
|
1368
|
+
"partialText": {
|
|
1369
|
+
"type": "string"
|
|
1370
|
+
},
|
|
1371
|
+
"reason": {
|
|
1372
|
+
"type": "string"
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
]
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
},
|
|
1380
|
+
{
|
|
1381
|
+
"type": "object",
|
|
1382
|
+
"additionalProperties": true,
|
|
1383
|
+
"required": [
|
|
1384
|
+
"schemaVersion",
|
|
1385
|
+
"runId",
|
|
1386
|
+
"sequence",
|
|
1387
|
+
"timestamp",
|
|
1388
|
+
"type"
|
|
1389
|
+
],
|
|
1390
|
+
"properties": {
|
|
1391
|
+
"schemaVersion": {
|
|
1392
|
+
"description": "Contract schema version used to interpret this event payload.",
|
|
1393
|
+
"const": "1.0"
|
|
1394
|
+
},
|
|
1395
|
+
"runId": {
|
|
1396
|
+
"description": "Opaque run identifier this event belongs to, matching StreamRunHandle.runId.",
|
|
1397
|
+
"type": "string",
|
|
1398
|
+
"minLength": 1
|
|
1399
|
+
},
|
|
1400
|
+
"sequence": {
|
|
1401
|
+
"description": "Zero-based, monotonically increasing event index within this run. The ordering authority; do not rely on delivery/arrival order.",
|
|
1402
|
+
"type": "integer",
|
|
1403
|
+
"minimum": 0
|
|
1404
|
+
},
|
|
1405
|
+
"timestamp": {
|
|
1406
|
+
"description": "Wall-clock event timestamp in Unix epoch milliseconds.",
|
|
1407
|
+
"type": "number",
|
|
1408
|
+
"minimum": 0
|
|
1409
|
+
},
|
|
1410
|
+
"type": {
|
|
1411
|
+
"description": "Forward-compatibility catch-all: any event type not among the known constants above. Exists so a consumer validating against this revision of the schema does not hard-fail when a future additive revision introduces a new known event type; SDKs must ignore or pass through such events for diagnostics rather than treating them as an error.",
|
|
1412
|
+
"type": "string",
|
|
1413
|
+
"not": {
|
|
1414
|
+
"enum": [
|
|
1415
|
+
"content_delta",
|
|
1416
|
+
"content_snapshot",
|
|
1417
|
+
"lifecycle",
|
|
1418
|
+
"diagnostic",
|
|
1419
|
+
"terminal"
|
|
1420
|
+
]
|
|
1421
|
+
}
|
|
1422
|
+
},
|
|
1423
|
+
"payload": {
|
|
1424
|
+
"description": "Optional event-specific payload for the unrecognized type. It must not contain prompt payloads or raw secrets.",
|
|
1425
|
+
"type": "object",
|
|
1426
|
+
"additionalProperties": true
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
]
|
|
1431
|
+
};
|
|
1432
|
+
export const streamTerminalOutcomeSchema = {
|
|
1433
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
1434
|
+
"$id": "https://schemas.inderun.dev/1.0/stream-terminal-outcome.schema.json",
|
|
1435
|
+
"title": "StreamTerminalOutcome",
|
|
1436
|
+
"description": "How a Mode 2 stream run ended. Completion, error, and cancellation are mutually exclusive terminal outcomes, enforced here as a closed set of three oneOf branches discriminated by 'outcome' (unlike StreamEvent.type, this set is not open-ended: the three-way terminal outcome is a fixed architectural guarantee, not something new outcome kinds get added to). Exactly one StreamTerminalOutcome is produced per run, and no further StreamEvent is delivered after it (see docs/architecture/architecture.md, 'Cancellation And Fallback'). This shape is also embedded by value as the payload of the terminal StreamEvent (stream-event.schema.json) so it can additionally be exposed standalone, e.g. as a completion future/promise a stream handle resolves independently of consuming the full event sequence; the two copies must stay structurally identical. Note on additionalProperties: per this repo's forward-compatible convention every branch permits unknown extra fields, so mutual exclusivity is enforced via the required 'outcome' discriminator plus each branch's own required peer field (finalText/error/partialText) being present, not by forbidding a payload from also carrying an unrelated stray field from another branch's vocabulary.",
|
|
1437
|
+
"oneOf": [
|
|
1438
|
+
{
|
|
1439
|
+
"type": "object",
|
|
1440
|
+
"additionalProperties": true,
|
|
1441
|
+
"required": [
|
|
1442
|
+
"schemaVersion",
|
|
1443
|
+
"runId",
|
|
1444
|
+
"outcome",
|
|
1445
|
+
"finalText"
|
|
1446
|
+
],
|
|
1447
|
+
"properties": {
|
|
1448
|
+
"schemaVersion": {
|
|
1449
|
+
"description": "Contract schema version used to interpret this outcome payload.",
|
|
1450
|
+
"const": "1.0"
|
|
1451
|
+
},
|
|
1452
|
+
"runId": {
|
|
1453
|
+
"description": "The stream run this outcome terminates, matching StreamRunHandle.runId and every StreamEvent.runId for the run.",
|
|
1454
|
+
"type": "string",
|
|
1455
|
+
"minLength": 1
|
|
1456
|
+
},
|
|
1457
|
+
"outcome": {
|
|
1458
|
+
"description": "The stream completed normally: every provider-generated event was delivered before this outcome was produced.",
|
|
1459
|
+
"const": "completed"
|
|
1460
|
+
},
|
|
1461
|
+
"finalText": {
|
|
1462
|
+
"description": "The full, cumulative text produced by the run. Equivalent in role to TaskResult.output.text for Mode 1.",
|
|
1463
|
+
"type": "string"
|
|
1464
|
+
},
|
|
1465
|
+
"usage": {
|
|
1466
|
+
"description": "Optional metadata regarding the quantity of tokens processed by the provider. Same shape as TaskResult.usage.",
|
|
1467
|
+
"type": "object",
|
|
1468
|
+
"additionalProperties": true,
|
|
1469
|
+
"properties": {
|
|
1470
|
+
"inputTokens": {
|
|
1471
|
+
"description": "Number of input tokens consumed, as reported by the provider.",
|
|
1472
|
+
"type": "integer",
|
|
1473
|
+
"minimum": 0
|
|
1474
|
+
},
|
|
1475
|
+
"outputTokens": {
|
|
1476
|
+
"description": "Number of output tokens generated, as reported by the provider.",
|
|
1477
|
+
"type": "integer",
|
|
1478
|
+
"minimum": 0
|
|
1479
|
+
},
|
|
1480
|
+
"totalTokens": {
|
|
1481
|
+
"description": "Aggregated token count for this request, as reported by the provider.",
|
|
1482
|
+
"type": "integer",
|
|
1483
|
+
"minimum": 0
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
},
|
|
1487
|
+
"telemetry": {
|
|
1488
|
+
"description": "Required metadata providing an overview of the execution result and performance metrics. Same shape as TaskResult.telemetry.",
|
|
1489
|
+
"type": "object",
|
|
1490
|
+
"additionalProperties": true,
|
|
1491
|
+
"required": [
|
|
1492
|
+
"providerUsed",
|
|
1493
|
+
"totalMs"
|
|
1494
|
+
],
|
|
1495
|
+
"properties": {
|
|
1496
|
+
"providerUsed": {
|
|
1497
|
+
"description": "The identifier for the specific provider that handled the request (e.g., 'openai_compatible_cloud').",
|
|
1498
|
+
"type": "string",
|
|
1499
|
+
"minLength": 1
|
|
1500
|
+
},
|
|
1501
|
+
"totalMs": {
|
|
1502
|
+
"description": "Measured execution duration in milliseconds, including route selection and result processing.",
|
|
1503
|
+
"type": "number",
|
|
1504
|
+
"minimum": 0
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
},
|
|
1510
|
+
{
|
|
1511
|
+
"type": "object",
|
|
1512
|
+
"additionalProperties": true,
|
|
1513
|
+
"required": [
|
|
1514
|
+
"schemaVersion",
|
|
1515
|
+
"runId",
|
|
1516
|
+
"outcome",
|
|
1517
|
+
"error"
|
|
1518
|
+
],
|
|
1519
|
+
"properties": {
|
|
1520
|
+
"schemaVersion": {
|
|
1521
|
+
"description": "Contract schema version used to interpret this outcome payload.",
|
|
1522
|
+
"const": "1.0"
|
|
1523
|
+
},
|
|
1524
|
+
"runId": {
|
|
1525
|
+
"description": "The stream run this outcome terminates, matching StreamRunHandle.runId and every StreamEvent.runId for the run.",
|
|
1526
|
+
"type": "string",
|
|
1527
|
+
"minLength": 1
|
|
1528
|
+
},
|
|
1529
|
+
"outcome": {
|
|
1530
|
+
"description": "The stream ended in failure: validation, routing (no eligible provider), or every attempted provider failing.",
|
|
1531
|
+
"const": "error"
|
|
1532
|
+
},
|
|
1533
|
+
"error": {
|
|
1534
|
+
"description": "The normalized error for this failure. Structurally identical to IndeRunError (contracts/schemas/inderun-error.schema.json), duplicated by value here rather than by $ref, matching this repo's schema convention of no cross-file references. Keep both shapes in sync; a cross-check test asserts a shared fixture validates against both schemas.",
|
|
1535
|
+
"type": "object",
|
|
1536
|
+
"additionalProperties": true,
|
|
1537
|
+
"required": [
|
|
1538
|
+
"schemaVersion",
|
|
1539
|
+
"errorClass",
|
|
1540
|
+
"message"
|
|
1541
|
+
],
|
|
1542
|
+
"properties": {
|
|
1543
|
+
"schemaVersion": {
|
|
1544
|
+
"description": "Contract schema version used to interpret the error payload.",
|
|
1545
|
+
"const": "1.0"
|
|
1546
|
+
},
|
|
1547
|
+
"errorClass": {
|
|
1548
|
+
"description": "Normalized error taxonomy, identical to IndeRunError.errorClass: CapabilityMismatch (request needs something no eligible provider supports), Offline/Unavailable (provider unreachable or not ready), AuthError (credential/auth failure), RateLimited (provider throttled the request), Timeout (provider exceeded its execution budget), Internal (unexpected engine-side failure).",
|
|
1549
|
+
"enum": [
|
|
1550
|
+
"CapabilityMismatch",
|
|
1551
|
+
"Offline",
|
|
1552
|
+
"AuthError",
|
|
1553
|
+
"RateLimited",
|
|
1554
|
+
"Timeout",
|
|
1555
|
+
"Unavailable",
|
|
1556
|
+
"Internal"
|
|
1557
|
+
]
|
|
1558
|
+
},
|
|
1559
|
+
"message": {
|
|
1560
|
+
"description": "Human-readable error message suitable for logs and developer diagnostics.",
|
|
1561
|
+
"type": "string",
|
|
1562
|
+
"minLength": 1
|
|
1563
|
+
},
|
|
1564
|
+
"providerId": {
|
|
1565
|
+
"description": "Identifier of the provider associated with the failure, if execution reached a provider.",
|
|
1566
|
+
"type": "string",
|
|
1567
|
+
"minLength": 1
|
|
1568
|
+
},
|
|
1569
|
+
"retryable": {
|
|
1570
|
+
"description": "Whether retrying the same request may succeed.",
|
|
1571
|
+
"type": "boolean"
|
|
1572
|
+
},
|
|
1573
|
+
"retryAfterMs": {
|
|
1574
|
+
"description": "Optional suggested delay before retrying, in milliseconds.",
|
|
1575
|
+
"type": "integer",
|
|
1576
|
+
"minimum": 0
|
|
1577
|
+
},
|
|
1578
|
+
"details": {
|
|
1579
|
+
"description": "Optional structured diagnostic details. It must not contain raw secrets.",
|
|
1580
|
+
"type": "object",
|
|
1581
|
+
"additionalProperties": true
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
},
|
|
1587
|
+
{
|
|
1588
|
+
"type": "object",
|
|
1589
|
+
"additionalProperties": true,
|
|
1590
|
+
"required": [
|
|
1591
|
+
"schemaVersion",
|
|
1592
|
+
"runId",
|
|
1593
|
+
"outcome",
|
|
1594
|
+
"partialText"
|
|
1595
|
+
],
|
|
1596
|
+
"properties": {
|
|
1597
|
+
"schemaVersion": {
|
|
1598
|
+
"description": "Contract schema version used to interpret this outcome payload.",
|
|
1599
|
+
"const": "1.0"
|
|
1600
|
+
},
|
|
1601
|
+
"runId": {
|
|
1602
|
+
"description": "The stream run this outcome terminates, matching StreamRunHandle.runId and every StreamEvent.runId for the run.",
|
|
1603
|
+
"type": "string",
|
|
1604
|
+
"minLength": 1
|
|
1605
|
+
},
|
|
1606
|
+
"outcome": {
|
|
1607
|
+
"description": "The stream was cancelled. No further StreamEvent is delivered after this outcome, and no further fallback attempt is made, per the engine's cancellation guarantee.",
|
|
1608
|
+
"const": "cancelled"
|
|
1609
|
+
},
|
|
1610
|
+
"partialText": {
|
|
1611
|
+
"description": "Whatever cumulative text had already been delivered via content_delta/content_snapshot StreamEvents before the cancellation point. May be empty if cancellation occurred before any content was produced.",
|
|
1612
|
+
"type": "string"
|
|
1613
|
+
},
|
|
1614
|
+
"reason": {
|
|
1615
|
+
"description": "Optional human-readable reason the run was cancelled (e.g. caller-initiated abort). Not a machine-taxonomy field; use errorClass on the 'error' outcome branch for failure classification.",
|
|
1616
|
+
"type": "string"
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
]
|
|
1621
|
+
};
|