@desplega.ai/agent-swarm 1.71.1 → 1.72.0

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.
Files changed (64) hide show
  1. package/README.md +3 -2
  2. package/openapi.json +994 -62
  3. package/package.json +2 -1
  4. package/src/be/budget-admission.ts +121 -0
  5. package/src/be/budget-refusal-notify.ts +145 -0
  6. package/src/be/db.ts +488 -5
  7. package/src/be/migrations/044_provider_meta.sql +2 -0
  8. package/src/be/migrations/046_budgets_and_pricing.sql +87 -0
  9. package/src/be/migrations/047_session_costs_cost_source.sql +16 -0
  10. package/src/cli.tsx +22 -1
  11. package/src/commands/claude-managed-setup.ts +687 -0
  12. package/src/commands/codex-login.ts +1 -1
  13. package/src/commands/runner.ts +175 -28
  14. package/src/commands/templates.ts +10 -6
  15. package/src/http/budgets.ts +219 -0
  16. package/src/http/index.ts +6 -0
  17. package/src/http/integrations.ts +134 -0
  18. package/src/http/poll.ts +161 -3
  19. package/src/http/pricing.ts +245 -0
  20. package/src/http/session-data.ts +54 -6
  21. package/src/http/tasks.ts +23 -2
  22. package/src/jira/app.ts +9 -3
  23. package/src/linear/app.ts +8 -2
  24. package/src/prompts/base-prompt.ts +103 -73
  25. package/src/prompts/session-templates.ts +43 -0
  26. package/src/providers/claude-adapter.ts +3 -1
  27. package/src/providers/claude-managed-adapter.ts +871 -0
  28. package/src/providers/claude-managed-models.ts +117 -0
  29. package/src/providers/claude-managed-swarm-events.ts +77 -0
  30. package/src/providers/codex-adapter.ts +3 -1
  31. package/src/providers/codex-skill-resolver.ts +10 -0
  32. package/src/providers/codex-swarm-events.ts +20 -161
  33. package/src/providers/devin-adapter.ts +894 -0
  34. package/src/providers/devin-api.ts +207 -0
  35. package/src/providers/devin-playbooks.ts +91 -0
  36. package/src/providers/devin-skill-resolver.ts +113 -0
  37. package/src/providers/index.ts +10 -1
  38. package/src/providers/pi-mono-adapter.ts +3 -1
  39. package/src/providers/swarm-events-shared.ts +262 -0
  40. package/src/providers/types.ts +26 -1
  41. package/src/tests/base-prompt.test.ts +199 -0
  42. package/src/tests/budget-admission.test.ts +339 -0
  43. package/src/tests/budget-claim-gate.test.ts +288 -0
  44. package/src/tests/budget-refusal-notification.test.ts +324 -0
  45. package/src/tests/budgets-routes.test.ts +331 -0
  46. package/src/tests/claude-managed-adapter.test.ts +1301 -0
  47. package/src/tests/claude-managed-setup.test.ts +325 -0
  48. package/src/tests/devin-adapter.test.ts +677 -0
  49. package/src/tests/devin-api.test.ts +339 -0
  50. package/src/tests/integrations-http.test.ts +211 -0
  51. package/src/tests/migration-046-budgets.test.ts +327 -0
  52. package/src/tests/pricing-routes.test.ts +315 -0
  53. package/src/tests/prompt-template-remaining.test.ts +4 -0
  54. package/src/tests/prompt-template-session.test.ts +2 -2
  55. package/src/tests/provider-adapter.test.ts +1 -1
  56. package/src/tests/runner-budget-refused.test.ts +271 -0
  57. package/src/tests/session-costs-codex-recompute.test.ts +386 -0
  58. package/src/tools/poll-task.ts +13 -2
  59. package/src/tools/task-action.ts +92 -2
  60. package/src/tools/templates.ts +29 -0
  61. package/src/types.ts +116 -0
  62. package/src/utils/budget-backoff.ts +34 -0
  63. package/src/utils/credentials.ts +4 -0
  64. package/src/utils/provider-metadata.ts +9 -0
package/openapi.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "openapi": "3.1.0",
3
3
  "info": {
4
4
  "title": "Agent Swarm API",
5
- "version": "1.71.1",
5
+ "version": "1.72.0",
6
6
  "description": "Multi-agent orchestration API for Claude Code, Codex, and Gemini CLI. Enables task distribution, agent communication, and service discovery.\n\nMCP tools are documented separately in [MCP.md](./MCP.md)."
7
7
  },
