@ouispec/contract 0.4.9 → 0.6.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.
@@ -2419,7 +2419,7 @@ export const CONTRACT_SCHEMAS = {
2419
2419
  "$schema": "https://json-schema.org/draft/2020-12/schema",
2420
2420
  "$id": "https://schemas.closurestudio.ai/oui/v1/approvals.json",
2421
2421
  "title": "Approvals",
2422
- "description": "Approvals: the shapes the agent worker, the approval store in the realtime server, the browser's approval card, OUI's surface runtime and a conversation engine exchange. An irreversible action — a `transaction`, or a `write` declared `destructive` — runs only on an approval the person gave, bound to the exact call by a single-use token.\n\n1. The worker stops the turn at the call and stores it (`PendingApprovalInput`); the person's tab receives `agent:approval_required` (`ApprovalRequiredEvent`) and renders the approval card from its `preview`, whose every word comes from the action's declaration, never from the model.\n2. In a UI only a click on the card counts: the card sends `approval:decide` (`ApprovalDecidePayload`) from the person's own socket. On a conversation channel, the verbatim `readback` and an affirmative next turn.\n3. The store answers the decider only (`ApprovalDecideResult`): a single-use token, a compact JWS (`ApprovalTokenClaims`), and the call's `argsHash`. The tab's OUI runtime holds an `ApprovalGrant`.\n4. The next turn carries the token (`ApprovalContinuation`); the worker redeems it for the stored call, exactly (`ApprovedCall`), and runs it. A UI action request then carries `approval` (`ActionRequestApproval`), which the browser checks against its grant before it runs the handler.\n5. When the realtime server holds receipt keys, redemption also returns a receipt (`ApprovalReceiptClaims`): a compact JWS, EdDSA over Ed25519, that the approved host or API call carries to the tool's own API (the `OUI-Approval-Receipt` header). The tool verifies it offline against the realtime server's published keys (`/.well-known/oui-approval-jwks.json`); a UI action gets none.\n\nThe args hash is SHA-256 over the RFC 8785 (JCS) canonical JSON of the call's arguments, lowercase hex; `oui-spec/approval-vectors.json` holds every implementation, in any language, to it.",
2422
+ "description": "Approvals: the shapes the agent worker, the approval store in the realtime server, the browser's approval card, OUI's surface runtime and a conversation engine exchange. An irreversible action — a `transaction`, or a `write` declared `destructive` — runs only on an approval the person gave, bound to the exact call by a single-use token.\n\n1. The worker stops the turn at the call and stores it (`PendingApprovalInput`); the person's tab receives `agent:approval_required` (`ApprovalRequiredEvent`) and renders the approval card from its `preview`, whose every word comes from the action's declaration, never from the model.\n2. In a UI only a click on the card counts: the card sends `approval:decide` (`ApprovalDecidePayload`) from the person's own socket. On a conversation channel, the verbatim `readback` and an affirmative next turn. An action on the person's page is approved by its card, or on `voice`, `phone` and `chat` by its readback and an affirmative next turn: the store then pushes the tab a single-use grant (`ApprovalGrantedEvent`), which one tab claims (`ApprovalClaimPayload`, `ApprovalClaimResult`).\n3. The store answers the decider only (`ApprovalDecideResult`): a single-use token, a compact JWS (`ApprovalTokenClaims`), and the call's `argsHash`. The tab's OUI runtime holds an `ApprovalGrant`: from the click's answer, or from the claimed push.\n4. The next turn carries the token (`ApprovalContinuation`); the worker redeems it for the stored call, exactly (`ApprovedCall`), and runs it. A UI action request then carries `approval` (`ActionRequestApproval`), which the browser checks against its grant before it runs the handler.\n5. When the realtime server holds receipt keys, redemption also returns a receipt (`ApprovalReceiptClaims`): a compact JWS, EdDSA over Ed25519, that the approved host or API call carries to the tool's own API (the `OUI-Approval-Receipt` header). The tool verifies it offline against the realtime server's published keys (`/.well-known/oui-approval-jwks.json`); a UI action gets none.\n\nThe args hash is SHA-256 over the RFC 8785 (JCS) canonical JSON of the call's arguments, lowercase hex; `oui-spec/approval-vectors.json` holds every implementation, in any language, to it.",
2423
2423
  "$defs": {
2424
2424
  "ArgsHash": {
2425
2425
  "description": "SHA-256 of the RFC 8785 canonical JSON of a call's arguments, lowercase hex.",
@@ -2427,7 +2427,7 @@ export const CONTRACT_SCHEMAS = {
2427
2427
  "pattern": "^[0-9a-f]{64}$"
2428
2428
  },
2429
2429
  "ApprovalChannel": {
2430
- "description": "Where the person confirmed. In a UI only a click on the card counts (`ui`); in a conversation channel, the verbatim readback and an affirmative next turn.",
2430
+ "description": "Where the person confirmed. In a UI only a click on the card counts (`ui`); in a conversation channel, the verbatim readback and an affirmative next turn. An action on the person's page is approved by its card, or on `voice`, `phone` and `chat` (`READBACK_UI_APPROVAL_CHANNELS`) by its readback; never by SMS.",
2431
2431
  "enum": [
2432
2432
  "ui",
2433
2433
  "voice",
@@ -2540,6 +2540,11 @@ export const CONTRACT_SCHEMAS = {
2540
2540
  "backend"
2541
2541
  ]
2542
2542
  },
2543
+ "room": {
2544
+ "description": "For an action on the person's page: the realtime room of the turn that asked (its `socketRoom`), where the action is dispatched. When the person approves it by voice or in chat, its grant is pushed to this room and nowhere else. Never set on a host or API tool.",
2545
+ "type": "string",
2546
+ "minLength": 1
2547
+ },
2543
2548
  "operationId": {
2544
2549
  "description": "For a generated API tool, its OpenAPI `operationId`: carried on the call's receipt.",
2545
2550
  "type": "string",
@@ -2656,7 +2661,7 @@ export const CONTRACT_SCHEMAS = {
2656
2661
  "additionalProperties": false
2657
2662
  },
2658
2663
  "ApprovalRefusalReason": {
2659
- "description": "Why an approval was refused:\n\n- `unknown`: no such pending approval: never stored, already declined or redeemed, or expired and gone.\n- `forbidden`: another user's approval, or another conversation's.\n- `expired`.\n- `decided`: already decided.\n- `used`: already redeemed.\n- `invalid`: not a token this environment signed, or malformed.\n- `mismatch`: signed, but not for the stored call.\n- `channel`: a decision from a channel that may not make it.",
2664
+ "description": "Why an approval was refused:\n\n- `unknown`: no such pending approval, or grant: never stored, already declined or redeemed, withdrawn, or expired and gone.\n- `forbidden`: another user's approval, or another conversation's; or a grant claimed from a socket that is not in its room.\n- `expired`.\n- `decided`: already decided.\n- `used`: already redeemed; or a grant another tab has claimed.\n- `invalid`: not a token this environment signed, or malformed.\n- `mismatch`: signed, but not for the stored call.\n- `channel`: a decision from a channel that may not make it: an action on the person's page approved by SMS, or by voice or chat when no room was stored with it.",
2660
2665
  "enum": [
2661
2666
  "unknown",
2662
2667
  "forbidden",
@@ -2754,6 +2759,153 @@ export const CONTRACT_SCHEMAS = {
2754
2759
  }
2755
2760
  ]
2756
2761
  },
2762
+ "ApprovalGrantedEvent": {
2763
+ "description": "`agent:approval_granted`: the person approved an action on their page by voice, on the phone or in chat, after its verbatim readback. The approval store pushes it, in the same step as the decision, to the room stored with the approval and nowhere else; the realtime server's emit API refuses it. A tab whose open conversation is `conversationId` and which is joined to `room` claims it (`approval:claim`); only the first claim is answered with the grant.",
2764
+ "type": "object",
2765
+ "properties": {
2766
+ "approvalId": {
2767
+ "type": "string",
2768
+ "minLength": 1
2769
+ },
2770
+ "grantId": {
2771
+ "description": "This grant, single use: what a claim names.",
2772
+ "type": "string",
2773
+ "minLength": 1
2774
+ },
2775
+ "argsHash": {
2776
+ "description": "The approved call's args hash: what the tab's OUI runtime checks the request's params against.",
2777
+ "$ref": "#/$defs/ArgsHash"
2778
+ },
2779
+ "expiresAt": {
2780
+ "description": "Epoch ms: two minutes after the decision (`APPROVAL_GRANT_TTL_MS`), or the approval's own expiry if sooner. A claim after it is refused, and the runtime admits nothing after it.",
2781
+ "type": "number"
2782
+ },
2783
+ "conversationId": {
2784
+ "type": "string",
2785
+ "minLength": 1
2786
+ },
2787
+ "room": {
2788
+ "description": "The room it was pushed to: that of the turn that asked.",
2789
+ "type": "string",
2790
+ "minLength": 1
2791
+ },
2792
+ "channel": {
2793
+ "description": "Where the person approved it.",
2794
+ "$ref": "#/$defs/ReadbackUIApprovalChannel"
2795
+ },
2796
+ "timestamp": {
2797
+ "type": "number"
2798
+ }
2799
+ },
2800
+ "required": [
2801
+ "approvalId",
2802
+ "grantId",
2803
+ "argsHash",
2804
+ "expiresAt",
2805
+ "conversationId",
2806
+ "room",
2807
+ "channel",
2808
+ "timestamp"
2809
+ ],
2810
+ "additionalProperties": false
2811
+ },
2812
+ "ReadbackUIApprovalChannel": {
2813
+ "description": "The conversation channels on which an action on the person's page is approved by its readback and an affirmative next turn, as well as by its card.",
2814
+ "enum": [
2815
+ "voice",
2816
+ "phone",
2817
+ "chat"
2818
+ ]
2819
+ },
2820
+ "ApprovalDeclinedEvent": {
2821
+ "description": "`agent:approval_declined`: the person declined an action on their page in a conversation channel. Pushed by the approval store to the room stored with the approval, so the card on screen says so. The emit API refuses it.",
2822
+ "type": "object",
2823
+ "properties": {
2824
+ "approvalId": {
2825
+ "type": "string",
2826
+ "minLength": 1
2827
+ },
2828
+ "conversationId": {
2829
+ "type": "string",
2830
+ "minLength": 1
2831
+ },
2832
+ "channel": {
2833
+ "description": "Where the person declined it: a conversation channel.",
2834
+ "enum": [
2835
+ "voice",
2836
+ "phone",
2837
+ "sms",
2838
+ "chat"
2839
+ ]
2840
+ },
2841
+ "timestamp": {
2842
+ "type": "number"
2843
+ }
2844
+ },
2845
+ "required": [
2846
+ "approvalId",
2847
+ "conversationId",
2848
+ "channel",
2849
+ "timestamp"
2850
+ ],
2851
+ "additionalProperties": false
2852
+ },
2853
+ "ApprovalClaimPayload": {
2854
+ "description": "`approval:claim`, from the person's own socket: this tab takes the pushed grant. The store answers only the first claim, from a socket of the approval's user that is in the grant's room, before the grant expires.",
2855
+ "type": "object",
2856
+ "properties": {
2857
+ "approvalId": {
2858
+ "type": "string",
2859
+ "minLength": 1
2860
+ },
2861
+ "grantId": {
2862
+ "type": "string",
2863
+ "minLength": 1
2864
+ }
2865
+ },
2866
+ "required": [
2867
+ "approvalId",
2868
+ "grantId"
2869
+ ],
2870
+ "additionalProperties": false
2871
+ },
2872
+ "ApprovalClaimResult": {
2873
+ "description": "The answer to a claim: the grant, for this tab's OUI runtime (`runtime.grantApproval`), with where the person approved it; or why not. Only one claim of a grant is ever answered with it.",
2874
+ "oneOf": [
2875
+ {
2876
+ "type": "object",
2877
+ "properties": {
2878
+ "ok": {
2879
+ "const": true
2880
+ },
2881
+ "approvalId": {
2882
+ "type": "string"
2883
+ },
2884
+ "argsHash": {
2885
+ "$ref": "#/$defs/ArgsHash"
2886
+ },
2887
+ "expiresAt": {
2888
+ "description": "Epoch ms after which the grant no longer admits anything.",
2889
+ "type": "number"
2890
+ },
2891
+ "channel": {
2892
+ "$ref": "#/$defs/ReadbackUIApprovalChannel"
2893
+ }
2894
+ },
2895
+ "required": [
2896
+ "ok",
2897
+ "approvalId",
2898
+ "argsHash",
2899
+ "expiresAt",
2900
+ "channel"
2901
+ ],
2902
+ "additionalProperties": false
2903
+ },
2904
+ {
2905
+ "$ref": "#/$defs/ApprovalRefusal"
2906
+ }
2907
+ ]
2908
+ },
2757
2909
  "ApprovalTokenClaims": {
2758
2910
  "description": "The token's claims: a compact JWS (HS256), signed with the environment's approval key.",
2759
2911
  "type": "object",
@@ -3042,7 +3194,7 @@ export const CONTRACT_SCHEMAS = {
3042
3194
  ]
3043
3195
  },
3044
3196
  "ActionRequestApproval": {
3045
- "description": "What a UI action request carries when it runs an approved call (`OUIActionApproval`): the browser runs a `transaction` or destructive action only when this matches a grant this tab received from its own card click.",
3197
+ "description": "What a UI action request carries when it runs an approved call (`OUIActionApproval`): the browser runs a `transaction` or destructive action only when this matches a grant this tab received from its own card click, or claimed from the push of an approval given by voice or in chat.",
3046
3198
  "type": "object",
3047
3199
  "properties": {
3048
3200
  "approvalId": {
@@ -3060,7 +3212,7 @@ export const CONTRACT_SCHEMAS = {
3060
3212
  "additionalProperties": false
3061
3213
  },
3062
3214
  "ApprovalGrant": {
3063
- "description": "What the person's approval click gives this tab's OUI runtime (`runtime.grantApproval`, `OUIApprovalGrant`): the request it approved, until it expires.",
3215
+ "description": "What this tab's OUI runtime holds (`runtime.grantApproval`, `OUIApprovalGrant`): the request the person approved, from their click on the card or from a claimed push, until it expires.",
3064
3216
  "type": "object",
3065
3217
  "properties": {
3066
3218
  "approvalId": {
@@ -3286,7 +3438,7 @@ export const CONTRACT_SCHEMAS = {
3286
3438
  "pattern": "^[A-Z][A-Za-z0-9]*$"
3287
3439
  },
3288
3440
  "rooms": {
3289
- "description": "The rooms the event is published to: names from the document's `rooms`, or `turn` for the room of the agent turn it belongs to (the host names that room in each turn).",
3441
+ "description": "The rooms the event is published to: names from the document's `rooms`; `turn` for the room of the agent turn it belongs to (the host names that room in each turn); or `conversation` for the room of the conversation it belongs to (the host names that room too).",
3290
3442
  "type": "array",
3291
3443
  "items": {
3292
3444
  "type": "string",
@@ -3399,6 +3551,846 @@ export const CONTRACT_SCHEMAS = {
3399
3551
  }
3400
3552
  }
3401
3553
  },
3554
+ 'conversation-takeover.json': {
3555
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3556
+ "$id": "https://schemas.closurestudio.ai/oui/v1/conversation-takeover.json",
3557
+ "title": "Conversation takeover",
3558
+ "description": "A person on the product's staff takes a live conversation from the agent, answers the customer as themselves, and hands it back: the shapes the realtime server, the agent worker, the product's API, the customer's tab and the staff console exchange.\n\n1. The product's own route checks that this person may take this conversation, then asks the realtime server to hold it (`POST /internal/conversations/{id}/hold`, `TakeOverRequest`). The server keeps one `ConversationHold`, stops any turn of the conversation that is running, and sends `agent:conversation_taken_over` (`ConversationTakenOverEvent`) to the conversation's room.\n2. While the conversation is held, the agent does not answer: a turn that arrives is not run by the model.\n3. The person's messages are stored by the product with `role: 'staff'` and their speaker, and announced (`POST /internal/conversations/{id}/messages`, `AnnounceMessageRequest`) as `agent:conversation_message` (`ConversationMessageEvent`), only while they hold the conversation.\n4. The holder, or the product on its own authority, hands it back (`POST /internal/conversations/{id}/hold/release`, `HandBackRequest`); `agent:conversation_handed_back` (`ConversationHandedBackEvent`) follows, and the agent's next turn reads the whole exchange in its history.\n\nThe realtime server never decides who may take over: its routes take the internal key, and the product calls them after its own check, as it does before it asks for a room token.",
3559
+ "$defs": {
3560
+ "StaffSpeaker": {
3561
+ "description": "A person on the product's staff, as the conversation names them. `displayName` and `role` are shown to the customer; `userId` is what a hand-back and a staff message are checked against. It reaches the customer's tab, so name an id you are content to show (an opaque staff id).",
3562
+ "type": "object",
3563
+ "properties": {
3564
+ "userId": {
3565
+ "description": "The staff member's id, as the product's realtime identity names them.",
3566
+ "type": "string",
3567
+ "minLength": 1,
3568
+ "maxLength": 200
3569
+ },
3570
+ "displayName": {
3571
+ "description": "The name the customer sees (\"Jordan\").",
3572
+ "type": "string",
3573
+ "minLength": 1,
3574
+ "maxLength": 80
3575
+ },
3576
+ "role": {
3577
+ "description": "What the customer sees beside the name (\"Toyota of Quillhaven sales\").",
3578
+ "type": "string",
3579
+ "minLength": 1,
3580
+ "maxLength": 80
3581
+ }
3582
+ },
3583
+ "required": [
3584
+ "userId",
3585
+ "displayName"
3586
+ ],
3587
+ "additionalProperties": false
3588
+ },
3589
+ "ConversationHold": {
3590
+ "description": "A conversation a person holds: the agent does not answer it until it is handed back. One holder at a time.",
3591
+ "type": "object",
3592
+ "properties": {
3593
+ "conversationId": {
3594
+ "type": "string",
3595
+ "minLength": 1
3596
+ },
3597
+ "holder": {
3598
+ "$ref": "#/$defs/StaffSpeaker"
3599
+ },
3600
+ "since": {
3601
+ "description": "When it was taken, epoch ms by the realtime server's clock.",
3602
+ "type": "number"
3603
+ }
3604
+ },
3605
+ "required": [
3606
+ "conversationId",
3607
+ "holder",
3608
+ "since"
3609
+ ],
3610
+ "additionalProperties": false
3611
+ },
3612
+ "TakeoverChange": {
3613
+ "description": "A conversation changing hands, as its stored entry and its event say: `taken_over` by a person, `handed_back` to the agent.",
3614
+ "enum": [
3615
+ "taken_over",
3616
+ "handed_back"
3617
+ ]
3618
+ },
3619
+ "HandBackCause": {
3620
+ "description": "Who ended a hold: the person who held it (`holder`), or the product on its own authority (`product`: an idle policy, a manager, the end of a shift).",
3621
+ "enum": [
3622
+ "holder",
3623
+ "product"
3624
+ ]
3625
+ },
3626
+ "ConversationMessageRole": {
3627
+ "description": "Who wrote a message of the conversation: the customer (`user`), the agent (`assistant`), or a person on the staff (`staff`).",
3628
+ "enum": [
3629
+ "user",
3630
+ "assistant",
3631
+ "staff"
3632
+ ]
3633
+ },
3634
+ "ConversationMessage": {
3635
+ "description": "A stored message of the conversation, as it is announced to the people watching it.",
3636
+ "type": "object",
3637
+ "properties": {
3638
+ "id": {
3639
+ "description": "The product's id for the stored message.",
3640
+ "type": "string",
3641
+ "minLength": 1,
3642
+ "maxLength": 200
3643
+ },
3644
+ "role": {
3645
+ "$ref": "#/$defs/ConversationMessageRole"
3646
+ },
3647
+ "content": {
3648
+ "type": "string",
3649
+ "maxLength": 100000
3650
+ },
3651
+ "createdAt": {
3652
+ "description": "When it was stored, ISO 8601.",
3653
+ "type": "string",
3654
+ "minLength": 1
3655
+ },
3656
+ "speaker": {
3657
+ "description": "Set on a `staff` message: who wrote it.",
3658
+ "$ref": "#/$defs/StaffSpeaker"
3659
+ }
3660
+ },
3661
+ "required": [
3662
+ "id",
3663
+ "role",
3664
+ "content",
3665
+ "createdAt"
3666
+ ],
3667
+ "additionalProperties": false
3668
+ },
3669
+ "ConversationRooms": {
3670
+ "description": "Where a conversation's event goes: the conversation's room, which the product names and guards with a room token, and any of the product's own (a team's board).",
3671
+ "type": "array",
3672
+ "items": {
3673
+ "type": "string",
3674
+ "minLength": 1
3675
+ },
3676
+ "minItems": 1,
3677
+ "maxItems": 5,
3678
+ "uniqueItems": true
3679
+ },
3680
+ "TakeOverRequest": {
3681
+ "description": "`POST /internal/conversations/{conversationId}/hold`, from the product's API after its own check that this person may take this conversation.",
3682
+ "type": "object",
3683
+ "properties": {
3684
+ "holder": {
3685
+ "$ref": "#/$defs/StaffSpeaker"
3686
+ },
3687
+ "rooms": {
3688
+ "$ref": "#/$defs/ConversationRooms"
3689
+ }
3690
+ },
3691
+ "required": [
3692
+ "holder",
3693
+ "rooms"
3694
+ ],
3695
+ "additionalProperties": false
3696
+ },
3697
+ "TakeOverResult": {
3698
+ "description": "The answer to a take-over: `taken_over` the first time, with the approvals it withdrew; `already` when this holder had it; 409 `held` when someone else holds it.",
3699
+ "oneOf": [
3700
+ {
3701
+ "type": "object",
3702
+ "properties": {
3703
+ "ok": {
3704
+ "const": true
3705
+ },
3706
+ "change": {
3707
+ "enum": [
3708
+ "taken_over",
3709
+ "already"
3710
+ ]
3711
+ },
3712
+ "hold": {
3713
+ "$ref": "#/$defs/ConversationHold"
3714
+ },
3715
+ "withdrawn": {
3716
+ "description": "On `taken_over`: the ids of the conversation's approvals that were waiting, or approved and not yet used, and are now withdrawn (`taken_over`), since the person now answering asked for none of them. Empty when there were none.",
3717
+ "type": "array",
3718
+ "items": {
3719
+ "type": "string"
3720
+ }
3721
+ }
3722
+ },
3723
+ "required": [
3724
+ "ok",
3725
+ "change",
3726
+ "hold"
3727
+ ],
3728
+ "additionalProperties": false
3729
+ },
3730
+ {
3731
+ "type": "object",
3732
+ "properties": {
3733
+ "ok": {
3734
+ "const": false
3735
+ },
3736
+ "reason": {
3737
+ "const": "held"
3738
+ },
3739
+ "hold": {
3740
+ "$ref": "#/$defs/ConversationHold"
3741
+ }
3742
+ },
3743
+ "required": [
3744
+ "ok",
3745
+ "reason",
3746
+ "hold"
3747
+ ],
3748
+ "additionalProperties": false
3749
+ }
3750
+ ]
3751
+ },
3752
+ "HandBackRequest": {
3753
+ "description": "`POST /internal/conversations/{conversationId}/hold/release`. With `userId`, only the holder may hand it back; without it, the product releases it on its own authority.",
3754
+ "type": "object",
3755
+ "properties": {
3756
+ "userId": {
3757
+ "description": "The staff member handing it back; must be the holder.",
3758
+ "type": "string",
3759
+ "minLength": 1
3760
+ },
3761
+ "rooms": {
3762
+ "$ref": "#/$defs/ConversationRooms"
3763
+ }
3764
+ },
3765
+ "required": [
3766
+ "rooms"
3767
+ ],
3768
+ "additionalProperties": false
3769
+ },
3770
+ "HandBackResult": {
3771
+ "description": "The answer to a hand-back: `handed_back` with the hold that ended, `not_held` when nobody held it; 409 `not_holder` when someone else holds it.",
3772
+ "oneOf": [
3773
+ {
3774
+ "type": "object",
3775
+ "properties": {
3776
+ "ok": {
3777
+ "const": true
3778
+ },
3779
+ "change": {
3780
+ "const": "handed_back"
3781
+ },
3782
+ "hold": {
3783
+ "$ref": "#/$defs/ConversationHold"
3784
+ },
3785
+ "by": {
3786
+ "$ref": "#/$defs/HandBackCause"
3787
+ }
3788
+ },
3789
+ "required": [
3790
+ "ok",
3791
+ "change",
3792
+ "hold",
3793
+ "by"
3794
+ ],
3795
+ "additionalProperties": false
3796
+ },
3797
+ {
3798
+ "type": "object",
3799
+ "properties": {
3800
+ "ok": {
3801
+ "const": true
3802
+ },
3803
+ "change": {
3804
+ "const": "not_held"
3805
+ }
3806
+ },
3807
+ "required": [
3808
+ "ok",
3809
+ "change"
3810
+ ],
3811
+ "additionalProperties": false
3812
+ },
3813
+ {
3814
+ "type": "object",
3815
+ "properties": {
3816
+ "ok": {
3817
+ "const": false
3818
+ },
3819
+ "reason": {
3820
+ "const": "not_holder"
3821
+ },
3822
+ "hold": {
3823
+ "$ref": "#/$defs/ConversationHold"
3824
+ }
3825
+ },
3826
+ "required": [
3827
+ "ok",
3828
+ "reason",
3829
+ "hold"
3830
+ ],
3831
+ "additionalProperties": false
3832
+ }
3833
+ ]
3834
+ },
3835
+ "AnnounceMessageRequest": {
3836
+ "description": "`POST /internal/conversations/{conversationId}/messages`: a message the product has stored, for the people watching the conversation. A `staff` message is announced only while its speaker holds the conversation.",
3837
+ "type": "object",
3838
+ "properties": {
3839
+ "message": {
3840
+ "$ref": "#/$defs/ConversationMessage"
3841
+ },
3842
+ "rooms": {
3843
+ "$ref": "#/$defs/ConversationRooms"
3844
+ }
3845
+ },
3846
+ "required": [
3847
+ "message",
3848
+ "rooms"
3849
+ ],
3850
+ "additionalProperties": false
3851
+ },
3852
+ "AnnounceMessageResult": {
3853
+ "description": "The answer to an announcement: sent, or 409 because its staff speaker does not hold the conversation (`not_held`: nobody does; `not_holder`: someone else does).",
3854
+ "oneOf": [
3855
+ {
3856
+ "type": "object",
3857
+ "properties": {
3858
+ "ok": {
3859
+ "const": true
3860
+ }
3861
+ },
3862
+ "required": [
3863
+ "ok"
3864
+ ],
3865
+ "additionalProperties": false
3866
+ },
3867
+ {
3868
+ "type": "object",
3869
+ "properties": {
3870
+ "ok": {
3871
+ "const": false
3872
+ },
3873
+ "reason": {
3874
+ "enum": [
3875
+ "not_held",
3876
+ "not_holder"
3877
+ ]
3878
+ }
3879
+ },
3880
+ "required": [
3881
+ "ok",
3882
+ "reason"
3883
+ ],
3884
+ "additionalProperties": false
3885
+ }
3886
+ ]
3887
+ },
3888
+ "ConversationTakenOverEvent": {
3889
+ "description": "`agent:conversation_taken_over`, to the conversation's room: a person took it, and the agent stopped answering.",
3890
+ "type": "object",
3891
+ "properties": {
3892
+ "conversationId": {
3893
+ "type": "string",
3894
+ "minLength": 1
3895
+ },
3896
+ "hold": {
3897
+ "$ref": "#/$defs/ConversationHold"
3898
+ },
3899
+ "at": {
3900
+ "description": "Epoch ms.",
3901
+ "type": "number"
3902
+ }
3903
+ },
3904
+ "required": [
3905
+ "conversationId",
3906
+ "hold",
3907
+ "at"
3908
+ ],
3909
+ "additionalProperties": false
3910
+ },
3911
+ "ConversationHandedBackEvent": {
3912
+ "description": "`agent:conversation_handed_back`, to the conversation's room: the hold ended, and the agent answers again.",
3913
+ "type": "object",
3914
+ "properties": {
3915
+ "conversationId": {
3916
+ "type": "string",
3917
+ "minLength": 1
3918
+ },
3919
+ "hold": {
3920
+ "description": "The hold that ended.",
3921
+ "$ref": "#/$defs/ConversationHold"
3922
+ },
3923
+ "by": {
3924
+ "$ref": "#/$defs/HandBackCause"
3925
+ },
3926
+ "at": {
3927
+ "description": "Epoch ms.",
3928
+ "type": "number"
3929
+ }
3930
+ },
3931
+ "required": [
3932
+ "conversationId",
3933
+ "hold",
3934
+ "by",
3935
+ "at"
3936
+ ],
3937
+ "additionalProperties": false
3938
+ },
3939
+ "ConversationMessageEvent": {
3940
+ "description": "`agent:conversation_message`, to the conversation's room: a message the product stored, for the people watching.",
3941
+ "type": "object",
3942
+ "properties": {
3943
+ "conversationId": {
3944
+ "type": "string",
3945
+ "minLength": 1
3946
+ },
3947
+ "message": {
3948
+ "$ref": "#/$defs/ConversationMessage"
3949
+ },
3950
+ "at": {
3951
+ "description": "Epoch ms.",
3952
+ "type": "number"
3953
+ }
3954
+ },
3955
+ "required": [
3956
+ "conversationId",
3957
+ "message",
3958
+ "at"
3959
+ ],
3960
+ "additionalProperties": false
3961
+ }
3962
+ }
3963
+ },
3964
+ 'agent-evals.json': {
3965
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3966
+ "$id": "https://schemas.closurestudio.ai/oui/v1/agent-evals.json",
3967
+ "title": "AgentEvalSuite",
3968
+ "description": "A suite of agent eval scenarios, written as data: what a customer says, turn by turn, and what must hold after each turn. `@ouispec/agent-evals` runs every scenario on every channel the suite names, against the product's real agent configuration (persona, tools, tool policy, turn policy), from recorded model responses in CI or against the live model, and fails on any assertion that does not hold.",
3969
+ "type": "object",
3970
+ "properties": {
3971
+ "version": {
3972
+ "description": "The suite format's version.",
3973
+ "const": 1
3974
+ },
3975
+ "name": {
3976
+ "description": "The suite's name, as reports show it.",
3977
+ "type": "string",
3978
+ "minLength": 1,
3979
+ "maxLength": 120
3980
+ },
3981
+ "description": {
3982
+ "type": "string"
3983
+ },
3984
+ "channels": {
3985
+ "description": "The channels every scenario runs on, as the eval configuration names them (`web_chat`, `sms`, `voice`). Default: every channel the configuration names.",
3986
+ "$ref": "#/$defs/AgentEvalChannelList"
3987
+ },
3988
+ "context": {
3989
+ "description": "What every turn of every scenario carries as its context, before the channel's and the scenario's own.",
3990
+ "type": "object",
3991
+ "additionalProperties": true
3992
+ },
3993
+ "stubs": {
3994
+ "description": "What each tool returns, for every scenario; a scenario's own stubs come first.",
3995
+ "$ref": "#/$defs/AgentEvalStubs"
3996
+ },
3997
+ "scenarios": {
3998
+ "type": "array",
3999
+ "items": {
4000
+ "$ref": "#/$defs/AgentEvalScenario"
4001
+ },
4002
+ "minItems": 1
4003
+ }
4004
+ },
4005
+ "required": [
4006
+ "version",
4007
+ "name",
4008
+ "scenarios"
4009
+ ],
4010
+ "additionalProperties": false,
4011
+ "$defs": {
4012
+ "AgentEvalChannelList": {
4013
+ "description": "Channel names, as the eval configuration names them.",
4014
+ "type": "array",
4015
+ "items": {
4016
+ "type": "string",
4017
+ "pattern": "^[a-z][a-z0-9_-]*$"
4018
+ },
4019
+ "minItems": 1,
4020
+ "uniqueItems": true
4021
+ },
4022
+ "AgentEvalScenario": {
4023
+ "description": "One conversation: its turns in order, and what must hold after each.",
4024
+ "type": "object",
4025
+ "properties": {
4026
+ "id": {
4027
+ "description": "Unique in the suite; names its recordings.",
4028
+ "type": "string",
4029
+ "pattern": "^[a-z0-9][a-z0-9_-]*$",
4030
+ "maxLength": 80
4031
+ },
4032
+ "title": {
4033
+ "description": "What it shows, as reports name it.",
4034
+ "type": "string",
4035
+ "minLength": 1
4036
+ },
4037
+ "description": {
4038
+ "type": "string"
4039
+ },
4040
+ "channels": {
4041
+ "description": "The suite's channels this scenario runs on, when not all of them.",
4042
+ "$ref": "#/$defs/AgentEvalChannelList"
4043
+ },
4044
+ "context": {
4045
+ "description": "What each of its turns carries as its context, after the suite's and the channel's.",
4046
+ "type": "object",
4047
+ "additionalProperties": true
4048
+ },
4049
+ "stubs": {
4050
+ "description": "What each tool returns in this scenario, before the suite's stubs.",
4051
+ "$ref": "#/$defs/AgentEvalStubs"
4052
+ },
4053
+ "turns": {
4054
+ "type": "array",
4055
+ "items": {
4056
+ "$ref": "#/$defs/AgentEvalTurn"
4057
+ },
4058
+ "minItems": 1
4059
+ }
4060
+ },
4061
+ "required": [
4062
+ "id",
4063
+ "title",
4064
+ "turns"
4065
+ ],
4066
+ "additionalProperties": false
4067
+ },
4068
+ "AgentEvalTurn": {
4069
+ "description": "One step of a scenario: the customer says something, answers the waiting approval, or a person on the staff acts.",
4070
+ "oneOf": [
4071
+ {
4072
+ "$ref": "#/$defs/AgentEvalUserTurn"
4073
+ },
4074
+ {
4075
+ "$ref": "#/$defs/AgentEvalApprovalTurn"
4076
+ },
4077
+ {
4078
+ "$ref": "#/$defs/AgentEvalStaffTurn"
4079
+ }
4080
+ ]
4081
+ },
4082
+ "AgentEvalUserTurn": {
4083
+ "description": "The customer's message: the agent's turn runs, and its expectations are checked.",
4084
+ "type": "object",
4085
+ "properties": {
4086
+ "user": {
4087
+ "type": "string",
4088
+ "minLength": 1
4089
+ },
4090
+ "expect": {
4091
+ "$ref": "#/$defs/AgentEvalExpectation"
4092
+ },
4093
+ "expectOn": {
4094
+ "$ref": "#/$defs/AgentEvalExpectationsByChannel"
4095
+ }
4096
+ },
4097
+ "required": [
4098
+ "user"
4099
+ ],
4100
+ "additionalProperties": false
4101
+ },
4102
+ "AgentEvalApprovalTurn": {
4103
+ "description": "The customer's answer to the approval the last turn stopped at, decided on the channel's approval channel (the card on `ui`; the readback and an affirmative message on a conversation channel). The continuation turn runs, and its expectations are checked.",
4104
+ "type": "object",
4105
+ "properties": {
4106
+ "approval": {
4107
+ "enum": [
4108
+ "approve",
4109
+ "decline"
4110
+ ]
4111
+ },
4112
+ "expect": {
4113
+ "$ref": "#/$defs/AgentEvalExpectation"
4114
+ },
4115
+ "expectOn": {
4116
+ "$ref": "#/$defs/AgentEvalExpectationsByChannel"
4117
+ }
4118
+ },
4119
+ "required": [
4120
+ "approval"
4121
+ ],
4122
+ "additionalProperties": false
4123
+ },
4124
+ "AgentEvalStaffTurn": {
4125
+ "description": "A person on the staff takes the conversation over, writes to the customer, or hands it back. No agent turn runs.",
4126
+ "type": "object",
4127
+ "properties": {
4128
+ "staff": {
4129
+ "oneOf": [
4130
+ {
4131
+ "type": "object",
4132
+ "properties": {
4133
+ "takeOver": {
4134
+ "type": "object",
4135
+ "properties": {
4136
+ "displayName": {
4137
+ "type": "string",
4138
+ "minLength": 1,
4139
+ "maxLength": 80
4140
+ },
4141
+ "role": {
4142
+ "type": "string",
4143
+ "minLength": 1,
4144
+ "maxLength": 80
4145
+ },
4146
+ "userId": {
4147
+ "description": "Default: `staff-` and the display name.",
4148
+ "type": "string",
4149
+ "minLength": 1
4150
+ }
4151
+ },
4152
+ "required": [
4153
+ "displayName"
4154
+ ],
4155
+ "additionalProperties": false
4156
+ }
4157
+ },
4158
+ "required": [
4159
+ "takeOver"
4160
+ ],
4161
+ "additionalProperties": false
4162
+ },
4163
+ {
4164
+ "type": "object",
4165
+ "properties": {
4166
+ "say": {
4167
+ "type": "string",
4168
+ "minLength": 1
4169
+ }
4170
+ },
4171
+ "required": [
4172
+ "say"
4173
+ ],
4174
+ "additionalProperties": false
4175
+ },
4176
+ {
4177
+ "type": "object",
4178
+ "properties": {
4179
+ "handBack": {
4180
+ "const": true
4181
+ }
4182
+ },
4183
+ "required": [
4184
+ "handBack"
4185
+ ],
4186
+ "additionalProperties": false
4187
+ }
4188
+ ]
4189
+ }
4190
+ },
4191
+ "required": [
4192
+ "staff"
4193
+ ],
4194
+ "additionalProperties": false
4195
+ },
4196
+ "AgentEvalTextMatcher": {
4197
+ "description": "What a reply's text is matched against: a string, found anywhere in it, ignoring case; a regular expression (`pattern`, with `flags`); or a `rubric`, which a judge model decides.",
4198
+ "oneOf": [
4199
+ {
4200
+ "type": "string",
4201
+ "minLength": 1
4202
+ },
4203
+ {
4204
+ "type": "object",
4205
+ "properties": {
4206
+ "pattern": {
4207
+ "type": "string",
4208
+ "minLength": 1
4209
+ },
4210
+ "flags": {
4211
+ "description": "Regular-expression flags among `i`, `m`, `s` and `u`.",
4212
+ "type": "string",
4213
+ "pattern": "^[imsu]*$"
4214
+ }
4215
+ },
4216
+ "required": [
4217
+ "pattern"
4218
+ ],
4219
+ "additionalProperties": false
4220
+ },
4221
+ {
4222
+ "type": "object",
4223
+ "properties": {
4224
+ "rubric": {
4225
+ "description": "What the reply must do, in a sentence a judge reads.",
4226
+ "type": "string",
4227
+ "minLength": 1
4228
+ }
4229
+ },
4230
+ "required": [
4231
+ "rubric"
4232
+ ],
4233
+ "additionalProperties": false
4234
+ }
4235
+ ]
4236
+ },
4237
+ "AgentEvalToolCall": {
4238
+ "description": "A tool the agent called: its name, and arguments its call holds (a subset: every key given, with an equal value; nested objects as subsets too).",
4239
+ "type": "object",
4240
+ "properties": {
4241
+ "name": {
4242
+ "type": "string",
4243
+ "minLength": 1
4244
+ },
4245
+ "args": {
4246
+ "type": "object",
4247
+ "additionalProperties": true
4248
+ }
4249
+ },
4250
+ "required": [
4251
+ "name"
4252
+ ],
4253
+ "additionalProperties": false
4254
+ },
4255
+ "AgentEvalApprovalExpectation": {
4256
+ "description": "The turn stopped at a call that needs the customer's approval, with a readback present.",
4257
+ "type": "object",
4258
+ "properties": {
4259
+ "tool": {
4260
+ "type": "string",
4261
+ "minLength": 1
4262
+ },
4263
+ "args": {
4264
+ "description": "A subset of the call's arguments.",
4265
+ "type": "object",
4266
+ "additionalProperties": true
4267
+ },
4268
+ "readback": {
4269
+ "description": "What the readback must say.",
4270
+ "$ref": "#/$defs/AgentEvalTextMatcher"
4271
+ }
4272
+ },
4273
+ "additionalProperties": false
4274
+ },
4275
+ "AgentEvalExpectation": {
4276
+ "description": "What must hold after a turn. Every field given must hold.",
4277
+ "type": "object",
4278
+ "properties": {
4279
+ "says": {
4280
+ "description": "Each must match the reply.",
4281
+ "type": "array",
4282
+ "items": {
4283
+ "$ref": "#/$defs/AgentEvalTextMatcher"
4284
+ }
4285
+ },
4286
+ "mustNotSay": {
4287
+ "description": "None may match the reply.",
4288
+ "type": "array",
4289
+ "items": {
4290
+ "$ref": "#/$defs/AgentEvalTextMatcher"
4291
+ }
4292
+ },
4293
+ "toolCalled": {
4294
+ "description": "Each was called, with these arguments.",
4295
+ "type": "array",
4296
+ "items": {
4297
+ "$ref": "#/$defs/AgentEvalToolCall"
4298
+ }
4299
+ },
4300
+ "toolNotCalled": {
4301
+ "description": "None of these was called; `*` means no tool at all.",
4302
+ "type": "array",
4303
+ "items": {
4304
+ "type": "string",
4305
+ "minLength": 1
4306
+ }
4307
+ },
4308
+ "approvalRequested": {
4309
+ "description": "The turn stopped for the customer's approval of this call; `false`: it did not stop for any.",
4310
+ "oneOf": [
4311
+ {
4312
+ "const": false
4313
+ },
4314
+ {
4315
+ "$ref": "#/$defs/AgentEvalApprovalExpectation"
4316
+ }
4317
+ ]
4318
+ },
4319
+ "refusal": {
4320
+ "description": "The reply declines: `true` for the usual phrasing of a refusal (can't, cannot, unable, not able, won't, not allowed), or a matcher for the agent's own words.",
4321
+ "oneOf": [
4322
+ {
4323
+ "const": true
4324
+ },
4325
+ {
4326
+ "$ref": "#/$defs/AgentEvalTextMatcher"
4327
+ }
4328
+ ]
4329
+ },
4330
+ "doesNotStore": {
4331
+ "description": "None of these appears in anything the turn stored: its text, its tool calls' arguments, its tool results.",
4332
+ "type": "array",
4333
+ "items": {
4334
+ "$ref": "#/$defs/AgentEvalTextMatcher"
4335
+ }
4336
+ },
4337
+ "held": {
4338
+ "description": "`true`: the turn ran no model call, because a person held the conversation.",
4339
+ "type": "boolean"
4340
+ }
4341
+ },
4342
+ "additionalProperties": false
4343
+ },
4344
+ "AgentEvalExpectationsByChannel": {
4345
+ "description": "What must also hold on one channel, by its name.",
4346
+ "type": "object",
4347
+ "additionalProperties": {
4348
+ "$ref": "#/$defs/AgentEvalExpectation"
4349
+ }
4350
+ },
4351
+ "AgentEvalStubCase": {
4352
+ "description": "What a tool returns when it is called with arguments that hold `when` (a subset; absent: any call).",
4353
+ "type": "object",
4354
+ "properties": {
4355
+ "when": {
4356
+ "type": "object",
4357
+ "additionalProperties": true
4358
+ },
4359
+ "result": {
4360
+ "type": "object",
4361
+ "properties": {
4362
+ "success": {
4363
+ "type": "boolean"
4364
+ },
4365
+ "data": {},
4366
+ "error": {
4367
+ "type": "string"
4368
+ }
4369
+ },
4370
+ "required": [
4371
+ "success"
4372
+ ],
4373
+ "additionalProperties": false
4374
+ }
4375
+ },
4376
+ "required": [
4377
+ "result"
4378
+ ],
4379
+ "additionalProperties": false
4380
+ },
4381
+ "AgentEvalStubs": {
4382
+ "description": "What each tool returns, by tool name: its cases in order, the first that matches the call wins. A call to a tool with no matching case fails the scenario: an eval never reaches a real backend.",
4383
+ "type": "object",
4384
+ "additionalProperties": {
4385
+ "type": "array",
4386
+ "items": {
4387
+ "$ref": "#/$defs/AgentEvalStubCase"
4388
+ },
4389
+ "minItems": 1
4390
+ }
4391
+ }
4392
+ }
4393
+ },
3402
4394
  };
3403
4395
  /**
3404
4396
  * Each generated type, by name, and the schema it is generated from (`file`, or
@@ -3479,6 +4471,11 @@ export const CONTRACT_TYPES = {
3479
4471
  ApprovalRefusalReason: 'approvals.json#/$defs/ApprovalRefusalReason',
3480
4472
  ApprovalRefusal: 'approvals.json#/$defs/ApprovalRefusal',
3481
4473
  ApprovalDecideResult: 'approvals.json#/$defs/ApprovalDecideResult',
4474
+ ApprovalGrantedEvent: 'approvals.json#/$defs/ApprovalGrantedEvent',
4475
+ ReadbackUIApprovalChannel: 'approvals.json#/$defs/ReadbackUIApprovalChannel',
4476
+ ApprovalDeclinedEvent: 'approvals.json#/$defs/ApprovalDeclinedEvent',
4477
+ ApprovalClaimPayload: 'approvals.json#/$defs/ApprovalClaimPayload',
4478
+ ApprovalClaimResult: 'approvals.json#/$defs/ApprovalClaimResult',
3482
4479
  ApprovalTokenClaims: 'approvals.json#/$defs/ApprovalTokenClaims',
3483
4480
  ApprovalReceiptClaims: 'approvals.json#/$defs/ApprovalReceiptClaims',
3484
4481
  ApprovedCall: 'approvals.json#/$defs/ApprovedCall',
@@ -3494,5 +4491,35 @@ export const CONTRACT_TYPES = {
3494
4491
  EventRole: 'event-declarations.json#/$defs/EventRole',
3495
4492
  FailureReason: 'event-declarations.json#/$defs/FailureReason',
3496
4493
  EventDeclaration: 'event-declarations.json#/$defs/EventDeclaration',
4494
+ StaffSpeaker: 'conversation-takeover.json#/$defs/StaffSpeaker',
4495
+ ConversationHold: 'conversation-takeover.json#/$defs/ConversationHold',
4496
+ TakeoverChange: 'conversation-takeover.json#/$defs/TakeoverChange',
4497
+ HandBackCause: 'conversation-takeover.json#/$defs/HandBackCause',
4498
+ ConversationMessageRole: 'conversation-takeover.json#/$defs/ConversationMessageRole',
4499
+ ConversationMessage: 'conversation-takeover.json#/$defs/ConversationMessage',
4500
+ ConversationRooms: 'conversation-takeover.json#/$defs/ConversationRooms',
4501
+ TakeOverRequest: 'conversation-takeover.json#/$defs/TakeOverRequest',
4502
+ TakeOverResult: 'conversation-takeover.json#/$defs/TakeOverResult',
4503
+ HandBackRequest: 'conversation-takeover.json#/$defs/HandBackRequest',
4504
+ HandBackResult: 'conversation-takeover.json#/$defs/HandBackResult',
4505
+ AnnounceMessageRequest: 'conversation-takeover.json#/$defs/AnnounceMessageRequest',
4506
+ AnnounceMessageResult: 'conversation-takeover.json#/$defs/AnnounceMessageResult',
4507
+ ConversationTakenOverEvent: 'conversation-takeover.json#/$defs/ConversationTakenOverEvent',
4508
+ ConversationHandedBackEvent: 'conversation-takeover.json#/$defs/ConversationHandedBackEvent',
4509
+ ConversationMessageEvent: 'conversation-takeover.json#/$defs/ConversationMessageEvent',
4510
+ AgentEvalSuite: 'agent-evals.json',
4511
+ AgentEvalChannelList: 'agent-evals.json#/$defs/AgentEvalChannelList',
4512
+ AgentEvalScenario: 'agent-evals.json#/$defs/AgentEvalScenario',
4513
+ AgentEvalTurn: 'agent-evals.json#/$defs/AgentEvalTurn',
4514
+ AgentEvalUserTurn: 'agent-evals.json#/$defs/AgentEvalUserTurn',
4515
+ AgentEvalApprovalTurn: 'agent-evals.json#/$defs/AgentEvalApprovalTurn',
4516
+ AgentEvalStaffTurn: 'agent-evals.json#/$defs/AgentEvalStaffTurn',
4517
+ AgentEvalTextMatcher: 'agent-evals.json#/$defs/AgentEvalTextMatcher',
4518
+ AgentEvalToolCall: 'agent-evals.json#/$defs/AgentEvalToolCall',
4519
+ AgentEvalApprovalExpectation: 'agent-evals.json#/$defs/AgentEvalApprovalExpectation',
4520
+ AgentEvalExpectation: 'agent-evals.json#/$defs/AgentEvalExpectation',
4521
+ AgentEvalExpectationsByChannel: 'agent-evals.json#/$defs/AgentEvalExpectationsByChannel',
4522
+ AgentEvalStubCase: 'agent-evals.json#/$defs/AgentEvalStubCase',
4523
+ AgentEvalStubs: 'agent-evals.json#/$defs/AgentEvalStubs',
3497
4524
  };
3498
4525
  //# sourceMappingURL=schemas.js.map