@onbox/cli 0.3.0 → 0.4.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 (3) hide show
  1. package/README.md +33 -1
  2. package/dist/onbox.js +2177 -656
  3. package/package.json +1 -1
package/dist/onbox.js CHANGED
@@ -441,14 +441,92 @@ function boolFlag(parsed, name) {
441
441
  // src/arguments.ts
442
442
  import { readFileSync as readFileSync4 } from "fs";
443
443
 
444
- // ../../packages/openapi/dist/public-api.mjs
444
+ // ../../packages/openapi/dist/chunk-2SQMN3BE.mjs
445
+ var BRAIN_PUBLIC_API_ROUTES = [
446
+ // Files
447
+ { method: "POST", path: "/v1/brain/build", tool: "build_brain" },
448
+ {
449
+ method: "GET",
450
+ path: "/v1/brain/{scope}/files",
451
+ tool: "list_brain_files",
452
+ params: { scope: { arg: "scope" } }
453
+ },
454
+ {
455
+ method: "GET",
456
+ path: "/v1/brain/{scope}/files/get",
457
+ tool: "read_brain_files",
458
+ params: { scope: { arg: "scope" } }
459
+ },
460
+ {
461
+ method: "GET",
462
+ path: "/v1/brain/{scope}/files/{path...}",
463
+ tool: "read_brain_files",
464
+ params: { scope: { arg: "scope" }, path: { arg: "paths", list: true } },
465
+ pick: { from: "files", by: "path", param: "path" }
466
+ },
467
+ {
468
+ method: "POST",
469
+ path: "/v1/brain/{scope}/changes",
470
+ tool: "write_brain_files",
471
+ params: { scope: { arg: "scope" } }
472
+ },
473
+ { method: "GET", path: "/v1/brain/proposals", tool: "list_brain_proposals" },
474
+ {
475
+ method: "GET",
476
+ path: "/v1/brain/proposals/{proposalId}",
477
+ tool: "list_brain_proposals",
478
+ summary: "Get a Brain Proposal",
479
+ params: { proposalId: { arg: "proposalId" } },
480
+ pick: { from: "proposals", by: "id", param: "proposalId" }
481
+ },
482
+ { method: "POST", path: "/v1/brain/proposals/accept", tool: "accept_brain_proposals" },
483
+ {
484
+ method: "POST",
485
+ path: "/v1/brain/proposals/{proposalId}/accept",
486
+ tool: "accept_brain_proposals",
487
+ params: {
488
+ proposalId: { arg: "proposals", itemKey: "proposalId", itemFields: ["reviewedHeadSha"] }
489
+ }
490
+ },
491
+ { method: "POST", path: "/v1/brain/proposals/decline", tool: "decline_brain_proposals" },
492
+ {
493
+ method: "POST",
494
+ path: "/v1/brain/proposals/{proposalId}/decline",
495
+ tool: "decline_brain_proposals",
496
+ params: { proposalId: { arg: "proposalIds", list: true } }
497
+ },
498
+ // Brain gaps: customer problems Onbox struggled with (the Dream's store)
499
+ { method: "GET", path: "/v1/brain/gaps", tool: "list_brain_gaps" },
500
+ {
501
+ method: "GET",
502
+ path: "/v1/brain/gaps/{gapId}",
503
+ tool: "list_brain_gaps",
504
+ summary: "Get a Brain Gap",
505
+ params: { gapId: { arg: "gapId" } },
506
+ // The tool answers this one gap or 404s; an uppercase id would not match by value.
507
+ pick: { from: "gaps" }
508
+ },
509
+ { method: "POST", path: "/v1/brain/gaps", tool: "create_brain_gap" },
510
+ {
511
+ method: "PATCH",
512
+ path: "/v1/brain/gaps/{gapId}",
513
+ tool: "update_brain_gap",
514
+ params: { gapId: { arg: "gapId" } }
515
+ },
516
+ {
517
+ method: "POST",
518
+ path: "/v1/brain/gaps/{gapId}/conversations",
519
+ tool: "record_brain_gap_conversations",
520
+ params: { gapId: { arg: "gapId" } }
521
+ }
522
+ ];
523
+ var AGENT_RUN_TRACE_MAX_PAGE_BYTES = 1e6;
445
524
  var conversationIds = { arg: "conversationIds", list: true };
446
525
  var conversationPick = { from: "conversations", param: "conversationId" };
447
526
  var PUBLIC_API_ROUTES = [
448
527
  // Account
449
528
  { method: "GET", path: "/v1/account/status", tool: "get_account_status" },
450
529
  { method: "GET", path: "/v1/account/billing", tool: "get_billing" },
451
- { method: "PATCH", path: "/v1/account/billing", tool: "update_billing" },
452
530
  { method: "PATCH", path: "/v1/organisation", tool: "update_organisation" },
453
531
  { method: "POST", path: "/v1/support/requests", tool: "contact_onbox_support" },
454
532
  // My inbox
@@ -775,58 +853,8 @@ var PUBLIC_API_ROUTES = [
775
853
  tool: "test_integration",
776
854
  params: { integration: { arg: "id", slugArg: "slug" } }
777
855
  },
778
- // Brain
779
- { method: "POST", path: "/v1/brain/build", tool: "build_brain" },
780
- {
781
- method: "GET",
782
- path: "/v1/brain/{scope}/files",
783
- tool: "list_brain_files",
784
- params: { scope: { arg: "scope" } }
785
- },
786
- {
787
- method: "GET",
788
- path: "/v1/brain/{scope}/files/get",
789
- tool: "read_brain_files",
790
- params: { scope: { arg: "scope" } }
791
- },
792
- {
793
- method: "GET",
794
- path: "/v1/brain/{scope}/files/{path...}",
795
- tool: "read_brain_files",
796
- params: { scope: { arg: "scope" }, path: { arg: "paths", list: true } },
797
- pick: { from: "files", by: "path", param: "path" }
798
- },
799
- {
800
- method: "POST",
801
- path: "/v1/brain/{scope}/changes",
802
- tool: "write_brain_files",
803
- params: { scope: { arg: "scope" } }
804
- },
805
- { method: "GET", path: "/v1/brain/proposals", tool: "list_brain_proposals" },
806
- {
807
- method: "GET",
808
- path: "/v1/brain/proposals/{proposalId}",
809
- tool: "list_brain_proposals",
810
- summary: "Get a Brain Proposal",
811
- params: { proposalId: { arg: "proposalId" } },
812
- pick: { from: "proposals", by: "id", param: "proposalId" }
813
- },
814
- { method: "POST", path: "/v1/brain/proposals/accept", tool: "accept_brain_proposals" },
815
- {
816
- method: "POST",
817
- path: "/v1/brain/proposals/{proposalId}/accept",
818
- tool: "accept_brain_proposals",
819
- params: {
820
- proposalId: { arg: "proposals", itemKey: "proposalId", itemFields: ["reviewedHeadSha"] }
821
- }
822
- },
823
- { method: "POST", path: "/v1/brain/proposals/decline", tool: "decline_brain_proposals" },
824
- {
825
- method: "POST",
826
- path: "/v1/brain/proposals/{proposalId}/decline",
827
- tool: "decline_brain_proposals",
828
- params: { proposalId: { arg: "proposalIds", list: true } }
829
- },
856
+ // Brain, its proposals and its gaps
857
+ ...BRAIN_PUBLIC_API_ROUTES,
830
858
  // Tests of the Onbox agent
831
859
  { method: "GET", path: "/v1/tests", tool: "list_tests" },
832
860
  { method: "POST", path: "/v1/tests", tool: "create_test" },
@@ -863,6 +891,27 @@ var PUBLIC_API_ROUTES = [
863
891
  path: "/v1/calendar/invitations/{eventId}/response",
864
892
  tool: "respond_to_invitation",
865
893
  params: { eventId: { arg: "eventId" } }
894
+ },
895
+ // Webhook endpoints
896
+ { method: "GET", path: "/v1/webhook-endpoints", tool: "list_webhook_endpoints" },
897
+ { method: "POST", path: "/v1/webhook-endpoints", tool: "create_webhook_endpoint" },
898
+ {
899
+ method: "PATCH",
900
+ path: "/v1/webhook-endpoints/{endpoint}",
901
+ tool: "update_webhook_endpoint",
902
+ params: { endpoint: { arg: "endpoint" } }
903
+ },
904
+ {
905
+ method: "DELETE",
906
+ path: "/v1/webhook-endpoints/{endpoint}",
907
+ tool: "delete_webhook_endpoint",
908
+ params: { endpoint: { arg: "endpoint" } }
909
+ },
910
+ {
911
+ method: "GET",
912
+ path: "/v1/webhook-endpoints/{endpoint}/deliveries",
913
+ tool: "list_webhook_deliveries",
914
+ params: { endpoint: { arg: "endpoint" } }
866
915
  }
867
916
  ];
868
917
  function publicApiReadsQuery(method) {
@@ -948,6 +997,9 @@ var openapi_default = {
948
997
  },
949
998
  {
950
999
  name: "calendar"
1000
+ },
1001
+ {
1002
+ name: "webhook-endpoints"
951
1003
  }
952
1004
  ],
953
1005
  paths: {
@@ -1052,7 +1104,7 @@ var openapi_default = {
1052
1104
  operationId: "get_billing",
1053
1105
  tags: ["account"],
1054
1106
  summary: "Get Billing",
1055
- description: "See the organisation's billing: whether the agent can work, the plans (price, conversations included, free trial), its plan's status, trial end or renewal and usage, the prepaid balance and this month's credit spent; for an admin with a subscription, the Stripe portal link. Read only: start a plan or add credit with update_billing. Never state a price beyond what it returns.",
1107
+ description: "See the organisation's billing status: whether the agent can work and why not, its plan's status, trial end or renewal and conversations used, the prepaid balance and this month's credit spent. Read only. Starting a plan, adding credit and payment settings happen on the billing page: give the person webUrl as is when the agent cannot work or they ask to change billing. Never state a price.",
1056
1108
  security: [
1057
1109
  {
1058
1110
  bearerAuth: []
@@ -1141,162 +1193,6 @@ var openapi_default = {
1141
1193
  }
1142
1194
  }
1143
1195
  }
1144
- },
1145
- patch: {
1146
- operationId: "update_billing",
1147
- tags: ["account"],
1148
- summary: "Update Billing",
1149
- description: "Start a plan, add prepaid credit, or manage it. Read plans, prices and settings with get_billing first, ask the person before calling, and give them every link as is. plan returns the Stripe Checkout link starting its free trial: the card is entered there, nothing is charged until the trial ends, and the trial starts when they come back; if a plan is running, it returns the Plans page, where a switch happens. topUp (at least 10) returns a Checkout link for credit used past the plan. automaticRefill turns refill on, off or changes its amounts; turning it on returns a Stripe link to save the card and agree to automatic charges. lowCreditAlert sets the balance below which admins get an email. Admins only.\n\nAdmins only: a member is refused.",
1150
- security: [
1151
- {
1152
- bearerAuth: []
1153
- }
1154
- ],
1155
- "x-onbox-tool": "update_billing",
1156
- "x-onbox-scope": "write",
1157
- "x-onbox-destructive": true,
1158
- requestBody: {
1159
- required: false,
1160
- content: {
1161
- "application/json": {
1162
- schema: {
1163
- type: "object",
1164
- properties: {
1165
- plan: {
1166
- type: "string",
1167
- enum: ["STARTER", "PRO", "BUSINESS"]
1168
- },
1169
- currency: {
1170
- description: "Of every amount; before a first payment, the one you quoted",
1171
- type: "string",
1172
- enum: ["usd", "eur", "gbp"]
1173
- },
1174
- topUp: {
1175
- type: "number",
1176
- minimum: 10,
1177
- maximum: 1e3
1178
- },
1179
- automaticRefill: {
1180
- description: "Charges the saved card when credit runs low. First time: pass all three amounts. Changes and turning it off apply at once",
1181
- type: "object",
1182
- properties: {
1183
- enabled: {
1184
- type: "boolean"
1185
- },
1186
- below: {
1187
- description: "Refill below this balance",
1188
- type: "number",
1189
- minimum: 0,
1190
- exclusiveMinimum: true
1191
- },
1192
- topUpTo: {
1193
- description: "Refill up to this, at least 10 above below",
1194
- type: "number",
1195
- minimum: 0,
1196
- exclusiveMinimum: true
1197
- },
1198
- monthlyMax: {
1199
- description: "Most charged per calendar month, more than one refill",
1200
- type: "number",
1201
- minimum: 0,
1202
- exclusiveMinimum: true
1203
- }
1204
- },
1205
- required: ["enabled"],
1206
- additionalProperties: false
1207
- },
1208
- lowCreditAlert: {
1209
- type: "number",
1210
- minimum: 0,
1211
- exclusiveMinimum: true,
1212
- maximum: 1e6
1213
- }
1214
- },
1215
- additionalProperties: false
1216
- }
1217
- }
1218
- }
1219
- },
1220
- responses: {
1221
- "200": {
1222
- description: "The tool's result.",
1223
- content: {
1224
- "application/json": {
1225
- schema: {}
1226
- }
1227
- }
1228
- },
1229
- "400": {
1230
- description: "The arguments are invalid.",
1231
- content: {
1232
- "application/json": {
1233
- schema: {
1234
- $ref: "#/components/schemas/Error"
1235
- }
1236
- }
1237
- }
1238
- },
1239
- "401": {
1240
- description: "No valid credential.",
1241
- content: {
1242
- "application/json": {
1243
- schema: {
1244
- $ref: "#/components/schemas/Error"
1245
- }
1246
- }
1247
- }
1248
- },
1249
- "403": {
1250
- description: "The caller may not use this route (an admin-only tool, or a token without the scope the route needs: code insufficient_scope).",
1251
- content: {
1252
- "application/json": {
1253
- schema: {
1254
- $ref: "#/components/schemas/Error"
1255
- }
1256
- }
1257
- }
1258
- },
1259
- "404": {
1260
- description: "The thing the arguments name does not exist, or the caller cannot see it.",
1261
- content: {
1262
- "application/json": {
1263
- schema: {
1264
- $ref: "#/components/schemas/Error"
1265
- }
1266
- }
1267
- }
1268
- },
1269
- "409": {
1270
- description: "The account is not ready for this call; the message names the step.",
1271
- content: {
1272
- "application/json": {
1273
- schema: {
1274
- $ref: "#/components/schemas/Error"
1275
- }
1276
- }
1277
- }
1278
- },
1279
- "422": {
1280
- description: "The tool understood the request and refused it; the message says why.",
1281
- content: {
1282
- "application/json": {
1283
- schema: {
1284
- $ref: "#/components/schemas/Error"
1285
- }
1286
- }
1287
- }
1288
- },
1289
- "500": {
1290
- description: "Unexpected error.",
1291
- content: {
1292
- "application/json": {
1293
- schema: {
1294
- $ref: "#/components/schemas/Error"
1295
- }
1296
- }
1297
- }
1298
- }
1299
- }
1300
1196
  }
1301
1197
  },
1302
1198
  "/v1/organisation": {
@@ -6161,7 +6057,7 @@ var openapi_default = {
6161
6057
  operationId: "get_agent_run_trace",
6162
6058
  tags: ["agent-runs"],
6163
6059
  summary: "Read Agent Run Trace",
6164
- description: "Read a run's trace (messages, tool calls) in 50KB pages; pass `nextCursor` as `cursor` until null. Join partial message parts.",
6060
+ description: "Read a run's trace (messages, tool calls) in 50KB pages by default, or request up to 1MB. Pass `nextCursor` as `cursor` until null. Join partial message parts. Organisation admins can set includeToolResults for stored tool results.",
6165
6061
  security: [
6166
6062
  {
6167
6063
  bearerAuth: []
@@ -6187,19 +6083,72 @@ var openapi_default = {
6187
6083
  schema: {
6188
6084
  type: "string"
6189
6085
  }
6190
- }
6191
- ],
6192
- responses: {
6193
- "200": {
6194
- description: "The tool's result.",
6195
- content: {
6196
- "application/json": {
6197
- schema: {}
6198
- }
6199
- }
6200
6086
  },
6201
- "400": {
6202
- description: "The arguments are invalid.",
6087
+ {
6088
+ name: "pageSizeBytes",
6089
+ in: "query",
6090
+ required: false,
6091
+ description: "Trace page budget in UTF-8 bytes. Defaults to 50000.",
6092
+ schema: {
6093
+ type: "integer",
6094
+ minimum: 4,
6095
+ maximum: 1e6
6096
+ }
6097
+ },
6098
+ {
6099
+ name: "includeToolResults",
6100
+ in: "query",
6101
+ required: false,
6102
+ description: "Include the stored tool result parts. Organisation admins only.",
6103
+ schema: {
6104
+ type: "boolean"
6105
+ }
6106
+ },
6107
+ {
6108
+ name: "toolResultLimitBytes",
6109
+ in: "query",
6110
+ required: false,
6111
+ description: "Optional UTF-8 byte limit for each tool result. Requires includeToolResults.",
6112
+ schema: {
6113
+ type: "integer",
6114
+ minimum: 4,
6115
+ maximum: 1048576
6116
+ }
6117
+ },
6118
+ {
6119
+ name: "toolResultRange",
6120
+ in: "query",
6121
+ required: false,
6122
+ description: "Inclusive zero-based message index range for results. Requires includeToolResults.",
6123
+ schema: {
6124
+ type: "object",
6125
+ properties: {
6126
+ from: {
6127
+ type: "integer",
6128
+ minimum: 0,
6129
+ maximum: 9007199254740991
6130
+ },
6131
+ to: {
6132
+ type: "integer",
6133
+ minimum: 0,
6134
+ maximum: 9007199254740991
6135
+ }
6136
+ },
6137
+ required: ["from", "to"]
6138
+ }
6139
+ }
6140
+ ],
6141
+ responses: {
6142
+ "200": {
6143
+ description: "The tool's result.",
6144
+ content: {
6145
+ "application/json": {
6146
+ schema: {}
6147
+ }
6148
+ }
6149
+ },
6150
+ "400": {
6151
+ description: "The arguments are invalid.",
6203
6152
  content: {
6204
6153
  "application/json": {
6205
6154
  schema: {
@@ -9954,7 +9903,7 @@ Admins only: a member is refused.`,
9954
9903
  operationId: "test_integration",
9955
9904
  tags: ["integrations"],
9956
9905
  summary: "Test an Integration",
9957
- description: "Test a connected integration, catalog or custom, by id or slug, with the account the Onbox agent uses for you, and store the result as its lastTest. Without operation it runs one fixed check: an MCP server lists its tools, an API gets one read endpoint, PostgreSQL runs SELECT 1. Custom OpenAPI only: operation names one GET operation of that admin-connected API, as list_integrations lists it, with arguments for its path and query; Onbox sends that GET with and without the secret and compares (verified, note). Any other method is refused: it never writes. Run the checks yourself; never ask the person to run a command. Testing a custom integration is for admins.",
9906
+ description: "Test a connected integration, catalog or custom, by id or slug, with the account the Onbox agent uses for you, and store the result as its lastTest. It runs one fixed check: an MCP server lists its tools, an API gets one read endpoint, PostgreSQL runs SELECT 1. For a custom OpenAPI integration, verified and note say whether the check showed the secret works. Run the checks yourself; never ask the person to run a command. Testing a custom integration is for admins.",
9958
9907
  security: [
9959
9908
  {
9960
9909
  bearerAuth: []
@@ -9974,42 +9923,6 @@ Admins only: a member is refused.`,
9974
9923
  }
9975
9924
  }
9976
9925
  ],
9977
- requestBody: {
9978
- required: false,
9979
- content: {
9980
- "application/json": {
9981
- schema: {
9982
- type: "object",
9983
- properties: {
9984
- operation: {
9985
- description: "Custom OpenAPI only: a GET operation needing the secret, by name; Onbox calls it with and without the secret and compares. Never a write",
9986
- type: "string",
9987
- minLength: 1,
9988
- maxLength: 200
9989
- },
9990
- arguments: {
9991
- description: "Its path and query parameters, for a record you know exists",
9992
- type: "object",
9993
- additionalProperties: {
9994
- anyOf: [
9995
- {
9996
- type: "string"
9997
- },
9998
- {
9999
- type: "number"
10000
- },
10001
- {
10002
- type: "boolean"
10003
- }
10004
- ]
10005
- }
10006
- }
10007
- },
10008
- additionalProperties: false
10009
- }
10010
- }
10011
- }
10012
- },
10013
9926
  responses: {
10014
9927
  "200": {
10015
9928
  description: "The tool's result.",
@@ -11456,20 +11369,68 @@ Admins only: a member is refused.`,
11456
11369
  }
11457
11370
  }
11458
11371
  },
11459
- "/v1/tests": {
11372
+ "/v1/brain/gaps": {
11460
11373
  get: {
11461
- operationId: "list_tests",
11462
- tags: ["tests"],
11463
- summary: "List Tests",
11464
- description: "List the tests of the Onbox agent: expected outcomes, notes, latest result, webUrl, and whether a person confirmed each. A failure of an unconfirmed test questions the test first. Admins only.\n\nAdmins only: a member is refused.",
11374
+ operationId: "list_brain_gaps",
11375
+ tags: ["brain"],
11376
+ summary: "List Brain Gaps",
11377
+ description: "List the brain gaps of your organisation: customer problems Onbox struggled with, in the customer's words, each with its scope, status, last review and how many conversations were first seen struggling in each window (default 30 and 90 days; sinceReview counts those after the last review). Pass gapId for one gap with its recent conversations you can read and their signals. Merged gaps are left out unless includeMerged.",
11465
11378
  security: [
11466
11379
  {
11467
11380
  bearerAuth: []
11468
11381
  }
11469
11382
  ],
11470
- "x-onbox-tool": "list_tests",
11383
+ "x-onbox-tool": "list_brain_gaps",
11471
11384
  "x-onbox-scope": "read",
11472
11385
  "x-onbox-destructive": false,
11386
+ parameters: [
11387
+ {
11388
+ name: "status",
11389
+ in: "query",
11390
+ required: false,
11391
+ description: "Only gaps in this state.",
11392
+ schema: {
11393
+ type: "string",
11394
+ enum: ["open", "in_review", "reviewed"]
11395
+ }
11396
+ },
11397
+ {
11398
+ name: "gapId",
11399
+ in: "query",
11400
+ required: false,
11401
+ description: "One gap, merged or not, with its conversations first seen inside the longest window, newest first, each with its signals.",
11402
+ schema: {
11403
+ type: "string",
11404
+ format: "uuid",
11405
+ pattern: "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
11406
+ }
11407
+ },
11408
+ {
11409
+ name: "windowDays",
11410
+ in: "query",
11411
+ required: false,
11412
+ description: "Windows to count conversations in, in days. Default 30 and 90.",
11413
+ schema: {
11414
+ minItems: 1,
11415
+ maxItems: 4,
11416
+ type: "array",
11417
+ items: {
11418
+ type: "integer",
11419
+ minimum: 1,
11420
+ maximum: 365
11421
+ }
11422
+ }
11423
+ },
11424
+ {
11425
+ name: "includeMerged",
11426
+ in: "query",
11427
+ required: false,
11428
+ description: "Also list gaps merged into another one. Default false.",
11429
+ schema: {
11430
+ type: "boolean"
11431
+ }
11432
+ }
11433
+ ],
11473
11434
  responses: {
11474
11435
  "200": {
11475
11436
  description: "The tool's result.",
@@ -11552,16 +11513,16 @@ Admins only: a member is refused.`,
11552
11513
  }
11553
11514
  },
11554
11515
  post: {
11555
- operationId: "create_test",
11556
- tags: ["tests"],
11557
- summary: "Create Test",
11558
- description: "Create a test of the Onbox agent: a conversation and what the agent must do with it. Copy one (fromConversationId, triggerMessageId) or describe one (customer, conversation). expectedOutcomes are judged one by one, so write checkable statements. Nothing a test does leaves Onbox. Next: run_tests, get_test_results, then the person confirms with update_test. Admins only.\n\nAdmins only: a member is refused.",
11516
+ operationId: "create_brain_gap",
11517
+ tags: ["brain"],
11518
+ summary: "Create a Brain Gap",
11519
+ description: "Create a brain gap: one customer problem Onbox struggled with, titled in the customer's words, with a scope of what is in and out. Group by what the customer says, not by cause. Create one only when no open gap fits (list_brain_gaps first), then file its conversations with record_brain_gap_conversations. The Dream and organisation admins only.",
11559
11520
  security: [
11560
11521
  {
11561
11522
  bearerAuth: []
11562
11523
  }
11563
11524
  ],
11564
- "x-onbox-tool": "create_test",
11525
+ "x-onbox-tool": "create_brain_gap",
11565
11526
  "x-onbox-scope": "write",
11566
11527
  "x-onbox-destructive": false,
11567
11528
  requestBody: {
@@ -11571,116 +11532,20 @@ Admins only: a member is refused.`,
11571
11532
  schema: {
11572
11533
  type: "object",
11573
11534
  properties: {
11574
- name: {
11535
+ title: {
11575
11536
  type: "string",
11576
11537
  minLength: 1,
11577
- maxLength: 120
11578
- },
11579
- inbox: {
11580
- type: "string",
11581
- description: "A shared inbox address, from list_inboxes"
11582
- },
11583
- channel: {
11584
- description: "Default email",
11585
- type: "string",
11586
- enum: ["email", "chat"]
11587
- },
11588
- fromConversationId: {
11589
- description: "Copy this conversation",
11590
- type: "string"
11591
- },
11592
- triggerMessageId: {
11593
- description: "The customer message the agent starts on",
11594
- type: "string"
11595
- },
11596
- customer: {
11597
- type: "object",
11598
- properties: {
11599
- name: {
11600
- type: "string"
11601
- },
11602
- address: {
11603
- type: "string",
11604
- description: "Email address, or a visitor id on chat"
11605
- }
11606
- },
11607
- required: ["address"]
11608
- },
11609
- conversation: {
11610
- description: "Oldest first, starting with a message",
11611
- minItems: 1,
11612
- maxItems: 50,
11613
- type: "array",
11614
- items: {
11615
- type: "object",
11616
- properties: {
11617
- type: {
11618
- type: "string",
11619
- enum: ["customer_message", "team_message", "comment"]
11620
- },
11621
- body: {
11622
- type: "string",
11623
- minLength: 1,
11624
- maxLength: 2e4
11625
- },
11626
- subject: {
11627
- description: "Email only",
11628
- type: "string",
11629
- maxLength: 300
11630
- },
11631
- authorEmail: {
11632
- description: "Comment: the teammate who wrote it",
11633
- type: "string"
11634
- },
11635
- at: {
11636
- description: "ISO time; default: one minute apart, up to now",
11637
- type: "string"
11638
- }
11639
- },
11640
- required: ["type", "body"]
11641
- }
11642
- },
11643
- startsAt: {
11644
- description: "Index the agent starts on, default last; later ones are customer follow-ups",
11645
- type: "integer",
11646
- minimum: 0,
11647
- maximum: 9007199254740991
11648
- },
11649
- scenario: {
11650
- description: "The situation, in a sentence or two",
11651
- type: "string",
11652
- maxLength: 400
11653
- },
11654
- expectedOutcomes: {
11655
- minItems: 1,
11656
- maxItems: 20,
11657
- type: "array",
11658
- items: {
11659
- type: "string",
11660
- minLength: 1,
11661
- maxLength: 1e3
11662
- },
11663
- description: "Checkable statements"
11538
+ maxLength: 200,
11539
+ description: `The problem in the customer's words, e.g. "A show or movie is missing".`
11664
11540
  },
11665
- notes: {
11666
- description: "Facts the simulated tools answer from",
11541
+ scope: {
11667
11542
  type: "string",
11668
- maxLength: 2e4
11669
- },
11670
- simulatedTools: {
11671
- description: "Slugs from list_integrations",
11672
- maxItems: 20,
11673
- type: "array",
11674
- items: {
11675
- type: "string"
11676
- }
11677
- },
11678
- assignee: {
11679
- description: '"agent" or a member email',
11680
- type: "string"
11543
+ minLength: 1,
11544
+ maxLength: 1e3,
11545
+ description: "Two or three lines: what is in the gap and what is out."
11681
11546
  }
11682
11547
  },
11683
- required: ["name", "inbox", "expectedOutcomes"]
11548
+ required: ["title", "scope"]
11684
11549
  }
11685
11550
  }
11686
11551
  }
@@ -11767,82 +11632,68 @@ Admins only: a member is refused.`,
11767
11632
  }
11768
11633
  }
11769
11634
  },
11770
- "/v1/tests/{testId}": {
11771
- patch: {
11772
- operationId: "update_test",
11773
- tags: ["tests"],
11774
- summary: "Edit Test",
11775
- description: "Change a test's name, scenario, expectedOutcomes, notes, simulatedTools or assignee; values replace the current ones. confirmed: true only when the person read a real result and agrees: ask them. Changing outcomes or notes unconfirms it. Admins only.\n\nAdmins only: a member is refused.",
11635
+ "/v1/brain/gaps/{gapId}": {
11636
+ get: {
11637
+ operationId: "list_brain_gaps__get_brain_gaps_by_gapId",
11638
+ tags: ["brain"],
11639
+ summary: "Get a Brain Gap",
11640
+ description: "List the brain gaps of your organisation: customer problems Onbox struggled with, in the customer's words, each with its scope, status, last review and how many conversations were first seen struggling in each window (default 30 and 90 days; sinceReview counts those after the last review). Pass gapId for one gap with its recent conversations you can read and their signals. Merged gaps are left out unless includeMerged.\n\nReturns the one element the tool's result holds for this path, not the whole list or map.",
11776
11641
  security: [
11777
11642
  {
11778
11643
  bearerAuth: []
11779
11644
  }
11780
11645
  ],
11781
- "x-onbox-tool": "update_test",
11782
- "x-onbox-scope": "write",
11783
- "x-onbox-destructive": true,
11646
+ "x-onbox-tool": "list_brain_gaps",
11647
+ "x-onbox-scope": "read",
11648
+ "x-onbox-destructive": false,
11784
11649
  parameters: [
11785
11650
  {
11786
- name: "testId",
11651
+ name: "gapId",
11787
11652
  in: "path",
11788
11653
  required: true,
11654
+ description: "One gap, merged or not, with its conversations first seen inside the longest window, newest first, each with its signals.",
11789
11655
  schema: {
11790
- type: "string"
11656
+ type: "string",
11657
+ format: "uuid",
11658
+ pattern: "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
11791
11659
  }
11792
- }
11793
- ],
11794
- requestBody: {
11795
- required: false,
11796
- content: {
11797
- "application/json": {
11798
- schema: {
11799
- type: "object",
11800
- properties: {
11801
- name: {
11802
- type: "string",
11803
- minLength: 1,
11804
- maxLength: 120
11805
- },
11806
- scenario: {
11807
- nullable: true,
11808
- type: "string",
11809
- maxLength: 400
11810
- },
11811
- expectedOutcomes: {
11812
- minItems: 1,
11813
- maxItems: 20,
11814
- type: "array",
11815
- items: {
11816
- type: "string",
11817
- minLength: 1,
11818
- maxLength: 1e3
11819
- }
11820
- },
11821
- notes: {
11822
- nullable: true,
11823
- type: "string",
11824
- maxLength: 2e4
11825
- },
11826
- simulatedTools: {
11827
- maxItems: 20,
11828
- type: "array",
11829
- items: {
11830
- type: "string"
11831
- }
11832
- },
11833
- assignee: {
11834
- description: '"agent", an email, or null',
11835
- nullable: true,
11836
- type: "string"
11837
- },
11838
- confirmed: {
11839
- type: "boolean"
11840
- }
11841
- }
11660
+ },
11661
+ {
11662
+ name: "status",
11663
+ in: "query",
11664
+ required: false,
11665
+ description: "Only gaps in this state.",
11666
+ schema: {
11667
+ type: "string",
11668
+ enum: ["open", "in_review", "reviewed"]
11669
+ }
11670
+ },
11671
+ {
11672
+ name: "windowDays",
11673
+ in: "query",
11674
+ required: false,
11675
+ description: "Windows to count conversations in, in days. Default 30 and 90.",
11676
+ schema: {
11677
+ minItems: 1,
11678
+ maxItems: 4,
11679
+ type: "array",
11680
+ items: {
11681
+ type: "integer",
11682
+ minimum: 1,
11683
+ maximum: 365
11842
11684
  }
11843
11685
  }
11686
+ },
11687
+ {
11688
+ name: "includeMerged",
11689
+ in: "query",
11690
+ required: false,
11691
+ description: "Also list gaps merged into another one. Default false.",
11692
+ schema: {
11693
+ type: "boolean"
11694
+ }
11844
11695
  }
11845
- },
11696
+ ],
11846
11697
  responses: {
11847
11698
  "200": {
11848
11699
  description: "The tool's result.",
@@ -11924,30 +11775,73 @@ Admins only: a member is refused.`,
11924
11775
  }
11925
11776
  }
11926
11777
  },
11927
- delete: {
11928
- operationId: "delete_test",
11929
- tags: ["tests"],
11930
- summary: "Delete Test",
11931
- description: "Delete a test of the Onbox agent that the person named. Its past results stay in get_test_results. Admins only.\n\nAdmins only: a member is refused.",
11778
+ patch: {
11779
+ operationId: "update_brain_gap",
11780
+ tags: ["brain"],
11781
+ summary: "Update a Brain Gap",
11782
+ description: "Update a brain gap: its title, scope, status (open, in_review, reviewed), the improvement its last review opened, or merge it into another gap that is the same problem (its conversations move there). A merged gap cannot be changed again. The Dream and organisation admins only.",
11932
11783
  security: [
11933
11784
  {
11934
11785
  bearerAuth: []
11935
11786
  }
11936
11787
  ],
11937
- "x-onbox-tool": "delete_test",
11788
+ "x-onbox-tool": "update_brain_gap",
11938
11789
  "x-onbox-scope": "write",
11939
11790
  "x-onbox-destructive": true,
11940
11791
  parameters: [
11941
11792
  {
11942
- name: "testId",
11793
+ name: "gapId",
11943
11794
  in: "path",
11944
11795
  required: true,
11945
- description: "From list_tests",
11796
+ description: "From list_brain_gaps.",
11946
11797
  schema: {
11947
- type: "string"
11798
+ type: "string",
11799
+ format: "uuid",
11800
+ pattern: "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
11948
11801
  }
11949
11802
  }
11950
11803
  ],
11804
+ requestBody: {
11805
+ required: false,
11806
+ content: {
11807
+ "application/json": {
11808
+ schema: {
11809
+ type: "object",
11810
+ properties: {
11811
+ title: {
11812
+ type: "string",
11813
+ minLength: 1,
11814
+ maxLength: 200,
11815
+ description: `The problem in the customer's words, e.g. "A show or movie is missing".`
11816
+ },
11817
+ scope: {
11818
+ type: "string",
11819
+ minLength: 1,
11820
+ maxLength: 1e3,
11821
+ description: "Two or three lines: what is in the gap and what is out."
11822
+ },
11823
+ status: {
11824
+ description: "in_review once a review card is open; reviewed once it is decided (sets reviewedAt).",
11825
+ type: "string",
11826
+ enum: ["open", "in_review", "reviewed"]
11827
+ },
11828
+ improvementId: {
11829
+ description: "The brain proposal the last review opened.",
11830
+ nullable: true,
11831
+ type: "string",
11832
+ minLength: 1
11833
+ },
11834
+ mergeIntoId: {
11835
+ description: "The same problem as that gap: its conversations move there and this gap only points to it.",
11836
+ type: "string",
11837
+ format: "uuid",
11838
+ pattern: "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
11839
+ }
11840
+ }
11841
+ }
11842
+ }
11843
+ }
11844
+ },
11951
11845
  responses: {
11952
11846
  "200": {
11953
11847
  description: "The tool's result.",
@@ -12030,20 +11924,33 @@ Admins only: a member is refused.`,
12030
11924
  }
12031
11925
  }
12032
11926
  },
12033
- "/v1/tests/run": {
11927
+ "/v1/brain/gaps/{gapId}/conversations": {
12034
11928
  post: {
12035
- operationId: "run_tests",
12036
- tags: ["tests"],
12037
- summary: "Run Tests",
12038
- description: "Run tests of the Onbox agent, all or testIds, each `runs` times. The real agent works on a copy of each conversation; nothing leaves Onbox. Attempts spend the organisation's credit: run what the person asked for. Returns a batchId; read get_test_results after a minute. Admins only.\n\nAdmins only: a member is refused.",
11929
+ operationId: "record_brain_gap_conversations",
11930
+ tags: ["brain"],
11931
+ summary: "Record Conversations Under a Brain Gap",
11932
+ description: "File conversations where Onbox struggled under a brain gap, each with when the struggle was first seen and its signals (kind, and the id of the feedback row that showed it). Safe to repeat: a conversation already filed keeps its earliest firstSeenAt and gains only new signals, so it never counts twice. Up to 100 per call. The Dream and organisation admins only.",
12039
11933
  security: [
12040
11934
  {
12041
11935
  bearerAuth: []
12042
11936
  }
12043
11937
  ],
12044
- "x-onbox-tool": "run_tests",
11938
+ "x-onbox-tool": "record_brain_gap_conversations",
12045
11939
  "x-onbox-scope": "write",
12046
11940
  "x-onbox-destructive": false,
11941
+ parameters: [
11942
+ {
11943
+ name: "gapId",
11944
+ in: "path",
11945
+ required: true,
11946
+ description: "From list_brain_gaps or create_brain_gap.",
11947
+ schema: {
11948
+ type: "string",
11949
+ format: "uuid",
11950
+ pattern: "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
11951
+ }
11952
+ }
11953
+ ],
12047
11954
  requestBody: {
12048
11955
  required: false,
12049
11956
  content: {
@@ -12051,22 +11958,56 @@ Admins only: a member is refused.`,
12051
11958
  schema: {
12052
11959
  type: "object",
12053
11960
  properties: {
12054
- testIds: {
12055
- description: "From list_tests; default every test",
11961
+ conversations: {
12056
11962
  minItems: 1,
12057
- maxItems: 50,
11963
+ maxItems: 100,
12058
11964
  type: "array",
12059
11965
  items: {
12060
- type: "string"
11966
+ type: "object",
11967
+ properties: {
11968
+ conversationId: {
11969
+ type: "string",
11970
+ minLength: 1
11971
+ },
11972
+ firstSeenAt: {
11973
+ type: "string",
11974
+ format: "date-time",
11975
+ pattern: "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
11976
+ description: "The first struggle on the conversation, ISO 8601."
11977
+ },
11978
+ signals: {
11979
+ minItems: 1,
11980
+ maxItems: 50,
11981
+ type: "array",
11982
+ items: {
11983
+ type: "object",
11984
+ properties: {
11985
+ kind: {
11986
+ type: "string",
11987
+ enum: [
11988
+ "correction",
11989
+ "draft_edit",
11990
+ "rating",
11991
+ "comment",
11992
+ "blocked",
11993
+ "escalation",
11994
+ "refusal"
11995
+ ]
11996
+ },
11997
+ feedbackId: {
11998
+ type: "string",
11999
+ minLength: 1
12000
+ }
12001
+ },
12002
+ required: ["kind", "feedbackId"]
12003
+ }
12004
+ }
12005
+ },
12006
+ required: ["conversationId", "firstSeenAt", "signals"]
12061
12007
  }
12062
- },
12063
- runs: {
12064
- description: "Attempts per test, default 1",
12065
- type: "integer",
12066
- minimum: 1,
12067
- maximum: 5
12068
12008
  }
12069
- }
12009
+ },
12010
+ required: ["conversations"]
12070
12011
  }
12071
12012
  }
12072
12013
  }
@@ -12153,48 +12094,20 @@ Admins only: a member is refused.`,
12153
12094
  }
12154
12095
  }
12155
12096
  },
12156
- "/v1/tests/{testId}/run": {
12157
- post: {
12158
- operationId: "run_tests__post_tests_by_testId_run",
12097
+ "/v1/tests": {
12098
+ get: {
12099
+ operationId: "list_tests",
12159
12100
  tags: ["tests"],
12160
- summary: "Run Tests",
12161
- description: "Run tests of the Onbox agent, all or testIds, each `runs` times. The real agent works on a copy of each conversation; nothing leaves Onbox. Attempts spend the organisation's credit: run what the person asked for. Returns a batchId; read get_test_results after a minute. Admins only.\n\nAdmins only: a member is refused.",
12101
+ summary: "List Tests",
12102
+ description: "List the tests of the Onbox agent: expected outcomes, notes, latest result, webUrl, and whether a person confirmed each. A failure of an unconfirmed test questions the test first. Admins only.\n\nAdmins only: a member is refused.",
12162
12103
  security: [
12163
12104
  {
12164
12105
  bearerAuth: []
12165
12106
  }
12166
12107
  ],
12167
- "x-onbox-tool": "run_tests",
12168
- "x-onbox-scope": "write",
12108
+ "x-onbox-tool": "list_tests",
12109
+ "x-onbox-scope": "read",
12169
12110
  "x-onbox-destructive": false,
12170
- parameters: [
12171
- {
12172
- name: "testId",
12173
- in: "path",
12174
- required: true,
12175
- schema: {
12176
- type: "string"
12177
- }
12178
- }
12179
- ],
12180
- requestBody: {
12181
- required: false,
12182
- content: {
12183
- "application/json": {
12184
- schema: {
12185
- type: "object",
12186
- properties: {
12187
- runs: {
12188
- description: "Attempts per test, default 1",
12189
- type: "integer",
12190
- minimum: 1,
12191
- maximum: 5
12192
- }
12193
- }
12194
- }
12195
- }
12196
- }
12197
- },
12198
12111
  responses: {
12199
12112
  "200": {
12200
12113
  description: "The tool's result.",
@@ -12275,79 +12188,1465 @@ Admins only: a member is refused.`,
12275
12188
  }
12276
12189
  }
12277
12190
  }
12278
- }
12279
- },
12280
- "/v1/tests/results": {
12281
- get: {
12282
- operationId: "get_test_results",
12191
+ },
12192
+ post: {
12193
+ operationId: "create_test",
12283
12194
  tags: ["tests"],
12284
- summary: "Read Test Results",
12285
- description: "Read test attempts, newest first, by batchId, testId, result or cause: the verdict per expected outcome with quoted evidence, agent runs (get_agent_run_trace), tool calls, guard decisions, pending actions, reply sent or held, webUrl. Causes: AGENT missed an outcome; SETUP, add the missing facts to notes; EXPECTATION, reword the outcome; ONBOX, run again. Read again while any is not DONE. Admins only.\n\nAdmins only: a member is refused.",
12195
+ summary: "Create Test",
12196
+ description: "Create a test of the Onbox agent: a conversation and what the agent must do with it. Copy one (fromConversationId, triggerMessageId) or describe one (customer, conversation). expectedOutcomes are judged one by one, so write checkable statements. Nothing a test does leaves Onbox. Next: run_tests, get_test_results, then the person confirms with update_test. Admins only.\n\nAdmins only: a member is refused.",
12286
12197
  security: [
12287
12198
  {
12288
12199
  bearerAuth: []
12289
12200
  }
12290
12201
  ],
12291
- "x-onbox-tool": "get_test_results",
12292
- "x-onbox-scope": "read",
12202
+ "x-onbox-tool": "create_test",
12203
+ "x-onbox-scope": "write",
12293
12204
  "x-onbox-destructive": false,
12294
- parameters: [
12295
- {
12296
- name: "batchId",
12297
- in: "query",
12298
- required: false,
12299
- description: "From run_tests",
12300
- schema: {
12301
- type: "string"
12302
- }
12303
- },
12304
- {
12305
- name: "testId",
12306
- in: "query",
12307
- required: false,
12308
- schema: {
12309
- type: "string"
12310
- }
12311
- },
12312
- {
12313
- name: "result",
12314
- in: "query",
12315
- required: false,
12316
- schema: {
12317
- type: "string",
12318
- enum: ["PASSED", "FAILED"]
12319
- }
12320
- },
12321
- {
12322
- name: "cause",
12323
- in: "query",
12324
- required: false,
12325
- schema: {
12326
- type: "string",
12327
- enum: ["AGENT", "SETUP", "EXPECTATION", "ONBOX"]
12205
+ requestBody: {
12206
+ required: false,
12207
+ content: {
12208
+ "application/json": {
12209
+ schema: {
12210
+ type: "object",
12211
+ properties: {
12212
+ name: {
12213
+ type: "string",
12214
+ minLength: 1,
12215
+ maxLength: 120
12216
+ },
12217
+ inbox: {
12218
+ type: "string",
12219
+ description: "A shared inbox address, from list_inboxes"
12220
+ },
12221
+ channel: {
12222
+ description: "Default email",
12223
+ type: "string",
12224
+ enum: ["email", "chat"]
12225
+ },
12226
+ fromConversationId: {
12227
+ description: "Copy this conversation",
12228
+ type: "string"
12229
+ },
12230
+ triggerMessageId: {
12231
+ description: "The customer message the agent starts on",
12232
+ type: "string"
12233
+ },
12234
+ customer: {
12235
+ type: "object",
12236
+ properties: {
12237
+ name: {
12238
+ type: "string"
12239
+ },
12240
+ address: {
12241
+ type: "string",
12242
+ description: "Email address, or a visitor id on chat"
12243
+ }
12244
+ },
12245
+ required: ["address"]
12246
+ },
12247
+ conversation: {
12248
+ description: "Oldest first, starting with a message",
12249
+ minItems: 1,
12250
+ maxItems: 50,
12251
+ type: "array",
12252
+ items: {
12253
+ type: "object",
12254
+ properties: {
12255
+ type: {
12256
+ type: "string",
12257
+ enum: ["customer_message", "team_message", "comment"]
12258
+ },
12259
+ body: {
12260
+ type: "string",
12261
+ minLength: 1,
12262
+ maxLength: 2e4
12263
+ },
12264
+ subject: {
12265
+ description: "Email only",
12266
+ type: "string",
12267
+ maxLength: 300
12268
+ },
12269
+ authorEmail: {
12270
+ description: "Comment: the teammate who wrote it",
12271
+ type: "string"
12272
+ },
12273
+ at: {
12274
+ description: "ISO time; default: one minute apart, up to now",
12275
+ type: "string"
12276
+ }
12277
+ },
12278
+ required: ["type", "body"]
12279
+ }
12280
+ },
12281
+ startsAt: {
12282
+ description: "Index the agent starts on, default last; later ones are customer follow-ups",
12283
+ type: "integer",
12284
+ minimum: 0,
12285
+ maximum: 9007199254740991
12286
+ },
12287
+ scenario: {
12288
+ description: "The situation, in a sentence or two",
12289
+ type: "string",
12290
+ maxLength: 400
12291
+ },
12292
+ expectedOutcomes: {
12293
+ minItems: 1,
12294
+ maxItems: 20,
12295
+ type: "array",
12296
+ items: {
12297
+ type: "string",
12298
+ minLength: 1,
12299
+ maxLength: 1e3
12300
+ },
12301
+ description: "Checkable statements"
12302
+ },
12303
+ notes: {
12304
+ description: "Facts the simulated tools answer from",
12305
+ type: "string",
12306
+ maxLength: 2e4
12307
+ },
12308
+ simulatedTools: {
12309
+ description: "Slugs from list_integrations",
12310
+ maxItems: 20,
12311
+ type: "array",
12312
+ items: {
12313
+ type: "string"
12314
+ }
12315
+ },
12316
+ assignee: {
12317
+ description: '"agent" or a member email',
12318
+ type: "string"
12319
+ }
12320
+ },
12321
+ required: ["name", "inbox", "expectedOutcomes"]
12322
+ }
12323
+ }
12324
+ }
12325
+ },
12326
+ responses: {
12327
+ "200": {
12328
+ description: "The tool's result.",
12329
+ content: {
12330
+ "application/json": {
12331
+ schema: {}
12332
+ }
12333
+ }
12334
+ },
12335
+ "400": {
12336
+ description: "The arguments are invalid.",
12337
+ content: {
12338
+ "application/json": {
12339
+ schema: {
12340
+ $ref: "#/components/schemas/Error"
12341
+ }
12342
+ }
12343
+ }
12344
+ },
12345
+ "401": {
12346
+ description: "No valid credential.",
12347
+ content: {
12348
+ "application/json": {
12349
+ schema: {
12350
+ $ref: "#/components/schemas/Error"
12351
+ }
12352
+ }
12353
+ }
12354
+ },
12355
+ "403": {
12356
+ description: "The caller may not use this route (an admin-only tool, or a token without the scope the route needs: code insufficient_scope).",
12357
+ content: {
12358
+ "application/json": {
12359
+ schema: {
12360
+ $ref: "#/components/schemas/Error"
12361
+ }
12362
+ }
12363
+ }
12364
+ },
12365
+ "404": {
12366
+ description: "The thing the arguments name does not exist, or the caller cannot see it.",
12367
+ content: {
12368
+ "application/json": {
12369
+ schema: {
12370
+ $ref: "#/components/schemas/Error"
12371
+ }
12372
+ }
12373
+ }
12374
+ },
12375
+ "409": {
12376
+ description: "The account is not ready for this call; the message names the step.",
12377
+ content: {
12378
+ "application/json": {
12379
+ schema: {
12380
+ $ref: "#/components/schemas/Error"
12381
+ }
12382
+ }
12383
+ }
12384
+ },
12385
+ "422": {
12386
+ description: "The tool understood the request and refused it; the message says why.",
12387
+ content: {
12388
+ "application/json": {
12389
+ schema: {
12390
+ $ref: "#/components/schemas/Error"
12391
+ }
12392
+ }
12393
+ }
12394
+ },
12395
+ "500": {
12396
+ description: "Unexpected error.",
12397
+ content: {
12398
+ "application/json": {
12399
+ schema: {
12400
+ $ref: "#/components/schemas/Error"
12401
+ }
12402
+ }
12403
+ }
12404
+ }
12405
+ }
12406
+ }
12407
+ },
12408
+ "/v1/tests/{testId}": {
12409
+ patch: {
12410
+ operationId: "update_test",
12411
+ tags: ["tests"],
12412
+ summary: "Edit Test",
12413
+ description: "Change a test's name, scenario, expectedOutcomes, notes, simulatedTools or assignee; values replace the current ones. confirmed: true only when the person read a real result and agrees: ask them. Changing outcomes or notes unconfirms it. Admins only.\n\nAdmins only: a member is refused.",
12414
+ security: [
12415
+ {
12416
+ bearerAuth: []
12417
+ }
12418
+ ],
12419
+ "x-onbox-tool": "update_test",
12420
+ "x-onbox-scope": "write",
12421
+ "x-onbox-destructive": true,
12422
+ parameters: [
12423
+ {
12424
+ name: "testId",
12425
+ in: "path",
12426
+ required: true,
12427
+ schema: {
12428
+ type: "string"
12429
+ }
12430
+ }
12431
+ ],
12432
+ requestBody: {
12433
+ required: false,
12434
+ content: {
12435
+ "application/json": {
12436
+ schema: {
12437
+ type: "object",
12438
+ properties: {
12439
+ name: {
12440
+ type: "string",
12441
+ minLength: 1,
12442
+ maxLength: 120
12443
+ },
12444
+ scenario: {
12445
+ nullable: true,
12446
+ type: "string",
12447
+ maxLength: 400
12448
+ },
12449
+ expectedOutcomes: {
12450
+ minItems: 1,
12451
+ maxItems: 20,
12452
+ type: "array",
12453
+ items: {
12454
+ type: "string",
12455
+ minLength: 1,
12456
+ maxLength: 1e3
12457
+ }
12458
+ },
12459
+ notes: {
12460
+ nullable: true,
12461
+ type: "string",
12462
+ maxLength: 2e4
12463
+ },
12464
+ simulatedTools: {
12465
+ maxItems: 20,
12466
+ type: "array",
12467
+ items: {
12468
+ type: "string"
12469
+ }
12470
+ },
12471
+ assignee: {
12472
+ description: '"agent", an email, or null',
12473
+ nullable: true,
12474
+ type: "string"
12475
+ },
12476
+ confirmed: {
12477
+ type: "boolean"
12478
+ }
12479
+ }
12480
+ }
12481
+ }
12482
+ }
12483
+ },
12484
+ responses: {
12485
+ "200": {
12486
+ description: "The tool's result.",
12487
+ content: {
12488
+ "application/json": {
12489
+ schema: {}
12490
+ }
12491
+ }
12492
+ },
12493
+ "400": {
12494
+ description: "The arguments are invalid.",
12495
+ content: {
12496
+ "application/json": {
12497
+ schema: {
12498
+ $ref: "#/components/schemas/Error"
12499
+ }
12500
+ }
12501
+ }
12502
+ },
12503
+ "401": {
12504
+ description: "No valid credential.",
12505
+ content: {
12506
+ "application/json": {
12507
+ schema: {
12508
+ $ref: "#/components/schemas/Error"
12509
+ }
12510
+ }
12511
+ }
12512
+ },
12513
+ "403": {
12514
+ description: "The caller may not use this route (an admin-only tool, or a token without the scope the route needs: code insufficient_scope).",
12515
+ content: {
12516
+ "application/json": {
12517
+ schema: {
12518
+ $ref: "#/components/schemas/Error"
12519
+ }
12520
+ }
12521
+ }
12522
+ },
12523
+ "404": {
12524
+ description: "The thing the arguments name does not exist, or the caller cannot see it.",
12525
+ content: {
12526
+ "application/json": {
12527
+ schema: {
12528
+ $ref: "#/components/schemas/Error"
12529
+ }
12530
+ }
12531
+ }
12532
+ },
12533
+ "409": {
12534
+ description: "The account is not ready for this call; the message names the step.",
12535
+ content: {
12536
+ "application/json": {
12537
+ schema: {
12538
+ $ref: "#/components/schemas/Error"
12539
+ }
12540
+ }
12541
+ }
12542
+ },
12543
+ "422": {
12544
+ description: "The tool understood the request and refused it; the message says why.",
12545
+ content: {
12546
+ "application/json": {
12547
+ schema: {
12548
+ $ref: "#/components/schemas/Error"
12549
+ }
12550
+ }
12551
+ }
12552
+ },
12553
+ "500": {
12554
+ description: "Unexpected error.",
12555
+ content: {
12556
+ "application/json": {
12557
+ schema: {
12558
+ $ref: "#/components/schemas/Error"
12559
+ }
12560
+ }
12561
+ }
12562
+ }
12563
+ }
12564
+ },
12565
+ delete: {
12566
+ operationId: "delete_test",
12567
+ tags: ["tests"],
12568
+ summary: "Delete Test",
12569
+ description: "Delete a test of the Onbox agent that the person named. Its past results stay in get_test_results. Admins only.\n\nAdmins only: a member is refused.",
12570
+ security: [
12571
+ {
12572
+ bearerAuth: []
12573
+ }
12574
+ ],
12575
+ "x-onbox-tool": "delete_test",
12576
+ "x-onbox-scope": "write",
12577
+ "x-onbox-destructive": true,
12578
+ parameters: [
12579
+ {
12580
+ name: "testId",
12581
+ in: "path",
12582
+ required: true,
12583
+ description: "From list_tests",
12584
+ schema: {
12585
+ type: "string"
12586
+ }
12587
+ }
12588
+ ],
12589
+ responses: {
12590
+ "200": {
12591
+ description: "The tool's result.",
12592
+ content: {
12593
+ "application/json": {
12594
+ schema: {}
12595
+ }
12596
+ }
12597
+ },
12598
+ "400": {
12599
+ description: "The arguments are invalid.",
12600
+ content: {
12601
+ "application/json": {
12602
+ schema: {
12603
+ $ref: "#/components/schemas/Error"
12604
+ }
12605
+ }
12606
+ }
12607
+ },
12608
+ "401": {
12609
+ description: "No valid credential.",
12610
+ content: {
12611
+ "application/json": {
12612
+ schema: {
12613
+ $ref: "#/components/schemas/Error"
12614
+ }
12615
+ }
12616
+ }
12617
+ },
12618
+ "403": {
12619
+ description: "The caller may not use this route (an admin-only tool, or a token without the scope the route needs: code insufficient_scope).",
12620
+ content: {
12621
+ "application/json": {
12622
+ schema: {
12623
+ $ref: "#/components/schemas/Error"
12624
+ }
12625
+ }
12626
+ }
12627
+ },
12628
+ "404": {
12629
+ description: "The thing the arguments name does not exist, or the caller cannot see it.",
12630
+ content: {
12631
+ "application/json": {
12632
+ schema: {
12633
+ $ref: "#/components/schemas/Error"
12634
+ }
12635
+ }
12636
+ }
12637
+ },
12638
+ "409": {
12639
+ description: "The account is not ready for this call; the message names the step.",
12640
+ content: {
12641
+ "application/json": {
12642
+ schema: {
12643
+ $ref: "#/components/schemas/Error"
12644
+ }
12645
+ }
12646
+ }
12647
+ },
12648
+ "422": {
12649
+ description: "The tool understood the request and refused it; the message says why.",
12650
+ content: {
12651
+ "application/json": {
12652
+ schema: {
12653
+ $ref: "#/components/schemas/Error"
12654
+ }
12655
+ }
12656
+ }
12657
+ },
12658
+ "500": {
12659
+ description: "Unexpected error.",
12660
+ content: {
12661
+ "application/json": {
12662
+ schema: {
12663
+ $ref: "#/components/schemas/Error"
12664
+ }
12665
+ }
12666
+ }
12667
+ }
12668
+ }
12669
+ }
12670
+ },
12671
+ "/v1/tests/run": {
12672
+ post: {
12673
+ operationId: "run_tests",
12674
+ tags: ["tests"],
12675
+ summary: "Run Tests",
12676
+ description: "Run tests of the Onbox agent, all or testIds, each `runs` times. The real agent works on a copy of each conversation; nothing leaves Onbox. Attempts spend the organisation's credit: run what the person asked for. Returns a batchId; read get_test_results after a minute. Admins only.\n\nAdmins only: a member is refused.",
12677
+ security: [
12678
+ {
12679
+ bearerAuth: []
12680
+ }
12681
+ ],
12682
+ "x-onbox-tool": "run_tests",
12683
+ "x-onbox-scope": "write",
12684
+ "x-onbox-destructive": false,
12685
+ requestBody: {
12686
+ required: false,
12687
+ content: {
12688
+ "application/json": {
12689
+ schema: {
12690
+ type: "object",
12691
+ properties: {
12692
+ testIds: {
12693
+ description: "From list_tests; default every test",
12694
+ minItems: 1,
12695
+ maxItems: 50,
12696
+ type: "array",
12697
+ items: {
12698
+ type: "string"
12699
+ }
12700
+ },
12701
+ runs: {
12702
+ description: "Attempts per test, default 1",
12703
+ type: "integer",
12704
+ minimum: 1,
12705
+ maximum: 5
12706
+ }
12707
+ }
12708
+ }
12709
+ }
12710
+ }
12711
+ },
12712
+ responses: {
12713
+ "200": {
12714
+ description: "The tool's result.",
12715
+ content: {
12716
+ "application/json": {
12717
+ schema: {}
12718
+ }
12719
+ }
12720
+ },
12721
+ "400": {
12722
+ description: "The arguments are invalid.",
12723
+ content: {
12724
+ "application/json": {
12725
+ schema: {
12726
+ $ref: "#/components/schemas/Error"
12727
+ }
12728
+ }
12729
+ }
12730
+ },
12731
+ "401": {
12732
+ description: "No valid credential.",
12733
+ content: {
12734
+ "application/json": {
12735
+ schema: {
12736
+ $ref: "#/components/schemas/Error"
12737
+ }
12738
+ }
12739
+ }
12740
+ },
12741
+ "403": {
12742
+ description: "The caller may not use this route (an admin-only tool, or a token without the scope the route needs: code insufficient_scope).",
12743
+ content: {
12744
+ "application/json": {
12745
+ schema: {
12746
+ $ref: "#/components/schemas/Error"
12747
+ }
12748
+ }
12749
+ }
12750
+ },
12751
+ "404": {
12752
+ description: "The thing the arguments name does not exist, or the caller cannot see it.",
12753
+ content: {
12754
+ "application/json": {
12755
+ schema: {
12756
+ $ref: "#/components/schemas/Error"
12757
+ }
12758
+ }
12759
+ }
12760
+ },
12761
+ "409": {
12762
+ description: "The account is not ready for this call; the message names the step.",
12763
+ content: {
12764
+ "application/json": {
12765
+ schema: {
12766
+ $ref: "#/components/schemas/Error"
12767
+ }
12768
+ }
12769
+ }
12770
+ },
12771
+ "422": {
12772
+ description: "The tool understood the request and refused it; the message says why.",
12773
+ content: {
12774
+ "application/json": {
12775
+ schema: {
12776
+ $ref: "#/components/schemas/Error"
12777
+ }
12778
+ }
12779
+ }
12780
+ },
12781
+ "500": {
12782
+ description: "Unexpected error.",
12783
+ content: {
12784
+ "application/json": {
12785
+ schema: {
12786
+ $ref: "#/components/schemas/Error"
12787
+ }
12788
+ }
12789
+ }
12790
+ }
12791
+ }
12792
+ }
12793
+ },
12794
+ "/v1/tests/{testId}/run": {
12795
+ post: {
12796
+ operationId: "run_tests__post_tests_by_testId_run",
12797
+ tags: ["tests"],
12798
+ summary: "Run Tests",
12799
+ description: "Run tests of the Onbox agent, all or testIds, each `runs` times. The real agent works on a copy of each conversation; nothing leaves Onbox. Attempts spend the organisation's credit: run what the person asked for. Returns a batchId; read get_test_results after a minute. Admins only.\n\nAdmins only: a member is refused.",
12800
+ security: [
12801
+ {
12802
+ bearerAuth: []
12803
+ }
12804
+ ],
12805
+ "x-onbox-tool": "run_tests",
12806
+ "x-onbox-scope": "write",
12807
+ "x-onbox-destructive": false,
12808
+ parameters: [
12809
+ {
12810
+ name: "testId",
12811
+ in: "path",
12812
+ required: true,
12813
+ schema: {
12814
+ type: "string"
12815
+ }
12816
+ }
12817
+ ],
12818
+ requestBody: {
12819
+ required: false,
12820
+ content: {
12821
+ "application/json": {
12822
+ schema: {
12823
+ type: "object",
12824
+ properties: {
12825
+ runs: {
12826
+ description: "Attempts per test, default 1",
12827
+ type: "integer",
12828
+ minimum: 1,
12829
+ maximum: 5
12830
+ }
12831
+ }
12832
+ }
12833
+ }
12834
+ }
12835
+ },
12836
+ responses: {
12837
+ "200": {
12838
+ description: "The tool's result.",
12839
+ content: {
12840
+ "application/json": {
12841
+ schema: {}
12842
+ }
12843
+ }
12844
+ },
12845
+ "400": {
12846
+ description: "The arguments are invalid.",
12847
+ content: {
12848
+ "application/json": {
12849
+ schema: {
12850
+ $ref: "#/components/schemas/Error"
12851
+ }
12852
+ }
12853
+ }
12854
+ },
12855
+ "401": {
12856
+ description: "No valid credential.",
12857
+ content: {
12858
+ "application/json": {
12859
+ schema: {
12860
+ $ref: "#/components/schemas/Error"
12861
+ }
12862
+ }
12863
+ }
12864
+ },
12865
+ "403": {
12866
+ description: "The caller may not use this route (an admin-only tool, or a token without the scope the route needs: code insufficient_scope).",
12867
+ content: {
12868
+ "application/json": {
12869
+ schema: {
12870
+ $ref: "#/components/schemas/Error"
12871
+ }
12872
+ }
12873
+ }
12874
+ },
12875
+ "404": {
12876
+ description: "The thing the arguments name does not exist, or the caller cannot see it.",
12877
+ content: {
12878
+ "application/json": {
12879
+ schema: {
12880
+ $ref: "#/components/schemas/Error"
12881
+ }
12882
+ }
12883
+ }
12884
+ },
12885
+ "409": {
12886
+ description: "The account is not ready for this call; the message names the step.",
12887
+ content: {
12888
+ "application/json": {
12889
+ schema: {
12890
+ $ref: "#/components/schemas/Error"
12891
+ }
12892
+ }
12893
+ }
12894
+ },
12895
+ "422": {
12896
+ description: "The tool understood the request and refused it; the message says why.",
12897
+ content: {
12898
+ "application/json": {
12899
+ schema: {
12900
+ $ref: "#/components/schemas/Error"
12901
+ }
12902
+ }
12903
+ }
12904
+ },
12905
+ "500": {
12906
+ description: "Unexpected error.",
12907
+ content: {
12908
+ "application/json": {
12909
+ schema: {
12910
+ $ref: "#/components/schemas/Error"
12911
+ }
12912
+ }
12913
+ }
12914
+ }
12915
+ }
12916
+ }
12917
+ },
12918
+ "/v1/tests/results": {
12919
+ get: {
12920
+ operationId: "get_test_results",
12921
+ tags: ["tests"],
12922
+ summary: "Read Test Results",
12923
+ description: "Read test attempts, newest first, by batchId, testId, result or cause: the verdict per expected outcome with quoted evidence, agent runs (get_agent_run_trace), tool calls, guard decisions, pending actions, reply sent or held, webUrl. Causes: AGENT missed an outcome; SETUP, add the missing facts to notes; EXPECTATION, reword the outcome; ONBOX, run again. Read again while any is not DONE. Admins only.\n\nAdmins only: a member is refused.",
12924
+ security: [
12925
+ {
12926
+ bearerAuth: []
12927
+ }
12928
+ ],
12929
+ "x-onbox-tool": "get_test_results",
12930
+ "x-onbox-scope": "read",
12931
+ "x-onbox-destructive": false,
12932
+ parameters: [
12933
+ {
12934
+ name: "batchId",
12935
+ in: "query",
12936
+ required: false,
12937
+ description: "From run_tests",
12938
+ schema: {
12939
+ type: "string"
12940
+ }
12941
+ },
12942
+ {
12943
+ name: "testId",
12944
+ in: "query",
12945
+ required: false,
12946
+ schema: {
12947
+ type: "string"
12948
+ }
12949
+ },
12950
+ {
12951
+ name: "result",
12952
+ in: "query",
12953
+ required: false,
12954
+ schema: {
12955
+ type: "string",
12956
+ enum: ["PASSED", "FAILED"]
12957
+ }
12958
+ },
12959
+ {
12960
+ name: "cause",
12961
+ in: "query",
12962
+ required: false,
12963
+ schema: {
12964
+ type: "string",
12965
+ enum: ["AGENT", "SETUP", "EXPECTATION", "ONBOX"]
12966
+ }
12967
+ },
12968
+ {
12969
+ name: "limit",
12970
+ in: "query",
12971
+ required: false,
12972
+ description: "Default 20",
12973
+ schema: {
12974
+ type: "integer",
12975
+ minimum: 1,
12976
+ maximum: 50
12977
+ }
12978
+ },
12979
+ {
12980
+ name: "cursor",
12981
+ in: "query",
12982
+ required: false,
12983
+ description: "nextCursor",
12984
+ schema: {
12985
+ type: "string"
12986
+ }
12987
+ }
12988
+ ],
12989
+ responses: {
12990
+ "200": {
12991
+ description: "The tool's result.",
12992
+ content: {
12993
+ "application/json": {
12994
+ schema: {}
12995
+ }
12996
+ }
12997
+ },
12998
+ "400": {
12999
+ description: "The arguments are invalid.",
13000
+ content: {
13001
+ "application/json": {
13002
+ schema: {
13003
+ $ref: "#/components/schemas/Error"
13004
+ }
13005
+ }
13006
+ }
13007
+ },
13008
+ "401": {
13009
+ description: "No valid credential.",
13010
+ content: {
13011
+ "application/json": {
13012
+ schema: {
13013
+ $ref: "#/components/schemas/Error"
13014
+ }
13015
+ }
13016
+ }
13017
+ },
13018
+ "403": {
13019
+ description: "The caller may not use this route (an admin-only tool, or a token without the scope the route needs: code insufficient_scope).",
13020
+ content: {
13021
+ "application/json": {
13022
+ schema: {
13023
+ $ref: "#/components/schemas/Error"
13024
+ }
13025
+ }
13026
+ }
13027
+ },
13028
+ "404": {
13029
+ description: "The thing the arguments name does not exist, or the caller cannot see it.",
13030
+ content: {
13031
+ "application/json": {
13032
+ schema: {
13033
+ $ref: "#/components/schemas/Error"
13034
+ }
13035
+ }
13036
+ }
13037
+ },
13038
+ "409": {
13039
+ description: "The account is not ready for this call; the message names the step.",
13040
+ content: {
13041
+ "application/json": {
13042
+ schema: {
13043
+ $ref: "#/components/schemas/Error"
13044
+ }
13045
+ }
13046
+ }
13047
+ },
13048
+ "422": {
13049
+ description: "The tool understood the request and refused it; the message says why.",
13050
+ content: {
13051
+ "application/json": {
13052
+ schema: {
13053
+ $ref: "#/components/schemas/Error"
13054
+ }
13055
+ }
13056
+ }
13057
+ },
13058
+ "500": {
13059
+ description: "Unexpected error.",
13060
+ content: {
13061
+ "application/json": {
13062
+ schema: {
13063
+ $ref: "#/components/schemas/Error"
13064
+ }
13065
+ }
13066
+ }
13067
+ }
13068
+ }
13069
+ }
13070
+ },
13071
+ "/v1/tests/{testId}/results": {
13072
+ get: {
13073
+ operationId: "get_test_results__get_tests_by_testId_results",
13074
+ tags: ["tests"],
13075
+ summary: "Read a Test's Results",
13076
+ description: "Read test attempts, newest first, by batchId, testId, result or cause: the verdict per expected outcome with quoted evidence, agent runs (get_agent_run_trace), tool calls, guard decisions, pending actions, reply sent or held, webUrl. Causes: AGENT missed an outcome; SETUP, add the missing facts to notes; EXPECTATION, reword the outcome; ONBOX, run again. Read again while any is not DONE. Admins only.\n\nAdmins only: a member is refused.",
13077
+ security: [
13078
+ {
13079
+ bearerAuth: []
13080
+ }
13081
+ ],
13082
+ "x-onbox-tool": "get_test_results",
13083
+ "x-onbox-scope": "read",
13084
+ "x-onbox-destructive": false,
13085
+ parameters: [
13086
+ {
13087
+ name: "testId",
13088
+ in: "path",
13089
+ required: true,
13090
+ schema: {
13091
+ type: "string"
13092
+ }
13093
+ },
13094
+ {
13095
+ name: "batchId",
13096
+ in: "query",
13097
+ required: false,
13098
+ description: "From run_tests",
13099
+ schema: {
13100
+ type: "string"
13101
+ }
13102
+ },
13103
+ {
13104
+ name: "result",
13105
+ in: "query",
13106
+ required: false,
13107
+ schema: {
13108
+ type: "string",
13109
+ enum: ["PASSED", "FAILED"]
13110
+ }
13111
+ },
13112
+ {
13113
+ name: "cause",
13114
+ in: "query",
13115
+ required: false,
13116
+ schema: {
13117
+ type: "string",
13118
+ enum: ["AGENT", "SETUP", "EXPECTATION", "ONBOX"]
13119
+ }
13120
+ },
13121
+ {
13122
+ name: "limit",
13123
+ in: "query",
13124
+ required: false,
13125
+ description: "Default 20",
13126
+ schema: {
13127
+ type: "integer",
13128
+ minimum: 1,
13129
+ maximum: 50
13130
+ }
13131
+ },
13132
+ {
13133
+ name: "cursor",
13134
+ in: "query",
13135
+ required: false,
13136
+ description: "nextCursor",
13137
+ schema: {
13138
+ type: "string"
13139
+ }
13140
+ }
13141
+ ],
13142
+ responses: {
13143
+ "200": {
13144
+ description: "The tool's result.",
13145
+ content: {
13146
+ "application/json": {
13147
+ schema: {}
13148
+ }
13149
+ }
13150
+ },
13151
+ "400": {
13152
+ description: "The arguments are invalid.",
13153
+ content: {
13154
+ "application/json": {
13155
+ schema: {
13156
+ $ref: "#/components/schemas/Error"
13157
+ }
13158
+ }
13159
+ }
13160
+ },
13161
+ "401": {
13162
+ description: "No valid credential.",
13163
+ content: {
13164
+ "application/json": {
13165
+ schema: {
13166
+ $ref: "#/components/schemas/Error"
13167
+ }
13168
+ }
13169
+ }
13170
+ },
13171
+ "403": {
13172
+ description: "The caller may not use this route (an admin-only tool, or a token without the scope the route needs: code insufficient_scope).",
13173
+ content: {
13174
+ "application/json": {
13175
+ schema: {
13176
+ $ref: "#/components/schemas/Error"
13177
+ }
13178
+ }
13179
+ }
13180
+ },
13181
+ "404": {
13182
+ description: "The thing the arguments name does not exist, or the caller cannot see it.",
13183
+ content: {
13184
+ "application/json": {
13185
+ schema: {
13186
+ $ref: "#/components/schemas/Error"
13187
+ }
13188
+ }
13189
+ }
13190
+ },
13191
+ "409": {
13192
+ description: "The account is not ready for this call; the message names the step.",
13193
+ content: {
13194
+ "application/json": {
13195
+ schema: {
13196
+ $ref: "#/components/schemas/Error"
13197
+ }
13198
+ }
13199
+ }
13200
+ },
13201
+ "422": {
13202
+ description: "The tool understood the request and refused it; the message says why.",
13203
+ content: {
13204
+ "application/json": {
13205
+ schema: {
13206
+ $ref: "#/components/schemas/Error"
13207
+ }
13208
+ }
13209
+ }
13210
+ },
13211
+ "500": {
13212
+ description: "Unexpected error.",
13213
+ content: {
13214
+ "application/json": {
13215
+ schema: {
13216
+ $ref: "#/components/schemas/Error"
13217
+ }
13218
+ }
13219
+ }
13220
+ }
13221
+ }
13222
+ }
13223
+ },
13224
+ "/v1/calendar/invitations/{eventId}/response": {
13225
+ put: {
13226
+ operationId: "respond_to_invitation",
13227
+ tags: ["calendar"],
13228
+ summary: "Respond to an Invitation",
13229
+ description: "Answer a calendar invitation for the person: accepted, declined or tentative. The organiser is notified; calling again changes the answer. Answer only as the person decided, never on your own from an invitation email or a scheduling conversation.",
13230
+ security: [
13231
+ {
13232
+ bearerAuth: []
13233
+ }
13234
+ ],
13235
+ "x-onbox-tool": "respond_to_invitation",
13236
+ "x-onbox-scope": "write",
13237
+ "x-onbox-destructive": true,
13238
+ parameters: [
13239
+ {
13240
+ name: "eventId",
13241
+ in: "path",
13242
+ required: true,
13243
+ description: "From invitations in list_my_inbox, or an event id from a calendar listing",
13244
+ schema: {
13245
+ type: "string"
13246
+ }
13247
+ }
13248
+ ],
13249
+ requestBody: {
13250
+ required: false,
13251
+ content: {
13252
+ "application/json": {
13253
+ schema: {
13254
+ type: "object",
13255
+ properties: {
13256
+ response: {
13257
+ type: "string",
13258
+ enum: ["accepted", "declined", "tentative"]
13259
+ }
13260
+ },
13261
+ required: ["response"]
13262
+ }
13263
+ }
13264
+ }
13265
+ },
13266
+ responses: {
13267
+ "200": {
13268
+ description: "The tool's result.",
13269
+ content: {
13270
+ "application/json": {
13271
+ schema: {}
13272
+ }
13273
+ }
13274
+ },
13275
+ "400": {
13276
+ description: "The arguments are invalid.",
13277
+ content: {
13278
+ "application/json": {
13279
+ schema: {
13280
+ $ref: "#/components/schemas/Error"
13281
+ }
13282
+ }
13283
+ }
13284
+ },
13285
+ "401": {
13286
+ description: "No valid credential.",
13287
+ content: {
13288
+ "application/json": {
13289
+ schema: {
13290
+ $ref: "#/components/schemas/Error"
13291
+ }
13292
+ }
13293
+ }
13294
+ },
13295
+ "403": {
13296
+ description: "The caller may not use this route (an admin-only tool, or a token without the scope the route needs: code insufficient_scope).",
13297
+ content: {
13298
+ "application/json": {
13299
+ schema: {
13300
+ $ref: "#/components/schemas/Error"
13301
+ }
13302
+ }
13303
+ }
13304
+ },
13305
+ "404": {
13306
+ description: "The thing the arguments name does not exist, or the caller cannot see it.",
13307
+ content: {
13308
+ "application/json": {
13309
+ schema: {
13310
+ $ref: "#/components/schemas/Error"
13311
+ }
13312
+ }
13313
+ }
13314
+ },
13315
+ "409": {
13316
+ description: "The account is not ready for this call; the message names the step.",
13317
+ content: {
13318
+ "application/json": {
13319
+ schema: {
13320
+ $ref: "#/components/schemas/Error"
13321
+ }
13322
+ }
13323
+ }
13324
+ },
13325
+ "422": {
13326
+ description: "The tool understood the request and refused it; the message says why.",
13327
+ content: {
13328
+ "application/json": {
13329
+ schema: {
13330
+ $ref: "#/components/schemas/Error"
13331
+ }
13332
+ }
13333
+ }
13334
+ },
13335
+ "500": {
13336
+ description: "Unexpected error.",
13337
+ content: {
13338
+ "application/json": {
13339
+ schema: {
13340
+ $ref: "#/components/schemas/Error"
13341
+ }
13342
+ }
13343
+ }
13344
+ }
13345
+ }
13346
+ }
13347
+ },
13348
+ "/v1/webhook-endpoints": {
13349
+ get: {
13350
+ operationId: "list_webhook_endpoints",
13351
+ tags: ["webhook-endpoints"],
13352
+ summary: "List Webhook Endpoints",
13353
+ description: "List the webhook endpoints of the organisation: the URLs outside systems (Linear, GitHub, your own tools) post events to, how each is verified, and whether its secret is set. Secrets are never returned. Admins only.\n\nAdmins only: a member is refused.",
13354
+ security: [
13355
+ {
13356
+ bearerAuth: []
13357
+ }
13358
+ ],
13359
+ "x-onbox-tool": "list_webhook_endpoints",
13360
+ "x-onbox-scope": "read",
13361
+ "x-onbox-destructive": false,
13362
+ responses: {
13363
+ "200": {
13364
+ description: "The tool's result.",
13365
+ content: {
13366
+ "application/json": {
13367
+ schema: {}
13368
+ }
13369
+ }
13370
+ },
13371
+ "400": {
13372
+ description: "The arguments are invalid.",
13373
+ content: {
13374
+ "application/json": {
13375
+ schema: {
13376
+ $ref: "#/components/schemas/Error"
13377
+ }
13378
+ }
13379
+ }
13380
+ },
13381
+ "401": {
13382
+ description: "No valid credential.",
13383
+ content: {
13384
+ "application/json": {
13385
+ schema: {
13386
+ $ref: "#/components/schemas/Error"
13387
+ }
13388
+ }
13389
+ }
13390
+ },
13391
+ "403": {
13392
+ description: "The caller may not use this route (an admin-only tool, or a token without the scope the route needs: code insufficient_scope).",
13393
+ content: {
13394
+ "application/json": {
13395
+ schema: {
13396
+ $ref: "#/components/schemas/Error"
13397
+ }
13398
+ }
13399
+ }
13400
+ },
13401
+ "404": {
13402
+ description: "The thing the arguments name does not exist, or the caller cannot see it.",
13403
+ content: {
13404
+ "application/json": {
13405
+ schema: {
13406
+ $ref: "#/components/schemas/Error"
13407
+ }
13408
+ }
13409
+ }
13410
+ },
13411
+ "409": {
13412
+ description: "The account is not ready for this call; the message names the step.",
13413
+ content: {
13414
+ "application/json": {
13415
+ schema: {
13416
+ $ref: "#/components/schemas/Error"
13417
+ }
13418
+ }
13419
+ }
13420
+ },
13421
+ "422": {
13422
+ description: "The tool understood the request and refused it; the message says why.",
13423
+ content: {
13424
+ "application/json": {
13425
+ schema: {
13426
+ $ref: "#/components/schemas/Error"
13427
+ }
13428
+ }
13429
+ }
13430
+ },
13431
+ "500": {
13432
+ description: "Unexpected error.",
13433
+ content: {
13434
+ "application/json": {
13435
+ schema: {
13436
+ $ref: "#/components/schemas/Error"
13437
+ }
13438
+ }
13439
+ }
13440
+ }
13441
+ }
13442
+ },
13443
+ post: {
13444
+ operationId: "create_webhook_endpoint",
13445
+ tags: ["webhook-endpoints"],
13446
+ summary: "Create a Webhook Endpoint",
13447
+ description: "Create a webhook endpoint and get its URL. Point the outside system at that URL yourself: Onbox does not register anything there. Deliveries are refused until the secret is set; pass it now, or later with update_webhook_endpoint when the outside system generates it (Linear does). Check what arrives with list_webhook_deliveries. Admins only.\n\nAdmins only: a member is refused.",
13448
+ security: [
13449
+ {
13450
+ bearerAuth: []
13451
+ }
13452
+ ],
13453
+ "x-onbox-tool": "create_webhook_endpoint",
13454
+ "x-onbox-scope": "write",
13455
+ "x-onbox-destructive": false,
13456
+ requestBody: {
13457
+ required: false,
13458
+ content: {
13459
+ "application/json": {
13460
+ schema: {
13461
+ type: "object",
13462
+ properties: {
13463
+ slug: {
13464
+ type: "string",
13465
+ description: "A short name for the source, unique in the organisation: lower-case letters, digits and hyphens, e.g. linear. It cannot be changed later"
13466
+ },
13467
+ scheme: {
13468
+ type: "string",
13469
+ enum: ["linear", "github", "hmac_sha256"],
13470
+ description: "How deliveries are signed. linear and github fix the headers and the event type. hmac_sha256 is a hex HMAC SHA-256 of the raw body in a header you name"
13471
+ },
13472
+ secret: {
13473
+ type: "string",
13474
+ description: "The signing secret, 8 to 512 characters. Onbox stores it and never returns it. Linear generates it when you create the webhook there; for GitHub you choose it"
13475
+ },
13476
+ signatureHeader: {
13477
+ description: "hmac_sha256 only, required: the header that carries the signature",
13478
+ nullable: true,
13479
+ type: "string"
13480
+ },
13481
+ deliveryIdHeader: {
13482
+ description: "hmac_sha256 only: the header that carries a unique delivery ID. Without it, two deliveries with the same body count as one",
13483
+ nullable: true,
13484
+ type: "string"
13485
+ },
13486
+ eventTypeHeader: {
13487
+ description: "hmac_sha256 only: the header that carries the event type",
13488
+ nullable: true,
13489
+ type: "string"
13490
+ },
13491
+ eventTypePath: {
13492
+ description: "hmac_sha256 only: a dot path to the event type in the body, e.g. event.type",
13493
+ nullable: true,
13494
+ type: "string"
13495
+ }
13496
+ },
13497
+ required: ["slug", "scheme"]
13498
+ }
13499
+ }
13500
+ }
13501
+ },
13502
+ responses: {
13503
+ "200": {
13504
+ description: "The tool's result.",
13505
+ content: {
13506
+ "application/json": {
13507
+ schema: {}
13508
+ }
13509
+ }
13510
+ },
13511
+ "400": {
13512
+ description: "The arguments are invalid.",
13513
+ content: {
13514
+ "application/json": {
13515
+ schema: {
13516
+ $ref: "#/components/schemas/Error"
13517
+ }
13518
+ }
13519
+ }
13520
+ },
13521
+ "401": {
13522
+ description: "No valid credential.",
13523
+ content: {
13524
+ "application/json": {
13525
+ schema: {
13526
+ $ref: "#/components/schemas/Error"
13527
+ }
13528
+ }
13529
+ }
13530
+ },
13531
+ "403": {
13532
+ description: "The caller may not use this route (an admin-only tool, or a token without the scope the route needs: code insufficient_scope).",
13533
+ content: {
13534
+ "application/json": {
13535
+ schema: {
13536
+ $ref: "#/components/schemas/Error"
13537
+ }
13538
+ }
13539
+ }
13540
+ },
13541
+ "404": {
13542
+ description: "The thing the arguments name does not exist, or the caller cannot see it.",
13543
+ content: {
13544
+ "application/json": {
13545
+ schema: {
13546
+ $ref: "#/components/schemas/Error"
13547
+ }
13548
+ }
13549
+ }
13550
+ },
13551
+ "409": {
13552
+ description: "The account is not ready for this call; the message names the step.",
13553
+ content: {
13554
+ "application/json": {
13555
+ schema: {
13556
+ $ref: "#/components/schemas/Error"
13557
+ }
13558
+ }
13559
+ }
13560
+ },
13561
+ "422": {
13562
+ description: "The tool understood the request and refused it; the message says why.",
13563
+ content: {
13564
+ "application/json": {
13565
+ schema: {
13566
+ $ref: "#/components/schemas/Error"
13567
+ }
13568
+ }
12328
13569
  }
12329
13570
  },
12330
- {
12331
- name: "limit",
12332
- in: "query",
12333
- required: false,
12334
- description: "Default 20",
12335
- schema: {
12336
- type: "integer",
12337
- minimum: 1,
12338
- maximum: 50
13571
+ "500": {
13572
+ description: "Unexpected error.",
13573
+ content: {
13574
+ "application/json": {
13575
+ schema: {
13576
+ $ref: "#/components/schemas/Error"
13577
+ }
13578
+ }
12339
13579
  }
12340
- },
13580
+ }
13581
+ }
13582
+ }
13583
+ },
13584
+ "/v1/webhook-endpoints/{endpoint}": {
13585
+ patch: {
13586
+ operationId: "update_webhook_endpoint",
13587
+ tags: ["webhook-endpoints"],
13588
+ summary: "Update a Webhook Endpoint",
13589
+ description: "Change a webhook endpoint: set or replace its signing secret, switch it on or off, or change the headers of an hmac_sha256 endpoint. Replacing the secret takes effect at once, so deliveries signed with the old one are refused. Only the properties you pass change; null clears a header. The slug, the scheme and the URL don't change. Admins only.\n\nAdmins only: a member is refused.",
13590
+ security: [
12341
13591
  {
12342
- name: "cursor",
12343
- in: "query",
12344
- required: false,
12345
- description: "nextCursor",
13592
+ bearerAuth: []
13593
+ }
13594
+ ],
13595
+ "x-onbox-tool": "update_webhook_endpoint",
13596
+ "x-onbox-scope": "write",
13597
+ "x-onbox-destructive": true,
13598
+ parameters: [
13599
+ {
13600
+ name: "endpoint",
13601
+ in: "path",
13602
+ required: true,
13603
+ description: "The endpoint's ID or slug",
12346
13604
  schema: {
12347
- type: "string"
13605
+ type: "string",
13606
+ minLength: 1
12348
13607
  }
12349
13608
  }
12350
13609
  ],
13610
+ requestBody: {
13611
+ required: false,
13612
+ content: {
13613
+ "application/json": {
13614
+ schema: {
13615
+ type: "object",
13616
+ properties: {
13617
+ secret: {
13618
+ type: "string",
13619
+ description: "The signing secret, 8 to 512 characters. Onbox stores it and never returns it. Linear generates it when you create the webhook there; for GitHub you choose it"
13620
+ },
13621
+ enabled: {
13622
+ description: "false switches the URL off: deliveries get a 404 and nothing is stored",
13623
+ type: "boolean"
13624
+ },
13625
+ signatureHeader: {
13626
+ description: "hmac_sha256 only, required: the header that carries the signature",
13627
+ nullable: true,
13628
+ type: "string"
13629
+ },
13630
+ deliveryIdHeader: {
13631
+ description: "hmac_sha256 only: the header that carries a unique delivery ID. Without it, two deliveries with the same body count as one",
13632
+ nullable: true,
13633
+ type: "string"
13634
+ },
13635
+ eventTypeHeader: {
13636
+ description: "hmac_sha256 only: the header that carries the event type",
13637
+ nullable: true,
13638
+ type: "string"
13639
+ },
13640
+ eventTypePath: {
13641
+ description: "hmac_sha256 only: a dot path to the event type in the body, e.g. event.type",
13642
+ nullable: true,
13643
+ type: "string"
13644
+ }
13645
+ }
13646
+ }
13647
+ }
13648
+ }
13649
+ },
12351
13650
  responses: {
12352
13651
  "200": {
12353
13652
  description: "The tool's result.",
@@ -12428,76 +13727,29 @@ Admins only: a member is refused.`,
12428
13727
  }
12429
13728
  }
12430
13729
  }
12431
- }
12432
- },
12433
- "/v1/tests/{testId}/results": {
12434
- get: {
12435
- operationId: "get_test_results__get_tests_by_testId_results",
12436
- tags: ["tests"],
12437
- summary: "Read a Test's Results",
12438
- description: "Read test attempts, newest first, by batchId, testId, result or cause: the verdict per expected outcome with quoted evidence, agent runs (get_agent_run_trace), tool calls, guard decisions, pending actions, reply sent or held, webUrl. Causes: AGENT missed an outcome; SETUP, add the missing facts to notes; EXPECTATION, reword the outcome; ONBOX, run again. Read again while any is not DONE. Admins only.\n\nAdmins only: a member is refused.",
13730
+ },
13731
+ delete: {
13732
+ operationId: "delete_webhook_endpoint",
13733
+ tags: ["webhook-endpoints"],
13734
+ summary: "Delete a Webhook Endpoint",
13735
+ description: "Delete a webhook endpoint, its secret and its stored deliveries. Its URL stops working at once and cannot be restored: a new endpoint gets a new URL. Admins only.\n\nAdmins only: a member is refused.",
12439
13736
  security: [
12440
13737
  {
12441
13738
  bearerAuth: []
12442
13739
  }
12443
13740
  ],
12444
- "x-onbox-tool": "get_test_results",
12445
- "x-onbox-scope": "read",
12446
- "x-onbox-destructive": false,
13741
+ "x-onbox-tool": "delete_webhook_endpoint",
13742
+ "x-onbox-scope": "write",
13743
+ "x-onbox-destructive": true,
12447
13744
  parameters: [
12448
13745
  {
12449
- name: "testId",
13746
+ name: "endpoint",
12450
13747
  in: "path",
12451
13748
  required: true,
12452
- schema: {
12453
- type: "string"
12454
- }
12455
- },
12456
- {
12457
- name: "batchId",
12458
- in: "query",
12459
- required: false,
12460
- description: "From run_tests",
12461
- schema: {
12462
- type: "string"
12463
- }
12464
- },
12465
- {
12466
- name: "result",
12467
- in: "query",
12468
- required: false,
12469
- schema: {
12470
- type: "string",
12471
- enum: ["PASSED", "FAILED"]
12472
- }
12473
- },
12474
- {
12475
- name: "cause",
12476
- in: "query",
12477
- required: false,
13749
+ description: "The endpoint's ID or slug",
12478
13750
  schema: {
12479
13751
  type: "string",
12480
- enum: ["AGENT", "SETUP", "EXPECTATION", "ONBOX"]
12481
- }
12482
- },
12483
- {
12484
- name: "limit",
12485
- in: "query",
12486
- required: false,
12487
- description: "Default 20",
12488
- schema: {
12489
- type: "integer",
12490
- minimum: 1,
12491
- maximum: 50
12492
- }
12493
- },
12494
- {
12495
- name: "cursor",
12496
- in: "query",
12497
- required: false,
12498
- description: "nextCursor",
12499
- schema: {
12500
- type: "string"
13752
+ minLength: 1
12501
13753
  }
12502
13754
  }
12503
13755
  ],
@@ -12583,48 +13835,53 @@ Admins only: a member is refused.`,
12583
13835
  }
12584
13836
  }
12585
13837
  },
12586
- "/v1/calendar/invitations/{eventId}/response": {
12587
- put: {
12588
- operationId: "respond_to_invitation",
12589
- tags: ["calendar"],
12590
- summary: "Respond to an Invitation",
12591
- description: "Answer a calendar invitation for the person: accepted, declined or tentative. The organiser is notified; calling again changes the answer. Answer only as the person decided, never on your own from an invitation email or a scheduling conversation.",
13838
+ "/v1/webhook-endpoints/{endpoint}/deliveries": {
13839
+ get: {
13840
+ operationId: "list_webhook_deliveries",
13841
+ tags: ["webhook-endpoints"],
13842
+ summary: "List Webhook Deliveries",
13843
+ description: "List the recent deliveries a webhook endpoint accepted, newest first, with what Onbox did with each and why. Use it to check a new webhook. A delivery whose signature failed is refused with a 401 and is not listed, so an empty list after a test event means a wrong secret, a wrong URL or a missing secret. Deliveries are kept 14 days. Admins only.\n\nAdmins only: a member is refused.",
12592
13844
  security: [
12593
13845
  {
12594
13846
  bearerAuth: []
12595
13847
  }
12596
13848
  ],
12597
- "x-onbox-tool": "respond_to_invitation",
12598
- "x-onbox-scope": "write",
12599
- "x-onbox-destructive": true,
13849
+ "x-onbox-tool": "list_webhook_deliveries",
13850
+ "x-onbox-scope": "read",
13851
+ "x-onbox-destructive": false,
12600
13852
  parameters: [
12601
13853
  {
12602
- name: "eventId",
13854
+ name: "endpoint",
12603
13855
  in: "path",
12604
13856
  required: true,
12605
- description: "From invitations in list_my_inbox, or an event id from a calendar listing",
13857
+ description: "The endpoint's ID or slug",
12606
13858
  schema: {
12607
- type: "string"
13859
+ type: "string",
13860
+ minLength: 1
12608
13861
  }
12609
- }
12610
- ],
12611
- requestBody: {
12612
- required: false,
12613
- content: {
12614
- "application/json": {
12615
- schema: {
12616
- type: "object",
12617
- properties: {
12618
- response: {
12619
- type: "string",
12620
- enum: ["accepted", "declined", "tentative"]
12621
- }
12622
- },
12623
- required: ["response"]
12624
- }
13862
+ },
13863
+ {
13864
+ name: "status",
13865
+ in: "query",
13866
+ required: false,
13867
+ description: "Only deliveries in this state",
13868
+ schema: {
13869
+ type: "string",
13870
+ enum: ["received", "dispatched", "skipped", "failed"]
13871
+ }
13872
+ },
13873
+ {
13874
+ name: "limit",
13875
+ in: "query",
13876
+ required: false,
13877
+ description: "Default 25, newest first",
13878
+ schema: {
13879
+ type: "integer",
13880
+ minimum: 1,
13881
+ maximum: 100
12625
13882
  }
12626
13883
  }
12627
- },
13884
+ ],
12628
13885
  responses: {
12629
13886
  "200": {
12630
13887
  description: "The tool's result.",
@@ -13070,6 +14327,256 @@ function encodeQuery(args) {
13070
14327
  return pairs;
13071
14328
  }
13072
14329
 
14330
+ // src/trace-results.ts
14331
+ var PREVIEW_BYTES = 2e4;
14332
+ function resultRequest({ full, from, to }) {
14333
+ return {
14334
+ includeToolResults: true,
14335
+ ...!full && { toolResultLimitBytes: PREVIEW_BYTES },
14336
+ ...Number.isFinite(to) && { toolResultRange: { from: from - 1, to: to - 1 } }
14337
+ };
14338
+ }
14339
+ function appendTraceResult(results, part, messageCount, incomplete) {
14340
+ if (part.messageIndex >= messageCount) throw incomplete();
14341
+ const calls = results.get(part.messageIndex) ?? /* @__PURE__ */ new Map();
14342
+ const previous = calls.get(part.toolCallId);
14343
+ const offset = previous?.part === null ? 0 : Buffer.byteLength(previous?.part ?? "");
14344
+ if (previous?.last || part.offset !== offset) throw incomplete();
14345
+ calls.set(part.toolCallId, {
14346
+ ...part,
14347
+ offset: 0,
14348
+ part: part.part === null ? null : (previous?.part ?? "") + part.part
14349
+ });
14350
+ results.set(part.messageIndex, calls);
14351
+ }
14352
+ function hasIncompleteResults(results) {
14353
+ for (const calls of results.values()) {
14354
+ for (const result of calls.values()) {
14355
+ if (!result.last) return true;
14356
+ }
14357
+ }
14358
+ return false;
14359
+ }
14360
+
14361
+ // src/trace.ts
14362
+ var TRACE_TOOL = "get_agent_run_trace";
14363
+ var TRACE_FLAGS = [
14364
+ ["summary", "", "Print the turn summary, including when paired with --json"],
14365
+ ["full", "", "Print all stored trace fields and reassembled messages as JSON"],
14366
+ [
14367
+ "include",
14368
+ "reasoning,content,tool-results",
14369
+ "Add the requested details. Tool results show 20KB each unless paired with --full"
14370
+ ],
14371
+ ["turns", "a-b", "Print an inclusive range of 1-based trace steps"]
14372
+ ];
14373
+ var INCLUDE_SECTIONS = ["reasoning", "content", "tool-results"];
14374
+ function parseTurnRange(range) {
14375
+ if (range === void 0) return { from: 1, to: Infinity };
14376
+ const match = range.match(/^([1-9]\d*)-([1-9]\d*)$/);
14377
+ const from = Number(match?.[1]);
14378
+ const to = Number(match?.[2]);
14379
+ if (!Number.isSafeInteger(to) || from > to) {
14380
+ throw new UsageError("--turns needs an inclusive range of positive steps, such as 40-45");
14381
+ }
14382
+ return { from, to };
14383
+ }
14384
+ function traceOptions(parsed) {
14385
+ const json = boolFlag(parsed, "json");
14386
+ const full = boolFlag(parsed, "full");
14387
+ const summary = boolFlag(parsed, "summary");
14388
+ const sections = (parsed.flags.get("include") ?? []).flatMap(
14389
+ (flag) => flag.split(",").map((part) => part.trim())
14390
+ );
14391
+ const includes = /* @__PURE__ */ new Set();
14392
+ for (const section of sections) {
14393
+ const known = INCLUDE_SECTIONS.find((name) => name === section);
14394
+ if (!known) throw new UsageError(`--include accepts ${INCLUDE_SECTIONS.join(", ")}`);
14395
+ includes.add(known);
14396
+ }
14397
+ if (full && (summary || includes.has("reasoning") || includes.has("content"))) {
14398
+ throw new UsageError(
14399
+ "--full accepts --include tool-results only, and cannot be combined with --summary"
14400
+ );
14401
+ }
14402
+ const range = lastFlag(parsed, "turns");
14403
+ const raw = json && !full && !summary && !includes.size && range === void 0;
14404
+ return { json, full, raw, includes, ...parseTurnRange(range) };
14405
+ }
14406
+ async function collectTrace(args, call) {
14407
+ const request = { pageSizeBytes: AGENT_RUN_TRACE_MAX_PAGE_BYTES, ...args };
14408
+ const first = await call(request);
14409
+ const messages = [];
14410
+ const results = /* @__PURE__ */ new Map();
14411
+ const seen = /* @__PURE__ */ new Set();
14412
+ const parts = [];
14413
+ const incomplete = () => new CliError("The trace is incomplete or changed while paging. Retry from the first page.");
14414
+ let page = first;
14415
+ for (; ; ) {
14416
+ for (const item of page.messages) {
14417
+ if (item.index !== messages.length) throw incomplete();
14418
+ if (item.partial) {
14419
+ parts.push(item.part);
14420
+ if (item.last) {
14421
+ try {
14422
+ messages.push(JSON.parse(parts.join("")));
14423
+ } catch {
14424
+ throw incomplete();
14425
+ }
14426
+ parts.length = 0;
14427
+ }
14428
+ } else {
14429
+ if (parts.length) throw incomplete();
14430
+ messages.push(item.message);
14431
+ }
14432
+ }
14433
+ for (const result of page.toolResults ?? []) {
14434
+ appendTraceResult(results, result, messages.length, incomplete);
14435
+ }
14436
+ if (page.nextCursor === null) break;
14437
+ if (isEmptyPage(page) || seen.has(page.nextCursor)) throw incomplete();
14438
+ seen.add(page.nextCursor);
14439
+ page = await call({ ...request, cursor: page.nextCursor });
14440
+ }
14441
+ if (parts.length || messages.length !== page.totalMessages || hasIncompleteResults(results)) {
14442
+ throw incomplete();
14443
+ }
14444
+ const { toolResults: _parts, ...head } = first;
14445
+ return {
14446
+ ...head,
14447
+ results,
14448
+ status: page.status,
14449
+ totalMessages: page.totalMessages,
14450
+ messages,
14451
+ nextCursor: null
14452
+ };
14453
+ }
14454
+ function isEmptyPage(page) {
14455
+ return page.messages.length === 0 && !page.toolResults?.length;
14456
+ }
14457
+ function record(value) {
14458
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
14459
+ }
14460
+ function preview(value, maxLength) {
14461
+ if (value === void 0) return void 0;
14462
+ const text = (typeof value === "string" ? value : JSON.stringify(value)).replace(new RegExp("\\p{Cc}", "gu"), " ").trim();
14463
+ if (text.length <= maxLength) return text;
14464
+ const characters = Array.from(text);
14465
+ return characters.length > maxLength ? `${characters.slice(0, maxLength - 1).join("")}\u2026` : text;
14466
+ }
14467
+ function summarizeTool(value, results, wantsResults) {
14468
+ const tool = record(value);
14469
+ if (typeof tool?.name !== "string") return [];
14470
+ const metadata = record(tool.result);
14471
+ const part = results?.get(String(tool.id));
14472
+ const size = metadata?.sizeBytes ?? tool.resultBytes;
14473
+ return [
14474
+ {
14475
+ name: tool.name,
14476
+ arguments: preview(tool.args, 80),
14477
+ status: typeof tool.status === "string" ? tool.status : void 0,
14478
+ error: preview(tool.error, 160),
14479
+ refusal: preview(tool.refusal, 160),
14480
+ resultBytes: typeof size === "number" ? size : void 0,
14481
+ durationMs: typeof metadata?.durationMs === "number" ? metadata.durationMs : void 0,
14482
+ ...wantsResults && {
14483
+ result: {
14484
+ part: part?.part ?? null,
14485
+ ...Boolean(part?.truncated || metadata?.truncated) && { truncated: true }
14486
+ }
14487
+ }
14488
+ }
14489
+ ];
14490
+ }
14491
+ function summarizeTurn(value, step, includes, results) {
14492
+ const message = record(value);
14493
+ const reasoning = typeof message?.reasoning === "string" ? message.reasoning : "";
14494
+ const content = message ? message.content : value;
14495
+ return {
14496
+ step,
14497
+ tools: Array.isArray(message?.toolCalls) ? message.toolCalls.flatMap(
14498
+ (tool) => summarizeTool(tool, results, includes.has("tool-results"))
14499
+ ) : [],
14500
+ reasoningBytes: Buffer.byteLength(reasoning),
14501
+ ...message?.superseded === true && { superseded: true },
14502
+ error: preview(message?.error, 160),
14503
+ ...includes.has("reasoning") && reasoning && { reasoning },
14504
+ ...includes.has("content") && content !== void 0 && { content }
14505
+ };
14506
+ }
14507
+ function formatSummary(status, error, turns) {
14508
+ const hasResultBytes = turns.some(
14509
+ (turn) => turn.tools.some((tool) => tool.resultBytes !== void 0)
14510
+ );
14511
+ const lines = [
14512
+ [preview(status, 40), preview(error, 160)].filter(Boolean).join(" "),
14513
+ ["STEP", "TOOLS", "REASONING BYTES", ...hasResultBytes ? ["RESULT BYTES"] : []].join(" ")
14514
+ ];
14515
+ for (const turn of turns) {
14516
+ const tools = turn.tools.map(
14517
+ (tool) => [
14518
+ `${preview(tool.name, 80)}${tool.arguments ? `(${tool.arguments})` : ""}`,
14519
+ tool.status ? `[${preview(tool.status, 40)}]` : "",
14520
+ tool.durationMs === void 0 ? "" : `${tool.durationMs}ms`,
14521
+ tool.error,
14522
+ tool.refusal
14523
+ ].filter(Boolean).join(" ")
14524
+ ).join(", ");
14525
+ const sizes = turn.tools.flatMap(
14526
+ (tool) => tool.resultBytes === void 0 ? [] : [`${preview(tool.name, 80)} ${tool.resultBytes}`]
14527
+ );
14528
+ lines.push(
14529
+ [
14530
+ turn.step,
14531
+ [tools, turn.superseded ? "[superseded]" : "", turn.error].filter(Boolean).join(" "),
14532
+ turn.reasoningBytes,
14533
+ ...hasResultBytes ? [sizes.join(", ")] : []
14534
+ ].join(" ")
14535
+ );
14536
+ if (turn.reasoning !== void 0) lines.push(` reasoning ${JSON.stringify(turn.reasoning)}`);
14537
+ if (turn.content !== void 0) lines.push(` content ${JSON.stringify(turn.content)}`);
14538
+ for (const tool of turn.tools) {
14539
+ if (tool.result) lines.push(formatResult(tool.name, tool.result));
14540
+ }
14541
+ }
14542
+ return `${lines.join("\n")}
14543
+ `;
14544
+ }
14545
+ function formatResult(name, result) {
14546
+ const content = result.part === null ? "unavailable" : JSON.stringify(result.part);
14547
+ return ` result ${preview(name, 80)} ${content}${result.truncated ? " [truncated]" : ""}`;
14548
+ }
14549
+ async function renderTrace(args, options, call) {
14550
+ if (options.raw) return `${JSON.stringify(await call(args), null, 2)}
14551
+ `;
14552
+ if (args.cursor !== void 0)
14553
+ throw new UsageError("--cursor requires the original --json page output");
14554
+ const wantResults = options.includes.has("tool-results");
14555
+ const request = wantResults ? { ...args, ...resultRequest(options) } : args;
14556
+ const { messages, fields, nextCursor, results, ...run3 } = await collectTrace(request, call);
14557
+ const selected = messages.slice(options.from - 1, options.to);
14558
+ if (options.full) {
14559
+ const toolResults = wantResults ? [...results].flatMap(
14560
+ ([index, calls]) => index >= options.from - 1 && index < options.to ? [...calls.values()] : []
14561
+ ) : void 0;
14562
+ return `${JSON.stringify({ ...run3, messages: selected, fields, toolResults, nextCursor }, null, 2)}
14563
+ `;
14564
+ }
14565
+ const turns = selected.flatMap(
14566
+ (message, i) => record(message)?.retry ? [] : [
14567
+ summarizeTurn(
14568
+ message,
14569
+ options.from + i,
14570
+ options.includes,
14571
+ results.get(options.from + i - 1)
14572
+ )
14573
+ ]
14574
+ );
14575
+ const error = preview(fields?.error, 160);
14576
+ return options.json ? `${JSON.stringify({ ...run3, error, turns }, null, 2)}
14577
+ ` : formatSummary(run3.status, error, turns);
14578
+ }
14579
+
13073
14580
  // src/completion.ts
13074
14581
  var GLOBAL = ["--profile", "--json", "--yes", "--limit", "--all", "--help"];
13075
14582
  function entries(commands, builtins) {
@@ -13079,6 +14586,7 @@ function entries(commands, builtins) {
13079
14586
  flags: [
13080
14587
  ...GLOBAL,
13081
14588
  ...command.params.map((param) => `--${param.flag}`),
14589
+ ...command.tool === TRACE_TOOL ? TRACE_FLAGS.map(([name]) => `--${name}`) : [],
13082
14590
  `--${envelopeFlag(command)}`
13083
14591
  ]
13084
14592
  })),
@@ -13292,7 +14800,7 @@ function callbackPage(ok) {
13292
14800
  // package.json
13293
14801
  var package_default = {
13294
14802
  name: "@onbox/cli",
13295
- version: "0.3.0",
14803
+ version: "0.4.0",
13296
14804
  description: "The onbox command line: the Onbox public API (/v1) from a terminal.",
13297
14805
  keywords: [
13298
14806
  "onbox",
@@ -13895,6 +15403,7 @@ function parseLimit(parsed) {
13895
15403
  }
13896
15404
  async function runCommand(ctx2, command, parsed) {
13897
15405
  const { variant, path, args } = buildInvocation(command, parsed);
15406
+ const trace = command.tool === TRACE_TOOL ? traceOptions(parsed) : void 0;
13898
15407
  const limit = parseLimit(parsed);
13899
15408
  const all = boolFlag(parsed, "all");
13900
15409
  if (limit !== void 0 && all) throw new UsageError("Use --limit or --all, not both");
@@ -13907,8 +15416,8 @@ async function runCommand(ctx2, command, parsed) {
13907
15416
  path,
13908
15417
  ...variant.readsQuery ? { query: encodeQuery(callArgs) } : { body: callArgs }
13909
15418
  });
13910
- const result = await fetchPages(variant, args, { limit, all }, call);
13911
- emit(ctx2, result, boolFlag(parsed, "json"));
15419
+ if (trace) ctx2.stdout(await renderTrace(args, trace, call));
15420
+ else emit(ctx2, await fetchPages(variant, args, { limit, all }, call), boolFlag(parsed, "json"));
13912
15421
  return EXIT.OK;
13913
15422
  }
13914
15423
 
@@ -14347,10 +15856,16 @@ function commandHelp(command) {
14347
15856
  const choices = param.enum ? ` One of: ${param.enum.join(", ")}.` : "";
14348
15857
  return [`--${param.flag}${kind}`, `${firstLine(param.description)}${choices}${required}`];
14349
15858
  });
15859
+ if (command.tool === TRACE_TOOL) {
15860
+ for (const [name2, argument, description] of TRACE_FLAGS) {
15861
+ flags.push([`--${name2}${argument ? ` <${argument}>` : ""}`, description]);
15862
+ }
15863
+ }
14350
15864
  const notes = [
14351
15865
  command.scope === "write" ? "Needs the write scope." : "Needs the read scope.",
14352
15866
  command.destructive ? "Changes or removes data: asks first, or needs --yes without a terminal." : "",
14353
- command.variants.some((variant) => variant.paging) ? "Follows pages with --limit <n> or --all." : ""
15867
+ command.variants.some((variant) => variant.paging) ? "Follows pages with --limit <n> or --all." : "",
15868
+ command.tool === TRACE_TOOL ? "Follows all trace pages and summarizes by default. Plain --json returns one API page with its cursor." : ""
14354
15869
  ].filter(Boolean);
14355
15870
  const name = command.path.join(" ");
14356
15871
  const usage = command.variants.map((variant, index) => {
@@ -14402,18 +15917,24 @@ function childrenOf(path) {
14402
15917
  if (path.length === 0) words.add("help");
14403
15918
  return words;
14404
15919
  }
15920
+ function commandFlags(command) {
15921
+ const booleans = command.params.filter((p) => p.type === "boolean").map((p) => p.flag);
15922
+ const values = command.params.filter((p) => p.type !== "boolean").map((p) => p.flag);
15923
+ values.push(envelopeFlag(command));
15924
+ if (command.tool === TRACE_TOOL) {
15925
+ for (const [name, argument] of TRACE_FLAGS) {
15926
+ const flags = argument ? values : booleans;
15927
+ flags.push(name);
15928
+ }
15929
+ }
15930
+ return flagSpec(booleans, values);
15931
+ }
14405
15932
  async function dispatch(argv2, ctx2) {
14406
15933
  const { path, rest } = splitCommand(argv2, childrenOf);
14407
15934
  if (path[0] === "help") return dispatch([...path.slice(1), ...rest, "--help"], ctx2);
14408
15935
  const builtin = BUILTINS.find((b) => b.path.join(" ") === path.join(" "));
14409
15936
  const command = builtin ? void 0 : commandTree.find(path);
14410
- const spec = builtin ? flagSpec(builtin.booleans, builtin.values) : command ? flagSpec(
14411
- command.params.filter((p) => p.type === "boolean").map((p) => p.flag),
14412
- [
14413
- ...command.params.filter((p) => p.type !== "boolean").map((p) => p.flag),
14414
- envelopeFlag(command)
14415
- ]
14416
- ) : flagSpec(path.length === 0 ? ["version"] : [], []);
15937
+ const spec = builtin ? flagSpec(builtin.booleans, builtin.values) : command ? commandFlags(command) : flagSpec(path.length === 0 ? ["version"] : [], []);
14417
15938
  const parsed = parseFlags(rest, spec);
14418
15939
  if (path.length === 0) {
14419
15940
  if (boolFlag(parsed, "version")) {