8
8
  "servers": [
@@ -947,6 +947,401 @@
947
947
  }
948
948
  }
949
949
  },
950
+ "/api/budgets": {
951
+ "get": {
952
+ "summary": "List all configured budget rows",
953
+ "tags": [
954
+ "Budgets"
955
+ ],
956
+ "security": [
957
+ {
958
+ "bearerAuth": []
959
+ }
960
+ ],
961
+ "responses": {
962
+ "200": {
963
+ "description": "Budget list",
964
+ "content": {
965
+ "application/json": {
966
+ "schema": {
967
+ "type": "object",
968
+ "properties": {
969
+ "budgets": {
970
+ "type": "array",
971
+ "items": {
972
+ "type": "object",
973
+ "properties": {
974
+ "scope": {
975
+ "type": "string",
976
+ "enum": [
977
+ "global",
978
+ "agent"
979
+ ]
980
+ },
981
+ "scopeId": {
982
+ "type": "string"
983
+ },
984
+ "dailyBudgetUsd": {
985
+ "type": "number",
986
+ "minimum": 0
987
+ },
988
+ "createdAt": {
989
+ "type": "number"
990
+ },
991
+ "lastUpdatedAt": {
992
+ "type": "number"
993
+ }
994
+ },
995
+ "required": [
996
+ "scope",
997
+ "scopeId",
998
+ "dailyBudgetUsd",
999
+ "createdAt",
1000
+ "lastUpdatedAt"
1001
+ ]
1002
+ }
1003
+ }
1004
+ },
1005
+ "required": [
1006
+ "budgets"
1007
+ ]
1008
+ }
1009
+ }
1010
+ }
1011
+ }
1012
+ }
1013
+ }
1014
+ },
1015
+ "/api/budgets/refusals": {
1016
+ "get": {
1017
+ "summary": "List recent budget refusal notifications",
1018
+ "tags": [
1019
+ "Budgets"
1020
+ ],
1021
+ "security": [
1022
+ {
1023
+ "bearerAuth": []
1024
+ }
1025
+ ],
1026
+ "parameters": [
1027
+ {
1028
+ "schema": {
1029
+ "type": "integer",
1030
+ "exclusiveMinimum": 0,
1031
+ "maximum": 500
1032
+ },
1033
+ "required": false,
1034
+ "name": "limit",
1035
+ "in": "query"
1036
+ }
1037
+ ],
1038
+ "responses": {
1039
+ "200": {
1040
+ "description": "Recent budget refusals (newest first)",
1041
+ "content": {
1042
+ "application/json": {
1043
+ "schema": {
1044
+ "type": "object",
1045
+ "properties": {
1046
+ "refusals": {
1047
+ "type": "array",
1048
+ "items": {
1049
+ "type": "object",
1050
+ "properties": {
1051
+ "taskId": {
1052
+ "type": "string"
1053
+ },
1054
+ "date": {
1055
+ "type": "string"
1056
+ },
1057
+ "agentId": {
1058
+ "type": "string"
1059
+ },
1060
+ "cause": {
1061
+ "type": "string",
1062
+ "enum": [
1063
+ "agent",
1064
+ "global"
1065
+ ]
1066
+ },
1067
+ "agentSpendUsd": {
1068
+ "type": [
1069
+ "number",
1070
+ "null"
1071
+ ]
1072
+ },
1073
+ "agentBudgetUsd": {
1074
+ "type": [
1075
+ "number",
1076
+ "null"
1077
+ ]
1078
+ },
1079
+ "globalSpendUsd": {
1080
+ "type": [
1081
+ "number",
1082
+ "null"
1083
+ ]
1084
+ },
1085
+ "globalBudgetUsd": {
1086
+ "type": [
1087
+ "number",
1088
+ "null"
1089
+ ]
1090
+ },
1091
+ "followUpTaskId": {
1092
+ "type": [
1093
+ "string",
1094
+ "null"
1095
+ ]
1096
+ },
1097
+ "createdAt": {
1098
+ "type": "number"
1099
+ }
1100
+ },
1101
+ "required": [
1102
+ "taskId",
1103
+ "date",
1104
+ "agentId",
1105
+ "cause",
1106
+ "createdAt"
1107
+ ]
1108
+ }
1109
+ }
1110
+ },
1111
+ "required": [
1112
+ "refusals"
1113
+ ]
1114
+ }
1115
+ }
1116
+ }
1117
+ }
1118
+ }
1119
+ }
1120
+ },
1121
+ "/api/budgets/{scope}/{scopeId}": {
1122
+ "get": {
1123
+ "summary": "Get a single budget row",
1124
+ "tags": [
1125
+ "Budgets"
1126
+ ],
1127
+ "security": [
1128
+ {
1129
+ "bearerAuth": []
1130
+ }
1131
+ ],
1132
+ "parameters": [
1133
+ {
1134
+ "schema": {
1135
+ "type": "string",
1136
+ "enum": [
1137
+ "global",
1138
+ "agent"
1139
+ ]
1140
+ },
1141
+ "required": true,
1142
+ "name": "scope",
1143
+ "in": "path"
1144
+ },
1145
+ {
1146
+ "schema": {
1147
+ "type": "string",
1148
+ "maxLength": 255,
1149
+ "description": "Scope identifier — empty string for global, agent UUID otherwise"
1150
+ },
1151
+ "required": true,
1152
+ "description": "Scope identifier — empty string for global, agent UUID otherwise",
1153
+ "name": "scopeId",
1154
+ "in": "path"
1155
+ }
1156
+ ],
1157
+ "responses": {
1158
+ "200": {
1159
+ "description": "Budget row",
1160
+ "content": {
1161
+ "application/json": {
1162
+ "schema": {
1163
+ "type": "object",
1164
+ "properties": {
1165
+ "scope": {
1166
+ "type": "string",
1167
+ "enum": [
1168
+ "global",
1169
+ "agent"
1170
+ ]
1171
+ },
1172
+ "scopeId": {
1173
+ "type": "string"
1174
+ },
1175
+ "dailyBudgetUsd": {
1176
+ "type": "number",
1177
+ "minimum": 0
1178
+ },
1179
+ "createdAt": {
1180
+ "type": "number"
1181
+ },
1182
+ "lastUpdatedAt": {
1183
+ "type": "number"
1184
+ }
1185
+ },
1186
+ "required": [
1187
+ "scope",
1188
+ "scopeId",
1189
+ "dailyBudgetUsd",
1190
+ "createdAt",
1191
+ "lastUpdatedAt"
1192
+ ]
1193
+ }
1194
+ }
1195
+ }
1196
+ },
1197
+ "404": {
1198
+ "description": "Budget not configured"
1199
+ }
1200
+ }
1201
+ },
1202
+ "put": {
1203
+ "summary": "Create or update a budget row",
1204
+ "tags": [
1205
+ "Budgets"
1206
+ ],
1207
+ "security": [
1208
+ {
1209
+ "bearerAuth": []
1210
+ }
1211
+ ],
1212
+ "parameters": [
1213
+ {
1214
+ "schema": {
1215
+ "type": "string",
1216
+ "enum": [
1217
+ "global",
1218
+ "agent"
1219
+ ]
1220
+ },
1221
+ "required": true,
1222
+ "name": "scope",
1223
+ "in": "path"
1224
+ },
1225
+ {
1226
+ "schema": {
1227
+ "type": "string",
1228
+ "maxLength": 255,
1229
+ "description": "Scope identifier — empty string for global, agent UUID otherwise"
1230
+ },
1231
+ "required": true,
1232
+ "description": "Scope identifier — empty string for global, agent UUID otherwise",
1233
+ "name": "scopeId",
1234
+ "in": "path"
1235
+ }
1236
+ ],
1237
+ "requestBody": {
1238
+ "content": {
1239
+ "application/json": {
1240
+ "schema": {
1241
+ "type": "object",
1242
+ "properties": {
1243
+ "dailyBudgetUsd": {
1244
+ "type": "number",
1245
+ "minimum": 0
1246
+ }
1247
+ },
1248
+ "required": [
1249
+ "dailyBudgetUsd"
1250
+ ]
1251
+ }
1252
+ }
1253
+ }
1254
+ },
1255
+ "responses": {
1256
+ "200": {
1257
+ "description": "Budget upserted",
1258
+ "content": {
1259
+ "application/json": {
1260
+ "schema": {
1261
+ "type": "object",
1262
+ "properties": {
1263
+ "scope": {
1264
+ "type": "string",
1265
+ "enum": [
1266
+ "global",
1267
+ "agent"
1268
+ ]
1269
+ },
1270
+ "scopeId": {
1271
+ "type": "string"
1272
+ },
1273
+ "dailyBudgetUsd": {
1274
+ "type": "number",
1275
+ "minimum": 0
1276
+ },
1277
+ "createdAt": {
1278
+ "type": "number"
1279
+ },
1280
+ "lastUpdatedAt": {
1281
+ "type": "number"
1282
+ }
1283
+ },
1284
+ "required": [
1285
+ "scope",
1286
+ "scopeId",
1287
+ "dailyBudgetUsd",
1288
+ "createdAt",
1289
+ "lastUpdatedAt"
1290
+ ]
1291
+ }
1292
+ }
1293
+ }
1294
+ },
1295
+ "400": {
1296
+ "description": "Validation error"
1297
+ }
1298
+ }
1299
+ },
1300
+ "delete": {
1301
+ "summary": "Delete a budget row",
1302
+ "tags": [
1303
+ "Budgets"
1304
+ ],
1305
+ "security": [
1306
+ {
1307
+ "bearerAuth": []
1308
+ }
1309
+ ],
1310
+ "parameters": [
1311
+ {
1312
+ "schema": {
1313
+ "type": "string",
1314
+ "enum": [
1315
+ "global",
1316
+ "agent"
1317
+ ]
1318
+ },
1319
+ "required": true,
1320
+ "name": "scope",
1321
+ "in": "path"
1322
+ },
1323
+ {
1324
+ "schema": {
1325
+ "type": "string",
1326
+ "maxLength": 255,
1327
+ "description": "Scope identifier — empty string for global, agent UUID otherwise"
1328
+ },
1329
+ "required": true,
1330
+ "description": "Scope identifier — empty string for global, agent UUID otherwise",
1331
+ "name": "scopeId",
1332
+ "in": "path"
1333
+ }
1334
+ ],
1335
+ "responses": {
1336
+ "204": {
1337
+ "description": "Budget deleted"
1338
+ },
1339
+ "404": {
1340
+ "description": "Budget not configured"
1341
+ }
1342
+ }
1343
+ }
1344
+ },
950
1345
  "/api/config/resolved": {
951
1346
  "get": {
952
1347
  "summary": "Get resolved config (merged global + agent + repo scopes)",
@@ -2326,6 +2721,34 @@
2326
2721
  }
2327
2722
  }
2328
2723
  },
2724
+ "/api/integrations/claude-managed/test": {
2725
+ "post": {
2726
+ "summary": "Test the claude-managed integration: resolves ANTHROPIC_API_KEY + MANAGED_AGENT_ID from swarm_config and calls beta.agents.retrieve.",
2727
+ "tags": [
2728
+ "Integrations"
2729
+ ],
2730
+ "security": [
2731
+ {
2732
+ "bearerAuth": []
2733
+ }
2734
+ ],
2735
+ "requestBody": {
2736
+ "content": {
2737
+ "application/json": {
2738
+ "schema": {
2739
+ "type": "object",
2740
+ "properties": {}
2741
+ }
2742
+ }
2743
+ }
2744
+ },
2745
+ "responses": {
2746
+ "200": {
2747
+ "description": "Connection result — `{ ok: true, agentName, model }` on success or `{ ok: false, error }` on any failure (missing config, Anthropic API error). Always 200 OK."
2748
+ }
2749
+ }
2750
+ }
2751
+ },
2329
2752
  "/api/memory/index": {
2330
2753
  "post": {
2331
2754
  "summary": "Ingest content into memory system (async embedding)",
@@ -2894,101 +3317,544 @@
2894
3317
  "changedBy": {
2895
3318
  "type": "string"
2896
3319
  },
2897
- "changeReason": {
2898
- "type": "string"
3320
+ "changeReason": {
3321
+ "type": "string"
3322
+ }
3323
+ },
3324
+ "required": [
3325
+ "eventType",
3326
+ "body"
3327
+ ]
3328
+ }
3329
+ }
3330
+ }
3331
+ },
3332
+ "responses": {
3333
+ "200": {
3334
+ "description": "Upserted template"
3335
+ },
3336
+ "400": {
3337
+ "description": "Validation error"
3338
+ }
3339
+ }
3340
+ }
3341
+ },
3342
+ "/api/poll": {
3343
+ "get": {
3344
+ "summary": "Poll for triggers (tasks, mentions)",
3345
+ "tags": [
3346
+ "Poll"
3347
+ ],
3348
+ "security": [
3349
+ {
3350
+ "bearerAuth": []
3351
+ }
3352
+ ],
3353
+ "responses": {
3354
+ "200": {
3355
+ "description": "Trigger data or null"
3356
+ },
3357
+ "400": {
3358
+ "description": "Missing X-Agent-ID"
3359
+ },
3360
+ "404": {
3361
+ "description": "Agent not found"
3362
+ }
3363
+ }
3364
+ }
3365
+ },
3366
+ "/api/channel-activity/commit-cursors": {
3367
+ "post": {
3368
+ "summary": "Commit channel activity cursors after successful processing",
3369
+ "tags": [
3370
+ "Poll"
3371
+ ],
3372
+ "security": [
3373
+ {
3374
+ "bearerAuth": []
3375
+ }
3376
+ ],
3377
+ "requestBody": {
3378
+ "content": {
3379
+ "application/json": {
3380
+ "schema": {
3381
+ "type": "object",
3382
+ "properties": {
3383
+ "cursorUpdates": {
3384
+ "type": "array",
3385
+ "items": {
3386
+ "type": "object",
3387
+ "properties": {
3388
+ "channelId": {
3389
+ "type": "string"
3390
+ },
3391
+ "ts": {
3392
+ "type": "string"
3393
+ }
3394
+ },
3395
+ "required": [
3396
+ "channelId",
3397
+ "ts"
3398
+ ]
3399
+ }
3400
+ }
3401
+ },
3402
+ "required": [
3403
+ "cursorUpdates"
3404
+ ]
3405
+ }
3406
+ }
3407
+ }
3408
+ },
3409
+ "responses": {
3410
+ "200": {
3411
+ "description": "Cursors committed"
3412
+ },
3413
+ "400": {
3414
+ "description": "Invalid request"
3415
+ }
3416
+ }
3417
+ }
3418
+ },
3419
+ "/api/pricing": {
3420
+ "get": {
3421
+ "summary": "List every pricing row across all providers",
3422
+ "tags": [
3423
+ "Pricing"
3424
+ ],
3425
+ "security": [
3426
+ {
3427
+ "bearerAuth": []
3428
+ }
3429
+ ],
3430
+ "responses": {
3431
+ "200": {
3432
+ "description": "Pricing rows",
3433
+ "content": {
3434
+ "application/json": {
3435
+ "schema": {
3436
+ "type": "object",
3437
+ "properties": {
3438
+ "rows": {
3439
+ "type": "array",
3440
+ "items": {
3441
+ "type": "object",
3442
+ "properties": {
3443
+ "provider": {
3444
+ "type": "string",
3445
+ "enum": [
3446
+ "claude",
3447
+ "codex",
3448
+ "pi"
3449
+ ]
3450
+ },
3451
+ "model": {
3452
+ "type": "string"
3453
+ },
3454
+ "tokenClass": {
3455
+ "type": "string",
3456
+ "enum": [
3457
+ "input",
3458
+ "cached_input",
3459
+ "output"
3460
+ ]
3461
+ },
3462
+ "effectiveFrom": {
3463
+ "type": "number",
3464
+ "minimum": 0
3465
+ },
3466
+ "pricePerMillionUsd": {
3467
+ "type": "number",
3468
+ "minimum": 0
3469
+ },
3470
+ "createdAt": {
3471
+ "type": "number"
3472
+ },
3473
+ "lastUpdatedAt": {
3474
+ "type": "number"
3475
+ }
3476
+ },
3477
+ "required": [
3478
+ "provider",
3479
+ "model",
3480
+ "tokenClass",
3481
+ "effectiveFrom",
3482
+ "pricePerMillionUsd",
3483
+ "createdAt",
3484
+ "lastUpdatedAt"
3485
+ ]
3486
+ }
3487
+ }
3488
+ },
3489
+ "required": [
3490
+ "rows"
3491
+ ]
3492
+ }
3493
+ }
3494
+ }
3495
+ }
3496
+ }
3497
+ }
3498
+ },
3499
+ "/api/pricing/{provider}/{model}/{tokenClass}": {
3500
+ "get": {
3501
+ "summary": "List pricing history for a (provider, model, tokenClass) triple",
3502
+ "tags": [
3503
+ "Pricing"
3504
+ ],
3505
+ "security": [
3506
+ {
3507
+ "bearerAuth": []
3508
+ }
3509
+ ],
3510
+ "parameters": [
3511
+ {
3512
+ "schema": {
3513
+ "type": "string",
3514
+ "enum": [
3515
+ "claude",
3516
+ "codex",
3517
+ "pi"
3518
+ ]
3519
+ },
3520
+ "required": true,
3521
+ "name": "provider",
3522
+ "in": "path"
3523
+ },
3524
+ {
3525
+ "schema": {
3526
+ "type": "string",
3527
+ "minLength": 1
3528
+ },
3529
+ "required": true,
3530
+ "name": "model",
3531
+ "in": "path"
3532
+ },
3533
+ {
3534
+ "schema": {
3535
+ "type": "string",
3536
+ "enum": [
3537
+ "input",
3538
+ "cached_input",
3539
+ "output"
3540
+ ]
3541
+ },
3542
+ "required": true,
3543
+ "name": "tokenClass",
3544
+ "in": "path"
3545
+ }
3546
+ ],
3547
+ "responses": {
3548
+ "200": {
3549
+ "description": "Pricing rows (latest first)"
3550
+ }
3551
+ }
3552
+ },
3553
+ "post": {
3554
+ "summary": "Append a new pricing row",
3555
+ "tags": [
3556
+ "Pricing"
3557
+ ],
3558
+ "security": [
3559
+ {
3560
+ "bearerAuth": []
3561
+ }
3562
+ ],
3563
+ "parameters": [
3564
+ {
3565
+ "schema": {
3566
+ "type": "string",
3567
+ "enum": [
3568
+ "claude",
3569
+ "codex",
3570
+ "pi"
3571
+ ]
3572
+ },
3573
+ "required": true,
3574
+ "name": "provider",
3575
+ "in": "path"
3576
+ },
3577
+ {
3578
+ "schema": {
3579
+ "type": "string",
3580
+ "minLength": 1
3581
+ },
3582
+ "required": true,
3583
+ "name": "model",
3584
+ "in": "path"
3585
+ },
3586
+ {
3587
+ "schema": {
3588
+ "type": "string",
3589
+ "enum": [
3590
+ "input",
3591
+ "cached_input",
3592
+ "output"
3593
+ ]
3594
+ },
3595
+ "required": true,
3596
+ "name": "tokenClass",
3597
+ "in": "path"
3598
+ }
3599
+ ],
3600
+ "requestBody": {
3601
+ "content": {
3602
+ "application/json": {
3603
+ "schema": {
3604
+ "type": "object",
3605
+ "properties": {
3606
+ "pricePerMillionUsd": {
3607
+ "type": "number",
3608
+ "minimum": 0
3609
+ },
3610
+ "effectiveFrom": {
3611
+ "type": "number",
3612
+ "minimum": 0
2899
3613
  }
2900
3614
  },
2901
3615
  "required": [
2902
- "eventType",
2903
- "body"
3616
+ "pricePerMillionUsd"
2904
3617
  ]
2905
3618
  }
2906
3619
  }
2907
3620
  }
2908
3621
  },
2909
3622
  "responses": {
2910
- "200": {
2911
- "description": "Upserted template"
3623
+ "201": {
3624
+ "description": "Pricing row inserted",
3625
+ "content": {
3626
+ "application/json": {
3627
+ "schema": {
3628
+ "type": "object",
3629
+ "properties": {
3630
+ "provider": {
3631
+ "type": "string",
3632
+ "enum": [
3633
+ "claude",
3634
+ "codex",
3635
+ "pi"
3636
+ ]
3637
+ },
3638
+ "model": {
3639
+ "type": "string"
3640
+ },
3641
+ "tokenClass": {
3642
+ "type": "string",
3643
+ "enum": [
3644
+ "input",
3645
+ "cached_input",
3646
+ "output"
3647
+ ]
3648
+ },
3649
+ "effectiveFrom": {
3650
+ "type": "number",
3651
+ "minimum": 0
3652
+ },
3653
+ "pricePerMillionUsd": {
3654
+ "type": "number",
3655
+ "minimum": 0
3656
+ },
3657
+ "createdAt": {
3658
+ "type": "number"
3659
+ },
3660
+ "lastUpdatedAt": {
3661
+ "type": "number"
3662
+ }
3663
+ },
3664
+ "required": [
3665
+ "provider",
3666
+ "model",
3667
+ "tokenClass",
3668
+ "effectiveFrom",
3669
+ "pricePerMillionUsd",
3670
+ "createdAt",
3671
+ "lastUpdatedAt"
3672
+ ]
3673
+ }
3674
+ }
3675
+ }
2912
3676
  },
2913
3677
  "400": {
2914
3678
  "description": "Validation error"
3679
+ },
3680
+ "409": {
3681
+ "description": "Duplicate (provider, model, tokenClass, effectiveFrom)"
2915
3682
  }
2916
3683
  }
2917
3684
  }
2918
3685
  },
2919
- "/api/poll": {
3686
+ "/api/pricing/{provider}/{model}/{tokenClass}/active": {
2920
3687
  "get": {
2921
- "summary": "Poll for triggers (tasks, mentions)",
3688
+ "summary": "Get the currently active pricing row",
2922
3689
  "tags": [
2923
- "Poll"
3690
+ "Pricing"
2924
3691
  ],
2925
3692
  "security": [
2926
3693
  {
2927
3694
  "bearerAuth": []
2928
3695
  }
2929
3696
  ],
3697
+ "parameters": [
3698
+ {
3699
+ "schema": {
3700
+ "type": "string",
3701
+ "enum": [
3702
+ "claude",
3703
+ "codex",
3704
+ "pi"
3705
+ ]
3706
+ },
3707
+ "required": true,
3708
+ "name": "provider",
3709
+ "in": "path"
3710
+ },
3711
+ {
3712
+ "schema": {
3713
+ "type": "string",
3714
+ "minLength": 1
3715
+ },
3716
+ "required": true,
3717
+ "name": "model",
3718
+ "in": "path"
3719
+ },
3720
+ {
3721
+ "schema": {
3722
+ "type": "string",
3723
+ "enum": [
3724
+ "input",
3725
+ "cached_input",
3726
+ "output"
3727
+ ]
3728
+ },
3729
+ "required": true,
3730
+ "name": "tokenClass",
3731
+ "in": "path"
3732
+ }
3733
+ ],
2930
3734
  "responses": {
2931
3735
  "200": {
2932
- "description": "Trigger data or null"
2933
- },
2934
- "400": {
2935
- "description": "Missing X-Agent-ID"
3736
+ "description": "Active pricing row",
3737
+ "content": {
3738
+ "application/json": {
3739
+ "schema": {
3740
+ "type": "object",
3741
+ "properties": {
3742
+ "provider": {
3743
+ "type": "string",
3744
+ "enum": [
3745
+ "claude",
3746
+ "codex",
3747
+ "pi"
3748
+ ]
3749
+ },
3750
+ "model": {
3751
+ "type": "string"
3752
+ },
3753
+ "tokenClass": {
3754
+ "type": "string",
3755
+ "enum": [
3756
+ "input",
3757
+ "cached_input",
3758
+ "output"
3759
+ ]
3760
+ },
3761
+ "effectiveFrom": {
3762
+ "type": "number",
3763
+ "minimum": 0
3764
+ },
3765
+ "pricePerMillionUsd": {
3766
+ "type": "number",
3767
+ "minimum": 0
3768
+ },
3769
+ "createdAt": {
3770
+ "type": "number"
3771
+ },
3772
+ "lastUpdatedAt": {
3773
+ "type": "number"
3774
+ }
3775
+ },
3776
+ "required": [
3777
+ "provider",
3778
+ "model",
3779
+ "tokenClass",
3780
+ "effectiveFrom",
3781
+ "pricePerMillionUsd",
3782
+ "createdAt",
3783
+ "lastUpdatedAt"
3784
+ ]
3785
+ }
3786
+ }
3787
+ }
2936
3788
  },
2937
3789
  "404": {
2938
- "description": "Agent not found"
3790
+ "description": "No pricing row in effect"
2939
3791
  }
2940
3792
  }
2941
3793
  }
2942
3794
  },
2943
- "/api/channel-activity/commit-cursors": {
2944
- "post": {
2945
- "summary": "Commit channel activity cursors after successful processing",
3795
+ "/api/pricing/{provider}/{model}/{tokenClass}/{effectiveFrom}": {
3796
+ "delete": {
3797
+ "summary": "Delete a pricing row (typo correction)",
2946
3798
  "tags": [
2947
- "Poll"
3799
+ "Pricing"
2948
3800
  ],
2949
3801
  "security": [
2950
3802
  {
2951
3803
  "bearerAuth": []
2952
3804
  }
2953
3805
  ],
2954
- "requestBody": {
2955
- "content": {
2956
- "application/json": {
2957
- "schema": {
2958
- "type": "object",
2959
- "properties": {
2960
- "cursorUpdates": {
2961
- "type": "array",
2962
- "items": {
2963
- "type": "object",
2964
- "properties": {
2965
- "channelId": {
2966
- "type": "string"
2967
- },
2968
- "ts": {
2969
- "type": "string"
2970
- }
2971
- },
2972
- "required": [
2973
- "channelId",
2974
- "ts"
2975
- ]
2976
- }
2977
- }
2978
- },
2979
- "required": [
2980
- "cursorUpdates"
2981
- ]
2982
- }
2983
- }
3806
+ "parameters": [
3807
+ {
3808
+ "schema": {
3809
+ "type": "string",
3810
+ "enum": [
3811
+ "claude",
3812
+ "codex",
3813
+ "pi"
3814
+ ]
3815
+ },
3816
+ "required": true,
3817
+ "name": "provider",
3818
+ "in": "path"
3819
+ },
3820
+ {
3821
+ "schema": {
3822
+ "type": "string",
3823
+ "minLength": 1
3824
+ },
3825
+ "required": true,
3826
+ "name": "model",
3827
+ "in": "path"
3828
+ },
3829
+ {
3830
+ "schema": {
3831
+ "type": "string",
3832
+ "enum": [
3833
+ "input",
3834
+ "cached_input",
3835
+ "output"
3836
+ ]
3837
+ },
3838
+ "required": true,
3839
+ "name": "tokenClass",
3840
+ "in": "path"
3841
+ },
3842
+ {
3843
+ "schema": {
3844
+ "type": "string",
3845
+ "pattern": "^\\d+$"
3846
+ },
3847
+ "required": true,
3848
+ "name": "effectiveFrom",
3849
+ "in": "path"
2984
3850
  }
2985
- },
3851
+ ],
2986
3852
  "responses": {
2987
- "200": {
2988
- "description": "Cursors committed"
3853
+ "204": {
3854
+ "description": "Pricing row deleted"
2989
3855
  },
2990
- "400": {
2991
- "description": "Invalid request"
3856
+ "404": {
3857
+ "description": "Pricing row not found"
2992
3858
  }
2993
3859
  }
2994
3860
  }
@@ -4149,6 +5015,18 @@
4149
5015
  },
4150
5016
  "isError": {
4151
5017
  "type": "boolean"
5018
+ },
5019
+ "provider": {
5020
+ "type": "string",
5021
+ "enum": [
5022
+ "claude",
5023
+ "codex",
5024
+ "pi"
5025
+ ]
5026
+ },
5027
+ "createdAt": {
5028
+ "type": "integer",
5029
+ "minimum": 0
4152
5030
  }
4153
5031
  },
4154
5032
  "required": [
@@ -5849,15 +6727,69 @@
5849
6727
  "content": {
5850
6728
  "application/json": {
5851
6729
  "schema": {
5852
- "type": "object",
5853
- "properties": {
5854
- "claudeSessionId": {
5855
- "type": "string",
5856
- "minLength": 1
6730
+ "anyOf": [
6731
+ {
6732
+ "type": "object",
6733
+ "properties": {
6734
+ "claudeSessionId": {
6735
+ "type": "string",
6736
+ "minLength": 1
6737
+ },
6738
+ "provider": {
6739
+ "type": "string",
6740
+ "enum": [
6741
+ "devin"
6742
+ ]
6743
+ },
6744
+ "providerMeta": {
6745
+ "type": "object",
6746
+ "properties": {
6747
+ "sessionUrl": {
6748
+ "type": "string"
6749
+ },
6750
+ "maxAcuLimit": {
6751
+ "type": "number"
6752
+ },
6753
+ "acuCostUsd": {
6754
+ "type": "number"
6755
+ }
6756
+ },
6757
+ "required": [
6758
+ "sessionUrl"
6759
+ ]
6760
+ }
6761
+ },
6762
+ "required": [
6763
+ "claudeSessionId",
6764
+ "provider",
6765
+ "providerMeta"
6766
+ ]
6767
+ },
6768
+ {
6769
+ "type": "object",
6770
+ "properties": {
6771
+ "claudeSessionId": {
6772
+ "type": "string",
6773
+ "minLength": 1
6774
+ },
6775
+ "provider": {
6776
+ "type": "string",
6777
+ "enum": [
6778
+ "claude",
6779
+ "codex",
6780
+ "pi",
6781
+ "claude-managed"
6782
+ ]
6783
+ },
6784
+ "providerMeta": {
6785
+ "type": "object",
6786
+ "properties": {}
6787
+ }
6788
+ },
6789
+ "required": [
6790
+ "claudeSessionId"
6791
+ ]
5857
6792
  }
5858
- },
5859
- "required": [
5860
- "claudeSessionId"
5861
6793
  ]
5862
6794
  }
5863
6795
  }